@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.
Files changed (60) hide show
  1. package/dist/abis/PaymasterV4_2.json +1193 -0
  2. package/dist/abis/SuperPaymaster.json +1 -1
  3. package/dist/abis/aPNTs.json +1160 -0
  4. package/dist/abis/abi.config.json +3 -3
  5. package/dist/abis/index.d.ts +15 -104
  6. package/dist/abis/index.js +22 -46
  7. package/dist/actions/account.d.ts +0 -15
  8. package/dist/actions/account.js +143 -108
  9. package/dist/actions/aggregator.d.ts +68 -7
  10. package/dist/actions/aggregator.js +328 -28
  11. package/dist/actions/dvt.d.ts +33 -5
  12. package/dist/actions/dvt.js +238 -38
  13. package/dist/actions/entryPoint.d.ts +3 -63
  14. package/dist/actions/entryPoint.js +52 -184
  15. package/dist/actions/factory.d.ts +48 -115
  16. package/dist/actions/factory.js +638 -438
  17. package/dist/actions/faucet.d.ts +23 -27
  18. package/dist/actions/faucet.js +150 -289
  19. package/dist/actions/index.d.ts +1 -2
  20. package/dist/actions/index.js +2 -4
  21. package/dist/actions/paymaster.d.ts +147 -0
  22. package/dist/actions/paymaster.js +706 -0
  23. package/dist/actions/paymasterV4.d.ts +26 -95
  24. package/dist/actions/paymasterV4.js +28 -121
  25. package/dist/actions/registry.d.ts +116 -165
  26. package/dist/actions/registry.js +855 -654
  27. package/dist/actions/reputation.d.ts +74 -52
  28. package/dist/actions/reputation.js +548 -242
  29. package/dist/actions/sbt.d.ts +90 -100
  30. package/dist/actions/sbt.js +801 -518
  31. package/dist/actions/staking.d.ts +45 -32
  32. package/dist/actions/staking.js +431 -260
  33. package/dist/actions/superPaymaster.d.ts +140 -158
  34. package/dist/actions/superPaymaster.js +965 -631
  35. package/dist/actions/tokens.d.ts +130 -108
  36. package/dist/actions/tokens.js +470 -414
  37. package/dist/actions/validators.d.ts +0 -73
  38. package/dist/actions/validators.js +0 -94
  39. package/dist/clients/BaseClient.d.ts +3 -3
  40. package/dist/clients/BundlerClient.d.ts +55 -0
  41. package/dist/clients/BundlerClient.js +92 -0
  42. package/dist/communities.js +2 -2
  43. package/dist/constants.js +1 -28
  44. package/dist/contract-addresses.d.ts +5 -14
  45. package/dist/contract-addresses.js +3 -9
  46. package/dist/contract-versions.d.ts +138 -0
  47. package/dist/contract-versions.js +328 -0
  48. package/dist/contracts.d.ts +6 -24
  49. package/dist/contracts.js +2 -2
  50. package/dist/errors/index.d.ts +57 -0
  51. package/dist/errors/index.js +123 -0
  52. package/dist/index.d.ts +2 -1
  53. package/dist/index.js +2 -1
  54. package/dist/requirementChecker.d.ts +35 -1
  55. package/dist/requirementChecker.js +39 -1
  56. package/dist/roles.d.ts +50 -61
  57. package/dist/roles.js +50 -61
  58. package/dist/validators/index.d.ts +35 -0
  59. package/dist/validators/index.js +60 -0
  60. package/package.json +5 -13
@@ -1,644 +1,978 @@
1
1
  import { SuperPaymasterABI } from '../abis/index.js';
