tempo.ts 0.10.5 → 0.11.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/CHANGELOG.md +36 -0
- package/README.md +0 -41
- package/dist/viem/Account.d.ts +8 -3
- package/dist/viem/Account.d.ts.map +1 -1
- package/dist/viem/Account.js +9 -2
- package/dist/viem/Account.js.map +1 -1
- package/dist/viem/Actions/account.d.ts.map +1 -1
- package/dist/viem/Actions/account.js +1 -1
- package/dist/viem/Actions/account.js.map +1 -1
- package/dist/viem/Actions/amm.d.ts +1 -1
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/amm.js +1 -2
- package/dist/viem/Actions/amm.js.map +1 -1
- package/dist/viem/Actions/dex.d.ts +0 -35
- package/dist/viem/Actions/dex.d.ts.map +1 -1
- package/dist/viem/Actions/dex.js +0 -43
- package/dist/viem/Actions/dex.js.map +1 -1
- package/dist/viem/Actions/fee.d.ts +1 -1
- package/dist/viem/Actions/fee.d.ts.map +1 -1
- package/dist/viem/Actions/fee.js +1 -1
- package/dist/viem/Actions/fee.js.map +1 -1
- package/dist/viem/Actions/nonce.d.ts.map +1 -1
- package/dist/viem/Actions/nonce.js +6 -4
- package/dist/viem/Actions/nonce.js.map +1 -1
- package/dist/viem/Actions/token.d.ts +1 -2
- package/dist/viem/Actions/token.d.ts.map +1 -1
- package/dist/viem/Actions/token.js +1 -2
- package/dist/viem/Actions/token.js.map +1 -1
- package/dist/viem/Chain.d.ts +34 -34
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +2 -0
- package/dist/viem/Chain.js.map +1 -1
- package/dist/viem/Decorator.d.ts +0 -27
- package/dist/viem/Decorator.d.ts.map +1 -1
- package/dist/viem/Decorator.js +0 -1
- package/dist/viem/Decorator.js.map +1 -1
- package/dist/viem/Formatters.d.ts.map +1 -1
- package/dist/viem/Formatters.js +5 -3
- package/dist/viem/Formatters.js.map +1 -1
- package/dist/viem/Transaction.d.ts +8 -5
- package/dist/viem/Transaction.d.ts.map +1 -1
- package/dist/viem/Transaction.js +13 -3
- package/dist/viem/Transaction.js.map +1 -1
- package/dist/viem/index.d.ts +10 -1
- package/dist/viem/index.d.ts.map +1 -1
- package/dist/viem/index.js +1 -1
- package/dist/viem/index.js.map +1 -1
- package/dist/viem/internal/types.d.ts +1 -1
- package/dist/viem/internal/types.d.ts.map +1 -1
- package/dist/wagmi/Actions/dex.d.ts +1 -45
- package/dist/wagmi/Actions/dex.d.ts.map +1 -1
- package/dist/wagmi/Actions/dex.js +0 -55
- package/dist/wagmi/Actions/dex.js.map +1 -1
- package/dist/wagmi/Connector.d.ts +1 -1
- package/dist/wagmi/Connector.d.ts.map +1 -1
- package/dist/wagmi/Connector.js +1 -2
- package/dist/wagmi/Connector.js.map +1 -1
- package/dist/wagmi/Hooks/dex.d.ts +3 -46
- package/dist/wagmi/Hooks/dex.d.ts.map +1 -1
- package/dist/wagmi/Hooks/dex.js +2 -54
- package/dist/wagmi/Hooks/dex.js.map +1 -1
- package/dist/wagmi/index.d.ts +1 -1
- package/dist/wagmi/index.d.ts.map +1 -1
- package/dist/wagmi/index.js +1 -1
- package/dist/wagmi/index.js.map +1 -1
- package/package.json +5 -13
- package/src/viem/Account.test.ts +1 -1
- package/src/viem/Account.ts +11 -2
- package/src/viem/Actions/account.ts +1 -1
- package/src/viem/Actions/amm.ts +1 -2
- package/src/viem/Actions/dex.test.ts +1 -195
- package/src/viem/Actions/dex.ts +0 -53
- package/src/viem/Actions/fee.test.ts +2 -2
- package/src/viem/Actions/fee.ts +1 -1
- package/src/viem/Actions/nonce.test.ts +27 -14
- package/src/viem/Actions/nonce.ts +6 -4
- package/src/viem/Actions/token.test.ts +18 -52
- package/src/viem/Actions/token.ts +1 -2
- package/src/viem/Chain.ts +3 -1
- package/src/viem/Decorator.ts +0 -30
- package/src/viem/Formatters.ts +9 -3
- package/src/viem/Transaction.ts +23 -7
- package/src/viem/e2e.test.ts +19 -0
- package/src/viem/index.ts +12 -1
- package/src/viem/internal/types.ts +1 -1
- package/src/wagmi/Actions/dex.test.ts +0 -26
- package/src/wagmi/Actions/dex.ts +1 -111
- package/src/wagmi/Actions/nonce.test.ts +8 -4
- package/src/wagmi/Actions/token.test.ts +2 -2
- package/src/wagmi/Connector.ts +1 -2
- package/src/wagmi/Hooks/dex.test.ts +0 -26
- package/src/wagmi/Hooks/dex.ts +1 -88
- package/src/wagmi/Hooks/nonce.test.ts +3 -3
- package/src/wagmi/index.ts +4 -1
- package/dist/ox/AuthorizationTempo.d.ts +0 -450
- package/dist/ox/AuthorizationTempo.d.ts.map +0 -1
- package/dist/ox/AuthorizationTempo.js +0 -433
- package/dist/ox/AuthorizationTempo.js.map +0 -1
- package/dist/ox/KeyAuthorization.d.ts +0 -356
- package/dist/ox/KeyAuthorization.d.ts.map +0 -1
- package/dist/ox/KeyAuthorization.js +0 -359
- package/dist/ox/KeyAuthorization.js.map +0 -1
- package/dist/ox/Order.d.ts +0 -92
- package/dist/ox/Order.d.ts.map +0 -1
- package/dist/ox/Order.js +0 -88
- package/dist/ox/Order.js.map +0 -1
- package/dist/ox/OrdersFilters.d.ts +0 -72
- package/dist/ox/OrdersFilters.d.ts.map +0 -1
- package/dist/ox/OrdersFilters.js +0 -100
- package/dist/ox/OrdersFilters.js.map +0 -1
- package/dist/ox/Pagination.d.ts +0 -128
- package/dist/ox/Pagination.d.ts.map +0 -1
- package/dist/ox/Pagination.js +0 -78
- package/dist/ox/Pagination.js.map +0 -1
- package/dist/ox/PoolId.d.ts +0 -18
- package/dist/ox/PoolId.d.ts.map +0 -1
- package/dist/ox/PoolId.js +0 -13
- package/dist/ox/PoolId.js.map +0 -1
- package/dist/ox/RpcSchema.d.ts +0 -32
- package/dist/ox/RpcSchema.d.ts.map +0 -1
- package/dist/ox/RpcSchema.js +0 -2
- package/dist/ox/RpcSchema.js.map +0 -1
- package/dist/ox/SignatureEnvelope.d.ts +0 -260
- package/dist/ox/SignatureEnvelope.d.ts.map +0 -1
- package/dist/ox/SignatureEnvelope.js +0 -477
- package/dist/ox/SignatureEnvelope.js.map +0 -1
- package/dist/ox/Tick.d.ts +0 -115
- package/dist/ox/Tick.d.ts.map +0 -1
- package/dist/ox/Tick.js +0 -127
- package/dist/ox/Tick.js.map +0 -1
- package/dist/ox/TokenId.d.ts +0 -25
- package/dist/ox/TokenId.d.ts.map +0 -1
- package/dist/ox/TokenId.js +0 -41
- package/dist/ox/TokenId.js.map +0 -1
- package/dist/ox/TokenRole.d.ts +0 -11
- package/dist/ox/TokenRole.d.ts.map +0 -1
- package/dist/ox/TokenRole.js +0 -22
- package/dist/ox/TokenRole.js.map +0 -1
- package/dist/ox/Transaction.d.ts +0 -201
- package/dist/ox/Transaction.d.ts.map +0 -1
- package/dist/ox/Transaction.js +0 -167
- package/dist/ox/Transaction.js.map +0 -1
- package/dist/ox/TransactionEnvelopeTempo.d.ts +0 -470
- package/dist/ox/TransactionEnvelopeTempo.d.ts.map +0 -1
- package/dist/ox/TransactionEnvelopeTempo.js +0 -547
- package/dist/ox/TransactionEnvelopeTempo.js.map +0 -1
- package/dist/ox/TransactionReceipt.d.ts +0 -155
- package/dist/ox/TransactionReceipt.d.ts.map +0 -1
- package/dist/ox/TransactionReceipt.js +0 -136
- package/dist/ox/TransactionReceipt.js.map +0 -1
- package/dist/ox/TransactionRequest.d.ts +0 -76
- package/dist/ox/TransactionRequest.d.ts.map +0 -1
- package/dist/ox/TransactionRequest.js +0 -93
- package/dist/ox/TransactionRequest.js.map +0 -1
- package/dist/ox/index.d.ts +0 -14
- package/dist/ox/index.d.ts.map +0 -1
- package/dist/ox/index.js +0 -14
- package/dist/ox/index.js.map +0 -1
- package/dist/prool/Instance.d.ts +0 -101
- package/dist/prool/Instance.d.ts.map +0 -1
- package/dist/prool/Instance.js +0 -136
- package/dist/prool/Instance.js.map +0 -1
- package/dist/prool/chain.json +0 -238
- package/dist/prool/index.d.ts +0 -2
- package/dist/prool/index.d.ts.map +0 -1
- package/dist/prool/index.js +0 -2
- package/dist/prool/index.js.map +0 -1
- package/src/ox/AuthorizationTempo.test.ts +0 -1256
- package/src/ox/AuthorizationTempo.ts +0 -648
- package/src/ox/KeyAuthorization.test.ts +0 -1332
- package/src/ox/KeyAuthorization.ts +0 -540
- package/src/ox/Order.test.ts +0 -78
- package/src/ox/Order.ts +0 -125
- package/src/ox/OrdersFilters.test.ts +0 -182
- package/src/ox/OrdersFilters.ts +0 -125
- package/src/ox/Pagination.test.ts +0 -162
- package/src/ox/Pagination.ts +0 -164
- package/src/ox/PoolId.test.ts +0 -33
- package/src/ox/PoolId.ts +0 -27
- package/src/ox/RpcSchema.ts +0 -35
- package/src/ox/SignatureEnvelope.test.ts +0 -1876
- package/src/ox/SignatureEnvelope.ts +0 -791
- package/src/ox/Tick.test.ts +0 -281
- package/src/ox/Tick.ts +0 -181
- package/src/ox/TokenId.test.ts +0 -40
- package/src/ox/TokenId.ts +0 -50
- package/src/ox/TokenRole.test.ts +0 -16
- package/src/ox/TokenRole.ts +0 -27
- package/src/ox/Transaction.test.ts +0 -523
- package/src/ox/Transaction.ts +0 -332
- package/src/ox/TransactionEnvelopeTempo.test.ts +0 -1352
- package/src/ox/TransactionEnvelopeTempo.ts +0 -905
- package/src/ox/TransactionReceipt.ts +0 -190
- package/src/ox/TransactionRequest.ts +0 -147
- package/src/ox/e2e.test.ts +0 -1393
- package/src/ox/index.ts +0 -13
- package/src/prool/Instance.test.ts +0 -43
- package/src/prool/Instance.ts +0 -247
- package/src/prool/chain.json +0 -238
- package/src/prool/index.ts +0 -1
- package/src/viem/Actions/__snapshots__/dex.test.ts.snap +0 -850
- package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +0 -310
- package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +0 -457
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TokenId } from 'ox/tempo'
|
|
1
2
|
import type {
|
|
2
3
|
Account,
|
|
3
4
|
Address,
|
|
@@ -10,7 +11,6 @@ import type {
|
|
|
10
11
|
MaybeRequired,
|
|
11
12
|
UnionPick,
|
|
12
13
|
} from '../../internal/types.js'
|
|
13
|
-
import type * as TokenId from '../../ox/TokenId.js'
|
|
14
14
|
import type { TransactionRequestTempo } from '../Transaction.js'
|
|
15
15
|
|
|
16
16
|
export type GetAccountParameter<
|
|
@@ -7,7 +7,6 @@ import { addresses } from '../../../test/config.js'
|
|
|
7
7
|
import { accounts } from '../../../test/viem/config.js'
|
|
8
8
|
import {
|
|
9
9
|
config,
|
|
10
|
-
queryClient,
|
|
11
10
|
setupOrders,
|
|
12
11
|
setupTokenPair,
|
|
13
12
|
} from '../../../test/wagmi/config.js'
|
|
@@ -453,31 +452,6 @@ describe('getOrder', () => {
|
|
|
453
452
|
})
|
|
454
453
|
})
|
|
455
454
|
|
|
456
|
-
describe('getOrders', () => {
|
|
457
|
-
test('default', async () => {
|
|
458
|
-
const response = await Actions.dex.getOrders(config, {
|
|
459
|
-
limit: 10,
|
|
460
|
-
})
|
|
461
|
-
|
|
462
|
-
expect(response).matchSnapshot()
|
|
463
|
-
})
|
|
464
|
-
|
|
465
|
-
describe('infiniteQueryOptions', () => {
|
|
466
|
-
test('default', async () => {
|
|
467
|
-
const options = Actions.dex.getOrders.infiniteQueryOptions(config, {
|
|
468
|
-
limit: 5,
|
|
469
|
-
query: {
|
|
470
|
-
pages: 2,
|
|
471
|
-
},
|
|
472
|
-
})
|
|
473
|
-
|
|
474
|
-
const result = await queryClient.fetchInfiniteQuery(options)
|
|
475
|
-
|
|
476
|
-
expect(result).matchSnapshot()
|
|
477
|
-
})
|
|
478
|
-
})
|
|
479
|
-
})
|
|
480
|
-
|
|
481
455
|
describe('getOrderbook', () => {
|
|
482
456
|
test('default', async () => {
|
|
483
457
|
const { base, quote } = await setupTokenPair()
|
package/src/wagmi/Actions/dex.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import type * as Query from '@tanstack/query-core'
|
|
2
2
|
import { type Config, getConnectorClient } from '@wagmi/core'
|
|
3
3
|
import type { ChainIdParameter, ConnectorParameter } from '@wagmi/core/internal'
|
|
4
|
-
import type * as Hex from 'ox/Hex'
|
|
5
4
|
import type { Account } from 'viem'
|
|
6
|
-
import type {
|
|
7
|
-
PartialBy,
|
|
8
|
-
RequiredBy,
|
|
9
|
-
UnionOmit,
|
|
10
|
-
UnionRequiredBy,
|
|
11
|
-
} from '../../internal/types.js'
|
|
5
|
+
import type { PartialBy, RequiredBy, UnionOmit } from '../../internal/types.js'
|
|
12
6
|
import * as viem_Actions from '../../viem/Actions/dex.js'
|
|
13
7
|
|
|
14
8
|
/**
|
|
@@ -624,110 +618,6 @@ export namespace getOrder {
|
|
|
624
618
|
}
|
|
625
619
|
}
|
|
626
620
|
|
|
627
|
-
/**
|
|
628
|
-
* Gets paginated orders from the orderbook.
|
|
629
|
-
*
|
|
630
|
-
* @example
|
|
631
|
-
* ```ts
|
|
632
|
-
* import { createConfig, http } from '@wagmi/core'
|
|
633
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
634
|
-
* import { Actions } from 'tempo.ts/wagmi'
|
|
635
|
-
*
|
|
636
|
-
* const config = createConfig({
|
|
637
|
-
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
638
|
-
* transports: {
|
|
639
|
-
* [tempo.id]: http(),
|
|
640
|
-
* },
|
|
641
|
-
* })
|
|
642
|
-
*
|
|
643
|
-
* const { orders, nextCursor } = await Actions.dex.getOrders(config, {
|
|
644
|
-
* limit: 100,
|
|
645
|
-
* filters: {
|
|
646
|
-
* baseToken: '0x20c0...',
|
|
647
|
-
* isBid: true,
|
|
648
|
-
* }
|
|
649
|
-
* })
|
|
650
|
-
* ```
|
|
651
|
-
*
|
|
652
|
-
* @param config - Config.
|
|
653
|
-
* @param parameters - Parameters.
|
|
654
|
-
* @returns Paginated orders and next cursor.
|
|
655
|
-
*/
|
|
656
|
-
export function getOrders<config extends Config>(
|
|
657
|
-
config: config,
|
|
658
|
-
parameters: getOrders.Parameters<config> = {},
|
|
659
|
-
): Promise<getOrders.ReturnValue> {
|
|
660
|
-
const { chainId, ...rest } = parameters
|
|
661
|
-
const client = config.getClient({ chainId })
|
|
662
|
-
return viem_Actions.getOrders(client, rest)
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
export namespace getOrders {
|
|
666
|
-
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
667
|
-
viem_Actions.getOrders.Parameters
|
|
668
|
-
|
|
669
|
-
export type ReturnValue = viem_Actions.getOrders.ReturnValue
|
|
670
|
-
|
|
671
|
-
export function queryKey<config extends Config>(
|
|
672
|
-
parameters: Parameters<config>,
|
|
673
|
-
) {
|
|
674
|
-
return ['getOrders', parameters] as const
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
export type QueryKey<config extends Config> = ReturnType<
|
|
678
|
-
typeof queryKey<config>
|
|
679
|
-
>
|
|
680
|
-
|
|
681
|
-
export function infiniteQueryOptions<
|
|
682
|
-
config extends Config,
|
|
683
|
-
selectData = ReturnValue,
|
|
684
|
-
>(
|
|
685
|
-
config: Config,
|
|
686
|
-
parameters: infiniteQueryOptions.Parameters<config, selectData>,
|
|
687
|
-
): infiniteQueryOptions.ReturnValue<config, selectData> {
|
|
688
|
-
const { cursor, query, ...rest } = parameters
|
|
689
|
-
return {
|
|
690
|
-
pages: 1,
|
|
691
|
-
...query,
|
|
692
|
-
getNextPageParam: (x) => x.nextCursor,
|
|
693
|
-
initialPageParam: cursor ?? undefined,
|
|
694
|
-
queryKey: queryKey(rest),
|
|
695
|
-
async queryFn({ queryKey, pageParam: cursor }) {
|
|
696
|
-
const [, parameters] = queryKey
|
|
697
|
-
return await getOrders(config, { ...parameters, cursor })
|
|
698
|
-
},
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
export declare namespace infiniteQueryOptions {
|
|
703
|
-
export type Parameters<
|
|
704
|
-
config extends Config,
|
|
705
|
-
selectData = getOrders.ReturnValue,
|
|
706
|
-
> = getOrders.Parameters<config> & {
|
|
707
|
-
query?:
|
|
708
|
-
| Omit<
|
|
709
|
-
ReturnValue<config, selectData>,
|
|
710
|
-
'initialPageParam' | 'queryKey' | 'queryFn'
|
|
711
|
-
>
|
|
712
|
-
| undefined
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
export type ReturnValue<
|
|
716
|
-
config extends Config,
|
|
717
|
-
selectData = getOrders.ReturnValue,
|
|
718
|
-
> = UnionRequiredBy<
|
|
719
|
-
Query.FetchInfiniteQueryOptions<
|
|
720
|
-
getOrders.ReturnValue,
|
|
721
|
-
Query.DefaultError,
|
|
722
|
-
selectData,
|
|
723
|
-
getOrders.QueryKey<config>,
|
|
724
|
-
Hex.Hex | undefined
|
|
725
|
-
>,
|
|
726
|
-
'queryKey' | 'queryFn'
|
|
727
|
-
>
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
|
|
731
621
|
/**
|
|
732
622
|
* Gets orderbook information for a trading pair.
|
|
733
623
|
*
|
|
@@ -21,7 +21,7 @@ describe('getNonce', () => {
|
|
|
21
21
|
account: account.address,
|
|
22
22
|
nonceKey: 1n,
|
|
23
23
|
})
|
|
24
|
-
expect(result).toBe(
|
|
24
|
+
expect(result).toBe(0n)
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
describe('queryOptions', () => {
|
|
@@ -31,7 +31,7 @@ describe('getNonce', () => {
|
|
|
31
31
|
nonceKey: 1n,
|
|
32
32
|
})
|
|
33
33
|
const result = await queryClient.fetchQuery(options)
|
|
34
|
-
expect(result).toBe(
|
|
34
|
+
expect(result).toBe(0n)
|
|
35
35
|
})
|
|
36
36
|
})
|
|
37
37
|
})
|
|
@@ -112,6 +112,10 @@ describe('watchActiveKeyCountChanged', () => {
|
|
|
112
112
|
},
|
|
113
113
|
})
|
|
114
114
|
|
|
115
|
+
const priorKeyCount = await getNonceKeyCount(config, {
|
|
116
|
+
account: account.address,
|
|
117
|
+
})
|
|
118
|
+
|
|
115
119
|
// First use of nonceKey 10 should increment active key count
|
|
116
120
|
await token.transferSync(config, {
|
|
117
121
|
to: account2.address,
|
|
@@ -134,8 +138,8 @@ describe('watchActiveKeyCountChanged', () => {
|
|
|
134
138
|
|
|
135
139
|
expect(events).toHaveLength(2)
|
|
136
140
|
expect(events[0]?.account).toBe(account.address)
|
|
137
|
-
expect(events[0]?.newCount).toBe(1n)
|
|
138
|
-
expect(events[1]?.newCount).toBe(2n)
|
|
141
|
+
expect(events[0]?.newCount - priorKeyCount).toBe(1n)
|
|
142
|
+
expect(events[1]?.newCount - priorKeyCount).toBe(2n)
|
|
139
143
|
unwatch()
|
|
140
144
|
})
|
|
141
145
|
})
|
|
@@ -74,7 +74,7 @@ describe('getMetadata', () => {
|
|
|
74
74
|
"quoteToken": "0x20C0000000000000000000000000000000000000",
|
|
75
75
|
"supplyCap": 340282366920938463463374607431768211455n,
|
|
76
76
|
"symbol": "AlphaUSD",
|
|
77
|
-
"totalSupply":
|
|
77
|
+
"totalSupply": 202914184810805067765n,
|
|
78
78
|
"transferPolicyId": 1n,
|
|
79
79
|
}
|
|
80
80
|
`)
|
|
@@ -96,7 +96,7 @@ describe('getMetadata', () => {
|
|
|
96
96
|
"quoteToken": "0x20C0000000000000000000000000000000000000",
|
|
97
97
|
"supplyCap": 340282366920938463463374607431768211455n,
|
|
98
98
|
"symbol": "AlphaUSD",
|
|
99
|
-
"totalSupply":
|
|
99
|
+
"totalSupply": 202914184810805067765n,
|
|
100
100
|
"transferPolicyId": 1n,
|
|
101
101
|
}
|
|
102
102
|
`)
|
package/src/wagmi/Connector.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Address from 'ox/Address'
|
|
2
2
|
import type * as Hex from 'ox/Hex'
|
|
3
3
|
import * as PublicKey from 'ox/PublicKey'
|
|
4
|
+
import { KeyAuthorization, SignatureEnvelope } from 'ox/tempo'
|
|
4
5
|
import {
|
|
5
6
|
createClient,
|
|
6
7
|
type EIP1193Provider,
|
|
@@ -11,8 +12,6 @@ import {
|
|
|
11
12
|
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
|
|
12
13
|
import { ChainNotConfiguredError, createConnector } from 'wagmi'
|
|
13
14
|
import type { OneOf } from '../internal/types.js'
|
|
14
|
-
import * as KeyAuthorization from '../ox/KeyAuthorization.js'
|
|
15
|
-
import * as SignatureEnvelope from '../ox/SignatureEnvelope.js'
|
|
16
15
|
import * as Account from '../viem/Account.js'
|
|
17
16
|
import type * as tempo_Chain from '../viem/Chain.js'
|
|
18
17
|
import { normalizeValue } from '../viem/internal/utils.js'
|
|
@@ -8,7 +8,6 @@ import { accounts } from '../../../test/viem/config.js'
|
|
|
8
8
|
import {
|
|
9
9
|
config,
|
|
10
10
|
renderHook,
|
|
11
|
-
setupOrders,
|
|
12
11
|
setupTokenPair,
|
|
13
12
|
} from '../../../test/wagmi/config.js'
|
|
14
13
|
|
|
@@ -421,31 +420,6 @@ describe('useOrder', () => {
|
|
|
421
420
|
})
|
|
422
421
|
})
|
|
423
422
|
|
|
424
|
-
describe('useGetOrders', () => {
|
|
425
|
-
test('default', async () => {
|
|
426
|
-
await setupOrders()
|
|
427
|
-
|
|
428
|
-
const { result } = await renderHook(() =>
|
|
429
|
-
Hooks.dex.useGetOrders({
|
|
430
|
-
limit: 10,
|
|
431
|
-
}),
|
|
432
|
-
)
|
|
433
|
-
|
|
434
|
-
await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy())
|
|
435
|
-
|
|
436
|
-
expect(result.current.data).matchSnapshot()
|
|
437
|
-
|
|
438
|
-
// fetch next page
|
|
439
|
-
result.current.fetchNextPage()
|
|
440
|
-
|
|
441
|
-
await vi.waitFor(() => {
|
|
442
|
-
expect(result.current.data?.pages.length).toBe(2)
|
|
443
|
-
})
|
|
444
|
-
|
|
445
|
-
expect(result.current.data).matchSnapshot()
|
|
446
|
-
})
|
|
447
|
-
})
|
|
448
|
-
|
|
449
423
|
describe('useOrderbook', () => {
|
|
450
424
|
test('default', async () => {
|
|
451
425
|
const { base, quote } = await setupTokenPair()
|
package/src/wagmi/Hooks/dex.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type { DefaultError
|
|
1
|
+
import type { DefaultError } from '@tanstack/query-core'
|
|
2
2
|
import type { UseMutationResult } from '@tanstack/react-query'
|
|
3
3
|
import type { Config, ResolvedRegister } from '@wagmi/core'
|
|
4
4
|
import { useEffect } from 'react'
|
|
5
5
|
import { useChainId, useConfig } from 'wagmi'
|
|
6
6
|
import type { ConfigParameter, QueryParameter } from 'wagmi/internal'
|
|
7
7
|
import {
|
|
8
|
-
type UseInfiniteQueryReturnType,
|
|
9
8
|
type UseMutationParameters,
|
|
10
9
|
type UseQueryReturnType,
|
|
11
|
-
useInfiniteQuery,
|
|
12
10
|
useMutation,
|
|
13
11
|
useQuery,
|
|
14
12
|
} from 'wagmi/query'
|
|
@@ -25,7 +23,6 @@ import {
|
|
|
25
23
|
getBuyQuote,
|
|
26
24
|
getOrder,
|
|
27
25
|
getOrderbook,
|
|
28
|
-
getOrders,
|
|
29
26
|
getSellQuote,
|
|
30
27
|
getTickLevel,
|
|
31
28
|
place,
|
|
@@ -641,90 +638,6 @@ export declare namespace useOrder {
|
|
|
641
638
|
UseQueryReturnType<selectData, Error>
|
|
642
639
|
}
|
|
643
640
|
|
|
644
|
-
/**
|
|
645
|
-
* Hook for getting paginated orders from the orderbook.
|
|
646
|
-
*
|
|
647
|
-
* @example
|
|
648
|
-
* ```tsx
|
|
649
|
-
* import { Hooks } from 'tempo.ts/wagmi'
|
|
650
|
-
*
|
|
651
|
-
* function App() {
|
|
652
|
-
* const { data, fetchNextPage, hasNextPage, isFetchingNextPage } = Hooks.dex.useGetOrders({
|
|
653
|
-
* limit: 10,
|
|
654
|
-
* filters: {
|
|
655
|
-
* baseToken: '0x20c0...',
|
|
656
|
-
* isBid: true,
|
|
657
|
-
* }
|
|
658
|
-
* })
|
|
659
|
-
*
|
|
660
|
-
* return (
|
|
661
|
-
* <div>
|
|
662
|
-
* {data?.pages.map((page, i) => (
|
|
663
|
-
* <div key={i}>
|
|
664
|
-
* {page.orders.map((order) => (
|
|
665
|
-
* <div key={order.orderId.toString()}>{order.amount.toString()}</div>
|
|
666
|
-
* ))}
|
|
667
|
-
* </div>
|
|
668
|
-
* ))}
|
|
669
|
-
* {hasNextPage && (
|
|
670
|
-
* <button onClick={() => fetchNextPage()} disabled={isFetchingNextPage}>
|
|
671
|
-
* Load More
|
|
672
|
-
* </button>
|
|
673
|
-
* )}
|
|
674
|
-
* </div>
|
|
675
|
-
* )
|
|
676
|
-
* }
|
|
677
|
-
* ```
|
|
678
|
-
*
|
|
679
|
-
* @param parameters - Parameters.
|
|
680
|
-
* @returns Infinite query result with paginated orders.
|
|
681
|
-
*/
|
|
682
|
-
export function useGetOrders<
|
|
683
|
-
config extends Config = ResolvedRegister['config'],
|
|
684
|
-
selectData = getOrders.ReturnValue,
|
|
685
|
-
>(parameters: useGetOrders.Parameters<config, selectData> = {}) {
|
|
686
|
-
const { query = {}, ...rest } = parameters
|
|
687
|
-
|
|
688
|
-
const config = useConfig(parameters)
|
|
689
|
-
const chainId = useChainId({ config })
|
|
690
|
-
|
|
691
|
-
const options = getOrders.infiniteQueryOptions(config, {
|
|
692
|
-
...rest,
|
|
693
|
-
chainId: parameters.chainId ?? chainId,
|
|
694
|
-
query: undefined,
|
|
695
|
-
})
|
|
696
|
-
|
|
697
|
-
return useInfiniteQuery({
|
|
698
|
-
...query,
|
|
699
|
-
...options,
|
|
700
|
-
} as never) as useGetOrders.ReturnValue<selectData>
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
export declare namespace useGetOrders {
|
|
704
|
-
export type Parameters<
|
|
705
|
-
config extends Config = ResolvedRegister['config'],
|
|
706
|
-
selectData = getOrders.ReturnValue,
|
|
707
|
-
> = ConfigParameter<config> &
|
|
708
|
-
Omit<
|
|
709
|
-
QueryParameter<
|
|
710
|
-
getOrders.ReturnValue,
|
|
711
|
-
DefaultError,
|
|
712
|
-
selectData,
|
|
713
|
-
getOrders.QueryKey<config>
|
|
714
|
-
>,
|
|
715
|
-
'queryFn' | 'queryKey'
|
|
716
|
-
> &
|
|
717
|
-
ExactPartial<
|
|
718
|
-
Omit<
|
|
719
|
-
getOrders.infiniteQueryOptions.Parameters<config, selectData>,
|
|
720
|
-
'query'
|
|
721
|
-
>
|
|
722
|
-
>
|
|
723
|
-
|
|
724
|
-
export type ReturnValue<selectData = getOrders.ReturnValue> =
|
|
725
|
-
UseInfiniteQueryReturnType<InfiniteData<selectData>, Error>
|
|
726
|
-
}
|
|
727
|
-
|
|
728
641
|
/**
|
|
729
642
|
* Hook for getting orderbook information for a trading pair.
|
|
730
643
|
*
|
|
@@ -38,7 +38,7 @@ describe('useNonce', () => {
|
|
|
38
38
|
|
|
39
39
|
// Should now be enabled and have data
|
|
40
40
|
expect(result.current.isEnabled).toBe(true)
|
|
41
|
-
expect(result.current.data).toBe(
|
|
41
|
+
expect(result.current.data).toBe(0n)
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
test('reactivity: account parameter', async () => {
|
|
@@ -62,7 +62,7 @@ describe('useNonce', () => {
|
|
|
62
62
|
})
|
|
63
63
|
|
|
64
64
|
expect(result.current.isEnabled).toBe(true)
|
|
65
|
-
expect(result.current.data).toBe(
|
|
65
|
+
expect(result.current.data).toBe(0n)
|
|
66
66
|
})
|
|
67
67
|
|
|
68
68
|
test('reactivity: nonceKey parameter', async () => {
|
|
@@ -86,7 +86,7 @@ describe('useNonce', () => {
|
|
|
86
86
|
})
|
|
87
87
|
|
|
88
88
|
expect(result.current.isEnabled).toBe(true)
|
|
89
|
-
expect(result.current.data).toBe(
|
|
89
|
+
expect(result.current.data).toBe(0n)
|
|
90
90
|
})
|
|
91
91
|
})
|
|
92
92
|
|
package/src/wagmi/index.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * as Actions from './Actions/index.js'
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
dangerous_secp256k1,
|
|
4
|
+
webAuthn,
|
|
5
|
+
} from './Connector.js'
|
|
3
6
|
export * as Hooks from './Hooks/index.js'
|
|
4
7
|
export * as KeyManager from './KeyManager.js'
|