tempo.ts 0.0.6 → 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.
- package/dist/chains.d.ts +244 -541
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +10 -23
- package/dist/chains.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ox/SignatureEnvelope.d.ts +245 -0
- package/dist/ox/SignatureEnvelope.d.ts.map +1 -0
- package/dist/ox/SignatureEnvelope.js +437 -0
- package/dist/ox/SignatureEnvelope.js.map +1 -0
- package/dist/ox/Transaction.d.ts +61 -24
- package/dist/ox/Transaction.d.ts.map +1 -1
- package/dist/ox/Transaction.js +63 -18
- package/dist/ox/Transaction.js.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.d.ts +461 -0
- package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -0
- package/dist/ox/TransactionEnvelopeAA.js +528 -0
- package/dist/ox/TransactionEnvelopeAA.js.map +1 -0
- package/dist/ox/TransactionRequest.d.ts +7 -5
- package/dist/ox/TransactionRequest.d.ts.map +1 -1
- package/dist/ox/TransactionRequest.js +21 -12
- package/dist/ox/TransactionRequest.js.map +1 -1
- package/dist/ox/index.d.ts +5 -4
- package/dist/ox/index.d.ts.map +1 -1
- package/dist/ox/index.js +5 -4
- package/dist/ox/index.js.map +1 -1
- package/dist/prool/Instance.d.ts +0 -4
- package/dist/prool/Instance.d.ts.map +1 -1
- package/dist/prool/Instance.js +7 -7
- package/dist/prool/Instance.js.map +1 -1
- package/dist/prool/index.d.ts +1 -1
- package/dist/prool/index.d.ts.map +1 -1
- package/dist/prool/index.js +1 -1
- package/dist/prool/index.js.map +1 -1
- package/dist/viem/{abis.d.ts → Abis.d.ts} +523 -9
- package/dist/viem/Abis.d.ts.map +1 -0
- package/dist/viem/{abis.js → Abis.js} +321 -9
- package/dist/viem/Abis.js.map +1 -0
- package/dist/viem/{actions → Actions}/amm.d.ts +21 -21
- package/dist/viem/Actions/amm.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/amm.js +55 -43
- package/dist/viem/Actions/amm.js.map +1 -0
- package/dist/viem/Actions/dex.d.ts +3263 -0
- package/dist/viem/Actions/dex.d.ts.map +1 -0
- package/dist/viem/Actions/dex.js +1357 -0
- package/dist/viem/Actions/dex.js.map +1 -0
- package/dist/viem/{actions → Actions}/fee.d.ts +8 -8
- package/dist/viem/Actions/fee.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/fee.js +14 -13
- package/dist/viem/Actions/fee.js.map +1 -0
- package/dist/viem/Actions/index.d.ts +6 -0
- package/dist/viem/Actions/index.d.ts.map +1 -0
- package/dist/viem/Actions/index.js +6 -0
- package/dist/viem/Actions/index.js.map +1 -0
- package/dist/viem/{actions → Actions}/policy.d.ts +19 -19
- package/dist/viem/Actions/policy.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/policy.js +59 -46
- package/dist/viem/Actions/policy.js.map +1 -0
- package/dist/viem/{actions → Actions}/token.d.ts +3250 -700
- package/dist/viem/Actions/token.d.ts.map +1 -0
- package/dist/viem/{actions → Actions}/token.js +419 -83
- package/dist/viem/Actions/token.js.map +1 -0
- package/dist/viem/Addresses.d.ts +9 -0
- package/dist/viem/Addresses.d.ts.map +1 -0
- package/dist/viem/Addresses.js +9 -0
- package/dist/viem/Addresses.js.map +1 -0
- package/dist/viem/{chain.d.ts → Chain.d.ts} +81 -57
- package/dist/viem/Chain.d.ts.map +1 -0
- package/dist/viem/{chain.js → Chain.js} +7 -7
- package/dist/viem/Chain.js.map +1 -0
- package/dist/viem/{client.d.ts → Client.d.ts} +4 -4
- package/dist/viem/Client.d.ts.map +1 -0
- package/dist/viem/{client.js → Client.js} +3 -3
- package/dist/viem/Client.js.map +1 -0
- package/dist/viem/{decorator.d.ts → Decorator.d.ts} +507 -5
- package/dist/viem/Decorator.d.ts.map +1 -0
- package/dist/viem/{decorator.js → Decorator.js} +31 -5
- package/dist/viem/Decorator.js.map +1 -0
- package/dist/viem/{formatters.d.ts → Formatters.d.ts} +2 -2
- package/dist/viem/Formatters.d.ts.map +1 -0
- package/dist/viem/{formatters.js → Formatters.js} +24 -17
- package/dist/viem/Formatters.js.map +1 -0
- package/dist/viem/Tick.d.ts +111 -0
- package/dist/viem/Tick.d.ts.map +1 -0
- package/dist/viem/Tick.js +127 -0
- package/dist/viem/Tick.js.map +1 -0
- package/dist/viem/TokenIds.d.ts +3 -0
- package/dist/viem/TokenIds.d.ts.map +1 -0
- package/dist/viem/TokenIds.js +3 -0
- package/dist/viem/TokenIds.js.map +1 -0
- package/dist/viem/Transaction.d.ts +57 -0
- package/dist/viem/Transaction.d.ts.map +1 -0
- package/dist/viem/Transaction.js +137 -0
- package/dist/viem/Transaction.js.map +1 -0
- package/dist/viem/{transport.d.ts → Transport.d.ts} +3 -3
- package/dist/viem/Transport.d.ts.map +1 -0
- package/dist/viem/{transport.js → Transport.js} +3 -3
- package/dist/viem/Transport.js.map +1 -0
- package/dist/viem/index.d.ts +13 -9
- package/dist/viem/index.d.ts.map +1 -1
- package/dist/viem/index.js +13 -9
- package/dist/viem/index.js.map +1 -1
- package/dist/viem/{types.d.ts → internal/types.d.ts} +3 -3
- package/dist/viem/internal/types.d.ts.map +1 -0
- package/dist/viem/{types.js.map → internal/types.js.map} +1 -1
- package/dist/viem/internal/utils.d.ts.map +1 -0
- package/dist/viem/internal/utils.js.map +1 -0
- package/package.json +87 -101
- package/src/chains.ts +10 -24
- package/src/ox/SignatureEnvelope.test.ts +1252 -0
- package/src/ox/SignatureEnvelope.ts +709 -0
- package/src/ox/Transaction.test.ts +144 -89
- package/src/ox/Transaction.ts +104 -29
- package/src/ox/TransactionEnvelopeAA.test.ts +1533 -0
- package/src/ox/TransactionEnvelopeAA.ts +858 -0
- package/src/ox/TransactionRequest.ts +25 -17
- package/src/ox/index.ts +2 -1
- package/src/prool/Instance.ts +6 -14
- package/src/prool/internal/chain.json +101 -27
- package/src/viem/{abis.ts → Abis.ts} +322 -8
- package/src/viem/{actions → Actions}/amm.test.ts +65 -68
- package/src/viem/{actions → Actions}/amm.ts +72 -60
- package/src/viem/Actions/dex.test.ts +1608 -0
- package/src/viem/Actions/dex.ts +2026 -0
- package/src/viem/{actions → Actions}/fee.test.ts +34 -36
- package/src/viem/{actions → Actions}/fee.ts +18 -17
- package/src/viem/{actions → Actions}/index.ts +1 -0
- package/src/viem/{actions → Actions}/policy.test.ts +2 -2
- package/src/viem/{actions → Actions}/policy.ts +77 -64
- package/src/viem/{actions → Actions}/token.test.ts +403 -64
- package/src/viem/{actions → Actions}/token.ts +672 -133
- package/src/viem/Addresses.ts +9 -0
- package/src/viem/{chain.ts → Chain.ts} +6 -6
- package/src/viem/{client.bench-d.ts → Client.bench-d.ts} +2 -2
- package/src/viem/{client.test.ts → Client.test.ts} +31 -6
- package/src/viem/{client.ts → Client.ts} +1 -1
- package/src/viem/{decorator.bench-d.ts → Decorator.bench-d.ts} +2 -2
- package/src/viem/{decorator.test.ts → Decorator.test.ts} +1 -0
- package/src/viem/{decorator.ts → Decorator.ts} +586 -4
- package/src/viem/{formatters.ts → Formatters.ts} +31 -20
- package/src/viem/Tick.test.ts +281 -0
- package/src/viem/Tick.ts +176 -0
- package/src/viem/TokenIds.ts +2 -0
- package/src/viem/Transaction.ts +303 -0
- package/src/viem/{transport.ts → Transport.ts} +5 -5
- package/src/viem/e2e.test.ts +153 -78
- package/src/viem/index.ts +13 -9
- package/src/viem/{types.ts → internal/types.ts} +3 -3
- package/dist/ox/TransactionEnvelopeFeeToken.d.ts +0 -393
- package/dist/ox/TransactionEnvelopeFeeToken.d.ts.map +0 -1
- package/dist/ox/TransactionEnvelopeFeeToken.js +0 -452
- package/dist/ox/TransactionEnvelopeFeeToken.js.map +0 -1
- package/dist/viem/abis.d.ts.map +0 -1
- package/dist/viem/abis.js.map +0 -1
- package/dist/viem/actions/amm.d.ts.map +0 -1
- package/dist/viem/actions/amm.js.map +0 -1
- package/dist/viem/actions/fee.d.ts.map +0 -1
- package/dist/viem/actions/fee.js.map +0 -1
- package/dist/viem/actions/index.d.ts +0 -5
- package/dist/viem/actions/index.d.ts.map +0 -1
- package/dist/viem/actions/index.js +0 -5
- package/dist/viem/actions/index.js.map +0 -1
- package/dist/viem/actions/policy.d.ts.map +0 -1
- package/dist/viem/actions/policy.js.map +0 -1
- package/dist/viem/actions/token.d.ts.map +0 -1
- package/dist/viem/actions/token.js.map +0 -1
- package/dist/viem/addresses.d.ts +0 -8
- package/dist/viem/addresses.d.ts.map +0 -1
- package/dist/viem/addresses.js +0 -8
- package/dist/viem/addresses.js.map +0 -1
- package/dist/viem/chain.d.ts.map +0 -1
- package/dist/viem/chain.js.map +0 -1
- package/dist/viem/client.d.ts.map +0 -1
- package/dist/viem/client.js.map +0 -1
- package/dist/viem/decorator.d.ts.map +0 -1
- package/dist/viem/decorator.js.map +0 -1
- package/dist/viem/formatters.d.ts.map +0 -1
- package/dist/viem/formatters.js.map +0 -1
- package/dist/viem/transaction.d.ts +0 -54
- package/dist/viem/transaction.d.ts.map +0 -1
- package/dist/viem/transaction.js +0 -108
- package/dist/viem/transaction.js.map +0 -1
- package/dist/viem/transport.d.ts.map +0 -1
- package/dist/viem/transport.js.map +0 -1
- package/dist/viem/types.d.ts.map +0 -1
- package/dist/viem/utils.d.ts.map +0 -1
- package/dist/viem/utils.js.map +0 -1
- package/src/ox/TransactionEnvelopeFeeToken.test.ts +0 -1119
- package/src/ox/TransactionEnvelopeFeeToken.ts +0 -717
- package/src/prool/internal/consensus.toml +0 -32
- package/src/viem/addresses.ts +0 -10
- package/src/viem/transaction.ts +0 -253
- /package/dist/viem/{types.js → internal/types.js} +0 -0
- /package/dist/viem/{utils.d.ts → internal/utils.d.ts} +0 -0
- /package/dist/viem/{utils.js → internal/utils.js} +0 -0
- /package/src/viem/{utils.ts → internal/utils.ts} +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { setTimeout } from 'node:timers/promises'
|
|
2
|
-
import
|
|
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
|
|
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:
|
|
35
|
-
address:
|
|
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:
|
|
41
|
-
address:
|
|
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": "
|
|
64
|
-
"id":
|
|
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
|
-
|
|
92
|
-
|
|
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:
|
|
97
|
+
token: 2n,
|
|
100
98
|
})
|
|
101
99
|
expect(setReceipt).toBeDefined()
|
|
102
100
|
expect(setResult).toMatchInlineSnapshot(`
|
|
103
101
|
{
|
|
104
|
-
"token": "
|
|
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": "
|
|
113
|
-
"id":
|
|
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:
|
|
121
|
-
token:
|
|
118
|
+
feeToken: 1n,
|
|
119
|
+
token: 1n,
|
|
122
120
|
})
|
|
123
121
|
expect(resetReceipt).toBeDefined()
|
|
124
122
|
expect(resetResult).toMatchInlineSnapshot(`
|
|
125
123
|
{
|
|
126
|
-
"token": "
|
|
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
|
-
|
|
135
|
-
|
|
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:
|
|
160
|
-
address:
|
|
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:
|
|
173
|
-
address:
|
|
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:
|
|
224
|
-
address:
|
|
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:
|
|
231
|
-
address:
|
|
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:
|
|
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
|
|
26
|
-
import
|
|
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:
|
|
104
|
-
abi:
|
|
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
|
|
169
|
+
const { token, ...rest } = parameters
|
|
170
|
+
const call = setUserToken.call({ token })
|
|
170
171
|
return (await action(client, {
|
|
171
|
-
...
|
|
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:
|
|
214
|
-
abi:
|
|
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:
|
|
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
|
|
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:
|
|
331
|
-
abi:
|
|
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
|
|
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
|
|
352
|
+
ExtractAbiItem<typeof Abis.feeManager, 'UserTokenSet'>,
|
|
352
353
|
true
|
|
353
354
|
>
|
|
354
355
|
|
|
355
356
|
export type Parameters = UnionOmit<
|
|
356
|
-
WatchContractEventParameters<typeof
|
|
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,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 '../
|
|
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
|
|
26
|
-
import
|
|
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
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
} as const
|
|
170
|
+
return {
|
|
171
|
+
functionName: 'createPolicy',
|
|
172
|
+
args: [admin, policyTypeMap[type]],
|
|
173
|
+
} as const
|
|
174
|
+
})()
|
|
173
175
|
return defineCall({
|
|
174
|
-
address:
|
|
175
|
-
abi:
|
|
176
|
-
...
|
|
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:
|
|
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
|
|
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
|
|
325
|
+
const { policyId, admin, ...rest } = parameters
|
|
326
|
+
const call = setAdmin.call({ policyId, admin })
|
|
324
327
|
return (await action(client, {
|
|
325
|
-
...
|
|
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:
|
|
370
|
-
abi:
|
|
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:
|
|
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
|
|
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({
|
|
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
|
-
...
|
|
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:
|
|
572
|
-
abi:
|
|
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:
|
|
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
|
|
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({
|
|
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
|
-
...
|
|
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:
|
|
775
|
-
abi:
|
|
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:
|
|
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
|
|
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
|
-
...
|
|
893
|
-
...getData.call(
|
|
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:
|
|
926
|
-
abi:
|
|
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
|
-
...
|
|
963
|
-
...isAuthorized.call(
|
|
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
|
|
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:
|
|
993
|
-
abi:
|
|
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:
|
|
1036
|
-
abi:
|
|
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
|
|
1076
|
+
ExtractAbiItem<typeof Abis.tip403Registry, 'PolicyCreated'>,
|
|
1064
1077
|
true
|
|
1065
1078
|
>
|
|
1066
1079
|
|
|
1067
1080
|
export type Parameters = UnionOmit<
|
|
1068
1081
|
WatchContractEventParameters<
|
|
1069
|
-
typeof
|
|
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:
|
|
1116
|
-
abi:
|
|
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
|
|
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
|
|
1149
|
+
ExtractAbiItem<typeof Abis.tip403Registry, 'PolicyAdminUpdated'>,
|
|
1137
1150
|
true
|
|
1138
1151
|
>
|
|
1139
1152
|
|
|
1140
1153
|
export type Parameters = UnionOmit<
|
|
1141
1154
|
WatchContractEventParameters<
|
|
1142
|
-
typeof
|
|
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:
|
|
1189
|
-
abi:
|
|
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
|
|
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
|
|
1222
|
+
ExtractAbiItem<typeof Abis.tip403Registry, 'WhitelistUpdated'>,
|
|
1210
1223
|
true
|
|
1211
1224
|
>
|
|
1212
1225
|
|
|
1213
1226
|
export type Parameters = UnionOmit<
|
|
1214
1227
|
WatchContractEventParameters<
|
|
1215
|
-
typeof
|
|
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:
|
|
1262
|
-
abi:
|
|
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
|
|
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
|
|
1295
|
+
ExtractAbiItem<typeof Abis.tip403Registry, 'BlacklistUpdated'>,
|
|
1283
1296
|
true
|
|
1284
1297
|
>
|
|
1285
1298
|
|
|
1286
1299
|
export type Parameters = UnionOmit<
|
|
1287
1300
|
WatchContractEventParameters<
|
|
1288
|
-
typeof
|
|
1301
|
+
typeof Abis.tip403Registry,
|
|
1289
1302
|
'BlacklistUpdated',
|
|
1290
1303
|
true
|
|
1291
1304
|
>,
|