@aastar/sdk 0.14.0 → 0.16.6

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 (656) hide show
  1. package/.eslintrc.cjs +30 -0
  2. package/.gitmodules +9 -0
  3. package/README.md +299 -0
  4. package/aastar-sdk.code-workspace +14 -0
  5. package/abis/BLSAggregator.json +572 -0
  6. package/abis/BLSValidator.json +39 -0
  7. package/abis/DVTValidator.json +383 -0
  8. package/abis/Eip7702Support.json +24 -0
  9. package/abis/EntryPoint.json +1379 -0
  10. package/abis/GToken.json +510 -0
  11. package/abis/GTokenStaking.json +918 -0
  12. package/abis/LegacyAccount.json +625 -0
  13. package/abis/MySBT.json +1547 -0
  14. package/abis/Paymaster.json +1192 -0
  15. package/abis/PaymasterFactory.json +637 -0
  16. package/abis/PaymasterV4_2.json +1193 -0
  17. package/abis/Registry.json +1677 -0
  18. package/abis/ReputationSystem.json +659 -0
  19. package/abis/SenderCreator.json +99 -0
  20. package/abis/Simple7702Account.json +395 -0
  21. package/abis/SimpleAccount.json +625 -0
  22. package/abis/SimpleAccountFactory.json +108 -0
  23. package/abis/SimpleAccountFactoryV08.json +87 -0
  24. package/abis/SimpleAccountV08.json +557 -0
  25. package/abis/SuperPaymaster.json +1568 -0
  26. package/abis/UserOperationLib.json +57 -0
  27. package/abis/aPNTs.json +1160 -0
  28. package/abis/xPNTsFactory.json +715 -0
  29. package/abis/xPNTsToken.json +1160 -0
  30. package/config/networks/README.md +54 -0
  31. package/config/networks/mainnet.env.example +39 -0
  32. package/config/networks/optimism-sepolia.env.example +35 -0
  33. package/config/networks/optimism.env.example +36 -0
  34. package/config/networks/sepolia.env.example +36 -0
  35. package/config.anvil.json +1 -0
  36. package/config.sepolia.json +1 -0
  37. package/config.test.json +27 -0
  38. package/data/experiment_data.csv +36 -0
  39. package/data/industry_baseline_2025-12-23.json +154 -0
  40. package/data/industry_baseline_latest.json +154 -0
  41. package/docs/ABI_Change_Tracking_Workflow.md +41 -0
  42. package/docs/ABI_MAINTENANCE_PLAN.md +132 -0
  43. package/docs/API_REFERENCE.md +956 -0
  44. package/docs/Configuration_Sync.md +47 -0
  45. package/docs/DAO_Mining_Distribution_Plan.md +522 -0
  46. package/docs/DEMO_REFACTOR_PLAN.md +289 -0
  47. package/docs/DOCUMENTATION_PLAN.md +455 -0
  48. package/docs/ENV_SEPOLIA_UPDATE.md +68 -0
  49. package/docs/Faucet_Gasless_Plan.md +56 -0
  50. package/docs/L2_BUSINESS_CLIENTS_PLAN.md +394 -0
  51. package/docs/L4_Manual_Test_CheatSheet.md +215 -0
  52. package/docs/Plan.md +266 -0
  53. package/docs/Regression_Testing_Guide.md +70 -0
  54. package/docs/SDK_ABI_COVERAGE.md +839 -0
  55. package/docs/SDK_COVERAGE_STRATEGY.md +397 -0
  56. package/docs/SDK_Optimization_Evaluation_Plan.md +51 -0
  57. package/docs/SDK_REGRESSION_AND_API_PLAN.md +98 -0
  58. package/docs/SDK_STAGE3_PLAN.md +151 -0
  59. package/docs/SEPOLIA_ENV_REFERENCE.md +51 -0
  60. package/docs/STAGE3.md +191 -0
  61. package/docs/Script_Comparison_Report.md +91 -0
  62. package/docs/Sepolia_Latest_Deployment.md +117 -0
  63. package/docs/TESTER_GUIDE_GASLESS.md +663 -0
  64. package/docs/TEST_COVERAGE_MATRIX.md +72 -0
  65. package/docs/TODO_SDK_COVERAGE.md +55 -0
  66. package/docs/USER_CASE_DESIGN.md +110 -0
  67. package/docs/Verifier_L4_Gasless_Plan.md +454 -0
  68. package/docs/api/@aastar/account.md +235 -0
  69. package/docs/api/@aastar/analytics.md +219 -0
  70. package/docs/api/@aastar/core.md +26830 -0
  71. package/docs/api/@aastar/dapp.md +130 -0
  72. package/docs/api/@aastar/identity.md +482 -0
  73. package/docs/api/@aastar/paymaster.md +1387 -0
  74. package/docs/api/@aastar/sdk/README.md +155 -0
  75. package/docs/api/@aastar/sdk/node.md +4044 -0
  76. package/docs/api/@aastar/tokens.md +1971 -0
  77. package/docs/api/README.md +10 -0
  78. package/docs/changelog.md +99 -0
  79. package/docs/examples/README.md +18 -0
  80. package/docs/examples/community-flow.md +28 -0
  81. package/docs/examples/enduser-flow.md +24 -0
  82. package/docs/examples/index.md +18 -0
  83. package/docs/examples/multi-chain.md +31 -0
  84. package/docs/examples/operator-flow.md +28 -0
  85. package/docs/guide/CLI_GUIDE.md +65 -0
  86. package/docs/guide/DOCUMENTATION_PLAN.md +455 -0
  87. package/docs/guide/Security-solution.md +106 -0
  88. package/docs/guide/TEST_COMMANDS.md +320 -0
  89. package/docs/guide/concepts/account-abstraction.md +95 -0
  90. package/docs/guide/concepts/rainbow-bridge.md +68 -0
  91. package/docs/guide/concepts/reputation.md +95 -0
  92. package/docs/guide/concepts/superpaymaster.md +141 -0
  93. package/docs/guide/getting-started.md +133 -0
  94. package/docs/guide/installation.md +40 -0
  95. package/docs/guide/paper-data-collection.md +69 -0
  96. package/docs/guide/quick-start.md +52 -0
  97. package/docs/guide/task_breakdown.md +121 -0
  98. package/docs/guide/use-cases/community-management.md +141 -0
  99. package/docs/guide/use-cases/gasless-transactions.md +71 -0
  100. package/docs/guide/use-cases/operator-staking.md +84 -0
  101. package/docs/guide/use-cases/yop.md +72 -0
  102. package/docs/old-solution.md +1078 -0
  103. package/docs/paper-data-collection.md +69 -0
  104. package/docs/refactor/2026-01-13-221242-trae-refactor.md +224 -0
  105. package/docs/refactor/2026-01-13-audit-analysis.md +96 -0
  106. package/docs/refactor/2026-01-13-audit-report-v0.16.2.md +76 -0
  107. package/docs/refactor/2026-01-13-audit-report-v0.17.0.md +74 -0
  108. package/docs/refactor/2026-01-13-cursor-refactor.md +511 -0
  109. package/docs/refactor/2026-01-13-refactor-plan.md +88 -0
  110. package/docs/refactor/2026-01-13-refactor-response-plan.md +77 -0
  111. package/docs/refactor/2026-01-13-refactor-review.md +39 -0
  112. package/docs/refactor/2026-01-13-sdk-enhancement-plan.md +120 -0
  113. package/docs/refactor/2026-01-14-audit-response.md +242 -0
  114. package/docs/refactor/2026-01-14-audit-summary.md +133 -0
  115. package/docs/refactor/cursor-2026-01-13-14-00-audit-report.md +267 -0
  116. package/docs/technical_plan.md +510 -0
  117. package/docs/zh/examples/community-flow.md +38 -0
  118. package/docs/zh/examples/complete-workflow.md +10 -0
  119. package/docs/zh/examples/enduser-flow.md +33 -0
  120. package/docs/zh/examples/index.md +18 -0
  121. package/docs/zh/examples/multi-chain.md +46 -0
  122. package/docs/zh/examples/operator-flow.md +37 -0
  123. package/docs/zh/guide/CLI_GUIDE.md +48 -0
  124. package/docs/zh/guide/DOCUMENTATION_PLAN.md +455 -0
  125. package/docs/zh/guide/Plan.md +266 -0
  126. package/docs/zh/guide/SDK_Optimization_Evaluation_Plan.md +51 -0
  127. package/docs/zh/guide/Security-solution.md +106 -0
  128. package/docs/zh/guide/TEST_COMMANDS.md +125 -0
  129. package/docs/zh/guide/TEST_COVERAGE_MATRIX.md +72 -0
  130. package/docs/zh/guide/concepts/account-abstraction.md +95 -0
  131. package/docs/zh/guide/concepts/rainbow-bridge.md +68 -0
  132. package/docs/zh/guide/concepts/reputation.md +95 -0
  133. package/docs/zh/guide/concepts/superpaymaster.md +141 -0
  134. package/docs/zh/guide/getting-started.md +133 -0
  135. package/docs/zh/guide/installation.md +107 -0
  136. package/docs/zh/guide/old-solution.md +1078 -0
  137. package/docs/zh/guide/paper-data-collection.md +69 -0
  138. package/docs/zh/guide/quick-start.md +134 -0
  139. package/docs/zh/guide/sdk-readme.md +253 -0
  140. package/docs/zh/guide/task_breakdown.md +76 -0
  141. package/docs/zh/guide/technical_plan.md +510 -0
  142. package/docs/zh/guide/use-cases/community-management.md +141 -0
  143. package/docs/zh/guide/use-cases/gasless-transactions.md +71 -0
  144. package/docs/zh/guide/use-cases/operator-staking.md +84 -0
  145. package/docs/zh/guide/use-cases/yop.md +72 -0
  146. package/env.template +32 -0
  147. package/examples/l1-api-demo.ts +184 -0
  148. package/examples/l2-clients-demo.ts +138 -0
  149. package/examples/l3-user-onboarding.ts +74 -0
  150. package/examples/prepare-gasless.ts +89 -0
  151. package/examples/sdk-demo/DEVELOPER_GUIDE.md +159 -0
  152. package/examples/sdk-demo/README.md +30 -0
  153. package/examples/sdk-demo/usage.ts +137 -0
  154. package/examples/simple-gasless-demo.ts +80 -0
  155. package/examples/simple-superpaymaster-demo.ts +96 -0
  156. package/ext/aastar-shared-config/.env.example +6 -0
  157. package/ext/aastar-shared-config/.github/workflows/check-secrets.yml +257 -0
  158. package/ext/aastar-shared-config/AGENTS.md +21 -0
  159. package/ext/aastar-shared-config/CHANGELOG.md +99 -0
  160. package/ext/aastar-shared-config/LICENSE +21 -0
  161. package/ext/aastar-shared-config/QUICK_START.md +215 -0
  162. package/ext/aastar-shared-config/README.md +412 -0
  163. package/ext/aastar-shared-config/SHARED_CONFIG_SUMMARY.md +273 -0
  164. package/ext/aastar-shared-config/check-locker-status.mjs +7 -0
  165. package/ext/aastar-shared-config/favicon.ico +0 -0
  166. package/ext/aastar-shared-config/generate-comparison-table.sh +67 -0
  167. package/ext/aastar-shared-config/package.json +46 -0
  168. package/ext/aastar-shared-config/pnpm-lock.yaml +1182 -0
  169. package/ext/aastar-shared-config/src/abis/BLSAggregator.json +1 -0
  170. package/ext/aastar-shared-config/src/abis/DVTValidator.json +1 -0
  171. package/ext/aastar-shared-config/src/abis/GToken.json +1 -0
  172. package/ext/aastar-shared-config/src/abis/GTokenStaking.json +1 -0
  173. package/ext/aastar-shared-config/src/abis/MySBT.json +1 -0
  174. package/ext/aastar-shared-config/src/abis/PaymasterFactory.json +1 -0
  175. package/ext/aastar-shared-config/src/abis/PaymasterV4.json +1098 -0
  176. package/ext/aastar-shared-config/src/abis/Registry.json +1 -0
  177. package/ext/aastar-shared-config/src/abis/SimpleAccount.json +557 -0
  178. package/ext/aastar-shared-config/src/abis/SimpleAccountFactory.json +87 -0
  179. package/ext/aastar-shared-config/src/abis/SuperPaymasterV2.json +1 -0
  180. package/ext/aastar-shared-config/src/abis/index.ts +45 -0
  181. package/ext/aastar-shared-config/src/abis/xPNTsFactory.json +1 -0
  182. package/ext/aastar-shared-config/src/abis/xPNTsToken.json +1 -0
  183. package/ext/aastar-shared-config/src/branding.ts +32 -0
  184. package/ext/aastar-shared-config/src/communities.ts +93 -0
  185. package/ext/aastar-shared-config/src/constants.ts +67 -0
  186. package/ext/aastar-shared-config/src/contract-addresses.ts +95 -0
  187. package/ext/aastar-shared-config/src/contract-versions.ts +374 -0
  188. package/ext/aastar-shared-config/src/contracts.ts +414 -0
  189. package/ext/aastar-shared-config/src/index.ts +14 -0
  190. package/ext/aastar-shared-config/src/networks.ts +117 -0
  191. package/ext/aastar-shared-config/sync-abis.sh +92 -0
  192. package/ext/aastar-shared-config/sync-versions.mjs +150 -0
  193. package/ext/aastar-shared-config/tsconfig.json +18 -0
  194. package/ext/aastar-shared-config/tsup.config.ts +10 -0
  195. package/ext/aastar-shared-config/verify-all.sh +207 -0
  196. package/ext/aastar-shared-config/verify-contracts.sh +85 -0
  197. package/ext/aastar-shared-config/verify-mysbt-v243.mjs +27 -0
  198. package/ext/aastar-shared-config/verify-onchain-versions.mjs +93 -0
  199. package/l4-setup.sh +11 -0
  200. package/lib/SHARED_CONFIG_REFERENCE.md +133 -0
  201. package/lib/shared-config/.env.example +6 -0
  202. package/lib/shared-config/.github/workflows/check-secrets.yml +257 -0
  203. package/lib/shared-config/AGENTS.md +21 -0
  204. package/lib/shared-config/CHANGELOG.md +99 -0
  205. package/lib/shared-config/LICENSE +21 -0
  206. package/lib/shared-config/QUICK_START.md +215 -0
  207. package/lib/shared-config/README.md +412 -0
  208. package/lib/shared-config/SHARED_CONFIG_SUMMARY.md +273 -0
  209. package/lib/shared-config/check-locker-status.mjs +7 -0
  210. package/lib/shared-config/favicon.ico +0 -0
  211. package/lib/shared-config/generate-comparison-table.sh +67 -0
  212. package/lib/shared-config/package.json +46 -0
  213. package/lib/shared-config/pnpm-lock.yaml +1182 -0
  214. package/lib/shared-config/src/abis/BLSAggregator.json +1 -0
  215. package/lib/shared-config/src/abis/DVTValidator.json +1 -0
  216. package/lib/shared-config/src/abis/GToken.json +1 -0
  217. package/lib/shared-config/src/abis/GTokenStaking.json +1 -0
  218. package/lib/shared-config/src/abis/MySBT.json +1 -0
  219. package/lib/shared-config/src/abis/PaymasterFactory.json +1 -0
  220. package/lib/shared-config/src/abis/PaymasterV4.json +1098 -0
  221. package/lib/shared-config/src/abis/Registry.json +1 -0
  222. package/lib/shared-config/src/abis/SimpleAccount.json +557 -0
  223. package/lib/shared-config/src/abis/SimpleAccountFactory.json +87 -0
  224. package/lib/shared-config/src/abis/SuperPaymasterV2.json +1 -0
  225. package/lib/shared-config/src/abis/index.ts +45 -0
  226. package/lib/shared-config/src/abis/xPNTsFactory.json +1 -0
  227. package/lib/shared-config/src/abis/xPNTsToken.json +1 -0
  228. package/lib/shared-config/src/branding.ts +32 -0
  229. package/lib/shared-config/src/communities.ts +93 -0
  230. package/lib/shared-config/src/constants.ts +67 -0
  231. package/lib/shared-config/src/contract-addresses.ts +95 -0
  232. package/lib/shared-config/src/contract-versions.ts +374 -0
  233. package/lib/shared-config/src/contracts.ts +414 -0
  234. package/lib/shared-config/src/index.ts +14 -0
  235. package/lib/shared-config/src/networks.ts +117 -0
  236. package/lib/shared-config/sync-abis.sh +92 -0
  237. package/lib/shared-config/sync-versions.mjs +150 -0
  238. package/lib/shared-config/tsconfig.json +18 -0
  239. package/lib/shared-config/tsup.config.ts +10 -0
  240. package/lib/shared-config/verify-all.sh +207 -0
  241. package/lib/shared-config/verify-contracts.sh +85 -0
  242. package/lib/shared-config/verify-mysbt-v243.mjs +27 -0
  243. package/lib/shared-config/verify-onchain-versions.mjs +93 -0
  244. package/package.json +58 -22
  245. package/packages/account/package.json +23 -0
  246. package/packages/account/src/accounts/simple.test.ts +93 -0
  247. package/packages/account/src/accounts/simple.ts +84 -0
  248. package/packages/account/src/eoa.test.ts +37 -0
  249. package/packages/account/src/eoa.ts +33 -0
  250. package/packages/account/src/index.test.ts +34 -0
  251. package/packages/account/src/index.ts +61 -0
  252. package/packages/account/tsconfig.json +11 -0
  253. package/packages/analytics/package.json +28 -0
  254. package/packages/analytics/src/index.ts +145 -0
  255. package/packages/analytics/tsconfig.json +11 -0
  256. package/packages/core/package.json +32 -0
  257. package/packages/core/scripts/audit-abi-coverage.ts +165 -0
  258. package/packages/core/scripts/debug-regex.ts +36 -0
  259. package/packages/core/src/abis/.abi-hashes.json +26 -0
  260. package/packages/core/src/abis/BLSAggregator.json +686 -0
  261. package/packages/core/src/abis/BLSValidator.json +42 -0
  262. package/packages/core/src/abis/DVTValidator.json +368 -0
  263. package/packages/core/src/abis/Eip7702Support.json +24 -0
  264. package/packages/core/src/abis/EntryPoint.json +1382 -0
  265. package/packages/core/src/abis/GToken.json +513 -0
  266. package/packages/core/src/abis/GTokenStaking.json +949 -0
  267. package/packages/core/src/abis/LegacyAccount.json +625 -0
  268. package/packages/core/src/abis/MySBT.json +1518 -0
  269. package/packages/core/src/abis/Paymaster.json +1143 -0
  270. package/packages/core/src/abis/PaymasterFactory.json +640 -0
  271. package/packages/core/src/abis/Registry.json +1942 -0
  272. package/packages/core/src/abis/ReputationSystem.json +699 -0
  273. package/packages/core/src/abis/SenderCreator.json +99 -0
  274. package/packages/core/src/abis/Simple7702Account.json +395 -0
  275. package/packages/core/src/abis/SimpleAccount.json +560 -0
  276. package/packages/core/src/abis/SimpleAccountFactory.json +111 -0
  277. package/packages/core/src/abis/SimpleAccountFactoryV08.json +87 -0
  278. package/packages/core/src/abis/SimpleAccountV08.json +557 -0
  279. package/packages/core/src/abis/SuperPaymaster.json +1781 -0
  280. package/packages/core/src/abis/UserOperationLib.json +57 -0
  281. package/packages/core/src/abis/abi.config.json +24 -0
  282. package/packages/core/src/abis/index.ts +104 -0
  283. package/packages/core/src/abis/xPNTsFactory.json +718 -0
  284. package/packages/core/src/abis/xPNTsToken.json +1280 -0
  285. package/packages/core/src/actions/StateValidator.test.ts +175 -0
  286. package/packages/core/src/actions/StateValidator.ts +253 -0
  287. package/packages/core/src/actions/account.test.ts +155 -0
  288. package/packages/core/src/actions/account.ts +179 -0
  289. package/packages/core/src/actions/aggregator.test.ts +88 -0
  290. package/packages/core/src/actions/aggregator.ts +41 -0
  291. package/packages/core/src/actions/dvt.test.ts +124 -0
  292. package/packages/core/src/actions/dvt.ts +53 -0
  293. package/packages/core/src/actions/entryPoint.test.ts +176 -0
  294. package/packages/core/src/actions/entryPoint.ts +266 -0
  295. package/packages/core/src/actions/factory.test.ts +250 -0
  296. package/packages/core/src/actions/factory.ts +613 -0
  297. package/packages/core/src/actions/faucet.test.ts +202 -0
  298. package/packages/core/src/actions/faucet.ts +421 -0
  299. package/packages/core/src/actions/gtokenExtended.test.ts +162 -0
  300. package/packages/core/src/actions/gtokenExtended.ts +153 -0
  301. package/packages/core/src/actions/index.ts +18 -0
  302. package/packages/core/src/actions/paymasterV4.test.ts +209 -0
  303. package/packages/core/src/actions/paymasterV4.ts +455 -0
  304. package/packages/core/src/actions/registry.test.ts +443 -0
  305. package/packages/core/src/actions/registry.ts +860 -0
  306. package/packages/core/src/actions/reputation.test.ts +225 -0
  307. package/packages/core/src/actions/reputation.ts +378 -0
  308. package/packages/core/src/actions/sbt.test.ts +322 -0
  309. package/packages/core/src/actions/sbt.ts +681 -0
  310. package/packages/core/src/actions/staking.test.ts +273 -0
  311. package/packages/core/src/actions/staking.ts +421 -0
  312. package/packages/core/src/actions/superPaymaster.test.ts +356 -0
  313. package/packages/core/src/actions/superPaymaster.ts +828 -0
  314. package/packages/core/src/actions/tokens.test.ts +60 -0
  315. package/packages/core/src/actions/tokens.ts +527 -0
  316. package/packages/core/src/actions/validators.test.ts +239 -0
  317. package/packages/core/src/actions/validators.ts +590 -0
  318. package/packages/core/src/branding.ts +32 -0
  319. package/packages/core/src/clients/BaseClient.ts +78 -0
  320. package/packages/core/src/clients/types.ts +69 -0
  321. package/packages/core/src/clients.ts +13 -0
  322. package/packages/core/src/communities.ts +93 -0
  323. package/packages/core/src/config/ContractConfigManager.ts +63 -0
  324. package/packages/core/src/constants.ts +145 -0
  325. package/packages/core/src/contract-addresses.ts +125 -0
  326. package/packages/core/src/contracts.test.ts +58 -0
  327. package/packages/core/src/contracts.ts +414 -0
  328. package/packages/core/src/crypto/blsSigner.ts +124 -0
  329. package/packages/core/src/crypto/index.ts +1 -0
  330. package/packages/core/src/index.ts +22 -0
  331. package/packages/core/src/networks.ts +127 -0
  332. package/packages/core/src/requirementChecker.test.ts +71 -0
  333. package/packages/core/src/requirementChecker.ts +187 -0
  334. package/packages/core/src/roles.test.ts +34 -0
  335. package/packages/core/src/roles.ts +255 -0
  336. package/packages/core/src/utils/validation.test.ts +50 -0
  337. package/packages/core/src/utils/validation.ts +66 -0
  338. package/packages/core/src/utils.ts +23 -0
  339. package/packages/core/tsconfig.json +12 -0
  340. package/packages/core/vitest.config.ts +14 -0
  341. package/packages/dapp/package.json +30 -0
  342. package/packages/dapp/src/index.ts +4 -0
  343. package/packages/dapp/src/ui/components/EvaluationPanel.tsx +40 -0
  344. package/packages/dapp/src/ui/hooks/useCreditScore.ts +44 -0
  345. package/packages/dapp/src/ui/hooks/useSuperPaymaster.ts +31 -0
  346. package/packages/dapp/src/ui/index.ts +22 -0
  347. package/packages/dapp/tsconfig.json +12 -0
  348. package/packages/identity/package.json +25 -0
  349. package/packages/identity/src/index.ts +114 -0
  350. package/packages/identity/src/mysbt.ts +48 -0
  351. package/packages/identity/tsconfig.json +11 -0
  352. package/packages/paymaster/package.json +25 -0
  353. package/packages/paymaster/src/SuperPaymaster/index.ts +168 -0
  354. package/packages/paymaster/src/V4/PaymasterClient.test.ts +114 -0
  355. package/packages/paymaster/src/V4/PaymasterClient.ts +385 -0
  356. package/packages/paymaster/src/V4/PaymasterOperator.test.ts +80 -0
  357. package/packages/paymaster/src/V4/PaymasterOperator.ts +282 -0
  358. package/packages/paymaster/src/V4/PaymasterUtils.test.ts +54 -0
  359. package/packages/paymaster/src/V4/PaymasterUtils.ts +185 -0
  360. package/packages/paymaster/src/V4/SuperPaymasterClient.test.ts +79 -0
  361. package/packages/paymaster/src/V4/SuperPaymasterClient.ts +123 -0
  362. package/packages/paymaster/src/V4/index.ts +4 -0
  363. package/packages/paymaster/src/index.ts +5 -0
  364. package/packages/paymaster/tsconfig.json +11 -0
  365. package/packages/sdk/README.md +150 -0
  366. package/packages/sdk/aastar/package.json +21 -0
  367. package/packages/sdk/aastar/src/index.ts +3 -0
  368. package/packages/sdk/aastar/tsconfig.json +7 -0
  369. package/packages/sdk/coverage_output.txt +393 -0
  370. package/packages/sdk/coverage_output_final.txt +739 -0
  371. package/packages/sdk/coverage_output_final_v2.txt +722 -0
  372. package/packages/sdk/coverage_output_final_v3.txt +722 -0
  373. package/packages/sdk/examples/config.json +1 -0
  374. package/packages/sdk/examples/regression_test.ts +106 -0
  375. package/packages/sdk/package.json +44 -0
  376. package/packages/sdk/src/clients/ExperimentClient.test.ts +65 -0
  377. package/packages/sdk/src/clients/ExperimentClient.ts +80 -0
  378. package/packages/sdk/src/clients/admin.test.ts +98 -0
  379. package/packages/sdk/src/clients/admin.ts +154 -0
  380. package/packages/sdk/src/clients/clients.test.ts +104 -0
  381. package/packages/sdk/src/clients/community.test.ts +118 -0
  382. package/packages/sdk/src/clients/community.ts +337 -0
  383. package/packages/sdk/src/clients/endUser.test.ts +221 -0
  384. package/packages/sdk/src/clients/endUser.ts +551 -0
  385. package/packages/sdk/src/clients/operator.test.ts +162 -0
  386. package/packages/sdk/src/clients/operator.ts +355 -0
  387. package/packages/sdk/src/errors/AAStarError.test.ts +92 -0
  388. package/packages/sdk/src/errors/AAStarError.ts +70 -0
  389. package/packages/sdk/src/errors/decoder.test.ts +107 -0
  390. package/packages/sdk/src/errors/decoder.ts +91 -0
  391. package/packages/sdk/src/index.ts +23 -0
  392. package/packages/sdk/src/node/index.ts +8 -0
  393. package/packages/sdk/src/types/result.ts +29 -0
  394. package/packages/sdk/src/utils/errorHandler.test.ts +102 -0
  395. package/packages/sdk/src/utils/errorHandler.ts +167 -0
  396. package/packages/sdk/src/utils/eventDecoder.test.ts +56 -0
  397. package/packages/sdk/src/utils/eventDecoder.ts +66 -0
  398. package/packages/sdk/src/utils/funding.test.ts +117 -0
  399. package/packages/sdk/src/utils/funding.ts +280 -0
  400. package/packages/sdk/src/utils/keys.test.ts +105 -0
  401. package/packages/sdk/src/utils/keys.ts +174 -0
  402. package/packages/sdk/src/utils/roleData.test.ts +85 -0
  403. package/packages/sdk/src/utils/roleData.ts +140 -0
  404. package/packages/sdk/src/utils/testScenarios.test.ts +79 -0
  405. package/packages/sdk/src/utils/testScenarios.ts +128 -0
  406. package/packages/sdk/src/utils/userOp.test.ts +190 -0
  407. package/packages/sdk/src/utils/userOp.ts +265 -0
  408. package/packages/sdk/tests/scenarios/01_onboard_community.ts +62 -0
  409. package/packages/sdk/tests/scenarios/02_onboard_operator.ts +109 -0
  410. package/packages/sdk/tests/scenarios/03_onboard_user.ts +53 -0
  411. package/packages/sdk/tests/scenarios/04_gasless_tx_flow.ts +68 -0
  412. package/packages/sdk/tests/scenarios/check_entrypoint.ts +19 -0
  413. package/packages/sdk/tests/scenarios/check_initialization.ts +65 -0
  414. package/packages/sdk/tests/scenarios/debug_addresses.ts +26 -0
  415. package/packages/sdk/tests/scenarios/diagnose_scenario4.ts +55 -0
  416. package/packages/sdk/tests/scenarios/setup.ts +33 -0
  417. package/packages/sdk/tests/scenarios/test_entrypoint_nonce.ts +46 -0
  418. package/packages/sdk/tsconfig.json +11 -0
  419. package/packages/tokens/package.json +25 -0
  420. package/packages/tokens/src/index.ts +273 -0
  421. package/packages/tokens/tsconfig.json +11 -0
  422. package/pnpm-workspace.yaml +2 -0
  423. package/run_l4_gasless_regression.sh +79 -0
  424. package/run_sdk_regression.sh +238 -0
  425. package/scripts/00_utils.ts +59 -0
  426. package/scripts/00_verify_phase1.ts +130 -0
  427. package/scripts/01_1_prep_gtoken.ts +81 -0
  428. package/scripts/01_2_register_sbt.ts +88 -0
  429. package/scripts/01_3_prep_tokens_paymaster.ts +102 -0
  430. package/scripts/01_prepare_all.ts +222 -0
  431. package/scripts/02_test_eoa.ts +53 -0
  432. package/scripts/03_test_standard_aa.ts +68 -0
  433. package/scripts/04_0_check_deploy.ts +24 -0
  434. package/scripts/04_1_check_allowance.ts +44 -0
  435. package/scripts/04_2_construct_verify.ts +96 -0
  436. package/scripts/04_3_verify_estimate.ts +66 -0
  437. package/scripts/04_4_verify_pack.ts +74 -0
  438. package/scripts/04_test_paymaster_v4.ts +60 -0
  439. package/scripts/05_1_deposit.ts +48 -0
  440. package/scripts/05_test_superpaymaster.ts +58 -0
  441. package/scripts/06_local_test_v3_admin.ts +163 -0
  442. package/scripts/06_local_test_v3_execution.ts +132 -0
  443. package/scripts/06_local_test_v3_full.ts +490 -0
  444. package/scripts/06_local_test_v3_funding.ts +124 -0
  445. package/scripts/06_local_test_v3_reputation.ts +234 -0
  446. package/scripts/07_local_test_v3_audit.ts +181 -0
  447. package/scripts/08_local_test_registry_lifecycle.ts +382 -0
  448. package/scripts/09_local_test_community_lifecycle.ts +385 -0
  449. package/scripts/09_local_test_community_simple.ts +108 -0
  450. package/scripts/09_scenario_bread_independent.ts +247 -0
  451. package/scripts/10_scenario_super_shared.ts +196 -0
  452. package/scripts/10_test_protocol_admin_full.ts +173 -0
  453. package/scripts/11_scenario_hacker_defense.ts +104 -0
  454. package/scripts/11_test_core_flows_full.ts +157 -0
  455. package/scripts/12_test_slash_mechanism.ts +205 -0
  456. package/scripts/12_test_slash_queries.ts +83 -0
  457. package/scripts/12_test_staking_exit.ts +152 -0
  458. package/scripts/12_test_staking_slash.ts +301 -0
  459. package/scripts/12_test_tier2_slash.ts +139 -0
  460. package/scripts/13_test_sbt_burn_linkage.ts +266 -0
  461. package/scripts/14_test_credit_redesign.ts +266 -0
  462. package/scripts/15_test_bls_full.ts +148 -0
  463. package/scripts/15_test_dvt_bls_full.ts +140 -0
  464. package/scripts/17_test_cross_role_collaboration.ts +95 -0
  465. package/scripts/18_sdk_e2e_verification.ts +67 -0
  466. package/scripts/18_test_dvt_sdk_flow.ts +138 -0
  467. package/scripts/18_test_lifecycle_completion.ts +144 -0
  468. package/scripts/19_sdk_experiment_runner.ts +114 -0
  469. package/scripts/19_sdk_experiment_runner.ts.backup +391 -0
  470. package/scripts/20_sdk_full_capability.ts +93 -0
  471. package/scripts/20_test_superpaymaster_new_apis.ts +193 -0
  472. package/scripts/21_test_paymasterv4_complete.ts +341 -0
  473. package/scripts/22_test_bls_signing.ts +260 -0
  474. package/scripts/23_test_middleware.ts +197 -0
  475. package/scripts/98_edge_reentrancy.ts +85 -0
  476. package/scripts/99_bug_hunting_fast.ts +99 -0
  477. package/scripts/analyze_abi_coverage.ts +169 -0
  478. package/scripts/check-admin.ts +95 -0
  479. package/scripts/check-jason-status.ts +184 -0
  480. package/scripts/check-roles.ts +36 -0
  481. package/scripts/clear-nonce.ts +47 -0
  482. package/scripts/collect_industry_baseline.ts +236 -0
  483. package/scripts/complete-jack-superpaymaster.ts +171 -0
  484. package/scripts/complete_env_config.ts +97 -0
  485. package/scripts/debug-addr.ts +43 -0
  486. package/scripts/debug-community-registration.ts +92 -0
  487. package/scripts/debug-deploy-v4.ts +116 -0
  488. package/scripts/debug-paymaster.ts +127 -0
  489. package/scripts/debug-register-role.ts +101 -0
  490. package/scripts/debug-version.ts +71 -0
  491. package/scripts/debug_account_c.ts +43 -0
  492. package/scripts/debug_bls.ts +58 -0
  493. package/scripts/debug_config_v036.ts +13 -0
  494. package/scripts/debug_contracts.ts +2 -0
  495. package/scripts/debug_env.ts +69 -0
  496. package/scripts/debug_find_paymaster.ts +98 -0
  497. package/scripts/debug_isolated_registration.ts +256 -0
  498. package/scripts/debug_paymaster_config.ts +19 -0
  499. package/scripts/debug_pim_addr.ts +23 -0
  500. package/scripts/debug_pm_status.ts +51 -0
  501. package/scripts/debug_registry.ts +39 -0
  502. package/scripts/debug_registry_setup.ts +129 -0
  503. package/scripts/debug_sanity.ts +32 -0
  504. package/scripts/debug_shared_config.ts +10 -0
  505. package/scripts/debug_token_compat.ts +51 -0
  506. package/scripts/debug_tokens.ts +41 -0
  507. package/scripts/debug_vcheck.ts +33 -0
  508. package/scripts/deploy-sync.ts +104 -0
  509. package/scripts/deploy_and_init_v3.sh +134 -0
  510. package/scripts/deploy_anvil_accounts.ts +144 -0
  511. package/scripts/deploy_paymaster_v4.ts +139 -0
  512. package/scripts/deploy_test_accounts.ts +401 -0
  513. package/scripts/deprecated/check_aa_entrypoint.ts +29 -0
  514. package/scripts/deprecated/check_paymaster_deposits.ts +45 -0
  515. package/scripts/deprecated/debug_aoa_function.ts +28 -0
  516. package/scripts/deprecated/debug_aoa_issue.ts +16 -0
  517. package/scripts/deprecated/debug_pimlico_aa23.ts +40 -0
  518. package/scripts/deprecated/debug_summary.ts +34 -0
  519. package/scripts/deprecated/deploy_v07_aa.ts +99 -0
  520. package/scripts/deprecated/fix_all_issues.ts +61 -0
  521. package/scripts/deprecated/fund_bpnts.ts +52 -0
  522. package/scripts/deprecated/get_factory_addresses.ts +28 -0
  523. package/scripts/deprecated/recheck_pim.ts +34 -0
  524. package/scripts/dev_tools/extract_abis.sh +151 -0
  525. package/scripts/dev_tools/extract_addresses_to_env.sh +67 -0
  526. package/scripts/dev_tools/final_safe_harmonize.py +77 -0
  527. package/scripts/dev_tools/safe_harmonize.py +107 -0
  528. package/scripts/dev_tools/surgical_harmonize.py +83 -0
  529. package/scripts/experiment/stage3/SETUP_GUIDE.md +258 -0
  530. package/scripts/experiment/stage3/archived_scripts/00_token_distribution.ts +78 -0
  531. package/scripts/experiment/stage3/archived_scripts/01_dao_launch.ts +96 -0
  532. package/scripts/experiment/stage3/archived_scripts/01b_bread_launch.ts +112 -0
  533. package/scripts/experiment/stage3/archived_scripts/02_operator_setup.ts +84 -0
  534. package/scripts/experiment/stage3/archived_scripts/02b_operator_b_setup.ts +104 -0
  535. package/scripts/experiment/stage3/archived_scripts/02c_finalize_operators.ts +86 -0
  536. package/scripts/experiment/stage3/archived_scripts/02d_operator_collateral.ts +89 -0
  537. package/scripts/experiment/stage3/archived_scripts/03_user_onboarding.ts +83 -0
  538. package/scripts/experiment/stage3/archived_scripts/03b_deploy_aa_account.ts +61 -0
  539. package/scripts/experiment/stage3/archived_scripts/03c_aa_onboarding.ts +104 -0
  540. package/scripts/experiment/stage3/archived_scripts/03d_mint_points.ts +60 -0
  541. package/scripts/experiment/stage3/archived_scripts/04_benchmarking.ts +100 -0
  542. package/scripts/experiment/stage3/archived_scripts/05_multi_op_setup.ts +149 -0
  543. package/scripts/experiment/stage3/archived_scripts/README.md +58 -0
  544. package/scripts/experiment/stage3/archived_scripts/check_roles.ts +29 -0
  545. package/scripts/experiment/stage3/archived_scripts/decode_error.ts +23 -0
  546. package/scripts/experiment/stage3/archived_scripts/fund_user.ts +51 -0
  547. package/scripts/experiment/stage3/archived_scripts/gen_b_key.ts +3 -0
  548. package/scripts/experiment/stage3/archived_scripts/gen_keys.ts +4 -0
  549. package/scripts/experiment/stage3/archived_scripts/setup.ts +105 -0
  550. package/scripts/experiment/stage3/archived_scripts/test_key.ts +4 -0
  551. package/scripts/experiment/stage3/archived_scripts/verify_state.ts +59 -0
  552. package/scripts/experiment/stage3/refactored/00_token_distribution.ts +46 -0
  553. package/scripts/experiment/stage3/refactored/02_operator_setup.ts +65 -0
  554. package/scripts/experiment/stage3/refactored/03_user_onboarding.ts +68 -0
  555. package/scripts/experiment/stage3/refactored/05_multi_op_setup.ts +63 -0
  556. package/scripts/experiment/stage3/refactored/README.md +71 -0
  557. package/scripts/extract-docs.sh +141 -0
  558. package/scripts/fund-jack.ts +38 -0
  559. package/scripts/generate_env_from_deployment.ts +109 -0
  560. package/scripts/inspect-anni-token.ts +116 -0
  561. package/scripts/inspect-factory.ts +83 -0
  562. package/scripts/l4-paymasterv4-transfer-test.ts +228 -0
  563. package/scripts/l4-setup.ts +453 -0
  564. package/scripts/l4-state.json +80 -0
  565. package/scripts/phase1_verify_contracts.ts +207 -0
  566. package/scripts/pre_test_sync.ts +83 -0
  567. package/scripts/prepare_sepolia_resources.ts +154 -0
  568. package/scripts/publish_all.sh +39 -0
  569. package/scripts/query-jack-token.ts +22 -0
  570. package/scripts/quick_setup.ts +124 -0
  571. package/scripts/quick_setup_account.ts +80 -0
  572. package/scripts/run_automated_experiment.sh +121 -0
  573. package/scripts/run_daily_experiment.ts +70 -0
  574. package/scripts/run_l4_gasless_regression.sh +32 -0
  575. package/scripts/run_sdk_experiment.sh +13 -0
  576. package/scripts/run_sdk_regression-v2.sh +38 -0
  577. package/scripts/sdk_regression_v2.ts +162 -0
  578. package/scripts/security_audit.sh +172 -0
  579. package/scripts/setup-bbq-community.ts +187 -0
  580. package/scripts/setup-dancing-community.ts +223 -0
  581. package/scripts/setup_test_accounts.ts +88 -0
  582. package/scripts/setup_test_environment.ts +147 -0
  583. package/scripts/sync_anvil_config.cjs +44 -0
  584. package/scripts/sync_config_to_env.ts +88 -0
  585. package/scripts/sync_contract_addresses.ts +186 -0
  586. package/scripts/sync_sepolia_config.cjs +90 -0
  587. package/scripts/sync_sepolia_config.mjs +74 -0
  588. package/scripts/test-brown-v4-deploy.ts +90 -0
  589. package/scripts/test-faucet-and-gasless.ts +170 -0
  590. package/scripts/test-jack-gasless.ts +119 -0
  591. package/scripts/test-jack-registration.ts +133 -0
  592. package/scripts/test-jack-superpaymaster-api.ts +112 -0
  593. package/scripts/test-kms-gasless.ts +138 -0
  594. package/scripts/test_groups.ts +138 -0
  595. package/scripts/test_multi_community_anvil.ts +276 -0
  596. package/scripts/test_new_sdk_apis_sepolia.ts +193 -0
  597. package/scripts/test_sdk_join_idempotent.ts +233 -0
  598. package/scripts/test_simple_sepolia.ts +44 -0
  599. package/scripts/update_env_from_config.ts +83 -0
  600. package/scripts/v2_regression/00_validate_env.ts +101 -0
  601. package/scripts/v2_regression/01_setup_and_fund.ts +132 -0
  602. package/scripts/v2_regression/02_operator_onboarding.ts +174 -0
  603. package/scripts/v2_regression/03_community_registry.ts +139 -0
  604. package/scripts/v2_regression/04_enduser_flow.ts +141 -0
  605. package/scripts/v2_regression/05_admin_audit.ts +157 -0
  606. package/scripts/v2_regression/README.md +161 -0
  607. package/scripts/validate_env.ts +112 -0
  608. package/scripts/verify-tx-status.ts +81 -0
  609. package/scripts/verify_onchain_milestone.ts +114 -0
  610. package/scripts/verify_phase1.ts +66 -0
  611. package/scripts/verify_phase2.ts +66 -0
  612. package/sdk_experiment_data.csv +4 -0
  613. package/simple-test-paymaster.sh +2 -0
  614. package/simple-test-superpaymaster.sh +1 -0
  615. package/tests/l1-regression.test.ts +458 -0
  616. package/tests/l4-test-anni-gasless.ts +105 -0
  617. package/tests/l4-test-jason1-gasless.ts +150 -0
  618. package/tests/l4-test-jason2-gasless.ts +174 -0
  619. package/tests/l4-test-pmv4-deposit.ts +111 -0
  620. package/tests/l4-test-pmv4-gasless.ts +166 -0
  621. package/tests/l4-test-pmv4-submit.ts +223 -0
  622. package/tests/regression/README.md +168 -0
  623. package/tests/regression/config.ts +215 -0
  624. package/tests/regression/display-versions.ts +85 -0
  625. package/tests/regression/index.ts +67 -0
  626. package/tests/regression/l1-tests.ts +267 -0
  627. package/tests/regression/l2-tests.ts +171 -0
  628. package/tests/regression/l3-tests.ts +125 -0
  629. package/tests/regression/l4-gasless.ts +897 -0
  630. package/tests/regression/l4-runner.ts +52 -0
  631. package/tests/reports/phase1_contract_verification.md +45 -0
  632. package/tests/utils/contractVerifier.ts +237 -0
  633. package/tests/utils/userOpHelper.ts +194 -0
  634. package/tsconfig.json +41 -0
  635. package/typedoc.json +59 -0
  636. package/vitest.config.ts +16 -0
  637. package/dist/clients/admin.d.ts +0 -12
  638. package/dist/clients/admin.d.ts.map +0 -1
  639. package/dist/clients/admin.js +0 -20
  640. package/dist/clients/admin.js.map +0 -1
  641. package/dist/clients/community.d.ts +0 -12
  642. package/dist/clients/community.d.ts.map +0 -1
  643. package/dist/clients/community.js +0 -18
  644. package/dist/clients/community.js.map +0 -1
  645. package/dist/clients/endUser.d.ts +0 -12
  646. package/dist/clients/endUser.d.ts.map +0 -1
  647. package/dist/clients/endUser.js +0 -20
  648. package/dist/clients/endUser.js.map +0 -1
  649. package/dist/clients/operator.d.ts +0 -18
  650. package/dist/clients/operator.d.ts.map +0 -1
  651. package/dist/clients/operator.js +0 -65
  652. package/dist/clients/operator.js.map +0 -1
  653. package/dist/index.d.ts +0 -11
  654. package/dist/index.d.ts.map +0 -1
  655. package/dist/index.js +0 -12
  656. package/dist/index.js.map +0 -1
