@aastar/sdk 0.20.8 → 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 (88) 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/channel-CkRRbzT8.d.cts +77 -0
  14. package/dist/channel.cjs +27 -0
  15. package/dist/channel.cjs.map +1 -0
  16. package/dist/channel.d.cts +64 -0
  17. package/dist/chunk-2RCJBWPO.cjs +1168 -0
  18. package/dist/chunk-2RCJBWPO.cjs.map +1 -0
  19. package/dist/chunk-FTJD2DWE.cjs +42472 -0
  20. package/dist/chunk-FTJD2DWE.cjs.map +1 -0
  21. package/dist/chunk-GRDC6ZRA.cjs +118 -0
  22. package/dist/chunk-GRDC6ZRA.cjs.map +1 -0
  23. package/dist/chunk-GX7NROST.cjs +421 -0
  24. package/dist/chunk-GX7NROST.cjs.map +1 -0
  25. package/dist/chunk-HSVQIFIK.cjs +128 -0
  26. package/dist/chunk-HSVQIFIK.cjs.map +1 -0
  27. package/dist/chunk-JTWY2XEG.cjs +115 -0
  28. package/dist/chunk-JTWY2XEG.cjs.map +1 -0
  29. package/dist/chunk-MRREGCWN.cjs +585 -0
  30. package/dist/chunk-MRREGCWN.cjs.map +1 -0
  31. package/dist/chunk-NT26BDGN.cjs +228 -0
  32. package/dist/chunk-NT26BDGN.cjs.map +1 -0
  33. package/dist/chunk-Q7SFCCGT.cjs +11 -0
  34. package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
  35. package/dist/chunk-QLF7N6H7.cjs +448 -0
  36. package/dist/chunk-QLF7N6H7.cjs.map +1 -0
  37. package/dist/chunk-RNHSA3LO.cjs +108 -0
  38. package/dist/chunk-RNHSA3LO.cjs.map +1 -0
  39. package/dist/chunk-S5IKOOUR.cjs +393 -0
  40. package/dist/chunk-S5IKOOUR.cjs.map +1 -0
  41. package/dist/chunk-TFLZETWB.cjs +4693 -0
  42. package/dist/chunk-TFLZETWB.cjs.map +1 -0
  43. package/dist/chunk-WQREDGUF.cjs +435 -0
  44. package/dist/chunk-WQREDGUF.cjs.map +1 -0
  45. package/dist/chunk-XQROKLZI.cjs +4521 -0
  46. package/dist/chunk-XQROKLZI.cjs.map +1 -0
  47. package/dist/contract-addresses-TANQ5DLX.cjs +49 -0
  48. package/dist/contract-addresses-TANQ5DLX.cjs.map +1 -0
  49. package/dist/core.cjs +894 -0
  50. package/dist/core.cjs.map +1 -0
  51. package/dist/core.d.cts +6930 -0
  52. package/dist/dapp.cjs +289 -0
  53. package/dist/dapp.cjs.map +1 -0
  54. package/dist/dapp.d.cts +127 -0
  55. package/dist/doc-types-471vSmPO.d.cts +16 -0
  56. package/dist/enduser.cjs +24 -0
  57. package/dist/enduser.cjs.map +1 -0
  58. package/dist/enduser.d.cts +261 -0
  59. package/dist/identity.cjs +23 -0
  60. package/dist/identity.cjs.map +1 -0
  61. package/dist/identity.d.cts +81 -0
  62. package/dist/index-B6SfEQxo.d.cts +47 -0
  63. package/dist/index.cjs +2814 -0
  64. package/dist/index.cjs.map +1 -0
  65. package/dist/index.d.cts +656 -0
  66. package/dist/kms.cjs +452 -0
  67. package/dist/kms.cjs.map +1 -0
  68. package/dist/kms.d.cts +3054 -0
  69. package/dist/lib-FE4GR7TO.cjs +1865 -0
  70. package/dist/lib-FE4GR7TO.cjs.map +1 -0
  71. package/dist/operator.cjs +27 -0
  72. package/dist/operator.cjs.map +1 -0
  73. package/dist/operator.d.cts +164 -0
  74. package/dist/paymaster.cjs +63 -0
  75. package/dist/paymaster.cjs.map +1 -0
  76. package/dist/paymaster.d.cts +312 -0
  77. package/dist/src-ENPA7D2S.cjs +63 -0
  78. package/dist/src-ENPA7D2S.cjs.map +1 -0
  79. package/dist/src-TQKEO2I4.cjs +894 -0
  80. package/dist/src-TQKEO2I4.cjs.map +1 -0
  81. package/dist/tier-router-DeeVg69O.d.cts +370 -0
  82. package/dist/tokens.cjs +15 -0
  83. package/dist/tokens.cjs.map +1 -0
  84. package/dist/tokens.d.cts +64 -0
  85. package/dist/x402.cjs +103 -0
  86. package/dist/x402.cjs.map +1 -0
  87. package/dist/x402.d.cts +373 -0
  88. package/package.json +32 -32
