tempo.ts 0.10.2 → 0.10.3

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/viem/Actions/index.d.ts +1 -0
  3. package/dist/viem/Actions/index.d.ts.map +1 -1
  4. package/dist/viem/Actions/index.js +1 -0
  5. package/dist/viem/Actions/index.js.map +1 -1
  6. package/dist/viem/Actions/nonce.d.ts +257 -0
  7. package/dist/viem/Actions/nonce.d.ts.map +1 -0
  8. package/dist/viem/Actions/nonce.js +226 -0
  9. package/dist/viem/Actions/nonce.js.map +1 -0
  10. package/dist/viem/Addresses.d.ts +1 -0
  11. package/dist/viem/Addresses.d.ts.map +1 -1
  12. package/dist/viem/Addresses.js +1 -0
  13. package/dist/viem/Addresses.js.map +1 -1
  14. package/dist/wagmi/Actions/index.d.ts +1 -0
  15. package/dist/wagmi/Actions/index.d.ts.map +1 -1
  16. package/dist/wagmi/Actions/index.js +1 -0
  17. package/dist/wagmi/Actions/index.js.map +1 -1
  18. package/dist/wagmi/Actions/nonce.d.ts +147 -0
  19. package/dist/wagmi/Actions/nonce.d.ts.map +1 -0
  20. package/dist/wagmi/Actions/nonce.js +169 -0
  21. package/dist/wagmi/Actions/nonce.js.map +1 -0
  22. package/dist/wagmi/Hooks/index.d.ts +1 -0
  23. package/dist/wagmi/Hooks/index.d.ts.map +1 -1
  24. package/dist/wagmi/Hooks/index.js +1 -0
  25. package/dist/wagmi/Hooks/index.js.map +1 -1
  26. package/dist/wagmi/Hooks/nonce.d.ts +110 -0
  27. package/dist/wagmi/Hooks/nonce.d.ts.map +1 -0
  28. package/dist/wagmi/Hooks/nonce.js +144 -0
  29. package/dist/wagmi/Hooks/nonce.js.map +1 -0
  30. package/package.json +1 -1
  31. package/src/viem/Actions/index.ts +1 -0
  32. package/src/viem/Actions/nonce.test.ts +193 -0
  33. package/src/viem/Actions/nonce.ts +345 -0
  34. package/src/viem/Addresses.ts +1 -0
  35. package/src/viem/Chain.test.ts +9 -9
  36. package/src/wagmi/Actions/index.ts +1 -0
  37. package/src/wagmi/Actions/nonce.test.ts +141 -0
  38. package/src/wagmi/Actions/nonce.ts +271 -0
  39. package/src/wagmi/Hooks/index.ts +1 -0
  40. package/src/wagmi/Hooks/nonce.test.ts +207 -0
  41. package/src/wagmi/Hooks/nonce.ts +230 -0
