@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.
- package/.eslintrc.cjs +30 -0
- package/.gitmodules +9 -0
- package/README.md +299 -0
- package/aastar-sdk.code-workspace +14 -0
- package/abis/BLSAggregator.json +572 -0
- package/abis/BLSValidator.json +39 -0
- package/abis/DVTValidator.json +383 -0
- package/abis/Eip7702Support.json +24 -0
- package/abis/EntryPoint.json +1379 -0
- package/abis/GToken.json +510 -0
- package/abis/GTokenStaking.json +918 -0
- package/abis/LegacyAccount.json +625 -0
- package/abis/MySBT.json +1547 -0
- package/abis/Paymaster.json +1192 -0
- package/abis/PaymasterFactory.json +637 -0
- package/abis/PaymasterV4_2.json +1193 -0
- package/abis/Registry.json +1677 -0
- package/abis/ReputationSystem.json +659 -0
- package/abis/SenderCreator.json +99 -0
- package/abis/Simple7702Account.json +395 -0
- package/abis/SimpleAccount.json +625 -0
- package/abis/SimpleAccountFactory.json +108 -0
- package/abis/SimpleAccountFactoryV08.json +87 -0
- package/abis/SimpleAccountV08.json +557 -0
- package/abis/SuperPaymaster.json +1568 -0
- package/abis/UserOperationLib.json +57 -0
- package/abis/aPNTs.json +1160 -0
- package/abis/xPNTsFactory.json +715 -0
- package/abis/xPNTsToken.json +1160 -0
- package/config/networks/README.md +54 -0
- package/config/networks/mainnet.env.example +39 -0
- package/config/networks/optimism-sepolia.env.example +35 -0
- package/config/networks/optimism.env.example +36 -0
- package/config/networks/sepolia.env.example +36 -0
- package/config.anvil.json +1 -0
- package/config.sepolia.json +1 -0
- package/config.test.json +27 -0
- package/data/experiment_data.csv +36 -0
- package/data/industry_baseline_2025-12-23.json +154 -0
- package/data/industry_baseline_latest.json +154 -0
- package/docs/ABI_Change_Tracking_Workflow.md +41 -0
- package/docs/ABI_MAINTENANCE_PLAN.md +132 -0
- package/docs/API_REFERENCE.md +956 -0
- package/docs/Configuration_Sync.md +47 -0
- package/docs/DAO_Mining_Distribution_Plan.md +522 -0
- package/docs/DEMO_REFACTOR_PLAN.md +289 -0
- package/docs/DOCUMENTATION_PLAN.md +455 -0
- package/docs/ENV_SEPOLIA_UPDATE.md +68 -0
- package/docs/Faucet_Gasless_Plan.md +56 -0
- package/docs/L2_BUSINESS_CLIENTS_PLAN.md +394 -0
- package/docs/L4_Manual_Test_CheatSheet.md +215 -0
- package/docs/Plan.md +266 -0
- package/docs/Regression_Testing_Guide.md +70 -0
- package/docs/SDK_ABI_COVERAGE.md +839 -0
- package/docs/SDK_COVERAGE_STRATEGY.md +397 -0
- package/docs/SDK_Optimization_Evaluation_Plan.md +51 -0
- package/docs/SDK_REGRESSION_AND_API_PLAN.md +98 -0
- package/docs/SDK_STAGE3_PLAN.md +151 -0
- package/docs/SEPOLIA_ENV_REFERENCE.md +51 -0
- package/docs/STAGE3.md +191 -0
- package/docs/Script_Comparison_Report.md +91 -0
- package/docs/Sepolia_Latest_Deployment.md +117 -0
- package/docs/TESTER_GUIDE_GASLESS.md +663 -0
- package/docs/TEST_COVERAGE_MATRIX.md +72 -0
- package/docs/TODO_SDK_COVERAGE.md +55 -0
- package/docs/USER_CASE_DESIGN.md +110 -0
- package/docs/Verifier_L4_Gasless_Plan.md +454 -0
- package/docs/api/@aastar/account.md +235 -0
- package/docs/api/@aastar/analytics.md +219 -0
- package/docs/api/@aastar/core.md +26830 -0
- package/docs/api/@aastar/dapp.md +130 -0
- package/docs/api/@aastar/identity.md +482 -0
- package/docs/api/@aastar/paymaster.md +1387 -0
- package/docs/api/@aastar/sdk/README.md +155 -0
- package/docs/api/@aastar/sdk/node.md +4044 -0
- package/docs/api/@aastar/tokens.md +1971 -0
- package/docs/api/README.md +10 -0
- package/docs/changelog.md +99 -0
- package/docs/examples/README.md +18 -0
- package/docs/examples/community-flow.md +28 -0
- package/docs/examples/enduser-flow.md +24 -0
- package/docs/examples/index.md +18 -0
- package/docs/examples/multi-chain.md +31 -0
- package/docs/examples/operator-flow.md +28 -0
- package/docs/guide/CLI_GUIDE.md +65 -0
- package/docs/guide/DOCUMENTATION_PLAN.md +455 -0
- package/docs/guide/Security-solution.md +106 -0
- package/docs/guide/TEST_COMMANDS.md +320 -0
- package/docs/guide/concepts/account-abstraction.md +95 -0
- package/docs/guide/concepts/rainbow-bridge.md +68 -0
- package/docs/guide/concepts/reputation.md +95 -0
- package/docs/guide/concepts/superpaymaster.md +141 -0
- package/docs/guide/getting-started.md +133 -0
- package/docs/guide/installation.md +40 -0
- package/docs/guide/paper-data-collection.md +69 -0
- package/docs/guide/quick-start.md +52 -0
- package/docs/guide/task_breakdown.md +121 -0
- package/docs/guide/use-cases/community-management.md +141 -0
- package/docs/guide/use-cases/gasless-transactions.md +71 -0
- package/docs/guide/use-cases/operator-staking.md +84 -0
- package/docs/guide/use-cases/yop.md +72 -0
- package/docs/old-solution.md +1078 -0
- package/docs/paper-data-collection.md +69 -0
- package/docs/refactor/2026-01-13-221242-trae-refactor.md +224 -0
- package/docs/refactor/2026-01-13-audit-analysis.md +96 -0
- package/docs/refactor/2026-01-13-audit-report-v0.16.2.md +76 -0
- package/docs/refactor/2026-01-13-audit-report-v0.17.0.md +74 -0
- package/docs/refactor/2026-01-13-cursor-refactor.md +511 -0
- package/docs/refactor/2026-01-13-refactor-plan.md +88 -0
- package/docs/refactor/2026-01-13-refactor-response-plan.md +77 -0
- package/docs/refactor/2026-01-13-refactor-review.md +39 -0
- package/docs/refactor/2026-01-13-sdk-enhancement-plan.md +120 -0
- package/docs/refactor/2026-01-14-audit-response.md +242 -0
- package/docs/refactor/2026-01-14-audit-summary.md +133 -0
- package/docs/refactor/cursor-2026-01-13-14-00-audit-report.md +267 -0
- package/docs/technical_plan.md +510 -0
- package/docs/zh/examples/community-flow.md +38 -0
- package/docs/zh/examples/complete-workflow.md +10 -0
- package/docs/zh/examples/enduser-flow.md +33 -0
- package/docs/zh/examples/index.md +18 -0
- package/docs/zh/examples/multi-chain.md +46 -0
- package/docs/zh/examples/operator-flow.md +37 -0
- package/docs/zh/guide/CLI_GUIDE.md +48 -0
- package/docs/zh/guide/DOCUMENTATION_PLAN.md +455 -0
- package/docs/zh/guide/Plan.md +266 -0
- package/docs/zh/guide/SDK_Optimization_Evaluation_Plan.md +51 -0
- package/docs/zh/guide/Security-solution.md +106 -0
- package/docs/zh/guide/TEST_COMMANDS.md +125 -0
- package/docs/zh/guide/TEST_COVERAGE_MATRIX.md +72 -0
- package/docs/zh/guide/concepts/account-abstraction.md +95 -0
- package/docs/zh/guide/concepts/rainbow-bridge.md +68 -0
- package/docs/zh/guide/concepts/reputation.md +95 -0
- package/docs/zh/guide/concepts/superpaymaster.md +141 -0
- package/docs/zh/guide/getting-started.md +133 -0
- package/docs/zh/guide/installation.md +107 -0
- package/docs/zh/guide/old-solution.md +1078 -0
- package/docs/zh/guide/paper-data-collection.md +69 -0
- package/docs/zh/guide/quick-start.md +134 -0
- package/docs/zh/guide/sdk-readme.md +253 -0
- package/docs/zh/guide/task_breakdown.md +76 -0
- package/docs/zh/guide/technical_plan.md +510 -0
- package/docs/zh/guide/use-cases/community-management.md +141 -0
- package/docs/zh/guide/use-cases/gasless-transactions.md +71 -0
- package/docs/zh/guide/use-cases/operator-staking.md +84 -0
- package/docs/zh/guide/use-cases/yop.md +72 -0
- package/env.template +32 -0
- package/examples/l1-api-demo.ts +184 -0
- package/examples/l2-clients-demo.ts +138 -0
- package/examples/l3-user-onboarding.ts +74 -0
- package/examples/prepare-gasless.ts +89 -0
- package/examples/sdk-demo/DEVELOPER_GUIDE.md +159 -0
- package/examples/sdk-demo/README.md +30 -0
- package/examples/sdk-demo/usage.ts +137 -0
- package/examples/simple-gasless-demo.ts +80 -0
- package/examples/simple-superpaymaster-demo.ts +96 -0
- package/ext/aastar-shared-config/.env.example +6 -0
- package/ext/aastar-shared-config/.github/workflows/check-secrets.yml +257 -0
- package/ext/aastar-shared-config/AGENTS.md +21 -0
- package/ext/aastar-shared-config/CHANGELOG.md +99 -0
- package/ext/aastar-shared-config/LICENSE +21 -0
- package/ext/aastar-shared-config/QUICK_START.md +215 -0
- package/ext/aastar-shared-config/README.md +412 -0
- package/ext/aastar-shared-config/SHARED_CONFIG_SUMMARY.md +273 -0
- package/ext/aastar-shared-config/check-locker-status.mjs +7 -0
- package/ext/aastar-shared-config/favicon.ico +0 -0
- package/ext/aastar-shared-config/generate-comparison-table.sh +67 -0
- package/ext/aastar-shared-config/package.json +46 -0
- package/ext/aastar-shared-config/pnpm-lock.yaml +1182 -0
- package/ext/aastar-shared-config/src/abis/BLSAggregator.json +1 -0
- package/ext/aastar-shared-config/src/abis/DVTValidator.json +1 -0
- package/ext/aastar-shared-config/src/abis/GToken.json +1 -0
- package/ext/aastar-shared-config/src/abis/GTokenStaking.json +1 -0
- package/ext/aastar-shared-config/src/abis/MySBT.json +1 -0
- package/ext/aastar-shared-config/src/abis/PaymasterFactory.json +1 -0
- package/ext/aastar-shared-config/src/abis/PaymasterV4.json +1098 -0
- package/ext/aastar-shared-config/src/abis/Registry.json +1 -0
- package/ext/aastar-shared-config/src/abis/SimpleAccount.json +557 -0
- package/ext/aastar-shared-config/src/abis/SimpleAccountFactory.json +87 -0
- package/ext/aastar-shared-config/src/abis/SuperPaymasterV2.json +1 -0
- package/ext/aastar-shared-config/src/abis/index.ts +45 -0
- package/ext/aastar-shared-config/src/abis/xPNTsFactory.json +1 -0
- package/ext/aastar-shared-config/src/abis/xPNTsToken.json +1 -0
- package/ext/aastar-shared-config/src/branding.ts +32 -0
- package/ext/aastar-shared-config/src/communities.ts +93 -0
- package/ext/aastar-shared-config/src/constants.ts +67 -0
- package/ext/aastar-shared-config/src/contract-addresses.ts +95 -0
- package/ext/aastar-shared-config/src/contract-versions.ts +374 -0
- package/ext/aastar-shared-config/src/contracts.ts +414 -0
- package/ext/aastar-shared-config/src/index.ts +14 -0
- package/ext/aastar-shared-config/src/networks.ts +117 -0
- package/ext/aastar-shared-config/sync-abis.sh +92 -0
- package/ext/aastar-shared-config/sync-versions.mjs +150 -0
- package/ext/aastar-shared-config/tsconfig.json +18 -0
- package/ext/aastar-shared-config/tsup.config.ts +10 -0
- package/ext/aastar-shared-config/verify-all.sh +207 -0
- package/ext/aastar-shared-config/verify-contracts.sh +85 -0
- package/ext/aastar-shared-config/verify-mysbt-v243.mjs +27 -0
- package/ext/aastar-shared-config/verify-onchain-versions.mjs +93 -0
- package/l4-setup.sh +11 -0
- package/lib/SHARED_CONFIG_REFERENCE.md +133 -0
- package/lib/shared-config/.env.example +6 -0
- package/lib/shared-config/.github/workflows/check-secrets.yml +257 -0
- package/lib/shared-config/AGENTS.md +21 -0
- package/lib/shared-config/CHANGELOG.md +99 -0
- package/lib/shared-config/LICENSE +21 -0
- package/lib/shared-config/QUICK_START.md +215 -0
- package/lib/shared-config/README.md +412 -0
- package/lib/shared-config/SHARED_CONFIG_SUMMARY.md +273 -0
- package/lib/shared-config/check-locker-status.mjs +7 -0
- package/lib/shared-config/favicon.ico +0 -0
- package/lib/shared-config/generate-comparison-table.sh +67 -0
- package/lib/shared-config/package.json +46 -0
- package/lib/shared-config/pnpm-lock.yaml +1182 -0
- package/lib/shared-config/src/abis/BLSAggregator.json +1 -0
- package/lib/shared-config/src/abis/DVTValidator.json +1 -0
- package/lib/shared-config/src/abis/GToken.json +1 -0
- package/lib/shared-config/src/abis/GTokenStaking.json +1 -0
- package/lib/shared-config/src/abis/MySBT.json +1 -0
- package/lib/shared-config/src/abis/PaymasterFactory.json +1 -0
- package/lib/shared-config/src/abis/PaymasterV4.json +1098 -0
- package/lib/shared-config/src/abis/Registry.json +1 -0
- package/lib/shared-config/src/abis/SimpleAccount.json +557 -0
- package/lib/shared-config/src/abis/SimpleAccountFactory.json +87 -0
- package/lib/shared-config/src/abis/SuperPaymasterV2.json +1 -0
- package/lib/shared-config/src/abis/index.ts +45 -0
- package/lib/shared-config/src/abis/xPNTsFactory.json +1 -0
- package/lib/shared-config/src/abis/xPNTsToken.json +1 -0
- package/lib/shared-config/src/branding.ts +32 -0
- package/lib/shared-config/src/communities.ts +93 -0
- package/lib/shared-config/src/constants.ts +67 -0
- package/lib/shared-config/src/contract-addresses.ts +95 -0
- package/lib/shared-config/src/contract-versions.ts +374 -0
- package/lib/shared-config/src/contracts.ts +414 -0
- package/lib/shared-config/src/index.ts +14 -0
- package/lib/shared-config/src/networks.ts +117 -0
- package/lib/shared-config/sync-abis.sh +92 -0
- package/lib/shared-config/sync-versions.mjs +150 -0
- package/lib/shared-config/tsconfig.json +18 -0
- package/lib/shared-config/tsup.config.ts +10 -0
- package/lib/shared-config/verify-all.sh +207 -0
- package/lib/shared-config/verify-contracts.sh +85 -0
- package/lib/shared-config/verify-mysbt-v243.mjs +27 -0
- package/lib/shared-config/verify-onchain-versions.mjs +93 -0
- package/package.json +58 -22
- package/packages/account/package.json +23 -0
- package/packages/account/src/accounts/simple.test.ts +93 -0
- package/packages/account/src/accounts/simple.ts +84 -0
- package/packages/account/src/eoa.test.ts +37 -0
- package/packages/account/src/eoa.ts +33 -0
- package/packages/account/src/index.test.ts +34 -0
- package/packages/account/src/index.ts +61 -0
- package/packages/account/tsconfig.json +11 -0
- package/packages/analytics/package.json +28 -0
- package/packages/analytics/src/index.ts +145 -0
- package/packages/analytics/tsconfig.json +11 -0
- package/packages/core/package.json +32 -0
- package/packages/core/scripts/audit-abi-coverage.ts +165 -0
- package/packages/core/scripts/debug-regex.ts +36 -0
- package/packages/core/src/abis/.abi-hashes.json +26 -0
- package/packages/core/src/abis/BLSAggregator.json +686 -0
- package/packages/core/src/abis/BLSValidator.json +42 -0
- package/packages/core/src/abis/DVTValidator.json +368 -0
- package/packages/core/src/abis/Eip7702Support.json +24 -0
- package/packages/core/src/abis/EntryPoint.json +1382 -0
- package/packages/core/src/abis/GToken.json +513 -0
- package/packages/core/src/abis/GTokenStaking.json +949 -0
- package/packages/core/src/abis/LegacyAccount.json +625 -0
- package/packages/core/src/abis/MySBT.json +1518 -0
- package/packages/core/src/abis/Paymaster.json +1143 -0
- package/packages/core/src/abis/PaymasterFactory.json +640 -0
- package/packages/core/src/abis/Registry.json +1942 -0
- package/packages/core/src/abis/ReputationSystem.json +699 -0
- package/packages/core/src/abis/SenderCreator.json +99 -0
- package/packages/core/src/abis/Simple7702Account.json +395 -0
- package/packages/core/src/abis/SimpleAccount.json +560 -0
- package/packages/core/src/abis/SimpleAccountFactory.json +111 -0
- package/packages/core/src/abis/SimpleAccountFactoryV08.json +87 -0
- package/packages/core/src/abis/SimpleAccountV08.json +557 -0
- package/packages/core/src/abis/SuperPaymaster.json +1781 -0
- package/packages/core/src/abis/UserOperationLib.json +57 -0
- package/packages/core/src/abis/abi.config.json +24 -0
- package/packages/core/src/abis/index.ts +104 -0
- package/packages/core/src/abis/xPNTsFactory.json +718 -0
- package/packages/core/src/abis/xPNTsToken.json +1280 -0
- package/packages/core/src/actions/StateValidator.test.ts +175 -0
- package/packages/core/src/actions/StateValidator.ts +253 -0
- package/packages/core/src/actions/account.test.ts +155 -0
- package/packages/core/src/actions/account.ts +179 -0
- package/packages/core/src/actions/aggregator.test.ts +88 -0
- package/packages/core/src/actions/aggregator.ts +41 -0
- package/packages/core/src/actions/dvt.test.ts +124 -0
- package/packages/core/src/actions/dvt.ts +53 -0
- package/packages/core/src/actions/entryPoint.test.ts +176 -0
- package/packages/core/src/actions/entryPoint.ts +266 -0
- package/packages/core/src/actions/factory.test.ts +250 -0
- package/packages/core/src/actions/factory.ts +613 -0
- package/packages/core/src/actions/faucet.test.ts +202 -0
- package/packages/core/src/actions/faucet.ts +421 -0
- package/packages/core/src/actions/gtokenExtended.test.ts +162 -0
- package/packages/core/src/actions/gtokenExtended.ts +153 -0
- package/packages/core/src/actions/index.ts +18 -0
- package/packages/core/src/actions/paymasterV4.test.ts +209 -0
- package/packages/core/src/actions/paymasterV4.ts +455 -0
- package/packages/core/src/actions/registry.test.ts +443 -0
- package/packages/core/src/actions/registry.ts +860 -0
- package/packages/core/src/actions/reputation.test.ts +225 -0
- package/packages/core/src/actions/reputation.ts +378 -0
- package/packages/core/src/actions/sbt.test.ts +322 -0
- package/packages/core/src/actions/sbt.ts +681 -0
- package/packages/core/src/actions/staking.test.ts +273 -0
- package/packages/core/src/actions/staking.ts +421 -0
- package/packages/core/src/actions/superPaymaster.test.ts +356 -0
- package/packages/core/src/actions/superPaymaster.ts +828 -0
- package/packages/core/src/actions/tokens.test.ts +60 -0
- package/packages/core/src/actions/tokens.ts +527 -0
- package/packages/core/src/actions/validators.test.ts +239 -0
- package/packages/core/src/actions/validators.ts +590 -0
- package/packages/core/src/branding.ts +32 -0
- package/packages/core/src/clients/BaseClient.ts +78 -0
- package/packages/core/src/clients/types.ts +69 -0
- package/packages/core/src/clients.ts +13 -0
- package/packages/core/src/communities.ts +93 -0
- package/packages/core/src/config/ContractConfigManager.ts +63 -0
- package/packages/core/src/constants.ts +145 -0
- package/packages/core/src/contract-addresses.ts +125 -0
- package/packages/core/src/contracts.test.ts +58 -0
- package/packages/core/src/contracts.ts +414 -0
- package/packages/core/src/crypto/blsSigner.ts +124 -0
- package/packages/core/src/crypto/index.ts +1 -0
- package/packages/core/src/index.ts +22 -0
- package/packages/core/src/networks.ts +127 -0
- package/packages/core/src/requirementChecker.test.ts +71 -0
- package/packages/core/src/requirementChecker.ts +187 -0
- package/packages/core/src/roles.test.ts +34 -0
- package/packages/core/src/roles.ts +255 -0
- package/packages/core/src/utils/validation.test.ts +50 -0
- package/packages/core/src/utils/validation.ts +66 -0
- package/packages/core/src/utils.ts +23 -0
- package/packages/core/tsconfig.json +12 -0
- package/packages/core/vitest.config.ts +14 -0
- package/packages/dapp/package.json +30 -0
- package/packages/dapp/src/index.ts +4 -0
- package/packages/dapp/src/ui/components/EvaluationPanel.tsx +40 -0
- package/packages/dapp/src/ui/hooks/useCreditScore.ts +44 -0
- package/packages/dapp/src/ui/hooks/useSuperPaymaster.ts +31 -0
- package/packages/dapp/src/ui/index.ts +22 -0
- package/packages/dapp/tsconfig.json +12 -0
- package/packages/identity/package.json +25 -0
- package/packages/identity/src/index.ts +114 -0
- package/packages/identity/src/mysbt.ts +48 -0
- package/packages/identity/tsconfig.json +11 -0
- package/packages/paymaster/package.json +25 -0
- package/packages/paymaster/src/SuperPaymaster/index.ts +168 -0
- package/packages/paymaster/src/V4/PaymasterClient.test.ts +114 -0
- package/packages/paymaster/src/V4/PaymasterClient.ts +385 -0
- package/packages/paymaster/src/V4/PaymasterOperator.test.ts +80 -0
- package/packages/paymaster/src/V4/PaymasterOperator.ts +282 -0
- package/packages/paymaster/src/V4/PaymasterUtils.test.ts +54 -0
- package/packages/paymaster/src/V4/PaymasterUtils.ts +185 -0
- package/packages/paymaster/src/V4/SuperPaymasterClient.test.ts +79 -0
- package/packages/paymaster/src/V4/SuperPaymasterClient.ts +123 -0
- package/packages/paymaster/src/V4/index.ts +4 -0
- package/packages/paymaster/src/index.ts +5 -0
- package/packages/paymaster/tsconfig.json +11 -0
- package/packages/sdk/README.md +150 -0
- package/packages/sdk/aastar/package.json +21 -0
- package/packages/sdk/aastar/src/index.ts +3 -0
- package/packages/sdk/aastar/tsconfig.json +7 -0
- package/packages/sdk/coverage_output.txt +393 -0
- package/packages/sdk/coverage_output_final.txt +739 -0
- package/packages/sdk/coverage_output_final_v2.txt +722 -0
- package/packages/sdk/coverage_output_final_v3.txt +722 -0
- package/packages/sdk/examples/config.json +1 -0
- package/packages/sdk/examples/regression_test.ts +106 -0
- package/packages/sdk/package.json +44 -0
- package/packages/sdk/src/clients/ExperimentClient.test.ts +65 -0
- package/packages/sdk/src/clients/ExperimentClient.ts +80 -0
- package/packages/sdk/src/clients/admin.test.ts +98 -0
- package/packages/sdk/src/clients/admin.ts +154 -0
- package/packages/sdk/src/clients/clients.test.ts +104 -0
- package/packages/sdk/src/clients/community.test.ts +118 -0
- package/packages/sdk/src/clients/community.ts +337 -0
- package/packages/sdk/src/clients/endUser.test.ts +221 -0
- package/packages/sdk/src/clients/endUser.ts +551 -0
- package/packages/sdk/src/clients/operator.test.ts +162 -0
- package/packages/sdk/src/clients/operator.ts +355 -0
- package/packages/sdk/src/errors/AAStarError.test.ts +92 -0
- package/packages/sdk/src/errors/AAStarError.ts +70 -0
- package/packages/sdk/src/errors/decoder.test.ts +107 -0
- package/packages/sdk/src/errors/decoder.ts +91 -0
- package/packages/sdk/src/index.ts +23 -0
- package/packages/sdk/src/node/index.ts +8 -0
- package/packages/sdk/src/types/result.ts +29 -0
- package/packages/sdk/src/utils/errorHandler.test.ts +102 -0
- package/packages/sdk/src/utils/errorHandler.ts +167 -0
- package/packages/sdk/src/utils/eventDecoder.test.ts +56 -0
- package/packages/sdk/src/utils/eventDecoder.ts +66 -0
- package/packages/sdk/src/utils/funding.test.ts +117 -0
- package/packages/sdk/src/utils/funding.ts +280 -0
- package/packages/sdk/src/utils/keys.test.ts +105 -0
- package/packages/sdk/src/utils/keys.ts +174 -0
- package/packages/sdk/src/utils/roleData.test.ts +85 -0
- package/packages/sdk/src/utils/roleData.ts +140 -0
- package/packages/sdk/src/utils/testScenarios.test.ts +79 -0
- package/packages/sdk/src/utils/testScenarios.ts +128 -0
- package/packages/sdk/src/utils/userOp.test.ts +190 -0
- package/packages/sdk/src/utils/userOp.ts +265 -0
- package/packages/sdk/tests/scenarios/01_onboard_community.ts +62 -0
- package/packages/sdk/tests/scenarios/02_onboard_operator.ts +109 -0
- package/packages/sdk/tests/scenarios/03_onboard_user.ts +53 -0
- package/packages/sdk/tests/scenarios/04_gasless_tx_flow.ts +68 -0
- package/packages/sdk/tests/scenarios/check_entrypoint.ts +19 -0
- package/packages/sdk/tests/scenarios/check_initialization.ts +65 -0
- package/packages/sdk/tests/scenarios/debug_addresses.ts +26 -0
- package/packages/sdk/tests/scenarios/diagnose_scenario4.ts +55 -0
- package/packages/sdk/tests/scenarios/setup.ts +33 -0
- package/packages/sdk/tests/scenarios/test_entrypoint_nonce.ts +46 -0
- package/packages/sdk/tsconfig.json +11 -0
- package/packages/tokens/package.json +25 -0
- package/packages/tokens/src/index.ts +273 -0
- package/packages/tokens/tsconfig.json +11 -0
- package/pnpm-workspace.yaml +2 -0
- package/run_l4_gasless_regression.sh +79 -0
- package/run_sdk_regression.sh +238 -0
- package/scripts/00_utils.ts +59 -0
- package/scripts/00_verify_phase1.ts +130 -0
- package/scripts/01_1_prep_gtoken.ts +81 -0
- package/scripts/01_2_register_sbt.ts +88 -0
- package/scripts/01_3_prep_tokens_paymaster.ts +102 -0
- package/scripts/01_prepare_all.ts +222 -0
- package/scripts/02_test_eoa.ts +53 -0
- package/scripts/03_test_standard_aa.ts +68 -0
- package/scripts/04_0_check_deploy.ts +24 -0
- package/scripts/04_1_check_allowance.ts +44 -0
- package/scripts/04_2_construct_verify.ts +96 -0
- package/scripts/04_3_verify_estimate.ts +66 -0
- package/scripts/04_4_verify_pack.ts +74 -0
- package/scripts/04_test_paymaster_v4.ts +60 -0
- package/scripts/05_1_deposit.ts +48 -0
- package/scripts/05_test_superpaymaster.ts +58 -0
- package/scripts/06_local_test_v3_admin.ts +163 -0
- package/scripts/06_local_test_v3_execution.ts +132 -0
- package/scripts/06_local_test_v3_full.ts +490 -0
- package/scripts/06_local_test_v3_funding.ts +124 -0
- package/scripts/06_local_test_v3_reputation.ts +234 -0
- package/scripts/07_local_test_v3_audit.ts +181 -0
- package/scripts/08_local_test_registry_lifecycle.ts +382 -0
- package/scripts/09_local_test_community_lifecycle.ts +385 -0
- package/scripts/09_local_test_community_simple.ts +108 -0
- package/scripts/09_scenario_bread_independent.ts +247 -0
- package/scripts/10_scenario_super_shared.ts +196 -0
- package/scripts/10_test_protocol_admin_full.ts +173 -0
- package/scripts/11_scenario_hacker_defense.ts +104 -0
- package/scripts/11_test_core_flows_full.ts +157 -0
- package/scripts/12_test_slash_mechanism.ts +205 -0
- package/scripts/12_test_slash_queries.ts +83 -0
- package/scripts/12_test_staking_exit.ts +152 -0
- package/scripts/12_test_staking_slash.ts +301 -0
- package/scripts/12_test_tier2_slash.ts +139 -0
- package/scripts/13_test_sbt_burn_linkage.ts +266 -0
- package/scripts/14_test_credit_redesign.ts +266 -0
- package/scripts/15_test_bls_full.ts +148 -0
- package/scripts/15_test_dvt_bls_full.ts +140 -0
- package/scripts/17_test_cross_role_collaboration.ts +95 -0
- package/scripts/18_sdk_e2e_verification.ts +67 -0
- package/scripts/18_test_dvt_sdk_flow.ts +138 -0
- package/scripts/18_test_lifecycle_completion.ts +144 -0
- package/scripts/19_sdk_experiment_runner.ts +114 -0
- package/scripts/19_sdk_experiment_runner.ts.backup +391 -0
- package/scripts/20_sdk_full_capability.ts +93 -0
- package/scripts/20_test_superpaymaster_new_apis.ts +193 -0
- package/scripts/21_test_paymasterv4_complete.ts +341 -0
- package/scripts/22_test_bls_signing.ts +260 -0
- package/scripts/23_test_middleware.ts +197 -0
- package/scripts/98_edge_reentrancy.ts +85 -0
- package/scripts/99_bug_hunting_fast.ts +99 -0
- package/scripts/analyze_abi_coverage.ts +169 -0
- package/scripts/check-admin.ts +95 -0
- package/scripts/check-jason-status.ts +184 -0
- package/scripts/check-roles.ts +36 -0
- package/scripts/clear-nonce.ts +47 -0
- package/scripts/collect_industry_baseline.ts +236 -0
- package/scripts/complete-jack-superpaymaster.ts +171 -0
- package/scripts/complete_env_config.ts +97 -0
- package/scripts/debug-addr.ts +43 -0
- package/scripts/debug-community-registration.ts +92 -0
- package/scripts/debug-deploy-v4.ts +116 -0
- package/scripts/debug-paymaster.ts +127 -0
- package/scripts/debug-register-role.ts +101 -0
- package/scripts/debug-version.ts +71 -0
- package/scripts/debug_account_c.ts +43 -0
- package/scripts/debug_bls.ts +58 -0
- package/scripts/debug_config_v036.ts +13 -0
- package/scripts/debug_contracts.ts +2 -0
- package/scripts/debug_env.ts +69 -0
- package/scripts/debug_find_paymaster.ts +98 -0
- package/scripts/debug_isolated_registration.ts +256 -0
- package/scripts/debug_paymaster_config.ts +19 -0
- package/scripts/debug_pim_addr.ts +23 -0
- package/scripts/debug_pm_status.ts +51 -0
- package/scripts/debug_registry.ts +39 -0
- package/scripts/debug_registry_setup.ts +129 -0
- package/scripts/debug_sanity.ts +32 -0
- package/scripts/debug_shared_config.ts +10 -0
- package/scripts/debug_token_compat.ts +51 -0
- package/scripts/debug_tokens.ts +41 -0
- package/scripts/debug_vcheck.ts +33 -0
- package/scripts/deploy-sync.ts +104 -0
- package/scripts/deploy_and_init_v3.sh +134 -0
- package/scripts/deploy_anvil_accounts.ts +144 -0
- package/scripts/deploy_paymaster_v4.ts +139 -0
- package/scripts/deploy_test_accounts.ts +401 -0
- package/scripts/deprecated/check_aa_entrypoint.ts +29 -0
- package/scripts/deprecated/check_paymaster_deposits.ts +45 -0
- package/scripts/deprecated/debug_aoa_function.ts +28 -0
- package/scripts/deprecated/debug_aoa_issue.ts +16 -0
- package/scripts/deprecated/debug_pimlico_aa23.ts +40 -0
- package/scripts/deprecated/debug_summary.ts +34 -0
- package/scripts/deprecated/deploy_v07_aa.ts +99 -0
- package/scripts/deprecated/fix_all_issues.ts +61 -0
- package/scripts/deprecated/fund_bpnts.ts +52 -0
- package/scripts/deprecated/get_factory_addresses.ts +28 -0
- package/scripts/deprecated/recheck_pim.ts +34 -0
- package/scripts/dev_tools/extract_abis.sh +151 -0
- package/scripts/dev_tools/extract_addresses_to_env.sh +67 -0
- package/scripts/dev_tools/final_safe_harmonize.py +77 -0
- package/scripts/dev_tools/safe_harmonize.py +107 -0
- package/scripts/dev_tools/surgical_harmonize.py +83 -0
- package/scripts/experiment/stage3/SETUP_GUIDE.md +258 -0
- package/scripts/experiment/stage3/archived_scripts/00_token_distribution.ts +78 -0
- package/scripts/experiment/stage3/archived_scripts/01_dao_launch.ts +96 -0
- package/scripts/experiment/stage3/archived_scripts/01b_bread_launch.ts +112 -0
- package/scripts/experiment/stage3/archived_scripts/02_operator_setup.ts +84 -0
- package/scripts/experiment/stage3/archived_scripts/02b_operator_b_setup.ts +104 -0
- package/scripts/experiment/stage3/archived_scripts/02c_finalize_operators.ts +86 -0
- package/scripts/experiment/stage3/archived_scripts/02d_operator_collateral.ts +89 -0
- package/scripts/experiment/stage3/archived_scripts/03_user_onboarding.ts +83 -0
- package/scripts/experiment/stage3/archived_scripts/03b_deploy_aa_account.ts +61 -0
- package/scripts/experiment/stage3/archived_scripts/03c_aa_onboarding.ts +104 -0
- package/scripts/experiment/stage3/archived_scripts/03d_mint_points.ts +60 -0
- package/scripts/experiment/stage3/archived_scripts/04_benchmarking.ts +100 -0
- package/scripts/experiment/stage3/archived_scripts/05_multi_op_setup.ts +149 -0
- package/scripts/experiment/stage3/archived_scripts/README.md +58 -0
- package/scripts/experiment/stage3/archived_scripts/check_roles.ts +29 -0
- package/scripts/experiment/stage3/archived_scripts/decode_error.ts +23 -0
- package/scripts/experiment/stage3/archived_scripts/fund_user.ts +51 -0
- package/scripts/experiment/stage3/archived_scripts/gen_b_key.ts +3 -0
- package/scripts/experiment/stage3/archived_scripts/gen_keys.ts +4 -0
- package/scripts/experiment/stage3/archived_scripts/setup.ts +105 -0
- package/scripts/experiment/stage3/archived_scripts/test_key.ts +4 -0
- package/scripts/experiment/stage3/archived_scripts/verify_state.ts +59 -0
- package/scripts/experiment/stage3/refactored/00_token_distribution.ts +46 -0
- package/scripts/experiment/stage3/refactored/02_operator_setup.ts +65 -0
- package/scripts/experiment/stage3/refactored/03_user_onboarding.ts +68 -0
- package/scripts/experiment/stage3/refactored/05_multi_op_setup.ts +63 -0
- package/scripts/experiment/stage3/refactored/README.md +71 -0
- package/scripts/extract-docs.sh +141 -0
- package/scripts/fund-jack.ts +38 -0
- package/scripts/generate_env_from_deployment.ts +109 -0
- package/scripts/inspect-anni-token.ts +116 -0
- package/scripts/inspect-factory.ts +83 -0
- package/scripts/l4-paymasterv4-transfer-test.ts +228 -0
- package/scripts/l4-setup.ts +453 -0
- package/scripts/l4-state.json +80 -0
- package/scripts/phase1_verify_contracts.ts +207 -0
- package/scripts/pre_test_sync.ts +83 -0
- package/scripts/prepare_sepolia_resources.ts +154 -0
- package/scripts/publish_all.sh +39 -0
- package/scripts/query-jack-token.ts +22 -0
- package/scripts/quick_setup.ts +124 -0
- package/scripts/quick_setup_account.ts +80 -0
- package/scripts/run_automated_experiment.sh +121 -0
- package/scripts/run_daily_experiment.ts +70 -0
- package/scripts/run_l4_gasless_regression.sh +32 -0
- package/scripts/run_sdk_experiment.sh +13 -0
- package/scripts/run_sdk_regression-v2.sh +38 -0
- package/scripts/sdk_regression_v2.ts +162 -0
- package/scripts/security_audit.sh +172 -0
- package/scripts/setup-bbq-community.ts +187 -0
- package/scripts/setup-dancing-community.ts +223 -0
- package/scripts/setup_test_accounts.ts +88 -0
- package/scripts/setup_test_environment.ts +147 -0
- package/scripts/sync_anvil_config.cjs +44 -0
- package/scripts/sync_config_to_env.ts +88 -0
- package/scripts/sync_contract_addresses.ts +186 -0
- package/scripts/sync_sepolia_config.cjs +90 -0
- package/scripts/sync_sepolia_config.mjs +74 -0
- package/scripts/test-brown-v4-deploy.ts +90 -0
- package/scripts/test-faucet-and-gasless.ts +170 -0
- package/scripts/test-jack-gasless.ts +119 -0
- package/scripts/test-jack-registration.ts +133 -0
- package/scripts/test-jack-superpaymaster-api.ts +112 -0
- package/scripts/test-kms-gasless.ts +138 -0
- package/scripts/test_groups.ts +138 -0
- package/scripts/test_multi_community_anvil.ts +276 -0
- package/scripts/test_new_sdk_apis_sepolia.ts +193 -0
- package/scripts/test_sdk_join_idempotent.ts +233 -0
- package/scripts/test_simple_sepolia.ts +44 -0
- package/scripts/update_env_from_config.ts +83 -0
- package/scripts/v2_regression/00_validate_env.ts +101 -0
- package/scripts/v2_regression/01_setup_and_fund.ts +132 -0
- package/scripts/v2_regression/02_operator_onboarding.ts +174 -0
- package/scripts/v2_regression/03_community_registry.ts +139 -0
- package/scripts/v2_regression/04_enduser_flow.ts +141 -0
- package/scripts/v2_regression/05_admin_audit.ts +157 -0
- package/scripts/v2_regression/README.md +161 -0
- package/scripts/validate_env.ts +112 -0
- package/scripts/verify-tx-status.ts +81 -0
- package/scripts/verify_onchain_milestone.ts +114 -0
- package/scripts/verify_phase1.ts +66 -0
- package/scripts/verify_phase2.ts +66 -0
- package/sdk_experiment_data.csv +4 -0
- package/simple-test-paymaster.sh +2 -0
- package/simple-test-superpaymaster.sh +1 -0
- package/tests/l1-regression.test.ts +458 -0
- package/tests/l4-test-anni-gasless.ts +105 -0
- package/tests/l4-test-jason1-gasless.ts +150 -0
- package/tests/l4-test-jason2-gasless.ts +174 -0
- package/tests/l4-test-pmv4-deposit.ts +111 -0
- package/tests/l4-test-pmv4-gasless.ts +166 -0
- package/tests/l4-test-pmv4-submit.ts +223 -0
- package/tests/regression/README.md +168 -0
- package/tests/regression/config.ts +215 -0
- package/tests/regression/display-versions.ts +85 -0
- package/tests/regression/index.ts +67 -0
- package/tests/regression/l1-tests.ts +267 -0
- package/tests/regression/l2-tests.ts +171 -0
- package/tests/regression/l3-tests.ts +125 -0
- package/tests/regression/l4-gasless.ts +897 -0
- package/tests/regression/l4-runner.ts +52 -0
- package/tests/reports/phase1_contract_verification.md +45 -0
- package/tests/utils/contractVerifier.ts +237 -0
- package/tests/utils/userOpHelper.ts +194 -0
- package/tsconfig.json +41 -0
- package/typedoc.json +59 -0
- package/vitest.config.ts +16 -0
- package/dist/clients/admin.d.ts +0 -12
- package/dist/clients/admin.d.ts.map +0 -1
- package/dist/clients/admin.js +0 -20
- package/dist/clients/admin.js.map +0 -1
- package/dist/clients/community.d.ts +0 -12
- package/dist/clients/community.d.ts.map +0 -1
- package/dist/clients/community.js +0 -18
- package/dist/clients/community.js.map +0 -1
- package/dist/clients/endUser.d.ts +0 -12
- package/dist/clients/endUser.d.ts.map +0 -1
- package/dist/clients/endUser.js +0 -20
- package/dist/clients/endUser.js.map +0 -1
- package/dist/clients/operator.d.ts +0 -18
- package/dist/clients/operator.d.ts.map +0 -1
- package/dist/clients/operator.js +0 -65
- package/dist/clients/operator.js.map +0 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -12
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,30 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aastar/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.16.6",
|
|
4
|
+
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
},
|
|
9
|
-
"main": "dist/index.js",
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
11
|
-
"files": [
|
|
12
|
-
"dist"
|
|
6
|
+
"workspaces": [
|
|
7
|
+
"packages/*"
|
|
13
8
|
],
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "pnpm -r build",
|
|
11
|
+
"test": "pnpm -r test",
|
|
12
|
+
"test:coverage": "vitest run packages --coverage",
|
|
13
|
+
"test:fast": "ts-node scripts/99_bug_hunting_fast.ts",
|
|
14
|
+
"test:init": "bash run_full_regression.sh init",
|
|
15
|
+
"test:admin": "ts-node scripts/10_test_protocol_admin_full.ts",
|
|
16
|
+
"test:credit": "ts-node scripts/14_test_credit_redesign.ts",
|
|
17
|
+
"test:reentrancy": "ts-node scripts/98_edge_reentrancy.ts",
|
|
18
|
+
"test:full_anvil": "bash run_full_regression.sh",
|
|
19
|
+
"test:full_sdk": "bash run_full_regression.sh sdk",
|
|
20
|
+
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint packages/*/src --ext .ts",
|
|
21
|
+
"lint:fix": "ESLINT_USE_FLAT_CONFIG=false eslint packages/*/src --ext .ts --fix",
|
|
22
|
+
"audit": "pnpm audit --audit-level=moderate",
|
|
23
|
+
"audit:fix": "pnpm audit --fix",
|
|
24
|
+
"security:check": "bash scripts/security_audit.sh",
|
|
25
|
+
"security:full": "pnpm audit && bash scripts/security_audit.sh",
|
|
26
|
+
"audit:abi": "pnpm --filter @aastar/core run audit:abi",
|
|
27
|
+
"precommit": "pnpm security:check",
|
|
28
|
+
"prepare": "pnpm install --frozen-lockfile",
|
|
29
|
+
"example:local": "pnpm --filter @aastar/sdk run example:local",
|
|
30
|
+
"sync-config": "cp ../SuperPaymaster/script/v3/config.json ./packages/sdk/examples/config.json",
|
|
31
|
+
"test:env": "tsx scripts/validate_env.ts",
|
|
32
|
+
"test:regression": "pnpm run test:regression:00 && pnpm run test:regression:01 && pnpm run test:regression:02 && pnpm run test:regression:03 && pnpm run test:regression:04 && pnpm run test:regression:05 && pnpm run test:regression:bls",
|
|
33
|
+
"test:regression:00": "tsx scripts/v2_regression/00_validate_env.ts",
|
|
34
|
+
"test:regression:01": "tsx scripts/v2_regression/01_setup_and_fund.ts",
|
|
35
|
+
"test:regression:02": "tsx scripts/v2_regression/02_operator_onboarding.ts",
|
|
36
|
+
"test:regression:03": "tsx scripts/v2_regression/03_community_registry.ts",
|
|
37
|
+
"test:regression:04": "tsx scripts/v2_regression/04_enduser_flow.ts",
|
|
38
|
+
"test:regression:05": "tsx scripts/v2_regression/05_admin_audit.ts",
|
|
39
|
+
"test:regression:bls": "ts-node scripts/15_test_bls_full.ts",
|
|
40
|
+
"docs:generate": "typedoc --options typedoc.json",
|
|
41
|
+
"docs:sync": "bash scripts/extract-docs.sh"
|
|
22
42
|
},
|
|
23
43
|
"devDependencies": {
|
|
24
|
-
"
|
|
44
|
+
"@types/node": "20.11.5",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "8.50.1",
|
|
46
|
+
"@typescript-eslint/parser": "8.50.1",
|
|
47
|
+
"@vitest/coverage-v8": "4.0.17",
|
|
48
|
+
"cross-env": "10.1.0",
|
|
49
|
+
"dotenv": "17.2.3",
|
|
50
|
+
"eslint": "9.39.2",
|
|
51
|
+
"ts-node": "10.9.2",
|
|
52
|
+
"tsx": "4.21.0",
|
|
53
|
+
"typedoc": "^0.28.15",
|
|
54
|
+
"typedoc-plugin-markdown": "^4.9.0",
|
|
55
|
+
"typescript": "5.7.2",
|
|
56
|
+
"vitest": "4.0.17",
|
|
57
|
+
"axios": "1.13.2",
|
|
58
|
+
"cheerio": "1.1.2",
|
|
59
|
+
"csv-writer": "1.6.0"
|
|
25
60
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@noble/bls12-381": "1.4.0",
|
|
63
|
+
"@noble/curves": "^1.9.7",
|
|
64
|
+
"viem": "2.43.3"
|
|
29
65
|
}
|
|
30
|
-
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aastar/account",
|
|
3
|
+
"version": "0.16.6",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@aastar/core": "workspace:*",
|
|
12
|
+
"viem": "2.43.3"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"typescript": "5.7.2"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { toSimpleSmartAccount } from './simple.js';
|
|
3
|
+
import { type Address } from 'viem';
|
|
4
|
+
|
|
5
|
+
describe('SimpleSmartAccount', () => {
|
|
6
|
+
const MOCK_OWNER = {
|
|
7
|
+
address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266' as Address,
|
|
8
|
+
signMessage: vi.fn().mockResolvedValue('0xsignature'),
|
|
9
|
+
signTypedData: vi.fn(),
|
|
10
|
+
};
|
|
11
|
+
const MOCK_FACTORY = '0x1111111111111111111111111111111111111111' as Address;
|
|
12
|
+
const MOCK_SMART_ACCOUNT = '0x2222222222222222222222222222222222222222' as Address;
|
|
13
|
+
const MOCK_EP = '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789' as Address;
|
|
14
|
+
|
|
15
|
+
it('should create simple smart account wrapper', async () => {
|
|
16
|
+
const mockClient = {
|
|
17
|
+
readContract: vi.fn().mockResolvedValue(MOCK_SMART_ACCOUNT),
|
|
18
|
+
chain: { id: 31337 }
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const account = await toSimpleSmartAccount({
|
|
22
|
+
client: mockClient,
|
|
23
|
+
owner: MOCK_OWNER as any,
|
|
24
|
+
factoryAddress: MOCK_FACTORY,
|
|
25
|
+
entryPoint: { address: MOCK_EP, version: '0.6' }
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
expect(account.address).toBe(MOCK_SMART_ACCOUNT);
|
|
29
|
+
expect(account.entryPoint).toBe(MOCK_EP);
|
|
30
|
+
|
|
31
|
+
const initCode = await account.getInitCode();
|
|
32
|
+
expect(initCode.startsWith(MOCK_FACTORY)).toBe(true);
|
|
33
|
+
|
|
34
|
+
const dummy = await account.getDummySignature();
|
|
35
|
+
expect(dummy).toBeDefined();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should sign user operation', async () => {
|
|
39
|
+
const mockClient = {
|
|
40
|
+
readContract: vi.fn().mockResolvedValue(MOCK_SMART_ACCOUNT),
|
|
41
|
+
chain: { id: 31337 }
|
|
42
|
+
};
|
|
43
|
+
const account = await toSimpleSmartAccount({
|
|
44
|
+
client: mockClient,
|
|
45
|
+
owner: MOCK_OWNER as any,
|
|
46
|
+
factoryAddress: MOCK_FACTORY,
|
|
47
|
+
entryPoint: { address: MOCK_EP, version: '0.6' }
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const userOp = {
|
|
51
|
+
sender: MOCK_SMART_ACCOUNT,
|
|
52
|
+
nonce: 0n,
|
|
53
|
+
initCode: '0x',
|
|
54
|
+
callData: '0x',
|
|
55
|
+
accountGasLimits: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
56
|
+
preVerificationGas: 0n,
|
|
57
|
+
gasFees: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
58
|
+
paymasterAndData: '0x'
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const sig = await account.signUserOperation(userOp);
|
|
62
|
+
expect(sig).toBe('0xsignature');
|
|
63
|
+
expect(MOCK_OWNER.signMessage).toHaveBeenCalled();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should sign message and typed data', async () => {
|
|
67
|
+
const mockClient = { readContract: vi.fn().mockResolvedValue(MOCK_SMART_ACCOUNT) };
|
|
68
|
+
const account = await toSimpleSmartAccount({
|
|
69
|
+
client: mockClient,
|
|
70
|
+
owner: MOCK_OWNER as any,
|
|
71
|
+
factoryAddress: MOCK_FACTORY,
|
|
72
|
+
entryPoint: { address: MOCK_EP, version: '0.6' }
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await account.signMessage({ message: 'hello' });
|
|
76
|
+
expect(MOCK_OWNER.signMessage).toHaveBeenCalled();
|
|
77
|
+
|
|
78
|
+
await account.signTypedData({} as any);
|
|
79
|
+
expect(MOCK_OWNER.signTypedData).toHaveBeenCalled();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should throw on signTransaction', async () => {
|
|
83
|
+
const mockClient = { readContract: vi.fn().mockResolvedValue(MOCK_SMART_ACCOUNT) };
|
|
84
|
+
const account = await toSimpleSmartAccount({
|
|
85
|
+
client: mockClient,
|
|
86
|
+
owner: MOCK_OWNER as any,
|
|
87
|
+
factoryAddress: MOCK_FACTORY,
|
|
88
|
+
entryPoint: { address: MOCK_EP, version: '0.6' }
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
await expect(account.signTransaction({})).rejects.toThrow('UserOperations');
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Address,
|
|
3
|
+
type Hex,
|
|
4
|
+
type LocalAccount,
|
|
5
|
+
type SignableMessage,
|
|
6
|
+
type TypedDataDefinition,
|
|
7
|
+
type Hash,
|
|
8
|
+
concatHex,
|
|
9
|
+
encodeFunctionData,
|
|
10
|
+
keccak256,
|
|
11
|
+
} from 'viem';
|
|
12
|
+
import { SimpleAccountFactoryABI } from '@aastar/core';
|
|
13
|
+
import { getUserOpHash } from '../index.js';
|
|
14
|
+
|
|
15
|
+
export type SimpleSmartAccount = LocalAccount & {
|
|
16
|
+
signUserOperation: (userOp: any) => Promise<Hex>;
|
|
17
|
+
getInitCode: () => Promise<Hex>;
|
|
18
|
+
getDummySignature: () => Promise<Hex>;
|
|
19
|
+
entryPoint: Address;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export async function toSimpleSmartAccount(parameters: {
|
|
23
|
+
client: any;
|
|
24
|
+
owner: LocalAccount;
|
|
25
|
+
factoryAddress: Address;
|
|
26
|
+
entryPoint: { address: Address; version: '0.6' | '0.7' };
|
|
27
|
+
salt?: bigint;
|
|
28
|
+
index?: bigint;
|
|
29
|
+
}): Promise<SimpleSmartAccount> {
|
|
30
|
+
const { client, owner, factoryAddress, entryPoint, index = 0n, salt = 0n } = parameters;
|
|
31
|
+
|
|
32
|
+
// Calculate initCode
|
|
33
|
+
const factoryData = encodeFunctionData({
|
|
34
|
+
abi: SimpleAccountFactoryABI,
|
|
35
|
+
functionName: 'createAccount',
|
|
36
|
+
args: [owner.address, salt]
|
|
37
|
+
});
|
|
38
|
+
const initCode = concatHex([factoryAddress, factoryData]);
|
|
39
|
+
|
|
40
|
+
// Calculate counterfactual address
|
|
41
|
+
const address = await client.readContract({
|
|
42
|
+
address: factoryAddress,
|
|
43
|
+
abi: SimpleAccountFactoryABI,
|
|
44
|
+
functionName: 'getAddress',
|
|
45
|
+
args: [owner.address, salt]
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
address,
|
|
50
|
+
publicKey: owner.address,
|
|
51
|
+
source: 'custom',
|
|
52
|
+
type: 'local',
|
|
53
|
+
entryPoint: entryPoint.address,
|
|
54
|
+
|
|
55
|
+
async signMessage({ message }: { message: SignableMessage }): Promise<Hex> {
|
|
56
|
+
// validating signature for smart account usually involves EIP-1271,
|
|
57
|
+
// but here we just sign with owner for SimpleAccount which validates owner sig
|
|
58
|
+
return owner.signMessage({ message });
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
async signTypedData(typedData: TypedDataDefinition): Promise<Hex> {
|
|
62
|
+
return owner.signTypedData(typedData);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
async signTransaction(transaction: any): Promise<Hex> {
|
|
66
|
+
throw new Error('Smart Accounts cannot sign transactions directly. Use UserOperations.');
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
async signUserOperation(userOp: any): Promise<Hex> {
|
|
70
|
+
const chainId = client.chain?.id || 31337; // Default to local anvil if not found
|
|
71
|
+
const hash = getUserOpHash(userOp, entryPoint.address, chainId);
|
|
72
|
+
return owner.signMessage({ message: { raw: hash } });
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
async getInitCode() {
|
|
76
|
+
return initCode;
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
async getDummySignature() {
|
|
80
|
+
return '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
} as any as SimpleSmartAccount;
|
|
84
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { createEOAWalletClient } from './eoa.js';
|
|
3
|
+
import * as viem from 'viem';
|
|
4
|
+
import { mainnet } from 'viem/chains';
|
|
5
|
+
|
|
6
|
+
vi.mock('viem', async () => {
|
|
7
|
+
const actual = await vi.importActual('viem');
|
|
8
|
+
return {
|
|
9
|
+
...actual,
|
|
10
|
+
createWalletClient: vi.fn(),
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('EOAWalletClient', () => {
|
|
15
|
+
const MOCK_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';
|
|
16
|
+
const MOCK_ADDR = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266';
|
|
17
|
+
|
|
18
|
+
it('should create and use EOA wallet client', async () => {
|
|
19
|
+
const sendTransactionSpy = vi.fn().mockResolvedValue('0xhash');
|
|
20
|
+
const mockViemClient = {
|
|
21
|
+
sendTransaction: sendTransactionSpy,
|
|
22
|
+
account: { address: MOCK_ADDR }
|
|
23
|
+
};
|
|
24
|
+
(viem.createWalletClient as any).mockReturnValue(mockViemClient);
|
|
25
|
+
|
|
26
|
+
const client = createEOAWalletClient(MOCK_KEY, mainnet);
|
|
27
|
+
|
|
28
|
+
expect(client.getAddress()).toBe(MOCK_ADDR);
|
|
29
|
+
|
|
30
|
+
const hash = await client.sendTransaction({ to: MOCK_ADDR, value: 100n });
|
|
31
|
+
expect(hash).toBe('0xhash');
|
|
32
|
+
expect(sendTransactionSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
33
|
+
to: MOCK_ADDR,
|
|
34
|
+
value: 100n
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type WalletClient, type PublicClient, type Address, type Chain, type Transport, type Hash, type Hex, createWalletClient, http } from 'viem';
|
|
2
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
3
|
+
|
|
4
|
+
export type EOAWalletClient = WalletClient & {
|
|
5
|
+
sendTransaction: (args: { to: Address, value?: bigint, data?: Hex }) => Promise<Hash>;
|
|
6
|
+
getAddress: () => Address;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const createEOAWalletClient = (
|
|
10
|
+
privateKey: Hex,
|
|
11
|
+
chain: Chain,
|
|
12
|
+
transport: Transport = http()
|
|
13
|
+
): EOAWalletClient => {
|
|
14
|
+
const account = privateKeyToAccount(privateKey);
|
|
15
|
+
const client = createWalletClient({
|
|
16
|
+
account,
|
|
17
|
+
chain,
|
|
18
|
+
transport
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const baseSendTransaction = client.sendTransaction.bind(client);
|
|
22
|
+
|
|
23
|
+
return Object.assign(client, {
|
|
24
|
+
async sendTransaction(args: { to: Address, value?: bigint, data?: Hex }) {
|
|
25
|
+
return baseSendTransaction({
|
|
26
|
+
...args,
|
|
27
|
+
account,
|
|
28
|
+
chain
|
|
29
|
+
} as any);
|
|
30
|
+
},
|
|
31
|
+
getAddress: () => account.address
|
|
32
|
+
}) as EOAWalletClient;
|
|
33
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { packUserOpLimits, UserOpClient } from './index.js';
|
|
3
|
+
|
|
4
|
+
describe('Account Utils', () => {
|
|
5
|
+
it('should pack user op limits', () => {
|
|
6
|
+
const packed = packUserOpLimits(100n, 200n);
|
|
7
|
+
expect(packed).toBeDefined();
|
|
8
|
+
expect(packed.length).toBe(66); // 0x + 64 chars
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
describe('UserOpClient', () => {
|
|
12
|
+
const mockBundler = {
|
|
13
|
+
request: vi.fn()
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
it('should estimate gas', async () => {
|
|
17
|
+
mockBundler.request.mockResolvedValue({ preVerificationGas: 1000n });
|
|
18
|
+
const res = await UserOpClient.estimateGas(mockBundler, {}, '0x1' as any);
|
|
19
|
+
expect(res.preVerificationGas).toBe(1000n);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should send user operation', async () => {
|
|
23
|
+
mockBundler.request.mockResolvedValue('0xhash');
|
|
24
|
+
const res = await UserOpClient.sendUserOp(mockBundler, {}, '0x1' as any);
|
|
25
|
+
expect(res).toBe('0xhash');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should get receipt', async () => {
|
|
29
|
+
mockBundler.request.mockResolvedValue({ success: true });
|
|
30
|
+
const res = await UserOpClient.getReceipt(mockBundler, '0xhash');
|
|
31
|
+
expect(res.success).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type Hex, type Address, encodeAbiParameters, keccak256 } from 'viem';
|
|
2
|
+
|
|
3
|
+
export * from './eoa.js';
|
|
4
|
+
export * from './accounts/simple.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Common Pack Logic for v0.7 UserOperations
|
|
8
|
+
*/
|
|
9
|
+
export function packUserOpLimits(high: bigint, low: bigint): Hex {
|
|
10
|
+
return `0x${((high << 128n) | low).toString(16).padStart(64, '0')}` as Hex;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Local implementation of EntryPoint v0.7 getUserOpHash
|
|
15
|
+
*/
|
|
16
|
+
export function getUserOpHash(op: any, ep: Address, chainId: number): Hex {
|
|
17
|
+
const packed = encodeAbiParameters(
|
|
18
|
+
[
|
|
19
|
+
{ type: 'address' }, { type: 'uint256' }, { type: 'bytes32' }, { type: 'bytes32' },
|
|
20
|
+
{ type: 'bytes32' }, { type: 'uint256' }, { type: 'bytes32' }, { type: 'bytes32' }
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
op.sender, BigInt(op.nonce),
|
|
24
|
+
keccak256(op.initCode && op.initCode !== "0x" ? op.initCode : '0x'),
|
|
25
|
+
keccak256(op.callData),
|
|
26
|
+
op.accountGasLimits, BigInt(op.preVerificationGas), op.gasFees,
|
|
27
|
+
keccak256(op.paymasterAndData)
|
|
28
|
+
]
|
|
29
|
+
);
|
|
30
|
+
const enc = encodeAbiParameters(
|
|
31
|
+
[{ type: 'bytes32' }, { type: 'address' }, { type: 'uint256' }],
|
|
32
|
+
[keccak256(packed), ep, BigInt(chainId)]
|
|
33
|
+
);
|
|
34
|
+
return keccak256(enc);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* UserOperation Client for handling high-level flows
|
|
39
|
+
*/
|
|
40
|
+
export class UserOpClient {
|
|
41
|
+
static async estimateGas(bundler: any, op: any, entryPoint: Address) {
|
|
42
|
+
return bundler.request({
|
|
43
|
+
method: 'eth_estimateUserOperationGas',
|
|
44
|
+
params: [op, entryPoint]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static async sendUserOp(bundler: any, op: any, entryPoint: Address) {
|
|
49
|
+
return bundler.request({
|
|
50
|
+
method: 'eth_sendUserOperation',
|
|
51
|
+
params: [op, entryPoint]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static async getReceipt(bundler: any, hash: Hex) {
|
|
56
|
+
return bundler.request({
|
|
57
|
+
method: 'eth_getUserOperationReceipt',
|
|
58
|
+
params: [hash]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aastar/analytics",
|
|
3
|
+
"version": "0.16.6",
|
|
4
|
+
"description": "Analytics client for AAstar SDK",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"test": "jest --passWithNoTests"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"aastar",
|
|
13
|
+
"analytics",
|
|
14
|
+
"web3"
|
|
15
|
+
],
|
|
16
|
+
"author": "AAstar Team",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@aastar/core": "workspace:*",
|
|
20
|
+
"viem": "2.43.3"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "5.7.2"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Address, Hash, PublicClient, zeroAddress, parseAbiItem, Log, parseAbi } from 'viem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Analytics client for monitoring and statistics
|
|
5
|
+
*
|
|
6
|
+
* @roleRequired None (public query APIs)
|
|
7
|
+
* @description Dashboard and monitoring tools
|
|
8
|
+
*
|
|
9
|
+
* ## No Permission Required - All Public Queries
|
|
10
|
+
*
|
|
11
|
+
* ## Typical Users:
|
|
12
|
+
* - Dashboard Developers
|
|
13
|
+
* - Community Analytics
|
|
14
|
+
* - Investors & Researchers
|
|
15
|
+
*/
|
|
16
|
+
export class AnalyticsClient {
|
|
17
|
+
private publicClient: PublicClient;
|
|
18
|
+
private gtokenAddress?: Address;
|
|
19
|
+
private registryAddress?: Address;
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
publicClient: PublicClient,
|
|
23
|
+
addresses?: {
|
|
24
|
+
gtoken?: Address;
|
|
25
|
+
registry?: Address;
|
|
26
|
+
}
|
|
27
|
+
) {
|
|
28
|
+
this.publicClient = publicClient;
|
|
29
|
+
this.gtokenAddress = addresses?.gtoken;
|
|
30
|
+
this.registryAddress = addresses?.registry;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get complete supply metrics
|
|
35
|
+
* @roleRequired None (public view)
|
|
36
|
+
*/
|
|
37
|
+
async getSupplyMetrics(): Promise<{
|
|
38
|
+
cap: bigint;
|
|
39
|
+
totalSupply: bigint;
|
|
40
|
+
totalLifetimeBurned: bigint;
|
|
41
|
+
remainingMintable: bigint;
|
|
42
|
+
deflationRate: number;
|
|
43
|
+
}> {
|
|
44
|
+
const { CORE_ADDRESSES } = await import('@aastar/core');
|
|
45
|
+
const gtokenAddress = this.gtokenAddress || CORE_ADDRESSES.gToken;
|
|
46
|
+
|
|
47
|
+
const [cap, totalSupply, remainingMintable] = await Promise.all([
|
|
48
|
+
this.publicClient.readContract({
|
|
49
|
+
address: gtokenAddress,
|
|
50
|
+
abi: parseAbi(['function cap() view returns (uint256)']),
|
|
51
|
+
functionName: 'cap'
|
|
52
|
+
}) as Promise<bigint>,
|
|
53
|
+
this.publicClient.readContract({
|
|
54
|
+
address: gtokenAddress,
|
|
55
|
+
abi: parseAbi(['function totalSupply() view returns (uint256)']),
|
|
56
|
+
functionName: 'totalSupply'
|
|
57
|
+
}) as Promise<bigint>,
|
|
58
|
+
this.publicClient.readContract({
|
|
59
|
+
address: gtokenAddress,
|
|
60
|
+
abi: parseAbi(['function remainingMintableSupply() view returns (uint256)']),
|
|
61
|
+
functionName: 'remainingMintableSupply'
|
|
62
|
+
}) as Promise<bigint>
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
let totalLifetimeBurned = 0n;
|
|
66
|
+
try {
|
|
67
|
+
totalLifetimeBurned = await this.publicClient.readContract({
|
|
68
|
+
address: gtokenAddress,
|
|
69
|
+
abi: parseAbi(['function totalLifetimeBurned() view returns (uint256)']),
|
|
70
|
+
functionName: 'totalLifetimeBurned'
|
|
71
|
+
}) as bigint;
|
|
72
|
+
} catch {
|
|
73
|
+
totalLifetimeBurned = cap - totalSupply - remainingMintable;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const deflationRate = Number(totalLifetimeBurned * 10000n / cap) / 100;
|
|
77
|
+
|
|
78
|
+
return { cap, totalSupply, totalLifetimeBurned, remainingMintable, deflationRate };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Subscribe to real-time burn events
|
|
83
|
+
* @roleRequired None (public events)
|
|
84
|
+
*/
|
|
85
|
+
subscribeToBurnEvents(callback: (event: {
|
|
86
|
+
from: Address;
|
|
87
|
+
amount: bigint;
|
|
88
|
+
blockNumber: number;
|
|
89
|
+
timestamp: number;
|
|
90
|
+
}) => void): () => void {
|
|
91
|
+
const { CORE_ADDRESSES } = require('@aastar/core');
|
|
92
|
+
const gtokenAddress = this.gtokenAddress || CORE_ADDRESSES.gToken;
|
|
93
|
+
|
|
94
|
+
const unwatch = this.publicClient.watchEvent({
|
|
95
|
+
address: gtokenAddress,
|
|
96
|
+
event: parseAbiItem('event Transfer(address indexed from, address indexed to, uint256 value)'),
|
|
97
|
+
onLogs: async (logs) => {
|
|
98
|
+
for (const log of logs) {
|
|
99
|
+
if (log.args && (log.args as any).to === zeroAddress) {
|
|
100
|
+
const block = await this.publicClient.getBlock({ blockNumber: log.blockNumber! });
|
|
101
|
+
callback({
|
|
102
|
+
from: (log.args as any).from,
|
|
103
|
+
amount: (log.args as any).value,
|
|
104
|
+
blockNumber: Number(log.blockNumber),
|
|
105
|
+
timestamp: Number(block.timestamp)
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
return unwatch;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get role entrance cost breakdown
|
|
117
|
+
* @roleRequired None (public view)
|
|
118
|
+
*/
|
|
119
|
+
async getRoleEntranceCost(roleId: Hash): Promise<{
|
|
120
|
+
minStake: bigint;
|
|
121
|
+
entryBurn: bigint;
|
|
122
|
+
totalRequired: bigint;
|
|
123
|
+
exitFee: { percent: number; minFee: bigint };
|
|
124
|
+
}> {
|
|
125
|
+
const { CORE_ADDRESSES } = await import('@aastar/core');
|
|
126
|
+
const registryAddress = this.registryAddress || CORE_ADDRESSES.registry;
|
|
127
|
+
|
|
128
|
+
const config = await this.publicClient.readContract({
|
|
129
|
+
address: registryAddress,
|
|
130
|
+
abi: parseAbi(['function getRoleConfig(bytes32) view returns ((uint256 minStake, uint256 entryBurn, uint8 slashThreshold, uint8 slashBase, uint8 slashIncrement, uint8 slashMax, uint256 exitFeePercent, uint256 minExitFee, bool isActive, string description))']),
|
|
131
|
+
functionName: 'getRoleConfig',
|
|
132
|
+
args: [roleId]
|
|
133
|
+
}) as any;
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
minStake: config.minStake,
|
|
137
|
+
entryBurn: config.entryBurn,
|
|
138
|
+
totalRequired: config.minStake + config.entryBurn,
|
|
139
|
+
exitFee: {
|
|
140
|
+
percent: Number(config.exitFeePercent) / 100,
|
|
141
|
+
minFee: config.minExitFee
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|