tempo.ts 0.0.5 → 0.1.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 (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 +3251 -707
  59. package/dist/viem/Actions/token.d.ts.map +1 -0
  60. package/dist/viem/{actions → Actions}/token.js +420 -88
  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 +406 -67
  130. package/src/viem/{actions → Actions}/token.ts +675 -144
  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,13 +1,11 @@
1
1
  import { setTimeout } from 'node:timers/promises'
2
- import * as actions from 'tempo.ts/viem/actions'
2
+ import { Abis, Addresses, createTempoClient } from 'tempo.ts/viem'
3
3
  import { parseEther, publicActions } from 'viem'
4
4
  import { mnemonicToAccount } from 'viem/accounts'
5
5
  import { writeContractSync } from 'viem/actions'
6
6
  import { describe, expect, test } from 'vitest'
7
7
  import { tempoTest } from '../../../test/viem/config.js'
8
- import { tip20Abi } from '../abis.js'
9
- import { usdAddress } from '../addresses.js'
10
- import { createTempoClient } from '../client.js'
8
+ import * as actions from './index.js'
11
9
 
12
10
  const account = mnemonicToAccount(
13
11
  'test test test test test test test test test test test junk',
@@ -31,14 +29,14 @@ describe('getUserToken', () => {
31
29
  test('default', async () => {
32
30
  // Fund accounts
33
31
  await writeContractSync(client, {
34
- abi: tip20Abi,
35
- address: usdAddress,
32
+ abi: Abis.tip20,
33
+ address: Addresses.defaultFeeToken,
36
34
  functionName: 'transfer',
37
35
  args: [account2.address, parseEther('100')],
38
36
  })
39
37
  await writeContractSync(client, {
40
- abi: tip20Abi,
41
- address: usdAddress,
38
+ abi: Abis.tip20,
39
+ address: Addresses.defaultFeeToken,
42
40
  functionName: 'transfer',
43
41
  args: [account3.address, parseEther('100')],
44
42
  })
@@ -60,8 +58,8 @@ describe('getUserToken', () => {
60
58
  await actions.fee.getUserToken(client, { account }),
61
59
  ).toMatchInlineSnapshot(`
62
60
  {
63
- "address": "0x20C0000000000000000000000000000000000000",
64
- "id": 0n,
61
+ "address": "0x20C0000000000000000000000000000000000001",
62
+ "id": 1n,
65
63
  }
66
64
  `)
67
65
  expect(
@@ -87,21 +85,21 @@ describe('setUserToken', () => {
87
85
  test('default', async () => {
88
86
  expect(await actions.fee.getUserToken(client)).toMatchInlineSnapshot(
89
87
  `
90
- {
91
- "address": "0x20C0000000000000000000000000000000000000",
92
- "id": 0n,
93
- }
94
- `,
88
+ {
89
+ "address": "0x20C0000000000000000000000000000000000001",
90
+ "id": 1n,
91
+ }
92
+ `,
95
93
  )
96
94
 
97
95
  const { receipt: setReceipt, ...setResult } =
98
96
  await actions.fee.setUserTokenSync(client, {
99
- token: '0x20c0000000000000000000000000000000000001',
97
+ token: 2n,
100
98
  })
101
99
  expect(setReceipt).toBeDefined()
102
100
  expect(setResult).toMatchInlineSnapshot(`
103
101
  {
104
- "token": "0x20C0000000000000000000000000000000000001",
102
+ "token": "0x20C0000000000000000000000000000000000002",
105
103
  "user": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
106
104
  }
107
105
  `)
@@ -109,32 +107,32 @@ describe('setUserToken', () => {
109
107
  expect(await actions.fee.getUserToken(client, {})).toMatchInlineSnapshot(
110
108
  `
111
109
  {
112
- "address": "0x20C0000000000000000000000000000000000001",
113
- "id": 1n,
110
+ "address": "0x20C0000000000000000000000000000000000002",
111
+ "id": 2n,
114
112
  }
115
113
  `,
116
114
  )
117
115
 
118
116
  const { receipt: resetReceipt, ...resetResult } =
119
117
  await actions.fee.setUserTokenSync(client, {
120
- feeToken: 0n,
121
- token: 0n,
118
+ feeToken: 1n,
119
+ token: 1n,
122
120
  })
123
121
  expect(resetReceipt).toBeDefined()
124
122
  expect(resetResult).toMatchInlineSnapshot(`
125
123
  {
126
- "token": "0x20C0000000000000000000000000000000000000",
124
+ "token": "0x20C0000000000000000000000000000000000001",
127
125
  "user": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
128
126
  }
129
127
  `)
130
128
 
131
129
  expect(await actions.fee.getUserToken(client, {})).toMatchInlineSnapshot(
132
130
  `
133
- {
134
- "address": "0x20C0000000000000000000000000000000000000",
135
- "id": 0n,
136
- }
137
- `,
131
+ {
132
+ "address": "0x20C0000000000000000000000000000000000001",
133
+ "id": 1n,
134
+ }
135
+ `,
138
136
  )
139
137
  })
140
138
  })
@@ -156,8 +154,8 @@ describe('watchSetUserToken', () => {
156
154
  try {
157
155
  // Set token for account2
158
156
  await writeContractSync(client, {
159
- abi: tip20Abi,
160
- address: usdAddress,
157
+ abi: Abis.tip20,
158
+ address: Addresses.defaultFeeToken,
161
159
  functionName: 'transfer',
162
160
  args: [account2.address, parseEther('1')],
163
161
  })
@@ -169,8 +167,8 @@ describe('watchSetUserToken', () => {
169
167
 
170
168
  // Set token for account3
171
169
  await writeContractSync(client, {
172
- abi: tip20Abi,
173
- address: usdAddress,
170
+ abi: Abis.tip20,
171
+ address: Addresses.defaultFeeToken,
174
172
  functionName: 'transfer',
175
173
  args: [account3.address, parseEther('1')],
176
174
  })
@@ -220,15 +218,15 @@ describe('watchSetUserToken', () => {
220
218
  try {
221
219
  // Transfer gas to accounts
222
220
  await writeContractSync(client, {
223
- abi: tip20Abi,
224
- address: usdAddress,
221
+ abi: Abis.tip20,
222
+ address: Addresses.defaultFeeToken,
225
223
  functionName: 'transfer',
226
224
  args: [account2.address, parseEther('1')],
227
225
  })
228
226
 
229
227
  await writeContractSync(client, {
230
- abi: tip20Abi,
231
- address: usdAddress,
228
+ abi: Abis.tip20,
229
+ address: Addresses.defaultFeeToken,
232
230
  functionName: 'transfer',
233
231
  args: [account3.address, parseEther('1')],
234
232
  })
@@ -248,7 +246,7 @@ describe('watchSetUserToken', () => {
248
246
  // Set token for account2 again (should be captured)
249
247
  await actions.fee.setUserTokenSync(client, {
250
248
  account: account2,
251
- feeToken: 0n,
249
+ feeToken: 1n,
252
250
  token: 2n,
253
251
  })
254
252
 
@@ -22,14 +22,14 @@ import {
22
22
  } from 'viem/actions'
23
23
  import type { Compute, UnionOmit } from '../../internal/types.js'
24
24
  import * as TokenId from '../../ox/TokenId.js'
25
- import { feeManagerAbi } from '../abis.js'
26
- import { feeManagerAddress } from '../addresses.js'
25
+ import * as Abis from '../Abis.js'
26
+ import * as Addresses from '../Addresses.js'
27
27
  import type {
28
28
  GetAccountParameter,
29
29
  ReadParameters,
30
30
  WriteParameters,
31
- } from '../types.js'
32
- import { defineCall } from '../utils.js'
31
+ } from '../internal/types.js'
32
+ import { defineCall } from '../internal/utils.js'
33
33
 
34
34
  /**
35
35
  * Gets the user's default fee token.
@@ -100,8 +100,8 @@ export namespace getUserToken {
100
100
  export function call(args: Args) {
101
101
  const { account } = args
102
102
  return defineCall({
103
- address: feeManagerAddress,
104
- abi: feeManagerAbi,
103
+ address: Addresses.feeManager,
104
+ abi: Abis.feeManager,
105
105
  args: [account],
106
106
  functionName: 'userTokens',
107
107
  })
@@ -166,9 +166,10 @@ export namespace setUserToken {
166
166
  client: Client<Transport, chain, account>,
167
167
  parameters: setUserToken.Parameters<chain, account>,
168
168
  ): Promise<ReturnType<action>> {
169
- const call = setUserToken.call(parameters)
169
+ const { token, ...rest } = parameters
170
+ const call = setUserToken.call({ token })
170
171
  return (await action(client, {
171
- ...parameters,
172
+ ...rest,
172
173
  ...call,
173
174
  } as never)) as never
174
175
  }
@@ -210,8 +211,8 @@ export namespace setUserToken {
210
211
  export function call(args: Args) {
211
212
  const { token } = args
212
213
  return defineCall({
213
- address: feeManagerAddress,
214
- abi: feeManagerAbi,
214
+ address: Addresses.feeManager,
215
+ abi: Abis.feeManager,
215
216
  functionName: 'setUserToken',
216
217
  args: [TokenId.toAddress(token)],
217
218
  })
@@ -219,7 +220,7 @@ export namespace setUserToken {
219
220
 
220
221
  export function extractEvent(logs: Log[]) {
221
222
  const [log] = parseEventLogs({
222
- abi: feeManagerAbi,
223
+ abi: Abis.feeManager,
223
224
  logs,
224
225
  eventName: 'UserTokenSet',
225
226
  strict: true,
@@ -283,7 +284,7 @@ export namespace setUserTokenSync {
283
284
 
284
285
  export type ReturnValue = Compute<
285
286
  GetEventArgs<
286
- typeof feeManagerAbi,
287
+ typeof Abis.feeManager,
287
288
  'UserTokenSet',
288
289
  { IndexedOnly: false; Required: true }
289
290
  > & {
@@ -327,8 +328,8 @@ export function watchSetUserToken<
327
328
  const { onUserTokenSet, ...rest } = parameters
328
329
  return watchContractEvent(client, {
329
330
  ...rest,
330
- address: feeManagerAddress,
331
- abi: feeManagerAbi,
331
+ address: Addresses.feeManager,
332
+ abi: Abis.feeManager,
332
333
  eventName: 'UserTokenSet',
333
334
  onLogs: (logs) => {
334
335
  for (const log of logs) onUserTokenSet(log.args, log)
@@ -339,7 +340,7 @@ export function watchSetUserToken<
339
340
 
340
341
  export declare namespace watchSetUserToken {
341
342
  export type Args = GetEventArgs<
342
- typeof feeManagerAbi,
343
+ typeof Abis.feeManager,
343
344
  'UserTokenSet',
344
345
  { IndexedOnly: false; Required: true }
345
346
  >
@@ -348,12 +349,12 @@ export declare namespace watchSetUserToken {
348
349
  bigint,
349
350
  number,
350
351
  false,
351
- ExtractAbiItem<typeof feeManagerAbi, 'UserTokenSet'>,
352
+ ExtractAbiItem<typeof Abis.feeManager, 'UserTokenSet'>,
352
353
  true
353
354
  >
354
355
 
355
356
  export type Parameters = UnionOmit<
356
- WatchContractEventParameters<typeof feeManagerAbi, 'UserTokenSet', true>,
357
+ WatchContractEventParameters<typeof Abis.feeManager, 'UserTokenSet', true>,
357
358
  'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'
358
359
  > & {
359
360
  /** Callback to invoke when a user token is set. */
@@ -1,4 +1,5 @@
1
1
  export * as amm from './amm.js'
2
+ export * as dex from './dex.js'
2
3
  export * as fee from './fee.js'
3
4
  export * as policy from './policy.js'
4
5
  export * as token from './token.js'
@@ -1,10 +1,10 @@
1
1
  import { setTimeout } from 'node:timers/promises'
2
- import * as actions from 'tempo.ts/viem/actions'
3
2
  import { publicActions } from 'viem'
4
3
  import { mnemonicToAccount } from 'viem/accounts'
5
4
  import { describe, expect, test } from 'vitest'
6
5
  import { tempoTest } from '../../../test/viem/config.js'
7
- import { createTempoClient } from '../client.js'
6
+ import { createTempoClient } from '../Client.js'
7
+ import * as actions from './index.js'
8
8
 
9
9
  const account = mnemonicToAccount(
10
10
  'test test test test test test test test test test test junk',
@@ -22,10 +22,10 @@ import {
22
22
  writeContractSync,
23
23
  } from 'viem/actions'
24
24
  import type { Compute, UnionOmit } from '../../internal/types.js'
25
- import { tip403RegistryAbi } from '../abis.js'
26
- import { tip403RegistryAddress } from '../addresses.js'
27
- import type { ReadParameters, WriteParameters } from '../types.js'
28
- import { defineCall } from '../utils.js'
25
+ import * as Abis from '../Abis.js'
26
+ import * as Addresses from '../Addresses.js'
27
+ import type { ReadParameters, WriteParameters } from '../internal/types.js'
28
+ import { defineCall } from '../internal/utils.js'
29
29
 
30
30
  export type PolicyType = 'whitelist' | 'blacklist'
31
31
 
@@ -161,19 +161,21 @@ export namespace create {
161
161
  */
162
162
  export function call(args: Args) {
163
163
  const { admin, type, addresses } = args
164
- const callArgs = addresses
165
- ? ({
164
+ const config = (() => {
165
+ if (addresses)
166
+ return {
166
167
  functionName: 'createPolicyWithAccounts',
167
168
  args: [admin, policyTypeMap[type], addresses],
168
- } as const)
169
- : ({
170
- functionName: 'createPolicy',
171
- args: [admin, policyTypeMap[type]],
172
- } as const)
169
+ } as const
170
+ return {
171
+ functionName: 'createPolicy',
172
+ args: [admin, policyTypeMap[type]],
173
+ } as const
174
+ })()
173
175
  return defineCall({
174
- address: tip403RegistryAddress,
175
- abi: tip403RegistryAbi,
176
- ...callArgs,
176
+ address: Addresses.tip403Registry,
177
+ abi: Abis.tip403Registry,
178
+ ...config,
177
179
  })
178
180
  }
179
181
 
@@ -185,7 +187,7 @@ export namespace create {
185
187
  */
186
188
  export function extractEvent(logs: Log[]) {
187
189
  const [log] = parseEventLogs({
188
- abi: tip403RegistryAbi,
190
+ abi: Abis.tip403Registry,
189
191
  logs,
190
192
  eventName: 'PolicyCreated',
191
193
  strict: true,
@@ -250,7 +252,7 @@ export namespace createSync {
250
252
 
251
253
  export type ReturnValue = Compute<
252
254
  GetEventArgs<
253
- typeof tip403RegistryAbi,
255
+ typeof Abis.tip403Registry,
254
256
  'PolicyCreated',
255
257
  { IndexedOnly: false; Required: true }
256
258
  > & {
@@ -320,9 +322,10 @@ export namespace setAdmin {
320
322
  client: Client<Transport, chain, account>,
321
323
  parameters: setAdmin.Parameters<chain, account>,
322
324
  ): Promise<ReturnType<action>> {
323
- const call = setAdmin.call(parameters)
325
+ const { policyId, admin, ...rest } = parameters
326
+ const call = setAdmin.call({ policyId, admin })
324
327
  return (await action(client, {
325
- ...parameters,
328
+ ...rest,
326
329
  ...call,
327
330
  } as never)) as never
328
331
  }
@@ -366,8 +369,8 @@ export namespace setAdmin {
366
369
  export function call(args: Args) {
367
370
  const { policyId, admin } = args
368
371
  return defineCall({
369
- address: tip403RegistryAddress,
370
- abi: tip403RegistryAbi,
372
+ address: Addresses.tip403Registry,
373
+ abi: Abis.tip403Registry,
371
374
  functionName: 'setPolicyAdmin',
372
375
  args: [policyId, admin],
373
376
  })
@@ -381,7 +384,7 @@ export namespace setAdmin {
381
384
  */
382
385
  export function extractEvent(logs: Log[]) {
383
386
  const [log] = parseEventLogs({
384
- abi: tip403RegistryAbi,
387
+ abi: Abis.tip403Registry,
385
388
  logs,
386
389
  eventName: 'PolicyAdminUpdated',
387
390
  strict: true,
@@ -446,7 +449,7 @@ export namespace setAdminSync {
446
449
 
447
450
  export type ReturnValue = Compute<
448
451
  GetEventArgs<
449
- typeof tip403RegistryAbi,
452
+ typeof Abis.tip403Registry,
450
453
  'PolicyAdminUpdated',
451
454
  { IndexedOnly: false; Required: true }
452
455
  > & {
@@ -519,10 +522,14 @@ export namespace modifyWhitelist {
519
522
  client: Client<Transport, chain, account>,
520
523
  parameters: modifyWhitelist.Parameters<chain, account>,
521
524
  ): Promise<ReturnType<action>> {
522
- const { address: targetAccount, ...rest } = parameters
523
- const call = modifyWhitelist.call({ ...rest, address: targetAccount })
525
+ const { address: targetAccount, allowed, policyId, ...rest } = parameters
526
+ const call = modifyWhitelist.call({
527
+ address: targetAccount,
528
+ allowed,
529
+ policyId,
530
+ })
524
531
  return (await action(client, {
525
- ...parameters,
532
+ ...rest,
526
533
  ...call,
527
534
  } as never)) as never
528
535
  }
@@ -568,8 +575,8 @@ export namespace modifyWhitelist {
568
575
  export function call(args: Args) {
569
576
  const { policyId, address, allowed } = args
570
577
  return defineCall({
571
- address: tip403RegistryAddress,
572
- abi: tip403RegistryAbi,
578
+ address: Addresses.tip403Registry,
579
+ abi: Abis.tip403Registry,
573
580
  functionName: 'modifyPolicyWhitelist',
574
581
  args: [policyId, address, allowed],
575
582
  })
@@ -583,7 +590,7 @@ export namespace modifyWhitelist {
583
590
  */
584
591
  export function extractEvent(logs: Log[]) {
585
592
  const [log] = parseEventLogs({
586
- abi: tip403RegistryAbi,
593
+ abi: Abis.tip403Registry,
587
594
  logs,
588
595
  eventName: 'WhitelistUpdated',
589
596
  strict: true,
@@ -649,7 +656,7 @@ export namespace modifyWhitelistSync {
649
656
 
650
657
  export type ReturnValue = Compute<
651
658
  GetEventArgs<
652
- typeof tip403RegistryAbi,
659
+ typeof Abis.tip403Registry,
653
660
  'WhitelistUpdated',
654
661
  { IndexedOnly: false; Required: true }
655
662
  > & {
@@ -722,10 +729,14 @@ export namespace modifyBlacklist {
722
729
  client: Client<Transport, chain, account>,
723
730
  parameters: modifyBlacklist.Parameters<chain, account>,
724
731
  ): Promise<ReturnType<action>> {
725
- const { address: targetAccount, ...rest } = parameters
726
- const call = modifyBlacklist.call({ ...rest, address: targetAccount })
732
+ const { address: targetAccount, policyId, restricted, ...rest } = parameters
733
+ const call = modifyBlacklist.call({
734
+ address: targetAccount,
735
+ policyId,
736
+ restricted,
737
+ })
727
738
  return (await action(client, {
728
- ...parameters,
739
+ ...rest,
729
740
  ...call,
730
741
  } as never)) as never
731
742
  }
@@ -771,8 +782,8 @@ export namespace modifyBlacklist {
771
782
  export function call(args: Args) {
772
783
  const { policyId, address, restricted } = args
773
784
  return defineCall({
774
- address: tip403RegistryAddress,
775
- abi: tip403RegistryAbi,
785
+ address: Addresses.tip403Registry,
786
+ abi: Abis.tip403Registry,
776
787
  functionName: 'modifyPolicyBlacklist',
777
788
  args: [policyId, address, restricted],
778
789
  })
@@ -786,7 +797,7 @@ export namespace modifyBlacklist {
786
797
  */
787
798
  export function extractEvent(logs: Log[]) {
788
799
  const [log] = parseEventLogs({
789
- abi: tip403RegistryAbi,
800
+ abi: Abis.tip403Registry,
790
801
  logs,
791
802
  eventName: 'BlacklistUpdated',
792
803
  strict: true,
@@ -852,7 +863,7 @@ export namespace modifyBlacklistSync {
852
863
 
853
864
  export type ReturnValue = Compute<
854
865
  GetEventArgs<
855
- typeof tip403RegistryAbi,
866
+ typeof Abis.tip403Registry,
856
867
  'BlacklistUpdated',
857
868
  { IndexedOnly: false; Required: true }
858
869
  > & {
@@ -888,9 +899,10 @@ export async function getData<chain extends Chain | undefined>(
888
899
  client: Client<Transport, chain>,
889
900
  parameters: getData.Parameters,
890
901
  ): Promise<getData.ReturnValue> {
902
+ const { policyId, ...rest } = parameters
891
903
  const result = await readContract(client, {
892
- ...parameters,
893
- ...getData.call(parameters),
904
+ ...rest,
905
+ ...getData.call({ policyId }),
894
906
  })
895
907
  return {
896
908
  admin: result[1],
@@ -922,8 +934,8 @@ export namespace getData {
922
934
  export function call(args: Args) {
923
935
  const { policyId } = args
924
936
  return defineCall({
925
- address: tip403RegistryAddress,
926
- abi: tip403RegistryAbi,
937
+ address: Addresses.tip403Registry,
938
+ abi: Abis.tip403Registry,
927
939
  args: [policyId],
928
940
  functionName: 'policyData',
929
941
  })
@@ -958,9 +970,10 @@ export async function isAuthorized<chain extends Chain | undefined>(
958
970
  client: Client<Transport, chain>,
959
971
  parameters: isAuthorized.Parameters,
960
972
  ): Promise<isAuthorized.ReturnValue> {
973
+ const { policyId, user, ...rest } = parameters
961
974
  return readContract(client, {
962
- ...parameters,
963
- ...isAuthorized.call(parameters),
975
+ ...rest,
976
+ ...isAuthorized.call({ policyId, user }),
964
977
  })
965
978
  }
966
979
 
@@ -975,7 +988,7 @@ export namespace isAuthorized {
975
988
  }
976
989
 
977
990
  export type ReturnValue = ReadContractReturnType<
978
- typeof tip403RegistryAbi,
991
+ typeof Abis.tip403Registry,
979
992
  'isAuthorized',
980
993
  never
981
994
  >
@@ -989,8 +1002,8 @@ export namespace isAuthorized {
989
1002
  export function call(args: Args) {
990
1003
  const { policyId, user } = args
991
1004
  return defineCall({
992
- address: tip403RegistryAddress,
993
- abi: tip403RegistryAbi,
1005
+ address: Addresses.tip403Registry,
1006
+ abi: Abis.tip403Registry,
994
1007
  args: [policyId, user],
995
1008
  functionName: 'isAuthorized',
996
1009
  })
@@ -1032,8 +1045,8 @@ export function watchCreate<
1032
1045
  const { onPolicyCreated, ...rest } = parameters
1033
1046
  return watchContractEvent(client, {
1034
1047
  ...rest,
1035
- address: tip403RegistryAddress,
1036
- abi: tip403RegistryAbi,
1048
+ address: Addresses.tip403Registry,
1049
+ abi: Abis.tip403Registry,
1037
1050
  eventName: 'PolicyCreated',
1038
1051
  onLogs: (logs) => {
1039
1052
  for (const log of logs)
@@ -1060,13 +1073,13 @@ export declare namespace watchCreate {
1060
1073
  bigint,
1061
1074
  number,
1062
1075
  false,
1063
- ExtractAbiItem<typeof tip403RegistryAbi, 'PolicyCreated'>,
1076
+ ExtractAbiItem<typeof Abis.tip403Registry, 'PolicyCreated'>,
1064
1077
  true
1065
1078
  >
1066
1079
 
1067
1080
  export type Parameters = UnionOmit<
1068
1081
  WatchContractEventParameters<
1069
- typeof tip403RegistryAbi,
1082
+ typeof Abis.tip403Registry,
1070
1083
  'PolicyCreated',
1071
1084
  true
1072
1085
  >,
@@ -1112,8 +1125,8 @@ export function watchAdminUpdated<
1112
1125
  const { onAdminUpdated, ...rest } = parameters
1113
1126
  return watchContractEvent(client, {
1114
1127
  ...rest,
1115
- address: tip403RegistryAddress,
1116
- abi: tip403RegistryAbi,
1128
+ address: Addresses.tip403Registry,
1129
+ abi: Abis.tip403Registry,
1117
1130
  eventName: 'PolicyAdminUpdated',
1118
1131
  onLogs: (logs) => {
1119
1132
  for (const log of logs) onAdminUpdated(log.args, log)
@@ -1124,7 +1137,7 @@ export function watchAdminUpdated<
1124
1137
 
1125
1138
  export declare namespace watchAdminUpdated {
1126
1139
  export type Args = GetEventArgs<
1127
- typeof tip403RegistryAbi,
1140
+ typeof Abis.tip403Registry,
1128
1141
  'PolicyAdminUpdated',
1129
1142
  { IndexedOnly: false; Required: true }
1130
1143
  >
@@ -1133,13 +1146,13 @@ export declare namespace watchAdminUpdated {
1133
1146
  bigint,
1134
1147
  number,
1135
1148
  false,
1136
- ExtractAbiItem<typeof tip403RegistryAbi, 'PolicyAdminUpdated'>,
1149
+ ExtractAbiItem<typeof Abis.tip403Registry, 'PolicyAdminUpdated'>,
1137
1150
  true
1138
1151
  >
1139
1152
 
1140
1153
  export type Parameters = UnionOmit<
1141
1154
  WatchContractEventParameters<
1142
- typeof tip403RegistryAbi,
1155
+ typeof Abis.tip403Registry,
1143
1156
  'PolicyAdminUpdated',
1144
1157
  true
1145
1158
  >,
@@ -1185,8 +1198,8 @@ export function watchWhitelistUpdated<
1185
1198
  const { onWhitelistUpdated, ...rest } = parameters
1186
1199
  return watchContractEvent(client, {
1187
1200
  ...rest,
1188
- address: tip403RegistryAddress,
1189
- abi: tip403RegistryAbi,
1201
+ address: Addresses.tip403Registry,
1202
+ abi: Abis.tip403Registry,
1190
1203
  eventName: 'WhitelistUpdated',
1191
1204
  onLogs: (logs) => {
1192
1205
  for (const log of logs) onWhitelistUpdated(log.args, log)
@@ -1197,7 +1210,7 @@ export function watchWhitelistUpdated<
1197
1210
 
1198
1211
  export declare namespace watchWhitelistUpdated {
1199
1212
  export type Args = GetEventArgs<
1200
- typeof tip403RegistryAbi,
1213
+ typeof Abis.tip403Registry,
1201
1214
  'WhitelistUpdated',
1202
1215
  { IndexedOnly: false; Required: true }
1203
1216
  >
@@ -1206,13 +1219,13 @@ export declare namespace watchWhitelistUpdated {
1206
1219
  bigint,
1207
1220
  number,
1208
1221
  false,
1209
- ExtractAbiItem<typeof tip403RegistryAbi, 'WhitelistUpdated'>,
1222
+ ExtractAbiItem<typeof Abis.tip403Registry, 'WhitelistUpdated'>,
1210
1223
  true
1211
1224
  >
1212
1225
 
1213
1226
  export type Parameters = UnionOmit<
1214
1227
  WatchContractEventParameters<
1215
- typeof tip403RegistryAbi,
1228
+ typeof Abis.tip403Registry,
1216
1229
  'WhitelistUpdated',
1217
1230
  true
1218
1231
  >,
@@ -1258,8 +1271,8 @@ export function watchBlacklistUpdated<
1258
1271
  const { onBlacklistUpdated, ...rest } = parameters
1259
1272
  return watchContractEvent(client, {
1260
1273
  ...rest,
1261
- address: tip403RegistryAddress,
1262
- abi: tip403RegistryAbi,
1274
+ address: Addresses.tip403Registry,
1275
+ abi: Abis.tip403Registry,
1263
1276
  eventName: 'BlacklistUpdated',
1264
1277
  onLogs: (logs) => {
1265
1278
  for (const log of logs) onBlacklistUpdated(log.args, log)
@@ -1270,7 +1283,7 @@ export function watchBlacklistUpdated<
1270
1283
 
1271
1284
  export declare namespace watchBlacklistUpdated {
1272
1285
  export type Args = GetEventArgs<
1273
- typeof tip403RegistryAbi,
1286
+ typeof Abis.tip403Registry,
1274
1287
  'BlacklistUpdated',
1275
1288
  { IndexedOnly: false; Required: true }
1276
1289
  >
@@ -1279,13 +1292,13 @@ export declare namespace watchBlacklistUpdated {
1279
1292
  bigint,
1280
1293
  number,
1281
1294
  false,
1282
- ExtractAbiItem<typeof tip403RegistryAbi, 'BlacklistUpdated'>,
1295
+ ExtractAbiItem<typeof Abis.tip403Registry, 'BlacklistUpdated'>,
1283
1296
  true
1284
1297
  >
1285
1298
 
1286
1299
  export type Parameters = UnionOmit<
1287
1300
  WatchContractEventParameters<
1288
- typeof tip403RegistryAbi,
1301
+ typeof Abis.tip403Registry,
1289
1302
  'BlacklistUpdated',
1290
1303
  true
1291
1304
  >,