tempo.ts 0.4.4 → 0.5.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.
Files changed (45) hide show
  1. package/README.md +2 -3
  2. package/dist/chains.d.ts +15 -1
  3. package/dist/chains.d.ts.map +1 -1
  4. package/dist/chains.js +2 -1
  5. package/dist/chains.js.map +1 -1
  6. package/dist/prool/Instance.d.ts +12 -4
  7. package/dist/prool/Instance.d.ts.map +1 -1
  8. package/dist/prool/Instance.js +34 -18
  9. package/dist/prool/Instance.js.map +1 -1
  10. package/dist/viem/Actions/faucet.d.ts +34 -1
  11. package/dist/viem/Actions/faucet.d.ts.map +1 -1
  12. package/dist/viem/Actions/faucet.js +35 -0
  13. package/dist/viem/Actions/faucet.js.map +1 -1
  14. package/dist/viem/Chain.d.ts +6 -0
  15. package/dist/viem/Chain.d.ts.map +1 -1
  16. package/dist/viem/Chain.js +3 -1
  17. package/dist/viem/Chain.js.map +1 -1
  18. package/dist/viem/Formatters.js +1 -1
  19. package/dist/viem/Formatters.js.map +1 -1
  20. package/dist/viem/Transaction.d.ts +4 -1
  21. package/dist/viem/Transaction.d.ts.map +1 -1
  22. package/dist/viem/Transaction.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/chains.ts +2 -1
  25. package/src/ox/TransactionEnvelopeAA.test.ts +2 -663
  26. package/src/ox/e2e.test.ts +659 -0
  27. package/src/prool/Instance.ts +51 -23
  28. package/src/tsconfig.json +2 -2
  29. package/src/viem/Actions/amm.test.ts +68 -58
  30. package/src/viem/Actions/dex.test.ts +339 -283
  31. package/src/viem/Actions/faucet.ts +63 -1
  32. package/src/viem/Actions/fee.test.ts +34 -43
  33. package/src/viem/Actions/policy.test.ts +115 -81
  34. package/src/viem/Actions/reward.test.ts +92 -74
  35. package/src/viem/Actions/token.test.ts +691 -529
  36. package/src/viem/Chain.ts +3 -1
  37. package/src/viem/Formatters.ts +1 -1
  38. package/src/viem/Transaction.ts +4 -1
  39. package/src/viem/e2e.test.ts +451 -472
  40. package/src/wagmi/Actions/amm.test.ts +2 -5
  41. package/src/wagmi/Actions/dex.test.ts +2 -1
  42. package/src/wagmi/Actions/token.test.ts +2 -1
  43. package/src/wagmi/Hooks/amm.test.ts +2 -5
  44. package/src/wagmi/Hooks/dex.test.ts +2 -1
  45. package/src/wagmi/Hooks/token.test.ts +2 -1
@@ -5,12 +5,8 @@ import { Abis, Addresses, TokenIds } from 'tempo.ts/viem'
5
5
  import { parseUnits } from 'viem'
6
6
  import { getCode, writeContractSync } from 'viem/actions'
7
7
  import { beforeAll, describe, expect, test } from 'vitest'
8
- import {
9
- accounts,
10
- addresses,
11
- client,
12
- rpcUrl,
13
- } from '../../../test/viem/config.js'
8
+ import { addresses, rpcUrl } from '../../../test/config.js'
9
+ import { accounts, clientWithAccount } from '../../../test/viem/config.js'
14
10
  import * as actions from './index.js'
15
11
 
16
12
  const account = accounts[0]
