@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
@@ -0,0 +1,426 @@
1
+ import { BaseClient, entryPointActions, accountActions, sbtActions, tokenActions, stakingActions, registryActions } from './chunk-ZSSNU3UF.js';
2
+ import { encodeFunctionData } from 'viem';
3
+ import { bundlerActions } from 'viem/account-abstraction';
4
+
5
+ var UserClient = class extends BaseClient {
6
+ accountAddress;
7
+ sbtAddress;
8
+ entryPointAddress;
9
+ gTokenStakingAddress;
10
+ registryAddress;
11
+ gTokenAddress;
12
+ bundlerClient;
13
+ constructor(config) {
14
+ super(config);
15
+ this.bundlerClient = config.bundlerClient;
16
+ this.accountAddress = config.accountAddress;
17
+ this.sbtAddress = config.sbtAddress;
18
+ this.entryPointAddress = config.entryPointAddress;
19
+ this.gTokenStakingAddress = config.gTokenStakingAddress;
20
+ this.registryAddress = config.registryAddress;
21
+ this.gTokenAddress = config.gTokenAddress;
22
+ }
23
+ /**
24
+ * Deploy a new Smart Account (Supports multiple factory types)
25
+ * Static helper to facilitate onboarding before instantiating the UserClient.
26
+ *
27
+ * @param client - WalletClient to sign the deployment transaction
28
+ * @param params - Deployment parameters
29
+ * @returns Object containing the deployed account address and transaction hash
30
+ */
31
+ static async deployAccount(client, params) {
32
+ const { accountFactoryActions, SimpleAccountFactoryABI } = await import('./index.node-55LOPHNQ.js');
33
+ let abi = params.customAbi || (SimpleAccountFactoryABI?.abi || SimpleAccountFactoryABI);
34
+ const factoryAddr = params.factoryAddress || "0x9406Cc6185a346906296840746125a0E44976454";
35
+ const salt = params.salt || 0n;
36
+ const readClient = params.publicClient || client;
37
+ const factoryRead = accountFactoryActions(factoryAddr, abi)(readClient);
38
+ const factoryWrite = accountFactoryActions(factoryAddr, abi)(client);
39
+ const accountAddress = await factoryRead.getAddress({
40
+ owner: params.owner,
41
+ salt
42
+ });
43
+ try {
44
+ const hash = await factoryWrite.createAccount({
45
+ owner: params.owner,
46
+ salt,
47
+ account: client.account
48
+ });
49
+ return { accountAddress, hash };
50
+ } catch (error) {
51
+ const messageParts = [
52
+ error?.shortMessage,
53
+ error?.message,
54
+ error?.details,
55
+ error?.cause?.shortMessage,
56
+ error?.cause?.message,
57
+ error?.cause?.details,
58
+ error?.cause?.cause?.shortMessage,
59
+ error?.cause?.cause?.message
60
+ ].filter(Boolean);
61
+ const message = messageParts.join(" ");
62
+ if (message.includes("gas required exceeds allowance") || message.includes("intrinsic gas too low")) {
63
+ const data = encodeFunctionData({
64
+ abi,
65
+ functionName: "createAccount",
66
+ args: [params.owner, salt]
67
+ });
68
+ const hash = await client.sendTransaction({
69
+ to: factoryAddr,
70
+ data,
71
+ gas: 2000000n,
72
+ account: client.account
73
+ });
74
+ return { accountAddress, hash };
75
+ }
76
+ throw error;
77
+ }
78
+ }
79
+ // ========================================
80
+ // 1. 账户基本操作 (基于 L1 simpleAccountActions)
81
+ // ========================================
82
+ /**
83
+ * Get the nonce of the account from EntryPoint (more reliable for 4337)
84
+ */
85
+ async getNonce(key = 0n) {
86
+ try {
87
+ if (!this.entryPointAddress) {
88
+ throw new Error("EntryPoint address required for this client");
89
+ }
90
+ const entryPoint = entryPointActions(this.entryPointAddress);
91
+ return await entryPoint(this.getStartPublicClient()).getNonce({
92
+ sender: this.accountAddress,
93
+ key
94
+ });
95
+ } catch (error) {
96
+ throw error;
97
+ }
98
+ }
99
+ /**
100
+ * Get the owner of the AA account
101
+ */
102
+ async getOwner() {
103
+ try {
104
+ const account = accountActions(this.accountAddress);
105
+ return await account(this.getStartPublicClient()).owner();
106
+ } catch (error) {
107
+ throw error;
108
+ }
109
+ }
110
+ /**
111
+ * Execute a transaction from the AA account
112
+ */
113
+ async execute(target, value, data, options) {
114
+ try {
115
+ const account = accountActions(this.accountAddress);
116
+ return await account(this.client).execute({
117
+ dest: target,
118
+ value,
119
+ func: data,
120
+ account: options?.account
121
+ });
122
+ } catch (error) {
123
+ throw error;
124
+ }
125
+ }
126
+ /**
127
+ * Execute a batch of transactions
128
+ */
129
+ async executeBatch(targets, values, datas, options) {
130
+ try {
131
+ const account = accountActions(this.accountAddress);
132
+ return await account(this.client).executeBatch({
133
+ dest: targets,
134
+ value: values,
135
+ func: datas,
136
+ account: options?.account
137
+ });
138
+ } catch (error) {
139
+ throw error;
140
+ }
141
+ }
142
+ // ========================================
143
+ // identity 与 SBT (基于 L1 sbtActions)
144
+ // ========================================
145
+ /**
146
+ * Get user's SBT balance
147
+ */
148
+ async getSBTBalance() {
149
+ try {
150
+ if (!this.sbtAddress)
151
+ throw new Error("SBT address required for this client");
152
+ const sbt = sbtActions(this.sbtAddress);
153
+ return await sbt(this.getStartPublicClient()).balanceOf({
154
+ owner: this.accountAddress
155
+ });
156
+ } catch (error) {
157
+ throw error;
158
+ }
159
+ }
160
+ async mintSBT(roleId, options) {
161
+ try {
162
+ if (!this.sbtAddress)
163
+ throw new Error("SBT address required for this client");
164
+ const { encodeFunctionData: encodeFunctionData2 } = await import('viem');
165
+ const data = encodeFunctionData2({
166
+ abi: [{ name: "mintForRole", type: "function", inputs: [{ name: "user", type: "address" }, { name: "roleId", type: "bytes32" }, { name: "roleData", type: "bytes" }], outputs: [{ type: "uint256" }] }],
167
+ functionName: "mintForRole",
168
+ args: [this.accountAddress, roleId, "0x"]
169
+ });
170
+ return await this.execute(this.sbtAddress, 0n, data, options);
171
+ } catch (error) {
172
+ throw error;
173
+ }
174
+ }
175
+ // ========================================
176
+ // 3. 资产管理 (基于 L1 tokenActions)
177
+ // ========================================
178
+ async transferToken(token, to, amount, options) {
179
+ try {
180
+ const { encodeFunctionData: encodeFunctionData2 } = await import('viem');
181
+ const data = encodeFunctionData2({
182
+ abi: [{ name: "transfer", type: "function", inputs: [{ name: "to", type: "address" }, { name: "amount", type: "uint256" }], outputs: [{ type: "bool" }] }],
183
+ functionName: "transfer",
184
+ args: [to, amount]
185
+ });
186
+ return await this.execute(token, 0n, data, options);
187
+ } catch (error) {
188
+ throw error;
189
+ }
190
+ }
191
+ /**
192
+ * Get Token Balance
193
+ */
194
+ async getTokenBalance(token) {
195
+ try {
196
+ const tokens = tokenActions()(this.getStartPublicClient());
197
+ return await tokens.balanceOf({
198
+ token,
199
+ account: this.accountAddress
200
+ });
201
+ } catch (error) {
202
+ throw error;
203
+ }
204
+ }
205
+ // ========================================
206
+ // 4. 委托与质押 (Delegation & Staking)
207
+ // ========================================
208
+ async stakeForRole(roleId, amount, options) {
209
+ try {
210
+ if (!this.gTokenStakingAddress)
211
+ throw new Error("GTokenStaking address required for this client");
212
+ const { encodeFunctionData: encodeFunctionData2 } = await import('viem');
213
+ const data = encodeFunctionData2({
214
+ abi: [{ name: "lockStake", type: "function", inputs: [{ name: "user", type: "address" }, { name: "roleId", type: "bytes32" }, { name: "stakeAmount", type: "uint256" }, { name: "entryBurn", type: "uint256" }, { name: "payer", type: "address" }], outputs: [] }],
215
+ functionName: "lockStake",
216
+ args: [this.accountAddress, roleId, amount, 0n, this.accountAddress]
217
+ });
218
+ return await this.execute(this.gTokenStakingAddress, 0n, data, options);
219
+ } catch (error) {
220
+ throw error;
221
+ }
222
+ }
223
+ async unstakeFromRole(roleId, options) {
224
+ try {
225
+ if (!this.gTokenStakingAddress)
226
+ throw new Error("GTokenStaking address required for this client");
227
+ const { encodeFunctionData: encodeFunctionData2 } = await import('viem');
228
+ const data = encodeFunctionData2({
229
+ abi: [{ name: "unlockAndTransfer", type: "function", inputs: [{ name: "user", type: "address" }, { name: "roleId", type: "bytes32" }], outputs: [{ name: "netAmount", type: "uint256" }] }],
230
+ functionName: "unlockAndTransfer",
231
+ args: [this.accountAddress, roleId]
232
+ });
233
+ return await this.execute(this.gTokenStakingAddress, 0n, data, options);
234
+ } catch (error) {
235
+ throw error;
236
+ }
237
+ }
238
+ /**
239
+ * Get staked balance for a specific role
240
+ */
241
+ async getStakedBalance(roleId) {
242
+ try {
243
+ if (!this.gTokenStakingAddress)
244
+ throw new Error("GTokenStaking address required for this client");
245
+ const staking = stakingActions(this.gTokenStakingAddress);
246
+ return await staking(this.getStartPublicClient()).getLockedStake({
247
+ user: this.accountAddress,
248
+ roleId
249
+ });
250
+ } catch (error) {
251
+ throw error;
252
+ }
253
+ }
254
+ // ========================================
255
+ // 5. 生命周期管理 (Lifecycle)
256
+ // ========================================
257
+ async exitRole(roleId, options) {
258
+ try {
259
+ if (!this.registryAddress)
260
+ throw new Error("Registry address required for this client");
261
+ const { encodeFunctionData: encodeFunctionData2 } = await import('viem');
262
+ const data = encodeFunctionData2({
263
+ abi: [{ name: "exitRole", type: "function", inputs: [{ name: "roleId", type: "bytes32" }], outputs: [] }],
264
+ functionName: "exitRole",
265
+ args: [roleId]
266
+ });
267
+ return await this.execute(this.registryAddress, 0n, data, options);
268
+ } catch (error) {
269
+ throw error;
270
+ }
271
+ }
272
+ async leaveCommunity(community, options) {
273
+ try {
274
+ if (!this.sbtAddress)
275
+ throw new Error("SBT address required for this client");
276
+ const { encodeFunctionData: encodeFunctionData2 } = await import('viem');
277
+ const data = encodeFunctionData2({
278
+ abi: [{ name: "leaveCommunity", type: "function", inputs: [{ name: "comm", type: "address" }], outputs: [] }],
279
+ functionName: "leaveCommunity",
280
+ args: [community]
281
+ });
282
+ return await this.execute(this.sbtAddress, 0n, data, options);
283
+ } catch (error) {
284
+ throw error;
285
+ }
286
+ }
287
+ /**
288
+ * Register as EndUser (One-click: Approve + Register)
289
+ * Handles GToken approval to Staking contract and Role registration.
290
+ */
291
+ async registerAsEndUser(communityAddress, stakeAmount, options) {
292
+ try {
293
+ if (!this.registryAddress)
294
+ throw new Error("Registry address required for this client");
295
+ if (!this.gTokenStakingAddress)
296
+ throw new Error("GTokenStaking address required for this client");
297
+ if (!this.gTokenAddress)
298
+ throw new Error("GToken address required for this client");
299
+ const { encodeAbiParameters, keccak256, toBytes, parseEther } = await import('viem');
300
+ const ROLE_ENDUSER = keccak256(toBytes("ENDUSER"));
301
+ const registry = registryActions(this.registryAddress);
302
+ const publicClient = this.getStartPublicClient();
303
+ const tokens = tokenActions()(publicClient);
304
+ const allowance = await tokens.allowance({
305
+ token: this.gTokenAddress,
306
+ owner: this.accountAddress,
307
+ spender: this.gTokenStakingAddress
308
+ });
309
+ console.log(` \u{1F50D} Debug Allowance: Account=${this.accountAddress}, Allowance=${allowance}, Needed=${stakeAmount}`);
310
+ const txs = [];
311
+ if (allowance < stakeAmount) {
312
+ const approveData = encodeFunctionData({
313
+ abi: [{ name: "approve", type: "function", inputs: [{ type: "address" }, { type: "uint256" }], outputs: [{ type: "bool" }], stateMutability: "nonpayable" }],
314
+ functionName: "approve",
315
+ args: [this.gTokenStakingAddress, parseEther("1000")]
316
+ });
317
+ txs.push({ target: this.gTokenAddress, value: 0n, data: approveData });
318
+ }
319
+ const roleData = encodeAbiParameters([
320
+ { type: "address", name: "account" },
321
+ { type: "address", name: "community" },
322
+ { type: "string", name: "avatarURI" },
323
+ { type: "string", name: "ensName" },
324
+ { type: "uint256", name: "stakeAmount" }
325
+ ], [
326
+ this.accountAddress,
327
+ communityAddress,
328
+ "",
329
+ "",
330
+ stakeAmount
331
+ ]);
332
+ const registerData = encodeFunctionData({
333
+ abi: [{ name: "registerRoleSelf", type: "function", inputs: [{ type: "bytes32" }, { type: "bytes" }], outputs: [{ type: "uint256" }], stateMutability: "nonpayable" }],
334
+ functionName: "registerRoleSelf",
335
+ args: [ROLE_ENDUSER, roleData]
336
+ });
337
+ txs.push({ target: this.registryAddress, value: 0n, data: registerData });
338
+ console.log(` \u{1F50D} Debug Onboard: Community=${communityAddress}, AA=${this.accountAddress}, Stake=${stakeAmount}`);
339
+ console.log(` \u{1F50D} Debug Batch: Txs=${txs.length}, Targets=${txs.map((t) => t.target)}`);
340
+ const hashes = [];
341
+ for (const tx of txs) {
342
+ const h = await this.execute(tx.target, tx.value, tx.data, options);
343
+ hashes.push(h);
344
+ await this.getStartPublicClient().waitForTransactionReceipt({ hash: h });
345
+ }
346
+ return hashes[hashes.length - 1];
347
+ } catch (error) {
348
+ throw error;
349
+ }
350
+ }
351
+ // ========================================
352
+ // 6. Gasless Execution (Advanced)
353
+ // ========================================
354
+ /**
355
+ * Execute a transaction with Gasless Sponsorship
356
+ */
357
+ async executeGasless(params, options) {
358
+ try {
359
+ const client = this.bundlerClient ? this.bundlerClient.extend(bundlerActions) : this.client.extend(bundlerActions);
360
+ const ep = this.requireEntryPoint();
361
+ const callData = encodeFunctionData({
362
+ abi: [{ name: "execute", type: "function", inputs: [{ name: "dest", type: "address" }, { name: "value", type: "uint256" }, { name: "func", type: "bytes" }], outputs: [] }],
363
+ functionName: "execute",
364
+ args: [params.target, params.value, params.data]
365
+ });
366
+ const { PaymasterClient: SDKPaymasterClient } = await import('./dist-GHTBO7CD.js');
367
+ let verificationGasLimit;
368
+ let paymasterVerificationGasLimit;
369
+ let paymasterPostOpGasLimit;
370
+ let autoEstimate = true;
371
+ if (params.paymasterType === "Super") {
372
+ const { tuneGasLimit } = await import('./dist-GHTBO7CD.js');
373
+ const est = await SDKPaymasterClient.estimateUserOperationGas(
374
+ this.client,
375
+ this.client,
376
+ this.accountAddress,
377
+ ep,
378
+ params.paymaster,
379
+ params.target,
380
+ // placeholder
381
+ this.bundlerClient?.transport?.url || this.client.transport.url || "",
382
+ callData,
383
+ {
384
+ operator: params.operator,
385
+ factory: void 0,
386
+ factoryData: void 0
387
+ }
388
+ );
389
+ const bundlerEstimate = est.paymasterVerificationGasLimit || 100000n;
390
+ paymasterVerificationGasLimit = tuneGasLimit(bundlerEstimate, 60000n, 0.45);
391
+ const SAFETY_PAD = 80000n;
392
+ verificationGasLimit = est.verificationGasLimit + SAFETY_PAD;
393
+ const _postOpBase = est.paymasterPostOpGasLimit + 100000n;
394
+ paymasterPostOpGasLimit = _postOpBase > 200000n ? _postOpBase : 200000n;
395
+ autoEstimate = false;
396
+ }
397
+ const txHash = await SDKPaymasterClient.submitGaslessUserOperation(
398
+ this.client,
399
+ this.client,
400
+ // WalletClient acts as signer
401
+ this.accountAddress,
402
+ ep,
403
+ params.paymaster,
404
+ params.target,
405
+ // placeholder for token if V4
406
+ this.bundlerClient?.transport?.url || this.client.transport.url || "",
407
+ callData,
408
+ {
409
+ operator: params.operator,
410
+ autoEstimate,
411
+ verificationGasLimit,
412
+ paymasterVerificationGasLimit,
413
+ paymasterPostOpGasLimit
414
+ }
415
+ );
416
+ return txHash;
417
+ } catch (error) {
418
+ console.error(" \u274C executeGasless Error:", error.message);
419
+ throw error;
420
+ }
421
+ }
422
+ };
423
+
424
+ export { UserClient };
425
+ //# sourceMappingURL=chunk-DI3E6PMI.js.map
426
+ //# sourceMappingURL=chunk-DI3E6PMI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../enduser/dist/UserClient.js"],"names":["encodeFunctionData"],"mappings":";;;;AAIO,IAAM,UAAA,GAAN,cAAyB,UAAA,CAAW;AAAA,EACvC,cAAA;AAAA,EACA,UAAA;AAAA,EACA,iBAAA;AAAA,EACA,oBAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AAA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AAA;AAAA;AAAA,QAClD,KAAK,aAAA,EAAe,SAAA,EAAW,OAAO,IAAA,CAAK,MAAA,CAAO,UAAU,GAAA,IAAO,EAAA;AAAA,QAAI,QAAA;AAAA,QAAU;AAAA,UAC7E,UAAU,MAAA,CAAO,QAAA;AAAA,UACjB,YAAA;AAAA,UACA,oBAAA;AAAA,UACA,6BAAA;AAAA,UACA;AAAA;AACJ,OAAC;AACD,MAAA,OAAO,MAAA;AAAA,IACX,SACO,KAAA,EAAO;AACV,MAAA,OAAA,CAAQ,KAAA,CAAM,iCAAA,EAA8B,KAAA,CAAM,OAAO,CAAA;AACzD,MAAA,MAAM,KAAA;AAAA,IACV;AAAA,EACJ;AACJ","file":"chunk-DI3E6PMI.js","sourcesContent":["import { encodeFunctionData } from 'viem';\nimport { BaseClient } from '@aastar/core';\nimport { accountActions, sbtActions, tokenActions, entryPointActions, stakingActions, registryActions } from '@aastar/core';\nimport { bundlerActions } from 'viem/account-abstraction';\nexport class UserClient extends BaseClient {\n accountAddress;\n sbtAddress;\n entryPointAddress;\n gTokenStakingAddress;\n registryAddress;\n gTokenAddress;\n bundlerClient;\n constructor(config) {\n super(config);\n this.bundlerClient = config.bundlerClient;\n this.accountAddress = config.accountAddress;\n this.sbtAddress = config.sbtAddress;\n this.entryPointAddress = config.entryPointAddress;\n this.gTokenStakingAddress = config.gTokenStakingAddress;\n this.registryAddress = config.registryAddress;\n this.gTokenAddress = config.gTokenAddress;\n }\n /**\n * Deploy a new Smart Account (Supports multiple factory types)\n * Static helper to facilitate onboarding before instantiating the UserClient.\n *\n * @param client - WalletClient to sign the deployment transaction\n * @param params - Deployment parameters\n * @returns Object containing the deployed account address and transaction hash\n */\n static async deployAccount(client, params) {\n const { accountFactoryActions, SimpleAccountFactoryABI } = await import('@aastar/core');\n // 1. Determine Factory ABI (Ensure it's the raw ABI array)\n let abi = params.customAbi || (SimpleAccountFactoryABI?.abi || SimpleAccountFactoryABI);\n // In the future, we can add more built-in ABIs here based on accountType\n // if (params.accountType === 'kernel') abi = KernelFactoryABI;\n const factoryAddr = params.factoryAddress || '0x9406Cc6185a346906296840746125a0E44976454'; // Default v0.7 Factory\n const salt = params.salt || 0n;\n // Use publicClient for reading if provided, otherwise fallback to client (which might be a Full Client)\n const readClient = params.publicClient || client;\n // Use the generic actions with the selected ABI\n const factoryRead = accountFactoryActions(factoryAddr, abi)(readClient);\n const factoryWrite = accountFactoryActions(factoryAddr, abi)(client);\n // 1. Predict Address\n const accountAddress = await factoryRead.getAddress({\n owner: params.owner,\n salt\n });\n // 2. Deploy\n try {\n const hash = await factoryWrite.createAccount({\n owner: params.owner,\n salt,\n account: client.account\n });\n return { accountAddress, hash };\n }\n catch (error) {\n const messageParts = [\n error?.shortMessage,\n error?.message,\n error?.details,\n error?.cause?.shortMessage,\n error?.cause?.message,\n error?.cause?.details,\n error?.cause?.cause?.shortMessage,\n error?.cause?.cause?.message\n ].filter(Boolean);\n const message = messageParts.join(' ');\n if (message.includes('gas required exceeds allowance') || message.includes('intrinsic gas too low')) {\n const data = encodeFunctionData({\n abi,\n functionName: 'createAccount',\n args: [params.owner, salt]\n });\n const hash = await client.sendTransaction({\n to: factoryAddr,\n data,\n gas: 2000000n,\n account: client.account\n });\n return { accountAddress, hash };\n }\n throw error;\n }\n }\n // ========================================\n // 1. 账户基本操作 (基于 L1 simpleAccountActions)\n // ========================================\n /**\n * Get the nonce of the account from EntryPoint (more reliable for 4337)\n */\n async getNonce(key = 0n) {\n try {\n if (!this.entryPointAddress) {\n throw new Error('EntryPoint address required for this client');\n }\n const entryPoint = entryPointActions(this.entryPointAddress);\n return await entryPoint(this.getStartPublicClient()).getNonce({\n sender: this.accountAddress,\n key\n });\n }\n catch (error) {\n throw error;\n }\n }\n /**\n * Get the owner of the AA account\n */\n async getOwner() {\n try {\n const account = accountActions(this.accountAddress);\n return await account(this.getStartPublicClient()).owner();\n }\n catch (error) {\n throw error;\n }\n }\n /**\n * Execute a transaction from the AA account\n */\n async execute(target, value, data, options) {\n try {\n const account = accountActions(this.accountAddress);\n // Use standard AA execute\n return await account(this.client).execute({\n dest: target,\n value,\n func: data,\n account: options?.account\n });\n }\n catch (error) {\n throw error;\n }\n }\n /**\n * Execute a batch of transactions\n */\n async executeBatch(targets, values, datas, options) {\n try {\n const account = accountActions(this.accountAddress);\n return await account(this.client).executeBatch({\n dest: targets,\n value: values,\n func: datas,\n account: options?.account\n });\n }\n catch (error) {\n throw error;\n }\n }\n // ========================================\n // identity 与 SBT (基于 L1 sbtActions)\n // ========================================\n /**\n * Get user's SBT balance\n */\n async getSBTBalance() {\n try {\n if (!this.sbtAddress)\n throw new Error('SBT address required for this client');\n const sbt = sbtActions(this.sbtAddress);\n return await sbt(this.getStartPublicClient()).balanceOf({\n owner: this.accountAddress\n });\n }\n catch (error) {\n throw error;\n }\n }\n async mintSBT(roleId, options) {\n try {\n if (!this.sbtAddress)\n throw new Error('SBT address required for this client');\n const { encodeFunctionData } = await import('viem');\n const data = encodeFunctionData({\n abi: [{ name: 'mintForRole', type: 'function', inputs: [{ name: 'user', type: 'address' }, { name: 'roleId', type: 'bytes32' }, { name: 'roleData', type: 'bytes' }], outputs: [{ type: 'uint256' }] }],\n functionName: 'mintForRole',\n args: [this.accountAddress, roleId, '0x']\n });\n return await this.execute(this.sbtAddress, 0n, data, options);\n }\n catch (error) {\n throw error;\n }\n }\n // ========================================\n // 3. 资产管理 (基于 L1 tokenActions)\n // ========================================\n async transferToken(token, to, amount, options) {\n try {\n const { encodeFunctionData } = await import('viem');\n const data = encodeFunctionData({\n abi: [{ name: 'transfer', type: 'function', inputs: [{ name: 'to', type: 'address' }, { name: 'amount', type: 'uint256' }], outputs: [{ type: 'bool' }] }],\n functionName: 'transfer',\n args: [to, amount]\n });\n return await this.execute(token, 0n, data, options);\n }\n catch (error) {\n throw error;\n }\n }\n /**\n * Get Token Balance\n */\n async getTokenBalance(token) {\n try {\n const tokens = tokenActions()(this.getStartPublicClient());\n return await tokens.balanceOf({\n token,\n account: this.accountAddress\n });\n }\n catch (error) {\n throw error;\n }\n }\n // ========================================\n // 4. 委托与质押 (Delegation & Staking)\n // ========================================\n async stakeForRole(roleId, amount, options) {\n try {\n if (!this.gTokenStakingAddress)\n throw new Error('GTokenStaking address required for this client');\n const { encodeFunctionData } = await import('viem');\n const data = encodeFunctionData({\n abi: [{ name: 'lockStake', type: 'function', inputs: [{ name: 'user', type: 'address' }, { name: 'roleId', type: 'bytes32' }, { name: 'stakeAmount', type: 'uint256' }, { name: 'entryBurn', type: 'uint256' }, { name: 'payer', type: 'address' }], outputs: [] }],\n functionName: 'lockStake',\n args: [this.accountAddress, roleId, amount, 0n, this.accountAddress]\n });\n return await this.execute(this.gTokenStakingAddress, 0n, data, options);\n }\n catch (error) {\n throw error;\n }\n }\n async unstakeFromRole(roleId, options) {\n try {\n if (!this.gTokenStakingAddress)\n throw new Error('GTokenStaking address required for this client');\n const { encodeFunctionData } = await import('viem');\n const data = encodeFunctionData({\n abi: [{ name: 'unlockAndTransfer', type: 'function', inputs: [{ name: 'user', type: 'address' }, { name: 'roleId', type: 'bytes32' }], outputs: [{ name: 'netAmount', type: 'uint256' }] }],\n functionName: 'unlockAndTransfer',\n args: [this.accountAddress, roleId]\n });\n return await this.execute(this.gTokenStakingAddress, 0n, data, options);\n }\n catch (error) {\n throw error;\n }\n }\n /**\n * Get staked balance for a specific role\n */\n async getStakedBalance(roleId) {\n try {\n if (!this.gTokenStakingAddress)\n throw new Error('GTokenStaking address required for this client');\n const staking = stakingActions(this.gTokenStakingAddress);\n return await staking(this.getStartPublicClient()).getLockedStake({\n user: this.accountAddress,\n roleId\n });\n }\n catch (error) {\n throw error;\n }\n }\n // ========================================\n // 5. 生命周期管理 (Lifecycle)\n // ========================================\n async exitRole(roleId, options) {\n try {\n if (!this.registryAddress)\n throw new Error('Registry address required for this client');\n const { encodeFunctionData } = await import('viem');\n const data = encodeFunctionData({\n abi: [{ name: 'exitRole', type: 'function', inputs: [{ name: 'roleId', type: 'bytes32' }], outputs: [] }],\n functionName: 'exitRole',\n args: [roleId]\n });\n return await this.execute(this.registryAddress, 0n, data, options);\n }\n catch (error) {\n throw error;\n }\n }\n async leaveCommunity(community, options) {\n try {\n if (!this.sbtAddress)\n throw new Error('SBT address required for this client');\n const { encodeFunctionData } = await import('viem');\n const data = encodeFunctionData({\n abi: [{ name: 'leaveCommunity', type: 'function', inputs: [{ name: 'comm', type: 'address' }], outputs: [] }],\n functionName: 'leaveCommunity',\n args: [community]\n });\n return await this.execute(this.sbtAddress, 0n, data, options);\n }\n catch (error) {\n throw error;\n }\n }\n /**\n * Register as EndUser (One-click: Approve + Register)\n * Handles GToken approval to Staking contract and Role registration.\n */\n async registerAsEndUser(communityAddress, stakeAmount, options) {\n try {\n if (!this.registryAddress)\n throw new Error('Registry address required for this client');\n if (!this.gTokenStakingAddress)\n throw new Error('GTokenStaking address required for this client');\n if (!this.gTokenAddress)\n throw new Error('GToken address required for this client');\n const { encodeAbiParameters, keccak256, toBytes, parseEther } = await import('viem');\n const ROLE_ENDUSER = keccak256(toBytes(\"ENDUSER\"));\n // Correct mapping for Registry Actions\n const registry = registryActions(this.registryAddress);\n const publicClient = this.getStartPublicClient();\n const tokens = tokenActions()(publicClient);\n // 1. Check Allowance\n const allowance = await tokens.allowance({\n token: this.gTokenAddress,\n owner: this.accountAddress,\n spender: this.gTokenStakingAddress\n });\n console.log(` 🔍 Debug Allowance: Account=${this.accountAddress}, Allowance=${allowance}, Needed=${stakeAmount}`);\n const txs = [];\n if (allowance < stakeAmount) {\n const approveData = encodeFunctionData({\n abi: [{ name: 'approve', type: 'function', inputs: [{ type: 'address' }, { type: 'uint256' }], outputs: [{ type: 'bool' }], stateMutability: 'nonpayable' }],\n functionName: 'approve',\n args: [this.gTokenStakingAddress, parseEther('1000')]\n });\n txs.push({ target: this.gTokenAddress, value: 0n, data: approveData });\n }\n // 2. Construct Register Call\n // struct EndUserRoleData { address account; address community; string avatarURI; string ensName; uint256 stakeAmount; }\n const roleData = encodeAbiParameters([\n { type: 'address', name: 'account' },\n { type: 'address', name: 'community' },\n { type: 'string', name: 'avatarURI' },\n { type: 'string', name: 'ensName' },\n { type: 'uint256', name: 'stakeAmount' }\n ], [\n this.accountAddress,\n communityAddress,\n '',\n '',\n stakeAmount\n ]);\n const registerData = encodeFunctionData({\n abi: [{ name: 'registerRoleSelf', type: 'function', inputs: [{ type: 'bytes32' }, { type: 'bytes' }], outputs: [{ type: 'uint256' }], stateMutability: 'nonpayable' }],\n functionName: 'registerRoleSelf',\n args: [ROLE_ENDUSER, roleData]\n });\n txs.push({ target: this.registryAddress, value: 0n, data: registerData });\n console.log(` 🔍 Debug Onboard: Community=${communityAddress}, AA=${this.accountAddress}, Stake=${stakeAmount}`);\n console.log(` 🔍 Debug Batch: Txs=${txs.length}, Targets=${txs.map(t => t.target)}`);\n // 3. Execute separately for stability (Batch execution has issues on current AA deployment)\n const hashes = [];\n for (const tx of txs) {\n const h = await this.execute(tx.target, tx.value, tx.data, options);\n hashes.push(h);\n // Wait for each tx to ensure sequential state updates (approve -> register)\n await this.getStartPublicClient().waitForTransactionReceipt({ hash: h });\n }\n return hashes[hashes.length - 1];\n }\n catch (error) {\n throw error;\n }\n }\n // ========================================\n // 6. Gasless Execution (Advanced)\n // ========================================\n /**\n * Execute a transaction with Gasless Sponsorship\n */\n async executeGasless(params, options) {\n try {\n const client = this.bundlerClient ? this.bundlerClient.extend(bundlerActions) : this.client.extend(bundlerActions);\n const ep = this.requireEntryPoint();\n // 1. Prepare Call Data\n const callData = encodeFunctionData({\n abi: [{ name: 'execute', type: 'function', inputs: [{ name: 'dest', type: 'address' }, { name: 'value', type: 'uint256' }, { name: 'func', type: 'bytes' }], outputs: [] }],\n functionName: 'execute',\n args: [params.target, params.value, params.data]\n });\n // 3. Delegate to PaymasterClient for v0.7 Gasless Submission\n // This ensures we follow the exact same logic as successful demo scripts\n // We dynamic import to avoid circular dependencies if any\n const { PaymasterClient: SDKPaymasterClient } = await import('@aastar/paymaster');\n let verificationGasLimit;\n let paymasterVerificationGasLimit;\n let paymasterPostOpGasLimit;\n let autoEstimate = true;\n if (params.paymasterType === 'Super') {\n // Apply Smart Buffer Strategy via PaymasterUtils (Same as SuperPaymasterClient)\n const { tuneGasLimit } = await import('@aastar/paymaster');\n const est = await SDKPaymasterClient.estimateUserOperationGas(this.client, this.client, this.accountAddress, ep, params.paymaster, params.target, // placeholder\n this.bundlerClient?.transport?.url || this.client.transport.url || '', callData, {\n operator: params.operator,\n factory: undefined,\n factoryData: undefined\n });\n // Matches SuperPaymasterClient Logic exactly:\n const bundlerEstimate = est.paymasterVerificationGasLimit || 100000n;\n // Nominal 60k, Efficiency 0.45\n paymasterVerificationGasLimit = tuneGasLimit(bundlerEstimate, 60000n, 0.45);\n // Safety Pad for VGL (Moderate, not 1M)\n const SAFETY_PAD = 80000n;\n verificationGasLimit = est.verificationGasLimit + SAFETY_PAD;\n // SuperPaymaster postOp calls burnFromWithOpHash (~40k gas) + storage writes.\n // Add 100k buffer; floor at 200k to prevent OOG. Pure BigInt to avoid Number precision loss.\n const _postOpBase = est.paymasterPostOpGasLimit + 100000n;\n paymasterPostOpGasLimit = _postOpBase > 200000n ? _postOpBase : 200000n;\n autoEstimate = false; // logic handled\n }\n const txHash = await SDKPaymasterClient.submitGaslessUserOperation(this.client, this.client, // WalletClient acts as signer\n this.accountAddress, ep, params.paymaster, params.target, // placeholder for token if V4\n this.bundlerClient?.transport?.url || this.client.transport.url || '', callData, {\n operator: params.operator,\n autoEstimate,\n verificationGasLimit,\n paymasterVerificationGasLimit,\n paymasterPostOpGasLimit\n });\n return txHash;\n }\n catch (error) {\n console.error(\" ❌ executeGasless Error:\", error.message);\n throw error;\n }\n }\n}\n"]}