@aastar/sdk 0.20.7 → 0.20.9

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 (94) hide show
  1. package/dist/BaseClient-CkBhQ1ou.d.cts +88 -0
  2. package/dist/UserClient-2J6XMTNV.cjs +15 -0
  3. package/dist/UserClient-2J6XMTNV.cjs.map +1 -0
  4. package/dist/account.cjs +31 -0
  5. package/dist/account.cjs.map +1 -0
  6. package/dist/account.d.cts +48 -0
  7. package/dist/admin.cjs +15 -0
  8. package/dist/admin.cjs.map +1 -0
  9. package/dist/admin.d.cts +62 -0
  10. package/dist/airaccount.cjs +452 -0
  11. package/dist/airaccount.cjs.map +1 -0
  12. package/dist/airaccount.d.cts +4 -0
  13. package/dist/airaccount.js +3 -1
  14. package/dist/channel-CkRRbzT8.d.cts +77 -0
  15. package/dist/channel.cjs +27 -0
  16. package/dist/channel.cjs.map +1 -0
  17. package/dist/channel.d.cts +64 -0
  18. package/dist/chunk-2RCJBWPO.cjs +1168 -0
  19. package/dist/chunk-2RCJBWPO.cjs.map +1 -0
  20. package/dist/chunk-FTJD2DWE.cjs +42472 -0
  21. package/dist/chunk-FTJD2DWE.cjs.map +1 -0
  22. package/dist/chunk-GRDC6ZRA.cjs +118 -0
  23. package/dist/chunk-GRDC6ZRA.cjs.map +1 -0
  24. package/dist/chunk-GX7NROST.cjs +421 -0
  25. package/dist/chunk-GX7NROST.cjs.map +1 -0
  26. package/dist/chunk-HSVQIFIK.cjs +128 -0
  27. package/dist/chunk-HSVQIFIK.cjs.map +1 -0
  28. package/dist/{chunk-UIFMIVDK.js → chunk-IC3G6YM2.js} +24 -26
  29. package/dist/chunk-IC3G6YM2.js.map +1 -0
  30. package/dist/chunk-JTWY2XEG.cjs +115 -0
  31. package/dist/chunk-JTWY2XEG.cjs.map +1 -0
  32. package/dist/chunk-MRREGCWN.cjs +585 -0
  33. package/dist/chunk-MRREGCWN.cjs.map +1 -0
  34. package/dist/chunk-NT26BDGN.cjs +228 -0
  35. package/dist/chunk-NT26BDGN.cjs.map +1 -0
  36. package/dist/chunk-Q7SFCCGT.cjs +11 -0
  37. package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
  38. package/dist/chunk-QLF7N6H7.cjs +448 -0
  39. package/dist/chunk-QLF7N6H7.cjs.map +1 -0
  40. package/dist/chunk-RNHSA3LO.cjs +108 -0
  41. package/dist/chunk-RNHSA3LO.cjs.map +1 -0
  42. package/dist/chunk-S5IKOOUR.cjs +393 -0
  43. package/dist/chunk-S5IKOOUR.cjs.map +1 -0
  44. package/dist/chunk-TFLZETWB.cjs +4693 -0
  45. package/dist/chunk-TFLZETWB.cjs.map +1 -0
  46. package/dist/chunk-WQREDGUF.cjs +435 -0
  47. package/dist/chunk-WQREDGUF.cjs.map +1 -0
  48. package/dist/chunk-XQROKLZI.cjs +4521 -0
  49. package/dist/chunk-XQROKLZI.cjs.map +1 -0
  50. package/dist/contract-addresses-TANQ5DLX.cjs +49 -0
  51. package/dist/contract-addresses-TANQ5DLX.cjs.map +1 -0
  52. package/dist/core.cjs +894 -0
  53. package/dist/core.cjs.map +1 -0
  54. package/dist/core.d.cts +6930 -0
  55. package/dist/dapp.cjs +289 -0
  56. package/dist/dapp.cjs.map +1 -0
  57. package/dist/dapp.d.cts +127 -0
  58. package/dist/doc-types-471vSmPO.d.cts +16 -0
  59. package/dist/enduser.cjs +24 -0
  60. package/dist/enduser.cjs.map +1 -0
  61. package/dist/enduser.d.cts +261 -0
  62. package/dist/identity.cjs +23 -0
  63. package/dist/identity.cjs.map +1 -0
  64. package/dist/identity.d.cts +81 -0
  65. package/dist/index-B6SfEQxo.d.cts +47 -0
  66. package/dist/index.cjs +2814 -0
  67. package/dist/index.cjs.map +1 -0
  68. package/dist/index.d.cts +656 -0
  69. package/dist/kms.cjs +452 -0
  70. package/dist/kms.cjs.map +1 -0
  71. package/dist/kms.d.cts +3054 -0
  72. package/dist/kms.d.ts +13 -13
  73. package/dist/kms.js +3 -1
  74. package/dist/lib-FE4GR7TO.cjs +1865 -0
  75. package/dist/lib-FE4GR7TO.cjs.map +1 -0
  76. package/dist/operator.cjs +27 -0
  77. package/dist/operator.cjs.map +1 -0
  78. package/dist/operator.d.cts +164 -0
  79. package/dist/paymaster.cjs +63 -0
  80. package/dist/paymaster.cjs.map +1 -0
  81. package/dist/paymaster.d.cts +312 -0
  82. package/dist/src-ENPA7D2S.cjs +63 -0
  83. package/dist/src-ENPA7D2S.cjs.map +1 -0
  84. package/dist/src-TQKEO2I4.cjs +894 -0
  85. package/dist/src-TQKEO2I4.cjs.map +1 -0
  86. package/dist/tier-router-DeeVg69O.d.cts +370 -0
  87. package/dist/tokens.cjs +15 -0
  88. package/dist/tokens.cjs.map +1 -0
  89. package/dist/tokens.d.cts +64 -0
  90. package/dist/x402.cjs +103 -0
  91. package/dist/x402.cjs.map +1 -0
  92. package/dist/x402.d.cts +373 -0
  93. package/package.json +32 -32
  94. package/dist/chunk-UIFMIVDK.js.map +0 -1
