@aastar/sdk 0.16.8 → 0.16.12

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 (187) hide show
  1. package/README.md +21 -0
  2. package/dist/clients/admin.d.ts +11 -0
  3. package/dist/clients/admin.js +20 -0
  4. package/dist/{sdk/src/clients → clients}/community.d.ts +4 -12
  5. package/dist/clients/community.js +300 -0
  6. package/dist/{sdk/src/clients → clients}/endUser.d.ts +5 -23
  7. package/dist/clients/endUser.js +298 -0
  8. package/dist/{sdk/src/clients → clients}/operator.d.ts +8 -38
  9. package/dist/{sdk/src/clients → clients}/operator.js +76 -114
  10. package/dist/errors/decoder.d.ts +6 -0
  11. package/dist/errors/decoder.js +44 -0
  12. package/dist/index.d.ts +18 -0
  13. package/dist/index.js +21 -0
  14. package/dist/{sdk/src/utils → utils}/keys.d.ts +0 -12
  15. package/dist/{sdk/src/utils → utils}/keys.js +0 -7
  16. package/dist/{sdk/src/utils → utils}/roleData.js +28 -15
  17. package/dist/{sdk/src/utils → utils}/testScenarios.js +1 -1
  18. package/dist/{sdk/src/utils → utils}/userOp.js +3 -8
  19. package/package.json +11 -25
  20. package/dist/account/src/accounts/simple.d.ts +0 -18
  21. package/dist/account/src/accounts/simple.js +0 -49
  22. package/dist/account/src/eoa.d.ts +0 -10
  23. package/dist/account/src/eoa.js +0 -21
  24. package/dist/account/src/index.d.ts +0 -19
  25. package/dist/account/src/index.js +0 -49
  26. package/dist/core/src/abis/index.d.ts +0 -1126
  27. package/dist/core/src/abis/index.js +0 -91
  28. package/dist/core/src/actions/StateValidator.d.ts +0 -68
  29. package/dist/core/src/actions/StateValidator.js +0 -187
  30. package/dist/core/src/actions/account.d.ts +0 -55
  31. package/dist/core/src/actions/account.js +0 -133
  32. package/dist/core/src/actions/aggregator.d.ts +0 -17
  33. package/dist/core/src/actions/aggregator.js +0 -31
  34. package/dist/core/src/actions/dvt.d.ts +0 -30
  35. package/dist/core/src/actions/dvt.js +0 -41
  36. package/dist/core/src/actions/entryPoint.d.ts +0 -90
  37. package/dist/core/src/actions/entryPoint.js +0 -211
  38. package/dist/core/src/actions/factory.d.ts +0 -215
  39. package/dist/core/src/actions/factory.js +0 -442
  40. package/dist/core/src/actions/faucet.d.ts +0 -48
  41. package/dist/core/src/actions/faucet.js +0 -337
  42. package/dist/core/src/actions/gtokenExtended.d.ts +0 -39
  43. package/dist/core/src/actions/gtokenExtended.js +0 -115
  44. package/dist/core/src/actions/index.d.ts +0 -15
  45. package/dist/core/src/actions/index.js +0 -17
  46. package/dist/core/src/actions/paymasterV4.d.ts +0 -170
  47. package/dist/core/src/actions/paymasterV4.js +0 -334
  48. package/dist/core/src/actions/registry.d.ts +0 -246
  49. package/dist/core/src/actions/registry.js +0 -667
  50. package/dist/core/src/actions/reputation.d.ts +0 -129
  51. package/dist/core/src/actions/reputation.js +0 -281
  52. package/dist/core/src/actions/sbt.d.ts +0 -191
  53. package/dist/core/src/actions/sbt.js +0 -533
  54. package/dist/core/src/actions/staking.d.ts +0 -132
  55. package/dist/core/src/actions/staking.js +0 -330
  56. package/dist/core/src/actions/superPaymaster.d.ts +0 -237
  57. package/dist/core/src/actions/superPaymaster.js +0 -644
  58. package/dist/core/src/actions/tokens.d.ts +0 -229
  59. package/dist/core/src/actions/tokens.js +0 -415
  60. package/dist/core/src/branding.d.ts +0 -30
  61. package/dist/core/src/branding.js +0 -30
  62. package/dist/core/src/clients/BaseClient.d.ts +0 -25
  63. package/dist/core/src/clients/BaseClient.js +0 -66
  64. package/dist/core/src/clients/types.d.ts +0 -60
  65. package/dist/core/src/clients/types.js +0 -1
  66. package/dist/core/src/clients.d.ts +0 -5
  67. package/dist/core/src/clients.js +0 -11
  68. package/dist/core/src/communities.d.ts +0 -52
  69. package/dist/core/src/communities.js +0 -73
  70. package/dist/core/src/config/ContractConfigManager.d.ts +0 -20
  71. package/dist/core/src/config/ContractConfigManager.js +0 -48
  72. package/dist/core/src/constants.d.ts +0 -88
  73. package/dist/core/src/constants.js +0 -125
  74. package/dist/core/src/contract-addresses.d.ts +0 -110
  75. package/dist/core/src/contract-addresses.js +0 -99
  76. package/dist/core/src/contracts.d.ts +0 -424
  77. package/dist/core/src/contracts.js +0 -343
  78. package/dist/core/src/crypto/blsSigner.d.ts +0 -64
  79. package/dist/core/src/crypto/blsSigner.js +0 -98
  80. package/dist/core/src/crypto/index.d.ts +0 -1
  81. package/dist/core/src/crypto/index.js +0 -1
  82. package/dist/core/src/index.d.ts +0 -21
  83. package/dist/core/src/index.js +0 -21
  84. package/dist/core/src/networks.d.ts +0 -127
  85. package/dist/core/src/networks.js +0 -118
  86. package/dist/core/src/requirementChecker.d.ts +0 -38
  87. package/dist/core/src/requirementChecker.js +0 -139
  88. package/dist/core/src/roles.d.ts +0 -204
  89. package/dist/core/src/roles.js +0 -211
  90. package/dist/core/src/utils/validation.d.ts +0 -24
  91. package/dist/core/src/utils/validation.js +0 -56
  92. package/dist/dapp/src/index.d.ts +0 -3
  93. package/dist/dapp/src/index.js +0 -3
  94. package/dist/dapp/src/ui/hooks/useCreditScore.d.ts +0 -13
  95. package/dist/dapp/src/ui/hooks/useCreditScore.js +0 -32
  96. package/dist/dapp/src/ui/hooks/useSuperPaymaster.d.ts +0 -8
  97. package/dist/dapp/src/ui/hooks/useSuperPaymaster.js +0 -23
  98. package/dist/dapp/src/ui/index.d.ts +0 -4
  99. package/dist/dapp/src/ui/index.js +0 -17
  100. package/dist/identity/src/index.d.ts +0 -46
  101. package/dist/identity/src/index.js +0 -94
  102. package/dist/identity/src/mysbt.d.ts +0 -13
  103. package/dist/identity/src/mysbt.js +0 -37
  104. package/dist/paymaster/src/SuperPaymaster/index.d.ts +0 -44
  105. package/dist/paymaster/src/SuperPaymaster/index.js +0 -133
  106. package/dist/paymaster/src/V4/PaymasterClient.d.ts +0 -79
  107. package/dist/paymaster/src/V4/PaymasterClient.js +0 -315
  108. package/dist/paymaster/src/V4/PaymasterOperator.d.ts +0 -41
  109. package/dist/paymaster/src/V4/PaymasterOperator.js +0 -241
  110. package/dist/paymaster/src/V4/PaymasterUtils.d.ts +0 -55
  111. package/dist/paymaster/src/V4/PaymasterUtils.js +0 -124
  112. package/dist/paymaster/src/V4/SuperPaymasterClient.d.ts +0 -21
  113. package/dist/paymaster/src/V4/SuperPaymasterClient.js +0 -73
  114. package/dist/paymaster/src/V4/index.d.ts +0 -4
  115. package/dist/paymaster/src/V4/index.js +0 -4
  116. package/dist/paymaster/src/index.d.ts +0 -2
  117. package/dist/paymaster/src/index.js +0 -4
  118. package/dist/sdk/src/clients/admin.d.ts +0 -57
  119. package/dist/sdk/src/clients/admin.js +0 -105
  120. package/dist/sdk/src/clients/community.js +0 -244
  121. package/dist/sdk/src/clients/endUser.js +0 -388
  122. package/dist/sdk/src/errors/decoder.d.ts +0 -1
  123. package/dist/sdk/src/errors/decoder.js +0 -83
  124. package/dist/sdk/src/index.d.ts +0 -16
  125. package/dist/sdk/src/index.js +0 -20
  126. package/dist/tokens/src/index.d.ts +0 -56
  127. package/dist/tokens/src/index.js +0 -230
  128. package/examples/config.json +0 -1
  129. package/examples/regression_test.d.ts +0 -2
  130. package/examples/regression_test.d.ts.map +0 -1
  131. package/examples/regression_test.js +0 -89
  132. package/examples/regression_test.js.map +0 -1
  133. package/examples/regression_test.ts +0 -106
  134. package/scripts/v2_regression/00_validate_env.ts +0 -101
  135. package/scripts/v2_regression/01_setup_and_fund.ts +0 -132
  136. package/scripts/v2_regression/02_operator_onboarding.ts +0 -174
  137. package/scripts/v2_regression/03_community_registry.ts +0 -139
  138. package/scripts/v2_regression/04_enduser_flow.ts +0 -141
  139. package/scripts/v2_regression/05_admin_audit.ts +0 -157
  140. package/scripts/validate_env.ts +0 -112
  141. /package/dist/{sdk/src/clients → clients}/ExperimentClient.d.ts +0 -0
  142. /package/dist/{sdk/src/clients → clients}/ExperimentClient.js +0 -0
  143. /package/dist/{sdk/src/clients → clients}/ExperimentClient.test.d.ts +0 -0
  144. /package/dist/{sdk/src/clients → clients}/ExperimentClient.test.js +0 -0
  145. /package/dist/{sdk/src/clients → clients}/admin.test.d.ts +0 -0
  146. /package/dist/{sdk/src/clients → clients}/admin.test.js +0 -0
  147. /package/dist/{sdk/src/clients → clients}/clients.test.d.ts +0 -0
  148. /package/dist/{sdk/src/clients → clients}/clients.test.js +0 -0
  149. /package/dist/{sdk/src/clients → clients}/community.test.d.ts +0 -0
  150. /package/dist/{sdk/src/clients → clients}/community.test.js +0 -0
  151. /package/dist/{sdk/src/clients → clients}/endUser.test.d.ts +0 -0
  152. /package/dist/{sdk/src/clients → clients}/endUser.test.js +0 -0
  153. /package/dist/{sdk/src/clients → clients}/operator.test.d.ts +0 -0
  154. /package/dist/{sdk/src/clients → clients}/operator.test.js +0 -0
  155. /package/dist/{sdk/src/errors → errors}/AAStarError.d.ts +0 -0
  156. /package/dist/{sdk/src/errors → errors}/AAStarError.js +0 -0
  157. /package/dist/{sdk/src/errors → errors}/AAStarError.test.d.ts +0 -0
  158. /package/dist/{sdk/src/errors → errors}/AAStarError.test.js +0 -0
  159. /package/dist/{sdk/src/errors → errors}/decoder.test.d.ts +0 -0
  160. /package/dist/{sdk/src/errors → errors}/decoder.test.js +0 -0
  161. /package/dist/{sdk/src/node → node}/index.d.ts +0 -0
  162. /package/dist/{sdk/src/node → node}/index.js +0 -0
  163. /package/dist/{sdk/src/types → types}/result.d.ts +0 -0
  164. /package/dist/{sdk/src/types → types}/result.js +0 -0
  165. /package/dist/{sdk/src/utils → utils}/errorHandler.d.ts +0 -0
  166. /package/dist/{sdk/src/utils → utils}/errorHandler.js +0 -0
  167. /package/dist/{sdk/src/utils → utils}/errorHandler.test.d.ts +0 -0
  168. /package/dist/{sdk/src/utils → utils}/errorHandler.test.js +0 -0
  169. /package/dist/{sdk/src/utils → utils}/eventDecoder.d.ts +0 -0
  170. /package/dist/{sdk/src/utils → utils}/eventDecoder.js +0 -0
  171. /package/dist/{sdk/src/utils → utils}/eventDecoder.test.d.ts +0 -0
  172. /package/dist/{sdk/src/utils → utils}/eventDecoder.test.js +0 -0
  173. /package/dist/{sdk/src/utils → utils}/funding.d.ts +0 -0
  174. /package/dist/{sdk/src/utils → utils}/funding.js +0 -0
  175. /package/dist/{sdk/src/utils → utils}/funding.test.d.ts +0 -0
  176. /package/dist/{sdk/src/utils → utils}/funding.test.js +0 -0
  177. /package/dist/{sdk/src/utils → utils}/keys.test.d.ts +0 -0
  178. /package/dist/{sdk/src/utils → utils}/keys.test.js +0 -0
  179. /package/dist/{sdk/src/utils → utils}/roleData.d.ts +0 -0
  180. /package/dist/{sdk/src/utils → utils}/roleData.test.d.ts +0 -0
  181. /package/dist/{sdk/src/utils → utils}/roleData.test.js +0 -0
  182. /package/dist/{sdk/src/utils → utils}/testScenarios.d.ts +0 -0
  183. /package/dist/{sdk/src/utils → utils}/testScenarios.test.d.ts +0 -0
  184. /package/dist/{sdk/src/utils → utils}/testScenarios.test.js +0 -0
  185. /package/dist/{sdk/src/utils → utils}/userOp.d.ts +0 -0
  186. /package/dist/{sdk/src/utils → utils}/userOp.test.d.ts +0 -0
  187. /package/dist/{sdk/src/utils → utils}/userOp.test.js +0 -0
