@aastar/sdk 0.18.0 → 0.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +180 -21
  2. package/dist/UserClient-YUHCJJJL.js +6 -0
  3. package/dist/UserClient-YUHCJJJL.js.map +1 -0
  4. package/dist/account.d.ts +1 -0
  5. package/dist/account.js +6 -0
  6. package/dist/account.js.map +1 -0
  7. package/dist/admin.d.ts +1 -0
  8. package/dist/admin.js +6 -0
  9. package/dist/admin.js.map +1 -0
  10. package/dist/airaccount.d.ts +2 -0
  11. package/dist/airaccount.js +4501 -0
  12. package/dist/airaccount.js.map +1 -0
  13. package/dist/channel.d.ts +1 -0
  14. package/dist/channel.js +6 -0
  15. package/dist/channel.js.map +1 -0
  16. package/dist/chunk-4DVUM4MC.js +106 -0
  17. package/dist/chunk-4DVUM4MC.js.map +1 -0
  18. package/dist/chunk-4KRQXOTI.js +4421 -0
  19. package/dist/chunk-4KRQXOTI.js.map +1 -0
  20. package/dist/chunk-DI3E6PMI.js +426 -0
  21. package/dist/chunk-DI3E6PMI.js.map +1 -0
  22. package/dist/chunk-DSZ372PH.js +333 -0
  23. package/dist/chunk-DSZ372PH.js.map +1 -0
  24. package/dist/chunk-HVAB4TTT.js +116 -0
  25. package/dist/chunk-HVAB4TTT.js.map +1 -0
  26. package/dist/chunk-MPOMWT2J.js +1140 -0
  27. package/dist/chunk-MPOMWT2J.js.map +1 -0
  28. package/dist/chunk-NZGXB2C5.js +115 -0
  29. package/dist/chunk-NZGXB2C5.js.map +1 -0
  30. package/dist/chunk-O3Y7II3B.js +578 -0
  31. package/dist/chunk-O3Y7II3B.js.map +1 -0
  32. package/dist/chunk-OSPRJZ5T.js +113 -0
  33. package/dist/chunk-OSPRJZ5T.js.map +1 -0
  34. package/dist/chunk-PCLPYRTX.js +229 -0
  35. package/dist/chunk-PCLPYRTX.js.map +1 -0
  36. package/dist/chunk-PZ5AY32C.js +9 -0
  37. package/dist/chunk-PZ5AY32C.js.map +1 -0
  38. package/dist/chunk-XFI3AK32.js +416 -0
  39. package/dist/chunk-XFI3AK32.js.map +1 -0
  40. package/dist/chunk-YHM77LIP.js +432 -0
  41. package/dist/chunk-YHM77LIP.js.map +1 -0
  42. package/dist/chunk-ZSSNU3UF.js +42091 -0
  43. package/dist/chunk-ZSSNU3UF.js.map +1 -0
  44. package/dist/contract-addresses-JE3X6DFY.js +4 -0
  45. package/dist/contract-addresses-JE3X6DFY.js.map +1 -0
  46. package/dist/core.d.ts +13 -0
  47. package/dist/core.js +5 -0
  48. package/dist/core.js.map +1 -0
  49. package/dist/dapp.d.ts +1 -0
  50. package/dist/dapp.js +283 -0
  51. package/dist/dapp.js.map +1 -0
  52. package/dist/dist-GHTBO7CD.js +6 -0
  53. package/dist/dist-GHTBO7CD.js.map +1 -0
  54. package/dist/enduser.d.ts +1 -0
  55. package/dist/enduser.js +7 -0
  56. package/dist/enduser.js.map +1 -0
  57. package/dist/identity.d.ts +1 -0
  58. package/dist/identity.js +6 -0
  59. package/dist/identity.js.map +1 -0
  60. package/dist/index.d.ts +601 -13
  61. package/dist/index.js +1639 -28
  62. package/dist/index.js.map +1 -0
  63. package/dist/index.node-55LOPHNQ.js +5 -0
  64. package/dist/index.node-55LOPHNQ.js.map +1 -0
  65. package/dist/lib-VRTYVDUO.js +1861 -0
  66. package/dist/lib-VRTYVDUO.js.map +1 -0
  67. package/dist/operator.d.ts +1 -0
  68. package/dist/operator.js +6 -0
  69. package/dist/operator.js.map +1 -0
  70. package/dist/paymaster.d.ts +1 -0
  71. package/dist/paymaster.js +6 -0
  72. package/dist/paymaster.js.map +1 -0
  73. package/dist/tokens.d.ts +1 -0
  74. package/dist/tokens.js +6 -0
  75. package/dist/tokens.js.map +1 -0
  76. package/dist/x402.d.ts +1 -0
  77. package/dist/x402.js +6 -0
  78. package/dist/x402.js.map +1 -0
  79. package/package.json +87 -18
  80. package/dist/clients/ExperimentClient.d.ts +0 -34
  81. package/dist/clients/ExperimentClient.js +0 -58
  82. package/dist/clients/admin.d.ts +0 -11
  83. package/dist/clients/admin.js +0 -20
  84. package/dist/clients/community.d.ts +0 -40
  85. package/dist/clients/community.js +0 -300
  86. package/dist/clients/endUser.d.ts +0 -77
  87. package/dist/clients/endUser.js +0 -298
  88. package/dist/clients/operator.d.ts +0 -66
  89. package/dist/clients/operator.js +0 -209
  90. package/dist/errors/decoder.d.ts +0 -6
  91. package/dist/errors/decoder.js +0 -44
  92. package/dist/utils/errorHandler.d.ts +0 -40
  93. package/dist/utils/errorHandler.js +0 -114
  94. package/dist/utils/funding.d.ts +0 -115
  95. package/dist/utils/funding.js +0 -188
  96. package/dist/utils/keys.d.ts +0 -61
  97. package/dist/utils/keys.js +0 -130
  98. package/dist/utils/roleData.d.ts +0 -66
  99. package/dist/utils/roleData.js +0 -128
  100. package/dist/utils/testScenarios.d.ts +0 -33
  101. package/dist/utils/testScenarios.js +0 -85
  102. package/dist/utils/userOp.d.ts +0 -89
  103. package/dist/utils/userOp.js +0 -231
