tempo.ts 0.1.5 → 0.2.0
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 +18 -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 +80 -118
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/amm.js +47 -116
- package/dist/viem/Actions/amm.js.map +1 -1
- package/dist/viem/Actions/dex.d.ts +889 -633
- package/dist/viem/Actions/dex.d.ts.map +1 -1
- package/dist/viem/Actions/dex.js +99 -0
- package/dist/viem/Actions/dex.js.map +1 -1
- package/dist/viem/Actions/fee.d.ts +3 -17
- package/dist/viem/Actions/fee.d.ts.map +1 -1
- package/dist/viem/Actions/fee.js.map +1 -1
- package/dist/viem/Actions/index.d.ts +1 -0
- package/dist/viem/Actions/index.d.ts.map +1 -1
- package/dist/viem/Actions/index.js +1 -0
- package/dist/viem/Actions/index.js.map +1 -1
- 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 +4295 -2646
- package/dist/viem/Actions/token.d.ts.map +1 -1
- package/dist/viem/Actions/token.js +214 -335
- 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 +959 -405
- package/dist/viem/Decorator.d.ts.map +1 -1
- package/dist/viem/Decorator.js +13 -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/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 +6 -0
- package/dist/wagmi/Actions/index.d.ts.map +1 -0
- package/dist/wagmi/Actions/index.js +6 -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 +73 -0
- package/dist/wagmi/Connector.d.ts.map +1 -0
- package/dist/wagmi/Connector.js +249 -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/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 +6 -0
- package/dist/wagmi/Hooks/index.d.ts.map +1 -0
- package/dist/wagmi/Hooks/index.js +6 -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 +19 -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 +98 -169
- package/src/viem/Actions/amm.ts +68 -155
- package/src/viem/Actions/dex.test.ts +563 -484
- package/src/viem/Actions/dex.ts +173 -0
- package/src/viem/Actions/fee.test.ts +23 -34
- package/src/viem/Actions/fee.ts +7 -0
- package/src/viem/Actions/index.ts +1 -0
- package/src/viem/Actions/policy.test.ts +19 -33
- 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 +452 -540
- package/src/viem/Addresses.ts +1 -2
- package/src/viem/Chain.ts +70 -20
- package/src/viem/Decorator.test.ts +2 -1
- package/src/viem/Decorator.ts +996 -421
- 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/fee.test.ts +63 -0
- package/src/wagmi/Actions/fee.ts +208 -0
- package/src/wagmi/Actions/index.ts +5 -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 +367 -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/fee.test.ts +166 -0
- package/src/wagmi/Hooks/fee.ts +206 -0
- package/src/wagmi/Hooks/index.ts +5 -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 {
|
|
@@ -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,
|
|
@@ -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
|
/**
|
|
@@ -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,
|
|
@@ -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
|
/**
|
|
@@ -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,
|
|
@@ -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
|
/**
|
|
@@ -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,
|
|
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,
|
|
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
|
*
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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
|
/**
|
|
@@ -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
|
/**
|
|
@@ -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,
|
|
@@ -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
|
/**
|
|
@@ -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,
|
|
@@ -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
|
}
|
|
@@ -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)
|
package/src/viem/Actions/fee.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type Account,
|
|
3
3
|
type Address,
|
|
4
|
+
type BaseErrorType,
|
|
4
5
|
type Chain,
|
|
5
6
|
type Client,
|
|
6
7
|
type ExtractAbiItem,
|
|
@@ -156,6 +157,9 @@ export namespace setUserToken {
|
|
|
156
157
|
|
|
157
158
|
export type ReturnValue = WriteContractReturnType
|
|
158
159
|
|
|
160
|
+
// TODO: exhaustive error type
|
|
161
|
+
export type ErrorType = BaseErrorType
|
|
162
|
+
|
|
159
163
|
/** @internal */
|
|
160
164
|
export async function inner<
|
|
161
165
|
action extends typeof writeContract | typeof writeContractSync,
|
|
@@ -291,6 +295,9 @@ export namespace setUserTokenSync {
|
|
|
291
295
|
receipt: TransactionReceipt
|
|
292
296
|
}
|
|
293
297
|
>
|
|
298
|
+
|
|
299
|
+
// TODO: exhaustive error type
|
|
300
|
+
export type ErrorType = BaseErrorType
|
|
294
301
|
}
|
|
295
302
|
|
|
296
303
|
/**
|
|
@@ -1,28 +1,11 @@
|
|
|
1
1
|
import { setTimeout } from 'node:timers/promises'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { describe, expect, test } from 'vitest'
|
|
5
|
-
import { tempoTest } from '../../../test/viem/config.js'
|
|
6
|
-
import { createTempoClient } from '../Client.js'
|
|
2
|
+
import { beforeAll, describe, expect, test } from 'vitest'
|
|
3
|
+
import { accounts, client, rpcUrl } from '../../../test/viem/config.js'
|
|
7
4
|
import * as actions from './index.js'
|
|
8
5
|
|
|
9
|
-
const account =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const account2 = mnemonicToAccount(
|
|
13
|
-
'test test test test test test test test test test test junk',
|
|
14
|
-
{ accountIndex: 1 },
|
|
15
|
-
)
|
|
16
|
-
const account3 = mnemonicToAccount(
|
|
17
|
-
'test test test test test test test test test test test junk',
|
|
18
|
-
{ accountIndex: 2 },
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
const client = createTempoClient({
|
|
22
|
-
account,
|
|
23
|
-
chain: tempoTest,
|
|
24
|
-
pollingInterval: 100,
|
|
25
|
-
}).extend(publicActions)
|
|
6
|
+
const account = accounts[0]
|
|
7
|
+
const account2 = accounts[1]
|
|
8
|
+
const account3 = accounts[2]
|
|
26
9
|
|
|
27
10
|
describe('create', () => {
|
|
28
11
|
test('default', async () => {
|
|
@@ -58,7 +41,7 @@ describe('create', () => {
|
|
|
58
41
|
expect(blacklistReceipt).toBeDefined()
|
|
59
42
|
expect(blacklistResult).toMatchInlineSnapshot(`
|
|
60
43
|
{
|
|
61
|
-
"policyId":
|
|
44
|
+
"policyId": 3n,
|
|
62
45
|
"policyType": 1,
|
|
63
46
|
"updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
64
47
|
}
|
|
@@ -120,7 +103,7 @@ describe('setAdmin', () => {
|
|
|
120
103
|
expect(setAdminResult).toMatchInlineSnapshot(`
|
|
121
104
|
{
|
|
122
105
|
"admin": "0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650",
|
|
123
|
-
"policyId":
|
|
106
|
+
"policyId": 4n,
|
|
124
107
|
"updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
125
108
|
}
|
|
126
109
|
`)
|
|
@@ -163,7 +146,7 @@ describe('modifyWhitelist', () => {
|
|
|
163
146
|
{
|
|
164
147
|
"account": "0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650",
|
|
165
148
|
"allowed": true,
|
|
166
|
-
"policyId":
|
|
149
|
+
"policyId": 5n,
|
|
167
150
|
"updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
168
151
|
}
|
|
169
152
|
`)
|
|
@@ -189,7 +172,7 @@ describe('modifyWhitelist', () => {
|
|
|
189
172
|
{
|
|
190
173
|
"account": "0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650",
|
|
191
174
|
"allowed": false,
|
|
192
|
-
"policyId":
|
|
175
|
+
"policyId": 5n,
|
|
193
176
|
"updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
194
177
|
}
|
|
195
178
|
`)
|
|
@@ -232,7 +215,7 @@ describe('modifyBlacklist', () => {
|
|
|
232
215
|
expect(addBlacklistResult).toMatchInlineSnapshot(`
|
|
233
216
|
{
|
|
234
217
|
"account": "0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650",
|
|
235
|
-
"policyId":
|
|
218
|
+
"policyId": 6n,
|
|
236
219
|
"restricted": true,
|
|
237
220
|
"updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
238
221
|
}
|
|
@@ -258,7 +241,7 @@ describe('modifyBlacklist', () => {
|
|
|
258
241
|
expect(removeBlacklistResult).toMatchInlineSnapshot(`
|
|
259
242
|
{
|
|
260
243
|
"account": "0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650",
|
|
261
|
-
"policyId":
|
|
244
|
+
"policyId": 6n,
|
|
262
245
|
"restricted": false,
|
|
263
246
|
"updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
264
247
|
}
|
|
@@ -397,13 +380,17 @@ describe('watchCreate', () => {
|
|
|
397
380
|
unwatch()
|
|
398
381
|
|
|
399
382
|
expect(logs.length).toBe(1)
|
|
400
|
-
expect(logs[0].args.policyId).
|
|
383
|
+
expect(logs[0].args.policyId).toBeDefined()
|
|
401
384
|
expect(logs[0].args.updater).toBe(account.address)
|
|
402
385
|
expect(logs[0].args.type).toBe('whitelist')
|
|
403
386
|
})
|
|
404
387
|
})
|
|
405
388
|
|
|
406
389
|
describe('watchAdminUpdated', () => {
|
|
390
|
+
beforeAll(async () => {
|
|
391
|
+
await fetch(`${rpcUrl}/restart`)
|
|
392
|
+
})
|
|
393
|
+
|
|
407
394
|
test('default', async () => {
|
|
408
395
|
// create policy
|
|
409
396
|
const { policyId } = await actions.policy.createSync(client, {
|
|
@@ -426,8 +413,7 @@ describe('watchAdminUpdated', () => {
|
|
|
426
413
|
await setTimeout(500)
|
|
427
414
|
unwatch()
|
|
428
415
|
|
|
429
|
-
expect(logs.
|
|
430
|
-
expect(logs[0].args.policyId).toBe(2n)
|
|
416
|
+
expect(logs[0].args.policyId).toBeDefined()
|
|
431
417
|
expect(logs[0].args.updater).toBe(account.address)
|
|
432
418
|
expect(logs[0].args.admin).toBe(account2.address)
|
|
433
419
|
})
|
|
@@ -465,7 +451,7 @@ describe('watchWhitelistUpdated', () => {
|
|
|
465
451
|
unwatch()
|
|
466
452
|
|
|
467
453
|
expect(logs.length).toBe(2)
|
|
468
|
-
expect(logs[0].args.policyId).
|
|
454
|
+
expect(logs[0].args.policyId).toBeDefined()
|
|
469
455
|
expect(logs[0].args.updater).toBe(account.address)
|
|
470
456
|
expect(logs[0].args.account).toBe(account2.address)
|
|
471
457
|
expect(logs[0].args.allowed).toBe(true)
|
|
@@ -505,7 +491,7 @@ describe('watchBlacklistUpdated', () => {
|
|
|
505
491
|
unwatch()
|
|
506
492
|
|
|
507
493
|
expect(logs.length).toBe(2)
|
|
508
|
-
expect(logs[0].args.policyId).
|
|
494
|
+
expect(logs[0].args.policyId).toBeDefined()
|
|
509
495
|
expect(logs[0].args.updater).toBe(account.address)
|
|
510
496
|
expect(logs[0].args.account).toBe(account2.address)
|
|
511
497
|
expect(logs[0].args.restricted).toBe(true)
|