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
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
import type { DefaultError } from '@tanstack/query-core'
|
|
2
|
+
import type { UseMutationResult } from '@tanstack/react-query'
|
|
3
|
+
import type { Config, ResolvedRegister } from '@wagmi/core'
|
|
4
|
+
import { useChainId, useConfig } from 'wagmi'
|
|
5
|
+
import type { ConfigParameter, QueryParameter } from 'wagmi/internal'
|
|
6
|
+
import {
|
|
7
|
+
type UseMutationParameters,
|
|
8
|
+
type UseQueryReturnType,
|
|
9
|
+
useMutation,
|
|
10
|
+
useQuery,
|
|
11
|
+
} from 'wagmi/query'
|
|
12
|
+
import type { ExactPartial } from '../../internal/types.js'
|
|
13
|
+
import * as Actions from '../Actions/reward.js'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Hook for canceling an active reward stream.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
21
|
+
*
|
|
22
|
+
* function App() {
|
|
23
|
+
* const { mutate: cancel } = Hooks.reward.useCancel()
|
|
24
|
+
*
|
|
25
|
+
* return (
|
|
26
|
+
* <button onClick={() => cancel({
|
|
27
|
+
* id: 1n,
|
|
28
|
+
* token: '0x20c0000000000000000000000000000000000001'
|
|
29
|
+
* })}>
|
|
30
|
+
* Cancel Stream
|
|
31
|
+
* </button>
|
|
32
|
+
* )
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param parameters - Parameters.
|
|
37
|
+
* @returns Mutation result.
|
|
38
|
+
*/
|
|
39
|
+
export function useCancel<
|
|
40
|
+
config extends Config = ResolvedRegister['config'],
|
|
41
|
+
context = unknown,
|
|
42
|
+
>(
|
|
43
|
+
parameters: useCancel.Parameters<config, context> = {},
|
|
44
|
+
): useCancel.ReturnType<config, context> {
|
|
45
|
+
const { mutation } = parameters
|
|
46
|
+
const config = useConfig(parameters)
|
|
47
|
+
return useMutation({
|
|
48
|
+
...mutation,
|
|
49
|
+
async mutationFn(variables) {
|
|
50
|
+
return Actions.cancel(config, variables)
|
|
51
|
+
},
|
|
52
|
+
mutationKey: ['cancel'],
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export declare namespace useCancel {
|
|
57
|
+
type Parameters<
|
|
58
|
+
config extends Config = Config,
|
|
59
|
+
context = unknown,
|
|
60
|
+
> = ConfigParameter<config> & {
|
|
61
|
+
mutation?:
|
|
62
|
+
| UseMutationParameters<
|
|
63
|
+
Actions.cancel.ReturnValue,
|
|
64
|
+
Actions.cancel.ErrorType,
|
|
65
|
+
Actions.cancel.Parameters<config>,
|
|
66
|
+
context
|
|
67
|
+
>
|
|
68
|
+
| undefined
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type ReturnType<
|
|
72
|
+
config extends Config = Config,
|
|
73
|
+
context = unknown,
|
|
74
|
+
> = UseMutationResult<
|
|
75
|
+
Actions.cancel.ReturnValue,
|
|
76
|
+
Actions.cancel.ErrorType,
|
|
77
|
+
Actions.cancel.Parameters<config>,
|
|
78
|
+
context
|
|
79
|
+
>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Hook for canceling an active reward stream and waiting for confirmation.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
88
|
+
*
|
|
89
|
+
* function App() {
|
|
90
|
+
* const { mutate: cancelSync } = Hooks.reward.useCancelSync()
|
|
91
|
+
*
|
|
92
|
+
* return (
|
|
93
|
+
* <button onClick={() => cancelSync({
|
|
94
|
+
* id: 1n,
|
|
95
|
+
* token: '0x20c0000000000000000000000000000000000001'
|
|
96
|
+
* })}>
|
|
97
|
+
* Cancel Stream
|
|
98
|
+
* </button>
|
|
99
|
+
* )
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @param parameters - Parameters.
|
|
104
|
+
* @returns Mutation result.
|
|
105
|
+
*/
|
|
106
|
+
export function useCancelSync<
|
|
107
|
+
config extends Config = ResolvedRegister['config'],
|
|
108
|
+
context = unknown,
|
|
109
|
+
>(
|
|
110
|
+
parameters: useCancelSync.Parameters<config, context> = {},
|
|
111
|
+
): useCancelSync.ReturnType<config, context> {
|
|
112
|
+
const { mutation } = parameters
|
|
113
|
+
const config = useConfig(parameters)
|
|
114
|
+
return useMutation({
|
|
115
|
+
...mutation,
|
|
116
|
+
async mutationFn(variables) {
|
|
117
|
+
return Actions.cancelSync(config, variables)
|
|
118
|
+
},
|
|
119
|
+
mutationKey: ['cancelSync'],
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export declare namespace useCancelSync {
|
|
124
|
+
type Parameters<
|
|
125
|
+
config extends Config = Config,
|
|
126
|
+
context = unknown,
|
|
127
|
+
> = ConfigParameter<config> & {
|
|
128
|
+
mutation?:
|
|
129
|
+
| UseMutationParameters<
|
|
130
|
+
Actions.cancelSync.ReturnValue,
|
|
131
|
+
Actions.cancelSync.ErrorType,
|
|
132
|
+
Actions.cancelSync.Parameters<config>,
|
|
133
|
+
context
|
|
134
|
+
>
|
|
135
|
+
| undefined
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
type ReturnType<
|
|
139
|
+
config extends Config = Config,
|
|
140
|
+
context = unknown,
|
|
141
|
+
> = UseMutationResult<
|
|
142
|
+
Actions.cancelSync.ReturnValue,
|
|
143
|
+
Actions.cancelSync.ErrorType,
|
|
144
|
+
Actions.cancelSync.Parameters<config>,
|
|
145
|
+
context
|
|
146
|
+
>
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Hook for claiming accumulated rewards.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```tsx
|
|
154
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
155
|
+
*
|
|
156
|
+
* function App() {
|
|
157
|
+
* const { mutate: claim } = Hooks.reward.useClaim()
|
|
158
|
+
*
|
|
159
|
+
* return (
|
|
160
|
+
* <button onClick={() => claim({
|
|
161
|
+
* token: '0x20c0000000000000000000000000000000000001'
|
|
162
|
+
* })}>
|
|
163
|
+
* Claim Rewards
|
|
164
|
+
* </button>
|
|
165
|
+
* )
|
|
166
|
+
* }
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @param parameters - Parameters.
|
|
170
|
+
* @returns Mutation result.
|
|
171
|
+
*/
|
|
172
|
+
export function useClaim<
|
|
173
|
+
config extends Config = ResolvedRegister['config'],
|
|
174
|
+
context = unknown,
|
|
175
|
+
>(
|
|
176
|
+
parameters: useClaim.Parameters<config, context> = {},
|
|
177
|
+
): useClaim.ReturnType<config, context> {
|
|
178
|
+
const { mutation } = parameters
|
|
179
|
+
const config = useConfig(parameters)
|
|
180
|
+
return useMutation({
|
|
181
|
+
...mutation,
|
|
182
|
+
async mutationFn(variables) {
|
|
183
|
+
return Actions.claim(config, variables)
|
|
184
|
+
},
|
|
185
|
+
mutationKey: ['claim'],
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export declare namespace useClaim {
|
|
190
|
+
type Parameters<
|
|
191
|
+
config extends Config = Config,
|
|
192
|
+
context = unknown,
|
|
193
|
+
> = ConfigParameter<config> & {
|
|
194
|
+
mutation?:
|
|
195
|
+
| UseMutationParameters<
|
|
196
|
+
Actions.claim.ReturnValue,
|
|
197
|
+
Actions.claim.ErrorType,
|
|
198
|
+
Actions.claim.Parameters<config>,
|
|
199
|
+
context
|
|
200
|
+
>
|
|
201
|
+
| undefined
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
type ReturnType<
|
|
205
|
+
config extends Config = Config,
|
|
206
|
+
context = unknown,
|
|
207
|
+
> = UseMutationResult<
|
|
208
|
+
Actions.claim.ReturnValue,
|
|
209
|
+
Actions.claim.ErrorType,
|
|
210
|
+
Actions.claim.Parameters<config>,
|
|
211
|
+
context
|
|
212
|
+
>
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Hook for claiming accumulated rewards and waiting for confirmation.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```tsx
|
|
220
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
221
|
+
*
|
|
222
|
+
* function App() {
|
|
223
|
+
* const { mutate: claimSync } = Hooks.reward.useClaimSync()
|
|
224
|
+
*
|
|
225
|
+
* return (
|
|
226
|
+
* <button onClick={() => claimSync({
|
|
227
|
+
* token: '0x20c0000000000000000000000000000000000001'
|
|
228
|
+
* })}>
|
|
229
|
+
* Claim Rewards
|
|
230
|
+
* </button>
|
|
231
|
+
* )
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @param parameters - Parameters.
|
|
236
|
+
* @returns Mutation result.
|
|
237
|
+
*/
|
|
238
|
+
export function useClaimSync<
|
|
239
|
+
config extends Config = ResolvedRegister['config'],
|
|
240
|
+
context = unknown,
|
|
241
|
+
>(
|
|
242
|
+
parameters: useClaimSync.Parameters<config, context> = {},
|
|
243
|
+
): useClaimSync.ReturnType<config, context> {
|
|
244
|
+
const { mutation } = parameters
|
|
245
|
+
const config = useConfig(parameters)
|
|
246
|
+
return useMutation({
|
|
247
|
+
...mutation,
|
|
248
|
+
async mutationFn(variables) {
|
|
249
|
+
return Actions.claimSync(config, variables)
|
|
250
|
+
},
|
|
251
|
+
mutationKey: ['claimSync'],
|
|
252
|
+
})
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export declare namespace useClaimSync {
|
|
256
|
+
type Parameters<
|
|
257
|
+
config extends Config = Config,
|
|
258
|
+
context = unknown,
|
|
259
|
+
> = ConfigParameter<config> & {
|
|
260
|
+
mutation?:
|
|
261
|
+
| UseMutationParameters<
|
|
262
|
+
Actions.claimSync.ReturnValue,
|
|
263
|
+
Actions.claimSync.ErrorType,
|
|
264
|
+
Actions.claimSync.Parameters<config>,
|
|
265
|
+
context
|
|
266
|
+
>
|
|
267
|
+
| undefined
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
type ReturnType<
|
|
271
|
+
config extends Config = Config,
|
|
272
|
+
context = unknown,
|
|
273
|
+
> = UseMutationResult<
|
|
274
|
+
Actions.claimSync.ReturnValue,
|
|
275
|
+
Actions.claimSync.ErrorType,
|
|
276
|
+
Actions.claimSync.Parameters<config>,
|
|
277
|
+
context
|
|
278
|
+
>
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Hook for getting a reward stream by its ID.
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```tsx
|
|
286
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
287
|
+
*
|
|
288
|
+
* function App() {
|
|
289
|
+
* const { data, isLoading } = Hooks.reward.useGetStream({
|
|
290
|
+
* id: 1n,
|
|
291
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
292
|
+
* })
|
|
293
|
+
*
|
|
294
|
+
* if (isLoading) return <div>Loading...</div>
|
|
295
|
+
* return <div>Funder: {data?.funder}</div>
|
|
296
|
+
* }
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @param parameters - Parameters.
|
|
300
|
+
* @returns Query result with stream details.
|
|
301
|
+
*/
|
|
302
|
+
export function useGetStream<
|
|
303
|
+
config extends Config = ResolvedRegister['config'],
|
|
304
|
+
selectData = Actions.getStream.ReturnValue,
|
|
305
|
+
>(parameters: useGetStream.Parameters<config, selectData> = {}) {
|
|
306
|
+
const { id, query = {}, token } = parameters
|
|
307
|
+
|
|
308
|
+
const config = useConfig(parameters)
|
|
309
|
+
const chainId = useChainId({ config })
|
|
310
|
+
|
|
311
|
+
const options = Actions.getStream.queryOptions(config, {
|
|
312
|
+
...parameters,
|
|
313
|
+
chainId: parameters.chainId ?? chainId,
|
|
314
|
+
query: undefined,
|
|
315
|
+
} as never)
|
|
316
|
+
const enabled = Boolean(id !== undefined && token && (query.enabled ?? true))
|
|
317
|
+
|
|
318
|
+
return useQuery({ ...query, ...options, enabled })
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export declare namespace useGetStream {
|
|
322
|
+
export type Parameters<
|
|
323
|
+
config extends Config = ResolvedRegister['config'],
|
|
324
|
+
selectData = Actions.getStream.ReturnValue,
|
|
325
|
+
> = ConfigParameter<config> &
|
|
326
|
+
QueryParameter<
|
|
327
|
+
Actions.getStream.ReturnValue,
|
|
328
|
+
DefaultError,
|
|
329
|
+
selectData,
|
|
330
|
+
Actions.getStream.QueryKey<config>
|
|
331
|
+
> &
|
|
332
|
+
ExactPartial<
|
|
333
|
+
Omit<
|
|
334
|
+
Actions.getStream.queryOptions.Parameters<config, selectData>,
|
|
335
|
+
'query'
|
|
336
|
+
>
|
|
337
|
+
>
|
|
338
|
+
|
|
339
|
+
export type ReturnValue<selectData = Actions.getStream.ReturnValue> =
|
|
340
|
+
UseQueryReturnType<selectData, Error>
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Hook for getting the total reward per second rate.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```tsx
|
|
348
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
349
|
+
*
|
|
350
|
+
* function App() {
|
|
351
|
+
* const { data, isLoading } = Hooks.reward.useGetTotalPerSecond({
|
|
352
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
353
|
+
* })
|
|
354
|
+
*
|
|
355
|
+
* if (isLoading) return <div>Loading...</div>
|
|
356
|
+
* return <div>Rate: {data?.toString()}</div>
|
|
357
|
+
* }
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @param parameters - Parameters.
|
|
361
|
+
* @returns Query result with total reward per second.
|
|
362
|
+
*/
|
|
363
|
+
export function useGetTotalPerSecond<
|
|
364
|
+
config extends Config = ResolvedRegister['config'],
|
|
365
|
+
selectData = Actions.getTotalPerSecond.ReturnValue,
|
|
366
|
+
>(parameters: useGetTotalPerSecond.Parameters<config, selectData> = {}) {
|
|
367
|
+
const { query = {}, token } = parameters
|
|
368
|
+
|
|
369
|
+
const config = useConfig(parameters)
|
|
370
|
+
const chainId = useChainId({ config })
|
|
371
|
+
|
|
372
|
+
const options = Actions.getTotalPerSecond.queryOptions(config, {
|
|
373
|
+
...parameters,
|
|
374
|
+
chainId: parameters.chainId ?? chainId,
|
|
375
|
+
query: undefined,
|
|
376
|
+
} as never)
|
|
377
|
+
const enabled = Boolean(token && (query.enabled ?? true))
|
|
378
|
+
|
|
379
|
+
return useQuery({ ...query, ...options, enabled })
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export declare namespace useGetTotalPerSecond {
|
|
383
|
+
export type Parameters<
|
|
384
|
+
config extends Config = ResolvedRegister['config'],
|
|
385
|
+
selectData = Actions.getTotalPerSecond.ReturnValue,
|
|
386
|
+
> = ConfigParameter<config> &
|
|
387
|
+
QueryParameter<
|
|
388
|
+
Actions.getTotalPerSecond.ReturnValue,
|
|
389
|
+
DefaultError,
|
|
390
|
+
selectData,
|
|
391
|
+
Actions.getTotalPerSecond.QueryKey<config>
|
|
392
|
+
> &
|
|
393
|
+
ExactPartial<
|
|
394
|
+
Omit<
|
|
395
|
+
Actions.getTotalPerSecond.queryOptions.Parameters<config, selectData>,
|
|
396
|
+
'query'
|
|
397
|
+
>
|
|
398
|
+
>
|
|
399
|
+
|
|
400
|
+
export type ReturnValue<selectData = Actions.getTotalPerSecond.ReturnValue> =
|
|
401
|
+
UseQueryReturnType<selectData, Error>
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Hook for setting the reward recipient for a token holder.
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```tsx
|
|
409
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
410
|
+
*
|
|
411
|
+
* function App() {
|
|
412
|
+
* const { mutate: setRecipient } = Hooks.reward.useSetRecipient()
|
|
413
|
+
*
|
|
414
|
+
* return (
|
|
415
|
+
* <button onClick={() => setRecipient({
|
|
416
|
+
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
|
417
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
418
|
+
* })}>
|
|
419
|
+
* Set Recipient
|
|
420
|
+
* </button>
|
|
421
|
+
* )
|
|
422
|
+
* }
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
* @param parameters - Parameters.
|
|
426
|
+
* @returns Mutation result.
|
|
427
|
+
*/
|
|
428
|
+
export function useSetRecipient<
|
|
429
|
+
config extends Config = ResolvedRegister['config'],
|
|
430
|
+
context = unknown,
|
|
431
|
+
>(
|
|
432
|
+
parameters: useSetRecipient.Parameters<config, context> = {},
|
|
433
|
+
): useSetRecipient.ReturnType<config, context> {
|
|
434
|
+
const { mutation } = parameters
|
|
435
|
+
const config = useConfig(parameters)
|
|
436
|
+
return useMutation({
|
|
437
|
+
...mutation,
|
|
438
|
+
async mutationFn(variables) {
|
|
439
|
+
return Actions.setRecipient(config, variables)
|
|
440
|
+
},
|
|
441
|
+
mutationKey: ['setRecipient'],
|
|
442
|
+
})
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export declare namespace useSetRecipient {
|
|
446
|
+
type Parameters<
|
|
447
|
+
config extends Config = Config,
|
|
448
|
+
context = unknown,
|
|
449
|
+
> = ConfigParameter<config> & {
|
|
450
|
+
mutation?:
|
|
451
|
+
| UseMutationParameters<
|
|
452
|
+
Actions.setRecipient.ReturnValue,
|
|
453
|
+
Actions.setRecipient.ErrorType,
|
|
454
|
+
Actions.setRecipient.Parameters<config>,
|
|
455
|
+
context
|
|
456
|
+
>
|
|
457
|
+
| undefined
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
type ReturnType<
|
|
461
|
+
config extends Config = Config,
|
|
462
|
+
context = unknown,
|
|
463
|
+
> = UseMutationResult<
|
|
464
|
+
Actions.setRecipient.ReturnValue,
|
|
465
|
+
Actions.setRecipient.ErrorType,
|
|
466
|
+
Actions.setRecipient.Parameters<config>,
|
|
467
|
+
context
|
|
468
|
+
>
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Hook for setting the reward recipient and waiting for confirmation.
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* ```tsx
|
|
476
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
477
|
+
*
|
|
478
|
+
* function App() {
|
|
479
|
+
* const { mutate: setRecipientSync } = Hooks.reward.useSetRecipientSync()
|
|
480
|
+
*
|
|
481
|
+
* return (
|
|
482
|
+
* <button onClick={() => setRecipientSync({
|
|
483
|
+
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
|
484
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
485
|
+
* })}>
|
|
486
|
+
* Set Recipient
|
|
487
|
+
* </button>
|
|
488
|
+
* )
|
|
489
|
+
* }
|
|
490
|
+
* ```
|
|
491
|
+
*
|
|
492
|
+
* @param parameters - Parameters.
|
|
493
|
+
* @returns Mutation result.
|
|
494
|
+
*/
|
|
495
|
+
export function useSetRecipientSync<
|
|
496
|
+
config extends Config = ResolvedRegister['config'],
|
|
497
|
+
context = unknown,
|
|
498
|
+
>(
|
|
499
|
+
parameters: useSetRecipientSync.Parameters<config, context> = {},
|
|
500
|
+
): useSetRecipientSync.ReturnType<config, context> {
|
|
501
|
+
const { mutation } = parameters
|
|
502
|
+
const config = useConfig(parameters)
|
|
503
|
+
return useMutation({
|
|
504
|
+
...mutation,
|
|
505
|
+
async mutationFn(variables) {
|
|
506
|
+
return Actions.setRecipientSync(config, variables)
|
|
507
|
+
},
|
|
508
|
+
mutationKey: ['setRecipientSync'],
|
|
509
|
+
})
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export declare namespace useSetRecipientSync {
|
|
513
|
+
type Parameters<
|
|
514
|
+
config extends Config = Config,
|
|
515
|
+
context = unknown,
|
|
516
|
+
> = ConfigParameter<config> & {
|
|
517
|
+
mutation?:
|
|
518
|
+
| UseMutationParameters<
|
|
519
|
+
Actions.setRecipientSync.ReturnValue,
|
|
520
|
+
Actions.setRecipientSync.ErrorType,
|
|
521
|
+
Actions.setRecipientSync.Parameters<config>,
|
|
522
|
+
context
|
|
523
|
+
>
|
|
524
|
+
| undefined
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
type ReturnType<
|
|
528
|
+
config extends Config = Config,
|
|
529
|
+
context = unknown,
|
|
530
|
+
> = UseMutationResult<
|
|
531
|
+
Actions.setRecipientSync.ReturnValue,
|
|
532
|
+
Actions.setRecipientSync.ErrorType,
|
|
533
|
+
Actions.setRecipientSync.Parameters<config>,
|
|
534
|
+
context
|
|
535
|
+
>
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Hook for starting a new reward stream.
|
|
540
|
+
*
|
|
541
|
+
* @example
|
|
542
|
+
* ```tsx
|
|
543
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
544
|
+
*
|
|
545
|
+
* function App() {
|
|
546
|
+
* const { mutate: start } = Hooks.reward.useStart()
|
|
547
|
+
*
|
|
548
|
+
* return (
|
|
549
|
+
* <button onClick={() => start({
|
|
550
|
+
* amount: 100000000000000000000n,
|
|
551
|
+
* seconds: 86400,
|
|
552
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
553
|
+
* })}>
|
|
554
|
+
* Start Reward
|
|
555
|
+
* </button>
|
|
556
|
+
* )
|
|
557
|
+
* }
|
|
558
|
+
* ```
|
|
559
|
+
*
|
|
560
|
+
* @param parameters - Parameters.
|
|
561
|
+
* @returns Mutation result.
|
|
562
|
+
*/
|
|
563
|
+
export function useStart<
|
|
564
|
+
config extends Config = ResolvedRegister['config'],
|
|
565
|
+
context = unknown,
|
|
566
|
+
>(
|
|
567
|
+
parameters: useStart.Parameters<config, context> = {},
|
|
568
|
+
): useStart.ReturnType<config, context> {
|
|
569
|
+
const { mutation } = parameters
|
|
570
|
+
const config = useConfig(parameters)
|
|
571
|
+
return useMutation({
|
|
572
|
+
...mutation,
|
|
573
|
+
async mutationFn(variables) {
|
|
574
|
+
return Actions.start(config, variables)
|
|
575
|
+
},
|
|
576
|
+
mutationKey: ['start'],
|
|
577
|
+
})
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
export declare namespace useStart {
|
|
581
|
+
type Parameters<
|
|
582
|
+
config extends Config = Config,
|
|
583
|
+
context = unknown,
|
|
584
|
+
> = ConfigParameter<config> & {
|
|
585
|
+
mutation?:
|
|
586
|
+
| UseMutationParameters<
|
|
587
|
+
Actions.start.ReturnValue,
|
|
588
|
+
Actions.start.ErrorType,
|
|
589
|
+
Actions.start.Parameters<config>,
|
|
590
|
+
context
|
|
591
|
+
>
|
|
592
|
+
| undefined
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
type ReturnType<
|
|
596
|
+
config extends Config = Config,
|
|
597
|
+
context = unknown,
|
|
598
|
+
> = UseMutationResult<
|
|
599
|
+
Actions.start.ReturnValue,
|
|
600
|
+
Actions.start.ErrorType,
|
|
601
|
+
Actions.start.Parameters<config>,
|
|
602
|
+
context
|
|
603
|
+
>
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Hook for starting a new reward stream and waiting for confirmation.
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* ```tsx
|
|
611
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
612
|
+
*
|
|
613
|
+
* function App() {
|
|
614
|
+
* const { mutate: startSync } = Hooks.reward.useStartSync()
|
|
615
|
+
*
|
|
616
|
+
* return (
|
|
617
|
+
* <button onClick={() => startSync({
|
|
618
|
+
* amount: 100000000000000000000n,
|
|
619
|
+
* seconds: 86400,
|
|
620
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
621
|
+
* })}>
|
|
622
|
+
* Start Reward
|
|
623
|
+
* </button>
|
|
624
|
+
* )
|
|
625
|
+
* }
|
|
626
|
+
* ```
|
|
627
|
+
*
|
|
628
|
+
* @param parameters - Parameters.
|
|
629
|
+
* @returns Mutation result.
|
|
630
|
+
*/
|
|
631
|
+
export function useStartSync<
|
|
632
|
+
config extends Config = ResolvedRegister['config'],
|
|
633
|
+
context = unknown,
|
|
634
|
+
>(
|
|
635
|
+
parameters: useStartSync.Parameters<config, context> = {},
|
|
636
|
+
): useStartSync.ReturnType<config, context> {
|
|
637
|
+
const { mutation } = parameters
|
|
638
|
+
const config = useConfig(parameters)
|
|
639
|
+
return useMutation({
|
|
640
|
+
...mutation,
|
|
641
|
+
async mutationFn(variables) {
|
|
642
|
+
return Actions.startSync(config, variables)
|
|
643
|
+
},
|
|
644
|
+
mutationKey: ['startSync'],
|
|
645
|
+
})
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
export declare namespace useStartSync {
|
|
649
|
+
type Parameters<
|
|
650
|
+
config extends Config = Config,
|
|
651
|
+
context = unknown,
|
|
652
|
+
> = ConfigParameter<config> & {
|
|
653
|
+
mutation?:
|
|
654
|
+
| UseMutationParameters<
|
|
655
|
+
Actions.startSync.ReturnValue,
|
|
656
|
+
Actions.startSync.ErrorType,
|
|
657
|
+
Actions.startSync.Parameters<config>,
|
|
658
|
+
context
|
|
659
|
+
>
|
|
660
|
+
| undefined
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
type ReturnType<
|
|
664
|
+
config extends Config = Config,
|
|
665
|
+
context = unknown,
|
|
666
|
+
> = UseMutationResult<
|
|
667
|
+
Actions.startSync.ReturnValue,
|
|
668
|
+
Actions.startSync.ErrorType,
|
|
669
|
+
Actions.startSync.Parameters<config>,
|
|
670
|
+
context
|
|
671
|
+
>
|
|
672
|
+
}
|