@@ -0,0 +1,320 @@
1
+ # 🚀 AAStar SDK 测试命令完整指南
2
+
3
+ 本文档提供所有测试命令的详细说明,包括如何在不同网络间切换。
4
+
5
+ ---
6
+
7
+ ## 📋 快速参考
8
+
9
+ ### 主要测试命令
10
+
11
+ | 命令 | 用途 | 网络依赖 | 时间 |
12
+ |------|------|---------|------|
13
+ | `pnpm run test:full_anvil` | 完整协议回归(72场景) | Anvil专用 | 5-10分钟 |
14
+ | `pnpm run test:full_sdk` | SDK功能验证(6场景) | **任意网络** | ~30秒 |
15
+ | `pnpm run test:init` | 环境初始化 | Anvil | ~2分钟 |
16
+
17
+ ---
18
+
19
+ ## 🌐 网络切换指南(适用于 `test:full_sdk`)
20
+
21
+ `test:full_sdk` 可以在任意EVM网络上运行,只需修改配置文件:
22
+
23
+ ### 方法1: 使用不同的 `.env` 文件
24
+
25
+ #### 步骤1: 创建网络专用配置文件
26
+
27
+ ```bash
28
+ # Sepolia测试网配置
29
+ cp .env.v3 .env.sepolia
30
+
31
+ # Mainnet配置
32
+ cp .env.v3 .env.mainnet
33
+ ```
34
+
35
+ #### 步骤2: 编辑配置文件
36
+
37
+ **`.env.sepolia` 示例**:
38
+ ```bash
39
+ # 网络RPC
40
+ RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_API_KEY
41
+
42
+ # 管理员私钥(请从加密存储中读取,不要硬编码!)
43
+ ADMIN_KEY=0x...
44
+
45
+ # Sepolia上的合约地址
46
+ REGISTRY_ADDRESS=0x1234...
47
+ GTOKEN_ADDRESS=0x5678...
48
+ GTOKEN_STAKING_ADDRESS=0x9abc...
49
+ SUPER_PAYMASTER_ADDRESS=0xdef0...
50
+ APNTS_ADDRESS=0x1111...
51
+ MYSBT_ADDRESS=0x2222...
52
+ ```
53
+
54
+ **`.env.mainnet` 示例**:
55
+ ```bash
56
+ # Mainnet RPC
57
+ RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY
58
+
59
+ # 管理员私钥
60
+ ADMIN_KEY=0x...
61
+
62
+ # Mainnet合约地址
63
+ REGISTRY_ADDRESS=0xMainnetRegistry...
64
+ GTOKEN_ADDRESS=0xMainnetGToken...
65
+ GTOKEN_STAKING_ADDRESS=0xMainnetStaking...
66
+ SUPER_PAYMASTER_ADDRESS=0xMainnetPaymaster...
67
+ APNTS_ADDRESS=0xMainnetAPNTs...
68
+ MYSBT_ADDRESS=0xMainnetSBT...
69
+ ```
70
+
71
+ #### 步骤3: 运行测试时指定配置
72
+
73
+ 修改 `scripts/99_final_v2_regression.ts` 第26行:
74
+
75
+ ```typescript
76
+ // 默认(Anvil本地)
77
+ dotenv.config({ path: path.resolve(process.cwd(), '.env.v3') });
78
+
79
+ // 切换到Sepolia
80
+ dotenv.config({ path: path.resolve(process.cwd(), '.env.sepolia') });
81
+
82
+ // 切换到Mainnet
83
+ dotenv.config({ path: path.resolve(process.cwd(), '.env.mainnet') });
84
+ ```
85
+
86
+ ---
87
+
88
+ ### 方法2: 使用环境变量覆盖(推荐)
89
+
90
+ 无需修改代码,直接在命令行传递参数:
91
+
92
+ ```bash
93
+ # Sepolia测试
94
+ RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY \
95
+ ADMIN_KEY=0xYourKey \
96
+ REGISTRY_ADDRESS=0x... \
97
+ pnpm run test:full_sdk
98
+
99
+ # Mainnet测试(只读操作)
100
+ RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY \
101
+ ADMIN_KEY=0xYourKey \
102
+ REGISTRY_ADDRESS=0x... \
103
+ pnpm run test:full_sdk
104
+ ```
105
+
106
+ ---
107
+
108
+ ### 方法3: 创建网络专用脚本(最佳实践)
109
+
110
+ 在 `package.json` 中添加:
111
+
112
+ ```json
113
+ {
114
+ "scripts": {
115
+ "test:sdk:sepolia": "dotenv -e .env.sepolia -- tsx scripts/99_final_v2_regression.ts",
116
+ "test:sdk:mainnet": "dotenv -e .env.mainnet -- tsx scripts/99_final_v2_regression.ts"
117
+ }
118
+ }
119
+ ```
120
+
121
+ 然后安装 `dotenv-cli`:
122
+ ```bash
123
+ pnpm add -D dotenv-cli
124
+ ```
125
+
126
+ 使用:
127
+ ```bash
128
+ pnpm run test:sdk:sepolia
129
+ pnpm run test:sdk:mainnet
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 📝 详细命令说明
135
+
136
+ ### 1. **完整协议回归测试** - `test:full_anvil`
137
+
138
+ ```bash
139
+ pnpm run test:full_anvil
140
+ ```
141
+
142
+ **特点**:
143
+ - 🔄 自动重启Anvil(干净状态)
144
+ - 📦 自动部署所有合约
145
+ - 🔄 自动同步配置和ABI
146
+ - 🧪 运行17个独立测试脚本
147
+ - ⚠️ **仅支持Anvil**(使用 `anvil_setBalance`, `anvil_impersonateAccount` 等特殊功能)
148
+
149
+ **覆盖范围**:
150
+ - 72个完整场景
151
+ - 95%分支覆盖率
152
+ - 包含所有协议功能(Admin、Staking、Slashing、Credit、DVT、SBT等)
153
+
154
+ **适用场景**:
155
+ - 本地开发验证
156
+ - CI/CD集成测试
157
+ - 完整功能回归
158
+
159
+ ---
160
+
161
+ ### 2. **SDK功能验证** - `test:full_sdk`
162
+
163
+ ```bash
164
+ pnpm run test:full_sdk
165
+ ```
166
+
167
+ **特点**:
168
+ - 🌐 **支持任意EVM网络**(Anvil/Sepolia/Mainnet)
169
+ - 🚀 快速执行(~30秒)
170
+ - 🔍 验证SDK核心架构
171
+ - ✅ 自动初始化(检测Anvil,自动运行 `test:init`)
172
+
173
+ **测试场景** (6个核心):
174
+ 1. ✅ Operator Staking (质押)
175
+ 2. ✅ Paymaster Deposit (存款-Push模式)
176
+ 3. ✅ Community Registration (社区注册)
177
+ 4. ✅ SBT Minting (SBT铸造)
178
+ 5. ✅ Admin Slashing (惩罚)
179
+ 6. ✅ Credit Query (信用查询)
180
+
181
+ **网络切换**: 参见上方 [🌐 网络切换指南](#🌐-网络切换指南(适用于-test_full_sdk))
182
+
183
+ ---
184
+
185
+ ### 3. **环境初始化** - `test:init`
186
+
187
+ ```bash
188
+ pnpm run test:init
189
+ ```
190
+
191
+ **功能**:
192
+ - 重启Anvil节点
193
+ - 部署所有合约到本地
194
+ - 提取ABI到 `packages/core/src/abis/`
195
+ - 同步配置到 `.env.v3`
196
+
197
+ **用途**:
198
+ - 手动调试前的环境准备
199
+ - 合约更新后重新部署
200
+
201
+ ---
202
+
203
+ ### 4. **专项测试命令**
204
+
205
+ #### 协议管理测试
206
+ ```bash
207
+ pnpm run test:admin
208
+ ```
209
+ 测试角色配置、费用设置、暂停等管理功能。
210
+
211
+ #### 信用系统测试
212
+ ```bash
213
+ pnpm run test:credit
214
+ ```
215
+ 测试信用限额、债务跟踪、自动还款。
216
+
217
+ #### 重入攻击测试
218
+ ```bash
219
+ pnpm run test:reentrancy
220
+ ```
221
+ 测试重入保护机制。
222
+
223
+ ---
224
+
225
+ ## 🔧 常见问题排查
226
+
227
+ ### 问题1: SDK测试失败,提示 "Contract not found"
228
+
229
+ **原因**: 合约地址在目标网络上不存在
230
+
231
+ **解决**:
232
+ ```bash
233
+ # 1. 检查.env配置
234
+ cat .env.v3
235
+
236
+ # 2. 验证合约是否部署
237
+ cast code $REGISTRY_ADDRESS --rpc-url $RPC_URL
238
+
239
+ # 3. 如果未部署,需先部署合约(Sepolia/Mainnet)
240
+ cd ../SuperPaymaster
241
+ forge script script/v3/DeployV3Sepolia.s.sol --rpc-url $SEPOLIA_RPC --broadcast
242
+ ```
243
+
244
+ ### 问题2: RPC速率限制
245
+
246
+ **解决**: 使用付费RPC节点(Alchemy/Infura)或降低并发:
247
+
248
+ ```typescript
249
+ // 在测试脚本中添加延迟
250
+ await new Promise(resolve => setTimeout(resolve, 1000)); // 1秒延迟
251
+ ```
252
+
253
+ ### 问题3: Gas不足(Sepolia/Mainnet)
254
+
255
+ **解决**: 确保测试账户有足够ETH:
256
+
257
+ ```bash
258
+ # 查看余额
259
+ cast balance $ADMIN_ADDRESS --rpc-url $RPC_URL
260
+
261
+ # Sepolia水龙头
262
+ # https://sepoliafaucet.com/
263
+ # https://www.alchemy.com/faucets/ethereum-sepolia
264
+ ```
265
+
266
+ ---
267
+
268
+ ## 📊 测试覆盖率对比
269
+
270
+ | 测试套件 | 场景数 | 分支覆盖 | 网络支持 | 执行时间 |
271
+ |---------|-------|---------|---------|---------|
272
+ | `test:full_anvil` | 72 | 95% | Anvil | 5-10分钟 |
273
+ | `test:full_sdk` | 6 | SDK核心 | **任意** | ~30秒 |
274
+ | 专项测试 | 1-5/个 | 特定功能 | 视情况 | 10-60秒 |
275
+
276
+ ---
277
+
278
+ ## 🎯 推荐工作流
279
+
280
+ ### 本地开发
281
+ ```bash
282
+ # 1. 启动环境
283
+ pnpm run test:init
284
+
285
+ # 2. 快速SDK验证
286
+ pnpm run test:full_sdk
287
+
288
+ # 3. 完整回归(发版前)
289
+ pnpm run test:full_anvil
290
+ ```
291
+
292
+ ### 测试网验证
293
+ ```bash
294
+ # 1. 配置Sepolia环境
295
+ cp .env.v3 .env.sepolia
296
+ # 编辑 .env.sepolia,填入Sepolia合约地址
297
+
298
+ # 2. 运行SDK测试
299
+ dotenv -e .env.sepolia -- pnpm run test:full_sdk
300
+ ```
301
+
302
+ ### 生产环境只读验证
303
+ ```bash
304
+ # 仅查询,不执行交易
305
+ RPC_URL=https://eth-mainnet.g.alchemy.com/v2/KEY \
306
+ REGISTRY_ADDRESS=0xMainnetAddr \
307
+ pnpm run test:full_sdk
308
+ ```
309
+
310
+ ---
311
+
312
+ ## 🔗 相关资源
313
+
314
+ - **SDK开发指南**: [`README.md`](../README.md)
315
+ - **合约部署**: [`../SuperPaymaster/README.md`](../../SuperPaymaster/README.md)
316
+ - **架构设计**: [`docs/task_breakdown.md`](./task_breakdown.md)
317
+
318
+ ---
319
+
320
+ **由 AAStarCommunity 维护 | 最后更新: 2025-12-24**
@@ -0,0 +1,95 @@
1
+ # Account Abstraction
2
+
3
+ Understanding Account Abstraction (ERC-4337) in AAStar SDK.
4
+
5
+ ## What is Account Abstraction?
6
+
7
+ Account Abstraction (AA) allows users to use smart contract wallets instead of traditional Externally Owned Accounts (EOAs). This enables advanced features like:
8
+
9
+ - **Gasless Transactions**: Users don't need ETH for gas
10
+ - **Social Recovery**: Recover accounts without seed phrases
11
+ - **Session Keys**: Temporary permissions for DApps
12
+ - **Batch Transactions**: Multiple operations in one transaction
13
+ - **Custom Validation**: Flexible signature schemes
14
+
15
+ ## ERC-4337 Overview
16
+
17
+ ERC-4337 is the standard for Account Abstraction. Key components:
18
+
19
+ ### UserOperation
20
+
21
+ A pseudo-transaction object that represents a user's intent:
22
+
23
+ ```typescript
24
+ interface UserOperation {
25
+ sender: Address; // Smart account address
26
+ nonce: bigint; // Anti-replay protection
27
+ callData: Hex; // Actual transaction data
28
+ paymasterAndData: Hex; // Paymaster info (for gasless tx)
29
+ signature: Hex; // User signature
30
+ // ... gas fields
31
+ }
32
+ ```
33
+
34
+ ### EntryPoint
35
+
36
+ The singleton contract that processes UserOperations.
37
+
38
+ ### Bundler
39
+
40
+ Off-chain service that bundles UserOperations and submits them to the EntryPoint.
41
+
42
+ ### Paymaster
43
+
44
+ Contract that sponsors gas fees for users.
45
+
46
+ ## AAStar Implementation
47
+
48
+ AAStar SDK provides a complete AA infrastructure:
49
+
50
+ ### Smart Accounts
51
+
52
+ ```typescript
53
+ import { createSmartAccount } from '@aastar/account';
54
+
55
+ const account = await createSmartAccount({
56
+ owner: ownerAddress,
57
+ salt: 0n,
58
+ factoryAddress: CONTRACTS.sepolia.simpleAccountFactory,
59
+ });
60
+ ```
61
+
62
+ ### Gasless Transactions
63
+
64
+ ```typescript
65
+ import { createEndUserClient } from '@aastar/core';
66
+
67
+ const user = createEndUserClient({...});
68
+
69
+ // Check eligibility
70
+ const eligible = await user.checkEligibility(communityAddress);
71
+
72
+ if (eligible) {
73
+ // Send gasless transaction
74
+ await sendGaslessTransaction();
75
+ }
76
+ ```
77
+
78
+ ## Benefits
79
+
80
+ 1. **Better UX**: Users don't need to understand gas or hold ETH
81
+ 2. **Security**: Smart contract wallets are more secure than EOAs
82
+ 3. **Flexibility**: Custom validation logic and recovery mechanisms
83
+ 4. **Programmability**: Wallets can have complex logic
84
+
85
+ ## Learn More
86
+
87
+ - [ERC-4337 Specification](https://eips.ethereum.org/EIPS/eip-4337)
88
+ - [Account Module API](/api/modules/account)
89
+ - [End User API](/api/roles/enduser)
90
+
91
+ ## Next Steps
92
+
93
+ - [SuperPaymaster (AOA+)](/guide/concepts/superpaymaster)
94
+ - [Quick Start](/guide/quick-start)
95
+ - [Examples](/examples/)
@@ -0,0 +1,68 @@
1
+ # EOA Rainbow Bridge
2
+
3
+ Seamlessly bridge between traditional EOA wallets and smart contract accounts.
4
+
5
+ ## Overview
6
+
7
+ The EOA Rainbow Bridge enables users to:
8
+ - Use existing EOA wallets
9
+ - Upgrade to smart accounts
10
+ - Maintain backward compatibility
11
+ - Seamless transition
12
+
13
+ ## How It Works
14
+
15
+ ```
16
+ EOA Wallet → Rainbow Bridge → Smart Account
17
+ ↓ ↓ ↓
18
+ Private Key Ownership Advanced Features
19
+ ```
20
+
21
+ ## Implementation
22
+
23
+ ```typescript
24
+ import { createSmartAccount } from '@aastar/account';
25
+ import { privateKeyToAccount } from 'viem/accounts';
26
+
27
+ // 1. Start with EOA
28
+ const eoaAccount = privateKeyToAccount(process.env.PRIVATE_KEY);
29
+
30
+ // 2. Create smart account owned by EOA
31
+ const smartAccount = await createSmartAccount({
32
+ owner: eoaAccount.address,
33
+ salt: 0n,
34
+ factoryAddress: CONTRACTS.sepolia.simpleAccountFactory,
35
+ });
36
+
37
+ // 3. Use smart account for advanced features
38
+ const user = createEndUserClient({
39
+ chain: sepolia,
40
+ transport: http(),
41
+ account: smartAccount,
42
+ });
43
+
44
+ // Now user has:
45
+ // - Gasless transactions
46
+ // - Social recovery
47
+ // - Session keys
48
+ // - Batch operations
49
+ ```
50
+
51
+ ## Benefits
52
+
53
+ 1. **No Learning Curve**: Users keep their familiar wallets
54
+ 2. **Gradual Adoption**: Upgrade when needed
55
+ 3. **Best of Both Worlds**: EOA simplicity + smart account features
56
+ 4. **Backward Compatible**: Works with existing DApps
57
+
58
+ ## Use Cases
59
+
60
+ - Onboarding new users
61
+ - Migrating existing users
62
+ - Multi-wallet support
63
+ - Progressive enhancement
64
+
65
+ ## Related
66
+
67
+ - [Account Module](/api/modules/account)
68
+ - [Account Abstraction](/guide/concepts/account-abstraction)
@@ -0,0 +1,95 @@
1
+ # Reputation System
2
+
3
+ On-chain reputation tracking with customizable rules and scoring.
4
+
5
+ ## Overview
6
+
7
+ The Reputation System enables:
8
+ - On-chain reputation tracking
9
+ - Customizable scoring rules
10
+ - Community-specific metrics
11
+ - Credit limit calculation
12
+
13
+ ## Architecture
14
+
15
+ ```
16
+ User Actions → Metrics → Reputation Score → Credit Limit
17
+ ```
18
+
19
+ ## Components
20
+
21
+ ### 1. Metrics
22
+
23
+ Measurable user activities:
24
+ - Code contributions
25
+ - Community engagement
26
+ - Governance participation
27
+ - Transaction history
28
+
29
+ ### 2. Scoring Rules
30
+
31
+ Community-defined weights:
32
+
33
+ ```typescript
34
+ await community.setReputationRules({
35
+ rules: [
36
+ { metric: 'contributions', weight: 40 },
37
+ { metric: 'engagement', weight: 30 },
38
+ { metric: 'governance', weight: 30 },
39
+ ],
40
+ });
41
+ ```
42
+
43
+ ### 3. Reputation Score
44
+
45
+ Calculated from metrics and weights:
46
+
47
+ ```
48
+ score = (metric1 * weight1) + (metric2 * weight2) + ...
49
+ ```
50
+
51
+ ### 4. Credit Limit
52
+
53
+ Based on reputation:
54
+
55
+ ```
56
+ creditLimit = baseLimit * (reputationScore / 1000)
57
+ ```
58
+
59
+ ## Usage
60
+
61
+ ```typescript
62
+ import { getReputationScore } from '@aastar/identity';
63
+
64
+ // Get user's reputation
65
+ const score = await getReputationScore(
66
+ client,
67
+ userAddress,
68
+ communityAddress
69
+ );
70
+
71
+ console.log('Reputation:', score.toString());
72
+
73
+ // Higher reputation = higher credit limit
74
+ const credit = await user.getCreditLimit();
75
+ ```
76
+
77
+ ## Benefits
78
+
79
+ 1. **Trustless**: On-chain, verifiable
80
+ 2. **Customizable**: Each community sets rules
81
+ 3. **Fair**: Transparent scoring
82
+ 4. **Dynamic**: Updates with user activity
83
+
84
+ ## Use Cases
85
+
86
+ - Gas credit limits
87
+ - Governance voting power
88
+ - Access control
89
+ - Reward distribution
90
+
91
+ ## Related
92
+
93
+ - [Identity Module](/api/modules/identity)
94
+ - [Community API](/api/roles/community)
95
+ - [End User API](/api/roles/enduser)
@@ -0,0 +1,141 @@
1
+ # SuperPaymaster (AOA+)
2
+
3
+ Advanced On-chain Accounting Paymaster with credit system.
4
+
5
+ ## Overview
6
+
7
+ SuperPaymaster is AAStar's innovative gas sponsorship solution that enables truly gasless transactions through an on-chain credit system.
8
+
9
+ ## Key Features
10
+
11
+ ### 1. Credit-Based System
12
+
13
+ Users get gas credit based on:
14
+ - **SBT Ownership**: Community membership tokens
15
+ - **Reputation Score**: On-chain reputation
16
+ - **Historical Behavior**: Past transaction patterns
17
+ - **Community Rules**: Custom eligibility criteria
18
+
19
+ ### 2. Operator Network
20
+
21
+ Decentralized network of Paymaster operators who:
22
+ - Stake GTokens to participate
23
+ - Deposit funds for gas sponsorship
24
+ - Earn fees from communities
25
+ - Get slashed for misbehavior
26
+
27
+ ### 3. Community Governance
28
+
29
+ Communities can:
30
+ - Set their own eligibility rules
31
+ - Configure credit limits
32
+ - Manage operator selection
33
+ - Customize fee structures
34
+
35
+ ## How It Works
36
+
37
+ ```mermaid
38
+ sequenceDiagram
39
+ User->>SuperPaymaster: Request gasless tx
40
+ SuperPaymaster->>Registry: Check eligibility
41
+ Registry->>SuperPaymaster: Return credit limit
42
+ SuperPaymaster->>Operator: Sponsor gas
43
+ Operator->>EntryPoint: Pay gas
44
+ EntryPoint->>User: Execute transaction
45
+ User->>SuperPaymaster: Repay debt (later)
46
+ ```
47
+
48
+ ## Architecture
49
+
50
+ ### Components
51
+
52
+ 1. **SuperPaymaster Contract**: Core logic for gas sponsorship
53
+ 2. **Registry**: Manages communities, operators, and users
54
+ 3. **GTokenStaking**: Operator stake management
55
+ 4. **ReputationSystem**: On-chain reputation tracking
56
+
57
+ ### Credit Calculation
58
+
59
+ ```typescript
60
+ credit = baseCreditLimit
61
+ * reputationMultiplier
62
+ * communityBonus
63
+ - outstandingDebt
64
+ ```
65
+
66
+ ## Usage Example
67
+
68
+ ```typescript
69
+ import { createEndUserClient } from '@aastar/core';
70
+ import { getPaymasterAndData } from '@aastar/paymaster';
71
+
72
+ // 1. Check eligibility
73
+ const user = createEndUserClient({...});
74
+ const eligible = await user.checkEligibility(communityAddress);
75
+
76
+ if (!eligible) {
77
+ throw new Error('Not eligible for gasless transactions');
78
+ }
79
+
80
+ // 2. Get credit limit
81
+ const creditLimit = await user.getCreditLimit();
82
+ console.log('Available credit:', formatEther(creditLimit));
83
+
84
+ // 3. Create UserOperation with paymaster data
85
+ const paymasterAndData = getPaymasterAndData(userOp, {
86
+ paymasterAddress: CONTRACTS.sepolia.superPaymaster,
87
+ communityAddress,
88
+ xPNTsAddress: CONTRACTS.sepolia.xPNTsToken,
89
+ verificationGasLimit: 100000n,
90
+ postOpGasLimit: 50000n,
91
+ });
92
+
93
+ // 4. Submit gasless transaction
94
+ const txHash = await submitUserOperation({
95
+ ...userOp,
96
+ paymasterAndData,
97
+ });
98
+ ```
99
+
100
+ ## Benefits
101
+
102
+ ### For Users
103
+ - ✅ No need to hold ETH for gas
104
+ - ✅ Seamless transaction experience
105
+ - ✅ Credit-based system (pay later)
106
+ - ✅ Community-specific benefits
107
+
108
+ ### For Communities
109
+ - ✅ Attract more users
110
+ - ✅ Customizable rules
111
+ - ✅ Better user retention
112
+ - ✅ Governance control
113
+
114
+ ### For Operators
115
+ - ✅ Earn fees from gas sponsorship
116
+ - ✅ Decentralized network
117
+ - ✅ Stake-based participation
118
+ - ✅ Performance incentives
119
+
120
+ ## Comparison with Traditional Paymasters
121
+
122
+ | Feature | Traditional Paymaster | SuperPaymaster (AOA+) |
123
+ |---------|----------------------|----------------------|
124
+ | Gas Sponsorship | ✅ | ✅ |
125
+ | Credit System | ❌ | ✅ |
126
+ | Decentralized | ❌ | ✅ |
127
+ | Community Governance | ❌ | ✅ |
128
+ | Reputation-Based | ❌ | ✅ |
129
+ | Operator Network | ❌ | ✅ |
130
+
131
+ ## Learn More
132
+
133
+ - [Operator API](/api/roles/operator) - Become an operator
134
+ - [Community API](/api/roles/community) - Set up gas sponsorship
135
+ - [End User API](/api/roles/enduser) - Use gasless transactions
136
+
137
+ ## Next Steps
138
+
139
+ - [EOA Rainbow Bridge](/guide/concepts/rainbow-bridge)
140
+ - [Reputation System](/guide/concepts/reputation)
141
+ - [Quick Start](/guide/quick-start)