@@ -0,0 +1,141 @@
1
+ import { connect } from '@wagmi/core'
2
+ import { afterEach, describe, expect, test } from 'vitest'
3
+ import { rpcUrl } from '../../../test/config.js'
4
+ import { accounts } from '../../../test/viem/config.js'
5
+ import { config, queryClient } from '../../../test/wagmi/config.js'
6
+ import * as nonce from './nonce.js'
7
+ import * as token from './token.js'
8
+
9
+ const { getNonceKeyCount, getNonce } = nonce
10
+
11
+ const account = accounts[0]
12
+ const account2 = accounts[1]
13
+
14
+ afterEach(async () => {
15
+ await fetch(`${rpcUrl}/restart`)
16
+ })
17
+
18
+ describe('getNonce', () => {
19
+ test('default', async () => {
20
+ const result = await getNonce(config, {
21
+ account: account.address,
22
+ nonceKey: 1n,
23
+ })
24
+ expect(result).toBe(1n)
25
+ })
26
+
27
+ describe('queryOptions', () => {
28
+ test('default', async () => {
29
+ const options = getNonce.queryOptions(config, {
30
+ account: account.address,
31
+ nonceKey: 1n,
32
+ })
33
+ const result = await queryClient.fetchQuery(options)
34
+ expect(result).toBe(1n)
35
+ })
36
+ })
37
+ })
38
+
39
+ describe('getNonceKeyCount', () => {
40
+ test('default', async () => {
41
+ const result = await getNonceKeyCount(config, {
42
+ account: account.address,
43
+ })
44
+ expect(result).toBe(0n)
45
+ })
46
+
47
+ describe('queryOptions', () => {
48
+ test('default', async () => {
49
+ const options = getNonceKeyCount.queryOptions(config, {
50
+ account: account.address,
51
+ })
52
+ expect(await queryClient.fetchQuery(options)).toBe(0n)
53
+ })
54
+ })
55
+ })
56
+
57
+ describe('watchNonceIncremented', () => {
58
+ test('default', async () => {
59
+ await connect(config, {
60
+ connector: config.connectors[0]!,
61
+ })
62
+
63
+ const events: any[] = []
64
+ const unwatch = nonce.watchNonceIncremented(config, {
65
+ onNonceIncremented: (args) => {
66
+ events.push(args)
67
+ },
68
+ args: {
69
+ account: account.address,
70
+ nonceKey: 5n,
71
+ },
72
+ })
73
+
74
+ // Have to manually set nonce because eth_FillTransaction does not support nonce keys
75
+ await token.transferSync(config, {
76
+ to: account2.address,
77
+ amount: 1n,
78
+ token: 1n,
79
+ nonceKey: 5n,
80
+ nonce: 0,
81
+ })
82
+
83
+ await token.transferSync(config, {
84
+ to: account2.address,
85
+ amount: 1n,
86
+ token: 1n,
87
+ nonceKey: 5n,
88
+ nonce: 1,
89
+ })
90
+
91
+ await new Promise((resolve) => setTimeout(resolve, 1000))
92
+
93
+ expect(events).toHaveLength(2)
94
+ expect(events[0]?.account).toBe(account.address)
95
+ expect(events[0]?.nonceKey).toBe(5n)
96
+ expect(events[0]?.newNonce).toBe(1n)
97
+ expect(events[1]?.newNonce).toBe(2n)
98
+ unwatch()
99
+ })
100
+ })
101
+
102
+ describe('watchActiveKeyCountChanged', () => {
103
+ test('default', async () => {
104
+ await connect(config, {
105
+ connector: config.connectors[0]!,
106
+ })
107
+
108
+ const events: any[] = []
109
+ const unwatch = nonce.watchActiveKeyCountChanged(config, {
110
+ onActiveKeyCountChanged: (args) => {
111
+ events.push(args)
112
+ },
113
+ })
114
+
115
+ // First use of nonceKey 10 should increment active key count
116
+ await token.transferSync(config, {
117
+ to: account2.address,
118
+ amount: 1n,
119
+ token: 1n,
120
+ nonceKey: 10n,
121
+ nonce: 0,
122
+ })
123
+
124
+ // First use of nonceKey 11 should increment again
125
+ await token.transferSync(config, {
126
+ to: account2.address,
127
+ amount: 1n,
128
+ token: 1n,
129
+ nonceKey: 11n,
130
+ nonce: 0,
131
+ })
132
+
133
+ await new Promise((resolve) => setTimeout(resolve, 1000))
134
+
135
+ expect(events).toHaveLength(2)
136
+ expect(events[0]?.account).toBe(account.address)
137
+ expect(events[0]?.newCount).toBe(1n)
138
+ expect(events[1]?.newCount).toBe(2n)
139
+ unwatch()
140
+ })
141
+ })
@@ -0,0 +1,271 @@
1
+ import type * as Query from '@tanstack/query-core'
2
+ import type { Config } from '@wagmi/core'
3
+ import type { ChainIdParameter } from '@wagmi/core/internal'
4
+ import type { PartialBy, RequiredBy } from '../../internal/types.js'
5
+ import * as viem_Actions from '../../viem/Actions/nonce.js'
6
+
7
+ /**
8
+ * Gets the nonce for an account and nonce key.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { createConfig, http } from '@wagmi/core'
13
+ * import { tempo } from 'tempo.ts/chains'
14
+ * import { Actions } from 'tempo.ts/wagmi'
15
+ *
16
+ * const config = createConfig({
17
+ * chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
18
+ * transports: {
19
+ * [tempo.id]: http(),
20
+ * },
21
+ * })
22
+ *
23
+ * const nonce = await Actions.nonce.getNonce(config, {
24
+ * account: '0x...',
25
+ * nonceKey: 1n,
26
+ * })
27
+ * ```
28
+ *
29
+ * @param config - Config.
30
+ * @param parameters - Parameters.
31
+ * @returns The nonce value.
32
+ */
33
+ export function getNonce<config extends Config>(
34
+ config: config,
35
+ parameters: getNonce.Parameters<config>,
36
+ ): Promise<getNonce.ReturnValue> {
37
+ const { chainId, ...rest } = parameters
38
+ const client = config.getClient({ chainId })
39
+ return viem_Actions.getNonce(client, rest)
40
+ }
41
+
42
+ export namespace getNonce {
43
+ export type Parameters<config extends Config> = ChainIdParameter<config> &
44
+ viem_Actions.getNonce.Parameters
45
+
46
+ export type ReturnValue = viem_Actions.getNonce.ReturnValue
47
+
48
+ export function queryKey<config extends Config>(
49
+ parameters: PartialBy<Parameters<config>, 'account' | 'nonceKey'>,
50
+ ) {
51
+ return ['getNonce', parameters] as const
52
+ }
53
+
54
+ export type QueryKey<config extends Config> = ReturnType<
55
+ typeof queryKey<config>
56
+ >
57
+
58
+ export function queryOptions<config extends Config, selectData = ReturnValue>(
59
+ config: Config,
60
+ parameters: queryOptions.Parameters<config, selectData>,
61
+ ): queryOptions.ReturnValue<config, selectData> {
62
+ const { query, ...rest } = parameters
63
+ return {
64
+ ...query,
65
+ queryKey: queryKey(rest),
66
+ async queryFn({ queryKey }) {
67
+ const [, { account, nonceKey, ...parameters }] = queryKey
68
+ if (!account) throw new Error('account is required.')
69
+ if (nonceKey === undefined) throw new Error('nonceKey is required.')
70
+ return await getNonce(config, { account, nonceKey, ...parameters })
71
+ },
72
+ }
73
+ }
74
+
75
+ export declare namespace queryOptions {
76
+ export type Parameters<
77
+ config extends Config,
78
+ selectData = getNonce.ReturnValue,
79
+ > = PartialBy<getNonce.Parameters<config>, 'account' | 'nonceKey'> & {
80
+ query?:
81
+ | Omit<ReturnValue<config, selectData>, 'queryKey' | 'queryFn'>
82
+ | undefined
83
+ }
84
+
85
+ export type ReturnValue<
86
+ config extends Config,
87
+ selectData = getNonce.ReturnValue,
88
+ > = RequiredBy<
89
+ Query.QueryOptions<
90
+ getNonce.ReturnValue,
91
+ Query.DefaultError,
92
+ selectData,
93
+ getNonce.QueryKey<config>
94
+ >,
95
+ 'queryKey' | 'queryFn'
96
+ >
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Gets the number of active nonce keys for an account.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * import { createConfig, http } from '@wagmi/core'
106
+ * import { tempo } from 'tempo.ts/chains'
107
+ * import { Actions } from 'tempo.ts/wagmi'
108
+ *
109
+ * const config = createConfig({
110
+ * chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
111
+ * transports: {
112
+ * [tempo.id]: http(),
113
+ * },
114
+ * })
115
+ *
116
+ * const count = await Actions.nonce.getNonceKeyCount(config, {
117
+ * account: '0x...',
118
+ * })
119
+ * ```
120
+ *
121
+ * @param config - Config.
122
+ * @param parameters - Parameters.
123
+ * @returns The number of active nonce keys.
124
+ */
125
+ export function getNonceKeyCount<config extends Config>(
126
+ config: config,
127
+ parameters: getNonceKeyCount.Parameters<config>,
128
+ ): Promise<getNonceKeyCount.ReturnValue> {
129
+ const { chainId, ...rest } = parameters
130
+ const client = config.getClient({ chainId })
131
+ return viem_Actions.getNonceKeyCount(client, rest)
132
+ }
133
+
134
+ export namespace getNonceKeyCount {
135
+ export type Parameters<config extends Config> = ChainIdParameter<config> &
136
+ viem_Actions.getNonceKeyCount.Parameters
137
+
138
+ export type ReturnValue = viem_Actions.getNonceKeyCount.ReturnValue
139
+
140
+ export function queryKey<config extends Config>(
141
+ parameters: PartialBy<Parameters<config>, 'account'>,
142
+ ) {
143
+ return ['getNonceKeyCount', parameters] as const
144
+ }
145
+
146
+ export type QueryKey<config extends Config> = ReturnType<
147
+ typeof queryKey<config>
148
+ >
149
+
150
+ export function queryOptions<config extends Config, selectData = ReturnValue>(
151
+ config: Config,
152
+ parameters: queryOptions.Parameters<config, selectData>,
153
+ ): queryOptions.ReturnValue<config, selectData> {
154
+ const { query, ...rest } = parameters
155
+ return {
156
+ ...query,
157
+ queryKey: queryKey(rest),
158
+ async queryFn({ queryKey }) {
159
+ const [, { account, ...parameters }] = queryKey
160
+ if (!account) throw new Error('account is required.')
161
+ return await getNonceKeyCount(config, { account, ...parameters })
162
+ },
163
+ }
164
+ }
165
+
166
+ export declare namespace queryOptions {
167
+ export type Parameters<
168
+ config extends Config,
169
+ selectData = getNonceKeyCount.ReturnValue,
170
+ > = PartialBy<getNonceKeyCount.Parameters<config>, 'account'> & {
171
+ query?:
172
+ | Omit<ReturnValue<config, selectData>, 'queryKey' | 'queryFn'>
173
+ | undefined
174
+ }
175
+
176
+ export type ReturnValue<
177
+ config extends Config,
178
+ selectData = getNonceKeyCount.ReturnValue,
179
+ > = RequiredBy<
180
+ Query.QueryOptions<
181
+ getNonceKeyCount.ReturnValue,
182
+ Query.DefaultError,
183
+ selectData,
184
+ getNonceKeyCount.QueryKey<config>
185
+ >,
186
+ 'queryKey' | 'queryFn'
187
+ >
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Watches for nonce incremented events.
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * import { createConfig, http } from '@wagmi/core'
197
+ * import { tempo } from 'tempo.ts/chains'
198
+ * import { Actions } from 'tempo.ts/wagmi'
199
+ *
200
+ * const config = createConfig({
201
+ * chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
202
+ * transports: {
203
+ * [tempo.id]: http(),
204
+ * },
205
+ * })
206
+ *
207
+ * const unwatch = Actions.nonce.watchNonceIncremented(config, {
208
+ * onNonceIncremented: (args, log) => {
209
+ * console.log('Nonce incremented:', args)
210
+ * },
211
+ * })
212
+ * ```
213
+ *
214
+ * @param config - Config.
215
+ * @param parameters - Parameters.
216
+ * @returns A function to unsubscribe from the event.
217
+ */
218
+ export function watchNonceIncremented<config extends Config>(
219
+ config: config,
220
+ parameters: watchNonceIncremented.Parameters<config>,
221
+ ): () => void {
222
+ const { chainId, ...rest } = parameters
223
+ const client = config.getClient({ chainId })
224
+ return viem_Actions.watchNonceIncremented(client, rest)
225
+ }
226
+
227
+ export declare namespace watchNonceIncremented {
228
+ export type Parameters<config extends Config> = ChainIdParameter<config> &
229
+ viem_Actions.watchNonceIncremented.Parameters
230
+ }
231
+
232
+ /**
233
+ * Watches for active key count changed events.
234
+ *
235
+ * @example
236
+ * ```ts
237
+ * import { createConfig, http } from '@wagmi/core'
238
+ * import { tempo } from 'tempo.ts/chains'
239
+ * import { Actions } from 'tempo.ts/wagmi'
240
+ *
241
+ * const config = createConfig({
242
+ * chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
243
+ * transports: {
244
+ * [tempo.id]: http(),
245
+ * },
246
+ * })
247
+ *
248
+ * const unwatch = Actions.nonce.watchActiveKeyCountChanged(config, {
249
+ * onActiveKeyCountChanged: (args, log) => {
250
+ * console.log('Active key count changed:', args)
251
+ * },
252
+ * })
253
+ * ```
254
+ *
255
+ * @param config - Config.
256
+ * @param parameters - Parameters.
257
+ * @returns A function to unsubscribe from the event.
258
+ */
259
+ export function watchActiveKeyCountChanged<config extends Config>(
260
+ config: config,
261
+ parameters: watchActiveKeyCountChanged.Parameters<config>,
262
+ ): () => void {
263
+ const { chainId, ...rest } = parameters
264
+ const client = config.getClient({ chainId })
265
+ return viem_Actions.watchActiveKeyCountChanged(client, rest)
266
+ }
267
+
268
+ export declare namespace watchActiveKeyCountChanged {
269
+ export type Parameters<config extends Config> = ChainIdParameter<config> &
270
+ viem_Actions.watchActiveKeyCountChanged.Parameters
271
+ }
@@ -2,6 +2,7 @@ export * as amm from './amm.js'
2
2
  export * as dex from './dex.js'
3
3
  export * as faucet from './faucet.js'
4
4
  export * as fee from './fee.js'
5
+ export * as nonce from './nonce.js'
5
6
  export * as policy from './policy.js'
6
7
  export * as reward from './reward.js'
7
8
  export * as token from './token.js'
@@ -0,0 +1,207 @@
1
+ import type { Address } from 'viem'
2
+ import { describe, expect, test, vi } from 'vitest'
3
+ import { useConnect } from 'wagmi'
4
+ import { accounts } from '../../../test/viem/config.js'
5
+ import { config, renderHook } from '../../../test/wagmi/config.js'
6
+ import * as hooks from './nonce.js'
7
+ import * as tokenHooks from './token.js'
8
+
9
+ const { useNonceKeyCount, useNonce } = hooks
10
+
11
+ const account = accounts[0]
12
+ const account2 = accounts[1]
13
+
14
+ describe('useNonce', () => {
15
+ test('default', async () => {
16
+ let testAccount: Address | undefined
17
+ let testNonceKey: bigint | undefined
18
+
19
+ const { result, rerender } = await renderHook(() =>
20
+ useNonce({ account: testAccount, nonceKey: testNonceKey }),
21
+ )
22
+
23
+ await vi.waitFor(() => result.current.fetchStatus === 'fetching')
24
+
25
+ // Should be disabled when account is undefined
26
+ expect(result.current.data).toBeUndefined()
27
+ expect(result.current.isPending).toBe(true)
28
+ expect(result.current.isEnabled).toBe(false)
29
+
30
+ // Set account and nonceKey
31
+ testAccount = account.address
32
+ testNonceKey = 1n
33
+ rerender()
34
+
35
+ await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy(), {
36
+ timeout: 5_000,
37
+ })
38
+
39
+ // Should now be enabled and have data
40
+ expect(result.current.isEnabled).toBe(true)
41
+ expect(result.current.data).toBe(1n)
42
+ })
43
+
44
+ test('reactivity: account parameter', async () => {
45
+ let testAccount: Address | undefined
46
+
47
+ const { result, rerender } = await renderHook(() =>
48
+ useNonce({ account: testAccount, nonceKey: 1n }),
49
+ )
50
+
51
+ await vi.waitFor(() => result.current.fetchStatus === 'fetching')
52
+
53
+ // Should be disabled when account is undefined
54
+ expect(result.current.isEnabled).toBe(false)
55
+
56
+ // Set account
57
+ testAccount = account.address
58
+ rerender()
59
+
60
+ await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy(), {
61
+ timeout: 5_000,
62
+ })
63
+
64
+ expect(result.current.isEnabled).toBe(true)
65
+ expect(result.current.data).toBe(1n)
66
+ })
67
+
68
+ test('reactivity: nonceKey parameter', async () => {
69
+ let testNonceKey: bigint | undefined
70
+
71
+ const { result, rerender } = await renderHook(() =>
72
+ useNonce({ account: account.address, nonceKey: testNonceKey }),
73
+ )
74
+
75
+ await vi.waitFor(() => result.current.fetchStatus === 'fetching')
76
+
77
+ // Should be disabled when nonceKey is undefined
78
+ expect(result.current.isEnabled).toBe(false)
79
+
80
+ // Set nonceKey
81
+ testNonceKey = 1n
82
+ rerender()
83
+
84
+ await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy(), {
85
+ timeout: 5_000,
86
+ })
87
+
88
+ expect(result.current.isEnabled).toBe(true)
89
+ expect(result.current.data).toBe(1n)
90
+ })
91
+ })
92
+
93
+ describe('useNonceKeyCount', () => {
94
+ test('default', async () => {
95
+ let testAccount: Address | undefined
96
+
97
+ const { result, rerender } = await renderHook(() =>
98
+ useNonceKeyCount({ account: testAccount }),
99
+ )
100
+
101
+ await vi.waitFor(() => result.current.fetchStatus === 'fetching')
102
+
103
+ // Should be disabled when account is undefined
104
+ expect(result.current.data).toBeUndefined()
105
+ expect(result.current.isPending).toBe(true)
106
+ expect(result.current.isEnabled).toBe(false)
107
+
108
+ // Set account
109
+ testAccount = account.address
110
+ rerender()
111
+
112
+ await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy(), {
113
+ timeout: 5_000,
114
+ })
115
+
116
+ // Should now be enabled and have data
117
+ expect(result.current.isEnabled).toBe(true)
118
+ expect(result.current.data).toBe(0n)
119
+ })
120
+ })
121
+
122
+ describe('useWatchNonceIncremented', () => {
123
+ test('default', async () => {
124
+ const { result: connectResult } = await renderHook(() => ({
125
+ connect: useConnect(),
126
+ transferSync: tokenHooks.useTransferSync(),
127
+ }))
128
+
129
+ await connectResult.current.connect.connectAsync({
130
+ connector: config.connectors[0]!,
131
+ })
132
+
133
+ const events: any[] = []
134
+ await renderHook(() =>
135
+ hooks.useWatchNonceIncremented({
136
+ onNonceIncremented(args) {
137
+ events.push(args)
138
+ },
139
+ args: {
140
+ account: account.address,
141
+ nonceKey: 5n,
142
+ },
143
+ }),
144
+ )
145
+
146
+ // Have to manually set nonce because eth_FillTransaction does not support nonce keys
147
+ await connectResult.current.transferSync.mutateAsync({
148
+ to: account2.address,
149
+ amount: 1n,
150
+ token: 1n,
151
+ nonceKey: 5n,
152
+ nonce: 0,
153
+ })
154
+
155
+ await connectResult.current.transferSync.mutateAsync({
156
+ to: account2.address,
157
+ amount: 1n,
158
+ token: 1n,
159
+ nonceKey: 5n,
160
+ nonce: 1,
161
+ })
162
+
163
+ await vi.waitUntil(() => events.length >= 2)
164
+
165
+ expect(events).toHaveLength(2)
166
+ expect(events[0]?.account).toBe(account.address)
167
+ expect(events[0]?.nonceKey).toBe(5n)
168
+ expect(events[0]?.newNonce).toBe(1n)
169
+ expect(events[1]?.newNonce).toBe(2n)
170
+ })
171
+ })
172
+
173
+ describe('useWatchActiveKeyCountChanged', () => {
174
+ test('default', async () => {
175
+ const { result: connectResult } = await renderHook(() => ({
176
+ connect: useConnect(),
177
+ transferSync: tokenHooks.useTransferSync(),
178
+ }))
179
+
180
+ await connectResult.current.connect.connectAsync({
181
+ connector: config.connectors[0]!,
182
+ })
183
+
184
+ const events: any[] = []
185
+ await renderHook(() =>
186
+ hooks.useWatchActiveKeyCountChanged({
187
+ onActiveKeyCountChanged(args) {
188
+ events.push(args)
189
+ },
190
+ }),
191
+ )
192
+
193
+ await connectResult.current.transferSync.mutateAsync({
194
+ to: account2.address,
195
+ amount: 1n,
196
+ token: 1n,
197
+ nonceKey: 10n,
198
+ nonce: 0,
199
+ })
200
+
201
+ await vi.waitUntil(() => events.length >= 1)
202
+
203
+ expect(events).toHaveLength(1)
204
+ expect(events[0]?.account).toBe(account.address)
205
+ expect(events[0]?.newCount).toBe(2n)
206
+ })
207
+ })