tempo.ts 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) 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/Actions/token.d.ts +12 -12
  15. package/dist/viem/Actions/token.js +12 -12
  16. package/dist/viem/Chain.d.ts +6 -0
  17. package/dist/viem/Chain.d.ts.map +1 -1
  18. package/dist/viem/Decorator.d.ts +9 -9
  19. package/dist/viem/Transaction.d.ts +4 -1
  20. package/dist/viem/Transaction.d.ts.map +1 -1
  21. package/dist/viem/Transaction.js.map +1 -1
  22. package/dist/wagmi/Actions/token.d.ts +1 -1
  23. package/dist/wagmi/Actions/token.js +1 -1
  24. package/dist/wagmi/Connector.d.ts +4 -3
  25. package/dist/wagmi/Connector.d.ts.map +1 -1
  26. package/dist/wagmi/Connector.js +91 -5
  27. package/dist/wagmi/Connector.js.map +1 -1
  28. package/dist/wagmi/Hooks/token.d.ts +1 -1
  29. package/dist/wagmi/Hooks/token.js +1 -1
  30. package/package.json +1 -1
  31. package/src/chains.ts +2 -1
  32. package/src/ox/TransactionEnvelopeAA.test.ts +2 -663
  33. package/src/ox/e2e.test.ts +659 -0
  34. package/src/prool/Instance.ts +51 -23
  35. package/src/tsconfig.json +2 -2
  36. package/src/viem/Actions/amm.test.ts +68 -58
  37. package/src/viem/Actions/dex.test.ts +339 -283
  38. package/src/viem/Actions/faucet.ts +63 -1
  39. package/src/viem/Actions/fee.test.ts +34 -43
  40. package/src/viem/Actions/policy.test.ts +115 -81
  41. package/src/viem/Actions/reward.test.ts +92 -74
  42. package/src/viem/Actions/token.test.ts +691 -529
  43. package/src/viem/Actions/token.ts +12 -12
  44. package/src/viem/Decorator.ts +9 -9
  45. package/src/viem/Transaction.ts +4 -1
  46. package/src/viem/e2e.test.ts +451 -472
  47. package/src/wagmi/Actions/amm.test.ts +2 -5
  48. package/src/wagmi/Actions/dex.test.ts +2 -1
  49. package/src/wagmi/Actions/token.test.ts +2 -1
  50. package/src/wagmi/Actions/token.ts +1 -1
  51. package/src/wagmi/Connector.ts +125 -10
  52. package/src/wagmi/Hooks/amm.test.ts +2 -5
  53. package/src/wagmi/Hooks/dex.test.ts +2 -1
  54. package/src/wagmi/Hooks/token.test.ts +2 -1
  55. package/src/wagmi/Hooks/token.ts +1 -1
@@ -1,6 +1,7 @@
1
1
  import { setTimeout } from 'node:timers/promises'
2
2
  import { beforeAll, describe, expect, test } from 'vitest'
3
- import { accounts, client, rpcUrl } from '../../../test/viem/config.js'
3
+ import { rpcUrl } from '../../../test/config.js'
4
+ import { accounts, clientWithAccount } from '../../../test/viem/config.js'
4
5
  import * as actions from './index.js'
5
6
 
6
7
  const account = accounts[0]