@@ -0,0 +1,115 @@
1
+ 'use strict';
2
+
3
+ var chunkFTJD2DWE_cjs = require('./chunk-FTJD2DWE.cjs');
4
+ var viem = require('viem');
5
+
6
+ // ../identity/src/mysbt.ts
7
+ async function checkMySBT(client, sbtAddress, user) {
8
+ const balance = await client.readContract({
9
+ address: sbtAddress,
10
+ abi: chunkFTJD2DWE_cjs.MySBTABI,
11
+ functionName: "balanceOf",
12
+ args: [user]
13
+ });
14
+ return { hasSBT: balance > 0n, balance };
15
+ }
16
+ async function getMySBTId(client, sbtAddress, user) {
17
+ const tokenId = await client.readContract({
18
+ address: sbtAddress,
19
+ abi: chunkFTJD2DWE_cjs.MySBTABI,
20
+ functionName: "getUserSBT",
21
+ args: [user]
22
+ });
23
+ return tokenId > 0n ? tokenId : null;
24
+ }
25
+ var ReputationClient = class {
26
+ /**
27
+ * Initialize ReputationClient
28
+ * @param client The public client for queries
29
+ * @param reputationAddress The address of the reputation system contract
30
+ * @param walletClient Optional wallet client for write operations
31
+ */
32
+ constructor(client, reputationAddress, walletClient) {
33
+ this.client = client;
34
+ this.reputationAddress = reputationAddress;
35
+ this.walletClient = walletClient;
36
+ }
37
+ /** @internal */
38
+ walletClient;
39
+ /**
40
+ * Compute reputation score for a user
41
+ */
42
+ async computeScore(user, communities, ruleIds, activities) {
43
+ return this.client.readContract({
44
+ address: this.reputationAddress,
45
+ abi: chunkFTJD2DWE_cjs.ReputationSystemABI,
46
+ functionName: "computeScore",
47
+ args: [user, communities, ruleIds, activities]
48
+ });
49
+ }
50
+ /**
51
+ * Get global reputation score for a user
52
+ * @param user User address
53
+ * @returns Reputation score
54
+ */
55
+ async getGlobalReputation(user) {
56
+ try {
57
+ const score = await this.computeScore(user, [], [], []);
58
+ return Number(score);
59
+ } catch (e) {
60
+ console.warn("Failed to read reputation from contract, defaulting to 0");
61
+ return 0;
62
+ }
63
+ }
64
+ /**
65
+ * Get credit limit based on reputation
66
+ * @param user User address
67
+ * @returns Credit limit in wei (Mock logic closely tied to Reputation)
68
+ */
69
+ async getCreditLimit(user) {
70
+ const reputation = await this.getGlobalReputation(user);
71
+ let limit = 0n;
72
+ if (reputation > 50) limit += 10000000000000000n;
73
+ if (reputation > 100) limit += 40000000000000000n;
74
+ return limit;
75
+ }
76
+ /**
77
+ * Get reputation score breakdown
78
+ * @param user User address
79
+ * @returns Detailed reputation breakdown (Mock implementation awaiting contract V4)
80
+ */
81
+ async getReputationBreakdown(user) {
82
+ const total = await this.getGlobalReputation(user);
83
+ return {
84
+ baseScore: Math.floor(total * 0.5),
85
+ stakingBonus: Math.floor(total * 0.3),
86
+ activityBonus: Math.floor(total * 0.2),
87
+ penaltyDeduction: 0,
88
+ total
89
+ };
90
+ }
91
+ /**
92
+ * Submit reputation proof (off-chain data to on-chain)
93
+ * @param params Proof parameters
94
+ * @returns Transaction hash
95
+ */
96
+ async submitReputationProof(params) {
97
+ if (!this.walletClient || !this.walletClient.account) {
98
+ throw new Error("Wallet client required to submit proofs");
99
+ }
100
+ return this.walletClient.writeContract({
101
+ address: this.reputationAddress,
102
+ abi: viem.parseAbi(["function submitProof(string,bytes32)"]),
103
+ functionName: "submitProof",
104
+ args: [params.proofData, params.signature],
105
+ chain: this.walletClient.chain,
106
+ account: this.walletClient.account
107
+ });
108
+ }
109
+ };
110
+
111
+ exports.ReputationClient = ReputationClient;
112
+ exports.checkMySBT = checkMySBT;
113
+ exports.getMySBTId = getMySBTId;
114
+ //# sourceMappingURL=chunk-JTWY2XEG.cjs.map
115
+ //# sourceMappingURL=chunk-JTWY2XEG.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../identity/src/mysbt.ts","../../identity/src/index.ts"],"names":["MySBTABI","ReputationSystemABI","parseAbi"],"mappings":";;;;;;AAaA,eAAsB,UAAA,CAClB,MAAA,EACA,UAAA,EACA,IAAA,EAC6C;AAC7C,EAAA,MAAM,OAAA,GAAU,MAAM,MAAA,CAAO,YAAA,CAAa;AAAA,IACtC,OAAA,EAAS,UAAA;AAAA,IACT,GAAA,EAAKA,0BAAA;AAAA,IACL,YAAA,EAAc,WAAA;AAAA,IACd,IAAA,EAAM,CAAC,IAAI;AAAA,GACd,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,OAAA,GAAU,EAAA,EAAI,OAAA,EAAQ;AAC3C;AAYA,eAAsB,UAAA,CAClB,MAAA,EACA,UAAA,EACA,IAAA,EACsB;AACtB,EAAA,MAAM,OAAA,GAAU,MAAM,MAAA,CAAO,YAAA,CAAa;AAAA,IACtC,OAAA,EAAS,UAAA;AAAA,IACT,GAAA,EAAKA,0BAAA;AAAA,IACL,YAAA,EAAc,YAAA;AAAA,IACd,IAAA,EAAM,CAAC,IAAI;AAAA,GACd,CAAA;AAGD,EAAA,OAAO,OAAA,GAAU,KAAK,OAAA,GAAU,IAAA;AACpC;AC9CO,IAAM,mBAAN,MAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU1B,WAAA,CACY,MAAA,EACA,iBAA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;AAAA,EAOA,MAAM,uBAAuB,IAAA,EAM1B;AACC,IAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,CAAK,mBAAA,CAAoB,IAAI,CAAA;AAGjD,IAAA,OAAO;AAAA,MACH,SAAA,EAAW,IAAA,CAAK,KAAA,CAAM,KAAA,GAAQ,GAAG,CAAA;AAAA,MACjC,YAAA,EAAc,IAAA,CAAK,KAAA,CAAM,KAAA,GAAQ,GAAG,CAAA;AAAA,MACpC,aAAA,EAAe,IAAA,CAAK,KAAA,CAAM,KAAA,GAAQ,GAAG,CAAA;AAAA,MACrC,gBAAA,EAAkB,CAAA;AAAA,MAClB;AAAA,KACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,sBAAsB,MAAA,EAIV;AACd,IAAA,IAAI,CAAC,IAAA,CAAK,YAAA,IAAgB,CAAC,IAAA,CAAK,aAAa,OAAA,EAAS;AAClD,MAAA,MAAM,IAAI,MAAM,yCAAyC,CAAA;AAAA,IAC7D;AAIA,IAAA,OAAO,IAAA,CAAK,aAAa,aAAA,CAAc;AAAA,MACnC,SAAS,IAAA,CAAK,iBAAA;AAAA,MACd,GAAA,EAAKC,aAAA,CAAS,CAAC,sCAAsC,CAAC,CAAA;AAAA,MACtD,YAAA,EAAc,aAAA;AAAA,MACd,IAAA,EAAM,CAAC,MAAA,CAAO,SAAA,EAAW,OAAO,SAAS,CAAA;AAAA,MACzC,KAAA,EAAO,KAAK,YAAA,CAAa,KAAA;AAAA,MACzB,OAAA,EAAS,KAAK,YAAA,CAAa;AAAA,KAC9B,CAAA;AAAA,EACL;AACJ","file":"chunk-JTWY2XEG.cjs","sourcesContent":["\nimport { type Address, type PublicClient } from 'viem';\nimport { MySBTABI } from '@aastar/core';\n\n/**\n * Check if user holds MySBT token (identity verification).\n *\n * Does NOT swallow read errors: `balanceOf` returns 0 for a non-holder, so any\n * thrown error is an RPC/transport/contract failure — masking it as\n * `{ hasSBT: false }` would turn a transient RPC blip into a false \"no SBT\" and\n * wrongly fail eligibility checks. The error propagates so the caller can retry\n * or surface \"couldn't determine\" rather than \"no SBT\".\n */\nexport async function checkMySBT(\n client: any,\n sbtAddress: Address,\n user: Address\n): Promise<{ hasSBT: boolean; balance: bigint }> {\n const balance = await client.readContract({\n address: sbtAddress,\n abi: MySBTABI,\n functionName: 'balanceOf',\n args: [user]\n }) as bigint;\n\n return { hasSBT: balance > 0n, balance };\n}\n\n/**\n * Fetch MySBT token ID for a specific user.\n * MySBT exposes `getUserSBT(address) -> uint256` (alias of the `userToSBT`\n * mapping), which returns the user's tokenId or 0 when they hold no SBT.\n *\n * Returns the tokenId, or `null` ONLY for the genuine \"no SBT\" sentinel (id == 0).\n * Read errors are NOT swallowed (see {@link checkMySBT}): a transient RPC failure\n * must not be reported as \"no SBT\" (a false negative for eligibility). The error\n * propagates to the caller.\n */\nexport async function getMySBTId(\n client: any,\n sbtAddress: Address,\n user: Address\n): Promise<bigint | null> {\n const tokenId = await client.readContract({\n address: sbtAddress,\n abi: MySBTABI,\n functionName: 'getUserSBT',\n args: [user]\n }) as bigint;\n\n // tokenId 0 is the contract's sentinel for \"no SBT\" (ids start at 1).\n return tokenId > 0n ? tokenId : null;\n}\n","\nexport * from './mysbt.js';\n\nimport { createAAStarPublicClient, ReputationSystemABI, type PublicClient, type WalletClient } from '@aastar/core';\nimport { type Address, type Hash, parseAbi } from 'viem';\n\nexport class ReputationClient {\n /** @internal */\n private walletClient?: WalletClient;\n\n /**\n * Initialize ReputationClient\n * @param client The public client for queries\n * @param reputationAddress The address of the reputation system contract\n * @param walletClient Optional wallet client for write operations\n */\n constructor(\n private client: PublicClient, \n private reputationAddress: Address,\n walletClient?: WalletClient\n ) {\n this.walletClient = walletClient;\n }\n\n /**\n * Compute reputation score for a user\n */\n async computeScore(user: Address, communities: Address[], ruleIds: `0x${string}`[][], activities: bigint[][]): Promise<bigint> {\n return this.client.readContract({\n address: this.reputationAddress,\n abi: ReputationSystemABI as any,\n functionName: 'computeScore',\n args: [user, communities, ruleIds, activities]\n }) as Promise<bigint>;\n }\n\n /**\n * Get global reputation score for a user\n * @param user User address\n * @returns Reputation score\n */\n async getGlobalReputation(user: Address): Promise<number> {\n // Try to read score, if fails (e.g. invalid contract), return 0\n try {\n const score = await this.computeScore(user, [], [], []);\n return Number(score);\n } catch (e) {\n console.warn('Failed to read reputation from contract, defaulting to 0');\n return 0;\n }\n }\n\n /**\n * Get credit limit based on reputation\n * @param user User address\n * @returns Credit limit in wei (Mock logic closely tied to Reputation)\n */\n async getCreditLimit(user: Address): Promise<bigint> {\n const reputation = await this.getGlobalReputation(user);\n \n // Dynamic Credit Limit Logic:\n // Base: 0\n // Score > 50: +0.01 ETH\n // Score > 100: +0.05 ETH\n let limit = 0n;\n if (reputation > 50) limit += 10000000000000000n; // 0.01 ETH\n if (reputation > 100) limit += 40000000000000000n; // +0.04 -> 0.05 ETH\n\n return limit;\n }\n\n /**\n * Get reputation score breakdown\n * @param user User address\n * @returns Detailed reputation breakdown (Mock implementation awaiting contract V4)\n */\n async getReputationBreakdown(user: Address): Promise<{\n baseScore: number;\n stakingBonus: number;\n activityBonus: number;\n penaltyDeduction: number;\n total: number;\n }> {\n const total = await this.getGlobalReputation(user);\n \n // Heuristic breakdown\n return {\n baseScore: Math.floor(total * 0.5),\n stakingBonus: Math.floor(total * 0.3),\n activityBonus: Math.floor(total * 0.2),\n penaltyDeduction: 0,\n total\n };\n }\n\n /**\n * Submit reputation proof (off-chain data to on-chain)\n * @param params Proof parameters\n * @returns Transaction hash\n */\n async submitReputationProof(params: {\n proofType: 'github' | 'twitter' | 'on-chain-activity';\n proofData: string;\n signature: Hash;\n }): Promise<Hash> {\n if (!this.walletClient || !this.walletClient.account) {\n throw new Error(\"Wallet client required to submit proofs\");\n }\n\n // Using a generic 'submitProof' signature for now\n // In reality this would target the ReputationOracle or similar\n return this.walletClient.writeContract({\n address: this.reputationAddress,\n abi: parseAbi(['function submitProof(string,bytes32)']),\n functionName: 'submitProof',\n args: [params.proofData, params.signature],\n chain: this.walletClient.chain,\n account: this.walletClient.account\n });\n }\n}\n"]}