tempo.ts 0.0.6 → 0.1.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 (195) hide show
  1. package/dist/chains.d.ts +244 -541
  2. package/dist/chains.d.ts.map +1 -1
  3. package/dist/chains.js +10 -23
  4. package/dist/chains.js.map +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/ox/SignatureEnvelope.d.ts +245 -0
  7. package/dist/ox/SignatureEnvelope.d.ts.map +1 -0
  8. package/dist/ox/SignatureEnvelope.js +437 -0
  9. package/dist/ox/SignatureEnvelope.js.map +1 -0
  10. package/dist/ox/Transaction.d.ts +61 -24
  11. package/dist/ox/Transaction.d.ts.map +1 -1
  12. package/dist/ox/Transaction.js +63 -18
  13. package/dist/ox/Transaction.js.map +1 -1
  14. package/dist/ox/TransactionEnvelopeAA.d.ts +461 -0
  15. package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -0
  16. package/dist/ox/TransactionEnvelopeAA.js +528 -0
  17. package/dist/ox/TransactionEnvelopeAA.js.map +1 -0
  18. package/dist/ox/TransactionRequest.d.ts +7 -5
  19. package/dist/ox/TransactionRequest.d.ts.map +1 -1
  20. package/dist/ox/TransactionRequest.js +21 -12
  21. package/dist/ox/TransactionRequest.js.map +1 -1
  22. package/dist/ox/index.d.ts +5 -4
  23. package/dist/ox/index.d.ts.map +1 -1
  24. package/dist/ox/index.js +5 -4
  25. package/dist/ox/index.js.map +1 -1
  26. package/dist/prool/Instance.d.ts +0 -4
  27. package/dist/prool/Instance.d.ts.map +1 -1
  28. package/dist/prool/Instance.js +7 -7
  29. package/dist/prool/Instance.js.map +1 -1
  30. package/dist/prool/index.d.ts +1 -1
  31. package/dist/prool/index.d.ts.map +1 -1
  32. package/dist/prool/index.js +1 -1
  33. package/dist/prool/index.js.map +1 -1
  34. package/dist/viem/{abis.d.ts → Abis.d.ts} +523 -9
  35. package/dist/viem/Abis.d.ts.map +1 -0
  36. package/dist/viem/{abis.js → Abis.js} +321 -9
  37. package/dist/viem/Abis.js.map +1 -0
  38. package/dist/viem/{actions → Actions}/amm.d.ts +21 -21
  39. package/dist/viem/Actions/amm.d.ts.map +1 -0
  40. package/dist/viem/{actions → Actions}/amm.js +55 -43
  41. package/dist/viem/Actions/amm.js.map +1 -0
  42. package/dist/viem/Actions/dex.d.ts +3263 -0
  43. package/dist/viem/Actions/dex.d.ts.map +1 -0
  44. package/dist/viem/Actions/dex.js +1357 -0
  45. package/dist/viem/Actions/dex.js.map +1 -0
  46. package/dist/viem/{actions → Actions}/fee.d.ts +8 -8
  47. package/dist/viem/Actions/fee.d.ts.map +1 -0
  48. package/dist/viem/{actions → Actions}/fee.js +14 -13
  49. package/dist/viem/Actions/fee.js.map +1 -0
  50. package/dist/viem/Actions/index.d.ts +6 -0
  51. package/dist/viem/Actions/index.d.ts.map +1 -0
  52. package/dist/viem/Actions/index.js +6 -0
  53. package/dist/viem/Actions/index.js.map +1 -0
  54. package/dist/viem/{actions → Actions}/policy.d.ts +19 -19
  55. package/dist/viem/Actions/policy.d.ts.map +1 -0
  56. package/dist/viem/{actions → Actions}/policy.js +59 -46
  57. package/dist/viem/Actions/policy.js.map +1 -0
  58. package/dist/viem/{actions → Actions}/token.d.ts +3275 -698
  59. package/dist/viem/Actions/token.d.ts.map +1 -0
  60. package/dist/viem/{actions → Actions}/token.js +458 -84
  61. package/dist/viem/Actions/token.js.map +1 -0
  62. package/dist/viem/Addresses.d.ts +9 -0
  63. package/dist/viem/Addresses.d.ts.map +1 -0
  64. package/dist/viem/Addresses.js +9 -0
  65. package/dist/viem/Addresses.js.map +1 -0
  66. package/dist/viem/{chain.d.ts → Chain.d.ts} +81 -57
  67. package/dist/viem/Chain.d.ts.map +1 -0
  68. package/dist/viem/{chain.js → Chain.js} +7 -7
  69. package/dist/viem/Chain.js.map +1 -0
  70. package/dist/viem/{client.d.ts → Client.d.ts} +4 -4
  71. package/dist/viem/Client.d.ts.map +1 -0
  72. package/dist/viem/{client.js → Client.js} +3 -3
  73. package/dist/viem/Client.js.map +1 -0
  74. package/dist/viem/{decorator.d.ts → Decorator.d.ts} +507 -5
  75. package/dist/viem/Decorator.d.ts.map +1 -0
  76. package/dist/viem/{decorator.js → Decorator.js} +31 -5
  77. package/dist/viem/Decorator.js.map +1 -0
  78. package/dist/viem/{formatters.d.ts → Formatters.d.ts} +2 -2
  79. package/dist/viem/Formatters.d.ts.map +1 -0
  80. package/dist/viem/{formatters.js → Formatters.js} +24 -17
  81. package/dist/viem/Formatters.js.map +1 -0
  82. package/dist/viem/Tick.d.ts +111 -0
  83. package/dist/viem/Tick.d.ts.map +1 -0
  84. package/dist/viem/Tick.js +127 -0
  85. package/dist/viem/Tick.js.map +1 -0
  86. package/dist/viem/TokenIds.d.ts +3 -0
  87. package/dist/viem/TokenIds.d.ts.map +1 -0
  88. package/dist/viem/TokenIds.js +3 -0
  89. package/dist/viem/TokenIds.js.map +1 -0
  90. package/dist/viem/Transaction.d.ts +57 -0
  91. package/dist/viem/Transaction.d.ts.map +1 -0
  92. package/dist/viem/Transaction.js +137 -0
  93. package/dist/viem/Transaction.js.map +1 -0
  94. package/dist/viem/{transport.d.ts → Transport.d.ts} +3 -3
  95. package/dist/viem/Transport.d.ts.map +1 -0
  96. package/dist/viem/{transport.js → Transport.js} +3 -3
  97. package/dist/viem/Transport.js.map +1 -0
  98. package/dist/viem/index.d.ts +13 -9
  99. package/dist/viem/index.d.ts.map +1 -1
  100. package/dist/viem/index.js +13 -9
  101. package/dist/viem/index.js.map +1 -1
  102. package/dist/viem/{types.d.ts → internal/types.d.ts} +3 -3
  103. package/dist/viem/internal/types.d.ts.map +1 -0
  104. package/dist/viem/{types.js.map → internal/types.js.map} +1 -1
  105. package/dist/viem/internal/utils.d.ts.map +1 -0
  106. package/dist/viem/internal/utils.js.map +1 -0
  107. package/package.json +87 -101
  108. package/src/chains.ts +10 -24
  109. package/src/ox/SignatureEnvelope.test.ts +1252 -0
  110. package/src/ox/SignatureEnvelope.ts +709 -0
  111. package/src/ox/Transaction.test.ts +144 -89
  112. package/src/ox/Transaction.ts +104 -29
  113. package/src/ox/TransactionEnvelopeAA.test.ts +1533 -0
  114. package/src/ox/TransactionEnvelopeAA.ts +858 -0
  115. package/src/ox/TransactionRequest.ts +25 -17
  116. package/src/ox/index.ts +2 -1
  117. package/src/prool/Instance.ts +6 -14
  118. package/src/prool/internal/chain.json +101 -27
  119. package/src/viem/{abis.ts → Abis.ts} +322 -8
  120. package/src/viem/{actions → Actions}/amm.test.ts +65 -68
  121. package/src/viem/{actions → Actions}/amm.ts +72 -60
  122. package/src/viem/Actions/dex.test.ts +1608 -0
  123. package/src/viem/Actions/dex.ts +2026 -0
  124. package/src/viem/{actions → Actions}/fee.test.ts +34 -36
  125. package/src/viem/{actions → Actions}/fee.ts +18 -17
  126. package/src/viem/{actions → Actions}/index.ts +1 -0
  127. package/src/viem/{actions → Actions}/policy.test.ts +2 -2
  128. package/src/viem/{actions → Actions}/policy.ts +77 -64
  129. package/src/viem/{actions → Actions}/token.test.ts +419 -64
  130. package/src/viem/{actions → Actions}/token.ts +751 -145
  131. package/src/viem/Addresses.ts +9 -0
  132. package/src/viem/{chain.ts → Chain.ts} +6 -6
  133. package/src/viem/{client.bench-d.ts → Client.bench-d.ts} +2 -2
  134. package/src/viem/{client.test.ts → Client.test.ts} +31 -6
  135. package/src/viem/{client.ts → Client.ts} +1 -1
  136. package/src/viem/{decorator.bench-d.ts → Decorator.bench-d.ts} +2 -2
  137. package/src/viem/{decorator.test.ts → Decorator.test.ts} +1 -0
  138. package/src/viem/{decorator.ts → Decorator.ts} +586 -4
  139. package/src/viem/{formatters.ts → Formatters.ts} +31 -20
  140. package/src/viem/Tick.test.ts +281 -0
  141. package/src/viem/Tick.ts +176 -0
  142. package/src/viem/TokenIds.ts +2 -0
  143. package/src/viem/Transaction.ts +303 -0
  144. package/src/viem/{transport.ts → Transport.ts} +5 -5
  145. package/src/viem/e2e.test.ts +153 -78
  146. package/src/viem/index.ts +13 -9
  147. package/src/viem/{types.ts → internal/types.ts} +3 -3
  148. package/dist/ox/TransactionEnvelopeFeeToken.d.ts +0 -393
  149. package/dist/ox/TransactionEnvelopeFeeToken.d.ts.map +0 -1
  150. package/dist/ox/TransactionEnvelopeFeeToken.js +0 -452
  151. package/dist/ox/TransactionEnvelopeFeeToken.js.map +0 -1
  152. package/dist/viem/abis.d.ts.map +0 -1
  153. package/dist/viem/abis.js.map +0 -1
  154. package/dist/viem/actions/amm.d.ts.map +0 -1
  155. package/dist/viem/actions/amm.js.map +0 -1
  156. package/dist/viem/actions/fee.d.ts.map +0 -1
  157. package/dist/viem/actions/fee.js.map +0 -1
  158. package/dist/viem/actions/index.d.ts +0 -5
  159. package/dist/viem/actions/index.d.ts.map +0 -1
  160. package/dist/viem/actions/index.js +0 -5
  161. package/dist/viem/actions/index.js.map +0 -1
  162. package/dist/viem/actions/policy.d.ts.map +0 -1
  163. package/dist/viem/actions/policy.js.map +0 -1
  164. package/dist/viem/actions/token.d.ts.map +0 -1
  165. package/dist/viem/actions/token.js.map +0 -1
  166. package/dist/viem/addresses.d.ts +0 -8
  167. package/dist/viem/addresses.d.ts.map +0 -1
  168. package/dist/viem/addresses.js +0 -8
  169. package/dist/viem/addresses.js.map +0 -1
  170. package/dist/viem/chain.d.ts.map +0 -1
  171. package/dist/viem/chain.js.map +0 -1
  172. package/dist/viem/client.d.ts.map +0 -1
  173. package/dist/viem/client.js.map +0 -1
  174. package/dist/viem/decorator.d.ts.map +0 -1
  175. package/dist/viem/decorator.js.map +0 -1
  176. package/dist/viem/formatters.d.ts.map +0 -1
  177. package/dist/viem/formatters.js.map +0 -1
  178. package/dist/viem/transaction.d.ts +0 -54
  179. package/dist/viem/transaction.d.ts.map +0 -1
  180. package/dist/viem/transaction.js +0 -108
  181. package/dist/viem/transaction.js.map +0 -1
  182. package/dist/viem/transport.d.ts.map +0 -1
  183. package/dist/viem/transport.js.map +0 -1
  184. package/dist/viem/types.d.ts.map +0 -1
  185. package/dist/viem/utils.d.ts.map +0 -1
  186. package/dist/viem/utils.js.map +0 -1
  187. package/src/ox/TransactionEnvelopeFeeToken.test.ts +0 -1119
  188. package/src/ox/TransactionEnvelopeFeeToken.ts +0 -717
  189. package/src/prool/internal/consensus.toml +0 -32
  190. package/src/viem/addresses.ts +0 -10
  191. package/src/viem/transaction.ts +0 -253
  192. /package/dist/viem/{types.js → internal/types.js} +0 -0
  193. /package/dist/viem/{utils.d.ts → internal/utils.d.ts} +0 -0
  194. /package/dist/viem/{utils.js → internal/utils.js} +0 -0
  195. /package/src/viem/{utils.ts → internal/utils.ts} +0 -0
