tempo.ts 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -0
- package/dist/chains.d.ts +1477 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +43 -0
- package/dist/chains.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/types.d.ts +284 -0
- package/dist/internal/types.d.ts.map +1 -0
- package/dist/internal/types.js +2 -0
- package/dist/internal/types.js.map +1 -0
- package/dist/ox/TokenId.d.ts +18 -0
- package/dist/ox/TokenId.d.ts.map +1 -0
- package/dist/ox/TokenId.js +29 -0
- package/dist/ox/TokenId.js.map +1 -0
- package/dist/ox/TokenRole.d.ts +11 -0
- package/dist/ox/TokenRole.d.ts.map +1 -0
- package/dist/ox/TokenRole.js +22 -0
- package/dist/ox/TokenRole.js.map +1 -0
- package/dist/ox/Transaction.d.ts +161 -0
- package/dist/ox/Transaction.d.ts.map +1 -0
- package/dist/ox/Transaction.js +117 -0
- package/dist/ox/Transaction.js.map +1 -0
- package/dist/ox/TransactionEnvelopeFeeToken.d.ts +393 -0
- package/dist/ox/TransactionEnvelopeFeeToken.d.ts.map +1 -0
- package/dist/ox/TransactionEnvelopeFeeToken.js +452 -0
- package/dist/ox/TransactionEnvelopeFeeToken.js.map +1 -0
- package/dist/ox/TransactionRequest.d.ts +62 -0
- package/dist/ox/TransactionRequest.d.ts.map +1 -0
- package/dist/ox/TransactionRequest.js +66 -0
- package/dist/ox/TransactionRequest.js.map +1 -0
- package/dist/ox/index.d.ts +5 -0
- package/dist/ox/index.d.ts.map +1 -0
- package/dist/ox/index.js +5 -0
- package/dist/ox/index.js.map +1 -0
- package/dist/prool/Instance.d.ts +92 -0
- package/dist/prool/Instance.d.ts.map +1 -0
- package/dist/prool/Instance.js +96 -0
- package/dist/prool/Instance.js.map +1 -0
- package/dist/prool/index.d.ts +2 -0
- package/dist/prool/index.d.ts.map +1 -0
- package/dist/prool/index.js +2 -0
- package/dist/prool/index.js.map +1 -0
- package/dist/viem/abis.d.ts +2058 -0
- package/dist/viem/abis.d.ts.map +1 -0
- package/dist/viem/abis.js +1599 -0
- package/dist/viem/abis.js.map +1 -0
- package/dist/viem/actions/amm.d.ts +2091 -0
- package/dist/viem/actions/amm.d.ts.map +1 -0
- package/dist/viem/actions/amm.js +876 -0
- package/dist/viem/actions/amm.js.map +1 -0
- package/dist/viem/actions/fee.d.ts +727 -0
- package/dist/viem/actions/fee.d.ts.map +1 -0
- package/dist/viem/actions/fee.js +230 -0
- package/dist/viem/actions/fee.js.map +1 -0
- package/dist/viem/actions/index.d.ts +5 -0
- package/dist/viem/actions/index.d.ts.map +1 -0
- package/dist/viem/actions/index.js +5 -0
- package/dist/viem/actions/index.js.map +1 -0
- package/dist/viem/actions/policy.d.ts +1900 -0
- package/dist/viem/actions/policy.d.ts.map +1 -0
- package/dist/viem/actions/policy.js +841 -0
- package/dist/viem/actions/policy.js.map +1 -0
- package/dist/viem/actions/token.d.ts +13759 -0
- package/dist/viem/actions/token.d.ts.map +1 -0
- package/dist/viem/actions/token.js +2579 -0
- package/dist/viem/actions/token.js.map +1 -0
- package/dist/viem/addresses.d.ts +8 -0
- package/dist/viem/addresses.d.ts.map +1 -0
- package/dist/viem/addresses.js +8 -0
- package/dist/viem/addresses.js.map +1 -0
- package/dist/viem/chain.d.ts +341 -0
- package/dist/viem/chain.d.ts.map +1 -0
- package/dist/viem/chain.js +22 -0
- package/dist/viem/chain.js.map +1 -0
- package/dist/viem/client.d.ts +27 -0
- package/dist/viem/client.d.ts.map +1 -0
- package/dist/viem/client.js +28 -0
- package/dist/viem/client.js.map +1 -0
- package/dist/viem/decorator.d.ts +1636 -0
- package/dist/viem/decorator.d.ts.map +1 -0
- package/dist/viem/decorator.js +95 -0
- package/dist/viem/decorator.js.map +1 -0
- package/dist/viem/formatters.d.ts +4 -0
- package/dist/viem/formatters.d.ts.map +1 -0
- package/dist/viem/formatters.js +69 -0
- package/dist/viem/formatters.js.map +1 -0
- package/dist/viem/index.d.ts +9 -0
- package/dist/viem/index.d.ts.map +1 -0
- package/dist/viem/index.js +9 -0
- package/dist/viem/index.js.map +1 -0
- package/dist/viem/transaction.d.ts +54 -0
- package/dist/viem/transaction.d.ts.map +1 -0
- package/dist/viem/transaction.js +108 -0
- package/dist/viem/transaction.js.map +1 -0
- package/dist/viem/transport.d.ts +16 -0
- package/dist/viem/transport.d.ts.map +1 -0
- package/dist/viem/transport.js +33 -0
- package/dist/viem/transport.js.map +1 -0
- package/dist/viem/types.d.ts +10 -0
- package/dist/viem/types.d.ts.map +1 -0
- package/dist/viem/types.js +2 -0
- package/dist/viem/types.js.map +1 -0
- package/dist/viem/utils.d.ts +8 -0
- package/dist/viem/utils.d.ts.map +1 -0
- package/dist/viem/utils.js +9 -0
- package/dist/viem/utils.js.map +1 -0
- package/package.json +100 -2
- package/src/chains.ts +46 -0
- package/src/index.ts +1 -0
- package/src/internal/types.ts +414 -0
- package/src/ox/TokenId.test.ts +29 -0
- package/src/ox/TokenId.ts +35 -0
- package/src/ox/TokenRole.test.ts +20 -0
- package/src/ox/TokenRole.ts +27 -0
- package/src/ox/Transaction.test.ts +257 -0
- package/src/ox/Transaction.ts +247 -0
- package/src/ox/TransactionEnvelopeFeeToken.test.ts +1215 -0
- package/src/ox/TransactionEnvelopeFeeToken.ts +717 -0
- package/src/ox/TransactionRequest.ts +100 -0
- package/src/ox/index.ts +4 -0
- package/src/prool/Instance.test.ts +43 -0
- package/src/prool/Instance.ts +190 -0
- package/src/prool/index.ts +1 -0
- package/src/prool/internal/chain.json +106 -0
- package/src/prool/internal/consensus.toml +32 -0
- package/src/viem/abis.ts +1606 -0
- package/src/viem/actions/amm.test.ts +425 -0
- package/src/viem/actions/amm.ts +1308 -0
- package/src/viem/actions/fee.test.ts +281 -0
- package/src/viem/actions/fee.ts +362 -0
- package/src/viem/actions/index.ts +4 -0
- package/src/viem/actions/policy.test.ts +514 -0
- package/src/viem/actions/policy.ts +1284 -0
- package/src/viem/actions/token.test.ts +2172 -0
- package/src/viem/actions/token.ts +3830 -0
- package/src/viem/addresses.ts +10 -0
- package/src/viem/chain.ts +27 -0
- package/src/viem/client.bench-d.ts +8 -0
- package/src/viem/client.test.ts +152 -0
- package/src/viem/client.ts +91 -0
- package/src/viem/decorator.bench-d.ts +11 -0
- package/src/viem/decorator.test.ts +35 -0
- package/src/viem/decorator.ts +1914 -0
- package/src/viem/e2e.test.ts +410 -0
- package/src/viem/formatters.ts +100 -0
- package/src/viem/index.ts +8 -0
- package/src/viem/transaction.ts +253 -0
- package/src/viem/transport.ts +47 -0
- package/src/viem/types.ts +55 -0
- package/src/viem/utils.ts +37 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const accountImplementationAddress =
|
|
2
|
+
'0x7702c00000000000000000000000000000000000'
|
|
3
|
+
export const accountRegistrarAddress =
|
|
4
|
+
'0x7702ac0000000000000000000000000000000000'
|
|
5
|
+
export const feeManagerAddress = '0xfeec000000000000000000000000000000000000'
|
|
6
|
+
export const tip20FactoryAddress = '0x20fc000000000000000000000000000000000000'
|
|
7
|
+
export const tip403RegistryAddress =
|
|
8
|
+
'0x403c000000000000000000000000000000000000'
|
|
9
|
+
export const usdAddress = '0x20c0000000000000000000000000000000000000'
|
|
10
|
+
export const usdId = 0n
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Chain,
|
|
3
|
+
type ChainConfig,
|
|
4
|
+
defineTransaction,
|
|
5
|
+
defineTransactionRequest,
|
|
6
|
+
} from 'viem'
|
|
7
|
+
import { formatTransaction, formatTransactionRequest } from './formatters.js'
|
|
8
|
+
import { serializeTransaction } from './transaction.js'
|
|
9
|
+
|
|
10
|
+
export const chainConfig = {
|
|
11
|
+
blockTime: 1_000,
|
|
12
|
+
contracts: {
|
|
13
|
+
multicall3: {
|
|
14
|
+
address: '0xca11bde05977b3631167028862be2a173976ca11',
|
|
15
|
+
blockCreated: 0,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
formatters: {
|
|
19
|
+
transaction: defineTransaction({ format: formatTransaction }),
|
|
20
|
+
transactionRequest: defineTransactionRequest({
|
|
21
|
+
format: formatTransactionRequest,
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
serializers: {
|
|
25
|
+
transaction: serializeTransaction,
|
|
26
|
+
},
|
|
27
|
+
} satisfies Pick<Chain, 'blockTime' | 'contracts'> & ChainConfig
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { expect, test } from 'vitest'
|
|
2
|
+
import { createTempoClient } from './client.js'
|
|
3
|
+
|
|
4
|
+
test('createTempoClient', () => {
|
|
5
|
+
const client = createTempoClient()
|
|
6
|
+
expect({ ...client, uid: null }).toMatchInlineSnapshot(`
|
|
7
|
+
{
|
|
8
|
+
"account": undefined,
|
|
9
|
+
"amm": {
|
|
10
|
+
"burn": [Function],
|
|
11
|
+
"burnSync": [Function],
|
|
12
|
+
"getLiquidityBalance": [Function],
|
|
13
|
+
"getPool": [Function],
|
|
14
|
+
"getPoolId": [Function],
|
|
15
|
+
"getTotalSupply": [Function],
|
|
16
|
+
"mint": [Function],
|
|
17
|
+
"mintSync": [Function],
|
|
18
|
+
"rebalanceSwap": [Function],
|
|
19
|
+
"rebalanceSwapSync": [Function],
|
|
20
|
+
"watchBurn": [Function],
|
|
21
|
+
"watchFeeSwap": [Function],
|
|
22
|
+
"watchMint": [Function],
|
|
23
|
+
"watchRebalanceSwap": [Function],
|
|
24
|
+
},
|
|
25
|
+
"batch": undefined,
|
|
26
|
+
"cacheTime": 500,
|
|
27
|
+
"ccipRead": undefined,
|
|
28
|
+
"chain": {
|
|
29
|
+
"blockTime": 1000,
|
|
30
|
+
"contracts": {
|
|
31
|
+
"multicall3": {
|
|
32
|
+
"address": "0xca11bde05977b3631167028862be2a173976ca11",
|
|
33
|
+
"blockCreated": 0,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
"fees": undefined,
|
|
37
|
+
"formatters": {
|
|
38
|
+
"transaction": {
|
|
39
|
+
"exclude": undefined,
|
|
40
|
+
"format": [Function],
|
|
41
|
+
"type": "transaction",
|
|
42
|
+
},
|
|
43
|
+
"transactionRequest": {
|
|
44
|
+
"exclude": undefined,
|
|
45
|
+
"format": [Function],
|
|
46
|
+
"type": "transactionRequest",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
"id": 4246,
|
|
50
|
+
"name": "Tempo",
|
|
51
|
+
"nativeCurrency": {
|
|
52
|
+
"decimals": 18,
|
|
53
|
+
"name": "USD",
|
|
54
|
+
"symbol": "USD",
|
|
55
|
+
},
|
|
56
|
+
"rpcUrls": {
|
|
57
|
+
"default": {
|
|
58
|
+
"http": [
|
|
59
|
+
"https://rpc-lento.tempoxyz.dev",
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
"serializers": {
|
|
64
|
+
"transaction": [Function],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
"extend": [Function],
|
|
68
|
+
"fee": {
|
|
69
|
+
"getUserToken": [Function],
|
|
70
|
+
"setUserToken": [Function],
|
|
71
|
+
"setUserTokenSync": [Function],
|
|
72
|
+
"watchSetUserToken": [Function],
|
|
73
|
+
},
|
|
74
|
+
"key": "base",
|
|
75
|
+
"name": "Base Client",
|
|
76
|
+
"policy": {
|
|
77
|
+
"create": [Function],
|
|
78
|
+
"createSync": [Function],
|
|
79
|
+
"getData": [Function],
|
|
80
|
+
"isAuthorized": [Function],
|
|
81
|
+
"modifyBlacklist": [Function],
|
|
82
|
+
"modifyBlacklistSync": [Function],
|
|
83
|
+
"modifyWhitelist": [Function],
|
|
84
|
+
"modifyWhitelistSync": [Function],
|
|
85
|
+
"setAdmin": [Function],
|
|
86
|
+
"setAdminSync": [Function],
|
|
87
|
+
"watchAdminUpdated": [Function],
|
|
88
|
+
"watchBlacklistUpdated": [Function],
|
|
89
|
+
"watchCreate": [Function],
|
|
90
|
+
"watchWhitelistUpdated": [Function],
|
|
91
|
+
},
|
|
92
|
+
"pollingInterval": 500,
|
|
93
|
+
"request": [Function],
|
|
94
|
+
"token": {
|
|
95
|
+
"approve": [Function],
|
|
96
|
+
"approveSync": [Function],
|
|
97
|
+
"burn": [Function],
|
|
98
|
+
"burnBlocked": [Function],
|
|
99
|
+
"burnBlockedSync": [Function],
|
|
100
|
+
"burnSync": [Function],
|
|
101
|
+
"changeTransferPolicy": [Function],
|
|
102
|
+
"changeTransferPolicySync": [Function],
|
|
103
|
+
"create": [Function],
|
|
104
|
+
"createSync": [Function],
|
|
105
|
+
"getAllowance": [Function],
|
|
106
|
+
"getBalance": [Function],
|
|
107
|
+
"getMetadata": [Function],
|
|
108
|
+
"grantRoles": [Function],
|
|
109
|
+
"grantRolesSync": [Function],
|
|
110
|
+
"mint": [Function],
|
|
111
|
+
"mintSync": [Function],
|
|
112
|
+
"pause": [Function],
|
|
113
|
+
"pauseSync": [Function],
|
|
114
|
+
"permit": [Function],
|
|
115
|
+
"permitSync": [Function],
|
|
116
|
+
"renounceRoles": [Function],
|
|
117
|
+
"renounceRolesSync": [Function],
|
|
118
|
+
"revokeRoles": [Function],
|
|
119
|
+
"revokeRolesSync": [Function],
|
|
120
|
+
"setRoleAdmin": [Function],
|
|
121
|
+
"setRoleAdminSync": [Function],
|
|
122
|
+
"setSupplyCap": [Function],
|
|
123
|
+
"setSupplyCapSync": [Function],
|
|
124
|
+
"transfer": [Function],
|
|
125
|
+
"transferSync": [Function],
|
|
126
|
+
"unpause": [Function],
|
|
127
|
+
"unpauseSync": [Function],
|
|
128
|
+
"watchAdminRole": [Function],
|
|
129
|
+
"watchApprove": [Function],
|
|
130
|
+
"watchBurn": [Function],
|
|
131
|
+
"watchCreate": [Function],
|
|
132
|
+
"watchMint": [Function],
|
|
133
|
+
"watchRole": [Function],
|
|
134
|
+
"watchTransfer": [Function],
|
|
135
|
+
},
|
|
136
|
+
"transport": {
|
|
137
|
+
"fetchOptions": undefined,
|
|
138
|
+
"key": "http",
|
|
139
|
+
"methods": undefined,
|
|
140
|
+
"name": "HTTP JSON-RPC",
|
|
141
|
+
"request": [Function],
|
|
142
|
+
"retryCount": 3,
|
|
143
|
+
"retryDelay": 150,
|
|
144
|
+
"timeout": 10000,
|
|
145
|
+
"type": "http",
|
|
146
|
+
"url": "https://rpc-lento.tempoxyz.dev",
|
|
147
|
+
},
|
|
148
|
+
"type": "base",
|
|
149
|
+
"uid": null,
|
|
150
|
+
}
|
|
151
|
+
`)
|
|
152
|
+
})
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Account,
|
|
3
|
+
type Address,
|
|
4
|
+
type Chain,
|
|
5
|
+
type ClientConfig,
|
|
6
|
+
createClient,
|
|
7
|
+
http,
|
|
8
|
+
type JsonRpcAccount,
|
|
9
|
+
type RpcSchema,
|
|
10
|
+
type Transport,
|
|
11
|
+
type Client as viem_Client,
|
|
12
|
+
} from 'viem'
|
|
13
|
+
import { tempo } from '../chains.js'
|
|
14
|
+
import type { PartialBy } from '../internal/types.js'
|
|
15
|
+
import * as actions from './decorator.js'
|
|
16
|
+
|
|
17
|
+
export type Client<
|
|
18
|
+
transport extends Transport = Transport,
|
|
19
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
20
|
+
account extends Account | undefined = undefined,
|
|
21
|
+
> = viem_Client<
|
|
22
|
+
transport,
|
|
23
|
+
chain,
|
|
24
|
+
account,
|
|
25
|
+
undefined,
|
|
26
|
+
actions.Decorator<chain, account>
|
|
27
|
+
>
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Instantiates a default Tempo client.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { createTempoClient } from 'tempo.ts/viem'
|
|
35
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
36
|
+
*
|
|
37
|
+
* const client = createTempoClient({
|
|
38
|
+
* account: privateKeyToAccount('0x...')
|
|
39
|
+
* })
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param parameters - The parameters for the client.
|
|
43
|
+
* @returns A Tempo client.
|
|
44
|
+
*/
|
|
45
|
+
export function createTempoClient<
|
|
46
|
+
transport extends Transport,
|
|
47
|
+
chain extends Chain | undefined = typeof tempo,
|
|
48
|
+
accountOrAddress extends Account | Address | undefined = undefined,
|
|
49
|
+
rpcSchema extends RpcSchema | undefined = undefined,
|
|
50
|
+
>(
|
|
51
|
+
parameters: createTempoClient.Parameters<
|
|
52
|
+
transport,
|
|
53
|
+
chain,
|
|
54
|
+
accountOrAddress,
|
|
55
|
+
rpcSchema
|
|
56
|
+
> = {},
|
|
57
|
+
): createTempoClient.ReturnValue<
|
|
58
|
+
transport,
|
|
59
|
+
chain,
|
|
60
|
+
accountOrAddress extends Address
|
|
61
|
+
? JsonRpcAccount<accountOrAddress>
|
|
62
|
+
: accountOrAddress
|
|
63
|
+
> {
|
|
64
|
+
const { chain = tempo, transport = http(), ...rest } = parameters
|
|
65
|
+
return createClient({
|
|
66
|
+
...rest,
|
|
67
|
+
chain,
|
|
68
|
+
transport,
|
|
69
|
+
}).extend(actions.decorator()) as never
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export declare namespace createTempoClient {
|
|
73
|
+
export type Parameters<
|
|
74
|
+
transport extends Transport = Transport,
|
|
75
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
76
|
+
accountOrAddress extends Account | Address | undefined =
|
|
77
|
+
| Account
|
|
78
|
+
| Address
|
|
79
|
+
| undefined,
|
|
80
|
+
rpcSchema extends RpcSchema | undefined = undefined,
|
|
81
|
+
> = PartialBy<
|
|
82
|
+
ClientConfig<transport, chain, accountOrAddress, rpcSchema>,
|
|
83
|
+
'transport'
|
|
84
|
+
>
|
|
85
|
+
|
|
86
|
+
export type ReturnValue<
|
|
87
|
+
transport extends Transport = Transport,
|
|
88
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
89
|
+
account extends Account | undefined = undefined,
|
|
90
|
+
> = Client<transport, chain, account>
|
|
91
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { attest } from '@ark/attest'
|
|
2
|
+
import { createClient, http } from 'viem'
|
|
3
|
+
import { test } from 'vitest'
|
|
4
|
+
import { decorator } from './decorator.js'
|
|
5
|
+
|
|
6
|
+
test('decorator', () => {
|
|
7
|
+
createClient({
|
|
8
|
+
transport: http('https://cloudflare-eth.com'),
|
|
9
|
+
}).extend(decorator())
|
|
10
|
+
attest.instantiations([27597, 'instantiations'])
|
|
11
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { tempoLocal } from 'tempo.ts/chains'
|
|
2
|
+
import { tempoActions } from 'tempo.ts/viem'
|
|
3
|
+
import { createClient, http } from 'viem'
|
|
4
|
+
import { describe, expect, test } from 'vitest'
|
|
5
|
+
|
|
6
|
+
describe('decorator', () => {
|
|
7
|
+
const client2 = createClient({
|
|
8
|
+
chain: tempoLocal,
|
|
9
|
+
transport: http(),
|
|
10
|
+
}).extend(tempoActions())
|
|
11
|
+
|
|
12
|
+
test('default', async () => {
|
|
13
|
+
expect(Object.keys(client2)).toMatchInlineSnapshot(`
|
|
14
|
+
[
|
|
15
|
+
"account",
|
|
16
|
+
"batch",
|
|
17
|
+
"cacheTime",
|
|
18
|
+
"ccipRead",
|
|
19
|
+
"chain",
|
|
20
|
+
"key",
|
|
21
|
+
"name",
|
|
22
|
+
"pollingInterval",
|
|
23
|
+
"request",
|
|
24
|
+
"transport",
|
|
25
|
+
"type",
|
|
26
|
+
"uid",
|
|
27
|
+
"extend",
|
|
28
|
+
"amm",
|
|
29
|
+
"fee",
|
|
30
|
+
"policy",
|
|
31
|
+
"token",
|
|
32
|
+
]
|
|
33
|
+
`)
|
|
34
|
+
})
|
|
35
|
+
})
|