@@ -0,0 +1,128 @@
1
+ 'use strict';
2
+
3
+ var chunkFTJD2DWE_cjs = require('./chunk-FTJD2DWE.cjs');
4
+ var viem = require('viem');
5
+ var accounts = require('viem/accounts');
6
+
7
+ var createEOAWalletClient = (privateKey, chain, transport = viem.http()) => {
8
+ const account = accounts.privateKeyToAccount(privateKey);
9
+ const client = viem.createWalletClient({
10
+ account,
11
+ chain,
12
+ transport
13
+ });
14
+ return Object.assign(client, {
15
+ async sendTransaction(args) {
16
+ return client.sendTransaction({
17
+ ...args,
18
+ account,
19
+ chain
20
+ });
21
+ },
22
+ getAddress: () => account.address
23
+ });
24
+ };
25
+ function packUserOpLimits(high, low) {
26
+ return `0x${(high << 128n | low).toString(16).padStart(64, "0")}`;
27
+ }
28
+ function getUserOpHash(op, ep, chainId) {
29
+ const packed = viem.encodeAbiParameters(
30
+ [
31
+ { type: "address" },
32
+ { type: "uint256" },
33
+ { type: "bytes32" },
34
+ { type: "bytes32" },
35
+ { type: "bytes32" },
36
+ { type: "uint256" },
37
+ { type: "bytes32" },
38
+ { type: "bytes32" }
39
+ ],
40
+ [
41
+ op.sender,
42
+ BigInt(op.nonce),
43
+ viem.keccak256(op.initCode && op.initCode !== "0x" ? op.initCode : "0x"),
44
+ viem.keccak256(op.callData),
45
+ op.accountGasLimits,
46
+ BigInt(op.preVerificationGas),
47
+ op.gasFees,
48
+ viem.keccak256(op.paymasterAndData)
49
+ ]
50
+ );
51
+ const enc = viem.encodeAbiParameters(
52
+ [{ type: "bytes32" }, { type: "address" }, { type: "uint256" }],
53
+ [viem.keccak256(packed), ep, BigInt(chainId)]
54
+ );
55
+ return viem.keccak256(enc);
56
+ }
57
+ var UserOpClient = class {
58
+ static async estimateGas(bundler, op, entryPoint) {
59
+ return bundler.request({
60
+ method: "eth_estimateUserOperationGas",
61
+ params: [op, entryPoint]
62
+ });
63
+ }
64
+ static async sendUserOp(bundler, op, entryPoint) {
65
+ return bundler.request({
66
+ method: "eth_sendUserOperation",
67
+ params: [op, entryPoint]
68
+ });
69
+ }
70
+ static async getReceipt(bundler, hash) {
71
+ return bundler.request({
72
+ method: "eth_getUserOperationReceipt",
73
+ params: [hash]
74
+ });
75
+ }
76
+ };
77
+
78
+ // ../account/src/accounts/simple.ts
79
+ async function toSimpleSmartAccount(parameters) {
80
+ const { client, owner, factoryAddress, entryPoint, index = 0n, salt = 0n } = parameters;
81
+ const factoryData = viem.encodeFunctionData({
82
+ abi: chunkFTJD2DWE_cjs.SimpleAccountFactoryABI,
83
+ functionName: "createAccount",
84
+ args: [owner.address, salt]
85
+ });
86
+ const initCode = viem.concatHex([factoryAddress, factoryData]);
87
+ const address = await client.readContract({
88
+ address: factoryAddress,
89
+ abi: chunkFTJD2DWE_cjs.SimpleAccountFactoryABI,
90
+ functionName: "getAddress",
91
+ args: [owner.address, salt]
92
+ });
93
+ return {
94
+ address,
95
+ publicKey: owner.address,
96
+ source: "custom",
97
+ type: "local",
98
+ entryPoint: entryPoint.address,
99
+ async signMessage({ message }) {
100
+ return owner.signMessage({ message });
101
+ },
102
+ async signTypedData(typedData) {
103
+ return owner.signTypedData(typedData);
104
+ },
105
+ async signTransaction(transaction) {
106
+ throw new Error("Smart Accounts cannot sign transactions directly. Use UserOperations.");
107
+ },
108
+ async signUserOperation(userOp) {
109
+ const chainId = client.chain?.id || 31337;
110
+ const hash = getUserOpHash(userOp, entryPoint.address, chainId);
111
+ return owner.signMessage({ message: { raw: hash } });
112
+ },
113
+ async getInitCode() {
114
+ return initCode;
115
+ },
116
+ async getDummySignature() {
117
+ return "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
118
+ }
119
+ };
120
+ }
121
+
122
+ exports.UserOpClient = UserOpClient;
123
+ exports.createEOAWalletClient = createEOAWalletClient;
124
+ exports.getUserOpHash = getUserOpHash;
125
+ exports.packUserOpLimits = packUserOpLimits;
126
+ exports.toSimpleSmartAccount = toSimpleSmartAccount;
127
+ //# sourceMappingURL=chunk-HSVQIFIK.cjs.map
128
+ //# sourceMappingURL=chunk-HSVQIFIK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../account/src/eoa.ts","../../account/src/index.ts","../../account/src/accounts/simple.ts"],"names":["http","privateKeyToAccount","createWalletClient","encodeAbiParameters","keccak256","encodeFunctionData","SimpleAccountFactoryABI","concatHex"],"mappings":";;;;;;AAQO,IAAM,wBAAwB,CACjC,UAAA,EACA,KAAA,EACA,SAAA,GAAuBA,WAAK,KACV;AAClB,EAAA,MAAM,OAAA,GAAUC,6BAAoB,UAAU,CAAA;AAC9C,EAAA,MAAM,SAASC,uBAAA,CAAmB;AAAA,IAC9B,OAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACH,CAAA;AAED,EAAA,OAAO,MAAA,CAAO,OAAO,MAAA,EAAQ;AAAA,IACzB,MAAM,gBAAgB,IAAA,EAAmD;AACrE,MAAA,OAAO,OAAO,eAAA,CAAgB;AAAA,QAC1B,GAAG,IAAA;AAAA,QACH,OAAA;AAAA,QACA;AAAA,OACH,CAAA;AAAA,IACL,CAAA;AAAA,IACA,UAAA,EAAY,MAAM,OAAA,CAAQ;AAAA,GAC7B,CAAA;AACL;ACtBO,SAAS,gBAAA,CAAiB,MAAc,GAAA,EAAk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A;AAAA,IACL,YAAA,EAAc,YAAA;AAAA,IACd,IAAA,EAAM,CAAC,KAAA,CAAM,OAAA,EAAS,IAAI;AAAA,GAC9B,CAAA;AAED,EAAA,OAAO;AAAA,IACH,OAAA;AAAA,IACA,WAAW,KAAA,CAAM,OAAA;AAAA,IACjB,MAAA,EAAQ,QAAA;AAAA,IACR,IAAA,EAAM,OAAA;AAAA,IACN,YAAY,UAAA,CAAW,OAAA;AAAA,IAEvB,MAAM,WAAA,CAAY,EAAE,OAAA,EAAQ,EAA+C;AAGvE,MAAA,OAAO,KAAA,CAAM,WAAA,CAAY,EAAE,OAAA,EAAS,CAAA;AAAA,IACxC,CAAA;AAAA,IAEA,MAAM,cAAc,SAAA,EAA8C;AAC9D,MAAA,OAAO,KAAA,CAAM,cAAc,SAAS,CAAA;AAAA,IACxC,CAAA;AAAA,IAEA,MAAM,gBAAgB,WAAA,EAAgC;AAClD,MAAA,MAAM,IAAI,MAAM,uEAAuE,CAAA;AAAA,IAC3F,CAAA;AAAA,IAEA,MAAM,kBAAkB,MAAA,EAA2B;AAC/C,MAAA,MAAM,OAAA,GAAU,MAAA,CAAO,KAAA,EAAO,EAAA,IAAM,KAAA;AACpC,MAAA,MAAM,IAAA,GAAO,aAAA,CAAc,MAAA,EAAQ,UAAA,CAAW,SAAS,OAAO,CAAA;AAC9D,MAAA,OAAO,KAAA,CAAM,YAAY,EAAE,OAAA,EAAS,EAAE,GAAA,EAAK,IAAA,IAAQ,CAAA;AAAA,IACvD,CAAA;AAAA,IAEA,MAAM,WAAA,GAAc;AAChB,MAAA,OAAO,QAAA;AAAA,IACX,CAAA;AAAA,IAEA,MAAM,iBAAA,GAAoB;AACtB,MAAA,OAAO,8IAAA;AAAA,IACX;AAAA,GAEJ;AACJ","file":"chunk-HSVQIFIK.cjs","sourcesContent":["import { type WalletClient, type PublicClient, type Address, type Chain, type Transport, type Hash, type Hex, createWalletClient, http } from 'viem';\nimport { privateKeyToAccount } from 'viem/accounts';\n\nexport type EOAWalletClient = WalletClient & {\n sendTransaction: (args: { to: Address, value?: bigint, data?: Hex }) => Promise<Hash>;\n getAddress: () => Address;\n};\n\nexport const createEOAWalletClient = (\n privateKey: Hex, \n chain: Chain, \n transport: Transport = http()\n): EOAWalletClient => {\n const account = privateKeyToAccount(privateKey);\n const client = createWalletClient({\n account,\n chain,\n transport\n });\n\n return Object.assign(client, {\n async sendTransaction(args: { to: Address, value?: bigint, data?: Hex }) {\n return client.sendTransaction({\n ...args,\n account,\n chain\n });\n },\n getAddress: () => account.address\n }) as EOAWalletClient;\n};\n","import { type Hex, type Address, encodeAbiParameters, keccak256 } from 'viem';\n\nexport * from './eoa.js';\nexport * from './accounts/simple.js';\n\n/**\n * Common Pack Logic for v0.7 UserOperations\n */\nexport function packUserOpLimits(high: bigint, low: bigint): Hex {\n return `0x${((high << 128n) | low).toString(16).padStart(64, '0')}` as Hex;\n}\n\n/**\n * Local implementation of EntryPoint v0.7 getUserOpHash\n */\nexport function getUserOpHash(op: any, ep: Address, chainId: number): Hex {\n const packed = encodeAbiParameters(\n [\n { type: 'address' }, { type: 'uint256' }, { type: 'bytes32' }, { type: 'bytes32' },\n { type: 'bytes32' }, { type: 'uint256' }, { type: 'bytes32' }, { type: 'bytes32' }\n ],\n [\n op.sender, BigInt(op.nonce), \n keccak256(op.initCode && op.initCode !== \"0x\" ? op.initCode : '0x'), \n keccak256(op.callData),\n op.accountGasLimits, BigInt(op.preVerificationGas), op.gasFees,\n keccak256(op.paymasterAndData)\n ]\n );\n const enc = encodeAbiParameters(\n [{ type: 'bytes32' }, { type: 'address' }, { type: 'uint256' }],\n [keccak256(packed), ep, BigInt(chainId)]\n );\n return keccak256(enc);\n}\n\n/**\n * UserOperation Client for handling high-level flows\n */\nexport class UserOpClient {\n static async estimateGas(bundler: any, op: any, entryPoint: Address) {\n return bundler.request({\n method: 'eth_estimateUserOperationGas',\n params: [op, entryPoint]\n });\n }\n\n static async sendUserOp(bundler: any, op: any, entryPoint: Address) {\n return bundler.request({\n method: 'eth_sendUserOperation',\n params: [op, entryPoint]\n });\n }\n\n static async getReceipt(bundler: any, hash: Hex) {\n return bundler.request({\n method: 'eth_getUserOperationReceipt',\n params: [hash]\n });\n }\n}\n","import { \n type Address, \n type Hex, \n type LocalAccount, \n type SignableMessage, \n type TypedDataDefinition,\n type Hash,\n concatHex, \n encodeFunctionData, \n keccak256,\n} from 'viem';\nimport { SimpleAccountFactoryABI, type PublicClient } from '@aastar/core';\nimport { getUserOpHash } from '../index.js';\n\nexport type SimpleSmartAccount = LocalAccount & {\n signUserOperation: (userOp: any) => Promise<Hex>;\n getInitCode: () => Promise<Hex>;\n getDummySignature: () => Promise<Hex>;\n entryPoint: Address;\n};\n\nexport async function toSimpleSmartAccount(parameters: {\n client: any;\n owner: LocalAccount;\n factoryAddress: Address;\n entryPoint: { address: Address; version: '0.6' | '0.7' };\n salt?: bigint;\n index?: bigint;\n}): Promise<SimpleSmartAccount> {\n const { client, owner, factoryAddress, entryPoint, index = 0n, salt = 0n } = parameters;\n \n // Calculate initCode\n const factoryData = encodeFunctionData({\n abi: SimpleAccountFactoryABI,\n functionName: 'createAccount',\n args: [owner.address, salt]\n });\n const initCode = concatHex([factoryAddress, factoryData]);\n\n // Calculate counterfactual address\n const address = await client.readContract({\n address: factoryAddress,\n abi: SimpleAccountFactoryABI,\n functionName: 'getAddress',\n args: [owner.address, salt]\n });\n\n return {\n address,\n publicKey: owner.address,\n source: 'custom', \n type: 'local',\n entryPoint: entryPoint.address,\n \n async signMessage({ message }: { message: SignableMessage }): Promise<Hex> {\n // validating signature for smart account usually involves EIP-1271, \n // but here we just sign with owner for SimpleAccount which validates owner sig\n return owner.signMessage({ message });\n },\n\n async signTypedData(typedData: TypedDataDefinition): Promise<Hex> {\n return owner.signTypedData(typedData);\n },\n\n async signTransaction(transaction: any): Promise<Hex> {\n throw new Error('Smart Accounts cannot sign transactions directly. Use UserOperations.');\n },\n \n async signUserOperation(userOp: any): Promise<Hex> {\n const chainId = client.chain?.id || 31337; // Default to local anvil if not found\n const hash = getUserOpHash(userOp, entryPoint.address, chainId);\n return owner.signMessage({ message: { raw: hash } });\n },\n \n async getInitCode() {\n return initCode;\n },\n\n async getDummySignature() {\n return '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';\n }\n\n } as any as SimpleSmartAccount;\n}\n"]}
@@ -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 @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rC,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"]}