package/dist/index.d.ts CHANGED
@@ -1,23 +1,611 @@
1
+ import { RegistryActions, SBTActions, SuperPaymasterActions, PaymasterActions, StakingActions, DVTActions, XPNTsFactoryActions, AggregatorActions } from '@aastar/core';
1
2
  export * from '@aastar/core';
2
3
  export * from '@aastar/account';
3
4
  export * from '@aastar/paymaster';
4
5
  export * from '@aastar/identity';
5
6
  export * from '@aastar/tokens';
6
- export * from '@aastar/dapp';
7
7
  export * from '@aastar/x402';
8
8
  export * from '@aastar/channel';
9
- export * from './clients/endUser.js';
10
- export * from './clients/operator.js';
11
- export { createCommunityClient, type CommunityClient as LegacyCommunityClient } from './clients/community.js';
12
- export * from './clients/admin.js';
13
- export * from './clients/ExperimentClient.js';
9
+ import { Client, Transport, Chain, Account, PublicActions, WalletActions, Address, Hex, Hash, PublicClient } from 'viem';
14
10
  export * from '@aastar/enduser';
15
11
  export * from '@aastar/operator';
16
12
  export * from '@aastar/admin';
17
- export * as AirAccount from '@aastar/airaccount';
18
- export * from './utils/roleData.js';
19
- export * from './utils/keys.js';
20
- export * from './utils/funding.js';
21
- export * from './utils/userOp.js';
22
- export * from './utils/testScenarios.js';
23
- export * from './errors/decoder.js';
13
+ import * as airaccount from '@aastar/airaccount';
14
+ export { airaccount as AirAccount };
15
+
16
+ type EndUserClient = Client<Transport, Chain, Account | undefined> & PublicActions<Transport, Chain, Account | undefined> & WalletActions<Chain, Account | undefined> & RegistryActions & SBTActions & SuperPaymasterActions & PaymasterActions & {
17
+ /**
18
+ * High-level API: Onboard user to community with automatic funding
19
+ */
20
+ onboard: (args: {
21
+ community: Address;
22
+ roleId: Hex;
23
+ roleData: Hex;
24
+ }) => Promise<{
25
+ tx: Hash;
26
+ sbtId: bigint;
27
+ }>;
28
+ /**
29
+ * Orchestrates the user joining a community and activating gas credit flow:
30
+ * 1. Mint SBT for the community (Register ENDUSER role)
31
+ * 2. Verify Credit is active (Reputation check)
32
+ */
33
+ joinAndActivate: (args: {
34
+ community: Address;
35
+ roleId: Hex;
36
+ roleData?: Hex;
37
+ }) => Promise<{
38
+ tx: Hash;
39
+ sbtId: bigint;
40
+ initialCredit: bigint;
41
+ }>;
42
+ /**
43
+ * Executes a gasless transaction via SuperPaymaster.
44
+ */
45
+ executeGasless: (args: {
46
+ target: Address;
47
+ data: Hex;
48
+ value?: bigint;
49
+ operator: Address;
50
+ }) => Promise<Hash>;
51
+ /**
52
+ * Check if the user meets the requirements to join a community (stake, sbt, etc.)
53
+ */
54
+ checkJoinRequirements: (address?: Address) => Promise<{
55
+ hasEnoughGToken: boolean;
56
+ hasSBT: boolean;
57
+ missingRequirements: string[];
58
+ }>;
59
+ /**
60
+ * Predict or deploy a SimpleAccount (ERC-4337)
61
+ */
62
+ deploySmartAccount: (params: {
63
+ owner: Address;
64
+ salt?: bigint;
65
+ fundWithETH?: bigint;
66
+ }) => Promise<{
67
+ accountAddress: Address;
68
+ deployTxHash: Hash;
69
+ isDeployed: boolean;
70
+ }>;
71
+ /**
72
+ * Predict the address of a SimpleAccount without deploying
73
+ */
74
+ createSmartAccount: (params: {
75
+ owner: Address;
76
+ salt?: bigint;
77
+ }) => Promise<{
78
+ accountAddress: Address;
79
+ initCode: Hex;
80
+ isDeployed: boolean;
81
+ }>;
82
+ };
83
+ declare function createEndUserClient({ chain, transport, account, addresses }: {
84
+ chain: Chain;
85
+ transport: Transport;
86
+ account?: Account;
87
+ addresses?: {
88
+ [key: string]: Address;
89
+ };
90
+ }): EndUserClient;
91
+
92
+ type OperatorClient = Client<Transport, Chain, Account | undefined> & PublicActions<Transport, Chain, Account | undefined> & WalletActions<Chain, Account | undefined> & RegistryActions & SuperPaymasterActions & PaymasterActions & StakingActions & {
93
+ /**
94
+ * High-level API: Setup operator with automatic funding and onboarding
95
+ */
96
+ setup: (args: {
97
+ stakeAmount: bigint;
98
+ depositAmount: bigint;
99
+ roleId: Hex;
100
+ roleData?: Hex;
101
+ }) => Promise<{
102
+ txs: Hash[];
103
+ }>;
104
+ deployPaymasterV4: (args?: {
105
+ version?: string;
106
+ initData?: Hex;
107
+ }) => Promise<Hash>;
108
+ /**
109
+ * Orchestrates the full onboarding flow:
110
+ * 1. Approve GToken (Stake)
111
+ * 2. Register Role (Stake Lock)
112
+ * 3. Approve aPNTs (Deposit)
113
+ * 4. Deposit aPNTs (SuperPaymaster)
114
+ */
115
+ onboardOperator: (args: {
116
+ stakeAmount: bigint;
117
+ depositAmount: bigint;
118
+ roleId: Hex;
119
+ roleData?: Hex;
120
+ }) => Promise<Hash[]>;
121
+ /** @deprecated Use onboardOperator */
122
+ onboardToSuperPaymaster: (args: {
123
+ stakeAmount: bigint;
124
+ depositAmount: bigint;
125
+ roleId: Hex;
126
+ }) => Promise<Hash[]>;
127
+ configureOperator: (args: {
128
+ xPNTsToken: Address;
129
+ treasury: Address;
130
+ account?: Account | Address;
131
+ }) => Promise<Hash>;
132
+ getOperatorStatus: (accountAddress: Address) => Promise<{
133
+ type: 'super' | 'v4' | null;
134
+ superPaymaster: {
135
+ hasRole: boolean;
136
+ isConfigured: boolean;
137
+ balance: bigint;
138
+ /** Exchange rate read from xPNTsToken.exchangeRate() — not from operators() */
139
+ exchangeRate: bigint;
140
+ treasury: Address;
141
+ } | null;
142
+ paymasterV4: {
143
+ address: Address;
144
+ balance: bigint;
145
+ } | null;
146
+ }>;
147
+ };
148
+ declare function createOperatorClient({ chain, transport, account, addresses }: {
149
+ chain: Chain;
150
+ transport: Transport;
151
+ account?: Account;
152
+ addresses?: {
153
+ [key: string]: Address;
154
+ };
155
+ }): OperatorClient;
156
+
157
+ type CommunityClient = Client<Transport, Chain, Account | undefined> & PublicActions<Transport, Chain, Account | undefined> & WalletActions<Chain, Account | undefined> & RegistryActions & SBTActions & {
158
+ /**
159
+ * Query community registration status and token information
160
+ * Returns null if not registered, otherwise returns community details
161
+ */
162
+ getCommunityInfo: (accountAddress: Address) => Promise<{
163
+ hasRole: boolean;
164
+ tokenAddress: Address | null;
165
+ communityData: {
166
+ name: string;
167
+ ensName: string;
168
+ website: string;
169
+ description: string;
170
+ } | null;
171
+ }>;
172
+ /**
173
+ * High-level API to launch a community with automatic roleData generation
174
+ */
175
+ launch: (args: {
176
+ name: string;
177
+ tokenName: string;
178
+ tokenSymbol: string;
179
+ description?: string;
180
+ logoURI?: string;
181
+ website?: string;
182
+ }) => Promise<{
183
+ tokenAddress: Address;
184
+ txs: Hex[];
185
+ }>;
186
+ };
187
+ declare function createCommunityClient({ chain, transport, account, addresses }: {
188
+ chain: Chain;
189
+ transport: Transport;
190
+ account?: Account;
191
+ addresses?: {
192
+ [key: string]: Address;
193
+ };
194
+ }): CommunityClient;
195
+
196
+ type AdminClient = Client<Transport, Chain, Account | undefined> & PublicActions<Transport, Chain, Account | undefined> & WalletActions<Chain, Account | undefined> & RegistryActions & SuperPaymasterActions & PaymasterActions & StakingActions & SBTActions & DVTActions & XPNTsFactoryActions & AggregatorActions;
197
+ declare function createAdminClient({ chain, transport, account, addresses }: {
198
+ chain: Chain;
199
+ transport: Transport;
200
+ account?: Account;
201
+ addresses?: {
202
+ [key: string]: Address;
203
+ };
204
+ }): AdminClient;
205
+
206
+ interface ExperimentRecord {
207
+ id: string;
208
+ scenario: string;
209
+ group: 'EOA' | 'AA' | 'SuperPaymaster';
210
+ txHash: string;
211
+ gasUsed: bigint;
212
+ gasPrice: bigint;
213
+ costETH: string;
214
+ status: 'Success' | 'Failed';
215
+ timestamp: number;
216
+ meta?: any;
217
+ }
218
+ /**
219
+ * ExperimentClient: Business-layer tool for measuring and recording execution metrics
220
+ */
221
+ declare class ExperimentClient {
222
+ private records;
223
+ private scenarioId;
224
+ private group;
225
+ constructor(scenarioId: string, group: 'EOA' | 'AA' | 'SuperPaymaster');
226
+ /**
227
+ * Record a transaction result
228
+ */
229
+ recordTx(txHash: Hash, receipt: {
230
+ gasUsed: any;
231
+ effectiveGasPrice: any;
232
+ }, status: 'Success' | 'Failed', meta?: any): ExperimentRecord;
233
+ /**
234
+ * Measure an async task (transaction) automatically
235
+ */
236
+ measureTx(taskName: string, txPromise: Promise<Hash>, publicClient: any): Promise<Hash>;
237
+ getRecords(): ExperimentRecord[];
238
+ }
239
+
240
+ declare const RoleIds: {
241
+ readonly PAYMASTER_SUPER: `0x${string}`;
242
+ readonly DVT: `0x${string}`;
243
+ readonly PAYMASTER_AOA: `0x${string}`;
244
+ readonly KMS: `0x${string}`;
245
+ readonly COMMUNITY: `0x${string}`;
246
+ readonly ENDUSER: `0x${string}`;
247
+ readonly ANODE: `0x${string}`;
248
+ };
249
+ type RoleId = typeof RoleIds[keyof typeof RoleIds];
250
+ declare const RoleDataFactory: {
251
+ /**
252
+ * Data for SuperPaymaster Operator (Empty)
253
+ */
254
+ paymasterSuper: () => Hex;
255
+ /**
256
+ * Data for Generic DVT Role (Empty)
257
+ */
258
+ dvt: () => Hex;
259
+ /**
260
+ * Data for Community Registration (matches Registry.sol CommunityRoleData)
261
+ * NOTE: Solidity's abi.encode(struct) adds a 32-byte offset prefix (0x20)
262
+ * which is required for abi.decode(struct) to work correctly.
263
+ *
264
+ * @param params.name Community Name (defaults to 'TestCommunity')
265
+ * @param params.ensName ENS name (optional)
266
+ * @param params.website Website URL (optional)
267
+ * @param params.description Community description (optional)
268
+ * @param params.logoURI Logo URI string (optional)
269
+ * @param params.stakeAmount Stake amount (defaults to 0)
270
+ */
271
+ community: (params?: {
272
+ name?: string;
273
+ ensName?: string;
274
+ website?: string;
275
+ description?: string;
276
+ logoURI?: string;
277
+ stakeAmount?: bigint;
278
+ }) => Hex;
279
+ /**
280
+ * Data for EndUser (matches Registry.sol EndUserRoleData)
281
+ */
282
+ endUser: (params?: {
283
+ account?: Address;
284
+ community?: Address;
285
+ avatarURI?: string;
286
+ ensName?: string;
287
+ stakeAmount?: bigint;
288
+ }) => Hex;
289
+ decodeCommunity: (data: Hex) => {
290
+ name: any;
291
+ ensName: any;
292
+ website: any;
293
+ description: any;
294
+ logoURI: any;
295
+ stakeAmount: any;
296
+ };
297
+ decodeEndUser: (data: Hex) => {
298
+ account: any;
299
+ community: any;
300
+ avatarURI: any;
301
+ ensName: any;
302
+ stakeAmount: any;
303
+ };
304
+ };
305
+
306
+ /**
307
+ * 密钥对接口
308
+ */
309
+ interface KeyPair {
310
+ name: string;
311
+ privateKey: Hex;
312
+ address: Address;
313
+ }
314
+ /**
315
+ * 密钥管理器
316
+ * 提供密钥生成、存储、加载等工具函数
317
+ */
318
+ declare class KeyManager {
319
+ /**
320
+ * 生成单个密钥对
321
+ * @param name - 密钥名称(如 'Jason', 'Anni')
322
+ */
323
+ static generateKeyPair(name: string): KeyPair;
324
+ /**
325
+ * 批量生成密钥对
326
+ * @param names - 密钥名称数组
327
+ */
328
+ static generateKeyPairs(names: string[]): KeyPair[];
329
+ /**
330
+ * 生成指定数量的密钥对(自动命名为 Operator_1, Operator_2, ...)
331
+ * @param count - 数量
332
+ * @param prefix - 名称前缀(默认 'Operator')
333
+ */
334
+ static generateMultiple(count: number, prefix?: string): KeyPair[];
335
+ /**
336
+ * 保存密钥到 .env 文件
337
+ * @param filePath - 文件路径(绝对路径)
338
+ * @param keys - 密钥对数组
339
+ * @param overwrite - 是否覆盖已存在的文件(默认 false)
340
+ */
341
+ static saveToEnvFile(filePath: string, keys: KeyPair[], overwrite?: boolean): void;
342
+ /**
343
+ * 从 .env 文件加载密钥
344
+ * @param filePath - 文件路径(绝对路径)
345
+ * @returns 密钥对数组
346
+ */
347
+ static loadFromEnvFile(filePath: string): KeyPair[];
348
+ /**
349
+ * 保存密钥到 JSON 文件(包含地址信息)
350
+ * @param filePath - 文件路径(绝对路径)
351
+ * @param keys - 密钥对数组
352
+ * @param overwrite - 是否覆盖已存在的文件(默认 false)
353
+ */
354
+ static saveToJsonFile(filePath: string, keys: KeyPair[], overwrite?: boolean): void;
355
+ /**
356
+ * 从 JSON 文件加载密钥
357
+ * @param filePath - 文件路径(绝对路径)
358
+ */
359
+ static loadFromJsonFile(filePath: string): KeyPair[];
360
+ /**
361
+ * 打印密钥信息(隐藏私钥)
362
+ * @param keys - 密钥对数组
363
+ */
364
+ static printKeys(keys: KeyPair[], showPrivateKey?: boolean): void;
365
+ }
366
+
367
+ /**
368
+ * 资金管理参数
369
+ */
370
+ interface FundingParams {
371
+ /** RPC URL */
372
+ rpcUrl: string;
373
+ /** 链配置 */
374
+ chain: Chain;
375
+ /** 资金提供者私钥 */
376
+ supplierKey: Hex;
377
+ /** 目标地址 */
378
+ targetAddress: Address;
379
+ }
380
+ /**
381
+ * ETH 充值参数
382
+ */
383
+ interface FundETHParams extends FundingParams {
384
+ /** 充值金额(ETH,如 '0.1') */
385
+ amount: string;
386
+ }
387
+ /**
388
+ * ERC20 充值参数
389
+ */
390
+ interface FundTokenParams extends FundingParams {
391
+ /** Token 合约地址 */
392
+ tokenAddress: Address;
393
+ /** 充值金额(Token,如 '100') */
394
+ amount: string;
395
+ }
396
+ /**
397
+ * 智能充值参数
398
+ */
399
+ interface EnsureFundingParams extends FundingParams {
400
+ /** 最小 ETH 余额阈值 */
401
+ minETH?: string;
402
+ /** 目标 ETH 充值金额 */
403
+ targetETH?: string;
404
+ /** Token 配置(可选) */
405
+ token?: {
406
+ address: Address;
407
+ minBalance?: string;
408
+ targetAmount?: string;
409
+ };
410
+ }
411
+ /**
412
+ * 充值结果
413
+ */
414
+ interface FundingResult {
415
+ success: boolean;
416
+ txHash?: Hex;
417
+ error?: string;
418
+ }
419
+ /**
420
+ * 资金管理器
421
+ * 提供 ETH 和 ERC20 Token 的充值、验证等工具函数
422
+ */
423
+ declare class FundingManager {
424
+ /**
425
+ * 创建 PublicClient 和 WalletClient
426
+ */
427
+ private static createClients;
428
+ /**
429
+ * 充值 ETH 到目标地址
430
+ * @param params - 充值参数
431
+ * @returns 充值结果
432
+ */
433
+ static fundWithETH(params: FundETHParams): Promise<FundingResult>;
434
+ /**
435
+ * 充值 ERC20 Token 到目标地址
436
+ * @param params - 充值参数
437
+ * @returns 充值结果
438
+ */
439
+ static fundWithToken(params: FundTokenParams): Promise<FundingResult>;
440
+ /**
441
+ * 检查 ETH 余额
442
+ * @param params - 基础参数
443
+ * @returns ETH 余额(wei)
444
+ */
445
+ static getETHBalance(params: FundingParams): Promise<bigint>;
446
+ /**
447
+ * 检查 ERC20 Token 余额
448
+ * @param params - 基础参数
449
+ * @param tokenAddress - Token 合约地址
450
+ * @returns Token 余额
451
+ */
452
+ static getTokenBalance(params: FundingParams, tokenAddress: Address): Promise<bigint>;
453
+ /**
454
+ * 智能充值:检查余额,不足时自动充值
455
+ * @param params - 充值参数
456
+ * @returns 充值结果数组
457
+ */
458
+ static ensureFunding(params: EnsureFundingParams): Promise<FundingResult[]>;
459
+ /**
460
+ * 批量充值 ETH
461
+ * @param params - 基础参数
462
+ * @param targets - 目标地址和金额数组
463
+ * @returns 充值结果数组
464
+ */
465
+ static batchFundETH(params: Omit<FundingParams, 'targetAddress'>, targets: Array<{
466
+ address: Address;
467
+ amount: string;
468
+ }>): Promise<FundingResult[]>;
469
+ /**
470
+ * 批量充值 Token
471
+ * @param params - 基础参数
472
+ * @param tokenAddress - Token 合约地址
473
+ * @param targets - 目标地址和金额数组
474
+ * @returns 充值结果数组
475
+ */
476
+ static batchFundToken(params: Omit<FundingParams, 'targetAddress'>, tokenAddress: Address, targets: Array<{
477
+ address: Address;
478
+ amount: string;
479
+ }>): Promise<FundingResult[]>;
480
+ }
481
+
482
+ /**
483
+ * ERC-4337 v0.7 Packed UserOperation structure.
484
+ */
485
+ interface PackedUserOperation {
486
+ sender: Address;
487
+ nonce: Hex;
488
+ initCode: Hex;
489
+ callData: Hex;
490
+ accountGasLimits: Hex;
491
+ preVerificationGas: Hex;
492
+ gasFees: Hex;
493
+ paymasterAndData: Hex;
494
+ signature: Hex;
495
+ }
496
+ interface UserOpGasParams {
497
+ verificationGasLimit: bigint;
498
+ callGasLimit: bigint;
499
+ preVerificationGas: bigint;
500
+ maxPriorityFeePerGas: bigint;
501
+ maxFeePerGas: bigint;
502
+ }
503
+ interface PaymasterGasParams {
504
+ paymasterGasLimit: bigint;
505
+ paymasterPostOpGasLimit: bigint;
506
+ }
507
+ declare class UserOperationBuilder {
508
+ /**
509
+ * Packs verificationGasLimit and callGasLimit into a bytes32 Hex string.
510
+ */
511
+ static packAccountGasLimits(verificationGasLimit: bigint, callGasLimit: bigint): Hex;
512
+ /**
513
+ * Packs maxPriorityFeePerGas and maxFeePerGas into a bytes32 Hex string.
514
+ */
515
+ static packGasFees(maxPriorityFeePerGas: bigint, maxFeePerGas: bigint): Hex;
516
+ static estimatePreVerificationGasV07(userOp: {
517
+ sender: Address;
518
+ nonce: bigint | Hex | number | string;
519
+ initCode: Hex;
520
+ callData: Hex;
521
+ accountGasLimits: Hex;
522
+ preVerificationGas: bigint | Hex | number | string;
523
+ gasFees: Hex;
524
+ paymasterAndData: Hex;
525
+ signature: Hex;
526
+ }): bigint;
527
+ /**
528
+ * Packs Paymaster parameters into the v0.7 paymasterAndData format.
529
+ */
530
+ static packPaymasterAndData(paymaster: Address, paymasterGasLimit: bigint, paymasterPostOpGasLimit: bigint, paymasterData?: Hex): Hex;
531
+ /**
532
+ * Pack PaymasterV4 Deposit-Only paymasterAndData
533
+ *
534
+ * v0.7 EntryPoint packs: [paymaster(20)][verificationGas(16)][postOpGas(16)][paymasterData]
535
+ * Contract extracts token at offset 52 = paymasterData[0:20]
536
+ *
537
+ * So paymasterData format must be: [token(20)][validUntil(6)][validAfter(6)]
538
+ *
539
+ * @param paymaster - Paymaster address (20 bytes)
540
+ * @param paymentToken - ERC20 token address (20 bytes, FIRST in paymasterData!)
541
+ * @param validUntil - Validity end timestamp (6 bytes)
542
+ * @param validAfter - Validity start timestamp (6 bytes)
543
+ */
544
+ static packPaymasterV4DepositData(paymaster: Address, paymasterVerificationGasLimit: bigint, paymasterPostOpGasLimit: bigint, paymentToken: Address, validUntil: bigint, validAfter: bigint): Hex;
545
+ /**
546
+ * Computes the UserOperation hash for signing.
547
+ */
548
+ static getUserOpHash({ userOp, entryPoint, chainId, publicClient }: {
549
+ userOp: PackedUserOperation;
550
+ entryPoint: Address;
551
+ chainId: number;
552
+ publicClient: PublicClient;
553
+ }): Promise<Hex>;
554
+ /**
555
+ * Formats a PackedUserOperation into a JSON-RPC compatible object with hex-encoded strings.
556
+ */
557
+ static jsonifyUserOp(userOp: any): any;
558
+ /**
559
+ * Converts a PackedUserOperation to the Alchemy-specific v0.7 JSON format.
560
+ * @param userOp - The packed UserOperation
561
+ * @param options - Optional configuration
562
+ * @param options.paymasterVerificationGasLimit - Gas limit for paymaster verification (default: 200000)
563
+ * @param options.paymasterPostOpGasLimit - Gas limit for paymaster postOp (default: 200000)
564
+ */
565
+ static toAlchemyUserOperation(userOp: any, options?: {
566
+ paymasterVerificationGasLimit?: bigint;
567
+ paymasterPostOpGasLimit?: bigint;
568
+ }): any;
569
+ }
570
+
571
+ declare enum UserOpScenarioType {
572
+ NATIVE = "NATIVE",// Plain ERC-4337, user pays ETH
573
+ GASLESS_V4 = "GASLESS_V4",// Standard PaymasterV4
574
+ SUPER_BPNT = "SUPER_BPNT",// SuperPaymaster with bPNT internal payment
575
+ SUPER_CPNT = "SUPER_CPNT",// SuperPaymaster with cPNT internal payment
576
+ SUPER_CUSTOM = "SUPER_CUSTOM"
577
+ }
578
+ interface ScenarioParams {
579
+ sender: Address;
580
+ ownerAccount: any;
581
+ recipient: Address;
582
+ tokenAddress: Address;
583
+ amount: bigint;
584
+ entryPoint: Address;
585
+ chainId: number;
586
+ publicClient: PublicClient;
587
+ paymaster?: Address;
588
+ operator?: Address;
589
+ paymasterGasLimit?: bigint;
590
+ paymasterPostOpGasLimit?: bigint;
591
+ nonceKey?: bigint;
592
+ gasToken?: Address;
593
+ }
594
+ declare class UserOpScenarioBuilder {
595
+ /**
596
+ * Builds a signed PackedUserOperation for a token transfer based on the specified scenario.
597
+ */
598
+ static buildTransferScenario(type: UserOpScenarioType, params: ScenarioParams): Promise<{
599
+ userOp: any;
600
+ opHash: Hash;
601
+ }>;
602
+ }
603
+
604
+ declare const CustomErrors: {
605
+ readonly RoleNotConfigured: "RoleNotConfigured(bytes32,bool)";
606
+ readonly RoleAlreadyGranted: "RoleAlreadyGranted(bytes32,address)";
607
+ readonly InsufficientStake: "InsufficientStake(uint256,uint256)";
608
+ };
609
+ declare function decodeContractError(error: any): string | null;
610
+
611
+ export { type AdminClient, CustomErrors, type EndUserClient, type EnsureFundingParams, ExperimentClient, type ExperimentRecord, type FundETHParams, type FundTokenParams, FundingManager, type FundingParams, type FundingResult, KeyManager, type KeyPair, type CommunityClient as LegacyCommunityClient, type OperatorClient, type PackedUserOperation, type PaymasterGasParams, RoleDataFactory, type RoleId, RoleIds, type ScenarioParams, type UserOpGasParams, UserOpScenarioBuilder, UserOpScenarioType, UserOperationBuilder, createAdminClient, createCommunityClient, createEndUserClient, createOperatorClient, decodeContractError };