@aastar/core 0.16.7 → 0.16.11
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/abis/PaymasterV4_2.json +1193 -0
- package/dist/abis/SuperPaymaster.json +1 -1
- package/dist/abis/aPNTs.json +1160 -0
- package/dist/abis/abi.config.json +3 -3
- package/dist/abis/index.d.ts +15 -104
- package/dist/abis/index.js +22 -46
- package/dist/actions/account.d.ts +0 -15
- package/dist/actions/account.js +143 -108
- package/dist/actions/aggregator.d.ts +68 -7
- package/dist/actions/aggregator.js +328 -28
- package/dist/actions/dvt.d.ts +33 -5
- package/dist/actions/dvt.js +238 -38
- package/dist/actions/entryPoint.d.ts +3 -63
- package/dist/actions/entryPoint.js +52 -184
- package/dist/actions/factory.d.ts +48 -115
- package/dist/actions/factory.js +638 -438
- package/dist/actions/faucet.d.ts +23 -27
- package/dist/actions/faucet.js +150 -289
- package/dist/actions/index.d.ts +1 -2
- package/dist/actions/index.js +2 -4
- package/dist/actions/paymaster.d.ts +147 -0
- package/dist/actions/paymaster.js +706 -0
- package/dist/actions/paymasterV4.d.ts +26 -95
- package/dist/actions/paymasterV4.js +28 -121
- package/dist/actions/registry.d.ts +116 -165
- package/dist/actions/registry.js +855 -654
- package/dist/actions/reputation.d.ts +74 -52
- package/dist/actions/reputation.js +548 -242
- package/dist/actions/sbt.d.ts +90 -100
- package/dist/actions/sbt.js +801 -518
- package/dist/actions/staking.d.ts +45 -32
- package/dist/actions/staking.js +431 -260
- package/dist/actions/superPaymaster.d.ts +140 -158
- package/dist/actions/superPaymaster.js +965 -631
- package/dist/actions/tokens.d.ts +130 -108
- package/dist/actions/tokens.js +470 -414
- package/dist/actions/validators.d.ts +0 -73
- package/dist/actions/validators.js +0 -94
- package/dist/clients/BaseClient.d.ts +3 -3
- package/dist/clients/BundlerClient.d.ts +55 -0
- package/dist/clients/BundlerClient.js +92 -0
- package/dist/communities.js +2 -2
- package/dist/constants.js +1 -28
- package/dist/contract-addresses.d.ts +5 -14
- package/dist/contract-addresses.js +3 -9
- package/dist/contract-versions.d.ts +138 -0
- package/dist/contract-versions.js +328 -0
- package/dist/contracts.d.ts +6 -24
- package/dist/contracts.js +2 -2
- package/dist/errors/index.d.ts +57 -0
- package/dist/errors/index.js +123 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/requirementChecker.d.ts +35 -1
- package/dist/requirementChecker.js +39 -1
- package/dist/roles.d.ts +50 -61
- package/dist/roles.js +50 -61
- package/dist/validators/index.d.ts +35 -0
- package/dist/validators/index.js +60 -0
- package/package.json +5 -13
package/dist/actions/tokens.js
CHANGED
|
@@ -1,415 +1,471 @@
|
|
|
1
1
|
import { GTokenABI, xPNTsTokenABI } from '../abis/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
abi:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
abi:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
functionName: '
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
abi:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
functionName: '
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
functionName: '
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
2
|
+
import { validateAddress, validateAmount, validateRequired } from '../validators/index.js';
|
|
3
|
+
import { AAStarError } from '../errors/index.js';
|
|
4
|
+
export const gTokenActions = (address) => (client) => {
|
|
5
|
+
const abi = GTokenABI;
|
|
6
|
+
const actions = {
|
|
7
|
+
async totalSupply({ token = address } = {}) {
|
|
8
|
+
validateAddress(token, 'token');
|
|
9
|
+
return client.readContract({ address: token, abi, functionName: 'totalSupply', args: [] });
|
|
10
|
+
},
|
|
11
|
+
async balanceOf({ token = address, account }) {
|
|
12
|
+
validateAddress(token, 'token');
|
|
13
|
+
validateAddress(account, 'account');
|
|
14
|
+
return client.readContract({ address: token, abi, functionName: 'balanceOf', args: [account] });
|
|
15
|
+
},
|
|
16
|
+
async transfer({ token = address, to, amount, account }) {
|
|
17
|
+
try {
|
|
18
|
+
validateAddress(token, 'token');
|
|
19
|
+
validateAddress(to, 'to');
|
|
20
|
+
validateAmount(amount, 'amount');
|
|
21
|
+
return await client.writeContract({ address: token, abi, functionName: 'transfer', args: [to, amount], account: account, chain: client.chain });
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw AAStarError.fromViemError(error, 'transfer');
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
async transferFrom({ token = address, from, to, amount, account }) {
|
|
28
|
+
try {
|
|
29
|
+
validateAddress(token, 'token');
|
|
30
|
+
validateAddress(from, 'from');
|
|
31
|
+
validateAddress(to, 'to');
|
|
32
|
+
validateAmount(amount, 'amount');
|
|
33
|
+
return await client.writeContract({ address: token, abi, functionName: 'transferFrom', args: [from, to, amount], account: account, chain: client.chain });
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw AAStarError.fromViemError(error, 'transferFrom');
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
async approve({ token = address, spender, amount, account }) {
|
|
40
|
+
try {
|
|
41
|
+
validateAddress(token, 'token');
|
|
42
|
+
validateAddress(spender, 'spender');
|
|
43
|
+
validateAmount(amount, 'amount');
|
|
44
|
+
return await client.writeContract({ address: token, abi, functionName: 'approve', args: [spender, amount], account: account, chain: client.chain });
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
throw AAStarError.fromViemError(error, 'approve');
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
async allowance({ token = address, owner, spender }) {
|
|
51
|
+
validateAddress(token, 'token');
|
|
52
|
+
validateAddress(owner, 'owner');
|
|
53
|
+
validateAddress(spender, 'spender');
|
|
54
|
+
return client.readContract({ address: token, abi, functionName: 'allowance', args: [owner, spender] });
|
|
55
|
+
},
|
|
56
|
+
async mint({ token = address, to, amount, account }) {
|
|
57
|
+
try {
|
|
58
|
+
validateAddress(token, 'token');
|
|
59
|
+
validateAddress(to, 'to');
|
|
60
|
+
validateAmount(amount, 'amount');
|
|
61
|
+
return await client.writeContract({ address: token, abi, functionName: 'mint', args: [to, amount], account: account, chain: client.chain });
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw AAStarError.fromViemError(error, 'mint');
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
async burn({ token = address, amount, account }) {
|
|
68
|
+
try {
|
|
69
|
+
validateAddress(token, 'token');
|
|
70
|
+
validateAmount(amount, 'amount');
|
|
71
|
+
return await client.writeContract({ address: token, abi, functionName: 'burn', args: [amount], account: account, chain: client.chain });
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw AAStarError.fromViemError(error, 'burn');
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
async burnFrom({ token = address, from, amount, account }) {
|
|
78
|
+
try {
|
|
79
|
+
validateAddress(token, 'token');
|
|
80
|
+
validateAddress(from, 'from');
|
|
81
|
+
validateAmount(amount, 'amount');
|
|
82
|
+
return await client.writeContract({ address: token, abi, functionName: 'burnFrom', args: [from, amount], account: account, chain: client.chain });
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
throw AAStarError.fromViemError(error, 'burnFrom');
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
async cap({ token = address } = {}) {
|
|
89
|
+
validateAddress(token, 'token');
|
|
90
|
+
return client.readContract({ address: token, abi, functionName: 'cap', args: [] });
|
|
91
|
+
},
|
|
92
|
+
async remainingMintableSupply({ token = address } = {}) {
|
|
93
|
+
validateAddress(token, 'token');
|
|
94
|
+
return client.readContract({ address: token, abi, functionName: 'remainingMintableSupply', args: [] });
|
|
95
|
+
},
|
|
96
|
+
async name({ token = address } = {}) {
|
|
97
|
+
validateAddress(token, 'token');
|
|
98
|
+
return client.readContract({ address: token, abi, functionName: 'name', args: [] });
|
|
99
|
+
},
|
|
100
|
+
async symbol({ token = address } = {}) {
|
|
101
|
+
validateAddress(token, 'token');
|
|
102
|
+
return client.readContract({ address: token, abi, functionName: 'symbol', args: [] });
|
|
103
|
+
},
|
|
104
|
+
async decimals({ token = address } = {}) {
|
|
105
|
+
validateAddress(token, 'token');
|
|
106
|
+
return client.readContract({ address: token, abi, functionName: 'decimals', args: [] });
|
|
107
|
+
},
|
|
108
|
+
async version({ token = address } = {}) {
|
|
109
|
+
validateAddress(token, 'token');
|
|
110
|
+
return client.readContract({ address: token, abi, functionName: 'version', args: [] });
|
|
111
|
+
},
|
|
112
|
+
async owner({ token = address } = {}) {
|
|
113
|
+
validateAddress(token, 'token');
|
|
114
|
+
return client.readContract({ address: token, abi, functionName: 'owner', args: [] });
|
|
115
|
+
},
|
|
116
|
+
async transferOwnership({ token = address, newOwner, account }) {
|
|
117
|
+
try {
|
|
118
|
+
validateAddress(token, 'token');
|
|
119
|
+
validateAddress(newOwner, 'newOwner');
|
|
120
|
+
return await client.writeContract({ address: token, abi, functionName: 'transferOwnership', args: [newOwner], account: account, chain: client.chain });
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
throw AAStarError.fromViemError(error, 'transferOwnership');
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
async renounceOwnership({ token = address, account }) {
|
|
127
|
+
try {
|
|
128
|
+
validateAddress(token, 'token');
|
|
129
|
+
return await client.writeContract({ address: token, abi, functionName: 'renounceOwnership', args: [], account: account, chain: client.chain });
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
throw AAStarError.fromViemError(error, 'renounceOwnership');
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
return actions;
|
|
137
|
+
};
|
|
138
|
+
export const xPNTsTokenActions = (address) => (client) => {
|
|
139
|
+
const abi = xPNTsTokenABI;
|
|
140
|
+
const actions = {
|
|
141
|
+
async totalSupply({ token = address } = {}) {
|
|
142
|
+
validateAddress(token, 'token');
|
|
143
|
+
return client.readContract({ address: token, abi, functionName: 'totalSupply', args: [] });
|
|
144
|
+
},
|
|
145
|
+
async balanceOf({ token = address, account }) {
|
|
146
|
+
validateAddress(token, 'token');
|
|
147
|
+
validateAddress(account, 'account');
|
|
148
|
+
return client.readContract({ address: token, abi, functionName: 'balanceOf', args: [account] });
|
|
149
|
+
},
|
|
150
|
+
async transfer({ token = address, to, amount, account }) {
|
|
151
|
+
try {
|
|
152
|
+
validateAddress(token, 'token');
|
|
153
|
+
validateAddress(to, 'to');
|
|
154
|
+
validateAmount(amount, 'amount');
|
|
155
|
+
return await client.writeContract({ address: token, abi, functionName: 'transfer', args: [to, amount], account: account, chain: client.chain });
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
throw AAStarError.fromViemError(error, 'transfer');
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
async transferFrom({ token = address, from, to, amount, account }) {
|
|
162
|
+
try {
|
|
163
|
+
validateAddress(token, 'token');
|
|
164
|
+
validateAddress(from, 'from');
|
|
165
|
+
validateAddress(to, 'to');
|
|
166
|
+
validateAmount(amount, 'amount');
|
|
167
|
+
return await client.writeContract({ address: token, abi, functionName: 'transferFrom', args: [from, to, amount], account: account, chain: client.chain });
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
throw AAStarError.fromViemError(error, 'transferFrom');
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
async approve({ token = address, spender, amount, account }) {
|
|
174
|
+
try {
|
|
175
|
+
validateAddress(token, 'token');
|
|
176
|
+
validateAddress(spender, 'spender');
|
|
177
|
+
validateAmount(amount, 'amount');
|
|
178
|
+
return await client.writeContract({ address: token, abi, functionName: 'approve', args: [spender, amount], account: account, chain: client.chain });
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
throw AAStarError.fromViemError(error, 'approve');
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
async allowance({ token = address, owner, spender }) {
|
|
185
|
+
validateAddress(token, 'token');
|
|
186
|
+
validateAddress(owner, 'owner');
|
|
187
|
+
validateAddress(spender, 'spender');
|
|
188
|
+
return client.readContract({ address: token, abi, functionName: 'allowance', args: [owner, spender] });
|
|
189
|
+
},
|
|
190
|
+
async mint({ token = address, to, amount, account }) {
|
|
191
|
+
try {
|
|
192
|
+
validateAddress(token, 'token');
|
|
193
|
+
validateAddress(to, 'to');
|
|
194
|
+
validateAmount(amount, 'amount');
|
|
195
|
+
return await client.writeContract({ address: token, abi, functionName: 'mint', args: [to, amount], account: account, chain: client.chain });
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
throw AAStarError.fromViemError(error, 'mint');
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
async burn({ token = address, amount, account }) {
|
|
202
|
+
try {
|
|
203
|
+
validateAddress(token, 'token');
|
|
204
|
+
validateAmount(amount, 'amount');
|
|
205
|
+
return await client.writeContract({ address: token, abi, functionName: 'burn', args: [amount], account: account, chain: client.chain });
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
throw AAStarError.fromViemError(error, 'burn');
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
async burnFrom({ token = address, from, amount, account }) {
|
|
212
|
+
try {
|
|
213
|
+
validateAddress(token, 'token');
|
|
214
|
+
validateAddress(from, 'from');
|
|
215
|
+
validateAmount(amount, 'amount');
|
|
216
|
+
return await client.writeContract({ address: token, abi, functionName: 'burn', args: [from, amount], account: account, chain: client.chain });
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
throw AAStarError.fromViemError(error, 'burnFrom');
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
async burnFromWithOpHash({ token = address, from, amount, userOpHash, account }) {
|
|
223
|
+
try {
|
|
224
|
+
validateAddress(token, 'token');
|
|
225
|
+
validateAddress(from, 'from');
|
|
226
|
+
validateAmount(amount, 'amount');
|
|
227
|
+
validateRequired(userOpHash, 'userOpHash');
|
|
228
|
+
return await client.writeContract({ address: token, abi, functionName: 'burnFromWithOpHash', args: [from, amount, userOpHash], account: account, chain: client.chain });
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
throw AAStarError.fromViemError(error, 'burnFromWithOpHash');
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
async name({ token = address } = {}) {
|
|
235
|
+
validateAddress(token, 'token');
|
|
236
|
+
return client.readContract({ address: token, abi, functionName: 'name', args: [] });
|
|
237
|
+
},
|
|
238
|
+
async symbol({ token = address } = {}) {
|
|
239
|
+
validateAddress(token, 'token');
|
|
240
|
+
return client.readContract({ address: token, abi, functionName: 'symbol', args: [] });
|
|
241
|
+
},
|
|
242
|
+
async decimals({ token = address } = {}) {
|
|
243
|
+
validateAddress(token, 'token');
|
|
244
|
+
return client.readContract({ address: token, abi, functionName: 'decimals', args: [] });
|
|
245
|
+
},
|
|
246
|
+
async version({ token = address } = {}) {
|
|
247
|
+
validateAddress(token, 'token');
|
|
248
|
+
return client.readContract({ address: token, abi, functionName: 'version', args: [] });
|
|
249
|
+
},
|
|
250
|
+
async exchangeRate({ token = address } = {}) {
|
|
251
|
+
validateAddress(token, 'token');
|
|
252
|
+
return client.readContract({ address: token, abi, functionName: 'exchangeRate', args: [] });
|
|
253
|
+
},
|
|
254
|
+
async updateExchangeRate({ token = address, newRate, account }) {
|
|
255
|
+
try {
|
|
256
|
+
validateAddress(token, 'token');
|
|
257
|
+
validateAmount(newRate, 'newRate');
|
|
258
|
+
return await client.writeContract({ address: token, abi, functionName: 'updateExchangeRate', args: [newRate], account: account, chain: client.chain });
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
throw AAStarError.fromViemError(error, 'updateExchangeRate');
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
async debts({ token = address, user }) {
|
|
265
|
+
validateAddress(token, 'token');
|
|
266
|
+
validateAddress(user, 'user');
|
|
267
|
+
return await client.readContract({
|
|
268
|
+
address: token,
|
|
269
|
+
abi,
|
|
270
|
+
functionName: 'debts',
|
|
271
|
+
args: [user]
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
async getDebt({ token = address, user }) {
|
|
275
|
+
validateAddress(token, 'token');
|
|
276
|
+
validateAddress(user, 'user');
|
|
277
|
+
return client.readContract({ address: token, abi, functionName: 'getDebt', args: [user] });
|
|
278
|
+
},
|
|
279
|
+
async recordDebt({ token = address, user, amountXPNTs, account }) {
|
|
280
|
+
try {
|
|
281
|
+
validateAddress(token, 'token');
|
|
282
|
+
validateAddress(user, 'user');
|
|
283
|
+
validateAmount(amountXPNTs, 'amountXPNTs');
|
|
284
|
+
return await client.writeContract({ address: token, abi, functionName: 'recordDebt', args: [user, amountXPNTs], account: account, chain: client.chain });
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
throw AAStarError.fromViemError(error, 'recordDebt');
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
async repayDebt({ token = address, amount, account }) {
|
|
291
|
+
try {
|
|
292
|
+
validateAddress(token, 'token');
|
|
293
|
+
validateAmount(amount, 'amount');
|
|
294
|
+
return await client.writeContract({ address: token, abi, functionName: 'repayDebt', args: [amount], account: account, chain: client.chain });
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
throw AAStarError.fromViemError(error, 'repayDebt');
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
async spendingLimits({ token = address, owner, spender }) {
|
|
301
|
+
validateAddress(token, 'token');
|
|
302
|
+
validateAddress(owner, 'owner');
|
|
303
|
+
validateAddress(spender, 'spender');
|
|
304
|
+
return client.readContract({ address: token, abi, functionName: 'spendingLimits', args: [owner, spender] });
|
|
305
|
+
},
|
|
306
|
+
async cumulativeSpent({ token = address, owner, spender }) {
|
|
307
|
+
validateAddress(token, 'token');
|
|
308
|
+
validateAddress(owner, 'owner');
|
|
309
|
+
validateAddress(spender, 'spender');
|
|
310
|
+
return client.readContract({ address: token, abi, functionName: 'cumulativeSpent', args: [owner, spender] });
|
|
311
|
+
},
|
|
312
|
+
async setPaymasterLimit({ token = address, spender, limit, account }) {
|
|
313
|
+
try {
|
|
314
|
+
validateAddress(token, 'token');
|
|
315
|
+
validateAddress(spender, 'spender');
|
|
316
|
+
validateAmount(limit, 'limit');
|
|
317
|
+
return await client.writeContract({ address: token, abi, functionName: 'setPaymasterLimit', args: [spender, limit], account: account, chain: client.chain });
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
throw AAStarError.fromViemError(error, 'setPaymasterLimit');
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
async DEFAULT_SPENDING_LIMIT_APNTS({ token = address } = {}) {
|
|
324
|
+
validateAddress(token, 'token');
|
|
325
|
+
return client.readContract({ address: token, abi, functionName: 'DEFAULT_SPENDING_LIMIT_APNTS', args: [] });
|
|
326
|
+
},
|
|
327
|
+
async getDefaultSpendingLimitXPNTs({ token = address } = {}) {
|
|
328
|
+
validateAddress(token, 'token');
|
|
329
|
+
return client.readContract({ address: token, abi, functionName: 'getDefaultSpendingLimitXPNTs', args: [] });
|
|
330
|
+
},
|
|
331
|
+
async needsApproval({ token = address, owner, spender, amount }) {
|
|
332
|
+
validateAddress(token, 'token');
|
|
333
|
+
validateAddress(owner, 'owner');
|
|
334
|
+
validateAddress(spender, 'spender');
|
|
335
|
+
validateAmount(amount, 'amount');
|
|
336
|
+
return client.readContract({ address: token, abi, functionName: 'needsApproval', args: [owner, spender, amount] });
|
|
337
|
+
},
|
|
338
|
+
async addAutoApprovedSpender({ token = address, spender, account }) {
|
|
339
|
+
try {
|
|
340
|
+
validateAddress(token, 'token');
|
|
341
|
+
validateAddress(spender, 'spender');
|
|
342
|
+
return await client.writeContract({ address: token, abi, functionName: 'addAutoApprovedSpender', args: [spender], account: account, chain: client.chain });
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
throw AAStarError.fromViemError(error, 'addAutoApprovedSpender');
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
async removeAutoApprovedSpender({ token = address, spender, account }) {
|
|
349
|
+
try {
|
|
350
|
+
validateAddress(token, 'token');
|
|
351
|
+
validateAddress(spender, 'spender');
|
|
352
|
+
return await client.writeContract({ address: token, abi, functionName: 'removeAutoApprovedSpender', args: [spender], account: account, chain: client.chain });
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
throw AAStarError.fromViemError(error, 'removeAutoApprovedSpender');
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
async autoApprovedSpenders({ token = address, spender }) {
|
|
359
|
+
validateAddress(token, 'token');
|
|
360
|
+
validateAddress(spender, 'spender');
|
|
361
|
+
return client.readContract({ address: token, abi, functionName: 'autoApprovedSpenders', args: [spender] });
|
|
362
|
+
},
|
|
363
|
+
async DOMAIN_SEPARATOR({ token = address } = {}) {
|
|
364
|
+
validateAddress(token, 'token');
|
|
365
|
+
return client.readContract({ address: token, abi, functionName: 'DOMAIN_SEPARATOR', args: [] });
|
|
366
|
+
},
|
|
367
|
+
async nonces({ token = address, owner }) {
|
|
368
|
+
validateAddress(token, 'token');
|
|
369
|
+
validateAddress(owner, 'owner');
|
|
370
|
+
return client.readContract({ address: token, abi, functionName: 'nonces', args: [owner] });
|
|
371
|
+
},
|
|
372
|
+
async permit({ token = address, owner, spender, value, deadline, v, r, s, account }) {
|
|
373
|
+
try {
|
|
374
|
+
validateAddress(token, 'token');
|
|
375
|
+
validateAddress(owner, 'owner');
|
|
376
|
+
validateAddress(spender, 'spender');
|
|
377
|
+
validateAmount(value, 'value');
|
|
378
|
+
validateRequired(deadline, 'deadline');
|
|
379
|
+
return await client.writeContract({ address: token, abi, functionName: 'permit', args: [owner, spender, value, deadline, v, r, s], account: account, chain: client.chain });
|
|
380
|
+
}
|
|
381
|
+
catch (error) {
|
|
382
|
+
throw AAStarError.fromViemError(error, 'permit');
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
async eip712Domain({ token = address } = {}) {
|
|
386
|
+
validateAddress(token, 'token');
|
|
387
|
+
return client.readContract({ address: token, abi, functionName: 'eip712Domain', args: [] });
|
|
388
|
+
},
|
|
389
|
+
async transferAndCall({ token = address, to, amount, data = '0x', account }) {
|
|
390
|
+
try {
|
|
391
|
+
validateAddress(token, 'token');
|
|
392
|
+
validateAddress(to, 'to');
|
|
393
|
+
validateAmount(amount, 'amount');
|
|
394
|
+
return await client.writeContract({ address: token, abi, functionName: 'transferAndCall', args: [to, amount, data], account: account, chain: client.chain });
|
|
395
|
+
}
|
|
396
|
+
catch (error) {
|
|
397
|
+
throw AAStarError.fromViemError(error, 'transferAndCall');
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
async communityENS({ token = address } = {}) {
|
|
401
|
+
validateAddress(token, 'token');
|
|
402
|
+
return client.readContract({ address: token, abi, functionName: 'communityENS', args: [] });
|
|
403
|
+
},
|
|
404
|
+
async communityName({ token = address } = {}) {
|
|
405
|
+
validateAddress(token, 'token');
|
|
406
|
+
return client.readContract({ address: token, abi, functionName: 'communityName', args: [] });
|
|
407
|
+
},
|
|
408
|
+
async communityOwner({ token = address } = {}) {
|
|
409
|
+
validateAddress(token, 'token');
|
|
410
|
+
return client.readContract({ address: token, abi, functionName: 'communityOwner', args: [] });
|
|
411
|
+
},
|
|
412
|
+
async getMetadata({ token = address } = {}) {
|
|
413
|
+
const abi = xPNTsTokenABI;
|
|
414
|
+
const res = await client.readContract({
|
|
415
|
+
address: token,
|
|
416
|
+
abi,
|
|
417
|
+
functionName: 'getMetadata',
|
|
418
|
+
args: []
|
|
419
|
+
});
|
|
420
|
+
if (Array.isArray(res)) {
|
|
421
|
+
return {
|
|
422
|
+
name: res[0],
|
|
423
|
+
symbol: res[1],
|
|
424
|
+
communityName: res[2],
|
|
425
|
+
communityENS: res[3],
|
|
426
|
+
communityOwner: res[4]
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
return res;
|
|
430
|
+
},
|
|
431
|
+
async transferCommunityOwnership({ token = address, newOwner, account }) {
|
|
432
|
+
try {
|
|
433
|
+
validateAddress(token, 'token');
|
|
434
|
+
validateAddress(newOwner, 'newOwner');
|
|
435
|
+
return await client.writeContract({ address: token, abi, functionName: 'transferCommunityOwnership', args: [newOwner], account: account, chain: client.chain });
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
throw AAStarError.fromViemError(error, 'transferCommunityOwnership');
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
async setSuperPaymasterAddress({ token = address, spAddress, account }) {
|
|
442
|
+
try {
|
|
443
|
+
validateAddress(token, 'token');
|
|
444
|
+
validateAddress(spAddress, 'spAddress');
|
|
445
|
+
return await client.writeContract({ address: token, abi, functionName: 'setSuperPaymasterAddress', args: [spAddress], account: account, chain: client.chain });
|
|
446
|
+
}
|
|
447
|
+
catch (error) {
|
|
448
|
+
throw AAStarError.fromViemError(error, 'setSuperPaymasterAddress');
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
async SUPERPAYMASTER_ADDRESS({ token = address } = {}) {
|
|
452
|
+
validateAddress(token, 'token');
|
|
453
|
+
return client.readContract({ address: token, abi, functionName: 'SUPERPAYMASTER_ADDRESS', args: [] });
|
|
454
|
+
},
|
|
455
|
+
async FACTORY({ token = address } = {}) {
|
|
456
|
+
validateAddress(token, 'token');
|
|
457
|
+
return client.readContract({ address: token, abi, functionName: 'FACTORY', args: [] });
|
|
458
|
+
},
|
|
459
|
+
async usedOpHashes({ token = address, opHash }) {
|
|
460
|
+
validateAddress(token, 'token');
|
|
461
|
+
validateRequired(opHash, 'opHash');
|
|
462
|
+
return client.readContract({ address: token, abi, functionName: 'usedOpHashes', args: [opHash] });
|
|
463
|
+
},
|
|
464
|
+
};
|
|
465
|
+
return actions;
|
|
466
|
+
};
|
|
467
|
+
// Legacy compatibility
|
|
468
|
+
export const tokenActions = (address) => (client) => {
|
|
469
|
+
// This is essentially xPNTsTokenActions for now as it's the more complex one
|
|
470
|
+
return xPNTsTokenActions(address)(client);
|
|
471
|
+
};
|