@wagmi/core 3.0.2 → 3.2.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/esm/exports/internal.js.map +1 -1
- package/dist/esm/exports/query.js +1 -1
- package/dist/esm/exports/query.js.map +1 -1
- package/dist/esm/exports/tempo.js +9 -0
- package/dist/esm/exports/tempo.js.map +1 -0
- package/dist/esm/tempo/Connectors.js +534 -0
- package/dist/esm/tempo/Connectors.js.map +1 -0
- package/dist/esm/tempo/KeyManager.js +106 -0
- package/dist/esm/tempo/KeyManager.js.map +1 -0
- package/dist/esm/tempo/actions/amm.js +437 -0
- package/dist/esm/tempo/actions/amm.js.map +1 -0
- package/dist/esm/tempo/actions/dex.js +1059 -0
- package/dist/esm/tempo/actions/dex.js.map +1 -0
- package/dist/esm/tempo/actions/faucet.js +64 -0
- package/dist/esm/tempo/actions/faucet.js.map +1 -0
- package/dist/esm/tempo/actions/fee.js +160 -0
- package/dist/esm/tempo/actions/fee.js.map +1 -0
- package/dist/esm/tempo/actions/index.js +11 -0
- package/dist/esm/tempo/actions/index.js.map +1 -0
- package/dist/esm/tempo/actions/nonce.js +91 -0
- package/dist/esm/tempo/actions/nonce.js.map +1 -0
- package/dist/esm/tempo/actions/policy.js +532 -0
- package/dist/esm/tempo/actions/policy.js.map +1 -0
- package/dist/esm/tempo/actions/reward.js +384 -0
- package/dist/esm/tempo/actions/reward.js.map +1 -0
- package/dist/esm/tempo/actions/token.js +1717 -0
- package/dist/esm/tempo/actions/token.js.map +1 -0
- package/dist/esm/tempo/actions/utils.js +2 -0
- package/dist/esm/tempo/actions/utils.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/exports/internal.d.ts +1 -1
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/exports/query.d.ts +1 -1
- package/dist/types/exports/query.d.ts.map +1 -1
- package/dist/types/exports/tempo.d.ts +5 -0
- package/dist/types/exports/tempo.d.ts.map +1 -0
- package/dist/types/tempo/Connectors.d.ts +99 -0
- package/dist/types/tempo/Connectors.d.ts.map +1 -0
- package/dist/types/tempo/KeyManager.d.ts +71 -0
- package/dist/types/tempo/KeyManager.d.ts.map +1 -0
- package/dist/types/tempo/actions/amm.d.ts +387 -0
- package/dist/types/tempo/actions/amm.d.ts.map +1 -0
- package/dist/types/tempo/actions/dex.d.ts +926 -0
- package/dist/types/tempo/actions/dex.d.ts.map +1 -0
- package/dist/types/tempo/actions/faucet.d.ts +70 -0
- package/dist/types/tempo/actions/faucet.d.ts.map +1 -0
- package/dist/types/tempo/actions/fee.d.ts +141 -0
- package/dist/types/tempo/actions/fee.d.ts.map +1 -0
- package/dist/types/tempo/actions/index.d.ts +10 -0
- package/dist/types/tempo/actions/index.d.ts.map +1 -0
- package/dist/types/tempo/actions/nonce.d.ts +79 -0
- package/dist/types/tempo/actions/nonce.d.ts.map +1 -0
- package/dist/types/tempo/actions/policy.d.ts +478 -0
- package/dist/types/tempo/actions/policy.d.ts.map +1 -0
- package/dist/types/tempo/actions/reward.d.ts +340 -0
- package/dist/types/tempo/actions/reward.d.ts.map +1 -0
- package/dist/types/tempo/actions/token.d.ts +1531 -0
- package/dist/types/tempo/actions/token.d.ts.map +1 -0
- package/dist/types/tempo/actions/utils.d.ts +9 -0
- package/dist/types/tempo/actions/utils.d.ts.map +1 -0
- package/dist/types/types/utils.d.ts +16 -0
- package/dist/types/types/utils.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +14 -2
- package/src/exports/internal.ts +3 -0
- package/src/exports/query.ts +4 -1
- package/src/exports/tempo.ts +14 -0
- package/src/tempo/Connectors.ts +762 -0
- package/src/tempo/KeyManager.ts +176 -0
- package/src/tempo/actions/amm.ts +678 -0
- package/src/tempo/actions/dex.ts +1685 -0
- package/src/tempo/actions/faucet.ts +95 -0
- package/src/tempo/actions/fee.ts +259 -0
- package/src/tempo/actions/index.ts +10 -0
- package/src/tempo/actions/nonce.ts +147 -0
- package/src/tempo/actions/policy.ts +827 -0
- package/src/tempo/actions/reward.ts +624 -0
- package/src/tempo/actions/token.ts +2598 -0
- package/src/tempo/actions/utils.ts +26 -0
- package/src/types/utils.ts +19 -0
- package/src/version.ts +1 -1
- package/tempo/package.json +5 -0
|
@@ -0,0 +1,827 @@
|
|
|
1
|
+
import type { Account, BaseErrorType } from 'viem'
|
|
2
|
+
import { Actions } from 'viem/tempo'
|
|
3
|
+
import { getConnectorClient } from '../../actions/getConnectorClient.js'
|
|
4
|
+
import type { Config } from '../../createConfig.js'
|
|
5
|
+
import type {
|
|
6
|
+
ChainIdParameter,
|
|
7
|
+
ConnectorParameter,
|
|
8
|
+
} from '../../types/properties.js'
|
|
9
|
+
import type { UnionLooseOmit } from '../../types/utils.js'
|
|
10
|
+
import type { QueryOptions, QueryParameter } from './utils.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new policy.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
18
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
19
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
20
|
+
*
|
|
21
|
+
* const config = createConfig({
|
|
22
|
+
* chains: [tempoModerato],
|
|
23
|
+
* transports: {
|
|
24
|
+
* [tempo.id]: http(),
|
|
25
|
+
* },
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* const hash = await Actions.policy.create(config, {
|
|
29
|
+
* type: 'whitelist',
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param config - Config.
|
|
34
|
+
* @param parameters - Parameters.
|
|
35
|
+
* @returns Transaction hash.
|
|
36
|
+
*/
|
|
37
|
+
export async function create<config extends Config>(
|
|
38
|
+
config: config,
|
|
39
|
+
parameters: create.Parameters<config>,
|
|
40
|
+
): Promise<Actions.policy.create.ReturnValue> {
|
|
41
|
+
const { account, chainId, connector } = parameters
|
|
42
|
+
|
|
43
|
+
const client = await getConnectorClient(config, {
|
|
44
|
+
account,
|
|
45
|
+
assertChainId: false,
|
|
46
|
+
chainId,
|
|
47
|
+
connector,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return Actions.policy.create(client, parameters as never)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export declare namespace create {
|
|
54
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
55
|
+
ConnectorParameter &
|
|
56
|
+
UnionLooseOmit<
|
|
57
|
+
Actions.policy.create.Parameters<config['chains'][number], Account>,
|
|
58
|
+
'chain' | 'admin'
|
|
59
|
+
>
|
|
60
|
+
|
|
61
|
+
export type ReturnValue = Actions.policy.create.ReturnValue
|
|
62
|
+
|
|
63
|
+
export type ErrorType = BaseErrorType // TODO: Actions.policy.create.ErrorType
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new policy.
|
|
68
|
+
*
|
|
69
|
+
* Note: This is a synchronous action that waits for the transaction to
|
|
70
|
+
* be included on a block before returning a response.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
75
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
76
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
77
|
+
*
|
|
78
|
+
* const config = createConfig({
|
|
79
|
+
* chains: [tempoModerato],
|
|
80
|
+
* transports: {
|
|
81
|
+
* [tempo.id]: http(),
|
|
82
|
+
* },
|
|
83
|
+
* })
|
|
84
|
+
*
|
|
85
|
+
* const result = await Actions.policy.createSync(config, {
|
|
86
|
+
* type: 'whitelist',
|
|
87
|
+
* })
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @param config - Config.
|
|
91
|
+
* @param parameters - Parameters.
|
|
92
|
+
* @returns The transaction receipt and event data.
|
|
93
|
+
*/
|
|
94
|
+
export async function createSync<config extends Config>(
|
|
95
|
+
config: config,
|
|
96
|
+
parameters: createSync.Parameters<config>,
|
|
97
|
+
): Promise<Actions.policy.createSync.ReturnValue> {
|
|
98
|
+
const { account, chainId, connector } = parameters
|
|
99
|
+
|
|
100
|
+
const client = await getConnectorClient(config, {
|
|
101
|
+
account,
|
|
102
|
+
assertChainId: false,
|
|
103
|
+
chainId,
|
|
104
|
+
connector,
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
return Actions.policy.createSync(client, parameters as never)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export declare namespace createSync {
|
|
111
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
112
|
+
ConnectorParameter &
|
|
113
|
+
UnionLooseOmit<
|
|
114
|
+
Actions.policy.createSync.Parameters<config['chains'][number], Account>,
|
|
115
|
+
'chain' | 'admin'
|
|
116
|
+
>
|
|
117
|
+
|
|
118
|
+
export type ReturnValue = Actions.policy.createSync.ReturnValue
|
|
119
|
+
|
|
120
|
+
export type ErrorType = BaseErrorType // TODO: Actions.policy.createSync.ErrorType
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Sets the admin for a policy.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
129
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
130
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
131
|
+
*
|
|
132
|
+
* const config = createConfig({
|
|
133
|
+
* chains: [tempoModerato],
|
|
134
|
+
* transports: {
|
|
135
|
+
* [tempo.id]: http(),
|
|
136
|
+
* },
|
|
137
|
+
* })
|
|
138
|
+
*
|
|
139
|
+
* const hash = await Actions.policy.setAdmin(config, {
|
|
140
|
+
* policyId: 2n,
|
|
141
|
+
* admin: '0x...',
|
|
142
|
+
* })
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @param config - Config.
|
|
146
|
+
* @param parameters - Parameters.
|
|
147
|
+
* @returns Transaction hash.
|
|
148
|
+
*/
|
|
149
|
+
export async function setAdmin<config extends Config>(
|
|
150
|
+
config: config,
|
|
151
|
+
parameters: setAdmin.Parameters<config>,
|
|
152
|
+
): Promise<Actions.policy.setAdmin.ReturnValue> {
|
|
153
|
+
const { account, chainId, connector } = parameters
|
|
154
|
+
|
|
155
|
+
const client = await getConnectorClient(config, {
|
|
156
|
+
account,
|
|
157
|
+
assertChainId: false,
|
|
158
|
+
chainId,
|
|
159
|
+
connector,
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
return Actions.policy.setAdmin(client, parameters as never)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export declare namespace setAdmin {
|
|
166
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
167
|
+
ConnectorParameter &
|
|
168
|
+
UnionLooseOmit<
|
|
169
|
+
Actions.policy.setAdmin.Parameters<config['chains'][number], Account>,
|
|
170
|
+
'chain'
|
|
171
|
+
>
|
|
172
|
+
|
|
173
|
+
export type ReturnValue = Actions.policy.setAdmin.ReturnValue
|
|
174
|
+
|
|
175
|
+
export type ErrorType = BaseErrorType // TODO: Actions.policy.setAdmin.ErrorType
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Sets the admin for a policy.
|
|
180
|
+
*
|
|
181
|
+
* Note: This is a synchronous action that waits for the transaction to
|
|
182
|
+
* be included on a block before returning a response.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
187
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
188
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
189
|
+
*
|
|
190
|
+
* const config = createConfig({
|
|
191
|
+
* chains: [tempoModerato],
|
|
192
|
+
* transports: {
|
|
193
|
+
* [tempo.id]: http(),
|
|
194
|
+
* },
|
|
195
|
+
* })
|
|
196
|
+
*
|
|
197
|
+
* const result = await Actions.policy.setAdminSync(config, {
|
|
198
|
+
* policyId: 2n,
|
|
199
|
+
* admin: '0x...',
|
|
200
|
+
* })
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @param config - Config.
|
|
204
|
+
* @param parameters - Parameters.
|
|
205
|
+
* @returns The transaction receipt and event data.
|
|
206
|
+
*/
|
|
207
|
+
export async function setAdminSync<config extends Config>(
|
|
208
|
+
config: config,
|
|
209
|
+
parameters: setAdminSync.Parameters<config>,
|
|
210
|
+
): Promise<Actions.policy.setAdminSync.ReturnValue> {
|
|
211
|
+
const { account, chainId, connector } = parameters
|
|
212
|
+
|
|
213
|
+
const client = await getConnectorClient(config, {
|
|
214
|
+
account,
|
|
215
|
+
assertChainId: false,
|
|
216
|
+
chainId,
|
|
217
|
+
connector,
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
return Actions.policy.setAdminSync(client, parameters as never)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export declare namespace setAdminSync {
|
|
224
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
225
|
+
ConnectorParameter &
|
|
226
|
+
UnionLooseOmit<
|
|
227
|
+
Actions.policy.setAdminSync.Parameters<config['chains'][number], Account>,
|
|
228
|
+
'chain'
|
|
229
|
+
>
|
|
230
|
+
|
|
231
|
+
export type ReturnValue = Actions.policy.setAdminSync.ReturnValue
|
|
232
|
+
|
|
233
|
+
export type ErrorType = BaseErrorType // TODO: Actions.policy.setAdminSync.ErrorType
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Modifies a policy whitelist.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
242
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
243
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
244
|
+
*
|
|
245
|
+
* const config = createConfig({
|
|
246
|
+
* chains: [tempoModerato],
|
|
247
|
+
* transports: {
|
|
248
|
+
* [tempo.id]: http(),
|
|
249
|
+
* },
|
|
250
|
+
* })
|
|
251
|
+
*
|
|
252
|
+
* const hash = await Actions.policy.modifyWhitelist(config, {
|
|
253
|
+
* policyId: 2n,
|
|
254
|
+
* address: '0x...',
|
|
255
|
+
* allowed: true,
|
|
256
|
+
* })
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* @param config - Config.
|
|
260
|
+
* @param parameters - Parameters.
|
|
261
|
+
* @returns Transaction hash.
|
|
262
|
+
*/
|
|
263
|
+
export async function modifyWhitelist<config extends Config>(
|
|
264
|
+
config: config,
|
|
265
|
+
parameters: modifyWhitelist.Parameters<config>,
|
|
266
|
+
): Promise<Actions.policy.modifyWhitelist.ReturnValue> {
|
|
267
|
+
const { account, chainId, connector } = parameters
|
|
268
|
+
|
|
269
|
+
const client = await getConnectorClient(config, {
|
|
270
|
+
account,
|
|
271
|
+
assertChainId: false,
|
|
272
|
+
chainId,
|
|
273
|
+
connector,
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
return Actions.policy.modifyWhitelist(client, parameters as never)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export declare namespace modifyWhitelist {
|
|
280
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
281
|
+
ConnectorParameter &
|
|
282
|
+
UnionLooseOmit<
|
|
283
|
+
Actions.policy.modifyWhitelist.Parameters<
|
|
284
|
+
config['chains'][number],
|
|
285
|
+
Account
|
|
286
|
+
>,
|
|
287
|
+
'chain'
|
|
288
|
+
>
|
|
289
|
+
|
|
290
|
+
export type ReturnValue = Actions.policy.modifyWhitelist.ReturnValue
|
|
291
|
+
|
|
292
|
+
export type ErrorType = BaseErrorType // TODO: Actions.policy.modifyWhitelist.ErrorType
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Modifies a policy whitelist.
|
|
297
|
+
*
|
|
298
|
+
* Note: This is a synchronous action that waits for the transaction to
|
|
299
|
+
* be included on a block before returning a response.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
304
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
305
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
306
|
+
*
|
|
307
|
+
* const config = createConfig({
|
|
308
|
+
* chains: [tempoModerato],
|
|
309
|
+
* transports: {
|
|
310
|
+
* [tempo.id]: http(),
|
|
311
|
+
* },
|
|
312
|
+
* })
|
|
313
|
+
*
|
|
314
|
+
* const result = await Actions.policy.modifyWhitelistSync(config, {
|
|
315
|
+
* policyId: 2n,
|
|
316
|
+
* address: '0x...',
|
|
317
|
+
* allowed: true,
|
|
318
|
+
* })
|
|
319
|
+
* ```
|
|
320
|
+
*
|
|
321
|
+
* @param config - Config.
|
|
322
|
+
* @param parameters - Parameters.
|
|
323
|
+
* @returns The transaction receipt and event data.
|
|
324
|
+
*/
|
|
325
|
+
export async function modifyWhitelistSync<config extends Config>(
|
|
326
|
+
config: config,
|
|
327
|
+
parameters: modifyWhitelistSync.Parameters<config>,
|
|
328
|
+
): Promise<Actions.policy.modifyWhitelistSync.ReturnValue> {
|
|
329
|
+
const { account, chainId, connector } = parameters
|
|
330
|
+
|
|
331
|
+
const client = await getConnectorClient(config, {
|
|
332
|
+
account,
|
|
333
|
+
assertChainId: false,
|
|
334
|
+
chainId,
|
|
335
|
+
connector,
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
return Actions.policy.modifyWhitelistSync(client, parameters as never)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export declare namespace modifyWhitelistSync {
|
|
342
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
343
|
+
ConnectorParameter &
|
|
344
|
+
UnionLooseOmit<
|
|
345
|
+
Actions.policy.modifyWhitelistSync.Parameters<
|
|
346
|
+
config['chains'][number],
|
|
347
|
+
Account
|
|
348
|
+
>,
|
|
349
|
+
'chain'
|
|
350
|
+
>
|
|
351
|
+
|
|
352
|
+
export type ReturnValue = Actions.policy.modifyWhitelistSync.ReturnValue
|
|
353
|
+
|
|
354
|
+
export type ErrorType = BaseErrorType // TODO: Actions.policy.modifyWhitelistSync.ErrorType
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Modifies a policy blacklist.
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```ts
|
|
362
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
363
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
364
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
365
|
+
*
|
|
366
|
+
* const config = createConfig({
|
|
367
|
+
* chains: [tempoModerato],
|
|
368
|
+
* transports: {
|
|
369
|
+
* [tempo.id]: http(),
|
|
370
|
+
* },
|
|
371
|
+
* })
|
|
372
|
+
*
|
|
373
|
+
* const hash = await Actions.policy.modifyBlacklist(config, {
|
|
374
|
+
* policyId: 2n,
|
|
375
|
+
* address: '0x...',
|
|
376
|
+
* restricted: true,
|
|
377
|
+
* })
|
|
378
|
+
* ```
|
|
379
|
+
*
|
|
380
|
+
* @param config - Config.
|
|
381
|
+
* @param parameters - Parameters.
|
|
382
|
+
* @returns Transaction hash.
|
|
383
|
+
*/
|
|
384
|
+
export async function modifyBlacklist<config extends Config>(
|
|
385
|
+
config: config,
|
|
386
|
+
parameters: modifyBlacklist.Parameters<config>,
|
|
387
|
+
): Promise<Actions.policy.modifyBlacklist.ReturnValue> {
|
|
388
|
+
const { account, chainId, connector } = parameters
|
|
389
|
+
|
|
390
|
+
const client = await getConnectorClient(config, {
|
|
391
|
+
account,
|
|
392
|
+
assertChainId: false,
|
|
393
|
+
chainId,
|
|
394
|
+
connector,
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
return Actions.policy.modifyBlacklist(client, parameters as never)
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export declare namespace modifyBlacklist {
|
|
401
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
402
|
+
ConnectorParameter &
|
|
403
|
+
UnionLooseOmit<
|
|
404
|
+
Actions.policy.modifyBlacklist.Parameters<
|
|
405
|
+
config['chains'][number],
|
|
406
|
+
Account
|
|
407
|
+
>,
|
|
408
|
+
'chain'
|
|
409
|
+
>
|
|
410
|
+
|
|
411
|
+
export type ReturnValue = Actions.policy.modifyBlacklist.ReturnValue
|
|
412
|
+
|
|
413
|
+
export type ErrorType = BaseErrorType // TODO: Actions.policy.modifyBlacklist.ErrorType
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Modifies a policy blacklist.
|
|
418
|
+
*
|
|
419
|
+
* Note: This is a synchronous action that waits for the transaction to
|
|
420
|
+
* be included on a block before returning a response.
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```ts
|
|
424
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
425
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
426
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
427
|
+
*
|
|
428
|
+
* const config = createConfig({
|
|
429
|
+
* chains: [tempoModerato],
|
|
430
|
+
* transports: {
|
|
431
|
+
* [tempo.id]: http(),
|
|
432
|
+
* },
|
|
433
|
+
* })
|
|
434
|
+
*
|
|
435
|
+
* const result = await Actions.policy.modifyBlacklistSync(config, {
|
|
436
|
+
* policyId: 2n,
|
|
437
|
+
* address: '0x...',
|
|
438
|
+
* restricted: true,
|
|
439
|
+
* })
|
|
440
|
+
* ```
|
|
441
|
+
*
|
|
442
|
+
* @param config - Config.
|
|
443
|
+
* @param parameters - Parameters.
|
|
444
|
+
* @returns The transaction receipt and event data.
|
|
445
|
+
*/
|
|
446
|
+
export async function modifyBlacklistSync<config extends Config>(
|
|
447
|
+
config: config,
|
|
448
|
+
parameters: modifyBlacklistSync.Parameters<config>,
|
|
449
|
+
): Promise<Actions.policy.modifyBlacklistSync.ReturnValue> {
|
|
450
|
+
const { account, chainId, connector } = parameters
|
|
451
|
+
|
|
452
|
+
const client = await getConnectorClient(config, {
|
|
453
|
+
account,
|
|
454
|
+
assertChainId: false,
|
|
455
|
+
chainId,
|
|
456
|
+
connector,
|
|
457
|
+
})
|
|
458
|
+
|
|
459
|
+
return Actions.policy.modifyBlacklistSync(client, parameters as never)
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export declare namespace modifyBlacklistSync {
|
|
463
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
464
|
+
ConnectorParameter &
|
|
465
|
+
UnionLooseOmit<
|
|
466
|
+
Actions.policy.modifyBlacklistSync.Parameters<
|
|
467
|
+
config['chains'][number],
|
|
468
|
+
Account
|
|
469
|
+
>,
|
|
470
|
+
'chain'
|
|
471
|
+
>
|
|
472
|
+
|
|
473
|
+
export type ReturnValue = Actions.policy.modifyBlacklistSync.ReturnValue
|
|
474
|
+
|
|
475
|
+
export type ErrorType = BaseErrorType // TODO: Actions.policy.modifyBlacklistSync.ErrorType
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Gets policy data.
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```ts
|
|
483
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
484
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
485
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
486
|
+
*
|
|
487
|
+
* const config = createConfig({
|
|
488
|
+
* chains: [tempoModerato],
|
|
489
|
+
* transports: {
|
|
490
|
+
* [tempo.id]: http(),
|
|
491
|
+
* },
|
|
492
|
+
* })
|
|
493
|
+
*
|
|
494
|
+
* const data = await Actions.policy.getData(config, {
|
|
495
|
+
* policyId: 2n,
|
|
496
|
+
* })
|
|
497
|
+
* ```
|
|
498
|
+
*
|
|
499
|
+
* @param config - Config.
|
|
500
|
+
* @param parameters - Parameters.
|
|
501
|
+
* @returns The policy data.
|
|
502
|
+
*/
|
|
503
|
+
export function getData<config extends Config>(
|
|
504
|
+
config: config,
|
|
505
|
+
parameters: getData.Parameters<config>,
|
|
506
|
+
): Promise<getData.ReturnValue> {
|
|
507
|
+
const { chainId, ...rest } = parameters
|
|
508
|
+
const client = config.getClient({ chainId })
|
|
509
|
+
return Actions.policy.getData(client, rest)
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export namespace getData {
|
|
513
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
514
|
+
Actions.policy.getData.Parameters
|
|
515
|
+
|
|
516
|
+
export type ReturnValue = Actions.policy.getData.ReturnValue
|
|
517
|
+
|
|
518
|
+
export type ErrorType = BaseErrorType
|
|
519
|
+
|
|
520
|
+
export function queryKey<config extends Config>(
|
|
521
|
+
parameters: Parameters<config>,
|
|
522
|
+
) {
|
|
523
|
+
return ['getData', parameters] as const
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export type QueryKey<config extends Config> = ReturnType<
|
|
527
|
+
typeof queryKey<config>
|
|
528
|
+
>
|
|
529
|
+
|
|
530
|
+
export function queryOptions<config extends Config, selectData = ReturnValue>(
|
|
531
|
+
config: Config,
|
|
532
|
+
parameters: queryOptions.Parameters<config, selectData>,
|
|
533
|
+
): queryOptions.ReturnValue<config, selectData> {
|
|
534
|
+
const { query, ...rest } = parameters
|
|
535
|
+
return {
|
|
536
|
+
...query,
|
|
537
|
+
enabled: Boolean(rest.policyId !== undefined && (query?.enabled ?? true)),
|
|
538
|
+
queryKey: queryKey(rest),
|
|
539
|
+
async queryFn({ queryKey }) {
|
|
540
|
+
const [, parameters] = queryKey
|
|
541
|
+
return await getData(config, parameters)
|
|
542
|
+
},
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
export declare namespace queryOptions {
|
|
547
|
+
export type Parameters<
|
|
548
|
+
config extends Config,
|
|
549
|
+
selectData = getData.ReturnValue,
|
|
550
|
+
> = getData.Parameters<config> &
|
|
551
|
+
QueryParameter<
|
|
552
|
+
getData.ReturnValue,
|
|
553
|
+
getData.ErrorType,
|
|
554
|
+
selectData,
|
|
555
|
+
getData.QueryKey<config>
|
|
556
|
+
>
|
|
557
|
+
|
|
558
|
+
export type ReturnValue<
|
|
559
|
+
config extends Config,
|
|
560
|
+
selectData = getData.ReturnValue,
|
|
561
|
+
> = QueryOptions<
|
|
562
|
+
getData.ReturnValue,
|
|
563
|
+
getData.ErrorType,
|
|
564
|
+
selectData,
|
|
565
|
+
getData.QueryKey<config>
|
|
566
|
+
>
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Checks if a user is authorized by a policy.
|
|
572
|
+
*
|
|
573
|
+
* @example
|
|
574
|
+
* ```ts
|
|
575
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
576
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
577
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
578
|
+
*
|
|
579
|
+
* const config = createConfig({
|
|
580
|
+
* chains: [tempoModerato],
|
|
581
|
+
* transports: {
|
|
582
|
+
* [tempo.id]: http(),
|
|
583
|
+
* },
|
|
584
|
+
* })
|
|
585
|
+
*
|
|
586
|
+
* const authorized = await Actions.policy.isAuthorized(config, {
|
|
587
|
+
* policyId: 2n,
|
|
588
|
+
* user: '0x...',
|
|
589
|
+
* })
|
|
590
|
+
* ```
|
|
591
|
+
*
|
|
592
|
+
* @param config - Config.
|
|
593
|
+
* @param parameters - Parameters.
|
|
594
|
+
* @returns Whether the user is authorized.
|
|
595
|
+
*/
|
|
596
|
+
export function isAuthorized<config extends Config>(
|
|
597
|
+
config: config,
|
|
598
|
+
parameters: isAuthorized.Parameters<config>,
|
|
599
|
+
): Promise<isAuthorized.ReturnValue> {
|
|
600
|
+
const { chainId, ...rest } = parameters
|
|
601
|
+
const client = config.getClient({ chainId })
|
|
602
|
+
return Actions.policy.isAuthorized(client, rest)
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
export namespace isAuthorized {
|
|
606
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
607
|
+
Actions.policy.isAuthorized.Parameters
|
|
608
|
+
|
|
609
|
+
export type ReturnValue = Actions.policy.isAuthorized.ReturnValue
|
|
610
|
+
|
|
611
|
+
export type ErrorType = BaseErrorType
|
|
612
|
+
|
|
613
|
+
export function queryKey<config extends Config>(
|
|
614
|
+
parameters: Parameters<config>,
|
|
615
|
+
) {
|
|
616
|
+
return ['isAuthorized', parameters] as const
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
export type QueryKey<config extends Config> = ReturnType<
|
|
620
|
+
typeof queryKey<config>
|
|
621
|
+
>
|
|
622
|
+
|
|
623
|
+
export function queryOptions<config extends Config, selectData = ReturnValue>(
|
|
624
|
+
config: Config,
|
|
625
|
+
parameters: queryOptions.Parameters<config, selectData>,
|
|
626
|
+
): queryOptions.ReturnValue<config, selectData> {
|
|
627
|
+
const { query, ...rest } = parameters
|
|
628
|
+
return {
|
|
629
|
+
...query,
|
|
630
|
+
enabled: Boolean(
|
|
631
|
+
rest.policyId !== undefined && rest.user && (query?.enabled ?? true),
|
|
632
|
+
),
|
|
633
|
+
queryKey: queryKey(rest),
|
|
634
|
+
async queryFn({ queryKey }) {
|
|
635
|
+
const [, parameters] = queryKey
|
|
636
|
+
return await isAuthorized(config, parameters)
|
|
637
|
+
},
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export declare namespace queryOptions {
|
|
642
|
+
export type Parameters<
|
|
643
|
+
config extends Config,
|
|
644
|
+
selectData = isAuthorized.ReturnValue,
|
|
645
|
+
> = isAuthorized.Parameters<config> &
|
|
646
|
+
QueryParameter<
|
|
647
|
+
isAuthorized.ReturnValue,
|
|
648
|
+
isAuthorized.ErrorType,
|
|
649
|
+
selectData,
|
|
650
|
+
isAuthorized.QueryKey<config>
|
|
651
|
+
>
|
|
652
|
+
|
|
653
|
+
export type ReturnValue<
|
|
654
|
+
config extends Config,
|
|
655
|
+
selectData = isAuthorized.ReturnValue,
|
|
656
|
+
> = QueryOptions<
|
|
657
|
+
isAuthorized.ReturnValue,
|
|
658
|
+
isAuthorized.ErrorType,
|
|
659
|
+
selectData,
|
|
660
|
+
isAuthorized.QueryKey<config>
|
|
661
|
+
>
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Watches for policy creation events.
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* ```ts
|
|
670
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
671
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
672
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
673
|
+
*
|
|
674
|
+
* const config = createConfig({
|
|
675
|
+
* chains: [tempoModerato],
|
|
676
|
+
* transports: {
|
|
677
|
+
* [tempo.id]: http(),
|
|
678
|
+
* },
|
|
679
|
+
* })
|
|
680
|
+
*
|
|
681
|
+
* const unwatch = Actions.policy.watchCreate(config, {
|
|
682
|
+
* onPolicyCreated: (args, log) => {
|
|
683
|
+
* console.log('Policy created:', args)
|
|
684
|
+
* },
|
|
685
|
+
* })
|
|
686
|
+
* ```
|
|
687
|
+
*
|
|
688
|
+
* @param config - Config.
|
|
689
|
+
* @param parameters - Parameters.
|
|
690
|
+
* @returns A function to unsubscribe from the event.
|
|
691
|
+
*/
|
|
692
|
+
export function watchCreate<config extends Config>(
|
|
693
|
+
config: config,
|
|
694
|
+
parameters: watchCreate.Parameters<config>,
|
|
695
|
+
) {
|
|
696
|
+
const { chainId, ...rest } = parameters
|
|
697
|
+
const client = config.getClient({ chainId })
|
|
698
|
+
return Actions.policy.watchCreate(client, rest)
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export declare namespace watchCreate {
|
|
702
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
703
|
+
Actions.policy.watchCreate.Parameters
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Watches for policy admin update events.
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* ```ts
|
|
711
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
712
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
713
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
714
|
+
*
|
|
715
|
+
* const config = createConfig({
|
|
716
|
+
* chains: [tempoModerato],
|
|
717
|
+
* transports: {
|
|
718
|
+
* [tempo.id]: http(),
|
|
719
|
+
* },
|
|
720
|
+
* })
|
|
721
|
+
*
|
|
722
|
+
* const unwatch = Actions.policy.watchAdminUpdated(config, {
|
|
723
|
+
* onAdminUpdated: (args, log) => {
|
|
724
|
+
* console.log('Policy admin updated:', args)
|
|
725
|
+
* },
|
|
726
|
+
* })
|
|
727
|
+
* ```
|
|
728
|
+
*
|
|
729
|
+
* @param config - Config.
|
|
730
|
+
* @param parameters - Parameters.
|
|
731
|
+
* @returns A function to unsubscribe from the event.
|
|
732
|
+
*/
|
|
733
|
+
export function watchAdminUpdated<config extends Config>(
|
|
734
|
+
config: config,
|
|
735
|
+
parameters: watchAdminUpdated.Parameters<config>,
|
|
736
|
+
) {
|
|
737
|
+
const { chainId, ...rest } = parameters
|
|
738
|
+
const client = config.getClient({ chainId })
|
|
739
|
+
return Actions.policy.watchAdminUpdated(client, rest)
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
export declare namespace watchAdminUpdated {
|
|
743
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
744
|
+
Actions.policy.watchAdminUpdated.Parameters
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Watches for whitelist update events.
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* ```ts
|
|
752
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
753
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
754
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
755
|
+
*
|
|
756
|
+
* const config = createConfig({
|
|
757
|
+
* chains: [tempoModerato],
|
|
758
|
+
* transports: {
|
|
759
|
+
* [tempo.id]: http(),
|
|
760
|
+
* },
|
|
761
|
+
* })
|
|
762
|
+
*
|
|
763
|
+
* const unwatch = Actions.policy.watchWhitelistUpdated(config, {
|
|
764
|
+
* onWhitelistUpdated: (args, log) => {
|
|
765
|
+
* console.log('Whitelist updated:', args)
|
|
766
|
+
* },
|
|
767
|
+
* })
|
|
768
|
+
* ```
|
|
769
|
+
*
|
|
770
|
+
* @param config - Config.
|
|
771
|
+
* @param parameters - Parameters.
|
|
772
|
+
* @returns A function to unsubscribe from the event.
|
|
773
|
+
*/
|
|
774
|
+
export function watchWhitelistUpdated<config extends Config>(
|
|
775
|
+
config: config,
|
|
776
|
+
parameters: watchWhitelistUpdated.Parameters<config>,
|
|
777
|
+
) {
|
|
778
|
+
const { chainId, ...rest } = parameters
|
|
779
|
+
const client = config.getClient({ chainId })
|
|
780
|
+
return Actions.policy.watchWhitelistUpdated(client, rest)
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export declare namespace watchWhitelistUpdated {
|
|
784
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
785
|
+
Actions.policy.watchWhitelistUpdated.Parameters
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Watches for blacklist update events.
|
|
790
|
+
*
|
|
791
|
+
* @example
|
|
792
|
+
* ```ts
|
|
793
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
794
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
795
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
796
|
+
*
|
|
797
|
+
* const config = createConfig({
|
|
798
|
+
* chains: [tempoModerato],
|
|
799
|
+
* transports: {
|
|
800
|
+
* [tempo.id]: http(),
|
|
801
|
+
* },
|
|
802
|
+
* })
|
|
803
|
+
*
|
|
804
|
+
* const unwatch = Actions.policy.watchBlacklistUpdated(config, {
|
|
805
|
+
* onBlacklistUpdated: (args, log) => {
|
|
806
|
+
* console.log('Blacklist updated:', args)
|
|
807
|
+
* },
|
|
808
|
+
* })
|
|
809
|
+
* ```
|
|
810
|
+
*
|
|
811
|
+
* @param config - Config.
|
|
812
|
+
* @param parameters - Parameters.
|
|
813
|
+
* @returns A function to unsubscribe from the event.
|
|
814
|
+
*/
|
|
815
|
+
export function watchBlacklistUpdated<config extends Config>(
|
|
816
|
+
config: config,
|
|
817
|
+
parameters: watchBlacklistUpdated.Parameters<config>,
|
|
818
|
+
) {
|
|
819
|
+
const { chainId, ...rest } = parameters
|
|
820
|
+
const client = config.getClient({ chainId })
|
|
821
|
+
return Actions.policy.watchBlacklistUpdated(client, rest)
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
export declare namespace watchBlacklistUpdated {
|
|
825
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
826
|
+
Actions.policy.watchBlacklistUpdated.Parameters
|
|
827
|
+
}
|