@aastar/sdk 0.17.7 → 0.20.1

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