tempo.ts 0.11.1 → 0.12.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.
- package/CHANGELOG.md +67 -4
- package/README.md +3 -34
- package/dist/server/Handler.d.ts +14 -14
- package/dist/server/Handler.d.ts.map +1 -1
- package/dist/server/Handler.js +16 -17
- package/dist/server/Handler.js.map +1 -1
- package/dist/wagmi/Actions/amm.d.ts +51 -51
- package/dist/wagmi/Actions/amm.d.ts.map +1 -1
- package/dist/wagmi/Actions/amm.js +37 -37
- package/dist/wagmi/Actions/amm.js.map +1 -1
- package/dist/wagmi/Actions/dex.d.ts +129 -129
- package/dist/wagmi/Actions/dex.d.ts.map +1 -1
- package/dist/wagmi/Actions/dex.js +73 -73
- package/dist/wagmi/Actions/dex.js.map +1 -1
- package/dist/wagmi/Actions/faucet.d.ts +9 -9
- package/dist/wagmi/Actions/faucet.d.ts.map +1 -1
- package/dist/wagmi/Actions/faucet.js +7 -7
- package/dist/wagmi/Actions/faucet.js.map +1 -1
- package/dist/wagmi/Actions/fee.d.ts +17 -17
- package/dist/wagmi/Actions/fee.d.ts.map +1 -1
- package/dist/wagmi/Actions/fee.js +10 -10
- package/dist/wagmi/Actions/fee.js.map +1 -1
- package/dist/wagmi/Actions/nonce.d.ts +9 -79
- package/dist/wagmi/Actions/nonce.d.ts.map +1 -1
- package/dist/wagmi/Actions/nonce.js +7 -89
- package/dist/wagmi/Actions/nonce.js.map +1 -1
- package/dist/wagmi/Actions/policy.d.ts +69 -70
- package/dist/wagmi/Actions/policy.d.ts.map +1 -1
- package/dist/wagmi/Actions/policy.js +43 -43
- package/dist/wagmi/Actions/policy.js.map +1 -1
- package/dist/wagmi/Actions/reward.d.ts +51 -51
- package/dist/wagmi/Actions/reward.d.ts.map +1 -1
- package/dist/wagmi/Actions/reward.js +31 -31
- package/dist/wagmi/Actions/reward.js.map +1 -1
- package/dist/wagmi/Actions/token.d.ts +238 -238
- package/dist/wagmi/Actions/token.d.ts.map +1 -1
- package/dist/wagmi/Actions/token.js +136 -136
- package/dist/wagmi/Actions/token.js.map +1 -1
- package/dist/wagmi/Connector.d.ts +2 -1
- package/dist/wagmi/Connector.d.ts.map +1 -1
- package/dist/wagmi/Connector.js +83 -22
- package/dist/wagmi/Connector.js.map +1 -1
- package/dist/wagmi/Hooks/nonce.d.ts +1 -52
- package/dist/wagmi/Hooks/nonce.d.ts.map +1 -1
- package/dist/wagmi/Hooks/nonce.js +1 -70
- package/dist/wagmi/Hooks/nonce.js.map +1 -1
- package/dist/wagmi/Hooks/policy.d.ts +0 -1
- package/dist/wagmi/Hooks/policy.d.ts.map +1 -1
- package/dist/wagmi/Hooks/policy.js.map +1 -1
- package/dist/wagmi/KeyManager.d.ts +6 -3
- package/dist/wagmi/KeyManager.d.ts.map +1 -1
- package/dist/wagmi/KeyManager.js +9 -4
- package/dist/wagmi/KeyManager.js.map +1 -1
- package/package.json +3 -13
- package/src/server/Handler.test.ts +2 -2
- package/src/server/Handler.ts +16 -17
- package/src/wagmi/Actions/amm.ts +63 -63
- package/src/wagmi/Actions/dex.test.ts +1 -1
- package/src/wagmi/Actions/dex.ts +153 -153
- package/src/wagmi/Actions/faucet.ts +11 -11
- package/src/wagmi/Actions/fee.ts +20 -20
- package/src/wagmi/Actions/nonce.test.ts +1 -64
- package/src/wagmi/Actions/nonce.ts +10 -142
- package/src/wagmi/Actions/policy.ts +83 -85
- package/src/wagmi/Actions/reward.ts +64 -61
- package/src/wagmi/Actions/token.ts +287 -283
- package/src/wagmi/Connector.ts +105 -31
- package/src/wagmi/Hooks/dex.test.ts +1 -1
- package/src/wagmi/Hooks/fee.test.ts +0 -6
- package/src/wagmi/Hooks/nonce.test.ts +1 -66
- package/src/wagmi/Hooks/nonce.ts +1 -114
- package/src/wagmi/Hooks/policy.ts +0 -2
- package/src/wagmi/KeyManager.ts +18 -5
- package/dist/chains.d.ts +0 -73
- package/dist/chains.d.ts.map +0 -1
- package/dist/chains.js +0 -51
- package/dist/chains.js.map +0 -1
- package/dist/viem/Abis.d.ts +0 -2649
- package/dist/viem/Abis.d.ts.map +0 -1
- package/dist/viem/Abis.js +0 -1677
- package/dist/viem/Abis.js.map +0 -1
- package/dist/viem/Account.d.ts +0 -244
- package/dist/viem/Account.d.ts.map +0 -1
- package/dist/viem/Account.js +0 -382
- package/dist/viem/Account.js.map +0 -1
- package/dist/viem/Actions/account.d.ts +0 -40
- package/dist/viem/Actions/account.d.ts.map +0 -1
- package/dist/viem/Actions/account.js +0 -86
- package/dist/viem/Actions/account.js.map +0 -1
- package/dist/viem/Actions/amm.d.ts +0 -1991
- package/dist/viem/Actions/amm.d.ts.map +0 -1
- package/dist/viem/Actions/amm.js +0 -814
- package/dist/viem/Actions/amm.js.map +0 -1
- package/dist/viem/Actions/dex.d.ts +0 -3900
- package/dist/viem/Actions/dex.d.ts.map +0 -1
- package/dist/viem/Actions/dex.js +0 -1414
- package/dist/viem/Actions/dex.js.map +0 -1
- package/dist/viem/Actions/faucet.d.ts +0 -69
- package/dist/viem/Actions/faucet.d.ts.map +0 -1
- package/dist/viem/Actions/faucet.js +0 -73
- package/dist/viem/Actions/faucet.js.map +0 -1
- package/dist/viem/Actions/fee.d.ts +0 -360
- package/dist/viem/Actions/fee.d.ts.map +0 -1
- package/dist/viem/Actions/fee.js +0 -237
- package/dist/viem/Actions/fee.js.map +0 -1
- package/dist/viem/Actions/index.d.ts +0 -10
- package/dist/viem/Actions/index.d.ts.map +0 -1
- package/dist/viem/Actions/index.js +0 -10
- package/dist/viem/Actions/index.js.map +0 -1
- package/dist/viem/Actions/nonce.d.ts +0 -257
- package/dist/viem/Actions/nonce.d.ts.map +0 -1
- package/dist/viem/Actions/nonce.js +0 -228
- package/dist/viem/Actions/nonce.js.map +0 -1
- package/dist/viem/Actions/policy.d.ts +0 -1680
- package/dist/viem/Actions/policy.d.ts.map +0 -1
- package/dist/viem/Actions/policy.js +0 -875
- package/dist/viem/Actions/policy.js.map +0 -1
- package/dist/viem/Actions/reward.d.ts +0 -2422
- package/dist/viem/Actions/reward.d.ts.map +0 -1
- package/dist/viem/Actions/reward.js +0 -651
- package/dist/viem/Actions/reward.js.map +0 -1
- package/dist/viem/Actions/token.d.ts +0 -16007
- package/dist/viem/Actions/token.d.ts.map +0 -1
- package/dist/viem/Actions/token.js +0 -2936
- package/dist/viem/Actions/token.js.map +0 -1
- package/dist/viem/Addresses.d.ts +0 -9
- package/dist/viem/Addresses.d.ts.map +0 -1
- package/dist/viem/Addresses.js +0 -9
- package/dist/viem/Addresses.js.map +0 -1
- package/dist/viem/Chain.d.ts +0 -451
- package/dist/viem/Chain.d.ts.map +0 -1
- package/dist/viem/Chain.js +0 -96
- package/dist/viem/Chain.js.map +0 -1
- package/dist/viem/Decorator.d.ts +0 -2783
- package/dist/viem/Decorator.d.ts.map +0 -1
- package/dist/viem/Decorator.js +0 -137
- package/dist/viem/Decorator.js.map +0 -1
- package/dist/viem/Formatters.d.ts +0 -10
- package/dist/viem/Formatters.d.ts.map +0 -1
- package/dist/viem/Formatters.js +0 -104
- package/dist/viem/Formatters.js.map +0 -1
- package/dist/viem/P256.d.ts +0 -2
- package/dist/viem/P256.d.ts.map +0 -1
- package/dist/viem/P256.js +0 -2
- package/dist/viem/P256.js.map +0 -1
- package/dist/viem/Secp256k1.d.ts +0 -2
- package/dist/viem/Secp256k1.d.ts.map +0 -1
- package/dist/viem/Secp256k1.js +0 -2
- package/dist/viem/Secp256k1.js.map +0 -1
- package/dist/viem/Storage.d.ts +0 -24
- package/dist/viem/Storage.d.ts.map +0 -1
- package/dist/viem/Storage.js +0 -68
- package/dist/viem/Storage.js.map +0 -1
- package/dist/viem/TokenIds.d.ts +0 -2
- package/dist/viem/TokenIds.d.ts.map +0 -1
- package/dist/viem/TokenIds.js +0 -2
- package/dist/viem/TokenIds.js.map +0 -1
- package/dist/viem/Transaction.d.ts +0 -76
- package/dist/viem/Transaction.d.ts.map +0 -1
- package/dist/viem/Transaction.js +0 -176
- package/dist/viem/Transaction.js.map +0 -1
- package/dist/viem/Transport.d.ts +0 -33
- package/dist/viem/Transport.d.ts.map +0 -1
- package/dist/viem/Transport.js +0 -138
- package/dist/viem/Transport.js.map +0 -1
- package/dist/viem/WebAuthnP256.d.ts +0 -82
- package/dist/viem/WebAuthnP256.d.ts.map +0 -1
- package/dist/viem/WebAuthnP256.js +0 -97
- package/dist/viem/WebAuthnP256.js.map +0 -1
- package/dist/viem/WebCryptoP256.d.ts +0 -2
- package/dist/viem/WebCryptoP256.d.ts.map +0 -1
- package/dist/viem/WebCryptoP256.js +0 -2
- package/dist/viem/WebCryptoP256.js.map +0 -1
- package/dist/viem/index.d.ts +0 -26
- package/dist/viem/index.d.ts.map +0 -1
- package/dist/viem/index.js +0 -17
- package/dist/viem/index.js.map +0 -1
- package/dist/viem/internal/types.d.ts +0 -20
- package/dist/viem/internal/types.d.ts.map +0 -1
- package/dist/viem/internal/types.js +0 -2
- package/dist/viem/internal/types.js.map +0 -1
- package/dist/viem/internal/utils.d.ts +0 -14
- package/dist/viem/internal/utils.d.ts.map +0 -1
- package/dist/viem/internal/utils.js +0 -33
- package/dist/viem/internal/utils.js.map +0 -1
- package/src/chains.ts +0 -54
- package/src/viem/Abis.ts +0 -1688
- package/src/viem/Account.test.ts +0 -444
- package/src/viem/Account.ts +0 -601
- package/src/viem/Actions/account.test.ts +0 -414
- package/src/viem/Actions/account.ts +0 -106
- package/src/viem/Actions/amm.test.ts +0 -381
- package/src/viem/Actions/amm.ts +0 -1227
- package/src/viem/Actions/dex.test.ts +0 -1549
- package/src/viem/Actions/dex.ts +0 -2150
- package/src/viem/Actions/faucet.ts +0 -121
- package/src/viem/Actions/fee.test.ts +0 -259
- package/src/viem/Actions/fee.ts +0 -372
- package/src/viem/Actions/index.ts +0 -9
- package/src/viem/Actions/nonce.test.ts +0 -206
- package/src/viem/Actions/nonce.ts +0 -347
- package/src/viem/Actions/policy.test.ts +0 -534
- package/src/viem/Actions/policy.ts +0 -1335
- package/src/viem/Actions/reward.test.ts +0 -434
- package/src/viem/Actions/reward.ts +0 -944
- package/src/viem/Actions/token.test.ts +0 -3029
- package/src/viem/Actions/token.ts +0 -4458
- package/src/viem/Addresses.ts +0 -9
- package/src/viem/Chain.bench-d.ts +0 -12
- package/src/viem/Chain.test.ts +0 -168
- package/src/viem/Chain.ts +0 -157
- package/src/viem/Decorator.bench-d.ts +0 -11
- package/src/viem/Decorator.test.ts +0 -39
- package/src/viem/Decorator.ts +0 -3179
- package/src/viem/Formatters.ts +0 -164
- package/src/viem/P256.ts +0 -1
- package/src/viem/Secp256k1.ts +0 -1
- package/src/viem/Storage.ts +0 -110
- package/src/viem/TokenIds.ts +0 -1
- package/src/viem/Transaction.ts +0 -382
- package/src/viem/Transport.ts +0 -191
- package/src/viem/WebAuthnP256.ts +0 -146
- package/src/viem/WebCryptoP256.ts +0 -1
- package/src/viem/e2e.test.ts +0 -1602
- package/src/viem/index.ts +0 -30
- package/src/viem/internal/types.ts +0 -69
- package/src/viem/internal/utils.ts +0 -58
- package/src/wagmi/internal/types.ts +0 -16
|
@@ -1,1335 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Account,
|
|
3
|
-
type Address,
|
|
4
|
-
type BaseErrorType,
|
|
5
|
-
type Chain,
|
|
6
|
-
type Client,
|
|
7
|
-
type ExtractAbiItem,
|
|
8
|
-
type GetEventArgs,
|
|
9
|
-
type Log,
|
|
10
|
-
parseEventLogs,
|
|
11
|
-
type ReadContractReturnType,
|
|
12
|
-
type TransactionReceipt,
|
|
13
|
-
type Transport,
|
|
14
|
-
type Log as viem_Log,
|
|
15
|
-
type WatchContractEventParameters,
|
|
16
|
-
type WriteContractReturnType,
|
|
17
|
-
} from 'viem'
|
|
18
|
-
import { parseAccount } from 'viem/accounts'
|
|
19
|
-
import {
|
|
20
|
-
readContract,
|
|
21
|
-
watchContractEvent,
|
|
22
|
-
writeContract,
|
|
23
|
-
writeContractSync,
|
|
24
|
-
} from 'viem/actions'
|
|
25
|
-
import type { Compute, UnionOmit } from '../../internal/types.js'
|
|
26
|
-
import * as Abis from '../Abis.js'
|
|
27
|
-
import * as Addresses from '../Addresses.js'
|
|
28
|
-
import type { ReadParameters, WriteParameters } from '../internal/types.js'
|
|
29
|
-
import { defineCall } from '../internal/utils.js'
|
|
30
|
-
|
|
31
|
-
export type PolicyType = 'whitelist' | 'blacklist'
|
|
32
|
-
|
|
33
|
-
const policyTypeMap = {
|
|
34
|
-
whitelist: 0,
|
|
35
|
-
blacklist: 1,
|
|
36
|
-
} as const
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Creates a new policy.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* import { createClient, http } from 'viem'
|
|
44
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
45
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
46
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
47
|
-
*
|
|
48
|
-
* const client = createClient({
|
|
49
|
-
* account: privateKeyToAccount('0x...'),
|
|
50
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
51
|
-
* transport: http(),
|
|
52
|
-
* })
|
|
53
|
-
*
|
|
54
|
-
* const { hash, policyId } = await Actions.policy.create(client, {
|
|
55
|
-
* admin: '0x...',
|
|
56
|
-
* type: 'whitelist',
|
|
57
|
-
* })
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @param client - Client.
|
|
61
|
-
* @param parameters - Parameters.
|
|
62
|
-
* @returns The transaction hash and policy ID.
|
|
63
|
-
*/
|
|
64
|
-
export async function create<
|
|
65
|
-
chain extends Chain | undefined,
|
|
66
|
-
account extends Account | undefined,
|
|
67
|
-
>(
|
|
68
|
-
client: Client<Transport, chain, account>,
|
|
69
|
-
parameters: create.Parameters<chain, account>,
|
|
70
|
-
): Promise<create.ReturnValue> {
|
|
71
|
-
return create.inner(writeContract, client, parameters)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export namespace create {
|
|
75
|
-
export type Parameters<
|
|
76
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
77
|
-
account extends Account | undefined = Account | undefined,
|
|
78
|
-
> = WriteParameters<chain, account> &
|
|
79
|
-
Omit<Args, 'admin'> & {
|
|
80
|
-
/** Address of the policy admin. */
|
|
81
|
-
admin?: Address | undefined
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export type Args = {
|
|
85
|
-
/** Optional array of accounts to initialize the policy with. */
|
|
86
|
-
addresses?: readonly Address[] | undefined
|
|
87
|
-
/** Address of the policy admin. */
|
|
88
|
-
admin: Address
|
|
89
|
-
/** Type of policy to create. */
|
|
90
|
-
type: PolicyType
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export type ReturnValue = WriteContractReturnType
|
|
94
|
-
|
|
95
|
-
// TODO: exhaustive error type
|
|
96
|
-
export type ErrorType = BaseErrorType
|
|
97
|
-
|
|
98
|
-
/** @internal */
|
|
99
|
-
export async function inner<
|
|
100
|
-
action extends typeof writeContract | typeof writeContractSync,
|
|
101
|
-
chain extends Chain | undefined,
|
|
102
|
-
account extends Account | undefined,
|
|
103
|
-
>(
|
|
104
|
-
action: action,
|
|
105
|
-
client: Client<Transport, chain, account>,
|
|
106
|
-
parameters: Parameters<chain, account>,
|
|
107
|
-
): Promise<ReturnType<action>> {
|
|
108
|
-
const {
|
|
109
|
-
account = client.account,
|
|
110
|
-
addresses,
|
|
111
|
-
chain = client.chain,
|
|
112
|
-
type,
|
|
113
|
-
...rest
|
|
114
|
-
} = parameters
|
|
115
|
-
|
|
116
|
-
if (!account) throw new Error('`account` is required')
|
|
117
|
-
|
|
118
|
-
const admin = parseAccount(account).address!
|
|
119
|
-
|
|
120
|
-
const call = create.call({ admin, type, addresses })
|
|
121
|
-
return action(client, {
|
|
122
|
-
...rest,
|
|
123
|
-
account,
|
|
124
|
-
chain,
|
|
125
|
-
...call,
|
|
126
|
-
} as never) as never
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Defines a call to the `createPolicy` function.
|
|
131
|
-
*
|
|
132
|
-
* Can be passed as a parameter to:
|
|
133
|
-
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
134
|
-
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
135
|
-
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* ```ts
|
|
139
|
-
* import { createClient, http, walletActions } from 'viem'
|
|
140
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
141
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
142
|
-
*
|
|
143
|
-
* const client = createClient({
|
|
144
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
145
|
-
* transport: http(),
|
|
146
|
-
* }).extend(walletActions)
|
|
147
|
-
*
|
|
148
|
-
* const { result } = await client.sendCalls({
|
|
149
|
-
* calls: [
|
|
150
|
-
* actions.policy.create.call({
|
|
151
|
-
* admin: '0xfeed...fede',
|
|
152
|
-
* type: 'whitelist',
|
|
153
|
-
* }),
|
|
154
|
-
* actions.policy.create.call({
|
|
155
|
-
* admin: '0xfeed...fede',
|
|
156
|
-
* type: 'blacklist',
|
|
157
|
-
* addresses: ['0x20c0...beef', '0x20c0...babe'],
|
|
158
|
-
* }),
|
|
159
|
-
* ]
|
|
160
|
-
* })
|
|
161
|
-
* ```
|
|
162
|
-
*
|
|
163
|
-
* @param args - Arguments.
|
|
164
|
-
* @returns The call.
|
|
165
|
-
*/
|
|
166
|
-
export function call(args: Args) {
|
|
167
|
-
const { admin, type, addresses } = args
|
|
168
|
-
const config = (() => {
|
|
169
|
-
if (addresses)
|
|
170
|
-
return {
|
|
171
|
-
functionName: 'createPolicyWithAccounts',
|
|
172
|
-
args: [admin, policyTypeMap[type], addresses],
|
|
173
|
-
} as const
|
|
174
|
-
return {
|
|
175
|
-
functionName: 'createPolicy',
|
|
176
|
-
args: [admin, policyTypeMap[type]],
|
|
177
|
-
} as const
|
|
178
|
-
})()
|
|
179
|
-
return defineCall({
|
|
180
|
-
address: Addresses.tip403Registry,
|
|
181
|
-
abi: Abis.tip403Registry,
|
|
182
|
-
...config,
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Extracts the `PolicyCreated` event from logs.
|
|
188
|
-
*
|
|
189
|
-
* @param logs - The logs.
|
|
190
|
-
* @returns The `PolicyCreated` event.
|
|
191
|
-
*/
|
|
192
|
-
export function extractEvent(logs: Log[]) {
|
|
193
|
-
const [log] = parseEventLogs({
|
|
194
|
-
abi: Abis.tip403Registry,
|
|
195
|
-
logs,
|
|
196
|
-
eventName: 'PolicyCreated',
|
|
197
|
-
strict: true,
|
|
198
|
-
})
|
|
199
|
-
if (!log) throw new Error('`PolicyCreated` event not found.')
|
|
200
|
-
return log
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Creates a new policy.
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* ```ts
|
|
209
|
-
* import { createClient, http } from 'viem'
|
|
210
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
211
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
212
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
213
|
-
*
|
|
214
|
-
* const client = createClient({
|
|
215
|
-
* account: privateKeyToAccount('0x...'),
|
|
216
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
217
|
-
* transport: http(),
|
|
218
|
-
* })
|
|
219
|
-
*
|
|
220
|
-
* const result = await Actions.policy.createSync(client, {
|
|
221
|
-
* admin: '0x...',
|
|
222
|
-
* type: 'whitelist',
|
|
223
|
-
* })
|
|
224
|
-
* ```
|
|
225
|
-
*
|
|
226
|
-
* @param client - Client.
|
|
227
|
-
* @param parameters - Parameters.
|
|
228
|
-
* @returns The transaction receipt and event data.
|
|
229
|
-
*/
|
|
230
|
-
export async function createSync<
|
|
231
|
-
chain extends Chain | undefined,
|
|
232
|
-
account extends Account | undefined,
|
|
233
|
-
>(
|
|
234
|
-
client: Client<Transport, chain, account>,
|
|
235
|
-
parameters: createSync.Parameters<chain, account>,
|
|
236
|
-
): Promise<createSync.ReturnValue> {
|
|
237
|
-
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
238
|
-
const receipt = await create.inner(writeContractSync, client, {
|
|
239
|
-
...rest,
|
|
240
|
-
throwOnReceiptRevert,
|
|
241
|
-
} as never)
|
|
242
|
-
const { args } = create.extractEvent(receipt.logs)
|
|
243
|
-
return {
|
|
244
|
-
...args,
|
|
245
|
-
receipt,
|
|
246
|
-
} as never
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export namespace createSync {
|
|
250
|
-
export type Parameters<
|
|
251
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
252
|
-
account extends Account | undefined = Account | undefined,
|
|
253
|
-
> = create.Parameters<chain, account>
|
|
254
|
-
|
|
255
|
-
export type Args = create.Args
|
|
256
|
-
|
|
257
|
-
export type ReturnValue = Compute<
|
|
258
|
-
GetEventArgs<
|
|
259
|
-
typeof Abis.tip403Registry,
|
|
260
|
-
'PolicyCreated',
|
|
261
|
-
{ IndexedOnly: false; Required: true }
|
|
262
|
-
> & {
|
|
263
|
-
receipt: TransactionReceipt
|
|
264
|
-
}
|
|
265
|
-
>
|
|
266
|
-
|
|
267
|
-
// TODO: exhaustive error type
|
|
268
|
-
export type ErrorType = BaseErrorType
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Sets the admin for a policy.
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* ```ts
|
|
276
|
-
* import { createClient, http } from 'viem'
|
|
277
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
278
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
279
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
280
|
-
*
|
|
281
|
-
* const client = createClient({
|
|
282
|
-
* account: privateKeyToAccount('0x...'),
|
|
283
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
284
|
-
* transport: http(),
|
|
285
|
-
* })
|
|
286
|
-
*
|
|
287
|
-
* const hash = await Actions.policy.setAdmin(client, {
|
|
288
|
-
* policyId: 2n,
|
|
289
|
-
* admin: '0x...',
|
|
290
|
-
* })
|
|
291
|
-
* ```
|
|
292
|
-
*
|
|
293
|
-
* @param client - Client.
|
|
294
|
-
* @param parameters - Parameters.
|
|
295
|
-
* @returns The transaction hash.
|
|
296
|
-
*/
|
|
297
|
-
export async function setAdmin<
|
|
298
|
-
chain extends Chain | undefined,
|
|
299
|
-
account extends Account | undefined,
|
|
300
|
-
>(
|
|
301
|
-
client: Client<Transport, chain, account>,
|
|
302
|
-
parameters: setAdmin.Parameters<chain, account>,
|
|
303
|
-
): Promise<setAdmin.ReturnValue> {
|
|
304
|
-
return setAdmin.inner(writeContract, client, parameters)
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export namespace setAdmin {
|
|
308
|
-
export type Parameters<
|
|
309
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
310
|
-
account extends Account | undefined = Account | undefined,
|
|
311
|
-
> = WriteParameters<chain, account> & Args
|
|
312
|
-
|
|
313
|
-
export type Args = {
|
|
314
|
-
/** New admin address. */
|
|
315
|
-
admin: Address
|
|
316
|
-
/** Policy ID. */
|
|
317
|
-
policyId: bigint
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
export type ReturnValue = WriteContractReturnType
|
|
321
|
-
|
|
322
|
-
// TODO: exhaustive error type
|
|
323
|
-
export type ErrorType = BaseErrorType
|
|
324
|
-
|
|
325
|
-
/** @internal */
|
|
326
|
-
export async function inner<
|
|
327
|
-
action extends typeof writeContract | typeof writeContractSync,
|
|
328
|
-
chain extends Chain | undefined,
|
|
329
|
-
account extends Account | undefined,
|
|
330
|
-
>(
|
|
331
|
-
action: action,
|
|
332
|
-
client: Client<Transport, chain, account>,
|
|
333
|
-
parameters: setAdmin.Parameters<chain, account>,
|
|
334
|
-
): Promise<ReturnType<action>> {
|
|
335
|
-
const { policyId, admin, ...rest } = parameters
|
|
336
|
-
const call = setAdmin.call({ policyId, admin })
|
|
337
|
-
return (await action(client, {
|
|
338
|
-
...rest,
|
|
339
|
-
...call,
|
|
340
|
-
} as never)) as never
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Defines a call to the `setPolicyAdmin` function.
|
|
345
|
-
*
|
|
346
|
-
* Can be passed as a parameter to:
|
|
347
|
-
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
348
|
-
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
349
|
-
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
350
|
-
*
|
|
351
|
-
* @example
|
|
352
|
-
* ```ts
|
|
353
|
-
* import { createClient, http, walletActions } from 'viem'
|
|
354
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
355
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
356
|
-
*
|
|
357
|
-
* const client = createClient({
|
|
358
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
359
|
-
* transport: http(),
|
|
360
|
-
* }).extend(walletActions)
|
|
361
|
-
*
|
|
362
|
-
* const { result } = await client.sendCalls({
|
|
363
|
-
* calls: [
|
|
364
|
-
* actions.policy.setAdmin.call({
|
|
365
|
-
* policyId: 2n,
|
|
366
|
-
* admin: '0xfeed...fede',
|
|
367
|
-
* }),
|
|
368
|
-
* actions.policy.setAdmin.call({
|
|
369
|
-
* policyId: 3n,
|
|
370
|
-
* admin: '0xfeed...babe',
|
|
371
|
-
* }),
|
|
372
|
-
* ]
|
|
373
|
-
* })
|
|
374
|
-
* ```
|
|
375
|
-
*
|
|
376
|
-
* @param args - Arguments.
|
|
377
|
-
* @returns The call.
|
|
378
|
-
*/
|
|
379
|
-
export function call(args: Args) {
|
|
380
|
-
const { policyId, admin } = args
|
|
381
|
-
return defineCall({
|
|
382
|
-
address: Addresses.tip403Registry,
|
|
383
|
-
abi: Abis.tip403Registry,
|
|
384
|
-
functionName: 'setPolicyAdmin',
|
|
385
|
-
args: [policyId, admin],
|
|
386
|
-
})
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Extracts the `PolicyAdminUpdated` event from logs.
|
|
391
|
-
*
|
|
392
|
-
* @param logs - The logs.
|
|
393
|
-
* @returns The `PolicyAdminUpdated` event.
|
|
394
|
-
*/
|
|
395
|
-
export function extractEvent(logs: Log[]) {
|
|
396
|
-
const [log] = parseEventLogs({
|
|
397
|
-
abi: Abis.tip403Registry,
|
|
398
|
-
logs,
|
|
399
|
-
eventName: 'PolicyAdminUpdated',
|
|
400
|
-
strict: true,
|
|
401
|
-
})
|
|
402
|
-
if (!log) throw new Error('`PolicyAdminUpdated` event not found.')
|
|
403
|
-
return log
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Sets the admin for a policy.
|
|
409
|
-
*
|
|
410
|
-
* @example
|
|
411
|
-
* ```ts
|
|
412
|
-
* import { createClient, http } from 'viem'
|
|
413
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
414
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
415
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
416
|
-
*
|
|
417
|
-
* const client = createClient({
|
|
418
|
-
* account: privateKeyToAccount('0x...'),
|
|
419
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
420
|
-
* transport: http(),
|
|
421
|
-
* })
|
|
422
|
-
*
|
|
423
|
-
* const result = await Actions.policy.setAdminSync(client, {
|
|
424
|
-
* policyId: 2n,
|
|
425
|
-
* admin: '0x...',
|
|
426
|
-
* })
|
|
427
|
-
* ```
|
|
428
|
-
*
|
|
429
|
-
* @param client - Client.
|
|
430
|
-
* @param parameters - Parameters.
|
|
431
|
-
* @returns The transaction receipt and event data.
|
|
432
|
-
*/
|
|
433
|
-
export async function setAdminSync<
|
|
434
|
-
chain extends Chain | undefined,
|
|
435
|
-
account extends Account | undefined,
|
|
436
|
-
>(
|
|
437
|
-
client: Client<Transport, chain, account>,
|
|
438
|
-
parameters: setAdminSync.Parameters<chain, account>,
|
|
439
|
-
): Promise<setAdminSync.ReturnValue> {
|
|
440
|
-
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
441
|
-
const receipt = await setAdmin.inner(writeContractSync, client, {
|
|
442
|
-
...rest,
|
|
443
|
-
throwOnReceiptRevert,
|
|
444
|
-
} as never)
|
|
445
|
-
const { args } = setAdmin.extractEvent(receipt.logs)
|
|
446
|
-
return {
|
|
447
|
-
...args,
|
|
448
|
-
receipt,
|
|
449
|
-
} as never
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
export namespace setAdminSync {
|
|
453
|
-
export type Parameters<
|
|
454
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
455
|
-
account extends Account | undefined = Account | undefined,
|
|
456
|
-
> = setAdmin.Parameters<chain, account>
|
|
457
|
-
|
|
458
|
-
export type Args = setAdmin.Args
|
|
459
|
-
|
|
460
|
-
export type ReturnValue = Compute<
|
|
461
|
-
GetEventArgs<
|
|
462
|
-
typeof Abis.tip403Registry,
|
|
463
|
-
'PolicyAdminUpdated',
|
|
464
|
-
{ IndexedOnly: false; Required: true }
|
|
465
|
-
> & {
|
|
466
|
-
receipt: TransactionReceipt
|
|
467
|
-
}
|
|
468
|
-
>
|
|
469
|
-
|
|
470
|
-
// TODO: exhaustive error type
|
|
471
|
-
export type ErrorType = BaseErrorType
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Modifies a policy whitelist.
|
|
476
|
-
*
|
|
477
|
-
* @example
|
|
478
|
-
* ```ts
|
|
479
|
-
* import { createClient, http } from 'viem'
|
|
480
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
481
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
482
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
483
|
-
*
|
|
484
|
-
* const client = createClient({
|
|
485
|
-
* account: privateKeyToAccount('0x...'),
|
|
486
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
487
|
-
* transport: http(),
|
|
488
|
-
* })
|
|
489
|
-
*
|
|
490
|
-
* const hash = await Actions.policy.modifyWhitelist(client, {
|
|
491
|
-
* policyId: 2n,
|
|
492
|
-
* account: '0x...',
|
|
493
|
-
* allowed: true,
|
|
494
|
-
* })
|
|
495
|
-
* ```
|
|
496
|
-
*
|
|
497
|
-
* @param client - Client.
|
|
498
|
-
* @param parameters - Parameters.
|
|
499
|
-
* @returns The transaction hash.
|
|
500
|
-
*/
|
|
501
|
-
export async function modifyWhitelist<
|
|
502
|
-
chain extends Chain | undefined,
|
|
503
|
-
account extends Account | undefined,
|
|
504
|
-
>(
|
|
505
|
-
client: Client<Transport, chain, account>,
|
|
506
|
-
parameters: modifyWhitelist.Parameters<chain, account>,
|
|
507
|
-
): Promise<modifyWhitelist.ReturnValue> {
|
|
508
|
-
return modifyWhitelist.inner(writeContract, client, parameters)
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
export namespace modifyWhitelist {
|
|
512
|
-
export type Parameters<
|
|
513
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
514
|
-
account extends Account | undefined = Account | undefined,
|
|
515
|
-
> = WriteParameters<chain, account> & Args
|
|
516
|
-
|
|
517
|
-
export type Args = {
|
|
518
|
-
/** Target account address. */
|
|
519
|
-
address: Address
|
|
520
|
-
/** Whether the account is allowed. */
|
|
521
|
-
allowed: boolean
|
|
522
|
-
/** Policy ID. */
|
|
523
|
-
policyId: bigint
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
export type ReturnValue = WriteContractReturnType
|
|
527
|
-
|
|
528
|
-
// TODO: exhaustive error type
|
|
529
|
-
export type ErrorType = BaseErrorType
|
|
530
|
-
|
|
531
|
-
/** @internal */
|
|
532
|
-
export async function inner<
|
|
533
|
-
action extends typeof writeContract | typeof writeContractSync,
|
|
534
|
-
chain extends Chain | undefined,
|
|
535
|
-
account extends Account | undefined,
|
|
536
|
-
>(
|
|
537
|
-
action: action,
|
|
538
|
-
client: Client<Transport, chain, account>,
|
|
539
|
-
parameters: modifyWhitelist.Parameters<chain, account>,
|
|
540
|
-
): Promise<ReturnType<action>> {
|
|
541
|
-
const { address: targetAccount, allowed, policyId, ...rest } = parameters
|
|
542
|
-
const call = modifyWhitelist.call({
|
|
543
|
-
address: targetAccount,
|
|
544
|
-
allowed,
|
|
545
|
-
policyId,
|
|
546
|
-
})
|
|
547
|
-
return (await action(client, {
|
|
548
|
-
...rest,
|
|
549
|
-
...call,
|
|
550
|
-
} as never)) as never
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* Defines a call to the `modifyPolicyWhitelist` function.
|
|
555
|
-
*
|
|
556
|
-
* Can be passed as a parameter to:
|
|
557
|
-
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
558
|
-
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
559
|
-
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
560
|
-
*
|
|
561
|
-
* @example
|
|
562
|
-
* ```ts
|
|
563
|
-
* import { createClient, http, walletActions } from 'viem'
|
|
564
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
565
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
566
|
-
*
|
|
567
|
-
* const client = createClient({
|
|
568
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
569
|
-
* transport: http(),
|
|
570
|
-
* }).extend(walletActions)
|
|
571
|
-
*
|
|
572
|
-
* const { result } = await client.sendCalls({
|
|
573
|
-
* calls: [
|
|
574
|
-
* actions.policy.modifyWhitelist.call({
|
|
575
|
-
* policyId: 2n,
|
|
576
|
-
* address: '0x20c0...beef',
|
|
577
|
-
* allowed: true,
|
|
578
|
-
* }),
|
|
579
|
-
* actions.policy.modifyWhitelist.call({
|
|
580
|
-
* policyId: 2n,
|
|
581
|
-
* address: '0x20c0...babe',
|
|
582
|
-
* allowed: false,
|
|
583
|
-
* }),
|
|
584
|
-
* ]
|
|
585
|
-
* })
|
|
586
|
-
* ```
|
|
587
|
-
*
|
|
588
|
-
* @param args - Arguments.
|
|
589
|
-
* @returns The call.
|
|
590
|
-
*/
|
|
591
|
-
export function call(args: Args) {
|
|
592
|
-
const { policyId, address, allowed } = args
|
|
593
|
-
return defineCall({
|
|
594
|
-
address: Addresses.tip403Registry,
|
|
595
|
-
abi: Abis.tip403Registry,
|
|
596
|
-
functionName: 'modifyPolicyWhitelist',
|
|
597
|
-
args: [policyId, address, allowed],
|
|
598
|
-
})
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* Extracts the `WhitelistUpdated` event from logs.
|
|
603
|
-
*
|
|
604
|
-
* @param logs - The logs.
|
|
605
|
-
* @returns The `WhitelistUpdated` event.
|
|
606
|
-
*/
|
|
607
|
-
export function extractEvent(logs: Log[]) {
|
|
608
|
-
const [log] = parseEventLogs({
|
|
609
|
-
abi: Abis.tip403Registry,
|
|
610
|
-
logs,
|
|
611
|
-
eventName: 'WhitelistUpdated',
|
|
612
|
-
strict: true,
|
|
613
|
-
})
|
|
614
|
-
if (!log) throw new Error('`WhitelistUpdated` event not found.')
|
|
615
|
-
return log
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
/**
|
|
620
|
-
* Modifies a policy whitelist.
|
|
621
|
-
*
|
|
622
|
-
* @example
|
|
623
|
-
* ```ts
|
|
624
|
-
* import { createClient, http } from 'viem'
|
|
625
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
626
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
627
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
628
|
-
*
|
|
629
|
-
* const client = createClient({
|
|
630
|
-
* account: privateKeyToAccount('0x...'),
|
|
631
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
632
|
-
* transport: http(),
|
|
633
|
-
* })
|
|
634
|
-
*
|
|
635
|
-
* const result = await Actions.policy.modifyWhitelistSync(client, {
|
|
636
|
-
* policyId: 2n,
|
|
637
|
-
* account: '0x...',
|
|
638
|
-
* allowed: true,
|
|
639
|
-
* })
|
|
640
|
-
* ```
|
|
641
|
-
*
|
|
642
|
-
* @param client - Client.
|
|
643
|
-
* @param parameters - Parameters.
|
|
644
|
-
* @returns The transaction receipt and event data.
|
|
645
|
-
*/
|
|
646
|
-
export async function modifyWhitelistSync<
|
|
647
|
-
chain extends Chain | undefined,
|
|
648
|
-
account extends Account | undefined,
|
|
649
|
-
>(
|
|
650
|
-
client: Client<Transport, chain, account>,
|
|
651
|
-
parameters: modifyWhitelistSync.Parameters<chain, account>,
|
|
652
|
-
): Promise<modifyWhitelistSync.ReturnValue> {
|
|
653
|
-
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
654
|
-
const receipt = await modifyWhitelist.inner(writeContractSync, client, {
|
|
655
|
-
...rest,
|
|
656
|
-
throwOnReceiptRevert,
|
|
657
|
-
} as never)
|
|
658
|
-
const { args } = modifyWhitelist.extractEvent(receipt.logs)
|
|
659
|
-
return {
|
|
660
|
-
...args,
|
|
661
|
-
receipt,
|
|
662
|
-
} as never
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
export namespace modifyWhitelistSync {
|
|
666
|
-
export type Parameters<
|
|
667
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
668
|
-
account extends Account | undefined = Account | undefined,
|
|
669
|
-
> = modifyWhitelist.Parameters<chain, account>
|
|
670
|
-
|
|
671
|
-
export type Args = modifyWhitelist.Args
|
|
672
|
-
|
|
673
|
-
export type ReturnValue = Compute<
|
|
674
|
-
GetEventArgs<
|
|
675
|
-
typeof Abis.tip403Registry,
|
|
676
|
-
'WhitelistUpdated',
|
|
677
|
-
{ IndexedOnly: false; Required: true }
|
|
678
|
-
> & {
|
|
679
|
-
receipt: TransactionReceipt
|
|
680
|
-
}
|
|
681
|
-
>
|
|
682
|
-
|
|
683
|
-
// TODO: exhaustive error type
|
|
684
|
-
export type ErrorType = BaseErrorType
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
/**
|
|
688
|
-
* Modifies a policy blacklist.
|
|
689
|
-
*
|
|
690
|
-
* @example
|
|
691
|
-
* ```ts
|
|
692
|
-
* import { createClient, http } from 'viem'
|
|
693
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
694
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
695
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
696
|
-
*
|
|
697
|
-
* const client = createClient({
|
|
698
|
-
* account: privateKeyToAccount('0x...'),
|
|
699
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
700
|
-
* transport: http(),
|
|
701
|
-
* })
|
|
702
|
-
*
|
|
703
|
-
* const hash = await Actions.policy.modifyBlacklist(client, {
|
|
704
|
-
* policyId: 2n,
|
|
705
|
-
* account: '0x...',
|
|
706
|
-
* restricted: true,
|
|
707
|
-
* })
|
|
708
|
-
* ```
|
|
709
|
-
*
|
|
710
|
-
* @param client - Client.
|
|
711
|
-
* @param parameters - Parameters.
|
|
712
|
-
* @returns The transaction hash.
|
|
713
|
-
*/
|
|
714
|
-
export async function modifyBlacklist<
|
|
715
|
-
chain extends Chain | undefined,
|
|
716
|
-
account extends Account | undefined,
|
|
717
|
-
>(
|
|
718
|
-
client: Client<Transport, chain, account>,
|
|
719
|
-
parameters: modifyBlacklist.Parameters<chain, account>,
|
|
720
|
-
): Promise<modifyBlacklist.ReturnValue> {
|
|
721
|
-
return modifyBlacklist.inner(writeContract, client, parameters)
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
export namespace modifyBlacklist {
|
|
725
|
-
export type Parameters<
|
|
726
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
727
|
-
account extends Account | undefined = Account | undefined,
|
|
728
|
-
> = WriteParameters<chain, account> & Args
|
|
729
|
-
|
|
730
|
-
export type Args = {
|
|
731
|
-
/** Target account address. */
|
|
732
|
-
address: Address
|
|
733
|
-
/** Policy ID. */
|
|
734
|
-
policyId: bigint
|
|
735
|
-
/** Whether the account is restricted. */
|
|
736
|
-
restricted: boolean
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
export type ReturnValue = WriteContractReturnType
|
|
740
|
-
|
|
741
|
-
// TODO: exhaustive error type
|
|
742
|
-
export type ErrorType = BaseErrorType
|
|
743
|
-
|
|
744
|
-
/** @internal */
|
|
745
|
-
export async function inner<
|
|
746
|
-
action extends typeof writeContract | typeof writeContractSync,
|
|
747
|
-
chain extends Chain | undefined,
|
|
748
|
-
account extends Account | undefined,
|
|
749
|
-
>(
|
|
750
|
-
action: action,
|
|
751
|
-
client: Client<Transport, chain, account>,
|
|
752
|
-
parameters: modifyBlacklist.Parameters<chain, account>,
|
|
753
|
-
): Promise<ReturnType<action>> {
|
|
754
|
-
const { address: targetAccount, policyId, restricted, ...rest } = parameters
|
|
755
|
-
const call = modifyBlacklist.call({
|
|
756
|
-
address: targetAccount,
|
|
757
|
-
policyId,
|
|
758
|
-
restricted,
|
|
759
|
-
})
|
|
760
|
-
return (await action(client, {
|
|
761
|
-
...rest,
|
|
762
|
-
...call,
|
|
763
|
-
} as never)) as never
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
/**
|
|
767
|
-
* Defines a call to the `modifyPolicyBlacklist` function.
|
|
768
|
-
*
|
|
769
|
-
* Can be passed as a parameter to:
|
|
770
|
-
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
771
|
-
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
772
|
-
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
773
|
-
*
|
|
774
|
-
* @example
|
|
775
|
-
* ```ts
|
|
776
|
-
* import { createClient, http, walletActions } from 'viem'
|
|
777
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
778
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
779
|
-
*
|
|
780
|
-
* const client = createClient({
|
|
781
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
782
|
-
* transport: http(),
|
|
783
|
-
* }).extend(walletActions)
|
|
784
|
-
*
|
|
785
|
-
* const { result } = await client.sendCalls({
|
|
786
|
-
* calls: [
|
|
787
|
-
* actions.policy.modifyBlacklist.call({
|
|
788
|
-
* policyId: 2n,
|
|
789
|
-
* address: '0x20c0...beef',
|
|
790
|
-
* restricted: true,
|
|
791
|
-
* }),
|
|
792
|
-
* actions.policy.modifyBlacklist.call({
|
|
793
|
-
* policyId: 2n,
|
|
794
|
-
* address: '0x20c0...babe',
|
|
795
|
-
* restricted: false,
|
|
796
|
-
* }),
|
|
797
|
-
* ]
|
|
798
|
-
* })
|
|
799
|
-
* ```
|
|
800
|
-
*
|
|
801
|
-
* @param args - Arguments.
|
|
802
|
-
* @returns The call.
|
|
803
|
-
*/
|
|
804
|
-
export function call(args: Args) {
|
|
805
|
-
const { policyId, address, restricted } = args
|
|
806
|
-
return defineCall({
|
|
807
|
-
address: Addresses.tip403Registry,
|
|
808
|
-
abi: Abis.tip403Registry,
|
|
809
|
-
functionName: 'modifyPolicyBlacklist',
|
|
810
|
-
args: [policyId, address, restricted],
|
|
811
|
-
})
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
/**
|
|
815
|
-
* Extracts the `BlacklistUpdated` event from logs.
|
|
816
|
-
*
|
|
817
|
-
* @param logs - The logs.
|
|
818
|
-
* @returns The `BlacklistUpdated` event.
|
|
819
|
-
*/
|
|
820
|
-
export function extractEvent(logs: Log[]) {
|
|
821
|
-
const [log] = parseEventLogs({
|
|
822
|
-
abi: Abis.tip403Registry,
|
|
823
|
-
logs,
|
|
824
|
-
eventName: 'BlacklistUpdated',
|
|
825
|
-
strict: true,
|
|
826
|
-
})
|
|
827
|
-
if (!log) throw new Error('`BlacklistUpdated` event not found.')
|
|
828
|
-
return log
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
/**
|
|
833
|
-
* Modifies a policy blacklist.
|
|
834
|
-
*
|
|
835
|
-
* @example
|
|
836
|
-
* ```ts
|
|
837
|
-
* import { createClient, http } from 'viem'
|
|
838
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
839
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
840
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
841
|
-
*
|
|
842
|
-
* const client = createClient({
|
|
843
|
-
* account: privateKeyToAccount('0x...'),
|
|
844
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
845
|
-
* transport: http(),
|
|
846
|
-
* })
|
|
847
|
-
*
|
|
848
|
-
* const result = await Actions.policy.modifyBlacklistSync(client, {
|
|
849
|
-
* policyId: 2n,
|
|
850
|
-
* account: '0x...',
|
|
851
|
-
* restricted: true,
|
|
852
|
-
* })
|
|
853
|
-
* ```
|
|
854
|
-
*
|
|
855
|
-
* @param client - Client.
|
|
856
|
-
* @param parameters - Parameters.
|
|
857
|
-
* @returns The transaction receipt and event data.
|
|
858
|
-
*/
|
|
859
|
-
export async function modifyBlacklistSync<
|
|
860
|
-
chain extends Chain | undefined,
|
|
861
|
-
account extends Account | undefined,
|
|
862
|
-
>(
|
|
863
|
-
client: Client<Transport, chain, account>,
|
|
864
|
-
parameters: modifyBlacklistSync.Parameters<chain, account>,
|
|
865
|
-
): Promise<modifyBlacklistSync.ReturnValue> {
|
|
866
|
-
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
867
|
-
const receipt = await modifyBlacklist.inner(writeContractSync, client, {
|
|
868
|
-
...rest,
|
|
869
|
-
throwOnReceiptRevert,
|
|
870
|
-
} as never)
|
|
871
|
-
const { args } = modifyBlacklist.extractEvent(receipt.logs)
|
|
872
|
-
return {
|
|
873
|
-
...args,
|
|
874
|
-
receipt,
|
|
875
|
-
} as never
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
export namespace modifyBlacklistSync {
|
|
879
|
-
export type Parameters<
|
|
880
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
881
|
-
account extends Account | undefined = Account | undefined,
|
|
882
|
-
> = modifyBlacklist.Parameters<chain, account>
|
|
883
|
-
|
|
884
|
-
export type Args = modifyBlacklist.Args
|
|
885
|
-
|
|
886
|
-
export type ReturnValue = Compute<
|
|
887
|
-
GetEventArgs<
|
|
888
|
-
typeof Abis.tip403Registry,
|
|
889
|
-
'BlacklistUpdated',
|
|
890
|
-
{ IndexedOnly: false; Required: true }
|
|
891
|
-
> & {
|
|
892
|
-
receipt: TransactionReceipt
|
|
893
|
-
}
|
|
894
|
-
>
|
|
895
|
-
|
|
896
|
-
// TODO: exhaustive error type
|
|
897
|
-
export type ErrorType = BaseErrorType
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Gets policy data.
|
|
902
|
-
*
|
|
903
|
-
* @example
|
|
904
|
-
* ```ts
|
|
905
|
-
* import { createClient, http } from 'viem'
|
|
906
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
907
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
908
|
-
*
|
|
909
|
-
* const client = createClient({
|
|
910
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
911
|
-
* transport: http(),
|
|
912
|
-
* })
|
|
913
|
-
*
|
|
914
|
-
* const data = await Actions.policy.getData(client, {
|
|
915
|
-
* policyId: 2n,
|
|
916
|
-
* })
|
|
917
|
-
* ```
|
|
918
|
-
*
|
|
919
|
-
* @param client - Client.
|
|
920
|
-
* @param parameters - Parameters.
|
|
921
|
-
* @returns The policy data.
|
|
922
|
-
*/
|
|
923
|
-
export async function getData<chain extends Chain | undefined>(
|
|
924
|
-
client: Client<Transport, chain>,
|
|
925
|
-
parameters: getData.Parameters,
|
|
926
|
-
): Promise<getData.ReturnValue> {
|
|
927
|
-
const { policyId, ...rest } = parameters
|
|
928
|
-
const result = await readContract(client, {
|
|
929
|
-
...rest,
|
|
930
|
-
...getData.call({ policyId }),
|
|
931
|
-
})
|
|
932
|
-
return {
|
|
933
|
-
admin: result[1],
|
|
934
|
-
type: result[0] === 0 ? 'whitelist' : 'blacklist',
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
export namespace getData {
|
|
939
|
-
export type Parameters = ReadParameters & Args
|
|
940
|
-
|
|
941
|
-
export type Args = {
|
|
942
|
-
/** Policy ID. */
|
|
943
|
-
policyId: bigint
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
export type ReturnValue = Compute<{
|
|
947
|
-
/** Admin address. */
|
|
948
|
-
admin: Address
|
|
949
|
-
/** Policy type. */
|
|
950
|
-
type: PolicyType
|
|
951
|
-
}>
|
|
952
|
-
|
|
953
|
-
/**
|
|
954
|
-
* Defines a call to the `policyData` function.
|
|
955
|
-
*
|
|
956
|
-
* @param args - Arguments.
|
|
957
|
-
* @returns The call.
|
|
958
|
-
*/
|
|
959
|
-
export function call(args: Args) {
|
|
960
|
-
const { policyId } = args
|
|
961
|
-
return defineCall({
|
|
962
|
-
address: Addresses.tip403Registry,
|
|
963
|
-
abi: Abis.tip403Registry,
|
|
964
|
-
args: [policyId],
|
|
965
|
-
functionName: 'policyData',
|
|
966
|
-
})
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
/**
|
|
971
|
-
* Checks if a user is authorized by a policy.
|
|
972
|
-
*
|
|
973
|
-
* @example
|
|
974
|
-
* ```ts
|
|
975
|
-
* import { createClient, http } from 'viem'
|
|
976
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
977
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
978
|
-
*
|
|
979
|
-
* const client = createClient({
|
|
980
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
981
|
-
* transport: http(),
|
|
982
|
-
* })
|
|
983
|
-
*
|
|
984
|
-
* const authorized = await Actions.policy.isAuthorized(client, {
|
|
985
|
-
* policyId: 2n,
|
|
986
|
-
* user: '0x...',
|
|
987
|
-
* })
|
|
988
|
-
* ```
|
|
989
|
-
*
|
|
990
|
-
* @param client - Client.
|
|
991
|
-
* @param parameters - Parameters.
|
|
992
|
-
* @returns Whether the user is authorized.
|
|
993
|
-
*/
|
|
994
|
-
export async function isAuthorized<chain extends Chain | undefined>(
|
|
995
|
-
client: Client<Transport, chain>,
|
|
996
|
-
parameters: isAuthorized.Parameters,
|
|
997
|
-
): Promise<isAuthorized.ReturnValue> {
|
|
998
|
-
const { policyId, user, ...rest } = parameters
|
|
999
|
-
return readContract(client, {
|
|
1000
|
-
...rest,
|
|
1001
|
-
...isAuthorized.call({ policyId, user }),
|
|
1002
|
-
})
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
export namespace isAuthorized {
|
|
1006
|
-
export type Parameters = ReadParameters & Args
|
|
1007
|
-
|
|
1008
|
-
export type Args = {
|
|
1009
|
-
/** Policy ID. */
|
|
1010
|
-
policyId: bigint
|
|
1011
|
-
/** User address to check. */
|
|
1012
|
-
user: Address
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
export type ReturnValue = ReadContractReturnType<
|
|
1016
|
-
typeof Abis.tip403Registry,
|
|
1017
|
-
'isAuthorized',
|
|
1018
|
-
never
|
|
1019
|
-
>
|
|
1020
|
-
|
|
1021
|
-
/**
|
|
1022
|
-
* Defines a call to the `isAuthorized` function.
|
|
1023
|
-
*
|
|
1024
|
-
* @param args - Arguments.
|
|
1025
|
-
* @returns The call.
|
|
1026
|
-
*/
|
|
1027
|
-
export function call(args: Args) {
|
|
1028
|
-
const { policyId, user } = args
|
|
1029
|
-
return defineCall({
|
|
1030
|
-
address: Addresses.tip403Registry,
|
|
1031
|
-
abi: Abis.tip403Registry,
|
|
1032
|
-
args: [policyId, user],
|
|
1033
|
-
functionName: 'isAuthorized',
|
|
1034
|
-
})
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
/**
|
|
1039
|
-
* Watches for policy creation events.
|
|
1040
|
-
*
|
|
1041
|
-
* @example
|
|
1042
|
-
* ```ts
|
|
1043
|
-
* import { createClient, http } from 'viem'
|
|
1044
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
1045
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
1046
|
-
*
|
|
1047
|
-
* const client = createClient({
|
|
1048
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1049
|
-
* transport: http(),
|
|
1050
|
-
* })
|
|
1051
|
-
*
|
|
1052
|
-
* const unwatch = actions.policy.watchCreate(client, {
|
|
1053
|
-
* onPolicyCreated: (args, log) => {
|
|
1054
|
-
* console.log('Policy created:', args)
|
|
1055
|
-
* },
|
|
1056
|
-
* })
|
|
1057
|
-
* ```
|
|
1058
|
-
*
|
|
1059
|
-
* @param client - Client.
|
|
1060
|
-
* @param parameters - Parameters.
|
|
1061
|
-
* @returns A function to unsubscribe from the event.
|
|
1062
|
-
*/
|
|
1063
|
-
export function watchCreate<
|
|
1064
|
-
chain extends Chain | undefined,
|
|
1065
|
-
account extends Account | undefined,
|
|
1066
|
-
>(
|
|
1067
|
-
client: Client<Transport, chain, account>,
|
|
1068
|
-
parameters: watchCreate.Parameters,
|
|
1069
|
-
) {
|
|
1070
|
-
const { onPolicyCreated, ...rest } = parameters
|
|
1071
|
-
return watchContractEvent(client, {
|
|
1072
|
-
...rest,
|
|
1073
|
-
address: Addresses.tip403Registry,
|
|
1074
|
-
abi: Abis.tip403Registry,
|
|
1075
|
-
eventName: 'PolicyCreated',
|
|
1076
|
-
onLogs: (logs) => {
|
|
1077
|
-
for (const log of logs)
|
|
1078
|
-
onPolicyCreated(
|
|
1079
|
-
{
|
|
1080
|
-
...log.args,
|
|
1081
|
-
type: log.args.policyType === 0 ? 'whitelist' : 'blacklist',
|
|
1082
|
-
},
|
|
1083
|
-
log,
|
|
1084
|
-
)
|
|
1085
|
-
},
|
|
1086
|
-
strict: true,
|
|
1087
|
-
})
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
export declare namespace watchCreate {
|
|
1091
|
-
export type Args = Compute<{
|
|
1092
|
-
policyId: bigint
|
|
1093
|
-
updater: Address
|
|
1094
|
-
type: PolicyType
|
|
1095
|
-
}>
|
|
1096
|
-
|
|
1097
|
-
export type Log = viem_Log<
|
|
1098
|
-
bigint,
|
|
1099
|
-
number,
|
|
1100
|
-
false,
|
|
1101
|
-
ExtractAbiItem<typeof Abis.tip403Registry, 'PolicyCreated'>,
|
|
1102
|
-
true
|
|
1103
|
-
>
|
|
1104
|
-
|
|
1105
|
-
export type Parameters = UnionOmit<
|
|
1106
|
-
WatchContractEventParameters<
|
|
1107
|
-
typeof Abis.tip403Registry,
|
|
1108
|
-
'PolicyCreated',
|
|
1109
|
-
true
|
|
1110
|
-
>,
|
|
1111
|
-
'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'
|
|
1112
|
-
> & {
|
|
1113
|
-
/** Callback to invoke when a policy is created. */
|
|
1114
|
-
onPolicyCreated: (args: Args, log: Log) => void
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
/**
|
|
1119
|
-
* Watches for policy admin update events.
|
|
1120
|
-
*
|
|
1121
|
-
* @example
|
|
1122
|
-
* ```ts
|
|
1123
|
-
* import { createClient, http } from 'viem'
|
|
1124
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
1125
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
1126
|
-
*
|
|
1127
|
-
* const client = createClient({
|
|
1128
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1129
|
-
* transport: http(),
|
|
1130
|
-
* })
|
|
1131
|
-
*
|
|
1132
|
-
* const unwatch = actions.policy.watchAdminUpdated(client, {
|
|
1133
|
-
* onAdminUpdated: (args, log) => {
|
|
1134
|
-
* console.log('Policy admin updated:', args)
|
|
1135
|
-
* },
|
|
1136
|
-
* })
|
|
1137
|
-
* ```
|
|
1138
|
-
*
|
|
1139
|
-
* @param client - Client.
|
|
1140
|
-
* @param parameters - Parameters.
|
|
1141
|
-
* @returns A function to unsubscribe from the event.
|
|
1142
|
-
*/
|
|
1143
|
-
export function watchAdminUpdated<
|
|
1144
|
-
chain extends Chain | undefined,
|
|
1145
|
-
account extends Account | undefined,
|
|
1146
|
-
>(
|
|
1147
|
-
client: Client<Transport, chain, account>,
|
|
1148
|
-
parameters: watchAdminUpdated.Parameters,
|
|
1149
|
-
) {
|
|
1150
|
-
const { onAdminUpdated, ...rest } = parameters
|
|
1151
|
-
return watchContractEvent(client, {
|
|
1152
|
-
...rest,
|
|
1153
|
-
address: Addresses.tip403Registry,
|
|
1154
|
-
abi: Abis.tip403Registry,
|
|
1155
|
-
eventName: 'PolicyAdminUpdated',
|
|
1156
|
-
onLogs: (logs) => {
|
|
1157
|
-
for (const log of logs) onAdminUpdated(log.args, log)
|
|
1158
|
-
},
|
|
1159
|
-
strict: true,
|
|
1160
|
-
})
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
export declare namespace watchAdminUpdated {
|
|
1164
|
-
export type Args = GetEventArgs<
|
|
1165
|
-
typeof Abis.tip403Registry,
|
|
1166
|
-
'PolicyAdminUpdated',
|
|
1167
|
-
{ IndexedOnly: false; Required: true }
|
|
1168
|
-
>
|
|
1169
|
-
|
|
1170
|
-
export type Log = viem_Log<
|
|
1171
|
-
bigint,
|
|
1172
|
-
number,
|
|
1173
|
-
false,
|
|
1174
|
-
ExtractAbiItem<typeof Abis.tip403Registry, 'PolicyAdminUpdated'>,
|
|
1175
|
-
true
|
|
1176
|
-
>
|
|
1177
|
-
|
|
1178
|
-
export type Parameters = UnionOmit<
|
|
1179
|
-
WatchContractEventParameters<
|
|
1180
|
-
typeof Abis.tip403Registry,
|
|
1181
|
-
'PolicyAdminUpdated',
|
|
1182
|
-
true
|
|
1183
|
-
>,
|
|
1184
|
-
'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'
|
|
1185
|
-
> & {
|
|
1186
|
-
/** Callback to invoke when a policy admin is updated. */
|
|
1187
|
-
onAdminUpdated: (args: Args, log: Log) => void
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* Watches for whitelist update events.
|
|
1193
|
-
*
|
|
1194
|
-
* @example
|
|
1195
|
-
* ```ts
|
|
1196
|
-
* import { createClient, http } from 'viem'
|
|
1197
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
1198
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
1199
|
-
*
|
|
1200
|
-
* const client = createClient({
|
|
1201
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1202
|
-
* transport: http(),
|
|
1203
|
-
* })
|
|
1204
|
-
*
|
|
1205
|
-
* const unwatch = actions.policy.watchWhitelistUpdated(client, {
|
|
1206
|
-
* onWhitelistUpdated: (args, log) => {
|
|
1207
|
-
* console.log('Whitelist updated:', args)
|
|
1208
|
-
* },
|
|
1209
|
-
* })
|
|
1210
|
-
* ```
|
|
1211
|
-
*
|
|
1212
|
-
* @param client - Client.
|
|
1213
|
-
* @param parameters - Parameters.
|
|
1214
|
-
* @returns A function to unsubscribe from the event.
|
|
1215
|
-
*/
|
|
1216
|
-
export function watchWhitelistUpdated<
|
|
1217
|
-
chain extends Chain | undefined,
|
|
1218
|
-
account extends Account | undefined,
|
|
1219
|
-
>(
|
|
1220
|
-
client: Client<Transport, chain, account>,
|
|
1221
|
-
parameters: watchWhitelistUpdated.Parameters,
|
|
1222
|
-
) {
|
|
1223
|
-
const { onWhitelistUpdated, ...rest } = parameters
|
|
1224
|
-
return watchContractEvent(client, {
|
|
1225
|
-
...rest,
|
|
1226
|
-
address: Addresses.tip403Registry,
|
|
1227
|
-
abi: Abis.tip403Registry,
|
|
1228
|
-
eventName: 'WhitelistUpdated',
|
|
1229
|
-
onLogs: (logs) => {
|
|
1230
|
-
for (const log of logs) onWhitelistUpdated(log.args, log)
|
|
1231
|
-
},
|
|
1232
|
-
strict: true,
|
|
1233
|
-
})
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
export declare namespace watchWhitelistUpdated {
|
|
1237
|
-
export type Args = GetEventArgs<
|
|
1238
|
-
typeof Abis.tip403Registry,
|
|
1239
|
-
'WhitelistUpdated',
|
|
1240
|
-
{ IndexedOnly: false; Required: true }
|
|
1241
|
-
>
|
|
1242
|
-
|
|
1243
|
-
export type Log = viem_Log<
|
|
1244
|
-
bigint,
|
|
1245
|
-
number,
|
|
1246
|
-
false,
|
|
1247
|
-
ExtractAbiItem<typeof Abis.tip403Registry, 'WhitelistUpdated'>,
|
|
1248
|
-
true
|
|
1249
|
-
>
|
|
1250
|
-
|
|
1251
|
-
export type Parameters = UnionOmit<
|
|
1252
|
-
WatchContractEventParameters<
|
|
1253
|
-
typeof Abis.tip403Registry,
|
|
1254
|
-
'WhitelistUpdated',
|
|
1255
|
-
true
|
|
1256
|
-
>,
|
|
1257
|
-
'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'
|
|
1258
|
-
> & {
|
|
1259
|
-
/** Callback to invoke when a whitelist is updated. */
|
|
1260
|
-
onWhitelistUpdated: (args: Args, log: Log) => void
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
/**
|
|
1265
|
-
* Watches for blacklist update events.
|
|
1266
|
-
*
|
|
1267
|
-
* @example
|
|
1268
|
-
* ```ts
|
|
1269
|
-
* import { createClient, http } from 'viem'
|
|
1270
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
1271
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
1272
|
-
*
|
|
1273
|
-
* const client = createClient({
|
|
1274
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1275
|
-
* transport: http(),
|
|
1276
|
-
* })
|
|
1277
|
-
*
|
|
1278
|
-
* const unwatch = actions.policy.watchBlacklistUpdated(client, {
|
|
1279
|
-
* onBlacklistUpdated: (args, log) => {
|
|
1280
|
-
* console.log('Blacklist updated:', args)
|
|
1281
|
-
* },
|
|
1282
|
-
* })
|
|
1283
|
-
* ```
|
|
1284
|
-
*
|
|
1285
|
-
* @param client - Client.
|
|
1286
|
-
* @param parameters - Parameters.
|
|
1287
|
-
* @returns A function to unsubscribe from the event.
|
|
1288
|
-
*/
|
|
1289
|
-
export function watchBlacklistUpdated<
|
|
1290
|
-
chain extends Chain | undefined,
|
|
1291
|
-
account extends Account | undefined,
|
|
1292
|
-
>(
|
|
1293
|
-
client: Client<Transport, chain, account>,
|
|
1294
|
-
parameters: watchBlacklistUpdated.Parameters,
|
|
1295
|
-
) {
|
|
1296
|
-
const { onBlacklistUpdated, ...rest } = parameters
|
|
1297
|
-
return watchContractEvent(client, {
|
|
1298
|
-
...rest,
|
|
1299
|
-
address: Addresses.tip403Registry,
|
|
1300
|
-
abi: Abis.tip403Registry,
|
|
1301
|
-
eventName: 'BlacklistUpdated',
|
|
1302
|
-
onLogs: (logs) => {
|
|
1303
|
-
for (const log of logs) onBlacklistUpdated(log.args, log)
|
|
1304
|
-
},
|
|
1305
|
-
strict: true,
|
|
1306
|
-
})
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
export declare namespace watchBlacklistUpdated {
|
|
1310
|
-
export type Args = GetEventArgs<
|
|
1311
|
-
typeof Abis.tip403Registry,
|
|
1312
|
-
'BlacklistUpdated',
|
|
1313
|
-
{ IndexedOnly: false; Required: true }
|
|
1314
|
-
>
|
|
1315
|
-
|
|
1316
|
-
export type Log = viem_Log<
|
|
1317
|
-
bigint,
|
|
1318
|
-
number,
|
|
1319
|
-
false,
|
|
1320
|
-
ExtractAbiItem<typeof Abis.tip403Registry, 'BlacklistUpdated'>,
|
|
1321
|
-
true
|
|
1322
|
-
>
|
|
1323
|
-
|
|
1324
|
-
export type Parameters = UnionOmit<
|
|
1325
|
-
WatchContractEventParameters<
|
|
1326
|
-
typeof Abis.tip403Registry,
|
|
1327
|
-
'BlacklistUpdated',
|
|
1328
|
-
true
|
|
1329
|
-
>,
|
|
1330
|
-
'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'
|
|
1331
|
-
> & {
|
|
1332
|
-
/** Callback to invoke when a blacklist is updated. */
|
|
1333
|
-
onBlacklistUpdated: (args: Args, log: Log) => void
|
|
1334
|
-
}
|
|
1335
|
-
}
|