@@ -21,11 +17,14 @@ describe('approve', () => {
21
17
  test('default', async () => {
22
18
  {
23
19
  // approve
24
- const { receipt, ...result } = await actions.token.approveSync(client, {
25
- spender: account2.address,
26
- amount: parseUnits('100', 6),
27
- token: addresses.alphaUsd,
28
- })
20
+ const { receipt, ...result } = await actions.token.approveSync(
21
+ clientWithAccount,
22
+ {
23
+ spender: account2.address,
24
+ amount: parseUnits('100', 6),
25
+ token: addresses.alphaUsd,
26
+ },
27
+ )
29
28
  expect(receipt).toBeDefined()
30
29
  expect(result).toMatchInlineSnapshot(`
31
30
  {
@@ -38,7 +37,7 @@ describe('approve', () => {
38
37
 
39
38
  {
40
39
  // check allowance
41
- const allowance = await actions.token.getAllowance(client, {
40
+ const allowance = await actions.token.getAllowance(clientWithAccount, {
42
41
  spender: account2.address,
43
42
  token: addresses.alphaUsd,
44
43
  })
@@ -46,7 +45,7 @@ describe('approve', () => {
46
45
  }
47
46
 
48
47
  // transfer tokens for gas
49
- await writeContractSync(client, {
48
+ await writeContractSync(clientWithAccount, {
50
49
  abi: Abis.tip20,
51
50
  address: addresses.alphaUsd,
52
51
  functionName: 'transfer',
@@ -54,7 +53,7 @@ describe('approve', () => {
54
53
  })
55
54
 
56
55
  // transfer tokens from approved account
57
- await actions.token.transferSync(client, {
56
+ await actions.token.transferSync(clientWithAccount, {
58
57
  amount: parseUnits('50', 6),
59
58
  account: account2,
60
59
  from: account.address,
@@ -64,7 +63,7 @@ describe('approve', () => {
64
63
 
65
64
  {
66
65
  // verify updated allowance
67
- const allowance = await actions.token.getAllowance(client, {
66
+ const allowance = await actions.token.getAllowance(clientWithAccount, {
68
67
  spender: account2.address,
69
68
  token: addresses.alphaUsd,
70
69
  })
@@ -72,7 +71,7 @@ describe('approve', () => {
72
71
  }
73
72
 
74
73
  // verify balance
75
- const balance = await actions.token.getBalance(client, {
74
+ const balance = await actions.token.getBalance(clientWithAccount, {
76
75
  account: '0x0000000000000000000000000000000000000001',
77
76
  token: addresses.alphaUsd,
78
77
  })
@@ -80,18 +79,21 @@ describe('approve', () => {
80
79
  })
81
80
 
82
81
  test('behavior: token address', async () => {
83
- const balanceBefore = await actions.token.getBalance(client, {
82
+ const balanceBefore = await actions.token.getBalance(clientWithAccount, {
84
83
  account: '0x0000000000000000000000000000000000000001',
85
84
  token: addresses.alphaUsd,
86
85
  })
87
86
 
88
87
  {
89
88
  // approve
90
- const { receipt, ...result } = await actions.token.approveSync(client, {
91
- amount: parseUnits('100', 6),
92
- token: addresses.alphaUsd,
93
- spender: account2.address,
94
- })
89
+ const { receipt, ...result } = await actions.token.approveSync(
90
+ clientWithAccount,
91
+ {
92
+ amount: parseUnits('100', 6),
93
+ token: addresses.alphaUsd,
94
+ spender: account2.address,
95
+ },
96
+ )
95
97
  expect(receipt).toBeDefined()
96
98
  expect(result).toMatchInlineSnapshot(`
97
99
  {
@@ -104,7 +106,7 @@ describe('approve', () => {
104
106
 
105
107
  {
106
108
  // check allowance
107
- const allowance = await actions.token.getAllowance(client, {
109
+ const allowance = await actions.token.getAllowance(clientWithAccount, {
108
110
  token: addresses.alphaUsd,
109
111
  spender: account2.address,
110
112
  })
@@ -112,7 +114,7 @@ describe('approve', () => {
112
114
  }
113
115
 
114
116
  // transfer tokens for gas
115
- await writeContractSync(client, {
117
+ await writeContractSync(clientWithAccount, {
116
118
  abi: Abis.tip20,
117
119
  address: addresses.alphaUsd,
118
120
  functionName: 'transfer',
@@ -120,7 +122,7 @@ describe('approve', () => {
120
122
  })
121
123
 
122
124
  // transfer tokens from approved account
123
- await actions.token.transferSync(client, {
125
+ await actions.token.transferSync(clientWithAccount, {
124
126
  amount: parseUnits('50', 6),
125
127
  account: account2,
126
128
  from: account.address,
@@ -130,7 +132,7 @@ describe('approve', () => {
130
132
 
131
133
  {
132
134
  // verify updated allowance
133
- const allowance = await actions.token.getAllowance(client, {
135
+ const allowance = await actions.token.getAllowance(clientWithAccount, {
134
136
  spender: account2.address,
135
137
  token: addresses.alphaUsd,
136
138
  })
@@ -138,7 +140,7 @@ describe('approve', () => {
138
140
  }
139
141
 
140
142
  // verify balance
141
- const balance = await actions.token.getBalance(client, {
143
+ const balance = await actions.token.getBalance(clientWithAccount, {
142
144
  account: '0x0000000000000000000000000000000000000001',
143
145
  token: addresses.alphaUsd,
144
146
  })
@@ -146,18 +148,21 @@ describe('approve', () => {
146
148
  })
147
149
 
148
150
  test('behavior: token address', async () => {
149
- const balanceBefore = await actions.token.getBalance(client, {
151
+ const balanceBefore = await actions.token.getBalance(clientWithAccount, {
150
152
  account: '0x0000000000000000000000000000000000000001',
151
153
  token: addresses.alphaUsd,
152
154
  })
153
155
 
154
156
  {
155
157
  // approve
156
- const { receipt, ...result } = await actions.token.approveSync(client, {
157
- amount: parseUnits('100', 6),
158
- token: addresses.alphaUsd,
159
- spender: account2.address,
160
- })
158
+ const { receipt, ...result } = await actions.token.approveSync(
159
+ clientWithAccount,
160
+ {
161
+ amount: parseUnits('100', 6),
162
+ token: addresses.alphaUsd,
163
+ spender: account2.address,
164
+ },
165
+ )
161
166
  expect(receipt).toBeDefined()
162
167
  expect(result).toMatchInlineSnapshot(`
163
168
  {
@@ -170,7 +175,7 @@ describe('approve', () => {
170
175
 
171
176
  {
172
177
  // check allowance
173
- const allowance = await actions.token.getAllowance(client, {
178
+ const allowance = await actions.token.getAllowance(clientWithAccount, {
174
179
  token: addresses.alphaUsd,
175
180
  spender: account2.address,
176
181
  })
@@ -178,7 +183,7 @@ describe('approve', () => {
178
183
  }
179
184
 
180
185
  // transfer tokens for gas
181
- await writeContractSync(client, {
186
+ await writeContractSync(clientWithAccount, {
182
187
  abi: Abis.tip20,
183
188
  address: addresses.alphaUsd,
184
189
  functionName: 'transfer',
@@ -186,7 +191,7 @@ describe('approve', () => {
186
191
  })
187
192
 
188
193
  // transfer tokens from approved account
189
- await actions.token.transferSync(client, {
194
+ await actions.token.transferSync(clientWithAccount, {
190
195
  amount: parseUnits('50', 6),
191
196
  account: account2,
192
197
  from: account.address,
@@ -196,7 +201,7 @@ describe('approve', () => {
196
201
 
197
202
  {
198
203
  // verify updated allowance
199
- const allowance = await actions.token.getAllowance(client, {
204
+ const allowance = await actions.token.getAllowance(clientWithAccount, {
200
205
  spender: account2.address,
201
206
  token: addresses.alphaUsd,
202
207
  })
@@ -204,7 +209,7 @@ describe('approve', () => {
204
209
  }
205
210
 
206
211
  // verify balance
207
- const balance = await actions.token.getBalance(client, {
212
+ const balance = await actions.token.getBalance(clientWithAccount, {
208
213
  account: '0x0000000000000000000000000000000000000001',
209
214
  token: addresses.alphaUsd,
210
215
  })
@@ -215,7 +220,7 @@ describe('approve', () => {
215
220
  describe('create', () => {
216
221
  test('default', async () => {
217
222
  const { receipt, token, tokenId, ...result } =
218
- await actions.token.createSync(client, {
223
+ await actions.token.createSync(clientWithAccount, {
219
224
  currency: 'USD',
220
225
  name: 'Test USD',
221
226
  symbol: 'TUSD',
@@ -234,7 +239,7 @@ describe('create', () => {
234
239
  expect(tokenId).toBeDefined()
235
240
  expect(receipt).toBeDefined()
236
241
 
237
- const code = await getCode(client, {
242
+ const code = await getCode(clientWithAccount, {
238
243
  address: token,
239
244
  })
240
245
  expect(code).toBe('0xef')
@@ -244,7 +249,7 @@ describe('create', () => {
244
249
  describe('getAllowance', () => {
245
250
  test('default', async () => {
246
251
  // First, approve some allowance
247
- await writeContractSync(client, {
252
+ await writeContractSync(clientWithAccount, {
248
253
  abi: Abis.tip20,
249
254
  address: addresses.alphaUsd,
250
255
  functionName: 'approve',
@@ -253,7 +258,7 @@ describe('getAllowance', () => {
253
258
 
254
259
  {
255
260
  // Test with default token
256
- const allowance = await actions.token.getAllowance(client, {
261
+ const allowance = await actions.token.getAllowance(clientWithAccount, {
257
262
  spender: account2.address,
258
263
  token: addresses.alphaUsd,
259
264
  })
@@ -262,7 +267,7 @@ describe('getAllowance', () => {
262
267
 
263
268
  {
264
269
  // Test with token address
265
- const allowance = await actions.token.getAllowance(client, {
270
+ const allowance = await actions.token.getAllowance(clientWithAccount, {
266
271
  token: addresses.alphaUsd,
267
272
  spender: account2.address,
268
273
  })
@@ -272,7 +277,7 @@ describe('getAllowance', () => {
272
277
 
273
278
  {
274
279
  // Test with token ID
275
- const allowance = await actions.token.getAllowance(client, {
280
+ const allowance = await actions.token.getAllowance(clientWithAccount, {
276
281
  token: addresses.alphaUsd,
277
282
  spender: account2.address,
278
283
  })
@@ -286,7 +291,7 @@ describe('getBalance', () => {
286
291
  test('default', async () => {
287
292
  {
288
293
  // Test with token address
289
- const balance = await actions.token.getBalance(client, {
294
+ const balance = await actions.token.getBalance(clientWithAccount, {
290
295
  token: addresses.alphaUsd,
291
296
  })
292
297
 
@@ -295,7 +300,7 @@ describe('getBalance', () => {
295
300
 
296
301
  {
297
302
  // Test with token ID & different account
298
- const balance = await actions.token.getBalance(client, {
303
+ const balance = await actions.token.getBalance(clientWithAccount, {
299
304
  token: addresses.alphaUsd,
300
305
  account: Hex.random(20),
301
306
  })
@@ -307,7 +312,7 @@ describe('getBalance', () => {
307
312
 
308
313
  describe('getMetadata', () => {
309
314
  test('default', async () => {
310
- const metadata = await actions.token.getMetadata(client, {
315
+ const metadata = await actions.token.getMetadata(clientWithAccount, {
311
316
  token: addresses.alphaUsd,
312
317
  })
313
318
 
@@ -327,13 +332,13 @@ describe('getMetadata', () => {
327
332
  })
328
333
 
329
334
  test('behavior: custom token (address)', async () => {
330
- const { token } = await actions.token.createSync(client, {
335
+ const { token } = await actions.token.createSync(clientWithAccount, {
331
336
  currency: 'USD',
332
337
  name: 'Test USD',
333
338
  symbol: 'TUSD',
334
339
  })
335
340
 
336
- const metadata = await actions.token.getMetadata(client, {
341
+ const metadata = await actions.token.getMetadata(clientWithAccount, {
337
342
  token,
338
343
  })
339
344
 
@@ -354,7 +359,7 @@ describe('getMetadata', () => {
354
359
 
355
360
  test('behavior: quote token', async () => {
356
361
  {
357
- const metadata = await actions.token.getMetadata(client, {
362
+ const metadata = await actions.token.getMetadata(clientWithAccount, {
358
363
  token: TokenIds.linkingUsd,
359
364
  })
360
365
 
@@ -370,7 +375,7 @@ describe('getMetadata', () => {
370
375
  }
371
376
 
372
377
  {
373
- const metadata = await actions.token.getMetadata(client, {
378
+ const metadata = await actions.token.getMetadata(clientWithAccount, {
374
379
  token: Addresses.linkingUsd,
375
380
  })
376
381
 
@@ -387,13 +392,13 @@ describe('getMetadata', () => {
387
392
  })
388
393
 
389
394
  test('behavior: custom token (id)', async () => {
390
- const token = await actions.token.createSync(client, {
395
+ const token = await actions.token.createSync(clientWithAccount, {
391
396
  currency: 'USD',
392
397
  name: 'Test USD',
393
398
  symbol: 'TUSD',
394
399
  })
395
400
 
396
- const metadata = await actions.token.getMetadata(client, {
401
+ const metadata = await actions.token.getMetadata(clientWithAccount, {
397
402
  token: token.tokenId,
398
403
  })
399
404
 
@@ -416,21 +421,21 @@ describe('getMetadata', () => {
416
421
  describe('mint', () => {
417
422
  test('default', async () => {
418
423
  // Create a new token where we're the admin
419
- const { token } = await actions.token.createSync(client, {
424
+ const { token } = await actions.token.createSync(clientWithAccount, {
420
425
  currency: 'USD',
421
426
  name: 'Mintable Token',
422
427
  symbol: 'MINT',
423
428
  })
424
429
 
425
430
  // Grant issuer role
426
- await actions.token.grantRolesSync(client, {
431
+ await actions.token.grantRolesSync(clientWithAccount, {
427
432
  token,
428
433
  roles: ['issuer'],
429
- to: client.account.address,
434
+ to: clientWithAccount.account.address,
430
435
  })
431
436
 
432
437
  // Check initial balance
433
- const balanceBefore = await actions.token.getBalance(client, {
438
+ const balanceBefore = await actions.token.getBalance(clientWithAccount, {
434
439
  token,
435
440
  account: account2.address,
436
441
  })
@@ -438,7 +443,7 @@ describe('mint', () => {
438
443
 
439
444
  // Mint tokens
440
445
  const { receipt: mintReceipt, ...mintResult } =
441
- await actions.token.mintSync(client, {
446
+ await actions.token.mintSync(clientWithAccount, {
442
447
  token,
443
448
  to: account2.address,
444
449
  amount: parseUnits('1000', 6),
@@ -452,14 +457,14 @@ describe('mint', () => {
452
457
  `)
453
458
 
454
459
  // Check balance after mint
455
- const balanceAfter = await actions.token.getBalance(client, {
460
+ const balanceAfter = await actions.token.getBalance(clientWithAccount, {
456
461
  token,
457
462
  account: account2.address,
458
463
  })
459
464
  expect(balanceAfter).toBe(parseUnits('1000', 6))
460
465
 
461
466
  // Check total supply
462
- const metadata = await actions.token.getMetadata(client, {
467
+ const metadata = await actions.token.getMetadata(clientWithAccount, {
463
468
  token,
464
469
  })
465
470
  expect(metadata.totalSupply).toBe(parseUnits('1000', 6))
@@ -468,23 +473,23 @@ describe('mint', () => {
468
473
  // TODO: fix
469
474
  test.skip('with memo', async () => {
470
475
  // Create a new token
471
- const { token } = await actions.token.createSync(client, {
472
- admin: client.account,
476
+ const { token } = await actions.token.createSync(clientWithAccount, {
477
+ admin: clientWithAccount.account,
473
478
  currency: 'USD',
474
479
  name: 'Mintable Token 2',
475
480
  symbol: 'MINT2',
476
481
  })
477
482
 
478
483
  // Grant issuer role
479
- await actions.token.grantRolesSync(client, {
484
+ await actions.token.grantRolesSync(clientWithAccount, {
480
485
  token,
481
486
  roles: ['issuer'],
482
- to: client.account.address,
487
+ to: clientWithAccount.account.address,
483
488
  })
484
489
 
485
490
  // Mint tokens with memo
486
491
  const { receipt: mintMemoReceipt, ...mintMemoResult } =
487
- await actions.token.mintSync(client, {
492
+ await actions.token.mintSync(clientWithAccount, {
488
493
  token,
489
494
  to: account2.address,
490
495
  amount: parseUnits('500', 6),
@@ -499,7 +504,7 @@ describe('mint', () => {
499
504
  `)
500
505
 
501
506
  // Verify balance
502
- const balance = await actions.token.getBalance(client, {
507
+ const balance = await actions.token.getBalance(clientWithAccount, {
503
508
  token,
504
509
  account: account2.address,
505
510
  })
@@ -510,18 +515,24 @@ describe('mint', () => {
510
515
  describe('transfer', () => {
511
516
  test('default', async () => {
512
517
  // Get initial balances
513
- const senderBalanceBefore = await actions.token.getBalance(client, {
514
- account: account.address,
515
- token: addresses.alphaUsd,
516
- })
517
- const receiverBalanceBefore = await actions.token.getBalance(client, {
518
- account: account2.address,
519
- token: addresses.alphaUsd,
520
- })
518
+ const senderBalanceBefore = await actions.token.getBalance(
519
+ clientWithAccount,
520
+ {
521
+ account: account.address,
522
+ token: addresses.alphaUsd,
523
+ },
524
+ )
525
+ const receiverBalanceBefore = await actions.token.getBalance(
526
+ clientWithAccount,
527
+ {
528
+ account: account2.address,
529
+ token: addresses.alphaUsd,
530
+ },
531
+ )
521
532
 
522
533
  // Transfer tokens
523
534
  const { receipt: transferReceipt, ...transferResult } =
524
- await actions.token.transferSync(client, {
535
+ await actions.token.transferSync(clientWithAccount, {
525
536
  to: account2.address,
526
537
  amount: parseUnits('10', 6),
527
538
  token: addresses.alphaUsd,
@@ -536,14 +547,20 @@ describe('transfer', () => {
536
547
  `)
537
548
 
538
549
  // Verify balances
539
- const senderBalanceAfter = await actions.token.getBalance(client, {
540
- account: account.address,
541
- token: addresses.alphaUsd,
542
- })
543
- const receiverBalanceAfter = await actions.token.getBalance(client, {
544
- account: account2.address,
545
- token: addresses.alphaUsd,
546
- })
550
+ const senderBalanceAfter = await actions.token.getBalance(
551
+ clientWithAccount,
552
+ {
553
+ account: account.address,
554
+ token: addresses.alphaUsd,
555
+ },
556
+ )
557
+ const receiverBalanceAfter = await actions.token.getBalance(
558
+ clientWithAccount,
559
+ {
560
+ account: account2.address,
561
+ token: addresses.alphaUsd,
562
+ },
563
+ )
547
564
 
548
565
  expect(senderBalanceAfter - senderBalanceBefore).toBeLessThan(
549
566
  parseUnits('10', 6),
@@ -555,34 +572,34 @@ describe('transfer', () => {
555
572
 
556
573
  test('behavior: with custom token', async () => {
557
574
  // Create a new token
558
- const { token } = await actions.token.createSync(client, {
575
+ const { token } = await actions.token.createSync(clientWithAccount, {
559
576
  currency: 'USD',
560
577
  name: 'Transfer Token',
561
578
  symbol: 'XFER',
562
579
  })
563
580
 
564
581
  // Grant issuer role and mint tokens
565
- await actions.token.grantRolesSync(client, {
582
+ await actions.token.grantRolesSync(clientWithAccount, {
566
583
  token,
567
584
  roles: ['issuer'],
568
- to: client.account.address,
585
+ to: clientWithAccount.account.address,
569
586
  })
570
587
 
571
- await actions.token.mintSync(client, {
588
+ await actions.token.mintSync(clientWithAccount, {
572
589
  token,
573
- to: client.account.address,
590
+ to: clientWithAccount.account.address,
574
591
  amount: parseUnits('1000', 6),
575
592
  })
576
593
 
577
594
  // Transfer custom tokens
578
- await actions.token.transferSync(client, {
595
+ await actions.token.transferSync(clientWithAccount, {
579
596
  token,
580
597
  to: account2.address,
581
598
  amount: parseUnits('100', 6),
582
599
  })
583
600
 
584
601
  // Verify balance
585
- const balance = await actions.token.getBalance(client, {
602
+ const balance = await actions.token.getBalance(clientWithAccount, {
586
603
  token,
587
604
  account: account2.address,
588
605
  })
@@ -593,7 +610,7 @@ describe('transfer', () => {
593
610
  const memo = Hex.fromString('Payment for services')
594
611
 
595
612
  const { receipt: transferMemoReceipt, ...transferMemoResult } =
596
- await actions.token.transferSync(client, {
613
+ await actions.token.transferSync(clientWithAccount, {
597
614
  to: account2.address,
598
615
  amount: parseUnits('5', 6),
599
616
  memo,
@@ -612,14 +629,14 @@ describe('transfer', () => {
612
629
 
613
630
  test('behavior: from another account (transferFrom)', async () => {
614
631
  // First approve account2 to spend tokens
615
- await actions.token.approveSync(client, {
632
+ await actions.token.approveSync(clientWithAccount, {
616
633
  spender: account2.address,
617
634
  amount: parseUnits('50', 6),
618
635
  token: addresses.alphaUsd,
619
636
  })
620
637
 
621
638
  // Transfer tokens for gas
622
- await writeContractSync(client, {
639
+ await writeContractSync(clientWithAccount, {
623
640
  abi: Abis.tip20,
624
641
  address: addresses.alphaUsd,
625
642
  functionName: 'transfer',
@@ -627,13 +644,13 @@ describe('transfer', () => {
627
644
  })
628
645
 
629
646
  // Get initial balance
630
- const balanceBefore = await actions.token.getBalance(client, {
647
+ const balanceBefore = await actions.token.getBalance(clientWithAccount, {
631
648
  account: account3.address,
632
649
  token: addresses.alphaUsd,
633
650
  })
634
651
 
635
652
  // Account2 transfers from account to account3
636
- await actions.token.transferSync(client, {
653
+ await actions.token.transferSync(clientWithAccount, {
637
654
  account: account2,
638
655
  from: account.address,
639
656
  to: account3.address,
@@ -642,14 +659,14 @@ describe('transfer', () => {
642
659
  })
643
660
 
644
661
  // Verify balance
645
- const balanceAfter = await actions.token.getBalance(client, {
662
+ const balanceAfter = await actions.token.getBalance(clientWithAccount, {
646
663
  account: account3.address,
647
664
  token: addresses.alphaUsd,
648
665
  })
649
666
  expect(balanceAfter - balanceBefore).toBe(parseUnits('25', 6))
650
667
 
651
668
  // Verify allowance was reduced
652
- const allowance = await actions.token.getAllowance(client, {
669
+ const allowance = await actions.token.getAllowance(clientWithAccount, {
653
670
  spender: account2.address,
654
671
  token: addresses.alphaUsd,
655
672
  })
@@ -660,43 +677,46 @@ describe('transfer', () => {
660
677
  describe('burn', () => {
661
678
  test('default', async () => {
662
679
  // Create a new token where we have issuer role
663
- const { token } = await actions.token.createSync(client, {
680
+ const { token } = await actions.token.createSync(clientWithAccount, {
664
681
  currency: 'USD',
665
682
  name: 'Burnable Token',
666
683
  symbol: 'BURN',
667
684
  })
668
685
 
669
686
  // Grant issuer role
670
- await actions.token.grantRolesSync(client, {
687
+ await actions.token.grantRolesSync(clientWithAccount, {
671
688
  token,
672
689
  roles: ['issuer'],
673
- to: client.account.address,
690
+ to: clientWithAccount.account.address,
674
691
  })
675
692
 
676
693
  // Mint some tokens
677
- await actions.token.mintSync(client, {
694
+ await actions.token.mintSync(clientWithAccount, {
678
695
  token,
679
- to: client.account.address,
696
+ to: clientWithAccount.account.address,
680
697
  amount: parseUnits('1000', 6),
681
698
  })
682
699
 
683
700
  // Check balance before burn
684
- const balanceBefore = await actions.token.getBalance(client, {
701
+ const balanceBefore = await actions.token.getBalance(clientWithAccount, {
685
702
  token,
686
703
  })
687
704
  expect(balanceBefore).toBe(parseUnits('1000', 6))
688
705
 
689
706
  // Check total supply before
690
- const metadataBefore = await actions.token.getMetadata(client, {
707
+ const metadataBefore = await actions.token.getMetadata(clientWithAccount, {
691
708
  token,
692
709
  })
693
710
  expect(metadataBefore.totalSupply).toBe(parseUnits('1000', 6))
694
711
 
695
712
  // Burn tokens
696
- const { receipt, ...result } = await actions.token.burnSync(client, {
697
- token,
698
- amount: parseUnits('100', 6),
699
- })
713
+ const { receipt, ...result } = await actions.token.burnSync(
714
+ clientWithAccount,
715
+ {
716
+ token,
717
+ amount: parseUnits('100', 6),
718
+ },
719
+ )
700
720
  expect(receipt).toBeDefined()
701
721
  expect(result).toMatchInlineSnapshot(`
702
722
  {
@@ -706,13 +726,13 @@ describe('burn', () => {
706
726
  `)
707
727
 
708
728
  // Check balance after burn
709
- const balanceAfter = await actions.token.getBalance(client, {
729
+ const balanceAfter = await actions.token.getBalance(clientWithAccount, {
710
730
  token,
711
731
  })
712
732
  expect(balanceAfter).toBe(parseUnits('900', 6))
713
733
 
714
734
  // Check total supply after
715
- const metadataAfter = await actions.token.getMetadata(client, {
735
+ const metadataAfter = await actions.token.getMetadata(clientWithAccount, {
716
736
  token,
717
737
  })
718
738
  expect(metadataAfter.totalSupply).toBe(parseUnits('900', 6))
@@ -720,38 +740,38 @@ describe('burn', () => {
720
740
 
721
741
  test('behavior: requires issuer role', async () => {
722
742
  // Create a new token
723
- const { token } = await actions.token.createSync(client, {
743
+ const { token } = await actions.token.createSync(clientWithAccount, {
724
744
  currency: 'USD',
725
745
  name: 'Restricted Burn Token',
726
746
  symbol: 'RBURN',
727
747
  })
728
748
 
729
749
  // Grant issuer role to account2 (not us)
730
- await actions.token.grantRolesSync(client, {
750
+ await actions.token.grantRolesSync(clientWithAccount, {
731
751
  token,
732
752
  roles: ['issuer'],
733
753
  to: account2.address,
734
754
  })
735
755
 
736
756
  // Transfer gas to account2
737
- await writeContractSync(client, {
757
+ await writeContractSync(clientWithAccount, {
738
758
  abi: Abis.tip20,
739
759
  address: addresses.alphaUsd,
740
760
  functionName: 'transfer',
741
761
  args: [account2.address, parseUnits('1', 6)],
742
762
  })
743
763
 
744
- await actions.token.mintSync(client, {
764
+ await actions.token.mintSync(clientWithAccount, {
745
765
  account: account2,
746
766
  feeToken: addresses.alphaUsd,
747
767
  token,
748
- to: client.account.address,
768
+ to: clientWithAccount.account.address,
749
769
  amount: parseUnits('100', 6),
750
770
  })
751
771
 
752
772
  // Try to burn without issuer role - should fail
753
773
  await expect(
754
- actions.token.burnSync(client, {
774
+ actions.token.burnSync(clientWithAccount, {
755
775
  token,
756
776
  amount: parseUnits('10', 6),
757
777
  }),
@@ -766,47 +786,47 @@ describe.todo('changeTokenTransferPolicy')
766
786
  describe('pause', () => {
767
787
  test('default', async () => {
768
788
  // Create a new token
769
- const { token } = await actions.token.createSync(client, {
789
+ const { token } = await actions.token.createSync(clientWithAccount, {
770
790
  currency: 'USD',
771
791
  name: 'Pausable Token',
772
792
  symbol: 'PAUSE',
773
793
  })
774
794
 
775
795
  // Grant pause role
776
- await actions.token.grantRolesSync(client, {
796
+ await actions.token.grantRolesSync(clientWithAccount, {
777
797
  token,
778
798
  roles: ['pause'],
779
- to: client.account.address,
799
+ to: clientWithAccount.account.address,
780
800
  })
781
801
 
782
802
  // Grant issuer role and mint tokens
783
- await actions.token.grantRolesSync(client, {
803
+ await actions.token.grantRolesSync(clientWithAccount, {
784
804
  token,
785
805
  roles: ['issuer'],
786
- to: client.account.address,
806
+ to: clientWithAccount.account.address,
787
807
  })
788
808
 
789
- await actions.token.mintSync(client, {
809
+ await actions.token.mintSync(clientWithAccount, {
790
810
  token,
791
811
  to: account2.address,
792
812
  amount: parseUnits('1000', 6),
793
813
  })
794
814
 
795
815
  // Verify token is not paused
796
- let metadata = await actions.token.getMetadata(client, {
816
+ let metadata = await actions.token.getMetadata(clientWithAccount, {
797
817
  token,
798
818
  })
799
819
  expect(metadata.paused).toBe(false)
800
820
 
801
821
  // Transfer gas
802
- await writeContractSync(client, {
822
+ await writeContractSync(clientWithAccount, {
803
823
  abi: Abis.tip20,
804
824
  address: addresses.alphaUsd,
805
825
  functionName: 'transfer',
806
826
  args: [account2.address, parseUnits('1', 6)],
807
827
  })
808
828
 
809
- await actions.token.transferSync(client, {
829
+ await actions.token.transferSync(clientWithAccount, {
810
830
  account: account2,
811
831
  token,
812
832
  to: account3.address,
@@ -815,7 +835,7 @@ describe('pause', () => {
815
835
 
816
836
  // Pause the token
817
837
  const { receipt: pauseReceipt, ...pauseResult } =
818
- await actions.token.pauseSync(client, {
838
+ await actions.token.pauseSync(clientWithAccount, {
819
839
  token,
820
840
  })
821
841
  expect(pauseReceipt).toBeDefined()
@@ -827,14 +847,14 @@ describe('pause', () => {
827
847
  `)
828
848
 
829
849
  // Verify token is paused
830
- metadata = await actions.token.getMetadata(client, {
850
+ metadata = await actions.token.getMetadata(clientWithAccount, {
831
851
  token,
832
852
  })
833
853
  expect(metadata.paused).toBe(true)
834
854
 
835
855
  // Transfers should now fail
836
856
  await expect(
837
- actions.token.transferSync(client, {
857
+ actions.token.transferSync(clientWithAccount, {
838
858
  account: account2,
839
859
  token,
840
860
  to: account3.address,
@@ -845,7 +865,7 @@ describe('pause', () => {
845
865
 
846
866
  test('behavior: requires pause role', async () => {
847
867
  // Create a new token
848
- const { token } = await actions.token.createSync(client, {
868
+ const { token } = await actions.token.createSync(clientWithAccount, {
849
869
  currency: 'USD',
850
870
  name: 'Restricted Pause Token',
851
871
  symbol: 'RPAUSE',
@@ -853,34 +873,34 @@ describe('pause', () => {
853
873
 
854
874
  // Try to pause without pause role - should fail
855
875
  await expect(
856
- actions.token.pauseSync(client, {
876
+ actions.token.pauseSync(clientWithAccount, {
857
877
  token,
858
878
  }),
859
879
  ).rejects.toThrow()
860
880
 
861
881
  // Grant pause role to account2
862
- await actions.token.grantRolesSync(client, {
882
+ await actions.token.grantRolesSync(clientWithAccount, {
863
883
  token,
864
884
  roles: ['pause'],
865
885
  to: account2.address,
866
886
  })
867
887
 
868
888
  // Transfer gas to account2
869
- await writeContractSync(client, {
889
+ await writeContractSync(clientWithAccount, {
870
890
  abi: Abis.tip20,
871
891
  address: addresses.alphaUsd,
872
892
  functionName: 'transfer',
873
893
  args: [account2.address, parseUnits('1', 6)],
874
894
  })
875
895
 
876
- await actions.token.pauseSync(client, {
896
+ await actions.token.pauseSync(clientWithAccount, {
877
897
  account: account2,
878
898
  feeToken: addresses.alphaUsd,
879
899
  token,
880
900
  })
881
901
 
882
902
  // Verify token is paused
883
- const metadata = await actions.token.getMetadata(client, {
903
+ const metadata = await actions.token.getMetadata(clientWithAccount, {
884
904
  token,
885
905
  })
886
906
  expect(metadata.paused).toBe(true)
@@ -888,27 +908,30 @@ describe('pause', () => {
888
908
 
889
909
  test('behavior: cannot pause already paused token', async () => {
890
910
  // Create a new token
891
- const { token: address } = await actions.token.createSync(client, {
892
- currency: 'USD',
893
- name: 'Double Pause Token',
894
- symbol: 'DPAUSE',
895
- })
911
+ const { token: address } = await actions.token.createSync(
912
+ clientWithAccount,
913
+ {
914
+ currency: 'USD',
915
+ name: 'Double Pause Token',
916
+ symbol: 'DPAUSE',
917
+ },
918
+ )
896
919
 
897
920
  // Grant pause role
898
- await actions.token.grantRolesSync(client, {
921
+ await actions.token.grantRolesSync(clientWithAccount, {
899
922
  token: address,
900
923
  roles: ['pause'],
901
- to: client.account.address,
924
+ to: clientWithAccount.account.address,
902
925
  })
903
926
 
904
927
  // Pause the token
905
- await actions.token.pauseSync(client, {
928
+ await actions.token.pauseSync(clientWithAccount, {
906
929
  token: address,
907
930
  })
908
931
 
909
932
  // Try to pause again - implementation may vary, but typically this succeeds without error
910
933
  const { receipt: doublePauseReceipt, ...doublePauseResult } =
911
- await actions.token.pauseSync(client, {
934
+ await actions.token.pauseSync(clientWithAccount, {
912
935
  token: address,
913
936
  })
914
937
  expect(doublePauseReceipt.status).toBe('success')
@@ -924,51 +947,54 @@ describe('pause', () => {
924
947
  describe('unpause', () => {
925
948
  test('default', async () => {
926
949
  // Create a new token
927
- const { token: address } = await actions.token.createSync(client, {
928
- currency: 'USD',
929
- name: 'Unpausable Token',
930
- symbol: 'UNPAUSE',
931
- })
950
+ const { token: address } = await actions.token.createSync(
951
+ clientWithAccount,
952
+ {
953
+ currency: 'USD',
954
+ name: 'Unpausable Token',
955
+ symbol: 'UNPAUSE',
956
+ },
957
+ )
932
958
 
933
959
  // Grant pause and unpause roles
934
- await actions.token.grantRolesSync(client, {
960
+ await actions.token.grantRolesSync(clientWithAccount, {
935
961
  token: address,
936
962
  roles: ['pause'],
937
- to: client.account.address,
963
+ to: clientWithAccount.account.address,
938
964
  })
939
965
 
940
- await actions.token.grantRolesSync(client, {
966
+ await actions.token.grantRolesSync(clientWithAccount, {
941
967
  token: address,
942
968
  roles: ['unpause'],
943
- to: client.account.address,
969
+ to: clientWithAccount.account.address,
944
970
  })
945
971
 
946
972
  // Grant issuer role and mint tokens
947
- await actions.token.grantRolesSync(client, {
973
+ await actions.token.grantRolesSync(clientWithAccount, {
948
974
  token: address,
949
975
  roles: ['issuer'],
950
- to: client.account.address,
976
+ to: clientWithAccount.account.address,
951
977
  })
952
978
 
953
- await actions.token.mintSync(client, {
979
+ await actions.token.mintSync(clientWithAccount, {
954
980
  token: address,
955
981
  to: account2.address,
956
982
  amount: parseUnits('1000', 6),
957
983
  })
958
984
 
959
985
  // First pause the token
960
- await actions.token.pauseSync(client, {
986
+ await actions.token.pauseSync(clientWithAccount, {
961
987
  token: address,
962
988
  })
963
989
 
964
990
  // Verify token is paused
965
- let metadata = await actions.token.getMetadata(client, {
991
+ let metadata = await actions.token.getMetadata(clientWithAccount, {
966
992
  token: address,
967
993
  })
968
994
  expect(metadata.paused).toBe(true)
969
995
 
970
996
  // Transfer gas to account2
971
- await writeContractSync(client, {
997
+ await writeContractSync(clientWithAccount, {
972
998
  abi: Abis.tip20,
973
999
  address: addresses.alphaUsd,
974
1000
  functionName: 'transfer',
@@ -977,7 +1003,7 @@ describe('unpause', () => {
977
1003
 
978
1004
  // Verify transfers fail when paused
979
1005
  await expect(
980
- actions.token.transferSync(client, {
1006
+ actions.token.transferSync(clientWithAccount, {
981
1007
  account: account2,
982
1008
  token: address,
983
1009
  to: account3.address,
@@ -987,7 +1013,7 @@ describe('unpause', () => {
987
1013
 
988
1014
  // Unpause the token
989
1015
  const { receipt: unpauseReceipt, ...unpauseResult } =
990
- await actions.token.unpauseSync(client, {
1016
+ await actions.token.unpauseSync(clientWithAccount, {
991
1017
  token: address,
992
1018
  })
993
1019
  expect(unpauseReceipt).toBeDefined()
@@ -999,20 +1025,20 @@ describe('unpause', () => {
999
1025
  `)
1000
1026
 
1001
1027
  // Verify token is unpaused
1002
- metadata = await actions.token.getMetadata(client, {
1028
+ metadata = await actions.token.getMetadata(clientWithAccount, {
1003
1029
  token: address,
1004
1030
  })
1005
1031
  expect(metadata.paused).toBe(false)
1006
1032
 
1007
1033
  // Transfers should work again
1008
- await actions.token.transferSync(client, {
1034
+ await actions.token.transferSync(clientWithAccount, {
1009
1035
  account: account2,
1010
1036
  token: address,
1011
1037
  to: account3.address,
1012
1038
  amount: parseUnits('100', 6),
1013
1039
  })
1014
1040
 
1015
- const balance = await actions.token.getBalance(client, {
1041
+ const balance = await actions.token.getBalance(clientWithAccount, {
1016
1042
  token: address,
1017
1043
  account: account3.address,
1018
1044
  })
@@ -1021,39 +1047,42 @@ describe('unpause', () => {
1021
1047
 
1022
1048
  test('behavior: requires unpause role', async () => {
1023
1049
  // Create a new token
1024
- const { token: address } = await actions.token.createSync(client, {
1025
- currency: 'USD',
1026
- name: 'Restricted Unpause Token',
1027
- symbol: 'RUNPAUSE',
1028
- })
1050
+ const { token: address } = await actions.token.createSync(
1051
+ clientWithAccount,
1052
+ {
1053
+ currency: 'USD',
1054
+ name: 'Restricted Unpause Token',
1055
+ symbol: 'RUNPAUSE',
1056
+ },
1057
+ )
1029
1058
 
1030
1059
  // Grant pause role and pause the token
1031
- await actions.token.grantRolesSync(client, {
1060
+ await actions.token.grantRolesSync(clientWithAccount, {
1032
1061
  token: address,
1033
1062
  roles: ['pause'],
1034
- to: client.account.address,
1063
+ to: clientWithAccount.account.address,
1035
1064
  })
1036
1065
 
1037
- await actions.token.pauseSync(client, {
1066
+ await actions.token.pauseSync(clientWithAccount, {
1038
1067
  token: address,
1039
1068
  })
1040
1069
 
1041
1070
  // Try to unpause without unpause role - should fail
1042
1071
  await expect(
1043
- actions.token.unpauseSync(client, {
1072
+ actions.token.unpauseSync(clientWithAccount, {
1044
1073
  token: address,
1045
1074
  }),
1046
1075
  ).rejects.toThrow()
1047
1076
 
1048
1077
  // Grant unpause role to account2
1049
- await actions.token.grantRolesSync(client, {
1078
+ await actions.token.grantRolesSync(clientWithAccount, {
1050
1079
  token: address,
1051
1080
  roles: ['unpause'],
1052
1081
  to: account2.address,
1053
1082
  })
1054
1083
 
1055
1084
  // Transfer gas to account2
1056
- await writeContractSync(client, {
1085
+ await writeContractSync(clientWithAccount, {
1057
1086
  abi: Abis.tip20,
1058
1087
  address: addresses.alphaUsd,
1059
1088
  functionName: 'transfer',
@@ -1061,14 +1090,14 @@ describe('unpause', () => {
1061
1090
  })
1062
1091
 
1063
1092
  // Now account2 should be able to unpause
1064
- await actions.token.unpauseSync(client, {
1093
+ await actions.token.unpauseSync(clientWithAccount, {
1065
1094
  account: account2,
1066
1095
  feeToken: addresses.alphaUsd,
1067
1096
  token: address,
1068
1097
  })
1069
1098
 
1070
1099
  // Verify token is unpaused
1071
- const metadata = await actions.token.getMetadata(client, {
1100
+ const metadata = await actions.token.getMetadata(clientWithAccount, {
1072
1101
  token: address,
1073
1102
  })
1074
1103
  expect(metadata.paused).toBe(false)
@@ -1076,35 +1105,38 @@ describe('unpause', () => {
1076
1105
 
1077
1106
  test('behavior: different roles for pause and unpause', async () => {
1078
1107
  // Create a new token
1079
- const { token: address } = await actions.token.createSync(client, {
1080
- currency: 'USD',
1081
- name: 'Split Role Token',
1082
- symbol: 'SPLIT',
1083
- })
1108
+ const { token: address } = await actions.token.createSync(
1109
+ clientWithAccount,
1110
+ {
1111
+ currency: 'USD',
1112
+ name: 'Split Role Token',
1113
+ symbol: 'SPLIT',
1114
+ },
1115
+ )
1084
1116
 
1085
1117
  // Grant pause role to account2
1086
- await actions.token.grantRolesSync(client, {
1118
+ await actions.token.grantRolesSync(clientWithAccount, {
1087
1119
  token: address,
1088
1120
  roles: ['pause'],
1089
1121
  to: account2.address,
1090
1122
  })
1091
1123
 
1092
1124
  // Grant unpause role to account3
1093
- await actions.token.grantRolesSync(client, {
1125
+ await actions.token.grantRolesSync(clientWithAccount, {
1094
1126
  token: address,
1095
1127
  roles: ['unpause'],
1096
1128
  to: account3.address,
1097
1129
  })
1098
1130
 
1099
1131
  // Transfer gas to both accounts
1100
- await writeContractSync(client, {
1132
+ await writeContractSync(clientWithAccount, {
1101
1133
  abi: Abis.tip20,
1102
1134
  address: addresses.alphaUsd,
1103
1135
  functionName: 'transfer',
1104
1136
  args: [account2.address, parseUnits('1', 6)],
1105
1137
  })
1106
1138
 
1107
- await writeContractSync(client, {
1139
+ await writeContractSync(clientWithAccount, {
1108
1140
  abi: Abis.tip20,
1109
1141
  address: addresses.alphaUsd,
1110
1142
  functionName: 'transfer',
@@ -1112,7 +1144,7 @@ describe('unpause', () => {
1112
1144
  })
1113
1145
 
1114
1146
  // Account2 can pause
1115
- await actions.token.pauseSync(client, {
1147
+ await actions.token.pauseSync(clientWithAccount, {
1116
1148
  account: account2,
1117
1149
  feeToken: addresses.alphaUsd,
1118
1150
  token: address,
@@ -1120,21 +1152,21 @@ describe('unpause', () => {
1120
1152
 
1121
1153
  // Account2 cannot unpause
1122
1154
  await expect(
1123
- actions.token.unpauseSync(client, {
1155
+ actions.token.unpauseSync(clientWithAccount, {
1124
1156
  account: account2,
1125
1157
  token: address,
1126
1158
  }),
1127
1159
  ).rejects.toThrow()
1128
1160
 
1129
1161
  // Account3 can unpause
1130
- await actions.token.unpauseSync(client, {
1162
+ await actions.token.unpauseSync(clientWithAccount, {
1131
1163
  account: account3,
1132
1164
  feeToken: addresses.alphaUsd,
1133
1165
  token: address,
1134
1166
  })
1135
1167
 
1136
1168
  // Verify token is unpaused
1137
- const metadata = await actions.token.getMetadata(client, {
1169
+ const metadata = await actions.token.getMetadata(clientWithAccount, {
1138
1170
  token: address,
1139
1171
  })
1140
1172
  expect(metadata.paused).toBe(false)
@@ -1145,7 +1177,7 @@ describe('prepareUpdateQuoteToken', () => {
1145
1177
  test('default', async () => {
1146
1178
  // Create two tokens - one to be the new quote token
1147
1179
  const { token: quoteTokenAddress } = await actions.token.createSync(
1148
- client,
1180
+ clientWithAccount,
1149
1181
  {
1150
1182
  currency: 'USD',
1151
1183
  name: 'Quote Token',
@@ -1153,18 +1185,21 @@ describe('prepareUpdateQuoteToken', () => {
1153
1185
  },
1154
1186
  )
1155
1187
 
1156
- const { token: address } = await actions.token.createSync(client, {
1157
- currency: 'USD',
1158
- name: 'Main Token',
1159
- symbol: 'MAIN',
1160
- })
1188
+ const { token: address } = await actions.token.createSync(
1189
+ clientWithAccount,
1190
+ {
1191
+ currency: 'USD',
1192
+ name: 'Main Token',
1193
+ symbol: 'MAIN',
1194
+ },
1195
+ )
1161
1196
 
1162
1197
  // Update quote token
1163
1198
  const {
1164
1199
  receipt: updateReceipt,
1165
1200
  nextQuoteToken,
1166
1201
  ...updateResult
1167
- } = await actions.token.prepareUpdateQuoteTokenSync(client, {
1202
+ } = await actions.token.prepareUpdateQuoteTokenSync(clientWithAccount, {
1168
1203
  token: address,
1169
1204
  quoteToken: quoteTokenAddress,
1170
1205
  })
@@ -1183,7 +1218,7 @@ describe('prepareUpdateQuoteToken', () => {
1183
1218
  test('behavior: requires admin role', async () => {
1184
1219
  // Create quote token
1185
1220
  const { token: quoteTokenAddress } = await actions.token.createSync(
1186
- client,
1221
+ clientWithAccount,
1187
1222
  {
1188
1223
  currency: 'USD',
1189
1224
  name: 'Quote Token 2',
@@ -1191,15 +1226,18 @@ describe('prepareUpdateQuoteToken', () => {
1191
1226
  },
1192
1227
  )
1193
1228
 
1194
- // Create main token where client.account is admin
1195
- const { token: address } = await actions.token.createSync(client, {
1196
- currency: 'USD',
1197
- name: 'Restricted Token',
1198
- symbol: 'RESTR',
1199
- })
1229
+ // Create main token where clientWithAccount.account is admin
1230
+ const { token: address } = await actions.token.createSync(
1231
+ clientWithAccount,
1232
+ {
1233
+ currency: 'USD',
1234
+ name: 'Restricted Token',
1235
+ symbol: 'RESTR',
1236
+ },
1237
+ )
1200
1238
 
1201
1239
  // Transfer gas to account2
1202
- await writeContractSync(client, {
1240
+ await writeContractSync(clientWithAccount, {
1203
1241
  abi: Abis.tip20,
1204
1242
  address: addresses.alphaUsd,
1205
1243
  functionName: 'transfer',
@@ -1208,7 +1246,7 @@ describe('prepareUpdateQuoteToken', () => {
1208
1246
 
1209
1247
  // Try to update quote token from account2 (not admin) - should fail
1210
1248
  await expect(
1211
- actions.token.prepareUpdateQuoteTokenSync(client, {
1249
+ actions.token.prepareUpdateQuoteTokenSync(clientWithAccount, {
1212
1250
  account: account2,
1213
1251
  token: address,
1214
1252
  quoteToken: quoteTokenAddress,
@@ -1219,7 +1257,7 @@ describe('prepareUpdateQuoteToken', () => {
1219
1257
  test('behavior: with token ID', async () => {
1220
1258
  // Create quote token
1221
1259
  const { token: quoteTokenAddress } = await actions.token.createSync(
1222
- client,
1260
+ clientWithAccount,
1223
1261
  {
1224
1262
  currency: 'USD',
1225
1263
  name: 'Quote Token 3',
@@ -1228,18 +1266,21 @@ describe('prepareUpdateQuoteToken', () => {
1228
1266
  )
1229
1267
 
1230
1268
  // Create main token using token ID
1231
- const { tokenId: mainTokenId } = await actions.token.createSync(client, {
1232
- currency: 'USD',
1233
- name: 'Main Token ID',
1234
- symbol: 'MAINID',
1235
- })
1269
+ const { tokenId: mainTokenId } = await actions.token.createSync(
1270
+ clientWithAccount,
1271
+ {
1272
+ currency: 'USD',
1273
+ name: 'Main Token ID',
1274
+ symbol: 'MAINID',
1275
+ },
1276
+ )
1236
1277
 
1237
1278
  // Update quote token using token ID for main token, address for quote token
1238
1279
  const {
1239
1280
  receipt: updateReceipt,
1240
1281
  nextQuoteToken,
1241
1282
  ...updateResult
1242
- } = await actions.token.prepareUpdateQuoteTokenSync(client, {
1283
+ } = await actions.token.prepareUpdateQuoteTokenSync(clientWithAccount, {
1243
1284
  token: mainTokenId,
1244
1285
  quoteToken: quoteTokenAddress,
1245
1286
  })
@@ -1258,7 +1299,7 @@ describe('finalizeUpdateQuoteToken', () => {
1258
1299
  test('default', async () => {
1259
1300
  // Create quote token
1260
1301
  const { token: quoteTokenAddress } = await actions.token.createSync(
1261
- client,
1302
+ clientWithAccount,
1262
1303
  {
1263
1304
  currency: 'USD',
1264
1305
  name: 'Quote Token',
@@ -1267,14 +1308,17 @@ describe('finalizeUpdateQuoteToken', () => {
1267
1308
  )
1268
1309
 
1269
1310
  // Create main token
1270
- const { token: address } = await actions.token.createSync(client, {
1271
- currency: 'USD',
1272
- name: 'Main Token',
1273
- symbol: 'MAIN',
1274
- })
1311
+ const { token: address } = await actions.token.createSync(
1312
+ clientWithAccount,
1313
+ {
1314
+ currency: 'USD',
1315
+ name: 'Main Token',
1316
+ symbol: 'MAIN',
1317
+ },
1318
+ )
1275
1319
 
1276
1320
  // Prepare update quote token (step 1)
1277
- await actions.token.prepareUpdateQuoteTokenSync(client, {
1321
+ await actions.token.prepareUpdateQuoteTokenSync(clientWithAccount, {
1278
1322
  token: address,
1279
1323
  quoteToken: quoteTokenAddress,
1280
1324
  })
@@ -1284,7 +1328,7 @@ describe('finalizeUpdateQuoteToken', () => {
1284
1328
  receipt: finalizeReceipt,
1285
1329
  newQuoteToken,
1286
1330
  ...finalizeResult
1287
- } = await actions.token.updateQuoteTokenSync(client, {
1331
+ } = await actions.token.updateQuoteTokenSync(clientWithAccount, {
1288
1332
  token: address,
1289
1333
  })
1290
1334
 
@@ -1299,7 +1343,7 @@ describe('finalizeUpdateQuoteToken', () => {
1299
1343
  expect(newQuoteToken).toBe(quoteTokenAddress)
1300
1344
 
1301
1345
  // Verify it's reflected in metadata
1302
- const metadata = await actions.token.getMetadata(client, {
1346
+ const metadata = await actions.token.getMetadata(clientWithAccount, {
1303
1347
  token: address,
1304
1348
  })
1305
1349
  expect(metadata.quoteToken).toBe(quoteTokenAddress)
@@ -1308,7 +1352,7 @@ describe('finalizeUpdateQuoteToken', () => {
1308
1352
  test('behavior: requires admin role', async () => {
1309
1353
  // Create quote token
1310
1354
  const { token: quoteTokenAddress } = await actions.token.createSync(
1311
- client,
1355
+ clientWithAccount,
1312
1356
  {
1313
1357
  currency: 'USD',
1314
1358
  name: 'Quote Token 2',
@@ -1317,20 +1361,23 @@ describe('finalizeUpdateQuoteToken', () => {
1317
1361
  )
1318
1362
 
1319
1363
  // Create main token
1320
- const { token: address } = await actions.token.createSync(client, {
1321
- currency: 'USD',
1322
- name: 'Restricted Token',
1323
- symbol: 'RESTR',
1324
- })
1364
+ const { token: address } = await actions.token.createSync(
1365
+ clientWithAccount,
1366
+ {
1367
+ currency: 'USD',
1368
+ name: 'Restricted Token',
1369
+ symbol: 'RESTR',
1370
+ },
1371
+ )
1325
1372
 
1326
1373
  // Update quote token as admin
1327
- await actions.token.prepareUpdateQuoteTokenSync(client, {
1374
+ await actions.token.prepareUpdateQuoteTokenSync(clientWithAccount, {
1328
1375
  token: address,
1329
1376
  quoteToken: quoteTokenAddress,
1330
1377
  })
1331
1378
 
1332
1379
  // Transfer gas to account2
1333
- await writeContractSync(client, {
1380
+ await writeContractSync(clientWithAccount, {
1334
1381
  abi: Abis.tip20,
1335
1382
  address: addresses.alphaUsd,
1336
1383
  functionName: 'transfer',
@@ -1339,7 +1386,7 @@ describe('finalizeUpdateQuoteToken', () => {
1339
1386
 
1340
1387
  // Try to finalize as non-admin - should fail
1341
1388
  await expect(
1342
- actions.token.updateQuoteTokenSync(client, {
1389
+ actions.token.updateQuoteTokenSync(clientWithAccount, {
1343
1390
  account: account2,
1344
1391
  token: address,
1345
1392
  }),
@@ -1348,29 +1395,35 @@ describe('finalizeUpdateQuoteToken', () => {
1348
1395
 
1349
1396
  test('behavior: prevents circular references', async () => {
1350
1397
  // Create token B
1351
- const { token: tokenBAddress } = await actions.token.createSync(client, {
1352
- currency: 'USD',
1353
- name: 'Token B',
1354
- symbol: 'TKB',
1355
- })
1398
+ const { token: tokenBAddress } = await actions.token.createSync(
1399
+ clientWithAccount,
1400
+ {
1401
+ currency: 'USD',
1402
+ name: 'Token B',
1403
+ symbol: 'TKB',
1404
+ },
1405
+ )
1356
1406
 
1357
1407
  // Create token A that links to token B
1358
- const { token: tokenAAddress } = await actions.token.createSync(client, {
1359
- currency: 'USD',
1360
- name: 'Token A',
1361
- symbol: 'TKA',
1362
- quoteToken: tokenBAddress,
1363
- })
1408
+ const { token: tokenAAddress } = await actions.token.createSync(
1409
+ clientWithAccount,
1410
+ {
1411
+ currency: 'USD',
1412
+ name: 'Token A',
1413
+ symbol: 'TKA',
1414
+ quoteToken: tokenBAddress,
1415
+ },
1416
+ )
1364
1417
 
1365
1418
  // Try to make token B link to token A (would create A -> B -> A loop)
1366
- await actions.token.prepareUpdateQuoteTokenSync(client, {
1419
+ await actions.token.prepareUpdateQuoteTokenSync(clientWithAccount, {
1367
1420
  token: tokenBAddress,
1368
1421
  quoteToken: tokenAAddress,
1369
1422
  })
1370
1423
 
1371
1424
  // Finalize should fail due to circular reference detection
1372
1425
  await expect(
1373
- actions.token.updateQuoteTokenSync(client, {
1426
+ actions.token.updateQuoteTokenSync(clientWithAccount, {
1374
1427
  token: tokenBAddress,
1375
1428
  }),
1376
1429
  ).rejects.toThrow()
@@ -1382,51 +1435,60 @@ describe.todo('setTokenSupplyCap')
1382
1435
  describe('hasRole', () => {
1383
1436
  test('default', async () => {
1384
1437
  // Create a new token where we're the admin
1385
- const { token: address } = await actions.token.createSync(client, {
1386
- currency: 'USD',
1387
- name: 'HasRole Test Token',
1388
- symbol: 'HRTEST',
1389
- })
1438
+ const { token: address } = await actions.token.createSync(
1439
+ clientWithAccount,
1440
+ {
1441
+ currency: 'USD',
1442
+ name: 'HasRole Test Token',
1443
+ symbol: 'HRTEST',
1444
+ },
1445
+ )
1390
1446
 
1391
1447
  // Client account should have defaultAdmin role on the new token
1392
- const hasDefaultAdminRole = await actions.token.hasRole(client, {
1448
+ const hasDefaultAdminRole = await actions.token.hasRole(clientWithAccount, {
1393
1449
  token: address,
1394
1450
  role: 'defaultAdmin',
1395
1451
  })
1396
1452
  expect(hasDefaultAdminRole).toBe(true)
1397
1453
 
1398
1454
  // Client account should not have issuer role initially on the new token
1399
- const hasIssuerRole = await actions.token.hasRole(client, {
1455
+ const hasIssuerRole = await actions.token.hasRole(clientWithAccount, {
1400
1456
  token: address,
1401
1457
  role: 'issuer',
1402
1458
  })
1403
1459
  expect(hasIssuerRole).toBe(false)
1404
1460
 
1405
1461
  // Grant issuer role
1406
- await actions.token.grantRolesSync(client, {
1462
+ await actions.token.grantRolesSync(clientWithAccount, {
1407
1463
  token: address,
1408
1464
  roles: ['issuer'],
1409
- to: client.account.address,
1465
+ to: clientWithAccount.account.address,
1410
1466
  })
1411
1467
 
1412
1468
  // Now should have issuer role
1413
- const hasIssuerRoleAfterGrant = await actions.token.hasRole(client, {
1414
- token: address,
1415
- role: 'issuer',
1416
- })
1469
+ const hasIssuerRoleAfterGrant = await actions.token.hasRole(
1470
+ clientWithAccount,
1471
+ {
1472
+ token: address,
1473
+ role: 'issuer',
1474
+ },
1475
+ )
1417
1476
  expect(hasIssuerRoleAfterGrant).toBe(true)
1418
1477
  })
1419
1478
 
1420
1479
  test('behavior: check other account', async () => {
1421
1480
  // Create a new token
1422
- const { token: address } = await actions.token.createSync(client, {
1423
- currency: 'USD',
1424
- name: 'HasRole Other Account',
1425
- symbol: 'HROAC',
1426
- })
1481
+ const { token: address } = await actions.token.createSync(
1482
+ clientWithAccount,
1483
+ {
1484
+ currency: 'USD',
1485
+ name: 'HasRole Other Account',
1486
+ symbol: 'HROAC',
1487
+ },
1488
+ )
1427
1489
 
1428
1490
  // Account2 should not have issuer role
1429
- const hasIssuerBefore = await actions.token.hasRole(client, {
1491
+ const hasIssuerBefore = await actions.token.hasRole(clientWithAccount, {
1430
1492
  token: address,
1431
1493
  account: account2.address,
1432
1494
  role: 'issuer',
@@ -1434,14 +1496,14 @@ describe('hasRole', () => {
1434
1496
  expect(hasIssuerBefore).toBe(false)
1435
1497
 
1436
1498
  // Grant issuer role to account2
1437
- await actions.token.grantRolesSync(client, {
1499
+ await actions.token.grantRolesSync(clientWithAccount, {
1438
1500
  token: address,
1439
1501
  roles: ['issuer'],
1440
1502
  to: account2.address,
1441
1503
  })
1442
1504
 
1443
1505
  // Account2 should now have issuer role
1444
- const hasIssuerAfter = await actions.token.hasRole(client, {
1506
+ const hasIssuerAfter = await actions.token.hasRole(clientWithAccount, {
1445
1507
  token: address,
1446
1508
  account: account2.address,
1447
1509
  role: 'issuer',
@@ -1449,7 +1511,7 @@ describe('hasRole', () => {
1449
1511
  expect(hasIssuerAfter).toBe(true)
1450
1512
 
1451
1513
  // Account3 should still not have issuer role
1452
- const account3HasIssuer = await actions.token.hasRole(client, {
1514
+ const account3HasIssuer = await actions.token.hasRole(clientWithAccount, {
1453
1515
  token: address,
1454
1516
  account: account3.address,
1455
1517
  role: 'issuer',
@@ -1459,21 +1521,24 @@ describe('hasRole', () => {
1459
1521
 
1460
1522
  test('behavior: multiple roles', async () => {
1461
1523
  // Create a new token
1462
- const { token: address } = await actions.token.createSync(client, {
1463
- currency: 'USD',
1464
- name: 'HasRole Multiple',
1465
- symbol: 'HRMULTI',
1466
- })
1524
+ const { token: address } = await actions.token.createSync(
1525
+ clientWithAccount,
1526
+ {
1527
+ currency: 'USD',
1528
+ name: 'HasRole Multiple',
1529
+ symbol: 'HRMULTI',
1530
+ },
1531
+ )
1467
1532
 
1468
1533
  // Grant multiple roles to account2
1469
- await actions.token.grantRolesSync(client, {
1534
+ await actions.token.grantRolesSync(clientWithAccount, {
1470
1535
  token: address,
1471
1536
  roles: ['issuer', 'pause'],
1472
1537
  to: account2.address,
1473
1538
  })
1474
1539
 
1475
1540
  // Check issuer role
1476
- const hasIssuer = await actions.token.hasRole(client, {
1541
+ const hasIssuer = await actions.token.hasRole(clientWithAccount, {
1477
1542
  token: address,
1478
1543
  account: account2.address,
1479
1544
  role: 'issuer',
@@ -1481,7 +1546,7 @@ describe('hasRole', () => {
1481
1546
  expect(hasIssuer).toBe(true)
1482
1547
 
1483
1548
  // Check pause role
1484
- const hasPause = await actions.token.hasRole(client, {
1549
+ const hasPause = await actions.token.hasRole(clientWithAccount, {
1485
1550
  token: address,
1486
1551
  account: account2.address,
1487
1552
  role: 'pause',
@@ -1489,7 +1554,7 @@ describe('hasRole', () => {
1489
1554
  expect(hasPause).toBe(true)
1490
1555
 
1491
1556
  // Check unpause role (not granted)
1492
- const hasUnpause = await actions.token.hasRole(client, {
1557
+ const hasUnpause = await actions.token.hasRole(clientWithAccount, {
1493
1558
  token: address,
1494
1559
  account: account2.address,
1495
1560
  role: 'unpause',
@@ -1499,21 +1564,24 @@ describe('hasRole', () => {
1499
1564
 
1500
1565
  test('behavior: after revoke', async () => {
1501
1566
  // Create a new token
1502
- const { token: address } = await actions.token.createSync(client, {
1503
- currency: 'USD',
1504
- name: 'HasRole Revoke',
1505
- symbol: 'HRREV',
1506
- })
1567
+ const { token: address } = await actions.token.createSync(
1568
+ clientWithAccount,
1569
+ {
1570
+ currency: 'USD',
1571
+ name: 'HasRole Revoke',
1572
+ symbol: 'HRREV',
1573
+ },
1574
+ )
1507
1575
 
1508
1576
  // Grant issuer role to account2
1509
- await actions.token.grantRolesSync(client, {
1577
+ await actions.token.grantRolesSync(clientWithAccount, {
1510
1578
  token: address,
1511
1579
  roles: ['issuer'],
1512
1580
  to: account2.address,
1513
1581
  })
1514
1582
 
1515
1583
  // Verify has role
1516
- const hasRoleBefore = await actions.token.hasRole(client, {
1584
+ const hasRoleBefore = await actions.token.hasRole(clientWithAccount, {
1517
1585
  token: address,
1518
1586
  account: account2.address,
1519
1587
  role: 'issuer',
@@ -1521,14 +1589,14 @@ describe('hasRole', () => {
1521
1589
  expect(hasRoleBefore).toBe(true)
1522
1590
 
1523
1591
  // Revoke the role
1524
- await actions.token.revokeRolesSync(client, {
1592
+ await actions.token.revokeRolesSync(clientWithAccount, {
1525
1593
  token: address,
1526
1594
  roles: ['issuer'],
1527
1595
  from: account2.address,
1528
1596
  })
1529
1597
 
1530
1598
  // Verify no longer has role
1531
- const hasRoleAfter = await actions.token.hasRole(client, {
1599
+ const hasRoleAfter = await actions.token.hasRole(clientWithAccount, {
1532
1600
  token: address,
1533
1601
  account: account2.address,
1534
1602
  role: 'issuer',
@@ -1538,21 +1606,24 @@ describe('hasRole', () => {
1538
1606
 
1539
1607
  test('behavior: with token ID', async () => {
1540
1608
  // Create a new token
1541
- const { token: address, tokenId } = await actions.token.createSync(client, {
1542
- currency: 'USD',
1543
- name: 'HasRole Token ID',
1544
- symbol: 'HRTID',
1545
- })
1609
+ const { token: address, tokenId } = await actions.token.createSync(
1610
+ clientWithAccount,
1611
+ {
1612
+ currency: 'USD',
1613
+ name: 'HasRole Token ID',
1614
+ symbol: 'HRTID',
1615
+ },
1616
+ )
1546
1617
 
1547
1618
  // Grant issuer role
1548
- await actions.token.grantRolesSync(client, {
1619
+ await actions.token.grantRolesSync(clientWithAccount, {
1549
1620
  token: tokenId,
1550
1621
  roles: ['issuer'],
1551
1622
  to: account2.address,
1552
1623
  })
1553
1624
 
1554
1625
  // Check using token ID
1555
- const hasRole = await actions.token.hasRole(client, {
1626
+ const hasRole = await actions.token.hasRole(clientWithAccount, {
1556
1627
  token: tokenId,
1557
1628
  account: account2.address,
1558
1629
  role: 'issuer',
@@ -1560,7 +1631,7 @@ describe('hasRole', () => {
1560
1631
  expect(hasRole).toBe(true)
1561
1632
 
1562
1633
  // Verify same result with address
1563
- const hasRoleWithAddress = await actions.token.hasRole(client, {
1634
+ const hasRoleWithAddress = await actions.token.hasRole(clientWithAccount, {
1564
1635
  token: address,
1565
1636
  account: account2.address,
1566
1637
  role: 'issuer',
@@ -1572,23 +1643,29 @@ describe('hasRole', () => {
1572
1643
  describe('getRoleAdmin', () => {
1573
1644
  test('default', async () => {
1574
1645
  // Create a new token where we're the admin
1575
- const { token: address } = await actions.token.createSync(client, {
1576
- currency: 'USD',
1577
- name: 'GetRoleAdmin Test Token',
1578
- symbol: 'GRATEST',
1579
- })
1646
+ const { token: address } = await actions.token.createSync(
1647
+ clientWithAccount,
1648
+ {
1649
+ currency: 'USD',
1650
+ name: 'GetRoleAdmin Test Token',
1651
+ symbol: 'GRATEST',
1652
+ },
1653
+ )
1580
1654
 
1581
1655
  // Get admin role for issuer role (should be defaultAdmin)
1582
- const issuerAdminRole = await actions.token.getRoleAdmin(client, {
1583
- token: address,
1584
- role: 'issuer',
1585
- })
1656
+ const issuerAdminRole = await actions.token.getRoleAdmin(
1657
+ clientWithAccount,
1658
+ {
1659
+ token: address,
1660
+ role: 'issuer',
1661
+ },
1662
+ )
1586
1663
  expect(issuerAdminRole).toBe(
1587
1664
  '0x0000000000000000000000000000000000000000000000000000000000000000',
1588
1665
  )
1589
1666
 
1590
1667
  // Get admin role for pause role (should be defaultAdmin)
1591
- const pauseAdminRole = await actions.token.getRoleAdmin(client, {
1668
+ const pauseAdminRole = await actions.token.getRoleAdmin(clientWithAccount, {
1592
1669
  token: address,
1593
1670
  role: 'pause',
1594
1671
  })
@@ -1597,10 +1674,13 @@ describe('getRoleAdmin', () => {
1597
1674
  )
1598
1675
 
1599
1676
  // Get admin role for unpause role (should be defaultAdmin)
1600
- const unpauseAdminRole = await actions.token.getRoleAdmin(client, {
1601
- token: address,
1602
- role: 'unpause',
1603
- })
1677
+ const unpauseAdminRole = await actions.token.getRoleAdmin(
1678
+ clientWithAccount,
1679
+ {
1680
+ token: address,
1681
+ role: 'unpause',
1682
+ },
1683
+ )
1604
1684
  expect(unpauseAdminRole).toBe(
1605
1685
  '0x0000000000000000000000000000000000000000000000000000000000000000',
1606
1686
  )
@@ -1608,74 +1688,98 @@ describe('getRoleAdmin', () => {
1608
1688
 
1609
1689
  test('behavior: after setting role admin', async () => {
1610
1690
  // Create a new token
1611
- const { token: address } = await actions.token.createSync(client, {
1612
- currency: 'USD',
1613
- name: 'GetRoleAdmin After Set',
1614
- symbol: 'GRASET',
1615
- })
1691
+ const { token: address } = await actions.token.createSync(
1692
+ clientWithAccount,
1693
+ {
1694
+ currency: 'USD',
1695
+ name: 'GetRoleAdmin After Set',
1696
+ symbol: 'GRASET',
1697
+ },
1698
+ )
1616
1699
 
1617
1700
  // Get initial admin role for issuer
1618
- const initialAdminRole = await actions.token.getRoleAdmin(client, {
1619
- token: address,
1620
- role: 'issuer',
1621
- })
1701
+ const initialAdminRole = await actions.token.getRoleAdmin(
1702
+ clientWithAccount,
1703
+ {
1704
+ token: address,
1705
+ role: 'issuer',
1706
+ },
1707
+ )
1622
1708
  expect(initialAdminRole).toBe(
1623
1709
  '0x0000000000000000000000000000000000000000000000000000000000000000',
1624
1710
  )
1625
1711
 
1626
1712
  // Set pause as admin role for issuer
1627
- await actions.token.setRoleAdminSync(client, {
1713
+ await actions.token.setRoleAdminSync(clientWithAccount, {
1628
1714
  token: address,
1629
1715
  role: 'issuer',
1630
1716
  adminRole: 'pause',
1631
1717
  })
1632
1718
 
1633
1719
  // Get updated admin role for issuer
1634
- const updatedAdminRole = await actions.token.getRoleAdmin(client, {
1635
- token: address,
1636
- role: 'issuer',
1637
- })
1720
+ const updatedAdminRole = await actions.token.getRoleAdmin(
1721
+ clientWithAccount,
1722
+ {
1723
+ token: address,
1724
+ role: 'issuer',
1725
+ },
1726
+ )
1638
1727
  expect(updatedAdminRole).toBe(TokenRole.serialize('pause'))
1639
1728
  })
1640
1729
 
1641
1730
  test('behavior: with token ID', async () => {
1642
1731
  // Create a new token
1643
- const { token: address, tokenId } = await actions.token.createSync(client, {
1644
- currency: 'USD',
1645
- name: 'GetRoleAdmin Token ID',
1646
- symbol: 'GRATID',
1647
- })
1732
+ const { token: address, tokenId } = await actions.token.createSync(
1733
+ clientWithAccount,
1734
+ {
1735
+ currency: 'USD',
1736
+ name: 'GetRoleAdmin Token ID',
1737
+ symbol: 'GRATID',
1738
+ },
1739
+ )
1648
1740
 
1649
1741
  // Get admin role using token ID
1650
- const adminRoleWithId = await actions.token.getRoleAdmin(client, {
1651
- token: tokenId,
1652
- role: 'issuer',
1653
- })
1742
+ const adminRoleWithId = await actions.token.getRoleAdmin(
1743
+ clientWithAccount,
1744
+ {
1745
+ token: tokenId,
1746
+ role: 'issuer',
1747
+ },
1748
+ )
1654
1749
  expect(adminRoleWithId).toBe(
1655
1750
  '0x0000000000000000000000000000000000000000000000000000000000000000',
1656
1751
  )
1657
1752
 
1658
1753
  // Get admin role using address
1659
- const adminRoleWithAddress = await actions.token.getRoleAdmin(client, {
1660
- token: address,
1661
- role: 'issuer',
1662
- })
1754
+ const adminRoleWithAddress = await actions.token.getRoleAdmin(
1755
+ clientWithAccount,
1756
+ {
1757
+ token: address,
1758
+ role: 'issuer',
1759
+ },
1760
+ )
1663
1761
  expect(adminRoleWithAddress).toBe(adminRoleWithId)
1664
1762
  })
1665
1763
 
1666
1764
  test('behavior: defaultAdmin role admin', async () => {
1667
1765
  // Create a new token
1668
- const { token: address } = await actions.token.createSync(client, {
1669
- currency: 'USD',
1670
- name: 'GetRoleAdmin DefaultAdmin',
1671
- symbol: 'GRADMIN',
1672
- })
1766
+ const { token: address } = await actions.token.createSync(
1767
+ clientWithAccount,
1768
+ {
1769
+ currency: 'USD',
1770
+ name: 'GetRoleAdmin DefaultAdmin',
1771
+ symbol: 'GRADMIN',
1772
+ },
1773
+ )
1673
1774
 
1674
1775
  // Get admin role for defaultAdmin role (should be itself - 0x00)
1675
- const defaultAdminAdminRole = await actions.token.getRoleAdmin(client, {
1676
- token: address,
1677
- role: 'defaultAdmin',
1678
- })
1776
+ const defaultAdminAdminRole = await actions.token.getRoleAdmin(
1777
+ clientWithAccount,
1778
+ {
1779
+ token: address,
1780
+ role: 'defaultAdmin',
1781
+ },
1782
+ )
1679
1783
  expect(defaultAdminAdminRole).toBe(
1680
1784
  '0x0000000000000000000000000000000000000000000000000000000000000000',
1681
1785
  )
@@ -1685,16 +1789,19 @@ describe('getRoleAdmin', () => {
1685
1789
  describe('grantRoles', () => {
1686
1790
  test('default', async () => {
1687
1791
  // Create a new token where we're the admin
1688
- const { token: address } = await actions.token.createSync(client, {
1689
- admin: client.account,
1690
- currency: 'USD',
1691
- name: 'Test Token',
1692
- symbol: 'TEST',
1693
- })
1792
+ const { token: address } = await actions.token.createSync(
1793
+ clientWithAccount,
1794
+ {
1795
+ admin: clientWithAccount.account,
1796
+ currency: 'USD',
1797
+ name: 'Test Token',
1798
+ symbol: 'TEST',
1799
+ },
1800
+ )
1694
1801
 
1695
1802
  // Grant issuer role to account2
1696
1803
  const { receipt: grantReceipt, value: grantValue } =
1697
- await actions.token.grantRolesSync(client, {
1804
+ await actions.token.grantRolesSync(clientWithAccount, {
1698
1805
  token: address,
1699
1806
  roles: ['issuer'],
1700
1807
  to: account2.address,
@@ -1716,21 +1823,24 @@ describe('grantRoles', () => {
1716
1823
 
1717
1824
  describe('revokeTokenRole', async () => {
1718
1825
  test('default', async () => {
1719
- const { token: address } = await actions.token.createSync(client, {
1720
- admin: client.account,
1721
- currency: 'USD',
1722
- name: 'Test Token 2',
1723
- symbol: 'TEST2',
1724
- })
1826
+ const { token: address } = await actions.token.createSync(
1827
+ clientWithAccount,
1828
+ {
1829
+ admin: clientWithAccount.account,
1830
+ currency: 'USD',
1831
+ name: 'Test Token 2',
1832
+ symbol: 'TEST2',
1833
+ },
1834
+ )
1725
1835
 
1726
- await actions.token.grantRolesSync(client, {
1836
+ await actions.token.grantRolesSync(clientWithAccount, {
1727
1837
  token: address,
1728
1838
  roles: ['issuer'],
1729
1839
  to: account2.address,
1730
1840
  })
1731
1841
 
1732
1842
  const { receipt: revokeReceipt, value: revokeValue } =
1733
- await actions.token.revokeRolesSync(client, {
1843
+ await actions.token.revokeRolesSync(clientWithAccount, {
1734
1844
  from: account2.address,
1735
1845
  token: address,
1736
1846
  roles: ['issuer'],
@@ -1752,25 +1862,28 @@ describe('revokeTokenRole', async () => {
1752
1862
 
1753
1863
  describe('renounceTokenRole', async () => {
1754
1864
  test('default', async () => {
1755
- const { token: address } = await actions.token.createSync(client, {
1756
- admin: client.account,
1757
- currency: 'USD',
1758
- name: 'Test Token 3',
1759
- symbol: 'TEST3',
1760
- })
1865
+ const { token: address } = await actions.token.createSync(
1866
+ clientWithAccount,
1867
+ {
1868
+ admin: clientWithAccount.account,
1869
+ currency: 'USD',
1870
+ name: 'Test Token 3',
1871
+ symbol: 'TEST3',
1872
+ },
1873
+ )
1761
1874
 
1762
1875
  const { receipt: grantReceipt } = await actions.token.grantRolesSync(
1763
- client,
1876
+ clientWithAccount,
1764
1877
  {
1765
1878
  token: address,
1766
1879
  roles: ['issuer'],
1767
- to: client.account.address,
1880
+ to: clientWithAccount.account.address,
1768
1881
  },
1769
1882
  )
1770
1883
  expect(grantReceipt.status).toBe('success')
1771
1884
 
1772
1885
  const { receipt: renounceReceipt, value: renounceValue } =
1773
- await actions.token.renounceRolesSync(client, {
1886
+ await actions.token.renounceRolesSync(clientWithAccount, {
1774
1887
  token: address,
1775
1888
  roles: ['issuer'],
1776
1889
  })
@@ -1798,20 +1911,20 @@ describe('watchCreate', () => {
1798
1911
  log: actions.token.watchCreate.Log
1799
1912
  }> = []
1800
1913
 
1801
- const unwatch = actions.token.watchCreate(client, {
1914
+ const unwatch = actions.token.watchCreate(clientWithAccount, {
1802
1915
  onTokenCreated: (args, log) => {
1803
1916
  receivedTokens.push({ args, log })
1804
1917
  },
1805
1918
  })
1806
1919
 
1807
1920
  try {
1808
- await actions.token.createSync(client, {
1921
+ await actions.token.createSync(clientWithAccount, {
1809
1922
  currency: 'USD',
1810
1923
  name: 'Watch Test Token 1',
1811
1924
  symbol: 'WATCH1',
1812
1925
  })
1813
1926
 
1814
- await actions.token.createSync(client, {
1927
+ await actions.token.createSync(clientWithAccount, {
1815
1928
  currency: 'USD',
1816
1929
  name: 'Watch Test Token 2',
1817
1930
  symbol: 'WATCH2',
@@ -1862,11 +1975,14 @@ describe('watchCreate', () => {
1862
1975
 
1863
1976
  test('behavior: filter by tokenId', async () => {
1864
1977
  // First, create a token to know what ID we're at
1865
- const { tokenId: firstId } = await actions.token.createSync(client, {
1866
- currency: 'USD',
1867
- name: 'Setup Token',
1868
- symbol: 'SETUP',
1869
- })
1978
+ const { tokenId: firstId } = await actions.token.createSync(
1979
+ clientWithAccount,
1980
+ {
1981
+ currency: 'USD',
1982
+ name: 'Setup Token',
1983
+ symbol: 'SETUP',
1984
+ },
1985
+ )
1870
1986
 
1871
1987
  // We want to watch for the token with ID = firstId + 2
1872
1988
  const targetTokenId = firstId + 2n
@@ -1877,7 +1993,7 @@ describe('watchCreate', () => {
1877
1993
  }> = []
1878
1994
 
1879
1995
  // Start watching for token creation events only for targetTokenId
1880
- const unwatch = actions.token.watchCreate(client, {
1996
+ const unwatch = actions.token.watchCreate(clientWithAccount, {
1881
1997
  args: {
1882
1998
  tokenId: targetTokenId,
1883
1999
  },
@@ -1888,21 +2004,24 @@ describe('watchCreate', () => {
1888
2004
 
1889
2005
  try {
1890
2006
  // Create first token (should NOT be captured - ID will be firstId + 1)
1891
- await actions.token.createSync(client, {
2007
+ await actions.token.createSync(clientWithAccount, {
1892
2008
  currency: 'USD',
1893
2009
  name: 'Filtered Watch Token 1',
1894
2010
  symbol: 'FWATCH1',
1895
2011
  })
1896
2012
 
1897
2013
  // Create second token (should be captured - ID will be firstId + 2 = targetTokenId)
1898
- const { tokenId: id2 } = await actions.token.createSync(client, {
1899
- currency: 'USD',
1900
- name: 'Filtered Watch Token 2',
1901
- symbol: 'FWATCH2',
1902
- })
2014
+ const { tokenId: id2 } = await actions.token.createSync(
2015
+ clientWithAccount,
2016
+ {
2017
+ currency: 'USD',
2018
+ name: 'Filtered Watch Token 2',
2019
+ symbol: 'FWATCH2',
2020
+ },
2021
+ )
1903
2022
 
1904
2023
  // Create third token (should NOT be captured - ID will be firstId + 3)
1905
- await actions.token.createSync(client, {
2024
+ await actions.token.createSync(clientWithAccount, {
1906
2025
  currency: 'USD',
1907
2026
  name: 'Filtered Watch Token 3',
1908
2027
  symbol: 'FWATCH3',
@@ -1937,17 +2056,20 @@ describe('watchCreate', () => {
1937
2056
  describe('watchMint', () => {
1938
2057
  test('default', async () => {
1939
2058
  // Create a new token for testing
1940
- const { token: address } = await actions.token.createSync(client, {
1941
- currency: 'USD',
1942
- name: 'Mint Watch Token',
1943
- symbol: 'MINT',
1944
- })
2059
+ const { token: address } = await actions.token.createSync(
2060
+ clientWithAccount,
2061
+ {
2062
+ currency: 'USD',
2063
+ name: 'Mint Watch Token',
2064
+ symbol: 'MINT',
2065
+ },
2066
+ )
1945
2067
 
1946
2068
  // Grant issuer role
1947
- await actions.token.grantRolesSync(client, {
2069
+ await actions.token.grantRolesSync(clientWithAccount, {
1948
2070
  token: address,
1949
2071
  roles: ['issuer'],
1950
- to: client.account.address,
2072
+ to: clientWithAccount.account.address,
1951
2073
  })
1952
2074
 
1953
2075
  const receivedMints: Array<{
@@ -1956,7 +2078,7 @@ describe('watchMint', () => {
1956
2078
  }> = []
1957
2079
 
1958
2080
  // Start watching for mint events
1959
- const unwatch = actions.token.watchMint(client, {
2081
+ const unwatch = actions.token.watchMint(clientWithAccount, {
1960
2082
  token: address,
1961
2083
  onMint: (args, log) => {
1962
2084
  receivedMints.push({ args, log })
@@ -1965,14 +2087,14 @@ describe('watchMint', () => {
1965
2087
 
1966
2088
  try {
1967
2089
  // Mint first batch
1968
- await actions.token.mintSync(client, {
2090
+ await actions.token.mintSync(clientWithAccount, {
1969
2091
  token: address,
1970
2092
  to: account2.address,
1971
2093
  amount: parseUnits('100', 6),
1972
2094
  })
1973
2095
 
1974
2096
  // Mint second batch
1975
- await actions.token.mintSync(client, {
2097
+ await actions.token.mintSync(clientWithAccount, {
1976
2098
  token: address,
1977
2099
  to: account3.address,
1978
2100
  amount: parseUnits('50', 6),
@@ -2001,17 +2123,20 @@ describe('watchMint', () => {
2001
2123
 
2002
2124
  test('behavior: filter by to address', async () => {
2003
2125
  // Create a new token for testing
2004
- const { token: address } = await actions.token.createSync(client, {
2005
- currency: 'USD',
2006
- name: 'Filtered Mint Token',
2007
- symbol: 'FMINT',
2008
- })
2126
+ const { token: address } = await actions.token.createSync(
2127
+ clientWithAccount,
2128
+ {
2129
+ currency: 'USD',
2130
+ name: 'Filtered Mint Token',
2131
+ symbol: 'FMINT',
2132
+ },
2133
+ )
2009
2134
 
2010
2135
  // Grant issuer role
2011
- await actions.token.grantRolesSync(client, {
2136
+ await actions.token.grantRolesSync(clientWithAccount, {
2012
2137
  token: address,
2013
2138
  roles: ['issuer'],
2014
- to: client.account.address,
2139
+ to: clientWithAccount.account.address,
2015
2140
  })
2016
2141
 
2017
2142
  const receivedMints: Array<{
@@ -2020,7 +2145,7 @@ describe('watchMint', () => {
2020
2145
  }> = []
2021
2146
 
2022
2147
  // Start watching for mint events only to account2
2023
- const unwatch = actions.token.watchMint(client, {
2148
+ const unwatch = actions.token.watchMint(clientWithAccount, {
2024
2149
  token: address,
2025
2150
  args: {
2026
2151
  to: account2.address,
@@ -2032,21 +2157,21 @@ describe('watchMint', () => {
2032
2157
 
2033
2158
  try {
2034
2159
  // Mint to account2 (should be captured)
2035
- await actions.token.mintSync(client, {
2160
+ await actions.token.mintSync(clientWithAccount, {
2036
2161
  token: address,
2037
2162
  to: account2.address,
2038
2163
  amount: parseUnits('100', 6),
2039
2164
  })
2040
2165
 
2041
2166
  // Mint to account3 (should NOT be captured)
2042
- await actions.token.mintSync(client, {
2167
+ await actions.token.mintSync(clientWithAccount, {
2043
2168
  token: address,
2044
2169
  to: account3.address,
2045
2170
  amount: parseUnits('50', 6),
2046
2171
  })
2047
2172
 
2048
2173
  // Mint to account2 again (should be captured)
2049
- await actions.token.mintSync(client, {
2174
+ await actions.token.mintSync(clientWithAccount, {
2050
2175
  token: address,
2051
2176
  to: account2.address,
2052
2177
  amount: parseUnits('75', 6),
@@ -2083,11 +2208,14 @@ describe('watchMint', () => {
2083
2208
  describe('watchApprove', () => {
2084
2209
  test('default', async () => {
2085
2210
  // Create a new token for testing
2086
- const { token: address } = await actions.token.createSync(client, {
2087
- currency: 'USD',
2088
- name: 'Approval Watch Token',
2089
- symbol: 'APPR',
2090
- })
2211
+ const { token: address } = await actions.token.createSync(
2212
+ clientWithAccount,
2213
+ {
2214
+ currency: 'USD',
2215
+ name: 'Approval Watch Token',
2216
+ symbol: 'APPR',
2217
+ },
2218
+ )
2091
2219
 
2092
2220
  const receivedApprovals: Array<{
2093
2221
  args: actions.token.watchApprove.Args
@@ -2095,7 +2223,7 @@ describe('watchApprove', () => {
2095
2223
  }> = []
2096
2224
 
2097
2225
  // Start watching for approval events
2098
- const unwatch = actions.token.watchApprove(client, {
2226
+ const unwatch = actions.token.watchApprove(clientWithAccount, {
2099
2227
  token: address,
2100
2228
  onApproval: (args, log) => {
2101
2229
  receivedApprovals.push({ args, log })
@@ -2104,14 +2232,14 @@ describe('watchApprove', () => {
2104
2232
 
2105
2233
  try {
2106
2234
  // Approve account2
2107
- await actions.token.approveSync(client, {
2235
+ await actions.token.approveSync(clientWithAccount, {
2108
2236
  token: address,
2109
2237
  spender: account2.address,
2110
2238
  amount: parseUnits('100', 6),
2111
2239
  })
2112
2240
 
2113
2241
  // Approve account3
2114
- await actions.token.approveSync(client, {
2242
+ await actions.token.approveSync(clientWithAccount, {
2115
2243
  token: address,
2116
2244
  spender: account3.address,
2117
2245
  amount: parseUnits('50', 6),
@@ -2142,11 +2270,14 @@ describe('watchApprove', () => {
2142
2270
 
2143
2271
  test('behavior: filter by spender address', async () => {
2144
2272
  // Create a new token for testing
2145
- const { token: address } = await actions.token.createSync(client, {
2146
- currency: 'USD',
2147
- name: 'Filtered Approval Token',
2148
- symbol: 'FAPPR',
2149
- })
2273
+ const { token: address } = await actions.token.createSync(
2274
+ clientWithAccount,
2275
+ {
2276
+ currency: 'USD',
2277
+ name: 'Filtered Approval Token',
2278
+ symbol: 'FAPPR',
2279
+ },
2280
+ )
2150
2281
 
2151
2282
  const receivedApprovals: Array<{
2152
2283
  args: actions.token.watchApprove.Args
@@ -2154,7 +2285,7 @@ describe('watchApprove', () => {
2154
2285
  }> = []
2155
2286
 
2156
2287
  // Start watching for approval events only to account2
2157
- const unwatch = actions.token.watchApprove(client, {
2288
+ const unwatch = actions.token.watchApprove(clientWithAccount, {
2158
2289
  token: address,
2159
2290
  args: {
2160
2291
  spender: account2.address,
@@ -2166,21 +2297,21 @@ describe('watchApprove', () => {
2166
2297
 
2167
2298
  try {
2168
2299
  // Approve account2 (should be captured)
2169
- await actions.token.approveSync(client, {
2300
+ await actions.token.approveSync(clientWithAccount, {
2170
2301
  token: address,
2171
2302
  spender: account2.address,
2172
2303
  amount: parseUnits('100', 6),
2173
2304
  })
2174
2305
 
2175
2306
  // Approve account3 (should NOT be captured)
2176
- await actions.token.approveSync(client, {
2307
+ await actions.token.approveSync(clientWithAccount, {
2177
2308
  token: address,
2178
2309
  spender: account3.address,
2179
2310
  amount: parseUnits('50', 6),
2180
2311
  })
2181
2312
 
2182
2313
  // Approve account2 again (should be captured)
2183
- await actions.token.approveSync(client, {
2314
+ await actions.token.approveSync(clientWithAccount, {
2184
2315
  token: address,
2185
2316
  spender: account2.address,
2186
2317
  amount: parseUnits('75', 6),
@@ -2219,34 +2350,37 @@ describe('watchApprove', () => {
2219
2350
  describe('watchBurn', () => {
2220
2351
  test('default', async () => {
2221
2352
  // Create a new token for testing
2222
- const { token: address } = await actions.token.createSync(client, {
2223
- currency: 'USD',
2224
- name: 'Burn Watch Token',
2225
- symbol: 'BURN',
2226
- })
2353
+ const { token: address } = await actions.token.createSync(
2354
+ clientWithAccount,
2355
+ {
2356
+ currency: 'USD',
2357
+ name: 'Burn Watch Token',
2358
+ symbol: 'BURN',
2359
+ },
2360
+ )
2227
2361
 
2228
2362
  // Grant issuer role to mint/burn tokens
2229
- await actions.token.grantRolesSync(client, {
2363
+ await actions.token.grantRolesSync(clientWithAccount, {
2230
2364
  token: address,
2231
2365
  roles: ['issuer'],
2232
- to: client.account.address,
2366
+ to: clientWithAccount.account.address,
2233
2367
  })
2234
2368
 
2235
2369
  // Grant issuer role to mint/burn tokens
2236
- await actions.token.grantRolesSync(client, {
2370
+ await actions.token.grantRolesSync(clientWithAccount, {
2237
2371
  token: address,
2238
2372
  roles: ['issuer'],
2239
2373
  to: account2.address,
2240
2374
  })
2241
2375
 
2242
2376
  // Mint tokens to burn later
2243
- await actions.token.mintSync(client, {
2377
+ await actions.token.mintSync(clientWithAccount, {
2244
2378
  token: address,
2245
- to: client.account.address,
2379
+ to: clientWithAccount.account.address,
2246
2380
  amount: parseUnits('200', 6),
2247
2381
  })
2248
2382
 
2249
- await actions.token.mintSync(client, {
2383
+ await actions.token.mintSync(clientWithAccount, {
2250
2384
  token: address,
2251
2385
  to: account2.address,
2252
2386
  amount: parseUnits('100', 6),
@@ -2258,7 +2392,7 @@ describe('watchBurn', () => {
2258
2392
  }> = []
2259
2393
 
2260
2394
  // Start watching for burn events
2261
- const unwatch = actions.token.watchBurn(client, {
2395
+ const unwatch = actions.token.watchBurn(clientWithAccount, {
2262
2396
  token: address,
2263
2397
  onBurn: (args, log) => {
2264
2398
  receivedBurns.push({ args, log })
@@ -2267,13 +2401,13 @@ describe('watchBurn', () => {
2267
2401
 
2268
2402
  try {
2269
2403
  // Burn first batch
2270
- await actions.token.burnSync(client, {
2404
+ await actions.token.burnSync(clientWithAccount, {
2271
2405
  token: address,
2272
2406
  amount: parseUnits('50', 6),
2273
2407
  })
2274
2408
 
2275
2409
  // Transfer gas to account2
2276
- await writeContractSync(client, {
2410
+ await writeContractSync(clientWithAccount, {
2277
2411
  abi: Abis.tip20,
2278
2412
  address: addresses.alphaUsd,
2279
2413
  functionName: 'transfer',
@@ -2281,7 +2415,7 @@ describe('watchBurn', () => {
2281
2415
  })
2282
2416
 
2283
2417
  // Burn second batch from account2
2284
- await actions.token.burnSync(client, {
2418
+ await actions.token.burnSync(clientWithAccount, {
2285
2419
  account: account2,
2286
2420
  token: address,
2287
2421
  amount: parseUnits('25', 6),
@@ -2310,34 +2444,37 @@ describe('watchBurn', () => {
2310
2444
 
2311
2445
  test('behavior: filter by from address', async () => {
2312
2446
  // Create a new token for testing
2313
- const { token: address } = await actions.token.createSync(client, {
2314
- currency: 'USD',
2315
- name: 'Filtered Burn Token',
2316
- symbol: 'FBURN',
2317
- })
2447
+ const { token: address } = await actions.token.createSync(
2448
+ clientWithAccount,
2449
+ {
2450
+ currency: 'USD',
2451
+ name: 'Filtered Burn Token',
2452
+ symbol: 'FBURN',
2453
+ },
2454
+ )
2318
2455
 
2319
2456
  // Grant issuer role
2320
- await actions.token.grantRolesSync(client, {
2457
+ await actions.token.grantRolesSync(clientWithAccount, {
2321
2458
  token: address,
2322
2459
  roles: ['issuer'],
2323
- to: client.account.address,
2460
+ to: clientWithAccount.account.address,
2324
2461
  })
2325
2462
 
2326
2463
  // Grant issuer role
2327
- await actions.token.grantRolesSync(client, {
2464
+ await actions.token.grantRolesSync(clientWithAccount, {
2328
2465
  token: address,
2329
2466
  roles: ['issuer'],
2330
2467
  to: account2.address,
2331
2468
  })
2332
2469
 
2333
2470
  // Mint tokens to multiple accounts
2334
- await actions.token.mintSync(client, {
2471
+ await actions.token.mintSync(clientWithAccount, {
2335
2472
  token: address,
2336
- to: client.account.address,
2473
+ to: clientWithAccount.account.address,
2337
2474
  amount: parseUnits('200', 6),
2338
2475
  })
2339
2476
 
2340
- await actions.token.mintSync(client, {
2477
+ await actions.token.mintSync(clientWithAccount, {
2341
2478
  token: address,
2342
2479
  to: account2.address,
2343
2480
  amount: parseUnits('200', 6),
@@ -2348,11 +2485,11 @@ describe('watchBurn', () => {
2348
2485
  log: actions.token.watchBurn.Log
2349
2486
  }> = []
2350
2487
 
2351
- // Start watching for burn events only from client.account
2352
- const unwatch = actions.token.watchBurn(client, {
2488
+ // Start watching for burn events only from clientWithAccount.account
2489
+ const unwatch = actions.token.watchBurn(clientWithAccount, {
2353
2490
  token: address,
2354
2491
  args: {
2355
- from: client.account.address,
2492
+ from: clientWithAccount.account.address,
2356
2493
  },
2357
2494
  onBurn: (args, log) => {
2358
2495
  receivedBurns.push({ args, log })
@@ -2360,14 +2497,14 @@ describe('watchBurn', () => {
2360
2497
  })
2361
2498
 
2362
2499
  try {
2363
- // Burn from client.account (should be captured)
2364
- await actions.token.burnSync(client, {
2500
+ // Burn from clientWithAccount.account (should be captured)
2501
+ await actions.token.burnSync(clientWithAccount, {
2365
2502
  token: address,
2366
2503
  amount: parseUnits('50', 6),
2367
2504
  })
2368
2505
 
2369
2506
  // Transfer gas to account2
2370
- await writeContractSync(client, {
2507
+ await writeContractSync(clientWithAccount, {
2371
2508
  abi: Abis.tip20,
2372
2509
  address: addresses.alphaUsd,
2373
2510
  functionName: 'transfer',
@@ -2375,21 +2512,21 @@ describe('watchBurn', () => {
2375
2512
  })
2376
2513
 
2377
2514
  // Burn from account2 (should NOT be captured)
2378
- await actions.token.burnSync(client, {
2515
+ await actions.token.burnSync(clientWithAccount, {
2379
2516
  account: account2,
2380
2517
  token: address,
2381
2518
  amount: parseUnits('25', 6),
2382
2519
  })
2383
2520
 
2384
- // Burn from client.account again (should be captured)
2385
- await actions.token.burnSync(client, {
2521
+ // Burn from clientWithAccount.account again (should be captured)
2522
+ await actions.token.burnSync(clientWithAccount, {
2386
2523
  token: address,
2387
2524
  amount: parseUnits('75', 6),
2388
2525
  })
2389
2526
 
2390
2527
  await setTimeout(100)
2391
2528
 
2392
- // Should only receive 2 events (from client.account)
2529
+ // Should only receive 2 events (from clientWithAccount.account)
2393
2530
  expect(receivedBurns).toHaveLength(2)
2394
2531
 
2395
2532
  expect(receivedBurns.at(0)!.args).toMatchInlineSnapshot(`
@@ -2405,9 +2542,9 @@ describe('watchBurn', () => {
2405
2542
  }
2406
2543
  `)
2407
2544
 
2408
- // Verify all received burns are from client.account
2545
+ // Verify all received burns are from clientWithAccount.account
2409
2546
  for (const burn of receivedBurns) {
2410
- expect(burn.args.from).toBe(client.account.address)
2547
+ expect(burn.args.from).toBe(clientWithAccount.account.address)
2411
2548
  }
2412
2549
  } finally {
2413
2550
  if (unwatch) unwatch()
@@ -2418,11 +2555,14 @@ describe('watchBurn', () => {
2418
2555
  describe('watchAdminRole', () => {
2419
2556
  test('default', async () => {
2420
2557
  // Create a new token for testing
2421
- const { token: address } = await actions.token.createSync(client, {
2422
- currency: 'USD',
2423
- name: 'Admin Role Watch Token',
2424
- symbol: 'ADMIN',
2425
- })
2558
+ const { token: address } = await actions.token.createSync(
2559
+ clientWithAccount,
2560
+ {
2561
+ currency: 'USD',
2562
+ name: 'Admin Role Watch Token',
2563
+ symbol: 'ADMIN',
2564
+ },
2565
+ )
2426
2566
 
2427
2567
  const receivedAdminUpdates: Array<{
2428
2568
  args: actions.token.watchAdminRole.Args
@@ -2430,7 +2570,7 @@ describe('watchAdminRole', () => {
2430
2570
  }> = []
2431
2571
 
2432
2572
  // Start watching for role admin updates
2433
- const unwatch = actions.token.watchAdminRole(client, {
2573
+ const unwatch = actions.token.watchAdminRole(clientWithAccount, {
2434
2574
  token: address,
2435
2575
  onRoleAdminUpdated: (args, log) => {
2436
2576
  receivedAdminUpdates.push({ args, log })
@@ -2444,7 +2584,7 @@ describe('watchAdminRole', () => {
2444
2584
  role,
2445
2585
  newAdminRole,
2446
2586
  ...setRoleAdmin1Result
2447
- } = await actions.token.setRoleAdminSync(client, {
2587
+ } = await actions.token.setRoleAdminSync(clientWithAccount, {
2448
2588
  token: address,
2449
2589
  role: 'issuer',
2450
2590
  adminRole: 'pause',
@@ -2459,7 +2599,7 @@ describe('watchAdminRole', () => {
2459
2599
  expect(newAdminRole).toBeDefined()
2460
2600
 
2461
2601
  // Set role admin for pause role
2462
- await actions.token.setRoleAdminSync(client, {
2602
+ await actions.token.setRoleAdminSync(clientWithAccount, {
2463
2603
  token: address,
2464
2604
  role: 'pause',
2465
2605
  adminRole: 'unpause',
@@ -2470,10 +2610,10 @@ describe('watchAdminRole', () => {
2470
2610
  expect(receivedAdminUpdates).toHaveLength(2)
2471
2611
 
2472
2612
  expect(receivedAdminUpdates.at(0)!.args.sender).toBe(
2473
- client.account.address,
2613
+ clientWithAccount.account.address,
2474
2614
  )
2475
2615
  expect(receivedAdminUpdates.at(1)!.args.sender).toBe(
2476
- client.account.address,
2616
+ clientWithAccount.account.address,
2477
2617
  )
2478
2618
  } finally {
2479
2619
  if (unwatch) unwatch()
@@ -2484,11 +2624,14 @@ describe('watchAdminRole', () => {
2484
2624
  describe('watchRole', () => {
2485
2625
  test('default', async () => {
2486
2626
  // Create a new token for testing
2487
- const { token: address } = await actions.token.createSync(client, {
2488
- currency: 'USD',
2489
- name: 'Role Watch Token',
2490
- symbol: 'ROLE',
2491
- })
2627
+ const { token: address } = await actions.token.createSync(
2628
+ clientWithAccount,
2629
+ {
2630
+ currency: 'USD',
2631
+ name: 'Role Watch Token',
2632
+ symbol: 'ROLE',
2633
+ },
2634
+ )
2492
2635
 
2493
2636
  const receivedRoleUpdates: Array<{
2494
2637
  args: actions.token.watchRole.Args
@@ -2496,7 +2639,7 @@ describe('watchRole', () => {
2496
2639
  }> = []
2497
2640
 
2498
2641
  // Start watching for role membership updates
2499
- const unwatch = actions.token.watchRole(client, {
2642
+ const unwatch = actions.token.watchRole(clientWithAccount, {
2500
2643
  token: address,
2501
2644
  onRoleUpdated: (args, log) => {
2502
2645
  receivedRoleUpdates.push({ args, log })
@@ -2505,21 +2648,21 @@ describe('watchRole', () => {
2505
2648
 
2506
2649
  try {
2507
2650
  // Grant issuer role to account2
2508
- await actions.token.grantRolesSync(client, {
2651
+ await actions.token.grantRolesSync(clientWithAccount, {
2509
2652
  token: address,
2510
2653
  roles: ['issuer'],
2511
2654
  to: account2.address,
2512
2655
  })
2513
2656
 
2514
2657
  // Grant pause role to account3
2515
- await actions.token.grantRolesSync(client, {
2658
+ await actions.token.grantRolesSync(clientWithAccount, {
2516
2659
  token: address,
2517
2660
  roles: ['pause'],
2518
2661
  to: account3.address,
2519
2662
  })
2520
2663
 
2521
2664
  // Revoke issuer role from account2
2522
- await actions.token.revokeRolesSync(client, {
2665
+ await actions.token.revokeRolesSync(clientWithAccount, {
2523
2666
  token: address,
2524
2667
  roles: ['issuer'],
2525
2668
  from: account2.address,
@@ -2550,11 +2693,14 @@ describe('watchRole', () => {
2550
2693
 
2551
2694
  test('behavior: filter by account address', async () => {
2552
2695
  // Create a new token for testing
2553
- const { token: address } = await actions.token.createSync(client, {
2554
- currency: 'USD',
2555
- name: 'Filtered Role Token',
2556
- symbol: 'FROLE',
2557
- })
2696
+ const { token: address } = await actions.token.createSync(
2697
+ clientWithAccount,
2698
+ {
2699
+ currency: 'USD',
2700
+ name: 'Filtered Role Token',
2701
+ symbol: 'FROLE',
2702
+ },
2703
+ )
2558
2704
 
2559
2705
  const receivedRoleUpdates: Array<{
2560
2706
  args: actions.token.watchRole.Args
@@ -2562,7 +2708,7 @@ describe('watchRole', () => {
2562
2708
  }> = []
2563
2709
 
2564
2710
  // Start watching for role updates only for account2
2565
- const unwatch = actions.token.watchRole(client, {
2711
+ const unwatch = actions.token.watchRole(clientWithAccount, {
2566
2712
  token: address,
2567
2713
  args: {
2568
2714
  account: account2.address,
@@ -2574,21 +2720,21 @@ describe('watchRole', () => {
2574
2720
 
2575
2721
  try {
2576
2722
  // Grant issuer role to account2 (should be captured)
2577
- await actions.token.grantRolesSync(client, {
2723
+ await actions.token.grantRolesSync(clientWithAccount, {
2578
2724
  token: address,
2579
2725
  roles: ['issuer'],
2580
2726
  to: account2.address,
2581
2727
  })
2582
2728
 
2583
2729
  // Grant pause role to account3 (should NOT be captured)
2584
- await actions.token.grantRolesSync(client, {
2730
+ await actions.token.grantRolesSync(clientWithAccount, {
2585
2731
  token: address,
2586
2732
  roles: ['pause'],
2587
2733
  to: account3.address,
2588
2734
  })
2589
2735
 
2590
2736
  // Revoke issuer role from account2 (should be captured)
2591
- await actions.token.revokeRolesSync(client, {
2737
+ await actions.token.revokeRolesSync(clientWithAccount, {
2592
2738
  token: address,
2593
2739
  roles: ['issuer'],
2594
2740
  from: account2.address,
@@ -2626,23 +2772,26 @@ describe('watchTransfer', () => {
2626
2772
 
2627
2773
  test('default', async () => {
2628
2774
  // Create a new token for testing
2629
- const { token: address } = await actions.token.createSync(client, {
2630
- currency: 'USD',
2631
- name: 'Transfer Watch Token',
2632
- symbol: 'XFER',
2633
- })
2775
+ const { token: address } = await actions.token.createSync(
2776
+ clientWithAccount,
2777
+ {
2778
+ currency: 'USD',
2779
+ name: 'Transfer Watch Token',
2780
+ symbol: 'XFER',
2781
+ },
2782
+ )
2634
2783
 
2635
2784
  // Grant issuer role to mint tokens
2636
- await actions.token.grantRolesSync(client, {
2785
+ await actions.token.grantRolesSync(clientWithAccount, {
2637
2786
  token: address,
2638
2787
  roles: ['issuer'],
2639
- to: client.account.address,
2788
+ to: clientWithAccount.account.address,
2640
2789
  })
2641
2790
 
2642
2791
  // Mint tokens to transfer
2643
- await actions.token.mintSync(client, {
2792
+ await actions.token.mintSync(clientWithAccount, {
2644
2793
  token: address,
2645
- to: client.account.address,
2794
+ to: clientWithAccount.account.address,
2646
2795
  amount: parseUnits('500', 6),
2647
2796
  })
2648
2797
 
@@ -2652,7 +2801,7 @@ describe('watchTransfer', () => {
2652
2801
  }> = []
2653
2802
 
2654
2803
  // Start watching for transfer events
2655
- const unwatch = actions.token.watchTransfer(client, {
2804
+ const unwatch = actions.token.watchTransfer(clientWithAccount, {
2656
2805
  token: address,
2657
2806
  onTransfer: (args, log) => {
2658
2807
  receivedTransfers.push({ args, log })
@@ -2661,14 +2810,14 @@ describe('watchTransfer', () => {
2661
2810
 
2662
2811
  try {
2663
2812
  // Transfer to account2
2664
- await actions.token.transferSync(client, {
2813
+ await actions.token.transferSync(clientWithAccount, {
2665
2814
  token: address,
2666
2815
  to: account2.address,
2667
2816
  amount: parseUnits('100', 6),
2668
2817
  })
2669
2818
 
2670
2819
  // Transfer to account3
2671
- await actions.token.transferSync(client, {
2820
+ await actions.token.transferSync(clientWithAccount, {
2672
2821
  token: address,
2673
2822
  to: account3.address,
2674
2823
  amount: parseUnits('50', 6),
@@ -2699,23 +2848,26 @@ describe('watchTransfer', () => {
2699
2848
 
2700
2849
  test('behavior: filter by to address', async () => {
2701
2850
  // Create a new token for testing
2702
- const { token: address } = await actions.token.createSync(client, {
2703
- currency: 'USD',
2704
- name: 'Filtered Transfer Token',
2705
- symbol: 'FXFER',
2706
- })
2851
+ const { token: address } = await actions.token.createSync(
2852
+ clientWithAccount,
2853
+ {
2854
+ currency: 'USD',
2855
+ name: 'Filtered Transfer Token',
2856
+ symbol: 'FXFER',
2857
+ },
2858
+ )
2707
2859
 
2708
2860
  // Grant issuer role
2709
- await actions.token.grantRolesSync(client, {
2861
+ await actions.token.grantRolesSync(clientWithAccount, {
2710
2862
  token: address,
2711
2863
  roles: ['issuer'],
2712
- to: client.account.address,
2864
+ to: clientWithAccount.account.address,
2713
2865
  })
2714
2866
 
2715
2867
  // Mint tokens
2716
- await actions.token.mintSync(client, {
2868
+ await actions.token.mintSync(clientWithAccount, {
2717
2869
  token: address,
2718
- to: client.account.address,
2870
+ to: clientWithAccount.account.address,
2719
2871
  amount: parseUnits('500', 6),
2720
2872
  })
2721
2873
 
@@ -2725,7 +2877,7 @@ describe('watchTransfer', () => {
2725
2877
  }> = []
2726
2878
 
2727
2879
  // Start watching for transfer events only to account2
2728
- const unwatch = actions.token.watchTransfer(client, {
2880
+ const unwatch = actions.token.watchTransfer(clientWithAccount, {
2729
2881
  token: address,
2730
2882
  args: {
2731
2883
  to: account2.address,
@@ -2737,21 +2889,21 @@ describe('watchTransfer', () => {
2737
2889
 
2738
2890
  try {
2739
2891
  // Transfer to account2 (should be captured)
2740
- await actions.token.transferSync(client, {
2892
+ await actions.token.transferSync(clientWithAccount, {
2741
2893
  token: address,
2742
2894
  to: account2.address,
2743
2895
  amount: parseUnits('100', 6),
2744
2896
  })
2745
2897
 
2746
2898
  // Transfer to account3 (should NOT be captured)
2747
- await actions.token.transferSync(client, {
2899
+ await actions.token.transferSync(clientWithAccount, {
2748
2900
  token: address,
2749
2901
  to: account3.address,
2750
2902
  amount: parseUnits('50', 6),
2751
2903
  })
2752
2904
 
2753
2905
  // Transfer to account2 again (should be captured)
2754
- await actions.token.transferSync(client, {
2906
+ await actions.token.transferSync(clientWithAccount, {
2755
2907
  token: address,
2756
2908
  to: account2.address,
2757
2909
  amount: parseUnits('75', 6),
@@ -2791,7 +2943,7 @@ describe('watchUpdateQuoteToken', () => {
2791
2943
  test('default', async () => {
2792
2944
  // Create quote token
2793
2945
  const { token: quoteTokenAddress } = await actions.token.createSync(
2794
- client,
2946
+ clientWithAccount,
2795
2947
  {
2796
2948
  currency: 'USD',
2797
2949
  name: 'Watch Quote Token',
@@ -2800,11 +2952,14 @@ describe('watchUpdateQuoteToken', () => {
2800
2952
  )
2801
2953
 
2802
2954
  // Create main token
2803
- const { token: address } = await actions.token.createSync(client, {
2804
- currency: 'USD',
2805
- name: 'Watch Main Token',
2806
- symbol: 'WMAIN',
2807
- })
2955
+ const { token: address } = await actions.token.createSync(
2956
+ clientWithAccount,
2957
+ {
2958
+ currency: 'USD',
2959
+ name: 'Watch Main Token',
2960
+ symbol: 'WMAIN',
2961
+ },
2962
+ )
2808
2963
 
2809
2964
  const receivedUpdates: Array<{
2810
2965
  args: actions.token.watchUpdateQuoteToken.Args
@@ -2812,7 +2967,7 @@ describe('watchUpdateQuoteToken', () => {
2812
2967
  }> = []
2813
2968
 
2814
2969
  // Start watching for quote token update events
2815
- const unwatch = actions.token.watchUpdateQuoteToken(client, {
2970
+ const unwatch = actions.token.watchUpdateQuoteToken(clientWithAccount, {
2816
2971
  token: address,
2817
2972
  onUpdateQuoteToken: (args, log) => {
2818
2973
  receivedUpdates.push({ args, log })
@@ -2821,13 +2976,13 @@ describe('watchUpdateQuoteToken', () => {
2821
2976
 
2822
2977
  try {
2823
2978
  // Step 1: Prepare update quote token (should emit NextQuoteTokenSet)
2824
- await actions.token.prepareUpdateQuoteTokenSync(client, {
2979
+ await actions.token.prepareUpdateQuoteTokenSync(clientWithAccount, {
2825
2980
  token: address,
2826
2981
  quoteToken: quoteTokenAddress,
2827
2982
  })
2828
2983
 
2829
2984
  // Step 2: Finalize the update (should emit QuoteTokenUpdateFinalized)
2830
- await actions.token.updateQuoteTokenSync(client, {
2985
+ await actions.token.updateQuoteTokenSync(clientWithAccount, {
2831
2986
  token: address,
2832
2987
  })
2833
2988
 
@@ -2839,12 +2994,16 @@ describe('watchUpdateQuoteToken', () => {
2839
2994
  // First event: update proposed (not finalized)
2840
2995
  expect(receivedUpdates.at(0)!.args.completed).toBe(false)
2841
2996
  expect(receivedUpdates.at(0)!.args.nextQuoteToken).toBe(quoteTokenAddress)
2842
- expect(receivedUpdates.at(0)!.args.updater).toBe(client.account.address)
2997
+ expect(receivedUpdates.at(0)!.args.updater).toBe(
2998
+ clientWithAccount.account.address,
2999
+ )
2843
3000
 
2844
3001
  // Second event: update finalized
2845
3002
  expect(receivedUpdates.at(1)!.args.completed).toBe(true)
2846
3003
  expect(receivedUpdates.at(1)!.args.newQuoteToken).toBe(quoteTokenAddress)
2847
- expect(receivedUpdates.at(1)!.args.updater).toBe(client.account.address)
3004
+ expect(receivedUpdates.at(1)!.args.updater).toBe(
3005
+ clientWithAccount.account.address,
3006
+ )
2848
3007
  } finally {
2849
3008
  if (unwatch) unwatch()
2850
3009
  }
@@ -2853,7 +3012,7 @@ describe('watchUpdateQuoteToken', () => {
2853
3012
  test('behavior: only proposed updates', async () => {
2854
3013
  // Create quote token
2855
3014
  const { token: quoteTokenAddress } = await actions.token.createSync(
2856
- client,
3015
+ clientWithAccount,
2857
3016
  {
2858
3017
  currency: 'USD',
2859
3018
  name: 'Proposed Quote Token',
@@ -2862,11 +3021,14 @@ describe('watchUpdateQuoteToken', () => {
2862
3021
  )
2863
3022
 
2864
3023
  // Create main token
2865
- const { token: address } = await actions.token.createSync(client, {
2866
- currency: 'USD',
2867
- name: 'Proposed Main Token',
2868
- symbol: 'PMAIN',
2869
- })
3024
+ const { token: address } = await actions.token.createSync(
3025
+ clientWithAccount,
3026
+ {
3027
+ currency: 'USD',
3028
+ name: 'Proposed Main Token',
3029
+ symbol: 'PMAIN',
3030
+ },
3031
+ )
2870
3032
 
2871
3033
  const receivedUpdates: Array<{
2872
3034
  args: actions.token.watchUpdateQuoteToken.Args
@@ -2874,7 +3036,7 @@ describe('watchUpdateQuoteToken', () => {
2874
3036
  }> = []
2875
3037
 
2876
3038
  // Start watching
2877
- const unwatch = actions.token.watchUpdateQuoteToken(client, {
3039
+ const unwatch = actions.token.watchUpdateQuoteToken(clientWithAccount, {
2878
3040
  token: address,
2879
3041
  onUpdateQuoteToken: (args, log) => {
2880
3042
  receivedUpdates.push({ args, log })
@@ -2883,7 +3045,7 @@ describe('watchUpdateQuoteToken', () => {
2883
3045
 
2884
3046
  try {
2885
3047
  // Only update (don't finalize)
2886
- await actions.token.prepareUpdateQuoteTokenSync(client, {
3048
+ await actions.token.prepareUpdateQuoteTokenSync(clientWithAccount, {
2887
3049
  token: address,
2888
3050
  quoteToken: quoteTokenAddress,
2889
3051
  })