tempo.ts 0.12.1 → 0.13.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/CHANGELOG.md +20 -0
- package/README.md +28 -34
- package/package.json +2 -28
- package/dist/wagmi/Actions/amm.d.ts +0 -418
- package/dist/wagmi/Actions/amm.d.ts.map +0 -1
- package/dist/wagmi/Actions/amm.js +0 -462
- package/dist/wagmi/Actions/amm.js.map +0 -1
- package/dist/wagmi/Actions/dex.d.ts +0 -864
- package/dist/wagmi/Actions/dex.d.ts.map +0 -1
- package/dist/wagmi/Actions/dex.js +0 -968
- package/dist/wagmi/Actions/dex.js.map +0 -1
- package/dist/wagmi/Actions/faucet.d.ts +0 -66
- package/dist/wagmi/Actions/faucet.d.ts.map +0 -1
- package/dist/wagmi/Actions/faucet.js +0 -64
- package/dist/wagmi/Actions/faucet.js.map +0 -1
- package/dist/wagmi/Actions/fee.d.ts +0 -111
- package/dist/wagmi/Actions/fee.d.ts.map +0 -1
- package/dist/wagmi/Actions/fee.js +0 -126
- package/dist/wagmi/Actions/fee.js.map +0 -1
- package/dist/wagmi/Actions/index.d.ts +0 -9
- package/dist/wagmi/Actions/index.d.ts.map +0 -1
- package/dist/wagmi/Actions/index.js +0 -9
- package/dist/wagmi/Actions/index.js.map +0 -1
- package/dist/wagmi/Actions/nonce.d.ts +0 -77
- package/dist/wagmi/Actions/nonce.d.ts.map +0 -1
- package/dist/wagmi/Actions/nonce.js +0 -87
- package/dist/wagmi/Actions/nonce.js.map +0 -1
- package/dist/wagmi/Actions/policy.d.ts +0 -480
- package/dist/wagmi/Actions/policy.d.ts.map +0 -1
- package/dist/wagmi/Actions/policy.js +0 -530
- package/dist/wagmi/Actions/policy.js.map +0 -1
- package/dist/wagmi/Actions/reward.d.ts +0 -346
- package/dist/wagmi/Actions/reward.d.ts.map +0 -1
- package/dist/wagmi/Actions/reward.js +0 -382
- package/dist/wagmi/Actions/reward.js.map +0 -1
- package/dist/wagmi/Actions/token.d.ts +0 -1546
- package/dist/wagmi/Actions/token.d.ts.map +0 -1
- package/dist/wagmi/Actions/token.js +0 -1712
- package/dist/wagmi/Actions/token.js.map +0 -1
- package/dist/wagmi/Connector.d.ts +0 -91
- package/dist/wagmi/Connector.d.ts.map +0 -1
- package/dist/wagmi/Connector.js +0 -473
- package/dist/wagmi/Connector.js.map +0 -1
- package/dist/wagmi/Hooks/amm.d.ts +0 -411
- package/dist/wagmi/Hooks/amm.d.ts.map +0 -1
- package/dist/wagmi/Hooks/amm.js +0 -494
- package/dist/wagmi/Hooks/amm.js.map +0 -1
- package/dist/wagmi/Hooks/dex.d.ts +0 -773
- package/dist/wagmi/Hooks/dex.d.ts.map +0 -1
- package/dist/wagmi/Hooks/dex.js +0 -921
- package/dist/wagmi/Hooks/dex.js.map +0 -1
- package/dist/wagmi/Hooks/faucet.d.ts +0 -71
- package/dist/wagmi/Hooks/faucet.d.ts.map +0 -1
- package/dist/wagmi/Hooks/faucet.js +0 -76
- package/dist/wagmi/Hooks/faucet.js.map +0 -1
- package/dist/wagmi/Hooks/fee.d.ts +0 -97
- package/dist/wagmi/Hooks/fee.d.ts.map +0 -1
- package/dist/wagmi/Hooks/fee.js +0 -109
- package/dist/wagmi/Hooks/fee.js.map +0 -1
- package/dist/wagmi/Hooks/index.d.ts +0 -9
- package/dist/wagmi/Hooks/index.d.ts.map +0 -1
- package/dist/wagmi/Hooks/index.js +0 -9
- package/dist/wagmi/Hooks/index.js.map +0 -1
- package/dist/wagmi/Hooks/nonce.d.ts +0 -59
- package/dist/wagmi/Hooks/nonce.d.ts.map +0 -1
- package/dist/wagmi/Hooks/nonce.js +0 -75
- package/dist/wagmi/Hooks/nonce.js.map +0 -1
- package/dist/wagmi/Hooks/policy.d.ts +0 -423
- package/dist/wagmi/Hooks/policy.d.ts.map +0 -1
- package/dist/wagmi/Hooks/policy.js +0 -510
- package/dist/wagmi/Hooks/policy.js.map +0 -1
- package/dist/wagmi/Hooks/reward.d.ts +0 -305
- package/dist/wagmi/Hooks/reward.d.ts.map +0 -1
- package/dist/wagmi/Hooks/reward.js +0 -368
- package/dist/wagmi/Hooks/reward.js.map +0 -1
- package/dist/wagmi/Hooks/token.d.ts +0 -1388
- package/dist/wagmi/Hooks/token.d.ts.map +0 -1
- package/dist/wagmi/Hooks/token.js +0 -1657
- package/dist/wagmi/Hooks/token.js.map +0 -1
- package/dist/wagmi/KeyManager.d.ts +0 -60
- package/dist/wagmi/KeyManager.d.ts.map +0 -1
- package/dist/wagmi/KeyManager.js +0 -106
- package/dist/wagmi/KeyManager.js.map +0 -1
- package/dist/wagmi/index.d.ts +0 -5
- package/dist/wagmi/index.d.ts.map +0 -1
- package/dist/wagmi/index.js +0 -5
- package/dist/wagmi/index.js.map +0 -1
- package/src/wagmi/Actions/amm.test.ts +0 -208
- package/src/wagmi/Actions/amm.ts +0 -690
- package/src/wagmi/Actions/dex.test.ts +0 -1482
- package/src/wagmi/Actions/dex.ts +0 -1540
- package/src/wagmi/Actions/faucet.ts +0 -89
- package/src/wagmi/Actions/fee.test.ts +0 -63
- package/src/wagmi/Actions/fee.ts +0 -211
- package/src/wagmi/Actions/index.ts +0 -8
- package/src/wagmi/Actions/nonce.test.ts +0 -82
- package/src/wagmi/Actions/nonce.ts +0 -139
- package/src/wagmi/Actions/policy.test.ts +0 -461
- package/src/wagmi/Actions/policy.ts +0 -817
- package/src/wagmi/Actions/reward.test.ts +0 -216
- package/src/wagmi/Actions/reward.ts +0 -613
- package/src/wagmi/Actions/token.test.ts +0 -1309
- package/src/wagmi/Actions/token.ts +0 -2644
- package/src/wagmi/Connector.test.ts +0 -56
- package/src/wagmi/Connector.ts +0 -670
- package/src/wagmi/Hooks/amm.test.ts +0 -564
- package/src/wagmi/Hooks/amm.ts +0 -796
- package/src/wagmi/Hooks/dex.test.ts +0 -992
- package/src/wagmi/Hooks/dex.ts +0 -1598
- package/src/wagmi/Hooks/faucet.ts +0 -144
- package/src/wagmi/Hooks/fee.test.ts +0 -166
- package/src/wagmi/Hooks/fee.ts +0 -206
- package/src/wagmi/Hooks/index.ts +0 -8
- package/src/wagmi/Hooks/nonce.test.ts +0 -142
- package/src/wagmi/Hooks/nonce.ts +0 -117
- package/src/wagmi/Hooks/policy.test.ts +0 -665
- package/src/wagmi/Hooks/policy.ts +0 -873
- package/src/wagmi/Hooks/reward.test.ts +0 -249
- package/src/wagmi/Hooks/reward.ts +0 -645
- package/src/wagmi/Hooks/token.test.ts +0 -1183
- package/src/wagmi/Hooks/token.ts +0 -2906
- package/src/wagmi/KeyManager.ts +0 -172
- package/src/wagmi/index.ts +0 -7
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { getAccount } from '@wagmi/core'
|
|
2
|
-
import type { Address } from 'viem'
|
|
3
|
-
import { parseUnits } from 'viem'
|
|
4
|
-
import { describe, expect, test, vi } from 'vitest'
|
|
5
|
-
import { useConnect } from 'wagmi'
|
|
6
|
-
import { config, renderHook, setupToken } from '../../../test/wagmi/config.js'
|
|
7
|
-
import * as hooks from './reward.js'
|
|
8
|
-
import * as tokenHooks from './token.js'
|
|
9
|
-
|
|
10
|
-
describe('useGetTotalPerSecond', () => {
|
|
11
|
-
test('default', async () => {
|
|
12
|
-
const { token } = await setupToken()
|
|
13
|
-
|
|
14
|
-
const { result } = await renderHook(() =>
|
|
15
|
-
hooks.useGetTotalPerSecond({
|
|
16
|
-
token,
|
|
17
|
-
}),
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy())
|
|
21
|
-
|
|
22
|
-
expect(result.current.data).toBe(0n)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test('reactivity: token parameter', async () => {
|
|
26
|
-
const { result, rerender } = await renderHook(
|
|
27
|
-
(props) =>
|
|
28
|
-
hooks.useGetTotalPerSecond({
|
|
29
|
-
token: props?.token,
|
|
30
|
-
}),
|
|
31
|
-
{
|
|
32
|
-
initialProps: {
|
|
33
|
-
token: undefined as Address | undefined,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
await vi.waitFor(() => result.current.fetchStatus === 'idle')
|
|
39
|
-
|
|
40
|
-
// Should be disabled when token is undefined
|
|
41
|
-
expect(result.current.data).toBeUndefined()
|
|
42
|
-
expect(result.current.isPending).toBe(true)
|
|
43
|
-
expect(result.current.isEnabled).toBe(false)
|
|
44
|
-
|
|
45
|
-
// Setup token
|
|
46
|
-
const { token } = await setupToken()
|
|
47
|
-
|
|
48
|
-
// Set token
|
|
49
|
-
rerender({ token })
|
|
50
|
-
|
|
51
|
-
await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy())
|
|
52
|
-
|
|
53
|
-
// Should now be enabled and have data
|
|
54
|
-
expect(result.current.isEnabled).toBe(true)
|
|
55
|
-
expect(result.current.data).toBe(0n)
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
describe('useUserRewardInfo', () => {
|
|
60
|
-
test('default', async () => {
|
|
61
|
-
const { token } = await setupToken()
|
|
62
|
-
|
|
63
|
-
const account = getAccount(config).address
|
|
64
|
-
|
|
65
|
-
const { result } = await renderHook(() =>
|
|
66
|
-
hooks.useUserRewardInfo({
|
|
67
|
-
token,
|
|
68
|
-
account,
|
|
69
|
-
}),
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy())
|
|
73
|
-
|
|
74
|
-
expect(result.current.data?.rewardRecipient).toBeDefined()
|
|
75
|
-
expect(result.current.data?.rewardPerToken).toBeDefined()
|
|
76
|
-
expect(result.current.data?.rewardBalance).toBeDefined()
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
test('reactivity: account and token parameters', async () => {
|
|
80
|
-
const { result, rerender } = await renderHook(
|
|
81
|
-
(props) =>
|
|
82
|
-
hooks.useUserRewardInfo({
|
|
83
|
-
token: props?.token,
|
|
84
|
-
account: props?.account,
|
|
85
|
-
}),
|
|
86
|
-
{
|
|
87
|
-
initialProps: {
|
|
88
|
-
token: undefined as Address | undefined,
|
|
89
|
-
account: undefined as Address | undefined,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
await vi.waitFor(() => result.current.fetchStatus === 'idle')
|
|
95
|
-
|
|
96
|
-
// Should be disabled when both token and account are undefined
|
|
97
|
-
expect(result.current.data).toBeUndefined()
|
|
98
|
-
expect(result.current.isPending).toBe(true)
|
|
99
|
-
expect(result.current.isEnabled).toBe(false)
|
|
100
|
-
|
|
101
|
-
// Setup token (this also connects the account)
|
|
102
|
-
const { token } = await setupToken()
|
|
103
|
-
|
|
104
|
-
// Set token only (account still undefined)
|
|
105
|
-
rerender({ token, account: undefined })
|
|
106
|
-
|
|
107
|
-
await vi.waitFor(() => result.current.fetchStatus === 'idle')
|
|
108
|
-
|
|
109
|
-
// Should still be disabled when account is undefined
|
|
110
|
-
expect(result.current.data).toBeUndefined()
|
|
111
|
-
expect(result.current.isPending).toBe(true)
|
|
112
|
-
expect(result.current.isEnabled).toBe(false)
|
|
113
|
-
|
|
114
|
-
// Get account from config (already connected by setupToken)
|
|
115
|
-
const account = getAccount(config).address
|
|
116
|
-
|
|
117
|
-
// Set both token and account
|
|
118
|
-
rerender({ token, account })
|
|
119
|
-
|
|
120
|
-
await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy())
|
|
121
|
-
|
|
122
|
-
// Should now be enabled and have data
|
|
123
|
-
expect(result.current.isEnabled).toBe(true)
|
|
124
|
-
expect(result.current.data?.rewardRecipient).toBeDefined()
|
|
125
|
-
expect(result.current.data?.rewardPerToken).toBeDefined()
|
|
126
|
-
expect(result.current.data?.rewardBalance).toBeDefined()
|
|
127
|
-
})
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
describe('useSetRecipientSync', () => {
|
|
131
|
-
test('default', async () => {
|
|
132
|
-
const { result } = await renderHook(() => ({
|
|
133
|
-
connect: useConnect(),
|
|
134
|
-
setRecipient: hooks.useSetRecipientSync(),
|
|
135
|
-
}))
|
|
136
|
-
|
|
137
|
-
await result.current.connect.connectAsync({
|
|
138
|
-
connector: config.connectors[0]!,
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
const { token } = await setupToken()
|
|
142
|
-
|
|
143
|
-
await result.current.setRecipient.mutateAsync({
|
|
144
|
-
recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
|
145
|
-
token,
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
await vi.waitFor(() =>
|
|
149
|
-
expect(result.current.setRecipient.isSuccess).toBeTruthy(),
|
|
150
|
-
)
|
|
151
|
-
})
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
describe('useWatchRewardScheduled', () => {
|
|
155
|
-
test('default', async () => {
|
|
156
|
-
const { result: connectResult } = await renderHook(() => ({
|
|
157
|
-
connect: useConnect(),
|
|
158
|
-
grantRolesSync: tokenHooks.useGrantRolesSync(),
|
|
159
|
-
mintSync: tokenHooks.useMintSync(),
|
|
160
|
-
setRecipientSync: hooks.useSetRecipientSync(),
|
|
161
|
-
startSync: hooks.useStartSync(),
|
|
162
|
-
}))
|
|
163
|
-
|
|
164
|
-
await connectResult.current.connect.connectAsync({
|
|
165
|
-
connector: config.connectors[0]!,
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
const { token: tokenAddr } = await setupToken()
|
|
169
|
-
|
|
170
|
-
const account = getAccount(config).address
|
|
171
|
-
|
|
172
|
-
await connectResult.current.grantRolesSync.mutateAsync({
|
|
173
|
-
token: tokenAddr,
|
|
174
|
-
roles: ['issuer'],
|
|
175
|
-
to: account!,
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
const rewardAmount = parseUnits('100', 6)
|
|
179
|
-
await connectResult.current.mintSync.mutateAsync({
|
|
180
|
-
token: tokenAddr,
|
|
181
|
-
to: account!,
|
|
182
|
-
amount: rewardAmount,
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
await connectResult.current.setRecipientSync.mutateAsync({
|
|
186
|
-
token: tokenAddr,
|
|
187
|
-
recipient: account!,
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
const events: any[] = []
|
|
191
|
-
await renderHook(() =>
|
|
192
|
-
hooks.useWatchRewardScheduled({
|
|
193
|
-
token: tokenAddr,
|
|
194
|
-
onRewardScheduled(args) {
|
|
195
|
-
events.push(args)
|
|
196
|
-
},
|
|
197
|
-
}),
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
await connectResult.current.startSync.mutateAsync({
|
|
201
|
-
token: tokenAddr,
|
|
202
|
-
amount: rewardAmount,
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
await vi.waitUntil(() => events.length >= 1)
|
|
206
|
-
|
|
207
|
-
expect(events.length).toBeGreaterThanOrEqual(1)
|
|
208
|
-
expect(events[0]?.amount).toBe(rewardAmount)
|
|
209
|
-
expect(events[0]?.funder).toBe(account)
|
|
210
|
-
})
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
describe('useWatchRewardRecipientSet', () => {
|
|
214
|
-
test('default', async () => {
|
|
215
|
-
const { result: connectResult } = await renderHook(() => ({
|
|
216
|
-
connect: useConnect(),
|
|
217
|
-
setRecipientSync: hooks.useSetRecipientSync(),
|
|
218
|
-
}))
|
|
219
|
-
|
|
220
|
-
await connectResult.current.connect.connectAsync({
|
|
221
|
-
connector: config.connectors[0]!,
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
const { token: tokenAddr } = await setupToken()
|
|
225
|
-
|
|
226
|
-
const account = getAccount(config).address
|
|
227
|
-
|
|
228
|
-
const events: any[] = []
|
|
229
|
-
await renderHook(() =>
|
|
230
|
-
hooks.useWatchRewardRecipientSet({
|
|
231
|
-
token: tokenAddr,
|
|
232
|
-
onRewardRecipientSet(args) {
|
|
233
|
-
events.push(args)
|
|
234
|
-
},
|
|
235
|
-
}),
|
|
236
|
-
)
|
|
237
|
-
|
|
238
|
-
await connectResult.current.setRecipientSync.mutateAsync({
|
|
239
|
-
token: tokenAddr,
|
|
240
|
-
recipient: account!,
|
|
241
|
-
})
|
|
242
|
-
|
|
243
|
-
await vi.waitUntil(() => events.length >= 1)
|
|
244
|
-
|
|
245
|
-
expect(events.length).toBeGreaterThanOrEqual(1)
|
|
246
|
-
expect(events[0]?.holder).toBe(account)
|
|
247
|
-
expect(events[0]?.recipient).toBe(account)
|
|
248
|
-
})
|
|
249
|
-
})
|