tempo.ts 0.1.5 → 0.2.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 +33 -2
- package/dist/chains.d.ts +509 -115
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +20 -9
- package/dist/chains.js.map +1 -1
- package/dist/ox/Order.d.ts +92 -0
- package/dist/ox/Order.d.ts.map +1 -0
- package/dist/ox/Order.js +88 -0
- package/dist/ox/Order.js.map +1 -0
- package/dist/ox/OrdersFilters.d.ts +72 -0
- package/dist/ox/OrdersFilters.d.ts.map +1 -0
- package/dist/ox/OrdersFilters.js +100 -0
- package/dist/ox/OrdersFilters.js.map +1 -0
- package/dist/ox/Pagination.d.ts +128 -0
- package/dist/ox/Pagination.d.ts.map +1 -0
- package/dist/ox/Pagination.js +78 -0
- package/dist/ox/Pagination.js.map +1 -0
- package/dist/ox/PoolId.d.ts +18 -0
- package/dist/ox/PoolId.d.ts.map +1 -0
- package/dist/ox/PoolId.js +13 -0
- package/dist/ox/PoolId.js.map +1 -0
- package/dist/ox/RpcSchema.d.ts +32 -0
- package/dist/ox/RpcSchema.d.ts.map +1 -0
- package/dist/ox/RpcSchema.js +2 -0
- package/dist/ox/RpcSchema.js.map +1 -0
- package/dist/ox/SignatureEnvelope.d.ts +1 -1
- package/dist/ox/SignatureEnvelope.d.ts.map +1 -1
- package/dist/ox/SignatureEnvelope.js.map +1 -1
- package/dist/{viem → ox}/Tick.d.ts +4 -0
- package/dist/ox/Tick.d.ts.map +1 -0
- package/dist/ox/Tick.js.map +1 -0
- package/dist/ox/Transaction.d.ts.map +1 -1
- package/dist/ox/Transaction.js +2 -1
- package/dist/ox/Transaction.js.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.d.ts +6 -6
- package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.js +4 -2
- package/dist/ox/TransactionEnvelopeAA.js.map +1 -1
- package/dist/ox/TransactionRequest.d.ts +4 -0
- package/dist/ox/TransactionRequest.d.ts.map +1 -1
- package/dist/ox/TransactionRequest.js.map +1 -1
- package/dist/ox/index.d.ts +6 -0
- package/dist/ox/index.d.ts.map +1 -1
- package/dist/ox/index.js +6 -0
- package/dist/ox/index.js.map +1 -1
- package/dist/prool/Instance.d.ts.map +1 -1
- package/dist/prool/Instance.js +20 -4
- package/dist/prool/Instance.js.map +1 -1
- package/dist/viem/Abis.d.ts +1469 -1082
- package/dist/viem/Abis.d.ts.map +1 -1
- package/dist/viem/Abis.js +932 -671
- package/dist/viem/Abis.js.map +1 -1
- package/dist/viem/Account.d.ts +150 -0
- package/dist/viem/Account.d.ts.map +1 -0
- package/dist/viem/Account.js +221 -0
- package/dist/viem/Account.js.map +1 -0
- package/dist/viem/Actions/amm.d.ts +144 -161
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/amm.js +109 -163
- package/dist/viem/Actions/amm.js.map +1 -1
- package/dist/viem/Actions/dex.d.ts +920 -664
- package/dist/viem/Actions/dex.d.ts.map +1 -1
- package/dist/viem/Actions/dex.js +129 -30
- package/dist/viem/Actions/dex.js.map +1 -1
- package/dist/viem/Actions/faucet.d.ts +34 -0
- package/dist/viem/Actions/faucet.d.ts.map +1 -0
- package/dist/viem/Actions/faucet.js +33 -0
- package/dist/viem/Actions/faucet.js.map +1 -0
- package/dist/viem/Actions/fee.d.ts +16 -30
- package/dist/viem/Actions/fee.d.ts.map +1 -1
- package/dist/viem/Actions/fee.js +13 -13
- package/dist/viem/Actions/fee.js.map +1 -1
- package/dist/viem/Actions/index.d.ts +2 -0
- package/dist/viem/Actions/index.d.ts.map +1 -1
- package/dist/viem/Actions/index.js +2 -0
- package/dist/viem/Actions/index.js.map +1 -1
- package/dist/viem/Actions/policy.d.ts +46 -46
- package/dist/viem/Actions/policy.js +46 -46
- package/dist/viem/Actions/reward.d.ts +3236 -0
- package/dist/viem/Actions/reward.d.ts.map +1 -0
- package/dist/viem/Actions/reward.js +725 -0
- package/dist/viem/Actions/reward.js.map +1 -0
- package/dist/viem/Actions/token.d.ts +4399 -2750
- package/dist/viem/Actions/token.d.ts.map +1 -1
- package/dist/viem/Actions/token.js +361 -482
- package/dist/viem/Actions/token.js.map +1 -1
- package/dist/viem/Addresses.d.ts +1 -2
- package/dist/viem/Addresses.d.ts.map +1 -1
- package/dist/viem/Addresses.js +1 -2
- package/dist/viem/Addresses.js.map +1 -1
- package/dist/viem/Chain.d.ts +38 -12
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +27 -18
- package/dist/viem/Chain.js.map +1 -1
- package/dist/viem/Decorator.d.ts +1009 -428
- package/dist/viem/Decorator.d.ts.map +1 -1
- package/dist/viem/Decorator.js +17 -5
- package/dist/viem/Decorator.js.map +1 -1
- package/dist/viem/Formatters.d.ts +8 -1
- package/dist/viem/Formatters.d.ts.map +1 -1
- package/dist/viem/Formatters.js +17 -0
- package/dist/viem/Formatters.js.map +1 -1
- package/dist/viem/P256.d.ts +2 -0
- package/dist/viem/P256.d.ts.map +1 -0
- package/dist/viem/P256.js +2 -0
- package/dist/viem/P256.js.map +1 -0
- package/dist/viem/Secp256k1.d.ts +2 -0
- package/dist/viem/Secp256k1.d.ts.map +1 -0
- package/dist/viem/Secp256k1.js +2 -0
- package/dist/viem/Secp256k1.js.map +1 -0
- package/dist/viem/TokenIds.d.ts +1 -2
- package/dist/viem/TokenIds.d.ts.map +1 -1
- package/dist/viem/TokenIds.js +1 -2
- package/dist/viem/TokenIds.js.map +1 -1
- package/dist/viem/Transaction.d.ts +1 -1
- package/dist/viem/Transaction.d.ts.map +1 -1
- package/dist/viem/Transaction.js +46 -5
- package/dist/viem/Transaction.js.map +1 -1
- package/dist/viem/WebAuthnP256.d.ts +79 -0
- package/dist/viem/WebAuthnP256.d.ts.map +1 -0
- package/dist/viem/WebAuthnP256.js +95 -0
- package/dist/viem/WebAuthnP256.js.map +1 -0
- package/dist/viem/WebCryptoP256.d.ts +2 -0
- package/dist/viem/WebCryptoP256.d.ts.map +1 -0
- package/dist/viem/WebCryptoP256.js +2 -0
- package/dist/viem/WebCryptoP256.js.map +1 -0
- package/dist/viem/index.d.ts +6 -3
- package/dist/viem/index.d.ts.map +1 -1
- package/dist/viem/index.js +6 -3
- package/dist/viem/index.js.map +1 -1
- package/dist/viem/internal/account.d.ts +24 -0
- package/dist/viem/internal/account.d.ts.map +1 -0
- package/dist/viem/internal/account.js +68 -0
- package/dist/viem/internal/account.js.map +1 -0
- package/dist/viem/internal/types.d.ts +10 -0
- package/dist/viem/internal/types.d.ts.map +1 -1
- package/dist/wagmi/Actions/amm.d.ts +428 -0
- package/dist/wagmi/Actions/amm.d.ts.map +1 -0
- package/dist/wagmi/Actions/amm.js +472 -0
- package/dist/wagmi/Actions/amm.js.map +1 -0
- package/dist/wagmi/Actions/dex.d.ts +908 -0
- package/dist/wagmi/Actions/dex.d.ts.map +1 -0
- package/dist/wagmi/Actions/dex.js +1023 -0
- package/dist/wagmi/Actions/dex.js.map +1 -0
- package/dist/wagmi/Actions/faucet.d.ts +35 -0
- package/dist/wagmi/Actions/faucet.d.ts.map +1 -0
- package/dist/wagmi/Actions/faucet.js +33 -0
- package/dist/wagmi/Actions/faucet.js.map +1 -0
- package/dist/wagmi/Actions/fee.d.ts +111 -0
- package/dist/wagmi/Actions/fee.d.ts.map +1 -0
- package/dist/wagmi/Actions/fee.js +126 -0
- package/dist/wagmi/Actions/fee.js.map +1 -0
- package/dist/wagmi/Actions/index.d.ts +7 -0
- package/dist/wagmi/Actions/index.d.ts.map +1 -0
- package/dist/wagmi/Actions/index.js +7 -0
- package/dist/wagmi/Actions/index.js.map +1 -0
- package/dist/wagmi/Actions/reward.d.ts +348 -0
- package/dist/wagmi/Actions/reward.d.ts.map +1 -0
- package/dist/wagmi/Actions/reward.js +388 -0
- package/dist/wagmi/Actions/reward.js.map +1 -0
- package/dist/wagmi/Actions/token.d.ts +1546 -0
- package/dist/wagmi/Actions/token.d.ts.map +1 -0
- package/dist/wagmi/Actions/token.js +1712 -0
- package/dist/wagmi/Actions/token.js.map +1 -0
- package/dist/wagmi/Connector.d.ts +81 -0
- package/dist/wagmi/Connector.d.ts.map +1 -0
- package/dist/wagmi/Connector.js +261 -0
- package/dist/wagmi/Connector.js.map +1 -0
- package/dist/wagmi/Hooks/amm.d.ts +421 -0
- package/dist/wagmi/Hooks/amm.d.ts.map +1 -0
- package/dist/wagmi/Hooks/amm.js +504 -0
- package/dist/wagmi/Hooks/amm.js.map +1 -0
- package/dist/wagmi/Hooks/dex.d.ts +816 -0
- package/dist/wagmi/Hooks/dex.d.ts.map +1 -0
- package/dist/wagmi/Hooks/dex.js +973 -0
- package/dist/wagmi/Hooks/dex.js.map +1 -0
- package/dist/wagmi/Hooks/faucet.d.ts +39 -0
- package/dist/wagmi/Hooks/faucet.d.ts.map +1 -0
- package/dist/wagmi/Hooks/faucet.js +40 -0
- package/dist/wagmi/Hooks/faucet.js.map +1 -0
- package/dist/wagmi/Hooks/fee.d.ts +97 -0
- package/dist/wagmi/Hooks/fee.d.ts.map +1 -0
- package/dist/wagmi/Hooks/fee.js +109 -0
- package/dist/wagmi/Hooks/fee.js.map +1 -0
- package/dist/wagmi/Hooks/index.d.ts +7 -0
- package/dist/wagmi/Hooks/index.d.ts.map +1 -0
- package/dist/wagmi/Hooks/index.js +7 -0
- package/dist/wagmi/Hooks/index.js.map +1 -0
- package/dist/wagmi/Hooks/reward.d.ts +307 -0
- package/dist/wagmi/Hooks/reward.d.ts.map +1 -0
- package/dist/wagmi/Hooks/reward.js +349 -0
- package/dist/wagmi/Hooks/reward.js.map +1 -0
- package/dist/wagmi/Hooks/token.d.ts +1388 -0
- package/dist/wagmi/Hooks/token.d.ts.map +1 -0
- package/dist/wagmi/Hooks/token.js +1657 -0
- package/dist/wagmi/Hooks/token.js.map +1 -0
- package/dist/wagmi/index.d.ts +4 -0
- package/dist/wagmi/index.d.ts.map +1 -0
- package/dist/wagmi/index.js +4 -0
- package/dist/wagmi/index.js.map +1 -0
- package/package.json +54 -10
- package/src/chains.ts +21 -9
- package/src/ox/Order.test.ts +78 -0
- package/src/ox/Order.ts +125 -0
- package/src/ox/OrdersFilters.test.ts +182 -0
- package/src/ox/OrdersFilters.ts +125 -0
- package/src/ox/Pagination.test.ts +162 -0
- package/src/ox/Pagination.ts +164 -0
- package/src/ox/PoolId.test.ts +33 -0
- package/src/ox/PoolId.ts +27 -0
- package/src/ox/RpcSchema.ts +35 -0
- package/src/ox/SignatureEnvelope.ts +3 -1
- package/src/{viem → ox}/Tick.test.ts +1 -1
- package/src/{viem → ox}/Tick.ts +5 -0
- package/src/ox/Transaction.test.ts +1 -1
- package/src/ox/Transaction.ts +2 -1
- package/src/ox/TransactionEnvelopeAA.test.ts +239 -96
- package/src/ox/TransactionEnvelopeAA.ts +9 -7
- package/src/ox/TransactionRequest.ts +4 -0
- package/src/ox/index.ts +6 -0
- package/src/prool/Instance.ts +51 -37
- package/src/prool/internal/chain.json +104 -52
- package/src/tsconfig.json +9 -0
- package/src/viem/Abis.ts +972 -710
- package/src/viem/Account.ts +279 -0
- package/src/viem/Actions/__snapshots__/dex.test.ts.snap +850 -0
- package/src/viem/Actions/amm.test.ts +173 -169
- package/src/viem/Actions/amm.ts +131 -203
- package/src/viem/Actions/dex.test.ts +563 -484
- package/src/viem/Actions/dex.ts +203 -30
- package/src/viem/Actions/faucet.ts +50 -0
- package/src/viem/Actions/fee.test.ts +23 -34
- package/src/viem/Actions/fee.ts +20 -13
- package/src/viem/Actions/index.ts +2 -0
- package/src/viem/Actions/policy.test.ts +19 -33
- package/src/viem/Actions/policy.ts +46 -46
- package/src/viem/Actions/reward.test.ts +457 -0
- package/src/viem/Actions/reward.ts +999 -0
- package/src/viem/Actions/token.test.ts +453 -287
- package/src/viem/Actions/token.ts +605 -693
- package/src/viem/Addresses.ts +1 -2
- package/src/viem/Chain.bench-d.ts +12 -0
- package/src/viem/Chain.ts +70 -20
- package/src/viem/Decorator.bench-d.ts +1 -1
- package/src/viem/Decorator.test.ts +3 -1
- package/src/viem/Decorator.ts +1049 -442
- package/src/viem/Formatters.ts +31 -5
- package/src/viem/P256.ts +1 -0
- package/src/viem/Secp256k1.ts +1 -0
- package/src/viem/TokenIds.ts +1 -2
- package/src/viem/Transaction.ts +53 -7
- package/src/viem/WebAuthnP256.ts +140 -0
- package/src/viem/WebCryptoP256.ts +1 -0
- package/src/viem/e2e.test.ts +1126 -297
- package/src/viem/index.ts +6 -3
- package/src/viem/internal/account.ts +107 -0
- package/src/viem/internal/types.ts +9 -0
- package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +310 -0
- package/src/wagmi/Actions/amm.test.ts +198 -0
- package/src/wagmi/Actions/amm.ts +691 -0
- package/src/wagmi/Actions/dex.test.ts +1507 -0
- package/src/wagmi/Actions/dex.ts +1640 -0
- package/src/wagmi/Actions/faucet.ts +46 -0
- package/src/wagmi/Actions/fee.test.ts +63 -0
- package/src/wagmi/Actions/fee.ts +208 -0
- package/src/wagmi/Actions/index.ts +6 -0
- package/src/wagmi/Actions/reward.test.ts +210 -0
- package/src/wagmi/Actions/reward.ts +632 -0
- package/src/wagmi/Actions/token.test.ts +1308 -0
- package/src/wagmi/Actions/token.ts +2613 -0
- package/src/wagmi/Connector.test.ts +53 -0
- package/src/wagmi/Connector.ts +390 -0
- package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +457 -0
- package/src/wagmi/Hooks/amm.test.ts +424 -0
- package/src/wagmi/Hooks/amm.ts +806 -0
- package/src/wagmi/Hooks/dex.test.ts +1017 -0
- package/src/wagmi/Hooks/dex.ts +1685 -0
- package/src/wagmi/Hooks/faucet.ts +76 -0
- package/src/wagmi/Hooks/fee.test.ts +166 -0
- package/src/wagmi/Hooks/fee.ts +206 -0
- package/src/wagmi/Hooks/index.ts +6 -0
- package/src/wagmi/Hooks/reward.test.ts +219 -0
- package/src/wagmi/Hooks/reward.ts +672 -0
- package/src/wagmi/Hooks/token.test.ts +1670 -0
- package/src/wagmi/Hooks/token.ts +2906 -0
- package/src/wagmi/index.ts +3 -0
- package/src/wagmi/internal/types.ts +16 -0
- package/dist/viem/Client.d.ts +0 -27
- package/dist/viem/Client.d.ts.map +0 -1
- package/dist/viem/Client.js +0 -28
- package/dist/viem/Client.js.map +0 -1
- package/dist/viem/Tick.d.ts.map +0 -1
- package/dist/viem/Tick.js.map +0 -1
- package/src/viem/Client.bench-d.ts +0 -8
- package/src/viem/Client.test.ts +0 -178
- package/src/viem/Client.ts +0 -91
- /package/dist/{viem → ox}/Tick.js +0 -0
package/src/viem/Actions/dex.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import * as Hash from 'ox/Hash'
|
|
2
|
+
import * as Hex from 'ox/Hex'
|
|
1
3
|
import {
|
|
2
4
|
type Account,
|
|
3
5
|
type Address,
|
|
6
|
+
type BaseErrorType,
|
|
4
7
|
type Chain,
|
|
5
8
|
type Client,
|
|
6
9
|
type ExtractAbiItem,
|
|
@@ -22,6 +25,9 @@ import {
|
|
|
22
25
|
writeContractSync,
|
|
23
26
|
} from 'viem/actions'
|
|
24
27
|
import type { Compute, UnionOmit } from '../../internal/types.js'
|
|
28
|
+
import * as Order from '../../ox/Order.js'
|
|
29
|
+
import * as OrdersFilters from '../../ox/OrdersFilters.js'
|
|
30
|
+
import * as Pagination from '../../ox/Pagination.js'
|
|
25
31
|
import * as Abis from '../Abis.js'
|
|
26
32
|
import * as Addresses from '../Addresses.js'
|
|
27
33
|
import type {
|
|
@@ -48,7 +54,7 @@ type OrderType = 'buy' | 'sell'
|
|
|
48
54
|
*
|
|
49
55
|
* const client = createClient({
|
|
50
56
|
* account: privateKeyToAccount('0x...'),
|
|
51
|
-
* chain: tempo
|
|
57
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
52
58
|
* transport: http(),
|
|
53
59
|
* })
|
|
54
60
|
*
|
|
@@ -93,6 +99,9 @@ export namespace buy {
|
|
|
93
99
|
|
|
94
100
|
export type ReturnValue = WriteContractReturnType
|
|
95
101
|
|
|
102
|
+
// TODO: exhaustive error type
|
|
103
|
+
export type ErrorType = BaseErrorType
|
|
104
|
+
|
|
96
105
|
/** @internal */
|
|
97
106
|
export async function inner<
|
|
98
107
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -126,7 +135,7 @@ export namespace buy {
|
|
|
126
135
|
* import { Actions } from 'tempo.ts/viem'
|
|
127
136
|
*
|
|
128
137
|
* const client = createClient({
|
|
129
|
-
* chain: tempo
|
|
138
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
130
139
|
* transport: http(),
|
|
131
140
|
* }).extend(walletActions)
|
|
132
141
|
*
|
|
@@ -168,7 +177,7 @@ export namespace buy {
|
|
|
168
177
|
*
|
|
169
178
|
* const client = createClient({
|
|
170
179
|
* account: privateKeyToAccount('0x...'),
|
|
171
|
-
* chain: tempo
|
|
180
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
172
181
|
* transport: http(),
|
|
173
182
|
* })
|
|
174
183
|
*
|
|
@@ -211,6 +220,9 @@ export namespace buySync {
|
|
|
211
220
|
/** Transaction receipt. */
|
|
212
221
|
receipt: TransactionReceipt
|
|
213
222
|
}>
|
|
223
|
+
|
|
224
|
+
// TODO: exhaustive error type
|
|
225
|
+
export type ErrorType = BaseErrorType
|
|
214
226
|
}
|
|
215
227
|
|
|
216
228
|
/**
|
|
@@ -225,7 +237,7 @@ export namespace buySync {
|
|
|
225
237
|
*
|
|
226
238
|
* const client = createClient({
|
|
227
239
|
* account: privateKeyToAccount('0x...'),
|
|
228
|
-
* chain: tempo
|
|
240
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
229
241
|
* transport: http(),
|
|
230
242
|
* })
|
|
231
243
|
*
|
|
@@ -261,6 +273,9 @@ export namespace cancel {
|
|
|
261
273
|
|
|
262
274
|
export type ReturnValue = WriteContractReturnType
|
|
263
275
|
|
|
276
|
+
// TODO: exhaustive error type
|
|
277
|
+
export type ErrorType = BaseErrorType
|
|
278
|
+
|
|
264
279
|
/** @internal */
|
|
265
280
|
export async function inner<
|
|
266
281
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -294,7 +309,7 @@ export namespace cancel {
|
|
|
294
309
|
* import { Actions } from 'tempo.ts/viem'
|
|
295
310
|
*
|
|
296
311
|
* const client = createClient({
|
|
297
|
-
* chain: tempo
|
|
312
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
298
313
|
* transport: http(),
|
|
299
314
|
* }).extend(walletActions)
|
|
300
315
|
*
|
|
@@ -350,7 +365,7 @@ export namespace cancel {
|
|
|
350
365
|
*
|
|
351
366
|
* const client = createClient({
|
|
352
367
|
* account: privateKeyToAccount('0x...'),
|
|
353
|
-
* chain: tempo
|
|
368
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
354
369
|
* transport: http(),
|
|
355
370
|
* })
|
|
356
371
|
*
|
|
@@ -400,6 +415,9 @@ export namespace cancelSync {
|
|
|
400
415
|
receipt: TransactionReceipt
|
|
401
416
|
}
|
|
402
417
|
>
|
|
418
|
+
|
|
419
|
+
// TODO: exhaustive error type
|
|
420
|
+
export type ErrorType = BaseErrorType
|
|
403
421
|
}
|
|
404
422
|
|
|
405
423
|
/**
|
|
@@ -414,7 +432,7 @@ export namespace cancelSync {
|
|
|
414
432
|
*
|
|
415
433
|
* const client = createClient({
|
|
416
434
|
* account: privateKeyToAccount('0x...'),
|
|
417
|
-
* chain: tempo
|
|
435
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
418
436
|
* transport: http(),
|
|
419
437
|
* })
|
|
420
438
|
*
|
|
@@ -450,6 +468,9 @@ export namespace createPair {
|
|
|
450
468
|
|
|
451
469
|
export type ReturnValue = WriteContractReturnType
|
|
452
470
|
|
|
471
|
+
// TODO: exhaustive error type
|
|
472
|
+
export type ErrorType = BaseErrorType
|
|
473
|
+
|
|
453
474
|
/** @internal */
|
|
454
475
|
export async function inner<
|
|
455
476
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -483,7 +504,7 @@ export namespace createPair {
|
|
|
483
504
|
* import { Actions } from 'tempo.ts/viem'
|
|
484
505
|
*
|
|
485
506
|
* const client = createClient({
|
|
486
|
-
* chain: tempo
|
|
507
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
487
508
|
* transport: http(),
|
|
488
509
|
* }).extend(walletActions)
|
|
489
510
|
*
|
|
@@ -539,7 +560,7 @@ export namespace createPair {
|
|
|
539
560
|
*
|
|
540
561
|
* const client = createClient({
|
|
541
562
|
* account: privateKeyToAccount('0x...'),
|
|
542
|
-
* chain: tempo
|
|
563
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
543
564
|
* transport: http(),
|
|
544
565
|
* })
|
|
545
566
|
*
|
|
@@ -589,6 +610,9 @@ export namespace createPairSync {
|
|
|
589
610
|
receipt: TransactionReceipt
|
|
590
611
|
}
|
|
591
612
|
>
|
|
613
|
+
|
|
614
|
+
// TODO: exhaustive error type
|
|
615
|
+
export type ErrorType = BaseErrorType
|
|
592
616
|
}
|
|
593
617
|
|
|
594
618
|
/**
|
|
@@ -601,7 +625,7 @@ export namespace createPairSync {
|
|
|
601
625
|
* import { Actions } from 'tempo.ts/viem'
|
|
602
626
|
*
|
|
603
627
|
* const client = createClient({
|
|
604
|
-
* chain: tempo
|
|
628
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
605
629
|
* transport: http(),
|
|
606
630
|
* })
|
|
607
631
|
*
|
|
@@ -676,7 +700,7 @@ export namespace getBalance {
|
|
|
676
700
|
* import { Actions } from 'tempo.ts/viem'
|
|
677
701
|
*
|
|
678
702
|
* const client = createClient({
|
|
679
|
-
* chain: tempo
|
|
703
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
680
704
|
* transport: http(),
|
|
681
705
|
* })
|
|
682
706
|
*
|
|
@@ -747,7 +771,7 @@ export namespace getBuyQuote {
|
|
|
747
771
|
* import { Actions } from 'tempo.ts/viem'
|
|
748
772
|
*
|
|
749
773
|
* const client = createClient({
|
|
750
|
-
* chain: tempo
|
|
774
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
751
775
|
* transport: http(),
|
|
752
776
|
* })
|
|
753
777
|
*
|
|
@@ -802,6 +826,125 @@ export namespace getOrder {
|
|
|
802
826
|
}
|
|
803
827
|
}
|
|
804
828
|
|
|
829
|
+
/**
|
|
830
|
+
* Gets paginated orders from the orderbook.
|
|
831
|
+
*
|
|
832
|
+
* @example
|
|
833
|
+
* ```ts
|
|
834
|
+
* import { createClient, http } from 'viem'
|
|
835
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
836
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
837
|
+
*
|
|
838
|
+
* const client = createClient({
|
|
839
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
840
|
+
* transport: http(),
|
|
841
|
+
* })
|
|
842
|
+
*
|
|
843
|
+
* const { items, nextCursor } = await Actions.dex.getOrders(client, {
|
|
844
|
+
* limit: 100,
|
|
845
|
+
* filters: {
|
|
846
|
+
* baseToken: '0x20c0...',
|
|
847
|
+
* isBid: true,
|
|
848
|
+
* }
|
|
849
|
+
* })
|
|
850
|
+
* ```
|
|
851
|
+
*
|
|
852
|
+
* @param client - Client.
|
|
853
|
+
* @param parameters - Parameters.
|
|
854
|
+
* @returns Paginated orders and next cursor.
|
|
855
|
+
*/
|
|
856
|
+
export async function getOrders<chain extends Chain | undefined>(
|
|
857
|
+
client: Client<Transport, chain>,
|
|
858
|
+
parameters: getOrders.Parameters = {},
|
|
859
|
+
): Promise<getOrders.ReturnValue> {
|
|
860
|
+
const params = Pagination.toRpcParameters(parameters, {
|
|
861
|
+
toRpcFilters: OrdersFilters.toRpc,
|
|
862
|
+
})
|
|
863
|
+
const response = await client.request<any>({
|
|
864
|
+
method: 'dex_getOrders',
|
|
865
|
+
params: [params],
|
|
866
|
+
})
|
|
867
|
+
return Pagination.fromRpcResponse(response, {
|
|
868
|
+
key: 'orders',
|
|
869
|
+
fromRpc: Order.fromRpc,
|
|
870
|
+
})
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
export namespace getOrders {
|
|
874
|
+
export type Parameters = Pagination.Params<OrdersFilters.OrdersFilters>
|
|
875
|
+
|
|
876
|
+
export type ReturnValue = Pagination.Response<'orders', Order.Order>
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Gets orderbook information for a trading pair.
|
|
881
|
+
*
|
|
882
|
+
* @example
|
|
883
|
+
* ```ts
|
|
884
|
+
* import { createClient, http } from 'viem'
|
|
885
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
886
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
887
|
+
*
|
|
888
|
+
* const client = createClient({
|
|
889
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
890
|
+
* transport: http(),
|
|
891
|
+
* })
|
|
892
|
+
*
|
|
893
|
+
* const book = await Actions.dex.getOrderbook(client, {
|
|
894
|
+
* base: '0x20c...11',
|
|
895
|
+
* quote: '0x20c...20',
|
|
896
|
+
* })
|
|
897
|
+
* ```
|
|
898
|
+
*
|
|
899
|
+
* @param client - Client.
|
|
900
|
+
* @param parameters - Parameters.
|
|
901
|
+
* @returns The orderbook information.
|
|
902
|
+
*/
|
|
903
|
+
export async function getOrderbook<chain extends Chain | undefined>(
|
|
904
|
+
client: Client<Transport, chain>,
|
|
905
|
+
parameters: getOrderbook.Parameters,
|
|
906
|
+
): Promise<getOrderbook.ReturnValue> {
|
|
907
|
+
const { base, quote, ...rest } = parameters
|
|
908
|
+
return readContract(client, {
|
|
909
|
+
...rest,
|
|
910
|
+
...getOrderbook.call({ base, quote }),
|
|
911
|
+
})
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
export namespace getOrderbook {
|
|
915
|
+
export type Parameters = ReadParameters & Args
|
|
916
|
+
|
|
917
|
+
export type Args = {
|
|
918
|
+
/** Address of the base token. */
|
|
919
|
+
base: Address
|
|
920
|
+
/** Address of the quote token. */
|
|
921
|
+
quote: Address
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
export type ReturnValue = ReadContractReturnType<
|
|
925
|
+
typeof Abis.stablecoinExchange,
|
|
926
|
+
'books',
|
|
927
|
+
never
|
|
928
|
+
>
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* Defines a call to the `books` function.
|
|
932
|
+
*
|
|
933
|
+
* @param args - Arguments.
|
|
934
|
+
* @returns The call.
|
|
935
|
+
*/
|
|
936
|
+
export function call(args: Args) {
|
|
937
|
+
const { base, quote } = args
|
|
938
|
+
const pairKey = getPairKey(base, quote)
|
|
939
|
+
return defineCall({
|
|
940
|
+
address: Addresses.stablecoinExchange,
|
|
941
|
+
abi: Abis.stablecoinExchange,
|
|
942
|
+
args: [pairKey],
|
|
943
|
+
functionName: 'books',
|
|
944
|
+
})
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
|
|
805
948
|
/**
|
|
806
949
|
* Gets the price level information at a specific tick.
|
|
807
950
|
*
|
|
@@ -812,7 +955,7 @@ export namespace getOrder {
|
|
|
812
955
|
* import { Actions, Tick } from 'tempo.ts/viem'
|
|
813
956
|
*
|
|
814
957
|
* const client = createClient({
|
|
815
|
-
* chain: tempo
|
|
958
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
816
959
|
* transport: http(),
|
|
817
960
|
* })
|
|
818
961
|
*
|
|
@@ -883,7 +1026,7 @@ export namespace getPriceLevel {
|
|
|
883
1026
|
* import { Actions } from 'tempo.ts/viem'
|
|
884
1027
|
*
|
|
885
1028
|
* const client = createClient({
|
|
886
|
-
* chain: tempo
|
|
1029
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
887
1030
|
* transport: http(),
|
|
888
1031
|
* })
|
|
889
1032
|
*
|
|
@@ -956,7 +1099,7 @@ export namespace getSellQuote {
|
|
|
956
1099
|
*
|
|
957
1100
|
* const client = createClient({
|
|
958
1101
|
* account: privateKeyToAccount('0x...'),
|
|
959
|
-
* chain: tempo
|
|
1102
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
960
1103
|
* transport: http(),
|
|
961
1104
|
* })
|
|
962
1105
|
*
|
|
@@ -1001,6 +1144,9 @@ export namespace place {
|
|
|
1001
1144
|
|
|
1002
1145
|
export type ReturnValue = WriteContractReturnType
|
|
1003
1146
|
|
|
1147
|
+
// TODO: exhaustive error type
|
|
1148
|
+
export type ErrorType = BaseErrorType
|
|
1149
|
+
|
|
1004
1150
|
/** @internal */
|
|
1005
1151
|
export async function inner<
|
|
1006
1152
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -1034,7 +1180,7 @@ export namespace place {
|
|
|
1034
1180
|
* import { Actions, Tick } from 'tempo.ts/viem'
|
|
1035
1181
|
*
|
|
1036
1182
|
* const client = createClient({
|
|
1037
|
-
* chain: tempo
|
|
1183
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1038
1184
|
* transport: http(),
|
|
1039
1185
|
* }).extend(walletActions)
|
|
1040
1186
|
*
|
|
@@ -1094,7 +1240,7 @@ export namespace place {
|
|
|
1094
1240
|
*
|
|
1095
1241
|
* const client = createClient({
|
|
1096
1242
|
* account: privateKeyToAccount('0x...'),
|
|
1097
|
-
* chain: tempo
|
|
1243
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1098
1244
|
* transport: http(),
|
|
1099
1245
|
* })
|
|
1100
1246
|
*
|
|
@@ -1142,6 +1288,9 @@ export namespace placeFlip {
|
|
|
1142
1288
|
|
|
1143
1289
|
export type ReturnValue = WriteContractReturnType
|
|
1144
1290
|
|
|
1291
|
+
// TODO: exhaustive error type
|
|
1292
|
+
export type ErrorType = BaseErrorType
|
|
1293
|
+
|
|
1145
1294
|
/** @internal */
|
|
1146
1295
|
export async function inner<
|
|
1147
1296
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -1175,7 +1324,7 @@ export namespace placeFlip {
|
|
|
1175
1324
|
* import { Actions, Tick } from 'tempo.ts/viem'
|
|
1176
1325
|
*
|
|
1177
1326
|
* const client = createClient({
|
|
1178
|
-
* chain: tempo
|
|
1327
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1179
1328
|
* transport: http(),
|
|
1180
1329
|
* }).extend(walletActions)
|
|
1181
1330
|
*
|
|
@@ -1236,7 +1385,7 @@ export namespace placeFlip {
|
|
|
1236
1385
|
*
|
|
1237
1386
|
* const client = createClient({
|
|
1238
1387
|
* account: privateKeyToAccount('0x...'),
|
|
1239
|
-
* chain: tempo
|
|
1388
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1240
1389
|
* transport: http(),
|
|
1241
1390
|
* })
|
|
1242
1391
|
*
|
|
@@ -1290,6 +1439,9 @@ export namespace placeFlipSync {
|
|
|
1290
1439
|
receipt: TransactionReceipt
|
|
1291
1440
|
}
|
|
1292
1441
|
>
|
|
1442
|
+
|
|
1443
|
+
// TODO: exhaustive error type
|
|
1444
|
+
export type ErrorType = BaseErrorType
|
|
1293
1445
|
}
|
|
1294
1446
|
|
|
1295
1447
|
/**
|
|
@@ -1304,7 +1456,7 @@ export namespace placeFlipSync {
|
|
|
1304
1456
|
*
|
|
1305
1457
|
* const client = createClient({
|
|
1306
1458
|
* account: privateKeyToAccount('0x...'),
|
|
1307
|
-
* chain: tempo
|
|
1459
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1308
1460
|
* transport: http(),
|
|
1309
1461
|
* })
|
|
1310
1462
|
*
|
|
@@ -1357,6 +1509,9 @@ export namespace placeSync {
|
|
|
1357
1509
|
receipt: TransactionReceipt
|
|
1358
1510
|
}
|
|
1359
1511
|
>
|
|
1512
|
+
|
|
1513
|
+
// TODO: exhaustive error type
|
|
1514
|
+
export type ErrorType = BaseErrorType
|
|
1360
1515
|
}
|
|
1361
1516
|
|
|
1362
1517
|
/**
|
|
@@ -1371,7 +1526,7 @@ export namespace placeSync {
|
|
|
1371
1526
|
*
|
|
1372
1527
|
* const client = createClient({
|
|
1373
1528
|
* account: privateKeyToAccount('0x...'),
|
|
1374
|
-
* chain: tempo
|
|
1529
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1375
1530
|
* transport: http(),
|
|
1376
1531
|
* })
|
|
1377
1532
|
*
|
|
@@ -1416,6 +1571,9 @@ export namespace sell {
|
|
|
1416
1571
|
|
|
1417
1572
|
export type ReturnValue = WriteContractReturnType
|
|
1418
1573
|
|
|
1574
|
+
// TODO: exhaustive error type
|
|
1575
|
+
export type ErrorType = BaseErrorType
|
|
1576
|
+
|
|
1419
1577
|
/** @internal */
|
|
1420
1578
|
export async function inner<
|
|
1421
1579
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -1449,7 +1607,7 @@ export namespace sell {
|
|
|
1449
1607
|
* import { Actions } from 'tempo.ts/viem'
|
|
1450
1608
|
*
|
|
1451
1609
|
* const client = createClient({
|
|
1452
|
-
* chain: tempo
|
|
1610
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1453
1611
|
* transport: http(),
|
|
1454
1612
|
* }).extend(walletActions)
|
|
1455
1613
|
*
|
|
@@ -1491,7 +1649,7 @@ export namespace sell {
|
|
|
1491
1649
|
*
|
|
1492
1650
|
* const client = createClient({
|
|
1493
1651
|
* account: privateKeyToAccount('0x...'),
|
|
1494
|
-
* chain: tempo
|
|
1652
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1495
1653
|
* transport: http(),
|
|
1496
1654
|
* })
|
|
1497
1655
|
*
|
|
@@ -1534,6 +1692,9 @@ export namespace sellSync {
|
|
|
1534
1692
|
/** Transaction receipt. */
|
|
1535
1693
|
receipt: TransactionReceipt
|
|
1536
1694
|
}>
|
|
1695
|
+
|
|
1696
|
+
// TODO: exhaustive error type
|
|
1697
|
+
export type ErrorType = BaseErrorType
|
|
1537
1698
|
}
|
|
1538
1699
|
|
|
1539
1700
|
/**
|
|
@@ -1546,7 +1707,7 @@ export namespace sellSync {
|
|
|
1546
1707
|
* import { Actions } from 'tempo.ts/viem'
|
|
1547
1708
|
*
|
|
1548
1709
|
* const client = createClient({
|
|
1549
|
-
* chain: tempo
|
|
1710
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1550
1711
|
* transport: http(),
|
|
1551
1712
|
* })
|
|
1552
1713
|
*
|
|
@@ -1627,7 +1788,7 @@ export declare namespace watchFlipOrderPlaced {
|
|
|
1627
1788
|
* import { Actions } from 'tempo.ts/viem'
|
|
1628
1789
|
*
|
|
1629
1790
|
* const client = createClient({
|
|
1630
|
-
* chain: tempo
|
|
1791
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1631
1792
|
* transport: http(),
|
|
1632
1793
|
* })
|
|
1633
1794
|
*
|
|
@@ -1703,7 +1864,7 @@ export declare namespace watchOrderCancelled {
|
|
|
1703
1864
|
* import { Actions } from 'tempo.ts/viem'
|
|
1704
1865
|
*
|
|
1705
1866
|
* const client = createClient({
|
|
1706
|
-
* chain: tempo
|
|
1867
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1707
1868
|
* transport: http(),
|
|
1708
1869
|
* })
|
|
1709
1870
|
*
|
|
@@ -1787,7 +1948,7 @@ export declare namespace watchOrderFilled {
|
|
|
1787
1948
|
* import { Actions } from 'tempo.ts/viem'
|
|
1788
1949
|
*
|
|
1789
1950
|
* const client = createClient({
|
|
1790
|
-
* chain: tempo
|
|
1951
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1791
1952
|
* transport: http(),
|
|
1792
1953
|
* })
|
|
1793
1954
|
*
|
|
@@ -1870,7 +2031,7 @@ export declare namespace watchOrderPlaced {
|
|
|
1870
2031
|
*
|
|
1871
2032
|
* const client = createClient({
|
|
1872
2033
|
* account: privateKeyToAccount('0x...'),
|
|
1873
|
-
* chain: tempo
|
|
2034
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1874
2035
|
* transport: http(),
|
|
1875
2036
|
* })
|
|
1876
2037
|
*
|
|
@@ -1909,6 +2070,9 @@ export namespace withdraw {
|
|
|
1909
2070
|
|
|
1910
2071
|
export type ReturnValue = WriteContractReturnType
|
|
1911
2072
|
|
|
2073
|
+
// TODO: exhaustive error type
|
|
2074
|
+
export type ErrorType = BaseErrorType
|
|
2075
|
+
|
|
1912
2076
|
/** @internal */
|
|
1913
2077
|
export async function inner<
|
|
1914
2078
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -1942,7 +2106,7 @@ export namespace withdraw {
|
|
|
1942
2106
|
* import { Actions } from 'tempo.ts/viem'
|
|
1943
2107
|
*
|
|
1944
2108
|
* const client = createClient({
|
|
1945
|
-
* chain: tempo
|
|
2109
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1946
2110
|
* transport: http(),
|
|
1947
2111
|
* }).extend(walletActions)
|
|
1948
2112
|
*
|
|
@@ -1982,7 +2146,7 @@ export namespace withdraw {
|
|
|
1982
2146
|
*
|
|
1983
2147
|
* const client = createClient({
|
|
1984
2148
|
* account: privateKeyToAccount('0x...'),
|
|
1985
|
-
* chain: tempo
|
|
2149
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1986
2150
|
* transport: http(),
|
|
1987
2151
|
* })
|
|
1988
2152
|
*
|
|
@@ -2023,4 +2187,13 @@ export namespace withdrawSync {
|
|
|
2023
2187
|
/** Transaction receipt. */
|
|
2024
2188
|
receipt: TransactionReceipt
|
|
2025
2189
|
}>
|
|
2190
|
+
|
|
2191
|
+
// TODO: exhaustive error type
|
|
2192
|
+
export type ErrorType = BaseErrorType
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
function getPairKey(base: Address, quote: Address) {
|
|
2196
|
+
const [tokenA, tokenB] =
|
|
2197
|
+
Hex.toBigInt(base) < Hex.toBigInt(quote) ? [base, quote] : [quote, base]
|
|
2198
|
+
return Hash.keccak256(Hex.concat(tokenA, tokenB))
|
|
2026
2199
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Account, Address, Chain, Client, Hash, Transport } from 'viem'
|
|
2
|
+
import { parseAccount } from 'viem/utils'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Funds an account with an initial amount of set token(s)
|
|
6
|
+
* on Tempo's testnet.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { createClient, http } from 'viem'
|
|
11
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
12
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
13
|
+
*
|
|
14
|
+
* const client = createClient({
|
|
15
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
|
|
16
|
+
* transport: http(),
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* const hashes = await Actions.faucet.fund(client, {
|
|
20
|
+
* account: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param client - Client.
|
|
25
|
+
* @param parameters - Parameters.
|
|
26
|
+
* @returns The transaction hash.
|
|
27
|
+
*/
|
|
28
|
+
export async function fund<chain extends Chain | undefined>(
|
|
29
|
+
client: Client<Transport, chain>,
|
|
30
|
+
parameters: fund.Parameters,
|
|
31
|
+
): Promise<fund.ReturnValue> {
|
|
32
|
+
const account = parseAccount(parameters.account)
|
|
33
|
+
return client.request<{
|
|
34
|
+
Method: 'tempo_fundAddress'
|
|
35
|
+
Parameters: [address: Address]
|
|
36
|
+
ReturnType: readonly Hash[]
|
|
37
|
+
}>({
|
|
38
|
+
method: 'tempo_fundAddress',
|
|
39
|
+
params: [account.address],
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export declare namespace fund {
|
|
44
|
+
export type Parameters = {
|
|
45
|
+
/** Account to fund. */
|
|
46
|
+
account: Account | Address
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type ReturnValue = readonly Hash[]
|
|
50
|
+
}
|
|
@@ -1,44 +1,33 @@
|
|
|
1
1
|
import { setTimeout } from 'node:timers/promises'
|
|
2
|
-
import { Abis
|
|
3
|
-
import {
|
|
4
|
-
import { mnemonicToAccount } from 'viem/accounts'
|
|
2
|
+
import { Abis } from 'tempo.ts/viem'
|
|
3
|
+
import { parseUnits } from 'viem'
|
|
5
4
|
import { writeContractSync } from 'viem/actions'
|
|
6
|
-
import { describe, expect, test } from 'vitest'
|
|
7
|
-
import {
|
|
5
|
+
import { afterEach, describe, expect, test } from 'vitest'
|
|
6
|
+
import { accounts, client, rpcUrl } from '../../../test/viem/config.js'
|
|
8
7
|
import * as actions from './index.js'
|
|
9
8
|
|
|
10
|
-
const account =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const account2 = mnemonicToAccount(
|
|
14
|
-
'test test test test test test test test test test test junk',
|
|
15
|
-
{ accountIndex: 1 },
|
|
16
|
-
)
|
|
17
|
-
const account3 = mnemonicToAccount(
|
|
18
|
-
'test test test test test test test test test test test junk',
|
|
19
|
-
{ accountIndex: 2 },
|
|
20
|
-
)
|
|
9
|
+
const account = accounts[0]
|
|
10
|
+
const account2 = accounts[1]
|
|
11
|
+
const account3 = accounts[2]
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
pollingInterval: 100,
|
|
26
|
-
}).extend(publicActions)
|
|
13
|
+
afterEach(async () => {
|
|
14
|
+
await fetch(`${rpcUrl}/restart`)
|
|
15
|
+
})
|
|
27
16
|
|
|
28
17
|
describe('getUserToken', () => {
|
|
29
18
|
test('default', async () => {
|
|
30
19
|
// Fund accounts
|
|
31
20
|
await writeContractSync(client, {
|
|
32
21
|
abi: Abis.tip20,
|
|
33
|
-
address:
|
|
22
|
+
address: '0x20c0000000000000000000000000000000000001',
|
|
34
23
|
functionName: 'transfer',
|
|
35
|
-
args: [account2.address,
|
|
24
|
+
args: [account2.address, parseUnits('100', 6)],
|
|
36
25
|
})
|
|
37
26
|
await writeContractSync(client, {
|
|
38
27
|
abi: Abis.tip20,
|
|
39
|
-
address:
|
|
28
|
+
address: '0x20c0000000000000000000000000000000000001',
|
|
40
29
|
functionName: 'transfer',
|
|
41
|
-
args: [account3.address,
|
|
30
|
+
args: [account3.address, parseUnits('100', 6)],
|
|
42
31
|
})
|
|
43
32
|
|
|
44
33
|
// Set token (address)
|
|
@@ -137,7 +126,7 @@ describe('setUserToken', () => {
|
|
|
137
126
|
})
|
|
138
127
|
})
|
|
139
128
|
|
|
140
|
-
describe('watchSetUserToken', () => {
|
|
129
|
+
describe('watchSetUserToken', async () => {
|
|
141
130
|
test('default', async () => {
|
|
142
131
|
const receivedSets: Array<{
|
|
143
132
|
args: actions.fee.watchSetUserToken.Args
|
|
@@ -155,9 +144,9 @@ describe('watchSetUserToken', () => {
|
|
|
155
144
|
// Set token for account2
|
|
156
145
|
await writeContractSync(client, {
|
|
157
146
|
abi: Abis.tip20,
|
|
158
|
-
address:
|
|
147
|
+
address: '0x20c0000000000000000000000000000000000001',
|
|
159
148
|
functionName: 'transfer',
|
|
160
|
-
args: [account2.address,
|
|
149
|
+
args: [account2.address, parseUnits('1', 6)],
|
|
161
150
|
})
|
|
162
151
|
|
|
163
152
|
await actions.fee.setUserTokenSync(client, {
|
|
@@ -168,9 +157,9 @@ describe('watchSetUserToken', () => {
|
|
|
168
157
|
// Set token for account3
|
|
169
158
|
await writeContractSync(client, {
|
|
170
159
|
abi: Abis.tip20,
|
|
171
|
-
address:
|
|
160
|
+
address: '0x20c0000000000000000000000000000000000001',
|
|
172
161
|
functionName: 'transfer',
|
|
173
|
-
args: [account3.address,
|
|
162
|
+
args: [account3.address, parseUnits('1', 6)],
|
|
174
163
|
})
|
|
175
164
|
|
|
176
165
|
await actions.fee.setUserTokenSync(client, {
|
|
@@ -219,16 +208,16 @@ describe('watchSetUserToken', () => {
|
|
|
219
208
|
// Transfer gas to accounts
|
|
220
209
|
await writeContractSync(client, {
|
|
221
210
|
abi: Abis.tip20,
|
|
222
|
-
address:
|
|
211
|
+
address: '0x20c0000000000000000000000000000000000001',
|
|
223
212
|
functionName: 'transfer',
|
|
224
|
-
args: [account2.address,
|
|
213
|
+
args: [account2.address, parseUnits('1', 6)],
|
|
225
214
|
})
|
|
226
215
|
|
|
227
216
|
await writeContractSync(client, {
|
|
228
217
|
abi: Abis.tip20,
|
|
229
|
-
address:
|
|
218
|
+
address: '0x20c0000000000000000000000000000000000001',
|
|
230
219
|
functionName: 'transfer',
|
|
231
|
-
args: [account3.address,
|
|
220
|
+
args: [account3.address, parseUnits('1', 6)],
|
|
232
221
|
})
|
|
233
222
|
|
|
234
223
|
// Set token for account2 (should be captured)
|