tempo.ts 0.5.0 → 0.5.2
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/viem/Actions/policy.d.ts +9 -1
- package/dist/viem/Actions/policy.d.ts.map +1 -1
- package/dist/viem/Actions/policy.js.map +1 -1
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +3 -1
- package/dist/viem/Chain.js.map +1 -1
- package/dist/viem/Formatters.js +1 -1
- package/dist/viem/Formatters.js.map +1 -1
- package/dist/viem/Transport.d.ts +8 -0
- package/dist/viem/Transport.d.ts.map +1 -1
- package/dist/viem/Transport.js +87 -1
- package/dist/viem/Transport.js.map +1 -1
- package/dist/wagmi/Actions/index.d.ts +1 -0
- package/dist/wagmi/Actions/index.d.ts.map +1 -1
- package/dist/wagmi/Actions/index.js +1 -0
- package/dist/wagmi/Actions/index.js.map +1 -1
- package/dist/wagmi/Actions/policy.d.ts +481 -0
- package/dist/wagmi/Actions/policy.d.ts.map +1 -0
- package/dist/wagmi/Actions/policy.js +530 -0
- package/dist/wagmi/Actions/policy.js.map +1 -0
- package/dist/wagmi/Connector.d.ts +1 -1
- package/dist/wagmi/Connector.d.ts.map +1 -1
- package/dist/wagmi/Connector.js +3 -85
- package/dist/wagmi/Connector.js.map +1 -1
- package/dist/wagmi/Hooks/index.d.ts +1 -0
- package/dist/wagmi/Hooks/index.d.ts.map +1 -1
- package/dist/wagmi/Hooks/index.js +1 -0
- package/dist/wagmi/Hooks/index.js.map +1 -1
- package/dist/wagmi/Hooks/policy.d.ts +424 -0
- package/dist/wagmi/Hooks/policy.d.ts.map +1 -0
- package/dist/wagmi/Hooks/policy.js +510 -0
- package/dist/wagmi/Hooks/policy.js.map +1 -0
- package/package.json +2 -2
- package/src/viem/Actions/policy.ts +25 -0
- package/src/viem/Chain.ts +3 -1
- package/src/viem/Formatters.ts +1 -1
- package/src/viem/Transport.ts +107 -1
- package/src/wagmi/Actions/index.ts +1 -0
- package/src/wagmi/Actions/policy.test.ts +461 -0
- package/src/wagmi/Actions/policy.ts +819 -0
- package/src/wagmi/Connector.ts +4 -112
- package/src/wagmi/Hooks/index.ts +1 -0
- package/src/wagmi/Hooks/policy.test.ts +665 -0
- package/src/wagmi/Hooks/policy.ts +875 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { getConnectorClient } from '@wagmi/core';
|
|
2
|
+
import * as viem_Actions from '../../viem/Actions/policy.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new policy.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
9
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
10
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
11
|
+
*
|
|
12
|
+
* const config = createConfig({
|
|
13
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
14
|
+
* transports: {
|
|
15
|
+
* [tempo.id]: http(),
|
|
16
|
+
* },
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* const hash = await Actions.policy.create(config, {
|
|
20
|
+
* type: 'whitelist',
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param config - Config.
|
|
25
|
+
* @param parameters - Parameters.
|
|
26
|
+
* @returns Transaction hash.
|
|
27
|
+
*/
|
|
28
|
+
export async function create(config, parameters) {
|
|
29
|
+
const { account, chainId, connector } = parameters;
|
|
30
|
+
const client = await getConnectorClient(config, {
|
|
31
|
+
account,
|
|
32
|
+
assertChainId: false,
|
|
33
|
+
chainId,
|
|
34
|
+
connector,
|
|
35
|
+
});
|
|
36
|
+
return viem_Actions.create(client, parameters);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new policy.
|
|
40
|
+
*
|
|
41
|
+
* Note: This is a synchronous action that waits for the transaction to
|
|
42
|
+
* be included on a block before returning a response.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
47
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
48
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
49
|
+
*
|
|
50
|
+
* const config = createConfig({
|
|
51
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
52
|
+
* transports: {
|
|
53
|
+
* [tempo.id]: http(),
|
|
54
|
+
* },
|
|
55
|
+
* })
|
|
56
|
+
*
|
|
57
|
+
* const result = await Actions.policy.createSync(config, {
|
|
58
|
+
* type: 'whitelist',
|
|
59
|
+
* })
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @param config - Config.
|
|
63
|
+
* @param parameters - Parameters.
|
|
64
|
+
* @returns The transaction receipt and event data.
|
|
65
|
+
*/
|
|
66
|
+
export async function createSync(config, parameters) {
|
|
67
|
+
const { account, chainId, connector } = parameters;
|
|
68
|
+
const client = await getConnectorClient(config, {
|
|
69
|
+
account,
|
|
70
|
+
assertChainId: false,
|
|
71
|
+
chainId,
|
|
72
|
+
connector,
|
|
73
|
+
});
|
|
74
|
+
return viem_Actions.createSync(client, parameters);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Sets the admin for a policy.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
82
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
83
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
84
|
+
*
|
|
85
|
+
* const config = createConfig({
|
|
86
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
87
|
+
* transports: {
|
|
88
|
+
* [tempo.id]: http(),
|
|
89
|
+
* },
|
|
90
|
+
* })
|
|
91
|
+
*
|
|
92
|
+
* const hash = await Actions.policy.setAdmin(config, {
|
|
93
|
+
* policyId: 2n,
|
|
94
|
+
* admin: '0x...',
|
|
95
|
+
* })
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @param config - Config.
|
|
99
|
+
* @param parameters - Parameters.
|
|
100
|
+
* @returns Transaction hash.
|
|
101
|
+
*/
|
|
102
|
+
export async function setAdmin(config, parameters) {
|
|
103
|
+
const { account, chainId, connector } = parameters;
|
|
104
|
+
const client = await getConnectorClient(config, {
|
|
105
|
+
account,
|
|
106
|
+
assertChainId: false,
|
|
107
|
+
chainId,
|
|
108
|
+
connector,
|
|
109
|
+
});
|
|
110
|
+
return viem_Actions.setAdmin(client, parameters);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Sets the admin for a policy.
|
|
114
|
+
*
|
|
115
|
+
* Note: This is a synchronous action that waits for the transaction to
|
|
116
|
+
* be included on a block before returning a response.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
121
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
122
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
123
|
+
*
|
|
124
|
+
* const config = createConfig({
|
|
125
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
126
|
+
* transports: {
|
|
127
|
+
* [tempo.id]: http(),
|
|
128
|
+
* },
|
|
129
|
+
* })
|
|
130
|
+
*
|
|
131
|
+
* const result = await Actions.policy.setAdminSync(config, {
|
|
132
|
+
* policyId: 2n,
|
|
133
|
+
* admin: '0x...',
|
|
134
|
+
* })
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @param config - Config.
|
|
138
|
+
* @param parameters - Parameters.
|
|
139
|
+
* @returns The transaction receipt and event data.
|
|
140
|
+
*/
|
|
141
|
+
export async function setAdminSync(config, parameters) {
|
|
142
|
+
const { account, chainId, connector } = parameters;
|
|
143
|
+
const client = await getConnectorClient(config, {
|
|
144
|
+
account,
|
|
145
|
+
assertChainId: false,
|
|
146
|
+
chainId,
|
|
147
|
+
connector,
|
|
148
|
+
});
|
|
149
|
+
return viem_Actions.setAdminSync(client, parameters);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Modifies a policy whitelist.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
157
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
158
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
159
|
+
*
|
|
160
|
+
* const config = createConfig({
|
|
161
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
162
|
+
* transports: {
|
|
163
|
+
* [tempo.id]: http(),
|
|
164
|
+
* },
|
|
165
|
+
* })
|
|
166
|
+
*
|
|
167
|
+
* const hash = await Actions.policy.modifyWhitelist(config, {
|
|
168
|
+
* policyId: 2n,
|
|
169
|
+
* address: '0x...',
|
|
170
|
+
* allowed: true,
|
|
171
|
+
* })
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @param config - Config.
|
|
175
|
+
* @param parameters - Parameters.
|
|
176
|
+
* @returns Transaction hash.
|
|
177
|
+
*/
|
|
178
|
+
export async function modifyWhitelist(config, parameters) {
|
|
179
|
+
const { account, chainId, connector } = parameters;
|
|
180
|
+
const client = await getConnectorClient(config, {
|
|
181
|
+
account,
|
|
182
|
+
assertChainId: false,
|
|
183
|
+
chainId,
|
|
184
|
+
connector,
|
|
185
|
+
});
|
|
186
|
+
return viem_Actions.modifyWhitelist(client, parameters);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Modifies a policy whitelist.
|
|
190
|
+
*
|
|
191
|
+
* Note: This is a synchronous action that waits for the transaction to
|
|
192
|
+
* be included on a block before returning a response.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
197
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
198
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
199
|
+
*
|
|
200
|
+
* const config = createConfig({
|
|
201
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
202
|
+
* transports: {
|
|
203
|
+
* [tempo.id]: http(),
|
|
204
|
+
* },
|
|
205
|
+
* })
|
|
206
|
+
*
|
|
207
|
+
* const result = await Actions.policy.modifyWhitelistSync(config, {
|
|
208
|
+
* policyId: 2n,
|
|
209
|
+
* address: '0x...',
|
|
210
|
+
* allowed: true,
|
|
211
|
+
* })
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* @param config - Config.
|
|
215
|
+
* @param parameters - Parameters.
|
|
216
|
+
* @returns The transaction receipt and event data.
|
|
217
|
+
*/
|
|
218
|
+
export async function modifyWhitelistSync(config, parameters) {
|
|
219
|
+
const { account, chainId, connector } = parameters;
|
|
220
|
+
const client = await getConnectorClient(config, {
|
|
221
|
+
account,
|
|
222
|
+
assertChainId: false,
|
|
223
|
+
chainId,
|
|
224
|
+
connector,
|
|
225
|
+
});
|
|
226
|
+
return viem_Actions.modifyWhitelistSync(client, parameters);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Modifies a policy blacklist.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
234
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
235
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
236
|
+
*
|
|
237
|
+
* const config = createConfig({
|
|
238
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
239
|
+
* transports: {
|
|
240
|
+
* [tempo.id]: http(),
|
|
241
|
+
* },
|
|
242
|
+
* })
|
|
243
|
+
*
|
|
244
|
+
* const hash = await Actions.policy.modifyBlacklist(config, {
|
|
245
|
+
* policyId: 2n,
|
|
246
|
+
* address: '0x...',
|
|
247
|
+
* restricted: true,
|
|
248
|
+
* })
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* @param config - Config.
|
|
252
|
+
* @param parameters - Parameters.
|
|
253
|
+
* @returns Transaction hash.
|
|
254
|
+
*/
|
|
255
|
+
export async function modifyBlacklist(config, parameters) {
|
|
256
|
+
const { account, chainId, connector } = parameters;
|
|
257
|
+
const client = await getConnectorClient(config, {
|
|
258
|
+
account,
|
|
259
|
+
assertChainId: false,
|
|
260
|
+
chainId,
|
|
261
|
+
connector,
|
|
262
|
+
});
|
|
263
|
+
return viem_Actions.modifyBlacklist(client, parameters);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Modifies a policy blacklist.
|
|
267
|
+
*
|
|
268
|
+
* Note: This is a synchronous action that waits for the transaction to
|
|
269
|
+
* be included on a block before returning a response.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
274
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
275
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
276
|
+
*
|
|
277
|
+
* const config = createConfig({
|
|
278
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
279
|
+
* transports: {
|
|
280
|
+
* [tempo.id]: http(),
|
|
281
|
+
* },
|
|
282
|
+
* })
|
|
283
|
+
*
|
|
284
|
+
* const result = await Actions.policy.modifyBlacklistSync(config, {
|
|
285
|
+
* policyId: 2n,
|
|
286
|
+
* address: '0x...',
|
|
287
|
+
* restricted: true,
|
|
288
|
+
* })
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* @param config - Config.
|
|
292
|
+
* @param parameters - Parameters.
|
|
293
|
+
* @returns The transaction receipt and event data.
|
|
294
|
+
*/
|
|
295
|
+
export async function modifyBlacklistSync(config, parameters) {
|
|
296
|
+
const { account, chainId, connector } = parameters;
|
|
297
|
+
const client = await getConnectorClient(config, {
|
|
298
|
+
account,
|
|
299
|
+
assertChainId: false,
|
|
300
|
+
chainId,
|
|
301
|
+
connector,
|
|
302
|
+
});
|
|
303
|
+
return viem_Actions.modifyBlacklistSync(client, parameters);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Gets policy data.
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
311
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
312
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
313
|
+
*
|
|
314
|
+
* const config = createConfig({
|
|
315
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
316
|
+
* transports: {
|
|
317
|
+
* [tempo.id]: http(),
|
|
318
|
+
* },
|
|
319
|
+
* })
|
|
320
|
+
*
|
|
321
|
+
* const data = await Actions.policy.getData(config, {
|
|
322
|
+
* policyId: 2n,
|
|
323
|
+
* })
|
|
324
|
+
* ```
|
|
325
|
+
*
|
|
326
|
+
* @param config - Config.
|
|
327
|
+
* @param parameters - Parameters.
|
|
328
|
+
* @returns The policy data.
|
|
329
|
+
*/
|
|
330
|
+
export function getData(config, parameters) {
|
|
331
|
+
const { chainId, ...rest } = parameters;
|
|
332
|
+
const client = config.getClient({ chainId });
|
|
333
|
+
return viem_Actions.getData(client, rest);
|
|
334
|
+
}
|
|
335
|
+
(function (getData) {
|
|
336
|
+
function queryKey(parameters) {
|
|
337
|
+
return ['getData', parameters];
|
|
338
|
+
}
|
|
339
|
+
getData.queryKey = queryKey;
|
|
340
|
+
function queryOptions(config, parameters) {
|
|
341
|
+
const { query, ...rest } = parameters;
|
|
342
|
+
return {
|
|
343
|
+
...query,
|
|
344
|
+
queryKey: queryKey(rest),
|
|
345
|
+
async queryFn({ queryKey }) {
|
|
346
|
+
const [, parameters] = queryKey;
|
|
347
|
+
return await getData(config, parameters);
|
|
348
|
+
},
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
getData.queryOptions = queryOptions;
|
|
352
|
+
})(getData || (getData = {}));
|
|
353
|
+
/**
|
|
354
|
+
* Checks if a user is authorized by a policy.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```ts
|
|
358
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
359
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
360
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
361
|
+
*
|
|
362
|
+
* const config = createConfig({
|
|
363
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
364
|
+
* transports: {
|
|
365
|
+
* [tempo.id]: http(),
|
|
366
|
+
* },
|
|
367
|
+
* })
|
|
368
|
+
*
|
|
369
|
+
* const authorized = await Actions.policy.isAuthorized(config, {
|
|
370
|
+
* policyId: 2n,
|
|
371
|
+
* user: '0x...',
|
|
372
|
+
* })
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* @param config - Config.
|
|
376
|
+
* @param parameters - Parameters.
|
|
377
|
+
* @returns Whether the user is authorized.
|
|
378
|
+
*/
|
|
379
|
+
export function isAuthorized(config, parameters) {
|
|
380
|
+
const { chainId, ...rest } = parameters;
|
|
381
|
+
const client = config.getClient({ chainId });
|
|
382
|
+
return viem_Actions.isAuthorized(client, rest);
|
|
383
|
+
}
|
|
384
|
+
(function (isAuthorized) {
|
|
385
|
+
function queryKey(parameters) {
|
|
386
|
+
return ['isAuthorized', parameters];
|
|
387
|
+
}
|
|
388
|
+
isAuthorized.queryKey = queryKey;
|
|
389
|
+
function queryOptions(config, parameters) {
|
|
390
|
+
const { query, ...rest } = parameters;
|
|
391
|
+
return {
|
|
392
|
+
...query,
|
|
393
|
+
queryKey: queryKey(rest),
|
|
394
|
+
async queryFn({ queryKey }) {
|
|
395
|
+
const [, parameters] = queryKey;
|
|
396
|
+
return await isAuthorized(config, parameters);
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
isAuthorized.queryOptions = queryOptions;
|
|
401
|
+
})(isAuthorized || (isAuthorized = {}));
|
|
402
|
+
/**
|
|
403
|
+
* Watches for policy creation events.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```ts
|
|
407
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
408
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
409
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
410
|
+
*
|
|
411
|
+
* const config = createConfig({
|
|
412
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
413
|
+
* transports: {
|
|
414
|
+
* [tempo.id]: http(),
|
|
415
|
+
* },
|
|
416
|
+
* })
|
|
417
|
+
*
|
|
418
|
+
* const unwatch = Actions.policy.watchCreate(config, {
|
|
419
|
+
* onPolicyCreated: (args, log) => {
|
|
420
|
+
* console.log('Policy created:', args)
|
|
421
|
+
* },
|
|
422
|
+
* })
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
* @param config - Config.
|
|
426
|
+
* @param parameters - Parameters.
|
|
427
|
+
* @returns A function to unsubscribe from the event.
|
|
428
|
+
*/
|
|
429
|
+
export function watchCreate(config, parameters) {
|
|
430
|
+
const { chainId, ...rest } = parameters;
|
|
431
|
+
const client = config.getClient({ chainId });
|
|
432
|
+
return viem_Actions.watchCreate(client, rest);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Watches for policy admin update events.
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
440
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
441
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
442
|
+
*
|
|
443
|
+
* const config = createConfig({
|
|
444
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
445
|
+
* transports: {
|
|
446
|
+
* [tempo.id]: http(),
|
|
447
|
+
* },
|
|
448
|
+
* })
|
|
449
|
+
*
|
|
450
|
+
* const unwatch = Actions.policy.watchAdminUpdated(config, {
|
|
451
|
+
* onAdminUpdated: (args, log) => {
|
|
452
|
+
* console.log('Policy admin updated:', args)
|
|
453
|
+
* },
|
|
454
|
+
* })
|
|
455
|
+
* ```
|
|
456
|
+
*
|
|
457
|
+
* @param config - Config.
|
|
458
|
+
* @param parameters - Parameters.
|
|
459
|
+
* @returns A function to unsubscribe from the event.
|
|
460
|
+
*/
|
|
461
|
+
export function watchAdminUpdated(config, parameters) {
|
|
462
|
+
const { chainId, ...rest } = parameters;
|
|
463
|
+
const client = config.getClient({ chainId });
|
|
464
|
+
return viem_Actions.watchAdminUpdated(client, rest);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Watches for whitelist update events.
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```ts
|
|
471
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
472
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
473
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
474
|
+
*
|
|
475
|
+
* const config = createConfig({
|
|
476
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
477
|
+
* transports: {
|
|
478
|
+
* [tempo.id]: http(),
|
|
479
|
+
* },
|
|
480
|
+
* })
|
|
481
|
+
*
|
|
482
|
+
* const unwatch = Actions.policy.watchWhitelistUpdated(config, {
|
|
483
|
+
* onWhitelistUpdated: (args, log) => {
|
|
484
|
+
* console.log('Whitelist updated:', args)
|
|
485
|
+
* },
|
|
486
|
+
* })
|
|
487
|
+
* ```
|
|
488
|
+
*
|
|
489
|
+
* @param config - Config.
|
|
490
|
+
* @param parameters - Parameters.
|
|
491
|
+
* @returns A function to unsubscribe from the event.
|
|
492
|
+
*/
|
|
493
|
+
export function watchWhitelistUpdated(config, parameters) {
|
|
494
|
+
const { chainId, ...rest } = parameters;
|
|
495
|
+
const client = config.getClient({ chainId });
|
|
496
|
+
return viem_Actions.watchWhitelistUpdated(client, rest);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Watches for blacklist update events.
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```ts
|
|
503
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
504
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
505
|
+
* import { Actions } from 'tempo.ts/wagmi'
|
|
506
|
+
*
|
|
507
|
+
* const config = createConfig({
|
|
508
|
+
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
509
|
+
* transports: {
|
|
510
|
+
* [tempo.id]: http(),
|
|
511
|
+
* },
|
|
512
|
+
* })
|
|
513
|
+
*
|
|
514
|
+
* const unwatch = Actions.policy.watchBlacklistUpdated(config, {
|
|
515
|
+
* onBlacklistUpdated: (args, log) => {
|
|
516
|
+
* console.log('Blacklist updated:', args)
|
|
517
|
+
* },
|
|
518
|
+
* })
|
|
519
|
+
* ```
|
|
520
|
+
*
|
|
521
|
+
* @param config - Config.
|
|
522
|
+
* @param parameters - Parameters.
|
|
523
|
+
* @returns A function to unsubscribe from the event.
|
|
524
|
+
*/
|
|
525
|
+
export function watchBlacklistUpdated(config, parameters) {
|
|
526
|
+
const { chainId, ...rest } = parameters;
|
|
527
|
+
const client = config.getClient({ chainId });
|
|
528
|
+
return viem_Actions.watchBlacklistUpdated(client, rest);
|
|
529
|
+
}
|
|
530
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../src/wagmi/Actions/policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAI7D,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAA;AAI5D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,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IAAI,CAAC,CAAA;AACzD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../../src/wagmi/Connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../../src/wagmi/Connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AAErC,OAAO,KAAK,KAAK,GAAG,MAAM,QAAQ,CAAA;AAClC,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,MAAM,CAAA;AAMb,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAA;AAIvD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,mBAAmB,CAAC,UAAe;;;;;YAKlC,gBAAgB,SAAS,OAAO,sBAAsB;QAC5D,YAAY,CAAC,EACT;YACE,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;SACpC,GACD,SAAS,CAAA;QACb,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC5B,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;QACpC,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,OAAO,GAAG,SAAS,CAAA;KAC1D,GAAG,OAAO,CAAC;QACV,QAAQ,EAAE,SAAS,OAAO,CAAC,OAAO,EAAE,CAAA;QACpC,OAAO,EAAE,MAAM,CAAA;KAChB,CAAC;;;+BAIyB,OAAO,CAAC,OAAO;mCACX,OAAO,CAAC,OAAO;GAqIjD;AAED,MAAM,CAAC,OAAO,WAAW,mBAAmB,CAAC;IAC3C,KAAY,UAAU,GAAG;QACvB,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;KACnC,CAAA;CACF;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,QAAQ,CAAC,UAAe;;;;;YAI9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/dist/wagmi/Connector.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import * as Address from 'ox/Address';
|
|
2
2
|
import * as Bytes from 'ox/Bytes';
|
|
3
|
-
import * as Hash from 'ox/Hash';
|
|
4
|
-
import * as Hex from 'ox/Hex';
|
|
5
|
-
import * as Provider from 'ox/Provider';
|
|
6
|
-
import * as RpcRequest from 'ox/RpcRequest';
|
|
7
3
|
import { createClient, getAddress, SwitchChainError, } from 'viem';
|
|
8
4
|
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
9
|
-
import { getTransactionReceipt, sendTransaction, sendTransactionSync, } from 'viem/actions';
|
|
10
5
|
import { ChainNotConfiguredError, createConnector } from 'wagmi';
|
|
11
6
|
import * as Account from '../viem/Account.js';
|
|
7
|
+
import { walletNamespaceCompat } from '../viem/Transport.js';
|
|
12
8
|
import * as WebAuthnP256 from '../viem/WebAuthnP256.js';
|
|
13
|
-
const sendCallsMagic = Hash.keccak256(Hex.fromString('TEMPO_5792'));
|
|
14
9
|
/**
|
|
15
10
|
* Connector for a Secp256k1 EOA.
|
|
16
11
|
*
|
|
@@ -121,9 +116,7 @@ export function dangerous_secp256k1(options = {}) {
|
|
|
121
116
|
return createClient({
|
|
122
117
|
account,
|
|
123
118
|
chain: chain,
|
|
124
|
-
transport:
|
|
125
|
-
account,
|
|
126
|
-
}),
|
|
119
|
+
transport: walletNamespaceCompat(transport),
|
|
127
120
|
});
|
|
128
121
|
},
|
|
129
122
|
async getProvider({ chainId } = {}) {
|
|
@@ -262,9 +255,7 @@ export function webAuthn(options = {}) {
|
|
|
262
255
|
return createClient({
|
|
263
256
|
account,
|
|
264
257
|
chain: chain,
|
|
265
|
-
transport:
|
|
266
|
-
account,
|
|
267
|
-
}),
|
|
258
|
+
transport: walletNamespaceCompat(transport),
|
|
268
259
|
});
|
|
269
260
|
},
|
|
270
261
|
async getProvider({ chainId } = {}) {
|
|
@@ -273,77 +264,4 @@ export function webAuthn(options = {}) {
|
|
|
273
264
|
},
|
|
274
265
|
}));
|
|
275
266
|
}
|
|
276
|
-
// TODO: This is a temporary workaround to support EIP-5792. To be removed
|
|
277
|
-
// once we support a EIP-1193 Provider abstraction for Tempo accounts.
|
|
278
|
-
// biome-ignore lint/correctness/noUnusedVariables: _
|
|
279
|
-
function withErc5792Compat(transport, { account }) {
|
|
280
|
-
return (options) => {
|
|
281
|
-
const t = transport(options);
|
|
282
|
-
return {
|
|
283
|
-
...t,
|
|
284
|
-
async request(args) {
|
|
285
|
-
const request = RpcRequest.from(args);
|
|
286
|
-
const client = createClient({
|
|
287
|
-
account,
|
|
288
|
-
chain: options.chain,
|
|
289
|
-
transport,
|
|
290
|
-
});
|
|
291
|
-
if (request.method === 'wallet_sendCalls') {
|
|
292
|
-
const params = request.params[0] ?? {};
|
|
293
|
-
const { capabilities, chainId, from } = params;
|
|
294
|
-
const { sync } = capabilities ?? {};
|
|
295
|
-
if (!account)
|
|
296
|
-
throw new Provider.DisconnectedError();
|
|
297
|
-
if (!chainId)
|
|
298
|
-
throw new Provider.UnsupportedChainIdError();
|
|
299
|
-
if (Number(chainId) !== client.chain.id)
|
|
300
|
-
throw new Provider.UnsupportedChainIdError();
|
|
301
|
-
if (from && !Address.isEqual(from, account.address))
|
|
302
|
-
throw new Provider.DisconnectedError();
|
|
303
|
-
const calls = (params.calls ?? []).map((call) => ({
|
|
304
|
-
to: call.to,
|
|
305
|
-
value: call.value ? BigInt(call.value) : undefined,
|
|
306
|
-
data: call.data,
|
|
307
|
-
}));
|
|
308
|
-
const hash = await (async () => {
|
|
309
|
-
if (!sync)
|
|
310
|
-
return sendTransaction(client, {
|
|
311
|
-
account,
|
|
312
|
-
calls,
|
|
313
|
-
});
|
|
314
|
-
const { transactionHash } = await sendTransactionSync(client, {
|
|
315
|
-
account,
|
|
316
|
-
calls,
|
|
317
|
-
});
|
|
318
|
-
return transactionHash;
|
|
319
|
-
})();
|
|
320
|
-
const id = Hex.concat(hash, Hex.padLeft(chainId, 32), sendCallsMagic);
|
|
321
|
-
return {
|
|
322
|
-
capabilities: { sync },
|
|
323
|
-
id,
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
if (request.method === 'wallet_getCallsStatus') {
|
|
327
|
-
const [id] = request.params ?? [];
|
|
328
|
-
if (!id)
|
|
329
|
-
throw new Error('`id` not found');
|
|
330
|
-
if (!id.endsWith(sendCallsMagic.slice(2)))
|
|
331
|
-
throw new Error('`id` not supported');
|
|
332
|
-
Hex.assert(id);
|
|
333
|
-
const hash = Hex.slice(id, 0, 32);
|
|
334
|
-
const chainId = Hex.slice(id, 32, 64);
|
|
335
|
-
const receipt = await getTransactionReceipt(client, { hash });
|
|
336
|
-
return {
|
|
337
|
-
atomic: true,
|
|
338
|
-
chainId: Number(chainId),
|
|
339
|
-
receipts: [receipt],
|
|
340
|
-
status: receipt.status === 'success' ? 200 : 500,
|
|
341
|
-
version: '2.0.0',
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
return t.request(args);
|
|
345
|
-
},
|
|
346
|
-
};
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
267
|
//# sourceMappingURL=Connector.js.map
|