@@ -1,14 +1,13 @@
1
1
  import { setTimeout } from 'node:timers/promises'
2
2
  import { Hex } from 'ox'
3
- import * as actions from 'tempo.ts/viem/actions'
3
+ import { Abis, Addresses, TokenIds } from 'tempo.ts/viem'
4
4
  import { parseEther, publicActions } from 'viem'
5
5
  import { mnemonicToAccount } from 'viem/accounts'
6
6
  import { getCode, writeContractSync } from 'viem/actions'
7
7
  import { describe, expect, test } from 'vitest'
8
8
  import { tempoTest } from '../../../test/viem/config.js'
9
- import { tip20Abi } from '../abis.js'
10
- import { usdAddress, usdId } from '../addresses.js'
11
- import { createTempoClient } from '../client.js'
9
+ import { createTempoClient } from '../Client.js'
10
+ import * as actions from './index.js'
12
11
 
13
12
  const account = mnemonicToAccount(
14
13
  'test test test test test test test test test test test junk',
@@ -56,8 +55,8 @@ describe('approve', () => {
56
55
 
57
56
  // transfer tokens for gas
58
57
  await writeContractSync(client, {
59
- abi: tip20Abi,
60
- address: usdAddress,
58
+ abi: Abis.tip20,
59
+ address: Addresses.defaultFeeToken,
61
60
  functionName: 'transfer',
62
61
  args: [account2.address, parseEther('1')],
63
62
  })
@@ -90,7 +89,7 @@ describe('approve', () => {
90
89
  // approve
91
90
  const { receipt, ...result } = await actions.token.approveSync(client, {
92
91
  amount: parseEther('100'),
93
- token: usdAddress,
92
+ token: Addresses.defaultFeeToken,
94
93
  spender: account2.address,
95
94
  })
96
95
  expect(receipt).toBeDefined()
@@ -106,7 +105,7 @@ describe('approve', () => {
106
105
  {
107
106
  // check allowance
108
107
  const allowance = await actions.token.getAllowance(client, {
109
- token: usdAddress,
108
+ token: Addresses.defaultFeeToken,
110
109
  spender: account2.address,
111
110
  })
112
111
  expect(allowance).toBe(parseEther('100'))
@@ -114,8 +113,8 @@ describe('approve', () => {
114
113
 
115
114
  // transfer tokens for gas
116
115
  await writeContractSync(client, {
117
- abi: tip20Abi,
118
- address: usdAddress,
116
+ abi: Abis.tip20,
117
+ address: Addresses.defaultFeeToken,
119
118
  functionName: 'transfer',
120
119
  args: [account2.address, parseEther('1')],
121
120
  })
@@ -126,14 +125,14 @@ describe('approve', () => {
126
125
  account: account2,
127
126
  from: account.address,
128
127
  to: '0x0000000000000000000000000000000000000001',
129
- token: usdAddress,
128
+ token: Addresses.defaultFeeToken,
130
129
  })
131
130
 
132
131
  {
133
132
  // verify updated allowance
134
133
  const allowance = await actions.token.getAllowance(client, {
135
134
  spender: account2.address,
136
- token: usdAddress,
135
+ token: Addresses.defaultFeeToken,
137
136
  })
138
137
  expect(allowance).toBe(parseEther('50'))
139
138
  }
@@ -141,7 +140,7 @@ describe('approve', () => {
141
140
  // verify balance
142
141
  const balance = await actions.token.getBalance(client, {
143
142
  account: '0x0000000000000000000000000000000000000001',
144
- token: usdAddress,
143
+ token: Addresses.defaultFeeToken,
145
144
  })
146
145
  expect(balance).toBe(parseEther('50'))
147
146
  })
@@ -151,7 +150,7 @@ describe('approve', () => {
151
150
  // approve
152
151
  const { receipt, ...result } = await actions.token.approveSync(client, {
153
152
  amount: parseEther('100'),
154
- token: usdId,
153
+ token: TokenIds.defaultFeeToken,
155
154
  spender: account2.address,
156
155
  })
157
156
  expect(receipt).toBeDefined()
@@ -167,7 +166,7 @@ describe('approve', () => {
167
166
  {
168
167
  // check allowance
169
168
  const allowance = await actions.token.getAllowance(client, {
170
- token: usdId,
169
+ token: TokenIds.defaultFeeToken,
171
170
  spender: account2.address,
172
171
  })
173
172
  expect(allowance).toBe(parseEther('100'))
@@ -175,8 +174,8 @@ describe('approve', () => {
175
174
 
176
175
  // transfer tokens for gas
177
176
  await writeContractSync(client, {
178
- abi: tip20Abi,
179
- address: usdAddress,
177
+ abi: Abis.tip20,
178
+ address: Addresses.defaultFeeToken,
180
179
  functionName: 'transfer',
181
180
  args: [account2.address, parseEther('1')],
182
181
  })
@@ -187,14 +186,14 @@ describe('approve', () => {
187
186
  account: account2,
188
187
  from: account.address,
189
188
  to: '0x0000000000000000000000000000000000000001',
190
- token: usdId,
189
+ token: TokenIds.defaultFeeToken,
191
190
  })
192
191
 
193
192
  {
194
193
  // verify updated allowance
195
194
  const allowance = await actions.token.getAllowance(client, {
196
195
  spender: account2.address,
197
- token: usdId,
196
+ token: TokenIds.defaultFeeToken,
198
197
  })
199
198
  expect(allowance).toBe(parseEther('50'))
200
199
  }
@@ -202,7 +201,7 @@ describe('approve', () => {
202
201
  // verify balance
203
202
  const balance = await actions.token.getBalance(client, {
204
203
  account: '0x0000000000000000000000000000000000000001',
205
- token: usdId,
204
+ token: TokenIds.defaultFeeToken,
206
205
  })
207
206
  expect(balance).toBe(parseEther('50'))
208
207
  })
@@ -217,15 +216,15 @@ describe('create', () => {
217
216
  })
218
217
 
219
218
  expect(result).toMatchInlineSnapshot(`
220
- {
221
- "admin": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
222
- "currency": "USD",
223
- "name": "Test USD",
224
- "symbol": "TUSD",
225
- "token": "0x20C0000000000000000000000000000000000001",
226
- "tokenId": 1n,
227
- }
228
- `)
219
+ {
220
+ "admin": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
221
+ "currency": "USD",
222
+ "name": "Test USD",
223
+ "symbol": "TUSD",
224
+ "token": "0x20C0000000000000000000000000000000000004",
225
+ "tokenId": 4n,
226
+ }
227
+ `)
229
228
  expect(receipt).toBeDefined()
230
229
 
231
230
  const code = await getCode(client, {
@@ -239,8 +238,8 @@ describe('getAllowance', () => {
239
238
  test('default', async () => {
240
239
  // First, approve some allowance
241
240
  await writeContractSync(client, {
242
- abi: tip20Abi,
243
- address: usdAddress,
241
+ abi: Abis.tip20,
242
+ address: Addresses.defaultFeeToken,
244
243
  functionName: 'approve',
245
244
  args: [account2.address, parseEther('50')],
246
245
  })
@@ -256,7 +255,7 @@ describe('getAllowance', () => {
256
255
  {
257
256
  // Test with token address
258
257
  const allowance = await actions.token.getAllowance(client, {
259
- token: usdAddress,
258
+ token: Addresses.defaultFeeToken,
260
259
  spender: account2.address,
261
260
  })
262
261
 
@@ -266,7 +265,7 @@ describe('getAllowance', () => {
266
265
  {
267
266
  // Test with token ID
268
267
  const allowance = await actions.token.getAllowance(client, {
269
- token: usdId,
268
+ token: TokenIds.defaultFeeToken,
270
269
  spender: account2.address,
271
270
  })
272
271
 
@@ -286,7 +285,7 @@ describe('getBalance', () => {
286
285
  {
287
286
  // Test with token address
288
287
  const balance = await actions.token.getBalance(client, {
289
- token: usdAddress,
288
+ token: Addresses.defaultFeeToken,
290
289
  })
291
290
 
292
291
  expect(balance).toBeGreaterThan(0n)
@@ -295,7 +294,7 @@ describe('getBalance', () => {
295
294
  {
296
295
  // Test with token ID & different account
297
296
  const balance = await actions.token.getBalance(client, {
298
- token: usdId,
297
+ token: TokenIds.defaultFeeToken,
299
298
  account: Hex.random(20),
300
299
  })
301
300
 
@@ -312,11 +311,12 @@ describe('getMetadata', () => {
312
311
  {
313
312
  "currency": "USD",
314
313
  "decimals": 6,
315
- "name": "TestUSD",
314
+ "name": "AlphaUSD",
316
315
  "paused": false,
316
+ "quoteToken": "0x20C0000000000000000000000000000000000000",
317
317
  "supplyCap": 115792089237316195423570985008687907853269984665640564039457584007913129639935n,
318
- "symbol": "TestUSD",
319
- "totalSupply": 340282366920938463647842048168863727605n,
318
+ "symbol": "AlphaUSD",
319
+ "totalSupply": 340282366920938463481821351505477763070n,
320
320
  "transferPolicyId": 1n,
321
321
  }
322
322
  `)
@@ -339,6 +339,7 @@ describe('getMetadata', () => {
339
339
  "decimals": 6,
340
340
  "name": "Test USD",
341
341
  "paused": false,
342
+ "quoteToken": "0x20C0000000000000000000000000000000000000",
342
343
  "supplyCap": 115792089237316195423570985008687907853269984665640564039457584007913129639935n,
343
344
  "symbol": "TUSD",
344
345
  "totalSupply": 0n,
@@ -347,6 +348,22 @@ describe('getMetadata', () => {
347
348
  `)
348
349
  })
349
350
 
351
+ test('behavior: quote token', async () => {
352
+ const metadata = await actions.token.getMetadata(client, {
353
+ token: TokenIds.defaultQuoteToken,
354
+ })
355
+
356
+ expect(metadata).toMatchInlineSnapshot(`
357
+ {
358
+ "currency": "USD",
359
+ "decimals": 6,
360
+ "name": "linkingUSD",
361
+ "symbol": "linkingUSD",
362
+ "totalSupply": 0n,
363
+ }
364
+ `)
365
+ })
366
+
350
367
  test('behavior: custom token (id)', async () => {
351
368
  const token = await actions.token.createSync(client, {
352
369
  currency: 'USD',
@@ -364,6 +381,7 @@ describe('getMetadata', () => {
364
381
  "decimals": 6,
365
382
  "name": "Test USD",
366
383
  "paused": false,
384
+ "quoteToken": "0x20C0000000000000000000000000000000000000",
367
385
  "supplyCap": 115792089237316195423570985008687907853269984665640564039457584007913129639935n,
368
386
  "symbol": "TUSD",
369
387
  "totalSupply": 0n,
@@ -573,8 +591,8 @@ describe('transfer', () => {
573
591
 
574
592
  // Transfer tokens for gas
575
593
  await writeContractSync(client, {
576
- abi: tip20Abi,
577
- address: usdAddress,
594
+ abi: Abis.tip20,
595
+ address: Addresses.defaultFeeToken,
578
596
  functionName: 'transfer',
579
597
  args: [account2.address, parseEther('1')],
580
598
  })
@@ -684,8 +702,8 @@ describe('burn', () => {
684
702
 
685
703
  // Transfer gas to account2
686
704
  await writeContractSync(client, {
687
- abi: tip20Abi,
688
- address: usdAddress,
705
+ abi: Abis.tip20,
706
+ address: Addresses.defaultFeeToken,
689
707
  functionName: 'transfer',
690
708
  args: [account2.address, parseEther('1')],
691
709
  })
@@ -748,8 +766,8 @@ describe('pause', () => {
748
766
 
749
767
  // Transfer gas
750
768
  await writeContractSync(client, {
751
- abi: tip20Abi,
752
- address: usdAddress,
769
+ abi: Abis.tip20,
770
+ address: Addresses.defaultFeeToken,
753
771
  functionName: 'transfer',
754
772
  args: [account2.address, parseEther('1')],
755
773
  })
@@ -815,8 +833,8 @@ describe('pause', () => {
815
833
 
816
834
  // Transfer gas to account2
817
835
  await writeContractSync(client, {
818
- abi: tip20Abi,
819
- address: usdAddress,
836
+ abi: Abis.tip20,
837
+ address: Addresses.defaultFeeToken,
820
838
  functionName: 'transfer',
821
839
  args: [account2.address, parseEther('1')],
822
840
  })
@@ -916,8 +934,8 @@ describe('unpause', () => {
916
934
 
917
935
  // Transfer gas to account2
918
936
  await writeContractSync(client, {
919
- abi: tip20Abi,
920
- address: usdAddress,
937
+ abi: Abis.tip20,
938
+ address: Addresses.defaultFeeToken,
921
939
  functionName: 'transfer',
922
940
  args: [account2.address, parseEther('1')],
923
941
  })
@@ -1001,8 +1019,8 @@ describe('unpause', () => {
1001
1019
 
1002
1020
  // Transfer gas to account2
1003
1021
  await writeContractSync(client, {
1004
- abi: tip20Abi,
1005
- address: usdAddress,
1022
+ abi: Abis.tip20,
1023
+ address: Addresses.defaultFeeToken,
1006
1024
  functionName: 'transfer',
1007
1025
  args: [account2.address, parseEther('1')],
1008
1026
  })
@@ -1044,15 +1062,15 @@ describe('unpause', () => {
1044
1062
 
1045
1063
  // Transfer gas to both accounts
1046
1064
  await writeContractSync(client, {
1047
- abi: tip20Abi,
1048
- address: usdAddress,
1065
+ abi: Abis.tip20,
1066
+ address: Addresses.defaultFeeToken,
1049
1067
  functionName: 'transfer',
1050
1068
  args: [account2.address, parseEther('1')],
1051
1069
  })
1052
1070
 
1053
1071
  await writeContractSync(client, {
1054
- abi: tip20Abi,
1055
- address: usdAddress,
1072
+ abi: Abis.tip20,
1073
+ address: Addresses.defaultFeeToken,
1056
1074
  functionName: 'transfer',
1057
1075
  args: [account3.address, parseEther('1')],
1058
1076
  })
@@ -1085,6 +1103,230 @@ describe('unpause', () => {
1085
1103
  })
1086
1104
  })
1087
1105
 
1106
+ describe('updateQuoteToken', () => {
1107
+ test('default', async () => {
1108
+ // Create two tokens - one to be the new quote token
1109
+ const { token: quoteTokenAddress } = await actions.token.createSync(
1110
+ client,
1111
+ {
1112
+ currency: 'USD',
1113
+ name: 'Quote Token',
1114
+ symbol: 'LINK',
1115
+ },
1116
+ )
1117
+
1118
+ const { token: address } = await actions.token.createSync(client, {
1119
+ currency: 'USD',
1120
+ name: 'Main Token',
1121
+ symbol: 'MAIN',
1122
+ })
1123
+
1124
+ // Update quote token
1125
+ const { receipt: updateReceipt, ...updateResult } =
1126
+ await actions.token.updateQuoteTokenSync(client, {
1127
+ token: address,
1128
+ quoteToken: quoteTokenAddress,
1129
+ })
1130
+
1131
+ expect(updateReceipt).toBeDefined()
1132
+ expect(updateResult).toMatchInlineSnapshot(`
1133
+ {
1134
+ "newQuoteToken": "0x20C0000000000000000000000000000000000004",
1135
+ "updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
1136
+ }
1137
+ `)
1138
+
1139
+ // Verify the event was emitted with correct quote token
1140
+ expect(updateResult.newQuoteToken).toBe(quoteTokenAddress)
1141
+ })
1142
+
1143
+ test('behavior: requires admin role', async () => {
1144
+ // Create quote token
1145
+ const { token: quoteTokenAddress } = await actions.token.createSync(
1146
+ client,
1147
+ {
1148
+ currency: 'USD',
1149
+ name: 'Quote Token 2',
1150
+ symbol: 'LINK2',
1151
+ },
1152
+ )
1153
+
1154
+ // Create main token where client.account is admin
1155
+ const { token: address } = await actions.token.createSync(client, {
1156
+ currency: 'USD',
1157
+ name: 'Restricted Token',
1158
+ symbol: 'RESTR',
1159
+ })
1160
+
1161
+ // Transfer gas to account2
1162
+ await writeContractSync(client, {
1163
+ abi: Abis.tip20,
1164
+ address: Addresses.defaultFeeToken,
1165
+ functionName: 'transfer',
1166
+ args: [account2.address, parseEther('1')],
1167
+ })
1168
+
1169
+ // Try to update quote token from account2 (not admin) - should fail
1170
+ await expect(
1171
+ actions.token.updateQuoteTokenSync(client, {
1172
+ account: account2,
1173
+ token: address,
1174
+ quoteToken: quoteTokenAddress,
1175
+ }),
1176
+ ).rejects.toThrow()
1177
+ })
1178
+
1179
+ test('behavior: with token ID', async () => {
1180
+ // Create quote token
1181
+ const { token: quoteTokenAddress } = await actions.token.createSync(
1182
+ client,
1183
+ {
1184
+ currency: 'USD',
1185
+ name: 'Quote Token 3',
1186
+ symbol: 'LINK3',
1187
+ },
1188
+ )
1189
+
1190
+ // Create main token using token ID
1191
+ const { tokenId: mainTokenId } = await actions.token.createSync(client, {
1192
+ currency: 'USD',
1193
+ name: 'Main Token ID',
1194
+ symbol: 'MAINID',
1195
+ })
1196
+
1197
+ // Update quote token using token ID for main token, address for quote token
1198
+ const { receipt: updateReceipt, ...updateResult } =
1199
+ await actions.token.updateQuoteTokenSync(client, {
1200
+ token: mainTokenId,
1201
+ quoteToken: quoteTokenAddress,
1202
+ })
1203
+
1204
+ expect(updateReceipt.status).toBe('success')
1205
+ expect(updateResult.updater).toBe(client.account.address)
1206
+ })
1207
+ })
1208
+
1209
+ describe('finalizeUpdateQuoteToken', () => {
1210
+ test('default', async () => {
1211
+ // Create quote token
1212
+ const { token: quoteTokenAddress } = await actions.token.createSync(
1213
+ client,
1214
+ {
1215
+ currency: 'USD',
1216
+ name: 'Quote Token',
1217
+ symbol: 'LINK',
1218
+ },
1219
+ )
1220
+
1221
+ // Create main token
1222
+ const { token: address } = await actions.token.createSync(client, {
1223
+ currency: 'USD',
1224
+ name: 'Main Token',
1225
+ symbol: 'MAIN',
1226
+ })
1227
+
1228
+ // Update quote token (step 1)
1229
+ await actions.token.updateQuoteTokenSync(client, {
1230
+ token: address,
1231
+ quoteToken: quoteTokenAddress,
1232
+ })
1233
+
1234
+ // Finalize the update (step 2)
1235
+ const { receipt: finalizeReceipt, ...finalizeResult } =
1236
+ await actions.token.finalizeUpdateQuoteTokenSync(client, {
1237
+ token: address,
1238
+ })
1239
+
1240
+ expect(finalizeReceipt).toBeDefined()
1241
+ expect(finalizeResult).toMatchInlineSnapshot(`
1242
+ {
1243
+ "newQuoteToken": "0x20C0000000000000000000000000000000000004",
1244
+ "updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
1245
+ }
1246
+ `)
1247
+
1248
+ // Verify the quote token was updated
1249
+ expect(finalizeResult.newQuoteToken).toBe(quoteTokenAddress)
1250
+
1251
+ // Verify it's reflected in metadata
1252
+ const metadata = await actions.token.getMetadata(client, {
1253
+ token: address,
1254
+ })
1255
+ expect(metadata.quoteToken).toBe(quoteTokenAddress)
1256
+ })
1257
+
1258
+ test('behavior: requires admin role', async () => {
1259
+ // Create quote token
1260
+ const { token: quoteTokenAddress } = await actions.token.createSync(
1261
+ client,
1262
+ {
1263
+ currency: 'USD',
1264
+ name: 'Quote Token 2',
1265
+ symbol: 'LINK2',
1266
+ },
1267
+ )
1268
+
1269
+ // Create main token
1270
+ const { token: address } = await actions.token.createSync(client, {
1271
+ currency: 'USD',
1272
+ name: 'Restricted Token',
1273
+ symbol: 'RESTR',
1274
+ })
1275
+
1276
+ // Update quote token as admin
1277
+ await actions.token.updateQuoteTokenSync(client, {
1278
+ token: address,
1279
+ quoteToken: quoteTokenAddress,
1280
+ })
1281
+
1282
+ // Transfer gas to account2
1283
+ await writeContractSync(client, {
1284
+ abi: Abis.tip20,
1285
+ address: Addresses.defaultFeeToken,
1286
+ functionName: 'transfer',
1287
+ args: [account2.address, parseEther('1')],
1288
+ })
1289
+
1290
+ // Try to finalize as non-admin - should fail
1291
+ await expect(
1292
+ actions.token.finalizeUpdateQuoteTokenSync(client, {
1293
+ account: account2,
1294
+ token: address,
1295
+ }),
1296
+ ).rejects.toThrow()
1297
+ })
1298
+
1299
+ test('behavior: prevents circular references', async () => {
1300
+ // Create token B
1301
+ const { token: tokenBAddress } = await actions.token.createSync(client, {
1302
+ currency: 'USD',
1303
+ name: 'Token B',
1304
+ symbol: 'TKB',
1305
+ })
1306
+
1307
+ // Create token A that links to token B
1308
+ const { token: tokenAAddress } = await actions.token.createSync(client, {
1309
+ currency: 'USD',
1310
+ name: 'Token A',
1311
+ symbol: 'TKA',
1312
+ quoteToken: tokenBAddress,
1313
+ })
1314
+
1315
+ // Try to make token B link to token A (would create A -> B -> A loop)
1316
+ await actions.token.updateQuoteTokenSync(client, {
1317
+ token: tokenBAddress,
1318
+ quoteToken: tokenAAddress,
1319
+ })
1320
+
1321
+ // Finalize should fail due to circular reference detection
1322
+ await expect(
1323
+ actions.token.finalizeUpdateQuoteTokenSync(client, {
1324
+ token: tokenBAddress,
1325
+ }),
1326
+ ).rejects.toThrow()
1327
+ })
1328
+ })
1329
+
1088
1330
  describe.todo('setTokenSupplyCap')
1089
1331
 
1090
1332
  describe('hasRole', () => {
@@ -1422,8 +1664,8 @@ describe('watchCreate', () => {
1422
1664
  "currency": "USD",
1423
1665
  "name": "Watch Test Token 1",
1424
1666
  "symbol": "WATCH1",
1425
- "token": "0x20C0000000000000000000000000000000000001",
1426
- "tokenId": 1n,
1667
+ "token": "0x20C0000000000000000000000000000000000004",
1668
+ "tokenId": 4n,
1427
1669
  }
1428
1670
  `)
1429
1671
  expect(receivedTokens.at(1)!.args).toMatchInlineSnapshot(`
@@ -1432,8 +1674,8 @@ describe('watchCreate', () => {
1432
1674
  "currency": "USD",
1433
1675
  "name": "Watch Test Token 2",
1434
1676
  "symbol": "WATCH2",
1435
- "token": "0x20C0000000000000000000000000000000000002",
1436
- "tokenId": 2n,
1677
+ "token": "0x20c0000000000000000000000000000000000005",
1678
+ "tokenId": 5n,
1437
1679
  }
1438
1680
  `)
1439
1681
  } finally {
@@ -1503,8 +1745,8 @@ describe('watchCreate', () => {
1503
1745
  "currency": "USD",
1504
1746
  "name": "Filtered Watch Token 2",
1505
1747
  "symbol": "FWATCH2",
1506
- "token": "0x20C0000000000000000000000000000000000003",
1507
- "tokenId": 3n,
1748
+ "token": "0x20C0000000000000000000000000000000000006",
1749
+ "tokenId": 6n,
1508
1750
  }
1509
1751
  `)
1510
1752
 
@@ -1856,8 +2098,8 @@ describe('watchBurn', () => {
1856
2098
 
1857
2099
  // Transfer gas to account2
1858
2100
  await writeContractSync(client, {
1859
- abi: tip20Abi,
1860
- address: usdAddress,
2101
+ abi: Abis.tip20,
2102
+ address: Addresses.defaultFeeToken,
1861
2103
  functionName: 'transfer',
1862
2104
  args: [account2.address, parseEther('1')],
1863
2105
  })
@@ -1950,8 +2192,8 @@ describe('watchBurn', () => {
1950
2192
 
1951
2193
  // Transfer gas to account2
1952
2194
  await writeContractSync(client, {
1953
- abi: tip20Abi,
1954
- address: usdAddress,
2195
+ abi: Abis.tip20,
2196
+ address: Addresses.defaultFeeToken,
1955
2197
  functionName: 'transfer',
1956
2198
  args: [account2.address, parseEther('1')],
1957
2199
  })
@@ -2360,3 +2602,116 @@ describe('watchTransfer', () => {
2360
2602
  }
2361
2603
  })
2362
2604
  })
2605
+
2606
+ describe('watchUpdateQuoteToken', () => {
2607
+ test('default', async () => {
2608
+ // Create quote token
2609
+ const { token: quoteTokenAddress } = await actions.token.createSync(
2610
+ client,
2611
+ {
2612
+ currency: 'USD',
2613
+ name: 'Watch Quote Token',
2614
+ symbol: 'WLINK',
2615
+ },
2616
+ )
2617
+
2618
+ // Create main token
2619
+ const { token: address } = await actions.token.createSync(client, {
2620
+ currency: 'USD',
2621
+ name: 'Watch Main Token',
2622
+ symbol: 'WMAIN',
2623
+ })
2624
+
2625
+ const receivedUpdates: Array<{
2626
+ args: actions.token.watchUpdateQuoteToken.Args
2627
+ log: actions.token.watchUpdateQuoteToken.Log
2628
+ }> = []
2629
+
2630
+ // Start watching for quote token update events
2631
+ const unwatch = actions.token.watchUpdateQuoteToken(client, {
2632
+ token: address,
2633
+ onUpdateQuoteToken: (args, log) => {
2634
+ receivedUpdates.push({ args, log })
2635
+ },
2636
+ })
2637
+
2638
+ try {
2639
+ // Step 1: Update quote token (should emit UpdateQuoteToken)
2640
+ await actions.token.updateQuoteTokenSync(client, {
2641
+ token: address,
2642
+ quoteToken: quoteTokenAddress,
2643
+ })
2644
+
2645
+ // Step 2: Finalize the update (should emit QuoteTokenUpdateFinalized)
2646
+ await actions.token.finalizeUpdateQuoteTokenSync(client, {
2647
+ token: address,
2648
+ })
2649
+
2650
+ await setTimeout(100)
2651
+
2652
+ // Should receive 2 events: one for update, one for finalized
2653
+ expect(receivedUpdates).toHaveLength(2)
2654
+
2655
+ // First event: update proposed (not finalized)
2656
+ expect(receivedUpdates.at(0)!.args.finalized).toBe(false)
2657
+ expect(receivedUpdates.at(0)!.args.newQuoteToken).toBe(quoteTokenAddress)
2658
+ expect(receivedUpdates.at(0)!.args.updater).toBe(client.account.address)
2659
+
2660
+ // Second event: update finalized
2661
+ expect(receivedUpdates.at(1)!.args.finalized).toBe(true)
2662
+ expect(receivedUpdates.at(1)!.args.newQuoteToken).toBe(quoteTokenAddress)
2663
+ expect(receivedUpdates.at(1)!.args.updater).toBe(client.account.address)
2664
+ } finally {
2665
+ if (unwatch) unwatch()
2666
+ }
2667
+ })
2668
+
2669
+ test('behavior: only proposed updates', async () => {
2670
+ // Create quote token
2671
+ const { token: quoteTokenAddress } = await actions.token.createSync(
2672
+ client,
2673
+ {
2674
+ currency: 'USD',
2675
+ name: 'Proposed Quote Token',
2676
+ symbol: 'PLINK',
2677
+ },
2678
+ )
2679
+
2680
+ // Create main token
2681
+ const { token: address } = await actions.token.createSync(client, {
2682
+ currency: 'USD',
2683
+ name: 'Proposed Main Token',
2684
+ symbol: 'PMAIN',
2685
+ })
2686
+
2687
+ const receivedUpdates: Array<{
2688
+ args: actions.token.watchUpdateQuoteToken.Args
2689
+ log: actions.token.watchUpdateQuoteToken.Log
2690
+ }> = []
2691
+
2692
+ // Start watching
2693
+ const unwatch = actions.token.watchUpdateQuoteToken(client, {
2694
+ token: address,
2695
+ onUpdateQuoteToken: (args, log) => {
2696
+ receivedUpdates.push({ args, log })
2697
+ },
2698
+ })
2699
+
2700
+ try {
2701
+ // Only update (don't finalize)
2702
+ await actions.token.updateQuoteTokenSync(client, {
2703
+ token: address,
2704
+ quoteToken: quoteTokenAddress,
2705
+ })
2706
+
2707
+ await setTimeout(100)
2708
+
2709
+ // Should only receive 1 event (not finalized)
2710
+ expect(receivedUpdates).toHaveLength(1)
2711
+ expect(receivedUpdates.at(0)!.args.finalized).toBe(false)
2712
+ expect(receivedUpdates.at(0)!.args.newQuoteToken).toBe(quoteTokenAddress)
2713
+ } finally {
2714
+ if (unwatch) unwatch()
2715
+ }
2716
+ })
2717
+ })