@@ -1,230 +0,0 @@
1
- import { parseAbi, formatEther } from 'viem';
2
- import { SuperPaymasterABI as SUPERPAYMASTER_ABI } from '@aastar/core';
3
- // Re-export low-level token APIs from @aastar/core for developer convenience
4
- export { tokenActions, gTokenActions,
5
- // ABIs
6
- GTokenABI, xPNTsTokenABI, xPNTsFactoryABI,
7
- // Actions
8
- xPNTsFactoryActions,
9
- // Addresses
10
- CORE_ADDRESSES } from '@aastar/core';
11
- const STAKING_ABI = parseAbi([
12
- 'function stake(uint256)',
13
- 'function withdraw(uint256)'
14
- ]);
15
- const ERC20_ABI = parseAbi([
16
- 'function balanceOf(address) view returns (uint256)',
17
- 'function totalSupply() view returns (uint256)',
18
- 'function approve(address,uint256) returns (bool)',
19
- 'function transfer(address,uint256) returns (bool)'
20
- ]);
21
- export class FinanceClient {
22
- publicClient;
23
- walletClient;
24
- constructor(publicClient, walletClient) {
25
- this.publicClient = publicClient;
26
- this.walletClient = walletClient;
27
- }
28
- // ========== Existing static methods (preserved for backward compatibility) ==========
29
- /** @deprecated Use instance methods instead */
30
- static async depositToPaymaster(wallet, paymaster, amount) {
31
- return wallet.writeContract({
32
- address: paymaster,
33
- abi: SUPERPAYMASTER_ABI,
34
- functionName: 'deposit',
35
- args: [amount],
36
- chain: wallet.chain
37
- });
38
- }
39
- /** @deprecated Use instance methods instead */
40
- static async depositViaTransferAndCall(wallet, token, paymaster, amount) {
41
- const ERC1363_ABI = [{
42
- name: 'transferAndCall',
43
- type: 'function',
44
- stateMutability: 'nonpayable',
45
- inputs: [{ type: 'address', name: 'to' }, { type: 'uint256', name: 'value' }],
46
- outputs: [{ type: 'bool' }]
47
- }];
48
- return wallet.writeContract({
49
- address: token,
50
- abi: ERC1363_ABI,
51
- functionName: 'transferAndCall',
52
- args: [paymaster, amount],
53
- chain: wallet.chain
54
- });
55
- }
56
- /** @deprecated Use instance methods instead */
57
- static async stakeGToken(wallet, stakingAddr, amount) {
58
- return wallet.writeContract({
59
- address: stakingAddr,
60
- abi: STAKING_ABI,
61
- functionName: 'stake',
62
- args: [amount],
63
- chain: wallet.chain
64
- });
65
- }
66
- /** @deprecated Use instance methods instead */
67
- static async withdrawProtocolRevenue(wallet, paymaster, to, amount) {
68
- return wallet.writeContract({
69
- address: paymaster,
70
- abi: SUPERPAYMASTER_ABI,
71
- functionName: 'withdrawProtocolRevenue',
72
- args: [to, amount],
73
- chain: wallet.chain
74
- });
75
- }
76
- /** @deprecated Use instance methods instead */
77
- static async depositToEntryPoint(wallet, entryPoint, paymaster, amount) {
78
- return wallet.writeContract({
79
- address: entryPoint,
80
- abi: parseAbi(['function depositTo(address) payable']),
81
- functionName: 'depositTo',
82
- args: [paymaster],
83
- value: amount,
84
- chain: wallet.chain
85
- });
86
- }
87
- /** @deprecated Use instance methods instead */
88
- static async getEntryPointBalance(client, entryPoint, account) {
89
- return client.readContract({
90
- address: entryPoint,
91
- abi: parseAbi(['function balanceOf(address) view returns (uint256)']),
92
- functionName: 'balanceOf',
93
- args: [account]
94
- });
95
- }
96
- /** @deprecated Use instance methods instead */
97
- static async operatorDeposit(wallet, paymaster, amount) {
98
- return wallet.writeContract({
99
- address: paymaster,
100
- abi: SUPERPAYMASTER_ABI,
101
- functionName: 'deposit',
102
- args: [amount],
103
- chain: wallet.chain
104
- });
105
- }
106
- /** @deprecated Use instance methods instead */
107
- static async operatorNotifyDeposit(wallet, paymaster, amount) {
108
- return wallet.writeContract({
109
- address: paymaster,
110
- abi: SUPERPAYMASTER_ABI,
111
- functionName: 'notifyDeposit',
112
- args: [amount],
113
- chain: wallet.chain
114
- });
115
- }
116
- // ========== New instance methods (business primitives) ==========
117
- /**
118
- * Get GToken balance
119
- */
120
- async getGTokenBalance(address) {
121
- const { CORE_ADDRESSES } = await import('@aastar/core');
122
- return this.publicClient.readContract({
123
- address: CORE_ADDRESSES.gToken,
124
- abi: ERC20_ABI,
125
- functionName: 'balanceOf',
126
- args: [address]
127
- });
128
- }
129
- /**
130
- * Get aPNTs balance
131
- */
132
- async getAPNTsBalance(address) {
133
- const { CORE_ADDRESSES } = await import('@aastar/core');
134
- return this.publicClient.readContract({
135
- address: CORE_ADDRESSES.aPNTs,
136
- abi: ERC20_ABI,
137
- functionName: 'balanceOf',
138
- args: [address]
139
- });
140
- }
141
- /**
142
- * One-step stake: Approve (if needed) + Stake
143
- *
144
- * @param amount Amount of GToken to stake
145
- * @returns Transaction hash of the stake action
146
- */
147
- async approveAndStake(amount) {
148
- const account = this.walletClient.account;
149
- if (!account)
150
- throw new Error("Account required");
151
- const { CORE_ADDRESSES } = await import('@aastar/core');
152
- const gTokenAddress = CORE_ADDRESSES.gToken;
153
- const stakingAddress = CORE_ADDRESSES.gTokenStaking;
154
- // 1. Check Allowance
155
- const allowance = await this.publicClient.readContract({
156
- address: gTokenAddress,
157
- abi: parseAbi(['function allowance(address owner, address spender) view returns (uint256)']),
158
- functionName: 'allowance',
159
- args: [account.address, stakingAddress]
160
- }); // as bigint
161
- if (allowance < amount) {
162
- console.log(`[FinanceClient] Approving ${formatEther(amount)} GToken...`);
163
- const approveTx = await this.walletClient.writeContract({
164
- address: gTokenAddress,
165
- abi: parseAbi(['function approve(address spender, uint256 amount) returns (bool)']),
166
- functionName: 'approve',
167
- args: [stakingAddress, amount],
168
- chain: this.walletClient.chain,
169
- account
170
- });
171
- await this.publicClient.waitForTransactionReceipt({ hash: approveTx });
172
- console.log(`[FinanceClient] Approved.`);
173
- }
174
- // 2. Stake
175
- console.log(`[FinanceClient] Staking...`);
176
- return FinanceClient.stakeGToken(this.walletClient, stakingAddress, amount);
177
- }
178
- /**
179
- * Get circulating supply (total - locked)
180
- */
181
- async getCirculatingSupply() {
182
- const { CORE_ADDRESSES } = await import('@aastar/core');
183
- const gTokenAddress = CORE_ADDRESSES.gToken;
184
- const total = await this.publicClient.readContract({
185
- address: gTokenAddress,
186
- abi: ERC20_ABI,
187
- functionName: 'totalSupply'
188
- });
189
- // In a real scenario, we might query GTokenStaking's totalStaked
190
- const locked = 0n;
191
- return {
192
- total,
193
- locked,
194
- circulating: total - locked
195
- };
196
- }
197
- /**
198
- * Get comprehensive tokenomics data
199
- */
200
- async getTokenomicsOverview() {
201
- const { CORE_ADDRESSES } = await import('@aastar/core');
202
- const [totalSupply, totalStaked, blackholeBalance] = await Promise.all([
203
- this.publicClient.readContract({
204
- address: CORE_ADDRESSES.gToken,
205
- abi: parseAbi(['function totalSupply() view returns (uint256)']),
206
- functionName: 'totalSupply'
207
- }),
208
- this.publicClient.readContract({
209
- address: CORE_ADDRESSES.gTokenStaking,
210
- abi: parseAbi(['function totalStaked() view returns (uint256)']),
211
- functionName: 'totalStaked'
212
- }),
213
- this.publicClient.readContract({
214
- address: CORE_ADDRESSES.gToken,
215
- abi: parseAbi(['function balanceOf(address) view returns (uint256)']),
216
- functionName: 'balanceOf',
217
- args: ['0x000000000000000000000000000000000000dEaD']
218
- })
219
- ]);
220
- const circulating = totalSupply - totalStaked - blackholeBalance;
221
- const ratio = Number(formatEther(totalStaked)) / Number(formatEther(totalSupply)) * 100;
222
- return {
223
- totalSupply,
224
- totalStaked,
225
- totalBurned: blackholeBalance,
226
- circulatingSupply: circulating,
227
- stakingRatio: ratio
228
- };
229
- }
230
- }
@@ -1 +0,0 @@
1
- {"aPNTs":"0x49fd2BE640DB2910c2fAb69bB8531Ab6E76127ff","blsAggregator":"0xF8e31cb472bc70500f08Cd84917E5A1912Ec8397","dvtValidator":"0xD5ac451B0c50B9476107823Af206eD814a2e2580","entryPoint":"0x2B0d36FACD61B71CC05ab8F3D2355ec3631C0dd5","gToken":"0xfbC22278A96299D91d41C453234d97b4F5Eb9B2d","paymasterFactory":"0x5c74c94173F05dA1720953407cbb920F3DF9f887","paymasterV4Impl":"0x720472c8ce72c2A2D711333e064ABD3E6BbEAdd3","paymasterV4Proxy":"0x0F9019Dd30C7Cc5774d4883fba933aA0Caba9424","registry":"0x367761085BF3C12e5DA2Df99AC6E1a824612b8fb","reputationSystem":"0xCace1b78160AE76398F486c8a18044da0d66d86D","sbt":"0x1c85638e118b37167e9298c2268758e058DdfDA0","simpleAccountFactory":"0x4b6aB5F819A515382B0dEB6935D793817bB4af28","staking":"0xC9a43158891282A2B1475592D5719c001986Aaec","superPaymaster":"0x86A2EE8FAf9A840F7a2c64CA3d51209F9A02081D","xPNTsFactory":"0xA4899D35897033b927acFCf422bc745916139776"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=regression_test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"regression_test.d.ts","sourceRoot":"","sources":["regression_test.ts"],"names":[],"mappings":""}
@@ -1,89 +0,0 @@
1
- import { createPublicClient, http, keccak256, stringToBytes } from 'viem';
2
- import { foundry } from 'viem/chains';
3
- import { privateKeyToAccount } from 'viem/accounts';
4
- import { RegistryABI, SimpleAccountFactoryABI } from '@aastar/core';
5
- import fs from 'fs';
6
- import path from 'path';
7
- import { fileURLToPath } from 'url';
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = path.dirname(__filename);
10
- // Dynamic Config Loading: Try local synced config first, fallback to bridge project
11
- const LOCAL_CONFIG_PATH = path.resolve(__dirname, './config.json');
12
- const SP_CONFIG_PATH = path.resolve(__dirname, '../../../../SuperPaymaster/script/v3/config.json');
13
- function loadConfig() {
14
- if (fs.existsSync(LOCAL_CONFIG_PATH)) {
15
- console.log("📂 Loading local config from examples/config.json");
16
- return JSON.parse(fs.readFileSync(LOCAL_CONFIG_PATH, 'utf8'));
17
- }
18
- if (fs.existsSync(SP_CONFIG_PATH)) {
19
- console.log("📂 Loading synced config from SuperPaymaster project");
20
- return JSON.parse(fs.readFileSync(SP_CONFIG_PATH, 'utf8'));
21
- }
22
- console.error("❌ config.json not found in examples/ or SuperPaymaster project.");
23
- process.exit(1);
24
- }
25
- const CONFIG = loadConfig();
26
- const RPC_URL = process.env.RPC_URL || 'http://127.0.0.1:8545';
27
- const ADMIN_KEY = (process.env.ADMIN_KEY || '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80');
28
- const USER_KEY = (process.env.USER_KEY || '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d');
29
- async function main() {
30
- console.log("\n🧪 AAStar SDK Automated Regression Test");
31
- console.log("========================================\n");
32
- const publicClient = createPublicClient({ chain: foundry, transport: http(RPC_URL) });
33
- const adminAccount = privateKeyToAccount(ADMIN_KEY);
34
- const userAccount = privateKeyToAccount(USER_KEY);
35
- console.log(`📡 Network: Local (Anvil)`);
36
- console.log(`👨‍✈️ Admin EOA: ${adminAccount.address}`);
37
- console.log(`👤 User Signer: ${userAccount.address}`);
38
- // Role IDs (Using stringToBytes correctly)
39
- const ROLE_COMMUNITY = keccak256(stringToBytes("COMMUNITY"));
40
- // 1. Connectivity & Address Verification
41
- console.log("\n🔍 Phase 1: Verification");
42
- const adminIsCommunity = await publicClient.readContract({
43
- address: CONFIG.registry,
44
- abi: RegistryABI,
45
- functionName: 'hasRole',
46
- args: [ROLE_COMMUNITY, adminAccount.address]
47
- });
48
- console.log(` [OK] Registry at ${CONFIG.registry}`);
49
- console.log(` [OK] Admin has COMMUNITY role: ${adminIsCommunity}`);
50
- // 2. Simple Account Factory Interaction
51
- const salt = 0n;
52
- const senderAddress = await publicClient.readContract({
53
- address: CONFIG.simpleAccountFactory,
54
- abi: SimpleAccountFactoryABI,
55
- functionName: 'getAddress',
56
- args: [userAccount.address, salt]
57
- });
58
- const byteCode = await publicClient.getBytecode({ address: senderAddress });
59
- console.log(` [OK] SimpleAccountFactory at ${CONFIG.simpleAccountFactory}`);
60
- console.log(` [OK] Target AA Address: ${senderAddress} (Deployed: ${!!byteCode})`);
61
- // 3. ABI Compatibility Check (v0.8)
62
- const epAddr = await publicClient.readContract({
63
- address: CONFIG.superPaymaster,
64
- abi: [
65
- {
66
- "inputs": [],
67
- "name": "entryPoint",
68
- "outputs": [
69
- {
70
- "internalType": "contract IEntryPoint",
71
- "name": "",
72
- "type": "address"
73
- }
74
- ],
75
- "stateMutability": "view",
76
- "type": "function"
77
- }
78
- ],
79
- functionName: 'entryPoint'
80
- });
81
- console.log(` [OK] SuperPaymaster linked to EntryPoint: ${epAddr}`);
82
- console.log("\n✨ Verification Complete: SDK is correctly linked to blockchain state.\n");
83
- }
84
- main().catch((err) => {
85
- console.error("\n❌ Test Failed:");
86
- console.error(err);
87
- process.exit(1);
88
- });
89
- //# sourceMappingURL=regression_test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"regression_test.js","sourceRoot":"","sources":["regression_test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAmC,SAAS,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC3G,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,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,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
@@ -1,106 +0,0 @@
1
- import { createPublicClient, http, parseEther, encodeAbiParameters, keccak256, stringToBytes } from 'viem';
2
- import { foundry } from 'viem/chains';
3
- import { privateKeyToAccount } from 'viem/accounts';
4
- import {
5
- RegistryABI,
6
- SimpleAccountFactoryABI,
7
- EntryPointABI
8
- } from '@aastar/core';
9
- import fs from 'fs';
10
- import path from 'path';
11
- import { fileURLToPath } from 'url';
12
-
13
- const __filename = fileURLToPath(import.meta.url);
14
- const __dirname = path.dirname(__filename);
15
-
16
- // Dynamic Config Loading: Try local synced config first, fallback to bridge project
17
- const LOCAL_CONFIG_PATH = path.resolve(__dirname, './config.json');
18
- const SP_CONFIG_PATH = path.resolve(__dirname, '../../../../SuperPaymaster/script/v3/config.json');
19
-
20
- function loadConfig() {
21
- if (fs.existsSync(LOCAL_CONFIG_PATH)) {
22
- console.log("📂 Loading local config from examples/config.json");
23
- return JSON.parse(fs.readFileSync(LOCAL_CONFIG_PATH, 'utf8'));
24
- }
25
- if (fs.existsSync(SP_CONFIG_PATH)) {
26
- console.log("📂 Loading synced config from SuperPaymaster project");
27
- return JSON.parse(fs.readFileSync(SP_CONFIG_PATH, 'utf8'));
28
- }
29
- console.error("❌ config.json not found in examples/ or SuperPaymaster project.");
30
- process.exit(1);
31
- }
32
-
33
- const CONFIG = loadConfig();
34
- const RPC_URL = process.env.RPC_URL || 'http://127.0.0.1:8545';
35
- const ADMIN_KEY = (process.env.ADMIN_KEY || '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80') as `0x${string}`;
36
- const USER_KEY = (process.env.USER_KEY || '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d') as `0x${string}`;
37
-
38
- async function main() {
39
- console.log("\n🧪 AAStar SDK Automated Regression Test");
40
- console.log("========================================\n");
41
-
42
- const publicClient = createPublicClient({ chain: foundry, transport: http(RPC_URL) });
43
- const adminAccount = privateKeyToAccount(ADMIN_KEY);
44
- const userAccount = privateKeyToAccount(USER_KEY);
45
-
46
- console.log(`📡 Network: Local (Anvil)`);
47
- console.log(`👨‍✈️ Admin EOA: ${adminAccount.address}`);
48
- console.log(`👤 User Signer: ${userAccount.address}`);
49
-
50
- // Role IDs (Using stringToBytes correctly)
51
- const ROLE_COMMUNITY = keccak256(stringToBytes("COMMUNITY"));
52
-
53
- // 1. Connectivity & Address Verification
54
- console.log("\n🔍 Phase 1: Verification");
55
- const adminIsCommunity = await publicClient.readContract({
56
- address: CONFIG.registry as `0x${string}`,
57
- abi: RegistryABI,
58
- functionName: 'hasRole',
59
- args: [ROLE_COMMUNITY, adminAccount.address]
60
- });
61
- console.log(` [OK] Registry at ${CONFIG.registry}`);
62
- console.log(` [OK] Admin has COMMUNITY role: ${adminIsCommunity}`);
63
-
64
- // 2. Simple Account Factory Interaction
65
- const salt = 0n;
66
- const senderAddress = await publicClient.readContract({
67
- address: CONFIG.simpleAccountFactory as `0x${string}`,
68
- abi: SimpleAccountFactoryABI,
69
- functionName: 'getAddress',
70
- args: [userAccount.address, salt]
71
- });
72
- const byteCode = await publicClient.getBytecode({ address: senderAddress });
73
-
74
- console.log(` [OK] SimpleAccountFactory at ${CONFIG.simpleAccountFactory}`);
75
- console.log(` [OK] Target AA Address: ${senderAddress} (Deployed: ${!!byteCode})`);
76
-
77
- // 3. ABI Compatibility Check (v0.8)
78
- const epAddr = await publicClient.readContract({
79
- address: CONFIG.superPaymaster as `0x${string}`,
80
- abi: [
81
- {
82
- "inputs": [],
83
- "name": "entryPoint",
84
- "outputs": [
85
- {
86
- "internalType": "contract IEntryPoint",
87
- "name": "",
88
- "type": "address"
89
- }
90
- ],
91
- "stateMutability": "view",
92
- "type": "function"
93
- }
94
- ] as const,
95
- functionName: 'entryPoint'
96
- });
97
- console.log(` [OK] SuperPaymaster linked to EntryPoint: ${epAddr}`);
98
-
99
- console.log("\n✨ Verification Complete: SDK is correctly linked to blockchain state.\n");
100
- }
101
-
102
- main().catch((err) => {
103
- console.error("\n❌ Test Failed:");
104
- console.error(err);
105
- process.exit(1);
106
- });
@@ -1,101 +0,0 @@
1
- import { createPublicClient, http, parseAbi } from 'viem';
2
- import { foundry, sepolia } from 'viem/chains';
3
- import dotenv from 'dotenv';
4
-
5
- if (!(BigInt.prototype as any).toJSON) {
6
- (BigInt.prototype as any).toJSON = function () { return this.toString(); };
7
- }
8
-
9
- const envPath = process.env.SDK_ENV_PATH || '.env.anvil';
10
- dotenv.config({ path: envPath, override: true });
11
-
12
- const isSepolia = process.env.REVISION_ENV === 'sepolia';
13
- const chain = isSepolia ? sepolia : foundry;
14
- const RPC_URL = process.env.RPC_URL || (isSepolia ? process.env.SEPOLIA_RPC_URL : 'http://127.0.0.1:8545');
15
- const client = createPublicClient({ chain, transport: http(RPC_URL) });
16
-
17
- async function main() {
18
- console.log('🔍 Environment Configuration Validation (Robust Mode)\n');
19
-
20
- console.log(`📍 Environment: ${isSepolia ? 'Sepolia' : 'Anvil'}`);
21
- console.log(`🔗 RPC URL: ${RPC_URL || 'NOT SET'}`);
22
- console.log(`📝 SDK_ENV_PATH: ${envPath}\n`);
23
-
24
- // Normalize and Filter empty
25
- const cleanAddress = (addr: string | undefined) => addr ? addr.toLowerCase() : "";
26
-
27
- const REGISTRY = cleanAddress(process.env.REGISTRY_ADDRESS);
28
- const GTOKEN = cleanAddress(process.env.GTOKEN_ADDRESS);
29
- const GTOKEN_STAKING = cleanAddress(process.env.GTOKENSTAKING_ADDRESS); // Note: script uses GTOKEN_STAKING in var, check env key
30
- // Map env keys correctly
31
- const ENV_STAKING = cleanAddress(process.env.STAKING_ADDRESS || process.env.GTOKENSTAKING_ADDRESS);
32
- const SUPER_PAYMASTER = cleanAddress(process.env.SUPER_PAYMASTER || process.env.SUPERPAYMASTER_ADDRESS);
33
- const APNTS = cleanAddress(process.env.APNTS_ADDRESS);
34
- const MYSBT = cleanAddress(process.env.MYSBT_ADDRESS);
35
-
36
- console.log('📋 Loaded Addresses:');
37
- console.log(` REGISTRY: ${REGISTRY || 'NOT SET'}`);
38
- console.log(` GTOKEN: ${GTOKEN || 'NOT SET'}`);
39
- console.log(` GTOKEN_STAKING: ${ENV_STAKING || 'NOT SET'}`);
40
- console.log(` SUPER_PAYMASTER: ${SUPER_PAYMASTER || 'NOT SET'}`);
41
- console.log(` APNTS: ${APNTS || 'NOT SET'}`);
42
- console.log(` MYSBT: ${MYSBT || 'NOT SET'}\n`);
43
-
44
- let hasError = false;
45
-
46
- // Helper for safe read
47
- async function checkLink(name: string, contractAddr: string, abi: any, funcName: string, expectedAddr: string) {
48
- if (!contractAddr || !expectedAddr) {
49
- console.log(`⚠️ Skipping ${name}: Addresses missing in Env`);
50
- return;
51
- }
52
- try {
53
- console.log(`Checking ${name}...`);
54
- const onChain = (await client.readContract({
55
- address: contractAddr as `0x${string}`,
56
- abi: parseAbi([abi]),
57
- functionName: funcName
58
- })) as string;
59
-
60
- if (cleanAddress(onChain) !== expectedAddr) {
61
- console.error(` ❌ FAIL: ${name}`);
62
- console.error(` Expected: ${expectedAddr}`);
63
- console.error(` Got: ${cleanAddress(onChain)}`);
64
- hasError = true;
65
- } else {
66
- console.log(` ✅ PASS: ${name}`);
67
- }
68
- } catch (e: any) {
69
- console.error(` ⚠️ Error reading ${name}: ${e.message.split('\n')[0]}`);
70
- // Don't fail the whole suite for network glitches, but warn
71
- }
72
- }
73
-
74
- await checkLink('Registry -> GTokenStaking', REGISTRY, 'function GTOKEN_STAKING() view returns (address)', 'GTOKEN_STAKING', ENV_STAKING);
75
- await checkLink('GTokenStaking -> Registry', ENV_STAKING, 'function REGISTRY() view returns (address)', 'REGISTRY', REGISTRY);
76
- await checkLink('GTokenStaking -> GToken', ENV_STAKING, 'function GTOKEN() view returns (address)', 'GTOKEN', GTOKEN);
77
- await checkLink('Registry -> MySBT', REGISTRY, 'function MYSBT() view returns (address)', 'MYSBT', MYSBT);
78
- await checkLink('SuperPaymaster -> aPNTs', SUPER_PAYMASTER, 'function APNTS_TOKEN() view returns (address)', 'APNTS_TOKEN', APNTS);
79
- await checkLink('SuperPaymaster -> Registry', SUPER_PAYMASTER, 'function REGISTRY() view returns (address)', 'REGISTRY', REGISTRY);
80
-
81
- console.log('\n' + '='.repeat(50));
82
- if (hasError) {
83
- if (isSepolia) {
84
- console.log('⚠️ Configuration mismatches detected on Sepolia');
85
- console.log('💡 This is expected - Sepolia contracts may have been redeployed');
86
- console.log('✅ Validation completed with warnings (not blocking)');
87
- } else {
88
- console.error('❌ Validation Found Mismatches (Non-Fatal for Script Flow)');
89
- }
90
- // Non-zero exit code might stop regression runner, but let's allow "yellow" state
91
- // process.exit(1);
92
- } else {
93
- console.log('✅ Configuration Consistent');
94
- }
95
- }
96
-
97
- main().catch((error) => {
98
- console.error('❌ Validation script encountered an error:');
99
- console.error(error);
100
- process.exit(1); // Exit with error code to properly report failure
101
- });
@@ -1,132 +0,0 @@
1
- import { createPublicClient, http, parseEther, type Hex, type Address, erc20Abi, keccak256, stringToBytes } from 'viem';
2
- import { privateKeyToAccount } from 'viem/accounts';
3
- import { foundry, sepolia } from 'viem/chains';
4
- import * as dotenv from 'dotenv';
5
- import * as path from 'path';
6
- import { createAdminClient } from '../../dist/index.js';
7
-
8
- if (!(BigInt.prototype as any).toJSON) {
9
- (BigInt.prototype as any).toJSON = function () { return this.toString(); };
10
- }
11
-
12
- const envPath = process.env.SDK_ENV_PATH || '.env.anvil';
13
- dotenv.config({ path: path.resolve(process.cwd(), envPath), override: true });
14
-
15
- const isSepolia = process.env.REVISION_ENV === 'sepolia';
16
- const chain = isSepolia ? sepolia : foundry;
17
- const RPC_URL = process.env.RPC_URL || (isSepolia ? process.env.SEPOLIA_RPC_URL : 'http://127.0.0.1:8545');
18
- const ADMIN_KEY = (process.env.ADMIN_KEY || '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80') as Hex;
19
-
20
- // Test Data
21
- const OPERATOR_KEY = (process.env.OPERATOR_KEY || "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d") as Hex;
22
- const COMMUNITY_OWNER_KEY = (process.env.COMMUNITY_OWNER_KEY || "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a") as Hex;
23
- const USER_KEY = (process.env.USER_KEY || "0x7c8521197cd533c301a916120409a63c809181144001a1c93a0280eb46c6495d") as Hex;
24
-
25
- const localAddresses = {
26
- registry: (process.env.REGISTRY_ADDRESS || '').trim() as Address,
27
- gToken: (process.env.GTOKEN_ADDRESS || '').trim() as Address,
28
- gTokenStaking: (process.env.GTOKENSTAKING_ADDRESS || '').trim() as Address,
29
- superPaymaster: (process.env.SUPER_PAYMASTER || '').trim() as Address,
30
- aPNTs: (process.env.APNTS_ADDRESS || '').trim() as Address,
31
- mySBT: (process.env.MYSBT_ADDRESS || '').trim() as Address
32
- };
33
-
34
- console.log(' Loaded Addresses:', JSON.stringify(localAddresses, null, 2));
35
-
36
-
37
- const erc20AbiWithMint = [
38
- ...erc20Abi,
39
- {
40
- type: 'function',
41
- name: 'mint',
42
- stateMutability: 'nonpayable',
43
- inputs: [
44
- { name: 'to', type: 'address' },
45
- { name: 'amount', type: 'uint256' }
46
- ],
47
- outputs: []
48
- }
49
- ] as const;
50
-
51
- async function setup() {
52
- console.log('🚀 Step 01: Setup and Fund Accounts');
53
-
54
- const adminAccount = privateKeyToAccount(ADMIN_KEY);
55
- const adminClient = createAdminClient({
56
- chain,
57
- transport: http(RPC_URL),
58
- account: adminAccount,
59
- addresses: localAddresses as any
60
- });
61
-
62
- if (isSepolia) {
63
- console.log(' 🌐 Sepolia Mode: Skipping Anvil-specific funding and minting...');
64
- console.log(' ℹ️ Assuming accounts are pre-funded on Testnet.');
65
- return;
66
- }
67
-
68
- const operator = privateKeyToAccount(OPERATOR_KEY).address;
69
- const community = privateKeyToAccount(COMMUNITY_OWNER_KEY).address;
70
- const user = privateKeyToAccount(USER_KEY).address;
71
-
72
- console.log(` Admin: ${adminAccount.address}`);
73
- console.log(` Operator: ${operator}`);
74
- console.log(` Community: ${community}`);
75
- console.log(` User: ${user}`);
76
-
77
- // 1. Ensure ETH balance
78
- console.log('\n💰 Funding ETH...');
79
- const targets = [adminAccount.address, operator, community, user];
80
- for (const target of targets) {
81
- await adminClient.request({
82
- method: 'anvil_setBalance' as any,
83
- params: [target, '0x56BC75E2D63100000'] // 100 ETH
84
- });
85
- }
86
- console.log(' ✅ ETH Funded for all accounts');
87
-
88
- // 2. Mint GTokens and aPNTs
89
- console.log('\n💎 Minting Tokens...');
90
-
91
- // Operator need funds for:
92
- // - Staking (30-50 GToken)
93
- // - Entry Burn (3-5 GToken)
94
- // - Paymaster Deposit (50 aPNTs)
95
-
96
- // Community need funds for:
97
- // - Staking (30 GToken)
98
- // - Entry Burn (3 GToken)
99
-
100
- const mints = [
101
- { token: localAddresses.gToken, to: operator, amount: parseEther('300') },
102
- { token: localAddresses.aPNTs, to: operator, amount: parseEther('200') },
103
- { token: localAddresses.gToken, to: community, amount: parseEther('300') },
104
- { token: localAddresses.gToken, to: user, amount: parseEther('100') }
105
- ];
106
-
107
- for (const m of mints) {
108
- if (!m.token) {
109
- console.warn(' ⚠️ Skipping mint: token address missing');
110
- continue;
111
- }
112
- console.log(` Attempting mint: ${m.amount.toString()} to ${m.to} on token ${m.token} (len: ${m.token.length})`);
113
- const tx = await adminClient.writeContract({
114
- address: m.token,
115
- abi: erc20AbiWithMint,
116
- functionName: 'mint',
117
- args: [m.to, m.amount],
118
- account: adminAccount,
119
- chain
120
- });
121
- await adminClient.waitForTransactionReceipt({ hash: tx });
122
- console.log(` ✅ Minted ${m.amount.toString()} to ${m.to} (${m.token})`);
123
- }
124
-
125
-
126
- console.log('\n🎉 Step 01 Completed Successfully\n');
127
- }
128
-
129
- setup().catch(err => {
130
- console.error('❌ Step 01 Failed:', err);
131
- process.exit(1);
132
- });