@@ -10,9 +11,12 @@ const account3 = accounts[2]
10
11
  describe('create', () => {
11
12
  test('default', async () => {
12
13
  // create whitelist policy
13
- const { receipt, ...result } = await actions.policy.createSync(client, {
14
- type: 'whitelist',
15
- })
14
+ const { receipt, ...result } = await actions.policy.createSync(
15
+ clientWithAccount,
16
+ {
17
+ type: 'whitelist',
18
+ },
19
+ )
16
20
  expect(receipt).toBeDefined()
17
21
  expect(result).toMatchInlineSnapshot(`
18
22
  {
@@ -25,7 +29,7 @@ describe('create', () => {
25
29
  const { policyId } = result
26
30
 
27
31
  // verify policy was created
28
- const data = await actions.policy.getData(client, {
32
+ const data = await actions.policy.getData(clientWithAccount, {
29
33
  policyId,
30
34
  })
31
35
  expect(data.admin).toBe(account.address)
@@ -35,7 +39,7 @@ describe('create', () => {
35
39
  test('behavior: blacklist', async () => {
36
40
  // create blacklist policy
37
41
  const { receipt: blacklistReceipt, ...blacklistResult } =
38
- await actions.policy.createSync(client, {
42
+ await actions.policy.createSync(clientWithAccount, {
39
43
  type: 'blacklist',
40
44
  })
41
45
  expect(blacklistReceipt).toBeDefined()
@@ -50,7 +54,7 @@ describe('create', () => {
50
54
  const { policyId } = blacklistResult
51
55
 
52
56
  // verify policy was created
53
- const data = await actions.policy.getData(client, {
57
+ const data = await actions.policy.getData(clientWithAccount, {
54
58
  policyId,
55
59
  })
56
60
  expect(data.admin).toBe(account.address)
@@ -59,26 +63,26 @@ describe('create', () => {
59
63
 
60
64
  test.skip('behavior: with initial addresses', async () => {
61
65
  // create policy with initial addresses
62
- const { policyId } = await actions.policy.createSync(client, {
66
+ const { policyId } = await actions.policy.createSync(clientWithAccount, {
63
67
  type: 'whitelist',
64
68
  addresses: [account2.address, account3.address],
65
69
  })
66
70
 
67
71
  // verify addresses are whitelisted
68
- const isAuthorized2 = await actions.policy.isAuthorized(client, {
72
+ const isAuthorized2 = await actions.policy.isAuthorized(clientWithAccount, {
69
73
  policyId,
70
74
  user: account2.address,
71
75
  })
72
76
  expect(isAuthorized2).toBe(true)
73
77
 
74
- const isAuthorized3 = await actions.policy.isAuthorized(client, {
78
+ const isAuthorized3 = await actions.policy.isAuthorized(clientWithAccount, {
75
79
  policyId,
76
80
  user: account3.address,
77
81
  })
78
82
  expect(isAuthorized3).toBe(true)
79
83
 
80
84
  // verify other address is not whitelisted
81
- const isAuthorized = await actions.policy.isAuthorized(client, {
85
+ const isAuthorized = await actions.policy.isAuthorized(clientWithAccount, {
82
86
  policyId,
83
87
  user: account.address,
84
88
  })
@@ -89,13 +93,13 @@ describe('create', () => {
89
93
  describe('setAdmin', () => {
90
94
  test('default', async () => {
91
95
  // create policy
92
- const { policyId } = await actions.policy.createSync(client, {
96
+ const { policyId } = await actions.policy.createSync(clientWithAccount, {
93
97
  type: 'whitelist',
94
98
  })
95
99
 
96
100
  // set new admin
97
101
  const { receipt: setAdminReceipt, ...setAdminResult } =
98
- await actions.policy.setAdminSync(client, {
102
+ await actions.policy.setAdminSync(clientWithAccount, {
99
103
  policyId,
100
104
  admin: account2.address,
101
105
  })
@@ -110,7 +114,7 @@ describe('setAdmin', () => {
110
114
 
111
115
  {
112
116
  // verify new admin
113
- const data = await actions.policy.getData(client, {
117
+ const data = await actions.policy.getData(clientWithAccount, {
114
118
  policyId,
115
119
  })
116
120
  expect(data.admin).toBe(account2.address)
@@ -121,22 +125,25 @@ describe('setAdmin', () => {
121
125
  describe('modifyWhitelist', () => {
122
126
  test('default', async () => {
123
127
  // create whitelist policy
124
- const { policyId } = await actions.policy.createSync(client, {
128
+ const { policyId } = await actions.policy.createSync(clientWithAccount, {
125
129
  type: 'whitelist',
126
130
  })
127
131
 
128
132
  {
129
133
  // verify account2 is not authorized
130
- const isAuthorized = await actions.policy.isAuthorized(client, {
131
- policyId,
132
- user: account2.address,
133
- })
134
+ const isAuthorized = await actions.policy.isAuthorized(
135
+ clientWithAccount,
136
+ {
137
+ policyId,
138
+ user: account2.address,
139
+ },
140
+ )
134
141
  expect(isAuthorized).toBe(false)
135
142
  }
136
143
 
137
144
  // add account2 to whitelist
138
145
  const { receipt: addReceipt, ...addResult } =
139
- await actions.policy.modifyWhitelistSync(client, {
146
+ await actions.policy.modifyWhitelistSync(clientWithAccount, {
140
147
  policyId,
141
148
  address: account2.address,
142
149
  allowed: true,
@@ -153,16 +160,19 @@ describe('modifyWhitelist', () => {
153
160
 
154
161
  {
155
162
  // verify account2 is authorized
156
- const isAuthorized = await actions.policy.isAuthorized(client, {
157
- policyId,
158
- user: account2.address,
159
- })
163
+ const isAuthorized = await actions.policy.isAuthorized(
164
+ clientWithAccount,
165
+ {
166
+ policyId,
167
+ user: account2.address,
168
+ },
169
+ )
160
170
  expect(isAuthorized).toBe(true)
161
171
  }
162
172
 
163
173
  // remove account2 from whitelist
164
174
  const { receipt: removeReceipt, ...removeResult } =
165
- await actions.policy.modifyWhitelistSync(client, {
175
+ await actions.policy.modifyWhitelistSync(clientWithAccount, {
166
176
  policyId,
167
177
  address: account2.address,
168
178
  allowed: false,
@@ -179,10 +189,13 @@ describe('modifyWhitelist', () => {
179
189
 
180
190
  {
181
191
  // verify account2 is no longer authorized
182
- const isAuthorized = await actions.policy.isAuthorized(client, {
183
- policyId,
184
- user: account2.address,
185
- })
192
+ const isAuthorized = await actions.policy.isAuthorized(
193
+ clientWithAccount,
194
+ {
195
+ policyId,
196
+ user: account2.address,
197
+ },
198
+ )
186
199
  expect(isAuthorized).toBe(false)
187
200
  }
188
201
  })
@@ -191,22 +204,25 @@ describe('modifyWhitelist', () => {
191
204
  describe('modifyBlacklist', () => {
192
205
  test('default', async () => {
193
206
  // create blacklist policy
194
- const { policyId } = await actions.policy.createSync(client, {
207
+ const { policyId } = await actions.policy.createSync(clientWithAccount, {
195
208
  type: 'blacklist',
196
209
  })
197
210
 
198
211
  {
199
212
  // verify account2 is authorized (not blacklisted)
200
- const isAuthorized = await actions.policy.isAuthorized(client, {
201
- policyId,
202
- user: account2.address,
203
- })
213
+ const isAuthorized = await actions.policy.isAuthorized(
214
+ clientWithAccount,
215
+ {
216
+ policyId,
217
+ user: account2.address,
218
+ },
219
+ )
204
220
  expect(isAuthorized).toBe(true)
205
221
  }
206
222
 
207
223
  // add account2 to blacklist
208
224
  const { receipt: addBlacklistReceipt, ...addBlacklistResult } =
209
- await actions.policy.modifyBlacklistSync(client, {
225
+ await actions.policy.modifyBlacklistSync(clientWithAccount, {
210
226
  policyId,
211
227
  address: account2.address,
212
228
  restricted: true,
@@ -223,16 +239,19 @@ describe('modifyBlacklist', () => {
223
239
 
224
240
  {
225
241
  // verify account2 is not authorized (blacklisted)
226
- const isAuthorized = await actions.policy.isAuthorized(client, {
227
- policyId,
228
- user: account2.address,
229
- })
242
+ const isAuthorized = await actions.policy.isAuthorized(
243
+ clientWithAccount,
244
+ {
245
+ policyId,
246
+ user: account2.address,
247
+ },
248
+ )
230
249
  expect(isAuthorized).toBe(false)
231
250
  }
232
251
 
233
252
  // remove account2 from blacklist
234
253
  const { receipt: removeBlacklistReceipt, ...removeBlacklistResult } =
235
- await actions.policy.modifyBlacklistSync(client, {
254
+ await actions.policy.modifyBlacklistSync(clientWithAccount, {
236
255
  policyId,
237
256
  address: account2.address,
238
257
  restricted: false,
@@ -249,10 +268,13 @@ describe('modifyBlacklist', () => {
249
268
 
250
269
  {
251
270
  // verify account2 is authorized again
252
- const isAuthorized = await actions.policy.isAuthorized(client, {
253
- policyId,
254
- user: account2.address,
255
- })
271
+ const isAuthorized = await actions.policy.isAuthorized(
272
+ clientWithAccount,
273
+ {
274
+ policyId,
275
+ user: account2.address,
276
+ },
277
+ )
256
278
  expect(isAuthorized).toBe(true)
257
279
  }
258
280
  })
@@ -261,13 +283,13 @@ describe('modifyBlacklist', () => {
261
283
  describe('getData', () => {
262
284
  test('default', async () => {
263
285
  // create policy
264
- const { policyId } = await actions.policy.createSync(client, {
286
+ const { policyId } = await actions.policy.createSync(clientWithAccount, {
265
287
  type: 'whitelist',
266
288
  })
267
289
 
268
290
  {
269
291
  // get policy data
270
- const data = await actions.policy.getData(client, {
292
+ const data = await actions.policy.getData(clientWithAccount, {
271
293
  policyId,
272
294
  })
273
295
  expect(data.admin).toBe(account.address)
@@ -277,13 +299,13 @@ describe('getData', () => {
277
299
 
278
300
  test('behavior: blacklist', async () => {
279
301
  // create blacklist policy
280
- const { policyId } = await actions.policy.createSync(client, {
302
+ const { policyId } = await actions.policy.createSync(clientWithAccount, {
281
303
  type: 'blacklist',
282
304
  })
283
305
 
284
306
  {
285
307
  // get policy data
286
- const data = await actions.policy.getData(client, {
308
+ const data = await actions.policy.getData(clientWithAccount, {
287
309
  policyId,
288
310
  })
289
311
  expect(data.admin).toBe(account.address)
@@ -294,7 +316,7 @@ describe('getData', () => {
294
316
 
295
317
  describe('isAuthorized', () => {
296
318
  test('special policy: always-reject (policyId 0)', async () => {
297
- const isAuthorized = await actions.policy.isAuthorized(client, {
319
+ const isAuthorized = await actions.policy.isAuthorized(clientWithAccount, {
298
320
  policyId: 0n,
299
321
  user: account.address,
300
322
  })
@@ -302,7 +324,7 @@ describe('isAuthorized', () => {
302
324
  })
303
325
 
304
326
  test('special policy: always-allow (policyId 1)', async () => {
305
- const isAuthorized = await actions.policy.isAuthorized(client, {
327
+ const isAuthorized = await actions.policy.isAuthorized(clientWithAccount, {
306
328
  policyId: 1n,
307
329
  user: account.address,
308
330
  })
@@ -311,52 +333,64 @@ describe('isAuthorized', () => {
311
333
 
312
334
  test.skip('whitelist policy', async () => {
313
335
  // create whitelist policy
314
- const { policyId } = await actions.policy.createSync(client, {
336
+ const { policyId } = await actions.policy.createSync(clientWithAccount, {
315
337
  type: 'whitelist',
316
338
  addresses: [account2.address],
317
339
  })
318
340
 
319
341
  {
320
342
  // verify whitelisted address is authorized
321
- const isAuthorized = await actions.policy.isAuthorized(client, {
322
- policyId,
323
- user: account2.address,
324
- })
343
+ const isAuthorized = await actions.policy.isAuthorized(
344
+ clientWithAccount,
345
+ {
346
+ policyId,
347
+ user: account2.address,
348
+ },
349
+ )
325
350
  expect(isAuthorized).toBe(true)
326
351
  }
327
352
 
328
353
  {
329
354
  // verify non-whitelisted address is not authorized
330
- const isAuthorized = await actions.policy.isAuthorized(client, {
331
- policyId,
332
- user: account.address,
333
- })
355
+ const isAuthorized = await actions.policy.isAuthorized(
356
+ clientWithAccount,
357
+ {
358
+ policyId,
359
+ user: account.address,
360
+ },
361
+ )
334
362
  expect(isAuthorized).toBe(false)
335
363
  }
336
364
  })
337
365
 
338
366
  test.skip('blacklist policy', async () => {
339
367
  // create blacklist policy
340
- const { policyId } = await actions.policy.createSync(client, {
368
+ const { policyId } = await actions.policy.createSync(clientWithAccount, {
341
369
  type: 'blacklist',
342
370
  addresses: [account2.address],
343
371
  })
344
372
 
345
373
  {
346
374
  // verify blacklisted address is not authorized
347
- const isAuthorized = await actions.policy.isAuthorized(client, {
348
- policyId,
349
- user: account2.address,
350
- })
375
+ const isAuthorized = await actions.policy.isAuthorized(
376
+ clientWithAccount,
377
+ {
378
+ policyId,
379
+ user: account2.address,
380
+ },
381
+ )
351
382
  expect(isAuthorized).toBe(false)
352
383
  }
353
384
 
354
385
  {
355
386
  // verify non-blacklisted address is authorized
356
- const isAuthorized = await actions.policy.isAuthorized(client, {
357
- policyId,
358
- user: account.address,
359
- })
387
+ const isAuthorized = await actions.policy.isAuthorized(
388
+ clientWithAccount,
389
+ {
390
+ policyId,
391
+ user: account.address,
392
+ },
393
+ )
360
394
  expect(isAuthorized).toBe(true)
361
395
  }
362
396
  })
@@ -365,14 +399,14 @@ describe('isAuthorized', () => {
365
399
  describe('watchCreate', () => {
366
400
  test('default', async () => {
367
401
  const logs: any[] = []
368
- const unwatch = actions.policy.watchCreate(client, {
402
+ const unwatch = actions.policy.watchCreate(clientWithAccount, {
369
403
  onPolicyCreated: (args, log) => {
370
404
  logs.push({ args, log })
371
405
  },
372
406
  })
373
407
 
374
408
  // create policy
375
- await actions.policy.createSync(client, {
409
+ await actions.policy.createSync(clientWithAccount, {
376
410
  type: 'whitelist',
377
411
  })
378
412
 
@@ -393,19 +427,19 @@ describe('watchAdminUpdated', () => {
393
427
 
394
428
  test('default', async () => {
395
429
  // create policy
396
- const { policyId } = await actions.policy.createSync(client, {
430
+ const { policyId } = await actions.policy.createSync(clientWithAccount, {
397
431
  type: 'whitelist',
398
432
  })
399
433
 
400
434
  const logs: any[] = []
401
- const unwatch = actions.policy.watchAdminUpdated(client, {
435
+ const unwatch = actions.policy.watchAdminUpdated(clientWithAccount, {
402
436
  onAdminUpdated: (args, log) => {
403
437
  logs.push({ args, log })
404
438
  },
405
439
  })
406
440
 
407
441
  // set new admin
408
- await actions.policy.setAdminSync(client, {
442
+ await actions.policy.setAdminSync(clientWithAccount, {
409
443
  policyId,
410
444
  admin: account2.address,
411
445
  })
@@ -422,26 +456,26 @@ describe('watchAdminUpdated', () => {
422
456
  describe('watchWhitelistUpdated', () => {
423
457
  test('default', async () => {
424
458
  // create whitelist policy
425
- const { policyId } = await actions.policy.createSync(client, {
459
+ const { policyId } = await actions.policy.createSync(clientWithAccount, {
426
460
  type: 'whitelist',
427
461
  })
428
462
 
429
463
  const logs: any[] = []
430
- const unwatch = actions.policy.watchWhitelistUpdated(client, {
464
+ const unwatch = actions.policy.watchWhitelistUpdated(clientWithAccount, {
431
465
  onWhitelistUpdated: (args, log) => {
432
466
  logs.push({ args, log })
433
467
  },
434
468
  })
435
469
 
436
470
  // add address to whitelist
437
- await actions.policy.modifyWhitelistSync(client, {
471
+ await actions.policy.modifyWhitelistSync(clientWithAccount, {
438
472
  policyId,
439
473
  address: account2.address,
440
474
  allowed: true,
441
475
  })
442
476
 
443
477
  // remove address from whitelist
444
- await actions.policy.modifyWhitelistSync(client, {
478
+ await actions.policy.modifyWhitelistSync(clientWithAccount, {
445
479
  policyId,
446
480
  address: account2.address,
447
481
  allowed: false,
@@ -462,26 +496,26 @@ describe('watchWhitelistUpdated', () => {
462
496
  describe('watchBlacklistUpdated', () => {
463
497
  test('default', async () => {
464
498
  // create blacklist policy
465
- const { policyId } = await actions.policy.createSync(client, {
499
+ const { policyId } = await actions.policy.createSync(clientWithAccount, {
466
500
  type: 'blacklist',
467
501
  })
468
502
 
469
503
  const logs: any[] = []
470
- const unwatch = actions.policy.watchBlacklistUpdated(client, {
504
+ const unwatch = actions.policy.watchBlacklistUpdated(clientWithAccount, {
471
505
  onBlacklistUpdated: (args, log) => {
472
506
  logs.push({ args, log })
473
507
  },
474
508
  })
475
509
 
476
510
  // add address to blacklist
477
- await actions.policy.modifyBlacklistSync(client, {
511
+ await actions.policy.modifyBlacklistSync(clientWithAccount, {
478
512
  policyId,
479
513
  address: account2.address,
480
514
  restricted: true,
481
515
  })
482
516
 
483
517
  // remove address from blacklist
484
- await actions.policy.modifyBlacklistSync(client, {
518
+ await actions.policy.modifyBlacklistSync(clientWithAccount, {
485
519
  policyId,
486
520
  address: account2.address,
487
521
  restricted: false,