@aastar/sdk 0.18.0 → 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 -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-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 +601 -12
  63. package/dist/index.js +1640 -28
  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 +87 -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,432 @@
1
+ import { BaseClient, xPNTsFactoryActions, registryActions, tokenActions, sbtActions, reputationActions } from './chunk-ZSSNU3UF.js';
2
+ import { parseEther, encodeAbiParameters, parseAbiParameters } from 'viem';
3
+
4
+ var CommunityClient = class extends BaseClient {
5
+ sbtAddress;
6
+ factoryAddress;
7
+ reputationAddress;
8
+ constructor(config) {
9
+ super(config);
10
+ this.sbtAddress = config.sbtAddress;
11
+ this.factoryAddress = config.factoryAddress;
12
+ this.reputationAddress = config.reputationAddress;
13
+ }
14
+ // ========================================
15
+ // 1. 社区创建与配置
16
+ // ========================================
17
+ /**
18
+ * Create a new Community Token (xPNTs) and register it.
19
+ * Note: In the current architecture, creating a community often involves:
20
+ * 1. Registering the ROLE_COMMUNITY on Registry (if not exists) -> usually manual or self-register
21
+ * 2. Deploying a Token (xPNTs) via Factory
22
+ * 3. Linking the Token to the Community in Registry
23
+ */
24
+ async createCommunityToken(params, options) {
25
+ try {
26
+ if (!this.factoryAddress) {
27
+ throw new Error("Factory address required for this client");
28
+ }
29
+ const factory = xPNTsFactoryActions(this.factoryAddress);
30
+ return await factory(this.client).createToken({
31
+ name: params.name,
32
+ symbol: params.tokenSymbol,
33
+ community: this.getAddress(),
34
+ account: options?.account
35
+ });
36
+ } catch (error) {
37
+ throw error;
38
+ }
39
+ }
40
+ /**
41
+ * Get Community Details (Decodes Role Metadata)
42
+ * @param communityAddress - The address of the community manager (defaults to self)
43
+ */
44
+ async getCommunityInfo(communityAddress) {
45
+ try {
46
+ const target = communityAddress || this.getAddress();
47
+ const registryAddr = this.requireRegistry();
48
+ const registry = registryActions(registryAddr);
49
+ const publicClient = this.getStartPublicClient();
50
+ const API_ROLE_COMMUNITY = await registry(publicClient).ROLE_COMMUNITY();
51
+ let metadataHex;
52
+ try {
53
+ metadataHex = await registry(publicClient).roleMetadata({
54
+ roleId: API_ROLE_COMMUNITY,
55
+ user: target
56
+ });
57
+ } catch (err) {
58
+ const m = (err instanceof Error ? `${err.message} ${err.cause?.message ?? ""}` : String(err)).toLowerCase();
59
+ const isContractGap = m.includes("revert") || m.includes("returned no data") || m.includes("does not exist") || m.includes("is not a function") || m.includes("no data was returned");
60
+ if (!isContractGap)
61
+ throw err;
62
+ metadataHex = void 0;
63
+ }
64
+ if (!metadataHex || metadataHex === "0x") {
65
+ let stakeAmount2 = 0n;
66
+ try {
67
+ stakeAmount2 = await registry(publicClient).roleStakes({ roleId: API_ROLE_COMMUNITY, user: target });
68
+ } catch {
69
+ }
70
+ return { name: "", ensName: "", website: "", description: "", logoURI: "", stakeAmount: stakeAmount2 };
71
+ }
72
+ let dataToDecode = metadataHex;
73
+ if (metadataHex.startsWith("0x0000000000000000000000000000000000000000000000000000000000000020")) {
74
+ dataToDecode = `0x${metadataHex.slice(66)}`;
75
+ }
76
+ const { decodeAbiParameters, parseAbiParameters: parseAbiParameters2 } = await import('viem');
77
+ const [name, ensName, website, description, logoURI, stakeAmount] = decodeAbiParameters(parseAbiParameters2("string, string, string, string, string, uint256"), dataToDecode);
78
+ return {
79
+ name,
80
+ ensName,
81
+ website,
82
+ description,
83
+ logoURI,
84
+ stakeAmount
85
+ };
86
+ } catch (error) {
87
+ throw error;
88
+ }
89
+ }
90
+ /**
91
+ * Register self as a Community Manager.
92
+ * This method handles all necessary steps:
93
+ * 1. Checks and approves GToken to GTokenStaking
94
+ * 2. Encodes CommunityRoleData with provided parameters
95
+ * 3. Calls registerRoleSelf on Registry
96
+ *
97
+ * @param params Community registration parameters
98
+ * @param options Transaction options
99
+ * @returns Transaction hash
100
+ */
101
+ async registerAsCommunity(params, options) {
102
+ try {
103
+ const registryAddr = this.requireRegistry();
104
+ const registry = registryActions(registryAddr);
105
+ const gTokenStakingAddr = this.requireGTokenStaking();
106
+ const gTokenAddr = this.requireGToken();
107
+ const roleCommunity = await registry(this.getStartPublicClient()).ROLE_COMMUNITY();
108
+ const stakeAmount = params.stakeAmount || parseEther("30");
109
+ const gToken = tokenActions();
110
+ const allowance = await gToken(this.getStartPublicClient()).allowance({
111
+ token: gTokenAddr,
112
+ owner: this.getAddress(),
113
+ spender: gTokenStakingAddr
114
+ });
115
+ if (allowance < stakeAmount) {
116
+ const approveHash = await gToken(this.client).approve({
117
+ token: gTokenAddr,
118
+ spender: gTokenStakingAddr,
119
+ amount: stakeAmount * BigInt(2),
120
+ // Approve 2x for future use
121
+ account: options?.account
122
+ });
123
+ await this.getStartPublicClient().waitForTransactionReceipt({ hash: approveHash });
124
+ }
125
+ const communityData = encodeAbiParameters(parseAbiParameters("string, string, string, string, string, uint256"), [
126
+ params.name,
127
+ params.ensName || "",
128
+ params.website || "",
129
+ params.description || `${params.name} Community`,
130
+ params.logoURI || "",
131
+ stakeAmount
132
+ ]);
133
+ return await registry(this.client).registerRoleSelf({
134
+ roleId: roleCommunity,
135
+ data: communityData,
136
+ account: options?.account
137
+ });
138
+ } catch (error) {
139
+ throw error;
140
+ }
141
+ }
142
+ /**
143
+ * One-click Setup: Register Community + Deploy Token
144
+ * Orchestrates the complete community initialization flow.
145
+ */
146
+ async setupCommunity(params, options) {
147
+ const hashes = [];
148
+ let tokenAddress = "0x0000000000000000000000000000000000000000";
149
+ const registry = registryActions(this.requireRegistry())(this.getStartPublicClient());
150
+ const ROLE_COMMUNITY = await registry.ROLE_COMMUNITY();
151
+ const hasRole = await registry.hasRole({ roleId: ROLE_COMMUNITY, user: this.getAddress() });
152
+ if (!hasRole) {
153
+ const hReg = await this.registerAsCommunity({
154
+ name: params.name,
155
+ ensName: params.website,
156
+ // Mapping website to ENS param for now as per legacy behavior
157
+ website: params.website,
158
+ description: params.description,
159
+ logoURI: params.logoURI,
160
+ stakeAmount: params.stakeAmount
161
+ }, options);
162
+ hashes.push(hReg);
163
+ await this.getStartPublicClient().waitForTransactionReceipt({ hash: hReg });
164
+ }
165
+ if (this.factoryAddress) {
166
+ const factoryReader = xPNTsFactoryActions(this.factoryAddress)(this.getStartPublicClient());
167
+ const existingToken = await factoryReader.getTokenAddress({ community: this.getAddress() });
168
+ if (existingToken && existingToken !== "0x0000000000000000000000000000000000000000") {
169
+ tokenAddress = existingToken;
170
+ } else {
171
+ const hToken = await this.createCommunityToken({
172
+ name: params.tokenName,
173
+ tokenSymbol: params.tokenSymbol,
174
+ description: params.description
175
+ }, options);
176
+ hashes.push(hToken);
177
+ await this.getStartPublicClient().waitForTransactionReceipt({ hash: hToken });
178
+ for (let i = 0; i < 5; i++) {
179
+ tokenAddress = await factoryReader.getTokenAddress({ community: this.getAddress() });
180
+ if (tokenAddress && tokenAddress !== "0x0000000000000000000000000000000000000000")
181
+ break;
182
+ await new Promise((r) => setTimeout(r, 2e3));
183
+ }
184
+ if (!tokenAddress || tokenAddress === "0x0000000000000000000000000000000000000000") {
185
+ console.warn(`Warning: Token address not found after 10s. Factory might be slow indexing.`);
186
+ }
187
+ }
188
+ }
189
+ return { tokenAddress, hashes };
190
+ }
191
+ // ========================================
192
+ // 2. 成员管理
193
+ // ========================================
194
+ /**
195
+ * Airdrop SBTs to users to make them members
196
+ */
197
+ async airdropSBT(users, roleId, options) {
198
+ try {
199
+ if (!this.sbtAddress)
200
+ throw new Error("SBT address required for this client");
201
+ const sbt = sbtActions(this.sbtAddress);
202
+ if (users.length === 1) {
203
+ const roleIdHex = `0x${roleId.toString(16).padStart(64, "0")}`;
204
+ return await sbt(this.client).mintForRole({
205
+ user: users[0],
206
+ roleId: roleIdHex,
207
+ roleData: "0x",
208
+ account: options?.account
209
+ });
210
+ }
211
+ throw new Error("Batch airdrop not fully implemented in L1 yet, use single user");
212
+ } catch (error) {
213
+ throw error;
214
+ }
215
+ }
216
+ // ========================================
217
+ // 3. 信誉系统
218
+ // ========================================
219
+ async setReputationRule(ruleId, ruleConfig, options) {
220
+ try {
221
+ if (!this.reputationAddress)
222
+ throw new Error("Reputation address required for this client");
223
+ const reputation = reputationActions(this.reputationAddress);
224
+ const ruleIdHex = `0x${ruleId.toString(16).padStart(64, "0")}`;
225
+ return await reputation(this.client).setReputationRule({
226
+ ruleId: ruleIdHex,
227
+ rule: ruleConfig,
228
+ account: options?.account
229
+ });
230
+ } catch (error) {
231
+ throw error;
232
+ }
233
+ }
234
+ // ========================================
235
+ // 4. 管理功能
236
+ // ========================================
237
+ /**
238
+ * Revoke membership (Burn SBT)
239
+ */
240
+ async revokeMembership(userAddr, options) {
241
+ try {
242
+ if (!this.sbtAddress)
243
+ throw new Error("SBT address required for this client");
244
+ const sbt = sbtActions(this.sbtAddress);
245
+ return await sbt(this.client).burnSBT({
246
+ user: userAddr,
247
+ account: options?.account
248
+ });
249
+ } catch (error) {
250
+ throw error;
251
+ }
252
+ }
253
+ /**
254
+ * Transfer ownership of the Community Token
255
+ */
256
+ async transferCommunityTokenOwnership(tokenAddress, newOwner, options) {
257
+ try {
258
+ const token = tokenActions()(this.client);
259
+ return await token.transferOwnership({
260
+ token: tokenAddress,
261
+ newOwner,
262
+ account: options?.account
263
+ });
264
+ } catch (error) {
265
+ throw error;
266
+ }
267
+ }
268
+ };
269
+ var UserLifecycle = class extends BaseClient {
270
+ accountAddress;
271
+ registryAddress;
272
+ sbtAddress;
273
+ gTokenAddress;
274
+ gTokenStakingAddress;
275
+ entryPointAddress;
276
+ gaslessConfig;
277
+ config;
278
+ constructor(config) {
279
+ super(config);
280
+ this.config = config;
281
+ this.accountAddress = config.accountAddress;
282
+ this.registryAddress = config.registryAddress;
283
+ this.sbtAddress = config.sbtAddress;
284
+ this.gTokenAddress = config.gTokenAddress;
285
+ this.gTokenStakingAddress = config.gTokenStakingAddress;
286
+ this.entryPointAddress = config.entryPointAddress;
287
+ this.gaslessConfig = config.gasless;
288
+ }
289
+ // ===========================================
290
+ // 1. Onboarding Phase (Registration)
291
+ // ===========================================
292
+ /**
293
+ * Check if user is eligible to join a community
294
+ * @param community Address of the community
295
+ */
296
+ async checkEligibility(community) {
297
+ const publicClient = this.getStartPublicClient();
298
+ registryActions(this.registryAddress)(publicClient);
299
+ return true;
300
+ }
301
+ /**
302
+ * One-click Onboarding: Approve -> Stake -> Register -> Mint SBT
303
+ * @param community Address of the community to join
304
+ * @param stakeAmount Amount of GToken to stake (default 0.4 GT)
305
+ */
306
+ async onboard(community, stakeAmount = parseEther("0.4")) {
307
+ try {
308
+ const registry = registryActions(this.registryAddress)(this.getStartPublicClient());
309
+ const userClient = await import('./UserClient-YUHCJJJL.js').then((m) => new m.UserClient({
310
+ ...this.config,
311
+ accountAddress: this.accountAddress,
312
+ registryAddress: this.registryAddress,
313
+ gTokenStakingAddress: this.gTokenStakingAddress,
314
+ gTokenAddress: this.gTokenAddress,
315
+ sbtAddress: this.sbtAddress
316
+ }));
317
+ const txHash = await userClient.registerAsEndUser(community, stakeAmount);
318
+ let hasRole = false;
319
+ for (let i = 0; i < 5; i++) {
320
+ hasRole = await registry.hasRole({
321
+ roleId: await registry.ROLE_ENDUSER(),
322
+ user: this.accountAddress
323
+ });
324
+ if (hasRole)
325
+ break;
326
+ await new Promise((r) => setTimeout(r, 2e3));
327
+ }
328
+ return {
329
+ success: hasRole,
330
+ txHash
331
+ };
332
+ } catch (error) {
333
+ console.error("Onboarding failed:", error);
334
+ return { success: false };
335
+ }
336
+ }
337
+ /**
338
+ * Enable or update Gasless configuration
339
+ */
340
+ async enableGasless(config) {
341
+ this.gaslessConfig = config;
342
+ }
343
+ // ===========================================
344
+ // 2. Operational Phase (Execute & Interact)
345
+ // ===========================================
346
+ /**
347
+ * Execute a transaction effectively using Gasless configuration if available
348
+ */
349
+ async executeGaslessTx(params) {
350
+ if (!this.gaslessConfig) {
351
+ throw new Error("Gasless configuration not enabled. Call enableGasless() first.");
352
+ }
353
+ const userClient = await import('./UserClient-YUHCJJJL.js').then((m) => new m.UserClient({
354
+ ...this.config,
355
+ accountAddress: this.accountAddress,
356
+ // Pass minimal config needed for execution
357
+ entryPointAddress: this.entryPointAddress,
358
+ bundlerClient: this.config.bundlerClient
359
+ }));
360
+ const paymasterType = this.gaslessConfig.policy === "CREDIT" ? "Super" : "V4";
361
+ const registry = registryActions(this.registryAddress)(this.client);
362
+ const paymasterAddress = await registry.SUPER_PAYMASTER();
363
+ return await userClient.executeGasless({
364
+ target: params.target,
365
+ value: params.value,
366
+ data: params.data,
367
+ paymaster: paymasterAddress,
368
+ paymasterType,
369
+ operator: params.operator
370
+ });
371
+ }
372
+ async claimSBT(roleId, options) {
373
+ const userClient = await import('./UserClient-YUHCJJJL.js').then((m) => new m.UserClient({
374
+ ...this.config,
375
+ accountAddress: this.accountAddress,
376
+ sbtAddress: this.sbtAddress
377
+ }));
378
+ return await userClient.mintSBT(roleId, options);
379
+ }
380
+ // ===========================================
381
+ // 3. Query Phase (Info & Stats)
382
+ // ===========================================
383
+ async getMyReputation() {
384
+ const publicClient = this.getStartPublicClient();
385
+ const registry = registryActions(this.registryAddress)(publicClient);
386
+ const [score, creditLimit] = await Promise.all([
387
+ registry.globalReputation({ user: this.accountAddress }),
388
+ registry.getCreditLimit({ user: this.accountAddress })
389
+ ]);
390
+ return {
391
+ score,
392
+ level: 0n,
393
+ // TODO: Add level calculation logic
394
+ creditLimit
395
+ };
396
+ }
397
+ async getCreditLimit() {
398
+ const registry = registryActions(this.registryAddress)(this.client);
399
+ return await registry.getCreditLimit({ user: this.accountAddress });
400
+ }
401
+ // ===========================================
402
+ // 4. Exit Phase (Cleanup)
403
+ // ===========================================
404
+ async leaveCommunity(community, options) {
405
+ const userClient = await import('./UserClient-YUHCJJJL.js').then((m) => new m.UserClient({
406
+ ...this.config,
407
+ accountAddress: this.accountAddress,
408
+ sbtAddress: this.sbtAddress
409
+ }));
410
+ return await userClient.leaveCommunity(community, options);
411
+ }
412
+ async exitRole(roleId, options) {
413
+ const userClient = await import('./UserClient-YUHCJJJL.js').then((m) => new m.UserClient({
414
+ ...this.config,
415
+ accountAddress: this.accountAddress,
416
+ registryAddress: this.registryAddress
417
+ }));
418
+ return await userClient.exitRole(roleId, options);
419
+ }
420
+ async unstakeAll(roleId, options) {
421
+ const userClient = await import('./UserClient-YUHCJJJL.js').then((m) => new m.UserClient({
422
+ ...this.config,
423
+ accountAddress: this.accountAddress,
424
+ gTokenStakingAddress: this.gTokenStakingAddress
425
+ }));
426
+ return await userClient.unstakeFromRole(roleId, options);
427
+ }
428
+ };
429
+
430
+ export { CommunityClient, UserLifecycle };
431
+ //# sourceMappingURL=chunk-YHM77LIP.js.map
432
+ //# sourceMappingURL=chunk-YHM77LIP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../enduser/dist/CommunityClient.js","../../enduser/dist/UserLifecycle.js"],"names":["stakeAmount","parseAbiParameters","parseEther"],"mappings":";;;AAMO,IAAM,eAAA,GAAN,cAA8B,UAAA,CAAW;AAAA,EAC5C,UAAA;AAAA,EACA,cAAA;AAAA,EACA,iBAAA;AAAA,EACA,YAAY,MAAA,EAAQ;AAChB,IAAA,KAAA,CAAM,MAAM,CAAA;AACZ,IAAA,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,MAAA,EAAQ,OAAO,CAAA;AAAA,EAC3D;AACJ","file":"chunk-YHM77LIP.js","sourcesContent":["import { parseEther, encodeAbiParameters, parseAbiParameters } from 'viem';\nimport { BaseClient } from '@aastar/core';\nimport { registryActions, sbtActions, xPNTsFactoryActions, reputationActions, tokenActions } from '@aastar/core';\n/**\n * Client for Community Managers (`ROLE_COMMUNITY`)\n */\nexport class CommunityClient extends BaseClient {\n sbtAddress;\n factoryAddress;\n reputationAddress;\n constructor(config) {\n super(config);\n this.sbtAddress = config.sbtAddress;\n this.factoryAddress = config.factoryAddress;\n this.reputationAddress = config.reputationAddress;\n }\n // ========================================\n // 1. 社区创建与配置\n // ========================================\n /**\n * Create a new Community Token (xPNTs) and register it.\n * Note: In the current architecture, creating a community often involves:\n * 1. Registering the ROLE_COMMUNITY on Registry (if not exists) -> usually manual or self-register\n * 2. Deploying a Token (xPNTs) via Factory\n * 3. Linking the Token to the Community in Registry\n */\n async createCommunityToken(params, options) {\n try {\n if (!this.factoryAddress) {\n throw new Error('Factory address required for this client');\n }\n const factory = xPNTsFactoryActions(this.factoryAddress);\n // 1. Deploy Token\n // Note: The address calculation should be handled via event parsing or predictive deployment\n // For now, returning the transaction hash as per L1 pattern\n return await factory(this.client).createToken({\n name: params.name,\n symbol: params.tokenSymbol,\n community: this.getAddress(),\n account: options?.account\n });\n }\n catch (error) {\n // Error is likely already an AAStarError from L1, but we wrap it for context\n throw error;\n }\n }\n /**\n * Get Community Details (Decodes Role Metadata)\n * @param communityAddress - The address of the community manager (defaults to self)\n */\n async getCommunityInfo(communityAddress) {\n try {\n const target = communityAddress || this.getAddress();\n const registryAddr = this.requireRegistry();\n const registry = registryActions(registryAddr);\n const publicClient = this.getStartPublicClient();\n // 1. Get Role ID\n const API_ROLE_COMMUNITY = await registry(publicClient).ROLE_COMMUNITY();\n // 2. Fetch Metadata (Hex).\n // NOTE: in the deployed v5 Registry, `roleMetadata` is an INTERNAL mapping with no\n // public getter (the rich community profile — name/website/logo — is written on\n // registerRole but not readable on-chain). When the getter is absent the call\n // reverts; degrade gracefully to the on-chain-readable fields (stake) with an\n // empty profile rather than throwing, so callers can still resolve the community.\n let metadataHex;\n try {\n metadataHex = await registry(publicClient).roleMetadata({\n roleId: API_ROLE_COMMUNITY,\n user: target\n });\n }\n catch (err) {\n // Degrade ONLY on contract-level \"no getter / reverted\" errors — the deployed\n // v5 Registry genuinely lacks a public roleMetadata getter. Re-throw genuine\n // transport/RPC errors so a transient network failure is not silently masked as\n // \"no community profile\".\n const m = (err instanceof Error ? `${err.message} ${err.cause?.message ?? ''}` : String(err)).toLowerCase();\n const isContractGap = m.includes('revert') || m.includes('returned no data') ||\n m.includes('does not exist') || m.includes('is not a function') ||\n m.includes('no data was returned');\n if (!isContractGap)\n throw err;\n metadataHex = undefined;\n }\n if (!metadataHex || metadataHex === '0x') {\n let stakeAmount = 0n;\n try {\n stakeAmount = await registry(publicClient).roleStakes({ roleId: API_ROLE_COMMUNITY, user: target });\n }\n catch { /* stake unreadable too — leave 0 */ }\n return { name: '', ensName: '', website: '', description: '', logoURI: '', stakeAmount };\n }\n // 3. Decode\n // struct CommunityRoleData { string name; string ensName; string website; string description; string logoURI; uint256 stakeAmount; }\n let dataToDecode = metadataHex;\n // Check for common 'bytes' or 'tuple' wrapper offset (0x20)\n if (metadataHex.startsWith('0x0000000000000000000000000000000000000000000000000000000000000020')) {\n dataToDecode = `0x${metadataHex.slice(66)}`;\n }\n const { decodeAbiParameters, parseAbiParameters } = await import('viem');\n const [name, ensName, website, description, logoURI, stakeAmount] = decodeAbiParameters(parseAbiParameters('string, string, string, string, string, uint256'), dataToDecode);\n return {\n name,\n ensName,\n website,\n description,\n logoURI,\n stakeAmount\n };\n }\n catch (error) {\n throw error;\n }\n }\n /**\n * Register self as a Community Manager.\n * This method handles all necessary steps:\n * 1. Checks and approves GToken to GTokenStaking\n * 2. Encodes CommunityRoleData with provided parameters\n * 3. Calls registerRoleSelf on Registry\n *\n * @param params Community registration parameters\n * @param options Transaction options\n * @returns Transaction hash\n */\n async registerAsCommunity(params, options) {\n try {\n const registryAddr = this.requireRegistry();\n const registry = registryActions(registryAddr);\n const gTokenStakingAddr = this.requireGTokenStaking();\n const gTokenAddr = this.requireGToken();\n // 1. Get ROLE_COMMUNITY\n const roleCommunity = await registry(this.getStartPublicClient()).ROLE_COMMUNITY();\n // 2. Prepare stake amount (default 30 GToken as per Registry config)\n const stakeAmount = params.stakeAmount || parseEther('30');\n // 3. Check and approve GToken to GTokenStaking if needed\n const gToken = tokenActions();\n const allowance = await gToken(this.getStartPublicClient()).allowance({\n token: gTokenAddr,\n owner: this.getAddress(),\n spender: gTokenStakingAddr\n });\n if (allowance < stakeAmount) {\n const approveHash = await gToken(this.client).approve({\n token: gTokenAddr,\n spender: gTokenStakingAddr,\n amount: stakeAmount * BigInt(2), // Approve 2x for future use\n account: options?.account\n });\n await this.getStartPublicClient().waitForTransactionReceipt({ hash: approveHash });\n }\n // 4. Encode CommunityRoleData\n // struct CommunityRoleData { string name; string ensName; string website; string description; string logoURI; uint256 stakeAmount; }\n const communityData = encodeAbiParameters(parseAbiParameters('string, string, string, string, string, uint256'), [\n params.name,\n params.ensName || '',\n params.website || '',\n params.description || `${params.name} Community`,\n params.logoURI || '',\n stakeAmount\n ]);\n // 5. Register role\n return await registry(this.client).registerRoleSelf({\n roleId: roleCommunity,\n data: communityData,\n account: options?.account\n });\n }\n catch (error) {\n throw error;\n }\n }\n /**\n * One-click Setup: Register Community + Deploy Token\n * Orchestrates the complete community initialization flow.\n */\n async setupCommunity(params, options) {\n const hashes = [];\n let tokenAddress = '0x0000000000000000000000000000000000000000';\n // 1. Register as Community (Idempotent check handled inside or by registry)\n // We should check hasRole first to avoid errors if already registered\n const registry = registryActions(this.requireRegistry())(this.getStartPublicClient());\n const ROLE_COMMUNITY = await registry.ROLE_COMMUNITY();\n const hasRole = await registry.hasRole({ roleId: ROLE_COMMUNITY, user: this.getAddress() });\n if (!hasRole) {\n const hReg = await this.registerAsCommunity({\n name: params.name,\n ensName: params.website, // Mapping website to ENS param for now as per legacy behavior\n website: params.website,\n description: params.description,\n logoURI: params.logoURI,\n stakeAmount: params.stakeAmount\n }, options);\n hashes.push(hReg);\n // Critical: Factory requires caller to be registered in Registry.\n // We must wait for the registration to be mined.\n await this.getStartPublicClient().waitForTransactionReceipt({ hash: hReg });\n }\n // 2. Deploy Token (Idempotent check via Factory)\n if (this.factoryAddress) {\n const factoryReader = xPNTsFactoryActions(this.factoryAddress)(this.getStartPublicClient());\n const existingToken = await factoryReader.getTokenAddress({ community: this.getAddress() });\n if (existingToken && existingToken !== '0x0000000000000000000000000000000000000000') {\n tokenAddress = existingToken;\n }\n else {\n const hToken = await this.createCommunityToken({\n name: params.tokenName,\n tokenSymbol: params.tokenSymbol,\n description: params.description\n }, options);\n hashes.push(hToken);\n // Critical: Wait for token deployment to fetch the address\n await this.getStartPublicClient().waitForTransactionReceipt({ hash: hToken });\n // Fetch the actual address (with retries for latency)\n for (let i = 0; i < 5; i++) {\n tokenAddress = await factoryReader.getTokenAddress({ community: this.getAddress() });\n if (tokenAddress && tokenAddress !== '0x0000000000000000000000000000000000000000')\n break;\n await new Promise(r => setTimeout(r, 2000));\n }\n if (!tokenAddress || tokenAddress === '0x0000000000000000000000000000000000000000') {\n console.warn(`Warning: Token address not found after 10s. Factory might be slow indexing.`);\n }\n }\n }\n return { tokenAddress, hashes };\n }\n // ========================================\n // 2. 成员管理\n // ========================================\n /**\n * Airdrop SBTs to users to make them members\n */\n async airdropSBT(users, roleId, options) {\n try {\n if (!this.sbtAddress)\n throw new Error('SBT address required for this client');\n const sbt = sbtActions(this.sbtAddress);\n if (users.length === 1) {\n // Convert roleId to Hex (bytes32)\n const roleIdHex = `0x${roleId.toString(16).padStart(64, '0')}`;\n return await sbt(this.client).mintForRole({\n user: users[0],\n roleId: roleIdHex,\n roleData: '0x',\n account: options?.account\n });\n }\n throw new Error('Batch airdrop not fully implemented in L1 yet, use single user');\n }\n catch (error) {\n throw error;\n }\n }\n // ========================================\n // 3. 信誉系统\n // ========================================\n async setReputationRule(ruleId, ruleConfig, options) {\n try {\n if (!this.reputationAddress)\n throw new Error('Reputation address required for this client');\n const reputation = reputationActions(this.reputationAddress);\n const ruleIdHex = `0x${ruleId.toString(16).padStart(64, '0')}`;\n return await reputation(this.client).setReputationRule({\n ruleId: ruleIdHex,\n rule: ruleConfig,\n account: options?.account\n });\n }\n catch (error) {\n throw error;\n }\n }\n // ========================================\n // 4. 管理功能\n // ========================================\n /**\n * Revoke membership (Burn SBT)\n */\n async revokeMembership(userAddr, options) {\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.client).burnSBT({\n user: userAddr,\n account: options?.account\n });\n }\n catch (error) {\n throw error;\n }\n }\n /**\n * Transfer ownership of the Community Token\n */\n async transferCommunityTokenOwnership(tokenAddress, newOwner, options) {\n try {\n const token = tokenActions()(this.client);\n return await token.transferOwnership({\n token: tokenAddress,\n newOwner,\n account: options?.account\n });\n }\n catch (error) {\n throw error;\n }\n }\n}\n","import { parseEther } from 'viem';\nimport { BaseClient } from '@aastar/core';\nimport { registryActions } from '@aastar/core'; // L2/L1 Actions\n/**\n * UserLifecycle - L3 Pattern\n *\n * Responsibilities:\n * 1. Managing the complete lifecycle of an End User (Onboard -> Operate -> Exit)\n * 2. Providing a unified interface for Gasless operations\n * 3. Abstracting underlying contract interactions via L2 Actions\n */\nexport class UserLifecycle extends BaseClient {\n accountAddress;\n registryAddress;\n sbtAddress;\n gTokenAddress;\n gTokenStakingAddress;\n entryPointAddress;\n gaslessConfig;\n config;\n constructor(config) {\n super(config);\n this.config = config;\n this.accountAddress = config.accountAddress;\n this.registryAddress = config.registryAddress;\n this.sbtAddress = config.sbtAddress;\n this.gTokenAddress = config.gTokenAddress;\n this.gTokenStakingAddress = config.gTokenStakingAddress;\n this.entryPointAddress = config.entryPointAddress;\n this.gaslessConfig = config.gasless;\n }\n // ===========================================\n // 1. Onboarding Phase (Registration)\n // ===========================================\n /**\n * Check if user is eligible to join a community\n * @param community Address of the community\n */\n async checkEligibility(community) {\n // Validation logic (e.g., check blacklist or whitelist via Registry)\n const publicClient = this.getStartPublicClient();\n const registry = registryActions(this.registryAddress)(publicClient);\n // Placeholder: simplistic check, real logic might involve community specific rules\n return true;\n }\n /**\n * One-click Onboarding: Approve -> Stake -> Register -> Mint SBT\n * @param community Address of the community to join\n * @param stakeAmount Amount of GToken to stake (default 0.4 GT)\n */\n async onboard(community, stakeAmount = parseEther('0.4')) {\n try {\n const registry = registryActions(this.registryAddress)(this.getStartPublicClient());\n const userClient = await import('./UserClient.js').then(m => new m.UserClient({\n ...this.config,\n accountAddress: this.accountAddress,\n registryAddress: this.registryAddress,\n gTokenStakingAddress: this.gTokenStakingAddress,\n gTokenAddress: this.gTokenAddress,\n sbtAddress: this.sbtAddress\n }));\n // Use UserClient's batch execution capability for atomic onboarding\n const txHash = await userClient.registerAsEndUser(community, stakeAmount);\n // Post-check: Verify role with retry\n let hasRole = false;\n for (let i = 0; i < 5; i++) {\n hasRole = await registry.hasRole({\n roleId: await registry.ROLE_ENDUSER(),\n user: this.accountAddress\n });\n if (hasRole)\n break;\n await new Promise(r => setTimeout(r, 2000));\n }\n return {\n success: hasRole,\n txHash\n };\n }\n catch (error) {\n console.error(\"Onboarding failed:\", error);\n return { success: false };\n }\n }\n /**\n * Enable or update Gasless configuration\n */\n async enableGasless(config) {\n this.gaslessConfig = config;\n // In future: verify paymaster connection here\n }\n // ===========================================\n // 2. Operational Phase (Execute & Interact)\n // ===========================================\n /**\n * Execute a transaction effectively using Gasless configuration if available\n */\n async executeGaslessTx(params) {\n if (!this.gaslessConfig) {\n throw new Error(\"Gasless configuration not enabled. Call enableGasless() first.\");\n }\n const userClient = await import('./UserClient.js').then(m => new m.UserClient({\n ...this.config,\n accountAddress: this.accountAddress,\n // Pass minimal config needed for execution\n entryPointAddress: this.entryPointAddress,\n bundlerClient: this.config.bundlerClient\n }));\n // Determine Paymaster Type based on policy\n const paymasterType = this.gaslessConfig.policy === 'CREDIT' ? 'Super' : 'V4';\n // Note: Real implementation needs to resolve actual Paymaster Address from Registry/Config\n // This is a placeholder address resolution\n const registry = registryActions(this.registryAddress)(this.client);\n const paymasterAddress = await registry.SUPER_PAYMASTER();\n return await userClient.executeGasless({\n target: params.target,\n value: params.value,\n data: params.data,\n paymaster: paymasterAddress,\n paymasterType,\n operator: params.operator\n });\n }\n async claimSBT(roleId, options) {\n const userClient = await import('./UserClient.js').then(m => new m.UserClient({\n ...this.config,\n accountAddress: this.accountAddress,\n sbtAddress: this.sbtAddress\n }));\n return await userClient.mintSBT(roleId, options);\n }\n // ===========================================\n // 3. Query Phase (Info & Stats)\n // ===========================================\n async getMyReputation() {\n const publicClient = this.getStartPublicClient();\n const registry = registryActions(this.registryAddress)(publicClient);\n const [score, creditLimit] = await Promise.all([\n registry.globalReputation({ user: this.accountAddress }),\n registry.getCreditLimit({ user: this.accountAddress })\n ]);\n return {\n score,\n level: 0n, // TODO: Add level calculation logic\n creditLimit\n };\n }\n async getCreditLimit() {\n const registry = registryActions(this.registryAddress)(this.client);\n return await registry.getCreditLimit({ user: this.accountAddress });\n }\n // ===========================================\n // 4. Exit Phase (Cleanup)\n // ===========================================\n async leaveCommunity(community, options) {\n const userClient = await import('./UserClient.js').then(m => new m.UserClient({\n ...this.config,\n accountAddress: this.accountAddress,\n sbtAddress: this.sbtAddress\n }));\n return await userClient.leaveCommunity(community, options);\n }\n async exitRole(roleId, options) {\n const userClient = await import('./UserClient.js').then(m => new m.UserClient({\n ...this.config,\n accountAddress: this.accountAddress,\n registryAddress: this.registryAddress\n }));\n return await userClient.exitRole(roleId, options);\n }\n async unstakeAll(roleId, options) {\n const userClient = await import('./UserClient.js').then(m => new m.UserClient({\n ...this.config,\n accountAddress: this.accountAddress,\n gTokenStakingAddress: this.gTokenStakingAddress\n }));\n return await userClient.unstakeFromRole(roleId, options);\n }\n}\n"]}