@aastar/core 0.16.8 → 0.16.12
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
|
@@ -0,0 +1,706 @@
|
|
|
1
|
+
import { PaymasterABI } from '../abis/index.js';
|
|
2
|
+
import { validateAddress, validateAmount, validatePositive, validateRequired } from '../validators/index.js';
|
|
3
|
+
import { AAStarError } from '../errors/index.js';
|
|
4
|
+
export const paymasterActions = (address) => (client) => ({
|
|
5
|
+
// Deposit Management
|
|
6
|
+
async depositFor({ user, token, amount, account }) {
|
|
7
|
+
try {
|
|
8
|
+
validateAddress(user, 'user');
|
|
9
|
+
validateAddress(token, 'token');
|
|
10
|
+
validatePositive(amount, 'amount');
|
|
11
|
+
return await client.writeContract({
|
|
12
|
+
address,
|
|
13
|
+
abi: PaymasterABI,
|
|
14
|
+
functionName: 'depositFor',
|
|
15
|
+
args: [user, token, amount],
|
|
16
|
+
account: account,
|
|
17
|
+
chain: client.chain
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
throw AAStarError.fromViemError(error, 'depositFor');
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
async withdraw({ token, amount, account }) {
|
|
25
|
+
try {
|
|
26
|
+
validateAddress(token, 'token');
|
|
27
|
+
validateAmount(amount, 'amount');
|
|
28
|
+
return await client.writeContract({
|
|
29
|
+
address,
|
|
30
|
+
abi: PaymasterABI,
|
|
31
|
+
functionName: 'withdraw',
|
|
32
|
+
args: [token, amount],
|
|
33
|
+
account: account,
|
|
34
|
+
chain: client.chain
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw AAStarError.fromViemError(error, 'withdraw');
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
async balances({ user, token }) {
|
|
42
|
+
try {
|
|
43
|
+
validateAddress(user, 'user');
|
|
44
|
+
validateAddress(token, 'token');
|
|
45
|
+
return await client.readContract({
|
|
46
|
+
address,
|
|
47
|
+
abi: PaymasterABI,
|
|
48
|
+
functionName: 'balances',
|
|
49
|
+
args: [user, token]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw AAStarError.fromViemError(error, 'balances');
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
async setTokenPrice({ token, price, account }) {
|
|
57
|
+
try {
|
|
58
|
+
validateAddress(token, 'token');
|
|
59
|
+
validateAmount(price, 'price');
|
|
60
|
+
return await client.writeContract({
|
|
61
|
+
address,
|
|
62
|
+
abi: PaymasterABI,
|
|
63
|
+
functionName: 'setTokenPrice',
|
|
64
|
+
args: [token, price],
|
|
65
|
+
account: account,
|
|
66
|
+
chain: client.chain
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
throw AAStarError.fromViemError(error, 'setTokenPrice');
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
async setCachedPrice({ price, timestamp, account }) {
|
|
74
|
+
try {
|
|
75
|
+
validatePositive(price, 'price');
|
|
76
|
+
validatePositive(BigInt(timestamp), 'timestamp');
|
|
77
|
+
return await client.writeContract({
|
|
78
|
+
address,
|
|
79
|
+
abi: PaymasterABI,
|
|
80
|
+
functionName: 'setCachedPrice',
|
|
81
|
+
args: [price, timestamp],
|
|
82
|
+
account: account,
|
|
83
|
+
chain: client.chain
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw AAStarError.fromViemError(error, 'setCachedPrice');
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
async tokenPrices({ token }) {
|
|
91
|
+
try {
|
|
92
|
+
validateAddress(token, 'token');
|
|
93
|
+
return await client.readContract({
|
|
94
|
+
address,
|
|
95
|
+
abi: PaymasterABI,
|
|
96
|
+
functionName: 'tokenPrices',
|
|
97
|
+
args: [token]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
throw AAStarError.fromViemError(error, 'tokenPrices');
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
// Validation
|
|
105
|
+
async validatePaymasterUserOp({ userOp, userOpHash, maxCost }) {
|
|
106
|
+
try {
|
|
107
|
+
validateRequired(userOp, 'userOp');
|
|
108
|
+
validateRequired(userOpHash, 'userOpHash');
|
|
109
|
+
validateAmount(maxCost, 'maxCost');
|
|
110
|
+
const result = await client.readContract({
|
|
111
|
+
address,
|
|
112
|
+
abi: PaymasterABI,
|
|
113
|
+
functionName: 'validatePaymasterUserOp',
|
|
114
|
+
args: [userOp, userOpHash, maxCost]
|
|
115
|
+
});
|
|
116
|
+
return { context: result[0], validationData: result[1] };
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
throw AAStarError.fromViemError(error, 'validatePaymasterUserOp');
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
async postOp({ mode, context, actualGasCost, actualUserOpFeePerGas, account }) {
|
|
123
|
+
try {
|
|
124
|
+
validateRequired(mode, 'mode');
|
|
125
|
+
validateRequired(context, 'context');
|
|
126
|
+
validateAmount(actualGasCost, 'actualGasCost');
|
|
127
|
+
validateAmount(actualUserOpFeePerGas, 'actualUserOpFeePerGas');
|
|
128
|
+
return await client.writeContract({
|
|
129
|
+
address,
|
|
130
|
+
abi: PaymasterABI,
|
|
131
|
+
functionName: 'postOp',
|
|
132
|
+
args: [mode, context, actualGasCost, actualUserOpFeePerGas],
|
|
133
|
+
account: account,
|
|
134
|
+
chain: client.chain
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
throw AAStarError.fromViemError(error, 'postOp');
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
// Deposit & Withdrawal
|
|
142
|
+
async addDeposit({ account, value }) {
|
|
143
|
+
try {
|
|
144
|
+
return await client.writeContract({
|
|
145
|
+
address,
|
|
146
|
+
abi: PaymasterABI,
|
|
147
|
+
functionName: 'addDeposit',
|
|
148
|
+
args: [],
|
|
149
|
+
account: account,
|
|
150
|
+
chain: client.chain,
|
|
151
|
+
value
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
throw AAStarError.fromViemError(error, 'addDeposit');
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
async withdrawTo({ to, amount, account }) {
|
|
159
|
+
try {
|
|
160
|
+
validateAddress(to, 'to');
|
|
161
|
+
validatePositive(amount, 'amount');
|
|
162
|
+
return await client.writeContract({
|
|
163
|
+
address,
|
|
164
|
+
abi: PaymasterABI,
|
|
165
|
+
functionName: 'withdrawTo',
|
|
166
|
+
args: [to, amount],
|
|
167
|
+
account: account,
|
|
168
|
+
chain: client.chain
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
throw AAStarError.fromViemError(error, 'withdrawTo');
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
async addStake({ unstakeDelaySec, account, value }) {
|
|
176
|
+
try {
|
|
177
|
+
validateRequired(unstakeDelaySec, 'unstakeDelaySec');
|
|
178
|
+
return await client.writeContract({
|
|
179
|
+
address,
|
|
180
|
+
abi: PaymasterABI,
|
|
181
|
+
functionName: 'addStake',
|
|
182
|
+
args: [unstakeDelaySec],
|
|
183
|
+
account: account,
|
|
184
|
+
chain: client.chain,
|
|
185
|
+
value
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
throw AAStarError.fromViemError(error, 'addStake');
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
async unlockStake({ account }) {
|
|
193
|
+
try {
|
|
194
|
+
return await client.writeContract({
|
|
195
|
+
address,
|
|
196
|
+
abi: PaymasterABI,
|
|
197
|
+
functionName: 'unlockStake',
|
|
198
|
+
args: [],
|
|
199
|
+
account: account,
|
|
200
|
+
chain: client.chain
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
throw AAStarError.fromViemError(error, 'unlockStake');
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
async withdrawStake({ to, account }) {
|
|
208
|
+
try {
|
|
209
|
+
validateAddress(to, 'to');
|
|
210
|
+
return await client.writeContract({
|
|
211
|
+
address,
|
|
212
|
+
abi: PaymasterABI,
|
|
213
|
+
functionName: 'withdrawStake',
|
|
214
|
+
args: [to],
|
|
215
|
+
account: account,
|
|
216
|
+
chain: client.chain
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
throw AAStarError.fromViemError(error, 'withdrawStake');
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
// EntryPoint
|
|
224
|
+
async entryPoint() {
|
|
225
|
+
try {
|
|
226
|
+
return await client.readContract({
|
|
227
|
+
address,
|
|
228
|
+
abi: PaymasterABI,
|
|
229
|
+
functionName: 'entryPoint',
|
|
230
|
+
args: []
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
throw AAStarError.fromViemError(error, 'entryPoint');
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
// Ownership
|
|
238
|
+
async owner() {
|
|
239
|
+
try {
|
|
240
|
+
return await client.readContract({
|
|
241
|
+
address,
|
|
242
|
+
abi: PaymasterABI,
|
|
243
|
+
functionName: 'owner',
|
|
244
|
+
args: []
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
throw AAStarError.fromViemError(error, 'owner');
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
async transferOwnership({ newOwner, account }) {
|
|
252
|
+
try {
|
|
253
|
+
validateAddress(newOwner, 'newOwner');
|
|
254
|
+
return await client.writeContract({
|
|
255
|
+
address,
|
|
256
|
+
abi: PaymasterABI,
|
|
257
|
+
functionName: 'transferOwnership',
|
|
258
|
+
args: [newOwner],
|
|
259
|
+
account: account,
|
|
260
|
+
chain: client.chain
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
throw AAStarError.fromViemError(error, 'transferOwnership');
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
async renounceOwnership({ account }) {
|
|
268
|
+
try {
|
|
269
|
+
return await client.writeContract({
|
|
270
|
+
address,
|
|
271
|
+
abi: PaymasterABI,
|
|
272
|
+
functionName: 'renounceOwnership',
|
|
273
|
+
args: [],
|
|
274
|
+
account: account,
|
|
275
|
+
chain: client.chain
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
throw AAStarError.fromViemError(error, 'renounceOwnership');
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
// Initialization & Configuration
|
|
283
|
+
async initialize({ _entryPoint, _owner, _treasury, _ethUsdPriceFeed, _serviceFeeRate, _maxGasCostCap, _priceStalenessThreshold, account }) {
|
|
284
|
+
try {
|
|
285
|
+
validateAddress(_entryPoint, 'entryPoint');
|
|
286
|
+
validateAddress(_owner, 'owner');
|
|
287
|
+
validateAddress(_treasury, 'treasury');
|
|
288
|
+
validateAddress(_ethUsdPriceFeed, 'ethUsdPriceFeed');
|
|
289
|
+
validateAmount(_serviceFeeRate, 'serviceFeeRate');
|
|
290
|
+
validateAmount(_maxGasCostCap, 'maxGasCostCap');
|
|
291
|
+
validateAmount(_priceStalenessThreshold, 'priceStalenessThreshold');
|
|
292
|
+
return await client.writeContract({
|
|
293
|
+
address,
|
|
294
|
+
abi: PaymasterABI,
|
|
295
|
+
functionName: 'initialize',
|
|
296
|
+
args: [_entryPoint, _owner, _treasury, _ethUsdPriceFeed, _serviceFeeRate, _maxGasCostCap, _priceStalenessThreshold],
|
|
297
|
+
account: account,
|
|
298
|
+
chain: client.chain
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
throw AAStarError.fromViemError(error, 'initialize');
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
async setTreasury({ treasury, account }) {
|
|
306
|
+
try {
|
|
307
|
+
validateAddress(treasury, 'treasury');
|
|
308
|
+
return await client.writeContract({
|
|
309
|
+
address,
|
|
310
|
+
abi: PaymasterABI,
|
|
311
|
+
functionName: 'setTreasury',
|
|
312
|
+
args: [treasury],
|
|
313
|
+
account: account,
|
|
314
|
+
chain: client.chain
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
throw AAStarError.fromViemError(error, 'setTreasury');
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
async setServiceFeeRate({ _serviceFeeRate, account }) {
|
|
322
|
+
try {
|
|
323
|
+
validateAmount(_serviceFeeRate, 'serviceFeeRate');
|
|
324
|
+
return await client.writeContract({
|
|
325
|
+
address,
|
|
326
|
+
abi: PaymasterABI,
|
|
327
|
+
functionName: 'setServiceFeeRate',
|
|
328
|
+
args: [_serviceFeeRate],
|
|
329
|
+
account: account,
|
|
330
|
+
chain: client.chain
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
throw AAStarError.fromViemError(error, 'setServiceFeeRate');
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
async setMaxGasCostCap({ _maxGasCostCap, account }) {
|
|
338
|
+
try {
|
|
339
|
+
validateAmount(_maxGasCostCap, 'maxGasCostCap');
|
|
340
|
+
return await client.writeContract({
|
|
341
|
+
address,
|
|
342
|
+
abi: PaymasterABI,
|
|
343
|
+
functionName: 'setMaxGasCostCap',
|
|
344
|
+
args: [_maxGasCostCap],
|
|
345
|
+
account: account,
|
|
346
|
+
chain: client.chain
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
throw AAStarError.fromViemError(error, 'setMaxGasCostCap');
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
async setPriceStalenessThreshold({ _priceStalenessThreshold, account }) {
|
|
354
|
+
try {
|
|
355
|
+
validateAmount(_priceStalenessThreshold, 'priceStalenessThreshold');
|
|
356
|
+
return await client.writeContract({
|
|
357
|
+
address,
|
|
358
|
+
abi: PaymasterABI,
|
|
359
|
+
functionName: 'setPriceStalenessThreshold',
|
|
360
|
+
args: [_priceStalenessThreshold],
|
|
361
|
+
account: account,
|
|
362
|
+
chain: client.chain
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
catch (error) {
|
|
366
|
+
throw AAStarError.fromViemError(error, 'setPriceStalenessThreshold');
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
// Pause/Unpause
|
|
370
|
+
async pause({ account }) {
|
|
371
|
+
try {
|
|
372
|
+
return await client.writeContract({
|
|
373
|
+
address,
|
|
374
|
+
abi: PaymasterABI,
|
|
375
|
+
functionName: 'pause',
|
|
376
|
+
args: [],
|
|
377
|
+
account: account,
|
|
378
|
+
chain: client.chain
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
catch (error) {
|
|
382
|
+
throw AAStarError.fromViemError(error, 'pause');
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
async unpause({ account }) {
|
|
386
|
+
try {
|
|
387
|
+
return await client.writeContract({
|
|
388
|
+
address,
|
|
389
|
+
abi: PaymasterABI,
|
|
390
|
+
functionName: 'unpause',
|
|
391
|
+
args: [],
|
|
392
|
+
account: account,
|
|
393
|
+
chain: client.chain
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
catch (error) {
|
|
397
|
+
throw AAStarError.fromViemError(error, 'unpause');
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
async paused() {
|
|
401
|
+
try {
|
|
402
|
+
return await client.readContract({
|
|
403
|
+
address,
|
|
404
|
+
abi: PaymasterABI,
|
|
405
|
+
functionName: 'paused',
|
|
406
|
+
args: []
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
throw AAStarError.fromViemError(error, 'paused');
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
// Price Management
|
|
414
|
+
async cachedPrice() {
|
|
415
|
+
try {
|
|
416
|
+
const result = await client.readContract({
|
|
417
|
+
address,
|
|
418
|
+
abi: PaymasterABI,
|
|
419
|
+
functionName: 'cachedPrice',
|
|
420
|
+
args: []
|
|
421
|
+
});
|
|
422
|
+
if (Array.isArray(result)) {
|
|
423
|
+
return { price: result[0], updatedAt: Number(result[1]) };
|
|
424
|
+
}
|
|
425
|
+
return {
|
|
426
|
+
price: result.price,
|
|
427
|
+
updatedAt: Number(result.updatedAt)
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
throw AAStarError.fromViemError(error, 'cachedPrice');
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
async updatePrice({ account }) {
|
|
435
|
+
try {
|
|
436
|
+
return await client.writeContract({
|
|
437
|
+
address,
|
|
438
|
+
abi: PaymasterABI,
|
|
439
|
+
functionName: 'updatePrice',
|
|
440
|
+
args: [],
|
|
441
|
+
account: account,
|
|
442
|
+
chain: client.chain
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
throw AAStarError.fromViemError(error, 'updatePrice');
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
async getRealtimeTokenCost({ gasCost, token }) {
|
|
450
|
+
try {
|
|
451
|
+
validateAmount(gasCost, 'gasCost');
|
|
452
|
+
validateAddress(token, 'token');
|
|
453
|
+
return await client.readContract({
|
|
454
|
+
address,
|
|
455
|
+
abi: PaymasterABI,
|
|
456
|
+
functionName: 'getRealtimeTokenCost',
|
|
457
|
+
args: [gasCost, token]
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
catch (error) {
|
|
461
|
+
throw AAStarError.fromViemError(error, 'getRealtimeTokenCost');
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
async calculateCost({ gasCost, token, useRealtime }) {
|
|
465
|
+
try {
|
|
466
|
+
validateAmount(gasCost, 'gasCost');
|
|
467
|
+
validateAddress(token, 'token');
|
|
468
|
+
return await client.readContract({
|
|
469
|
+
address,
|
|
470
|
+
abi: PaymasterABI,
|
|
471
|
+
functionName: 'calculateCost',
|
|
472
|
+
args: [gasCost, token, useRealtime]
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
catch (error) {
|
|
476
|
+
throw AAStarError.fromViemError(error, 'calculateCost');
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
// Registry Integration
|
|
480
|
+
async isActiveInRegistry() {
|
|
481
|
+
try {
|
|
482
|
+
return await client.readContract({
|
|
483
|
+
address,
|
|
484
|
+
abi: PaymasterABI,
|
|
485
|
+
functionName: 'isActiveInRegistry',
|
|
486
|
+
args: []
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
throw AAStarError.fromViemError(error, 'isActiveInRegistry');
|
|
491
|
+
}
|
|
492
|
+
},
|
|
493
|
+
async isRegistrySet() {
|
|
494
|
+
try {
|
|
495
|
+
return await client.readContract({
|
|
496
|
+
address,
|
|
497
|
+
abi: PaymasterABI,
|
|
498
|
+
functionName: 'isRegistrySet',
|
|
499
|
+
args: []
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
catch (error) {
|
|
503
|
+
throw AAStarError.fromViemError(error, 'isRegistrySet');
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
async deactivateFromRegistry({ account }) {
|
|
507
|
+
try {
|
|
508
|
+
return await client.writeContract({
|
|
509
|
+
address,
|
|
510
|
+
abi: PaymasterABI,
|
|
511
|
+
functionName: 'deactivateFromRegistry',
|
|
512
|
+
args: [],
|
|
513
|
+
account: account,
|
|
514
|
+
chain: client.chain
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
catch (error) {
|
|
518
|
+
throw AAStarError.fromViemError(error, 'deactivateFromRegistry');
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
async registry() {
|
|
522
|
+
try {
|
|
523
|
+
return await client.readContract({
|
|
524
|
+
address,
|
|
525
|
+
abi: PaymasterABI,
|
|
526
|
+
functionName: 'registry',
|
|
527
|
+
args: []
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
catch (error) {
|
|
531
|
+
throw AAStarError.fromViemError(error, 'registry');
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
// Configuration Getters
|
|
535
|
+
async ethUsdPriceFeed() {
|
|
536
|
+
try {
|
|
537
|
+
return await client.readContract({
|
|
538
|
+
address,
|
|
539
|
+
abi: PaymasterABI,
|
|
540
|
+
functionName: 'ethUsdPriceFeed',
|
|
541
|
+
args: []
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
catch (error) {
|
|
545
|
+
throw AAStarError.fromViemError(error, 'ethUsdPriceFeed');
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
async serviceFeeRate() {
|
|
549
|
+
try {
|
|
550
|
+
return await client.readContract({
|
|
551
|
+
address,
|
|
552
|
+
abi: PaymasterABI,
|
|
553
|
+
functionName: 'serviceFeeRate',
|
|
554
|
+
args: []
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
catch (error) {
|
|
558
|
+
throw AAStarError.fromViemError(error, 'serviceFeeRate');
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
async maxGasCostCap() {
|
|
562
|
+
try {
|
|
563
|
+
return await client.readContract({
|
|
564
|
+
address,
|
|
565
|
+
abi: PaymasterABI,
|
|
566
|
+
functionName: 'maxGasCostCap',
|
|
567
|
+
args: []
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
catch (error) {
|
|
571
|
+
throw AAStarError.fromViemError(error, 'maxGasCostCap');
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
async priceStalenessThreshold() {
|
|
575
|
+
try {
|
|
576
|
+
return await client.readContract({
|
|
577
|
+
address,
|
|
578
|
+
abi: PaymasterABI,
|
|
579
|
+
functionName: 'priceStalenessThreshold',
|
|
580
|
+
args: []
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
catch (error) {
|
|
584
|
+
throw AAStarError.fromViemError(error, 'priceStalenessThreshold');
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
async treasury() {
|
|
588
|
+
try {
|
|
589
|
+
return await client.readContract({
|
|
590
|
+
address,
|
|
591
|
+
abi: PaymasterABI,
|
|
592
|
+
functionName: 'treasury',
|
|
593
|
+
args: []
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
catch (error) {
|
|
597
|
+
throw AAStarError.fromViemError(error, 'treasury');
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
async oracleDecimals() {
|
|
601
|
+
try {
|
|
602
|
+
return await client.readContract({
|
|
603
|
+
address,
|
|
604
|
+
abi: PaymasterABI,
|
|
605
|
+
functionName: 'oracleDecimals',
|
|
606
|
+
args: []
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
catch (error) {
|
|
610
|
+
throw AAStarError.fromViemError(error, 'oracleDecimals');
|
|
611
|
+
}
|
|
612
|
+
},
|
|
613
|
+
async tokenDecimals({ token }) {
|
|
614
|
+
try {
|
|
615
|
+
validateAddress(token, 'token');
|
|
616
|
+
return await client.readContract({
|
|
617
|
+
address,
|
|
618
|
+
abi: PaymasterABI,
|
|
619
|
+
functionName: 'tokenDecimals',
|
|
620
|
+
args: [token]
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
catch (error) {
|
|
624
|
+
throw AAStarError.fromViemError(error, 'tokenDecimals');
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
// Constants
|
|
628
|
+
async MAX_ETH_USD_PRICE() {
|
|
629
|
+
try {
|
|
630
|
+
return await client.readContract({
|
|
631
|
+
address,
|
|
632
|
+
abi: PaymasterABI,
|
|
633
|
+
functionName: 'MAX_ETH_USD_PRICE',
|
|
634
|
+
args: []
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
catch (error) {
|
|
638
|
+
throw AAStarError.fromViemError(error, 'MAX_ETH_USD_PRICE');
|
|
639
|
+
}
|
|
640
|
+
},
|
|
641
|
+
async MIN_ETH_USD_PRICE() {
|
|
642
|
+
try {
|
|
643
|
+
return await client.readContract({
|
|
644
|
+
address,
|
|
645
|
+
abi: PaymasterABI,
|
|
646
|
+
functionName: 'MIN_ETH_USD_PRICE',
|
|
647
|
+
args: []
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
catch (error) {
|
|
651
|
+
throw AAStarError.fromViemError(error, 'MIN_ETH_USD_PRICE');
|
|
652
|
+
}
|
|
653
|
+
},
|
|
654
|
+
async MAX_GAS_TOKENS() {
|
|
655
|
+
try {
|
|
656
|
+
return await client.readContract({
|
|
657
|
+
address,
|
|
658
|
+
abi: PaymasterABI,
|
|
659
|
+
functionName: 'MAX_GAS_TOKENS',
|
|
660
|
+
args: []
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
catch (error) {
|
|
664
|
+
throw AAStarError.fromViemError(error, 'MAX_GAS_TOKENS');
|
|
665
|
+
}
|
|
666
|
+
},
|
|
667
|
+
async MAX_SBTS() {
|
|
668
|
+
try {
|
|
669
|
+
return await client.readContract({
|
|
670
|
+
address,
|
|
671
|
+
abi: PaymasterABI,
|
|
672
|
+
functionName: 'MAX_SBTS',
|
|
673
|
+
args: []
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
catch (error) {
|
|
677
|
+
throw AAStarError.fromViemError(error, 'MAX_SBTS');
|
|
678
|
+
}
|
|
679
|
+
},
|
|
680
|
+
async MAX_SERVICE_FEE() {
|
|
681
|
+
try {
|
|
682
|
+
return await client.readContract({
|
|
683
|
+
address,
|
|
684
|
+
abi: PaymasterABI,
|
|
685
|
+
functionName: 'MAX_SERVICE_FEE',
|
|
686
|
+
args: []
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
catch (error) {
|
|
690
|
+
throw AAStarError.fromViemError(error, 'MAX_SERVICE_FEE');
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
async version() {
|
|
694
|
+
try {
|
|
695
|
+
return await client.readContract({
|
|
696
|
+
address,
|
|
697
|
+
abi: PaymasterABI,
|
|
698
|
+
functionName: 'version',
|
|
699
|
+
args: []
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
catch (error) {
|
|
703
|
+
throw AAStarError.fromViemError(error, 'version');
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
});
|