2
+ import { validateAddress, validateRequired, validateAmount } from '../validators/index.js';
3
+ import { AAStarError } from '../errors/index.js';
2
4
  export const superPaymasterActions = (address) => (client) => ({
3
5
  // Deposit & Withdrawal
4
- async superPaymasterDeposit({ amount, account }) {
5
- return client.writeContract({
6
- address,
7
- abi: SuperPaymasterABI,
8
- functionName: 'deposit',
9
- args: [amount],
10
- account: account,
11
- chain: client.chain
12
- });
13
- },
14
- // Semantic alias: depositAPNTs - uses aPNTs token (nonpayable)
15
- async superPaymasterDepositAPNTs({ amount, account }) {
16
- return this.superPaymasterDeposit({ amount, account });
17
- },
18
- // depositETH - uses native ETH (payable, no args)
19
- async superPaymasterDepositETH({ value, account }) {
20
- return client.writeContract({
21
- address,
22
- abi: SuperPaymasterABI,
23
- functionName: 'deposit',
24
- args: [],
25
- value,
26
- account: account,
27
- chain: client.chain
28
- });
29
- },
30
- async superPaymasterWithdraw({ amount, account }) {
31
- return client.writeContract({
32
- address,
33
- abi: SuperPaymasterABI,
34
- functionName: 'withdraw',
35
- args: [amount],
36
- account: account,
37
- chain: client.chain
38
- });
39
- },
40
- async superPaymasterDepositFor({ operator, amount, account }) {
41
- return client.writeContract({
42
- address,
43
- abi: SuperPaymasterABI,
44
- functionName: 'depositFor',
45
- args: [operator, amount],
46
- account: account,
47
- chain: client.chain
48
- });
49
- },
50
- async superPaymasterWithdrawTo({ to, amount, account }) {
51
- return client.writeContract({
52
- address,
53
- abi: SuperPaymasterABI,
54
- functionName: 'withdrawTo',
55
- args: [to, amount],
56
- account: account,
57
- chain: client.chain
58
- });
59
- },
60
- async superPaymasterAddSuperStake({ amount, account }) {
61
- return client.writeContract({
62
- address,
63
- abi: SuperPaymasterABI,
64
- functionName: 'addStake',
65
- args: [amount],
66
- account: account,
67
- chain: client.chain
68
- });
69
- },
70
- async superPaymasterUnlockSuperStake({ account }) {
71
- return client.writeContract({
72
- address,
73
- abi: SuperPaymasterABI,
74
- functionName: 'unlockStake',
75
- args: [],
76
- account: account,
77
- chain: client.chain
78
- });
79
- },
80
- async superPaymasterWithdrawStake({ to, account }) {
81
- return client.writeContract({
82
- address,
83
- abi: SuperPaymasterABI,
84
- functionName: 'withdrawStake',
85
- args: [to],
86
- account: account,
87
- chain: client.chain
88
- });
6
+ async deposit({ amount, account }) {
7
+ try {
8
+ validateAmount(amount, 'amount');
9
+ return await client.writeContract({
10
+ address,
11
+ abi: SuperPaymasterABI,
12
+ functionName: 'deposit',
13
+ args: [amount],
14
+ account: account,
15
+ chain: client.chain
16
+ });
17
+ }
18
+ catch (error) {
19
+ throw AAStarError.fromViemError(error, 'deposit');
20
+ }
21
+ },
22
+ async depositETH({ value, account }) {
23
+ try {
24
+ validateAmount(value, 'value');
25
+ return await client.writeContract({
26
+ address,
27
+ abi: SuperPaymasterABI,
28
+ functionName: 'deposit',
29
+ args: [],
30
+ value,
31
+ account: account,
32
+ chain: client.chain
33
+ });
34
+ }
35
+ catch (error) {
36
+ throw AAStarError.fromViemError(error, 'depositETH');
37
+ }
38
+ },
39
+ async depositFor({ targetOperator, amount, account }) {
40
+ try {
41
+ validateAddress(targetOperator, 'targetOperator');
42
+ validateAmount(amount, 'amount');
43
+ return await client.writeContract({
44
+ address,
45
+ abi: SuperPaymasterABI,
46
+ functionName: 'depositFor',
47
+ args: [targetOperator, amount],
48
+ account: account,
49
+ chain: client.chain
50
+ });
51
+ }
52
+ catch (error) {
53
+ throw AAStarError.fromViemError(error, 'depositFor');
54
+ }
55
+ },
56
+ async withdrawTo({ to, amount, account }) {
57
+ try {
58
+ validateAddress(to, 'to');
59
+ validateAmount(amount, 'amount');
60
+ return await client.writeContract({
61
+ address,
62
+ abi: SuperPaymasterABI,
63
+ functionName: 'withdrawTo',
64
+ args: [to, amount],
65
+ account: account,
66
+ chain: client.chain
67
+ });
68
+ }
69
+ catch (error) {
70
+ throw AAStarError.fromViemError(error, 'withdrawTo');
71
+ }
72
+ },
73
+ async withdraw({ amount, account }) {
74
+ try {
75
+ validateAmount(amount, 'amount');
76
+ return await client.writeContract({
77
+ address,
78
+ abi: SuperPaymasterABI,
79
+ functionName: 'withdraw',
80
+ args: [amount],
81
+ account: account,
82
+ chain: client.chain
83
+ });
84
+ }
85
+ catch (error) {
86
+ throw AAStarError.fromViemError(error, 'withdraw');
87
+ }
88
+ },
89
+ // Staking
90
+ async addStake({ unstakeDelaySec, value, account }) {
91
+ try {
92
+ validateRequired(unstakeDelaySec, 'unstakeDelaySec');
93
+ validateAmount(value, 'value');
94
+ return await client.writeContract({
95
+ address,
96
+ abi: SuperPaymasterABI,
97
+ functionName: 'addStake',
98
+ args: [unstakeDelaySec],
99
+ value,
100
+ account: account,
101
+ chain: client.chain
102
+ });
103
+ }
104
+ catch (error) {
105
+ throw AAStarError.fromViemError(error, 'addStake');
106
+ }
107
+ },
108
+ async unlockStake({ account }) {
109
+ try {
110
+ return await client.writeContract({
111
+ address,
112
+ abi: SuperPaymasterABI,
113
+ functionName: 'unlockStake',
114
+ args: [],
115
+ account: account,
116
+ chain: client.chain
117
+ });
118
+ }
119
+ catch (error) {
120
+ throw AAStarError.fromViemError(error, 'unlockStake');
121
+ }
122
+ },
123
+ async withdrawStake({ to, account }) {
124
+ try {
125
+ validateAddress(to, 'to');
126
+ return await client.writeContract({
127
+ address,
128
+ abi: SuperPaymasterABI,
129
+ functionName: 'withdrawStake',
130
+ args: [to],
131
+ account: account,
132
+ chain: client.chain
133
+ });
134
+ }
135
+ catch (error) {
136
+ throw AAStarError.fromViemError(error, 'withdrawStake');
137
+ }
89
138
  },
90
139
  // Operator Management
91
- async superPaymasterConfigureOperator({ xPNTsToken, treasury, exchangeRate, account }) {
92
- return client.writeContract({
93
- address,
94
- abi: SuperPaymasterABI,
95
- functionName: 'configureOperator',
96
- args: [xPNTsToken, treasury, exchangeRate],
97
- account: account,
98
- chain: client.chain
99
- });
100
- },
101
- async superPaymasterSetOperatorPaused({ operator, paused, account }) {
102
- return client.writeContract({
103
- address,
104
- abi: SuperPaymasterABI,
105
- functionName: 'setOperatorPaused',
106
- args: [operator, paused],
107
- account: account,
108
- chain: client.chain
109
- });
110
- },
111
- async superPaymasterUpdateReputation({ operator, newReputation, account }) {
112
- return client.writeContract({
113
- address,
114
- abi: SuperPaymasterABI,
115
- functionName: 'updateReputation',
116
- args: [operator, newReputation],
117
- account: account,
118
- chain: client.chain
119
- });
120
- },
121
- async superPaymasterExecuteSlashWithBLS({ operator, roleId, amount, reason, blsSignature, account }) {
122
- return client.writeContract({
123
- address,
124
- abi: SuperPaymasterABI,
125
- functionName: 'executeSlashWithBLS',
126
- args: [operator, roleId, amount, reason, blsSignature],
127
- account: account,
128
- chain: client.chain
129
- });
130
- },
131
- // Price & Configuration
132
- async superPaymasterSetAPNTsPrice({ priceUSD, account }) {
133
- return client.writeContract({
134
- address,
135
- abi: SuperPaymasterABI,
136
- functionName: 'setAPNTsPrice',
137
- args: [priceUSD],
138
- account: account,
139
- chain: client.chain
140
- });
141
- },
142
- async superPaymasterSetCachedPrice({ price, account }) {
143
- return client.writeContract({
144
- address,
145
- abi: SuperPaymasterABI,
146
- functionName: 'setCachedPrice',
147
- args: [price],
148
- account: account,
149
- chain: client.chain
150
- });
151
- },
152
- async superPaymasterSetProtocolFee({ feeRecipient, feeBps, account }) {
153
- return client.writeContract({
154
- address,
155
- abi: SuperPaymasterABI,
156
- functionName: 'setProtocolFee',
157
- args: [feeRecipient, feeBps],
158
- account: account,
159
- chain: client.chain
160
- });
161
- },
162
- // User Management
163
- async superPaymasterBlockUser({ user, blocked, account }) {
164
- return client.writeContract({
165
- address,
166
- abi: SuperPaymasterABI,
167
- functionName: 'blockUser',
168
- args: [user, blocked],
169
- account: account,
170
- chain: client.chain
171
- });
172
- },
173
- // Validation (EntryPoint calls)
174
- async superPaymasterValidatePaymasterUserOp({ userOp, userOpHash, maxCost }) {
175
- return client.readContract({
176
- address,
177
- abi: SuperPaymasterABI,
178
- functionName: 'validatePaymasterUserOp',
179
- args: [userOp, userOpHash, maxCost]
180
- });
181
- },
182
- async superPaymasterPostOp({ mode, context, actualGasCost, actualUserOpFeePerGas }) {
183
- // postOp is called by EntryPoint, typically not called directly
184
- throw new Error('postOp is called by EntryPoint after UserOp execution');
140
+ async configureOperator({ xPNTsToken, opTreasury, exchangeRate, account }) {
141
+ try {
142
+ validateAddress(xPNTsToken, 'xPNTsToken');
143
+ validateAddress(opTreasury, 'opTreasury');
144
+ validateAmount(exchangeRate, 'exchangeRate');
145
+ return await client.writeContract({
146
+ address,
147
+ abi: SuperPaymasterABI,
148
+ functionName: 'configureOperator',
149
+ args: [xPNTsToken, opTreasury, exchangeRate],
150
+ account: account,
151
+ chain: client.chain
152
+ });
153
+ }
154
+ catch (error) {
155
+ throw AAStarError.fromViemError(error, 'configureOperator');
156
+ }
157
+ },
158
+ async setOperatorPaused({ operator, paused, account }) {
159
+ try {
160
+ validateAddress(operator, 'operator');
161
+ return await client.writeContract({
162
+ address,
163
+ abi: SuperPaymasterABI,
164
+ functionName: 'setOperatorPaused',
165
+ args: [operator, paused],
166
+ account: account,
167
+ chain: client.chain
168
+ });
169
+ }
170
+ catch (error) {
171
+ throw AAStarError.fromViemError(error, 'setOperatorPaused');
172
+ }
173
+ },
174
+ async setOperatorLimits({ minTxInterval, account }) {
175
+ try {
176
+ validateRequired(minTxInterval, 'minTxInterval');
177
+ return await client.writeContract({
178
+ address,
179
+ abi: SuperPaymasterABI,
180
+ functionName: 'setOperatorLimits',
181
+ args: [minTxInterval],
182
+ account: account,
183
+ chain: client.chain
184
+ });
185
+ }
186
+ catch (error) {
187
+ throw AAStarError.fromViemError(error, 'setOperatorLimits');
188
+ }
189
+ },
190
+ async updateReputation({ operator, newScore, account }) {
191
+ try {
192
+ validateAddress(operator, 'operator');
193
+ validateAmount(newScore, 'newScore');
194
+ return await client.writeContract({
195
+ address,
196
+ abi: SuperPaymasterABI,
197
+ functionName: 'updateReputation',
198
+ args: [operator, newScore],
199
+ account: account,
200
+ chain: client.chain
201
+ });
202
+ }
203
+ catch (error) {
204
+ throw AAStarError.fromViemError(error, 'updateReputation');
205
+ }
206
+ },
207
+ async executeSlashWithBLS({ operator, level, proof, account }) {
208
+ try {
209
+ validateAddress(operator, 'operator');
210
+ validateRequired(level, 'level');
211
+ validateRequired(proof, 'proof');
212
+ return await client.writeContract({
213
+ address,
214
+ abi: SuperPaymasterABI,
215
+ functionName: 'executeSlashWithBLS',
216
+ args: [operator, level, proof],
217
+ account: account,
218
+ chain: client.chain
219
+ });
220
+ }
221
+ catch (error) {
222
+ throw AAStarError.fromViemError(error, 'executeSlashWithBLS');
223
+ }
224
+ },
225
+ async slashOperator({ operator, level, penaltyAmount, reason, account }) {
226
+ try {
227
+ validateAddress(operator, 'operator');
228
+ validateRequired(level, 'level');
229
+ validateAmount(penaltyAmount, 'penaltyAmount');
230
+ validateRequired(reason, 'reason');
231
+ return await client.writeContract({
232
+ address,
233
+ abi: SuperPaymasterABI,
234
+ functionName: 'slashOperator',
235
+ args: [operator, level, penaltyAmount, reason],
236
+ account: account,
237
+ chain: client.chain
238
+ });
239
+ }
240
+ catch (error) {
241
+ throw AAStarError.fromViemError(error, 'slashOperator');
242
+ }
243
+ },
244
+ // User & SBT
245
+ async updateBlockedStatus({ operator, users, statuses, account }) {
246
+ try {
247
+ validateAddress(operator, 'operator');
248
+ validateRequired(users, 'users');
249
+ validateRequired(statuses, 'statuses');
250
+ return await client.writeContract({
251
+ address,
252
+ abi: SuperPaymasterABI,
253
+ functionName: 'updateBlockedStatus',
254
+ args: [operator, users, statuses],
255
+ account: account,
256
+ chain: client.chain
257
+ });
258
+ }
259
+ catch (error) {
260
+ throw AAStarError.fromViemError(error, 'updateBlockedStatus');
261
+ }
262
+ },
263
+ async updateSBTStatus({ user, status, account }) {
264
+ try {
265
+ validateAddress(user, 'user');
266
+ return await client.writeContract({
267
+ address,
268
+ abi: SuperPaymasterABI,
269
+ functionName: 'updateSBTStatus',
270
+ args: [user, status],
271
+ account: account,
272
+ chain: client.chain
273
+ });
274
+ }
275
+ catch (error) {
276
+ throw AAStarError.fromViemError(error, 'updateSBTStatus');
277
+ }
278
+ },
279
+ // Price
280
+ async setAPNTSPrice({ newPrice, account }) {
281
+ try {
282
+ validateAmount(newPrice, 'newPrice');
283
+ return await client.writeContract({
284
+ address,
285
+ abi: SuperPaymasterABI,
286
+ functionName: 'setAPNTSPrice',
287
+ args: [newPrice],
288
+ account: account,
289
+ chain: client.chain
290
+ });
291
+ }
292
+ catch (error) {
293
+ throw AAStarError.fromViemError(error, 'setAPNTSPrice');
294
+ }
295
+ },
296
+ async updatePrice({ account }) {
297
+ try {
298
+ return await client.writeContract({
299
+ address,
300
+ abi: SuperPaymasterABI,
301
+ functionName: 'updatePrice',
302
+ args: [],
303
+ account: account,
304
+ chain: client.chain
305
+ });
306
+ }
307
+ catch (error) {
308
+ throw AAStarError.fromViemError(error, 'updatePrice');
309
+ }
310
+ },
311
+ async updatePriceDVT({ price, updatedAt, proof, account }) {
312
+ try {
313
+ validateRequired(price, 'price');
314
+ validateRequired(updatedAt, 'updatedAt');
315
+ validateRequired(proof, 'proof');
316
+ return await client.writeContract({
317
+ address,
318
+ abi: SuperPaymasterABI,
319
+ functionName: 'updatePriceDVT',
320
+ args: [price, updatedAt, proof],
321
+ account: account,
322
+ chain: client.chain
323
+ });
324
+ }
325
+ catch (error) {
326
+ throw AAStarError.fromViemError(error, 'updatePriceDVT');
327
+ }
328
+ },
329
+ // Fees & Admin
330
+ async setProtocolFee({ newFeeBPS, account }) {
331
+ try {
332
+ validateAmount(newFeeBPS, 'newFeeBPS');
333
+ return await client.writeContract({
334
+ address,
335
+ abi: SuperPaymasterABI,
336
+ functionName: 'setProtocolFee',
337
+ args: [newFeeBPS],
338
+ account: account,
339
+ chain: client.chain
340
+ });
341
+ }
342
+ catch (error) {
343
+ throw AAStarError.fromViemError(error, 'setProtocolFee');
344
+ }
345
+ },
346
+ async setTreasury({ treasury, account }) {
347
+ try {
348
+ validateAddress(treasury, 'treasury');
349
+ return await client.writeContract({
350
+ address,
351
+ abi: SuperPaymasterABI,
352
+ functionName: 'setTreasury',
353
+ args: [treasury],
354
+ account: account,
355
+ chain: client.chain
356
+ });
357
+ }
358
+ catch (error) {
359
+ throw AAStarError.fromViemError(error, 'setTreasury');
360
+ }
361
+ },
362
+ async setXPNTsFactory({ factory, account }) {
363
+ try {
364
+ validateAddress(factory, 'factory');
365
+ return await client.writeContract({
366
+ address,
367
+ abi: SuperPaymasterABI,
368
+ functionName: 'setXPNTsFactory',
369
+ args: [factory],
370
+ account: account,
371
+ chain: client.chain
372
+ });
373
+ }
374
+ catch (error) {
375
+ throw AAStarError.fromViemError(error, 'setXPNTsFactory');
376
+ }
377
+ },
378
+ async setAPNTsToken({ token, account }) {
379
+ try {
380
+ validateAddress(token, 'token');
381
+ return await client.writeContract({
382
+ address,
383
+ abi: SuperPaymasterABI,
384
+ functionName: 'setAPNTsToken',
385
+ args: [token],
386
+ account: account,
387
+ chain: client.chain
388
+ });
389
+ }
390
+ catch (error) {
391
+ throw AAStarError.fromViemError(error, 'setAPNTsToken');
392
+ }
393
+ },
394
+ async setBLSAggregator({ aggregator, account }) {
395
+ try {
396
+ validateAddress(aggregator, 'aggregator');
397
+ return await client.writeContract({
398
+ address,
399
+ abi: SuperPaymasterABI,
400
+ functionName: 'setBLSAggregator',
401
+ args: [aggregator],
402
+ account: account,
403
+ chain: client.chain
404
+ });
405
+ }
406
+ catch (error) {
407
+ throw AAStarError.fromViemError(error, 'setBLSAggregator');
408
+ }
409
+ },
410
+ async withdrawProtocolRevenue({ to, amount, account }) {
411
+ try {
412
+ validateAddress(to, 'to');
413
+ validateAmount(amount, 'amount');
414
+ return await client.writeContract({
415
+ address,
416
+ abi: SuperPaymasterABI,
417
+ functionName: 'withdrawProtocolRevenue',
418
+ args: [to, amount],
419
+ account: account,
420
+ chain: client.chain
421
+ });
422
+ }
423
+ catch (error) {
424
+ throw AAStarError.fromViemError(error, 'withdrawProtocolRevenue');
425
+ }
426
+ },
427
+ // Callbacks & Validation
428
+ async onTransferReceived({ operator, from, value, data }) {
429
+ try {
430
+ validateAddress(operator, 'operator');
431
+ validateAddress(from, 'from');
432
+ validateAmount(value, 'value');
433
+ return await client.readContract({
434
+ address,
435
+ abi: SuperPaymasterABI,
436
+ functionName: 'onTransferReceived',
437
+ args: [operator, from, value, data]
438
+ });
439
+ }
440
+ catch (error) {
441
+ throw AAStarError.fromViemError(error, 'onTransferReceived');
442
+ }
443
+ },
444
+ async validatePaymasterUserOp({ userOp, userOpHash, maxCost }) {
445
+ try {
446
+ return await client.readContract({
447
+ address,
448
+ abi: SuperPaymasterABI,
449
+ functionName: 'validatePaymasterUserOp',
450
+ args: [userOp, userOpHash, maxCost]
451
+ });
452
+ }
453
+ catch (error) {
454
+ throw AAStarError.fromViemError(error, 'validatePaymasterUserOp');
455
+ }
185
456
  },
186
457
  // View Functions
187
- async superPaymasterOperators({ operator }) {
188
- return client.readContract({
189
- address,
190
- abi: SuperPaymasterABI,
191
- functionName: 'operators',
192
- args: [operator]
193
- });
194
- },
195
- async superPaymasterGetDeposit() {
196
- return client.readContract({
197
- address,
198
- abi: SuperPaymasterABI,
199
- functionName: 'getDeposit',
200
- args: []
201
- });
202
- },
203
- async superPaymasterGetAvailableCredit({ operator, user }) {
204
- return client.readContract({
205
- address,
206
- abi: SuperPaymasterABI,
207
- functionName: 'getAvailableCredit',
208
- args: [operator, user]
209
- });
210
- },
211
- async superPaymasterBlockedUsers({ user }) {
212
- return client.readContract({
213
- address,
214
- abi: SuperPaymasterABI,
215
- functionName: 'blockedUsers',
216
- args: [user]
217
- });
218
- },
219
- // Convenience function: Get operator's aPNTs balance
220
- async superPaymasterBalanceOfOperator({ operator }) {
221
- const operatorConfig = await this.superPaymasterOperators({ operator });
222
- return operatorConfig[0]; // aPNTsBalance is the first field
223
- },
224
- async superPaymasterAPNTsPriceUSD() {
225
- return client.readContract({
226
- address,
227
- abi: SuperPaymasterABI,
228
- functionName: 'aPNTsPriceUSD',
229
- args: []
230
- });
231
- },
232
- async superPaymasterCachedPrice() {
233
- return client.readContract({
234
- address,
235
- abi: SuperPaymasterABI,
236
- functionName: 'cachedPrice',
237
- args: []
238
- });
239
- },
240
- async superPaymasterProtocolFee() {
241
- return client.readContract({
242
- address,
243
- abi: SuperPaymasterABI,
244
- functionName: 'protocolFee',
245
- args: []
246
- });
247
- },
248
- async superPaymasterEntryPoint() {
249
- return client.readContract({
250
- address,
251
- abi: SuperPaymasterABI,
252
- functionName: 'entryPoint',
253
- args: []
254
- });
458
+ async operators({ operator }) {
459
+ try {
460
+ validateAddress(operator, 'operator');
461
+ const result = await client.readContract({
462
+ address,
463
+ abi: SuperPaymasterABI,
464
+ functionName: 'operators',
465
+ args: [operator]
466
+ });
467
+ if (Array.isArray(result)) {
468
+ return {
469
+ aPNTsBalance: result[0],
470
+ exchangeRate: result[1],
471
+ isConfigured: result[2],
472
+ isPaused: result[3],
473
+ xPNTsToken: result[4],
474
+ reputation: result[5],
475
+ minTxInterval: result[6],
476
+ treasury: result[7],
477
+ totalSpent: result[8],
478
+ totalTxSponsored: result[9]
479
+ };
480
+ }
481
+ return result;
482
+ }
483
+ catch (error) {
484
+ throw AAStarError.fromViemError(error, 'operators');
485
+ }
486
+ },
487
+ async getAvailableCredit({ user, token }) {
488
+ try {
489
+ validateAddress(user, 'user');
490
+ validateAddress(token, 'token');
491
+ return await client.readContract({
492
+ address,
493
+ abi: SuperPaymasterABI,
494
+ functionName: 'getAvailableCredit',
495
+ args: [user, token]
496
+ });
497
+ }
498
+ catch (error) {
499
+ throw AAStarError.fromViemError(error, 'getAvailableCredit');
500
+ }
501
+ },
502
+ async getDeposit() {
503
+ try {
504
+ return await client.readContract({
505
+ address,
506
+ abi: SuperPaymasterABI,
507
+ functionName: 'getDeposit',
508
+ args: []
509
+ });
510
+ }
511
+ catch (error) {
512
+ throw AAStarError.fromViemError(error, 'getDeposit');
513
+ }
514
+ },
515
+ async getLatestSlash({ operator }) {
516
+ try {
517
+ validateAddress(operator, 'operator');
518
+ const res = await client.readContract({
519
+ address,
520
+ abi: SuperPaymasterABI,
521
+ functionName: 'getLatestSlash',
522
+ args: [operator]
523
+ });
524
+ if (Array.isArray(res)) {
525
+ return {
526
+ timestamp: res[0],
527
+ amount: res[1],
528
+ reputationLoss: res[2],
529
+ reason: res[3],
530
+ level: res[4]
531
+ };
532
+ }
533
+ return res;
534
+ }
535
+ catch (error) {
536
+ throw AAStarError.fromViemError(error, 'getLatestSlash');
537
+ }
538
+ },
539
+ async getSlashCount({ operator }) {
540
+ try {
541
+ validateAddress(operator, 'operator');
542
+ return await client.readContract({
543
+ address,
544
+ abi: SuperPaymasterABI,
545
+ functionName: 'getSlashCount',
546
+ args: [operator]
547
+ });
548
+ }
549
+ catch (error) {
550
+ throw AAStarError.fromViemError(error, 'getSlashCount');
551
+ }
552
+ },
553
+ async getSlashHistory({ operator }) {
554
+ try {
555
+ validateAddress(operator, 'operator');
556
+ const res = await client.readContract({
557
+ address,
558
+ abi: SuperPaymasterABI,
559
+ functionName: 'getSlashHistory',
560
+ args: [operator]
561
+ });
562
+ return res.map(r => {
563
+ if (Array.isArray(r)) {
564
+ return {
565
+ timestamp: r[0],
566
+ amount: r[1],
567
+ reputationLoss: r[2],
568
+ reason: r[3],
569
+ level: r[4]
570
+ };
571
+ }
572
+ return r;
573
+ });
574
+ }
575
+ catch (error) {
576
+ throw AAStarError.fromViemError(error, 'getSlashHistory');
577
+ }
578
+ },
579
+ async slashHistory({ operator, index }) {
580
+ try {
581
+ validateAddress(operator, 'operator');
582
+ validateRequired(index, 'index');
583
+ const res = await client.readContract({
584
+ address,
585
+ abi: SuperPaymasterABI,
586
+ functionName: 'slashHistory',
587
+ args: [operator, index]
588
+ });
589
+ if (Array.isArray(res)) {
590
+ return {
591
+ timestamp: res[0],
592
+ amount: res[1],
593
+ reputationLoss: res[2],
594
+ reason: res[3],
595
+ level: res[4]
596
+ };
597
+ }
598
+ return res;
599
+ }
600
+ catch (error) {
601
+ throw AAStarError.fromViemError(error, 'slashHistory');
602
+ }
603
+ },
604
+ async userOpState({ user, operator }) {
605
+ try {
606
+ validateAddress(user, 'user');
607
+ validateAddress(operator, 'operator');
608
+ const res = await client.readContract({
609
+ address,
610
+ abi: SuperPaymasterABI,
611
+ functionName: 'userOpState',
612
+ args: [user, operator]
613
+ });
614
+ if (Array.isArray(res)) {
615
+ return { lastTimestamp: Number(res[0]), isBlocked: res[1] };
616
+ }
617
+ return { lastTimestamp: Number(res.lastTimestamp), isBlocked: res.isBlocked };
618
+ }
619
+ catch (error) {
620
+ throw AAStarError.fromViemError(error, 'userOpState');
621
+ }
622
+ },
623
+ async cachedPrice() {
624
+ try {
625
+ const res = await client.readContract({
626
+ address,
627
+ abi: SuperPaymasterABI,
628
+ functionName: 'cachedPrice',
629
+ args: []
630
+ });
631
+ if (Array.isArray(res)) {
632
+ return {
633
+ price: res[0],
634
+ updatedAt: res[1],
635
+ roundId: res[2],
636
+ decimals: res[3]
637
+ };
638
+ }
639
+ return res;
640
+ }
641
+ catch (error) {
642
+ throw AAStarError.fromViemError(error, 'cachedPrice');
643
+ }
644
+ },
645
+ async aPNTsPriceUSD() {
646
+ try {
647
+ return await client.readContract({
648
+ address,
649
+ abi: SuperPaymasterABI,
650
+ functionName: 'aPNTsPriceUSD',
651
+ args: []
652
+ });
653
+ }
654
+ catch (error) {
655
+ throw AAStarError.fromViemError(error, 'aPNTsPriceUSD');
656
+ }
657
+ },
658
+ async protocolFeeBPS() {
659
+ try {
660
+ return await client.readContract({
661
+ address,
662
+ abi: SuperPaymasterABI,
663
+ functionName: 'protocolFeeBPS',
664
+ args: []
665
+ });
666
+ }
667
+ catch (error) {
668
+ throw AAStarError.fromViemError(error, 'protocolFeeBPS');
669
+ }
670
+ },
671
+ async protocolRevenue() {
672
+ try {
673
+ return await client.readContract({
674
+ address,
675
+ abi: SuperPaymasterABI,
676
+ functionName: 'protocolRevenue',
677
+ args: []
678
+ });
679
+ }
680
+ catch (error) {
681
+ throw AAStarError.fromViemError(error, 'protocolRevenue');
682
+ }
683
+ },
684
+ async totalTrackedBalance() {
685
+ try {
686
+ return await client.readContract({
687
+ address,
688
+ abi: SuperPaymasterABI,
689
+ functionName: 'totalTrackedBalance',
690
+ args: []
691
+ });
692
+ }
693
+ catch (error) {
694
+ throw AAStarError.fromViemError(error, 'totalTrackedBalance');
695
+ }
696
+ },
697
+ async priceStalenessThreshold() {
698
+ try {
699
+ return await client.readContract({
700
+ address,
701
+ abi: SuperPaymasterABI,
702
+ functionName: 'priceStalenessThreshold',
703
+ args: []
704
+ });
705
+ }
706
+ catch (error) {
707
+ throw AAStarError.fromViemError(error, 'priceStalenessThreshold');
708
+ }
709
+ },
710
+ async sbtHolders({ user }) {
711
+ try {
712
+ validateAddress(user, 'user');
713
+ return await client.readContract({
714
+ address,
715
+ abi: SuperPaymasterABI,
716
+ functionName: 'sbtHolders',
717
+ args: [user]
718
+ });
719
+ }
720
+ catch (error) {
721
+ throw AAStarError.fromViemError(error, 'sbtHolders');
722
+ }
255
723
  },
256
724
  // Constants
257
- async superPaymasterAPNTS_TOKEN() {
258
- return client.readContract({
259
- address,
260
- abi: SuperPaymasterABI,
261
- functionName: 'APNTS_TOKEN',
262
- args: []
263
- });
264
- },
265
- async superPaymasterREGISTRY() {
266
- return client.readContract({
267
- address,
268
- abi: SuperPaymasterABI,
269
- functionName: 'REGISTRY',
270
- args: []
271
- });
272
- },
273
- async superPaymasterBLS_AGGREGATOR() {
274
- return client.readContract({
275
- address,
276
- abi: SuperPaymasterABI,
277
- functionName: 'BLS_AGGREGATOR',
278
- args: []
279
- });
280
- },
281
- async superPaymasterETH_USD_PRICE_FEED() {
282
- return client.readContract({
283
- address,
284
- abi: SuperPaymasterABI,
285
- functionName: 'ETH_USD_PRICE_FEED',
286
- args: []
287
- });
288
- },
289
- async superPaymasterPAYMASTER_DATA_OFFSET() {
290
- return client.readContract({
291
- address,
292
- abi: SuperPaymasterABI,
293
- functionName: 'PAYMASTER_DATA_OFFSET',
294
- args: []
295
- });
296
- },
297
- async superPaymasterRATE_OFFSET() {
298
- return client.readContract({
299
- address,
300
- abi: SuperPaymasterABI,
301
- functionName: 'RATE_OFFSET',
302
- args: []
303
- });
304
- },
305
- async superPaymasterBPS_DENOMINATOR() {
306
- return client.readContract({
307
- address,
308
- abi: SuperPaymasterABI,
309
- functionName: 'BPS_DENOMINATOR',
310
- args: []
311
- });
312
- },
313
- async superPaymasterPRICE_CACHE_DURATION() {
314
- return client.readContract({
315
- address,
316
- abi: SuperPaymasterABI,
317
- functionName: 'PRICE_CACHE_DURATION',
318
- args: []
319
- });
320
- },
321
- async superPaymasterPRICE_STALENESS_THRESHOLD() {
322
- return client.readContract({
323
- address,
324
- abi: SuperPaymasterABI,
325
- functionName: 'PRICE_STALENESS_THRESHOLD',
326
- args: []
327
- });
328
- },
329
- async superPaymasterMAX_ETH_USD_PRICE() {
330
- return client.readContract({
331
- address,
332
- abi: SuperPaymasterABI,
333
- functionName: 'MAX_ETH_USD_PRICE',
334
- args: []
335
- });
336
- },
337
- async superPaymasterMIN_ETH_USD_PRICE() {
338
- return client.readContract({
339
- address,
340
- abi: SuperPaymasterABI,
341
- functionName: 'MIN_ETH_USD_PRICE',
342
- args: []
343
- });
725
+ async APNTS_TOKEN() {
726
+ try {
727
+ return await client.readContract({
728
+ address,
729
+ abi: SuperPaymasterABI,
730
+ functionName: 'APNTS_TOKEN',
731
+ args: []
732
+ });
733
+ }
734
+ catch (error) {
735
+ throw AAStarError.fromViemError(error, 'APNTS_TOKEN');
736
+ }
737
+ },
738
+ async REGISTRY() {
739
+ try {
740
+ return await client.readContract({
741
+ address,
742
+ abi: SuperPaymasterABI,
743
+ functionName: 'REGISTRY',
744
+ args: []
745
+ });
746
+ }
747
+ catch (error) {
748
+ throw AAStarError.fromViemError(error, 'REGISTRY');
749
+ }
750
+ },
751
+ async BLS_AGGREGATOR() {
752
+ try {
753
+ return await client.readContract({
754
+ address,
755
+ abi: SuperPaymasterABI,
756
+ functionName: 'BLS_AGGREGATOR',
757
+ args: []
758
+ });
759
+ }
760
+ catch (error) {
761
+ throw AAStarError.fromViemError(error, 'BLS_AGGREGATOR');
762
+ }
763
+ },
764
+ async ETH_USD_PRICE_FEED() {
765
+ try {
766
+ return await client.readContract({
767
+ address,
768
+ abi: SuperPaymasterABI,
769
+ functionName: 'ETH_USD_PRICE_FEED',
770
+ args: []
771
+ });
772
+ }
773
+ catch (error) {
774
+ throw AAStarError.fromViemError(error, 'ETH_USD_PRICE_FEED');
775
+ }
776
+ },
777
+ async treasury() {
778
+ try {
779
+ return await client.readContract({
780
+ address,
781
+ abi: SuperPaymasterABI,
782
+ functionName: 'treasury',
783
+ args: []
784
+ });
785
+ }
786
+ catch (error) {
787
+ throw AAStarError.fromViemError(error, 'treasury');
788
+ }
789
+ },
790
+ async xpntsFactory() {
791
+ try {
792
+ return await client.readContract({
793
+ address,
794
+ abi: SuperPaymasterABI,
795
+ functionName: 'xpntsFactory',
796
+ args: []
797
+ });
798
+ }
799
+ catch (error) {
800
+ throw AAStarError.fromViemError(error, 'xpntsFactory');
801
+ }
802
+ },
803
+ async entryPoint() {
804
+ try {
805
+ return await client.readContract({
806
+ address,
807
+ abi: SuperPaymasterABI,
808
+ functionName: 'entryPoint',
809
+ args: []
810
+ });
811
+ }
812
+ catch (error) {
813
+ throw AAStarError.fromViemError(error, 'entryPoint');
814
+ }
815
+ },
816
+ async MAX_PROTOCOL_FEE() {
817
+ try {
818
+ return await client.readContract({
819
+ address,
820
+ abi: SuperPaymasterABI,
821
+ functionName: 'MAX_PROTOCOL_FEE',
822
+ args: []
823
+ });
824
+ }
825
+ catch (error) {
826
+ throw AAStarError.fromViemError(error, 'MAX_PROTOCOL_FEE');
827
+ }
828
+ },
829
+ async MAX_ETH_USD_PRICE() {
830
+ try {
831
+ return await client.readContract({
832
+ address,
833
+ abi: SuperPaymasterABI,
834
+ functionName: 'MAX_ETH_USD_PRICE',
835
+ args: []
836
+ });
837
+ }
838
+ catch (error) {
839
+ throw AAStarError.fromViemError(error, 'MAX_ETH_USD_PRICE');
840
+ }
841
+ },
842
+ async MIN_ETH_USD_PRICE() {
843
+ try {
844
+ return await client.readContract({
845
+ address,
846
+ abi: SuperPaymasterABI,
847
+ functionName: 'MIN_ETH_USD_PRICE',
848
+ args: []
849
+ });
850
+ }
851
+ catch (error) {
852
+ throw AAStarError.fromViemError(error, 'MIN_ETH_USD_PRICE');
853
+ }
854
+ },
855
+ async PAYMASTER_DATA_OFFSET() {
856
+ try {
857
+ return await client.readContract({
858
+ address,
859
+ abi: SuperPaymasterABI,
860
+ functionName: 'PAYMASTER_DATA_OFFSET',
861
+ args: []
862
+ });
863
+ }
864
+ catch (error) {
865
+ throw AAStarError.fromViemError(error, 'PAYMASTER_DATA_OFFSET');
866
+ }
867
+ },
868
+ async PRICE_CACHE_DURATION() {
869
+ try {
870
+ return await client.readContract({
871
+ address,
872
+ abi: SuperPaymasterABI,
873
+ functionName: 'PRICE_CACHE_DURATION',
874
+ args: []
875
+ });
876
+ }
877
+ catch (error) {
878
+ throw AAStarError.fromViemError(error, 'PRICE_CACHE_DURATION');
879
+ }
880
+ },
881
+ async RATE_OFFSET() {
882
+ try {
883
+ return await client.readContract({
884
+ address,
885
+ abi: SuperPaymasterABI,
886
+ functionName: 'RATE_OFFSET',
887
+ args: []
888
+ });
889
+ }
890
+ catch (error) {
891
+ throw AAStarError.fromViemError(error, 'RATE_OFFSET');
892
+ }
893
+ },
894
+ async VALIDATION_BUFFER_BPS() {
895
+ try {
896
+ return await client.readContract({
897
+ address,
898
+ abi: SuperPaymasterABI,
899
+ functionName: 'VALIDATION_BUFFER_BPS',
900
+ args: []
901
+ });
902
+ }
903
+ catch (error) {
904
+ throw AAStarError.fromViemError(error, 'VALIDATION_BUFFER_BPS');
905
+ }
906
+ },
907
+ async BPS_DENOMINATOR() {
908
+ try {
909
+ return await client.readContract({
910
+ address,
911
+ abi: SuperPaymasterABI,
912
+ functionName: 'BPS_DENOMINATOR',
913
+ args: []
914
+ });
915
+ }
916
+ catch (error) {
917
+ throw AAStarError.fromViemError(error, 'BPS_DENOMINATOR');
918
+ }
344
919
  },
345
920
  // Admin
346
- async transferSuperPaymasterOwnership({ newOwner, account }) {
347
- return client.writeContract({
348
- address,
349
- abi: SuperPaymasterABI,
350
- functionName: 'transferOwnership',
351
- args: [newOwner],
352
- account: account,
353
- chain: client.chain
354
- });
355
- },
356
- async superPaymasterOwner() {
357
- return client.readContract({
358
- address,
359
- abi: SuperPaymasterABI,
360
- functionName: 'owner',
361
- args: []
362
- });
363
- },
364
- async renounceSuperPaymasterOwnership({ account }) {
365
- return client.writeContract({
366
- address,
367
- abi: SuperPaymasterABI,
368
- functionName: 'renounceOwnership',
369
- args: [],
370
- account: account,
371
- chain: client.chain
372
- });
373
- },
374
- // Additional Operator Management
375
- async superPaymasterSetOperatorLimits({ operator, limits, account }) {
376
- return client.writeContract({
377
- address,
378
- abi: SuperPaymasterABI,
379
- functionName: 'setOperatorLimits',
380
- args: [operator, limits],
381
- account: account,
382
- chain: client.chain
383
- });
384
- },
385
- async superPaymasterSlashOperator({ operator, amount, reason, account }) {
386
- return client.writeContract({
387
- address,
388
- abi: SuperPaymasterABI,
389
- functionName: 'slashOperator',
390
- args: [operator, amount, reason],
391
- account: account,
392
- chain: client.chain
393
- });
394
- },
395
- // User Management
396
- async superPaymasterUpdateBlockedStatus({ user, blocked, account }) {
397
- return client.writeContract({
398
- address,
399
- abi: SuperPaymasterABI,
400
- functionName: 'updateBlockedStatus',
401
- args: [user, blocked],
402
- account: account,
403
- chain: client.chain
404
- });
405
- },
406
- // Additional View Functions
407
- async superPaymasterProtocolFeeBPS() {
408
- return client.readContract({
409
- address,
410
- abi: SuperPaymasterABI,
411
- functionName: 'protocolFeeBPS',
412
- args: []
413
- });
414
- },
415
- async superPaymasterProtocolRevenue() {
416
- return client.readContract({
417
- address,
418
- abi: SuperPaymasterABI,
419
- functionName: 'protocolRevenue',
420
- args: []
421
- });
422
- },
423
- async superPaymasterTreasury() {
424
- return client.readContract({
425
- address,
426
- abi: SuperPaymasterABI,
427
- functionName: 'treasury',
428
- args: []
429
- });
430
- },
431
- async superPaymasterXpntsFactory() {
432
- return client.readContract({
433
- address,
434
- abi: SuperPaymasterABI,
435
- functionName: 'xpntsFactory',
436
- args: []
437
- });
438
- },
439
- async superPaymasterTotalTrackedBalance() {
440
- return client.readContract({
441
- address,
442
- abi: SuperPaymasterABI,
443
- functionName: 'totalTrackedBalance',
444
- args: []
445
- });
446
- },
447
- async superPaymasterLastUserOpTimestamp({ user }) {
448
- return client.readContract({
449
- address,
450
- abi: SuperPaymasterABI,
451
- functionName: 'lastUserOpTimestamp',
452
- args: [user]
453
- });
454
- },
455
- // Slash History
456
- async superPaymasterGetSlashHistory({ operator }) {
457
- return client.readContract({
458
- address,
459
- abi: SuperPaymasterABI,
460
- functionName: 'getSlashHistory',
461
- args: [operator]
462
- });
463
- },
464
- async superPaymasterGetSlashCount({ operator }) {
465
- return client.readContract({
466
- address,
467
- abi: SuperPaymasterABI,
468
- functionName: 'getSlashCount',
469
- args: [operator]
470
- });
471
- },
472
- async superPaymasterGetLatestSlash({ operator }) {
473
- return client.readContract({
474
- address,
475
- abi: SuperPaymasterABI,
476
- functionName: 'getLatestSlash',
477
- args: [operator]
478
- });
479
- },
480
- async superPaymasterSlashHistory({ operator, index }) {
481
- return client.readContract({
482
- address,
483
- abi: SuperPaymasterABI,
484
- functionName: 'slashHistory',
485
- args: [operator, index]
486
- });
487
- },
488
- // Price Management
489
- async superPaymasterUpdatePrice({ account }) {
490
- return client.writeContract({
491
- address,
492
- abi: SuperPaymasterABI,
493
- functionName: 'updatePrice',
494
- args: [],
495
- account: account,
496
- chain: client.chain
497
- });
498
- },
499
- async superPaymasterUpdatePriceDVT({ price, proof, account }) {
500
- return client.writeContract({
501
- address,
502
- abi: SuperPaymasterABI,
503
- functionName: 'updatePriceDVT',
504
- args: [price, proof],
505
- account: account,
506
- chain: client.chain
507
- });
508
- },
509
- // Treasury & Revenue
510
- async superPaymasterSetTreasury({ treasury, account }) {
511
- return client.writeContract({
512
- address,
513
- abi: SuperPaymasterABI,
514
- functionName: 'setTreasury',
515
- args: [treasury],
516
- account: account,
517
- chain: client.chain
518
- });
519
- },
520
- async superPaymasterWithdrawProtocolRevenue({ to, account }) {
521
- return client.writeContract({
522
- address,
523
- abi: SuperPaymasterABI,
524
- functionName: 'withdrawProtocolRevenue',
525
- args: [to],
526
- account: account,
527
- chain: client.chain
528
- });
529
- },
530
- // Factory & Config
531
- async superPaymasterSetXPNTsFactory({ factory, account }) {
532
- return client.writeContract({
533
- address,
534
- abi: SuperPaymasterABI,
535
- functionName: 'setXPNTsFactory',
536
- args: [factory],
537
- account: account,
538
- chain: client.chain
539
- });
540
- },
541
- async superPaymasterSetAPNTsToken({ token, account }) {
542
- return client.writeContract({
543
- address,
544
- abi: SuperPaymasterABI,
545
- functionName: 'setAPNTsToken',
546
- args: [token],
547
- account: account,
548
- chain: client.chain
549
- });
550
- },
551
- async superPaymasterSetBLSAggregator({ aggregator, account }) {
552
- return client.writeContract({
553
- address,
554
- abi: SuperPaymasterABI,
555
- functionName: 'setBLSAggregator',
556
- args: [aggregator],
557
- account: account,
558
- chain: client.chain
559
- });
560
- },
561
- // Transfer callback
562
- async superPaymasterOnTransferReceived({ from, amount, data }) {
563
- return client.readContract({
564
- address,
565
- abi: SuperPaymasterABI,
566
- functionName: 'onTransferReceived',
567
- args: [from, amount, data]
568
- });
569
- },
570
- // Withdraw alias
571
- async superPaymasterWithdrawAPNTs({ amount, account }) {
572
- return client.writeContract({
573
- address,
574
- abi: SuperPaymasterABI,
575
- functionName: 'withdraw',
576
- args: [amount],
577
- account: account,
578
- chain: client.chain
579
- });
580
- },
581
- async superPaymasterVersion() {
582
- return client.readContract({
583
- address,
584
- abi: SuperPaymasterABI,
585
- functionName: 'version',
586
- args: []
587
- });
588
- },
589
- // Aliases including implementation
590
- async superPaymasterAddStake(args) { return this.superPaymasterDepositFor(args); },
591
- async superPaymasterDepositForAlias(args) { return this.superPaymasterDepositFor(args); },
592
- async superPaymasterUnlockStake(args) { return this.superPaymasterUnlockSuperStake(args); },
593
- async superPaymasterWithdrawAlias(args) { return this.superPaymasterWithdraw(args); },
594
- async superPaymasterMAX_PROTOCOL_FEE() {
595
- return client.readContract({
596
- address,
597
- abi: SuperPaymasterABI,
598
- functionName: 'MAX_PROTOCOL_FEE',
599
- args: []
600
- });
601
- },
602
- async superPaymasterVALIDATION_BUFFER_BPS() {
603
- return client.readContract({
604
- address,
605
- abi: SuperPaymasterABI,
606
- functionName: 'VALIDATION_BUFFER_BPS',
607
- args: []
608
- });
609
- },
610
- async superPaymasterPriceStalenessThreshold() {
611
- return client.readContract({
612
- address,
613
- abi: SuperPaymasterABI,
614
- functionName: 'priceStalenessThreshold', // Assuming ABI has this exact name
615
- args: []
616
- });
617
- },
618
- async superPaymasterSbtHolders({ user }) {
619
- return client.readContract({
620
- address,
621
- abi: SuperPaymasterABI,
622
- functionName: 'sbtHolders',
623
- args: [user]
624
- });
625
- },
626
- async superPaymasterUserOpState({ userOpHash }) {
627
- return client.readContract({
628
- address,
629
- abi: SuperPaymasterABI,
630
- functionName: 'userOpState',
631
- args: [userOpHash]
632
- });
633
- },
634
- async superPaymasterUpdateSBTStatus({ user, hasSBT, account }) {
635
- return client.writeContract({
636
- address,
637
- abi: SuperPaymasterABI,
638
- functionName: 'updateSBTStatus',
639
- args: [user, hasSBT],
640
- account: account,
641
- chain: client.chain
642
- });
921
+ async owner() {
922
+ try {
923
+ return await client.readContract({
924
+ address,
925
+ abi: SuperPaymasterABI,
926
+ functionName: 'owner',
927
+ args: []
928
+ });
929
+ }
930
+ catch (error) {
931
+ throw AAStarError.fromViemError(error, 'owner');
932
+ }
933
+ },
934
+ async transferOwnership({ newOwner, account }) {
935
+ try {
936
+ validateAddress(newOwner, 'newOwner');
937
+ return await client.writeContract({
938
+ address,
939
+ abi: SuperPaymasterABI,
940
+ functionName: 'transferOwnership',
941
+ args: [newOwner],
942
+ account: account,
943
+ chain: client.chain
944
+ });
945
+ }
946
+ catch (error) {
947
+ throw AAStarError.fromViemError(error, 'transferOwnership');
948
+ }
949
+ },
950
+ async renounceOwnership({ account }) {
951
+ try {
952
+ return await client.writeContract({
953
+ address,
954
+ abi: SuperPaymasterABI,
955
+ functionName: 'renounceOwnership',
956
+ args: [],
957
+ account: account,
958
+ chain: client.chain
959
+ });
960
+ }
961
+ catch (error) {
962
+ throw AAStarError.fromViemError(error, 'renounceOwnership');
963
+ }
964
+ },
965
+ async version() {
966
+ try {
967
+ return await client.readContract({
968
+ address,
969
+ abi: SuperPaymasterABI,
970
+ functionName: 'version',
971
+ args: []
972
+ });
973
+ }
974
+ catch (error) {
975
+ throw AAStarError.fromViemError(error, 'version');
976
+ }
643
977
  }
644
978
  });