@aastar/sdk 0.14.0 → 0.14.3
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.js +28 -0
- package/.gitmodules +9 -0
- package/README.md +170 -0
- package/aastar-sdk.code-workspace +14 -0
- package/abis/BLSAggregator.json +572 -0
- package/abis/BLSValidator.json +26 -0
- package/abis/DVTValidator.json +370 -0
- package/abis/Eip7702Support.json +24 -0
- package/abis/EntryPoint.json +1379 -0
- package/abis/GToken.json +479 -0
- package/abis/GTokenStaking.json +944 -0
- package/abis/LegacyAccount.json +625 -0
- package/abis/MySBT.json +1586 -0
- package/abis/Paymaster.json +1205 -0
- package/abis/PaymasterFactory.json +650 -0
- package/abis/PaymasterV4_2.json +1183 -0
- package/abis/Registry.json +1636 -0
- package/abis/ReputationSystem.json +477 -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 +1399 -0
- package/abis/UserOperationLib.json +57 -0
- package/abis/aPNTs.json +1173 -0
- package/abis/xPNTsFactory.json +728 -0
- package/abis/xPNTsToken.json +1173 -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/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/API_REFERENCE.md +796 -0
- package/docs/DAO_Mining_Distribution_Plan.md +522 -0
- package/docs/DOCUMENTATION_PLAN.md +455 -0
- package/docs/Plan.md +266 -0
- package/docs/Regression_Testing_Guide.md +70 -0
- package/docs/SDK_Optimization_Evaluation_Plan.md +51 -0
- package/docs/SEPOLIA_ENV_REFERENCE.md +51 -0
- package/docs/STAGE_3_SCENARIO_EXP_PLAN.md +77 -0
- package/docs/Script_Comparison_Report.md +91 -0
- package/docs/Sepolia_Latest_Deployment.md +117 -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/api/@aastar/account/README.md +15 -0
- package/docs/api/@aastar/account/classes/UserOpClient.md +87 -0
- package/docs/api/@aastar/account/functions/createEOAWalletClient.md +21 -0
- package/docs/api/@aastar/account/functions/getUserOpHash.md +23 -0
- package/docs/api/@aastar/account/functions/packUserOpLimits.md +19 -0
- package/docs/api/@aastar/account/functions/toSimpleSmartAccount.md +83 -0
- package/docs/api/@aastar/account/type-aliases/EOAWalletClient.md +37 -0
- package/docs/api/@aastar/account/type-aliases/SimpleSmartAccount.md +39 -0
- package/docs/api/@aastar/core/README.md +136 -0
- package/docs/api/@aastar/core/classes/BLSSigner.md +147 -0
- package/docs/api/@aastar/core/enumerations/NodeType.md +33 -0
- package/docs/api/@aastar/core/functions/aggregatorActions.md +2714 -0
- package/docs/api/@aastar/core/functions/createAAStarPublicClient.md +3105 -0
- package/docs/api/@aastar/core/functions/dvtActions.md +2714 -0
- package/docs/api/@aastar/core/functions/factoryActions.md +2714 -0
- package/docs/api/@aastar/core/functions/getAddressUrl.md +32 -0
- package/docs/api/@aastar/core/functions/getAllCommunityConfigs.md +9 -0
- package/docs/api/@aastar/core/functions/getAllV2Contracts.md +20 -0
- package/docs/api/@aastar/core/functions/getBlockExplorer.md +26 -0
- package/docs/api/@aastar/core/functions/getChainId.md +26 -0
- package/docs/api/@aastar/core/functions/getCommunities.md +76 -0
- package/docs/api/@aastar/core/functions/getCommunity.md +32 -0
- package/docs/api/@aastar/core/functions/getCommunityConfig.md +15 -0
- package/docs/api/@aastar/core/functions/getContract.md +37 -0
- package/docs/api/@aastar/core/functions/getContractNetworks.md +18 -0
- package/docs/api/@aastar/core/functions/getContracts.md +178 -0
- package/docs/api/@aastar/core/functions/getCoreContracts.md +55 -0
- package/docs/api/@aastar/core/functions/getDeploymentDate.md +32 -0
- package/docs/api/@aastar/core/functions/getEntryPoint.md +25 -0
- package/docs/api/@aastar/core/functions/getNetwork.md +26 -0
- package/docs/api/@aastar/core/functions/getPaymasterV4_1.md +25 -0
- package/docs/api/@aastar/core/functions/getRpcUrl.md +25 -0
- package/docs/api/@aastar/core/functions/getSimpleAccountFactory.md +25 -0
- package/docs/api/@aastar/core/functions/getSuperPaymasterV2.md +25 -0
- package/docs/api/@aastar/core/functions/getTestAccounts.md +30 -0
- package/docs/api/@aastar/core/functions/getTestTokenContracts.md +38 -0
- package/docs/api/@aastar/core/functions/getTokenContracts.md +31 -0
- package/docs/api/@aastar/core/functions/getTxUrl.md +32 -0
- package/docs/api/@aastar/core/functions/getV2ContractByAddress.md +28 -0
- package/docs/api/@aastar/core/functions/getV2ContractByName.md +28 -0
- package/docs/api/@aastar/core/functions/getV2ContractsByDate.md +26 -0
- package/docs/api/@aastar/core/functions/isContractNetworkSupported.md +27 -0
- package/docs/api/@aastar/core/functions/isRegisteredCommunity.md +15 -0
- package/docs/api/@aastar/core/functions/isV2Contract.md +27 -0
- package/docs/api/@aastar/core/functions/paymasterV4Actions.md +2719 -0
- package/docs/api/@aastar/core/functions/registryActions.md +2720 -0
- package/docs/api/@aastar/core/functions/reputationActions.md +2720 -0
- package/docs/api/@aastar/core/functions/sbtActions.md +2720 -0
- package/docs/api/@aastar/core/functions/stakingActions.md +2720 -0
- package/docs/api/@aastar/core/functions/superPaymasterActions.md +2720 -0
- package/docs/api/@aastar/core/functions/tokenActions.md +2714 -0
- package/docs/api/@aastar/core/interfaces/CommunityConfig.md +81 -0
- package/docs/api/@aastar/core/interfaces/ContractVersion.md +63 -0
- package/docs/api/@aastar/core/type-aliases/AggregatorActions.md +79 -0
- package/docs/api/@aastar/core/type-aliases/ContractCategory.md +5 -0
- package/docs/api/@aastar/core/type-aliases/ContractNetwork.md +5 -0
- package/docs/api/@aastar/core/type-aliases/DVTActions.md +139 -0
- package/docs/api/@aastar/core/type-aliases/FactoryActions.md +99 -0
- package/docs/api/@aastar/core/type-aliases/NetworkContracts.md +5 -0
- package/docs/api/@aastar/core/type-aliases/PaymasterV4Actions.md +422 -0
- package/docs/api/@aastar/core/type-aliases/RegistryActions.md +263 -0
- package/docs/api/@aastar/core/type-aliases/ReputationActions.md +47 -0
- package/docs/api/@aastar/core/type-aliases/RoleConfig.md +83 -0
- package/docs/api/@aastar/core/type-aliases/SBTActions.md +203 -0
- package/docs/api/@aastar/core/type-aliases/StakingActions.md +179 -0
- package/docs/api/@aastar/core/type-aliases/SuperPaymasterActions.md +219 -0
- package/docs/api/@aastar/core/type-aliases/SupportedNetwork.md +3 -0
- package/docs/api/@aastar/core/type-aliases/TokenActions.md +151 -0
- package/docs/api/@aastar/core/variables/AASTAR_COMMUNITY.md +8 -0
- package/docs/api/@aastar/core/variables/ALL_ADDRESSES.md +71 -0
- package/docs/api/@aastar/core/variables/BLSAggregatorABI.md +3 -0
- package/docs/api/@aastar/core/variables/BLSHelpers.md +91 -0
- package/docs/api/@aastar/core/variables/BPS_DENOMINATOR.md +5 -0
- package/docs/api/@aastar/core/variables/BRANDING.md +67 -0
- package/docs/api/@aastar/core/variables/BREAD_COMMUNITY.md +8 -0
- package/docs/api/@aastar/core/variables/COMMUNITIES.md +5 -0
- package/docs/api/@aastar/core/variables/COMMUNITY_OWNERS.md +15 -0
- package/docs/api/@aastar/core/variables/CONTRACTS.md +163 -0
- package/docs/api/@aastar/core/variables/CONTRACT_METADATA.md +67 -0
- package/docs/api/@aastar/core/variables/CORE_ADDRESSES.md +35 -0
- package/docs/api/@aastar/core/variables/DEFAULT_APNTS_PRICE_USD.md +5 -0
- package/docs/api/@aastar/core/variables/DEFAULT_GAS_TOKEN_MINT_AMOUNT.md +5 -0
- package/docs/api/@aastar/core/variables/DEFAULT_USDT_MINT_AMOUNT.md +5 -0
- package/docs/api/@aastar/core/variables/DVTValidatorABI.md +3 -0
- package/docs/api/@aastar/core/variables/EntryPointABI.md +3 -0
- package/docs/api/@aastar/core/variables/FAUCET_API_URL.md +5 -0
- package/docs/api/@aastar/core/variables/GTokenABI.md +3 -0
- package/docs/api/@aastar/core/variables/GTokenStakingABI.md +3 -0
- package/docs/api/@aastar/core/variables/LINKS.md +33 -0
- package/docs/api/@aastar/core/variables/MAX_SERVICE_FEE.md +5 -0
- package/docs/api/@aastar/core/variables/MONITORING_ADDRESSES.md +15 -0
- package/docs/api/@aastar/core/variables/MySBTABI.md +3 -0
- package/docs/api/@aastar/core/variables/NETWORKS.md +79 -0
- package/docs/api/@aastar/core/variables/NODE_STAKE_AMOUNTS.md +31 -0
- package/docs/api/@aastar/core/variables/OFFICIAL_ADDRESSES.md +11 -0
- package/docs/api/@aastar/core/variables/PAYMASTER_ADDRESSES.md +15 -0
- package/docs/api/@aastar/core/variables/PaymasterABI.md +3 -0
- package/docs/api/@aastar/core/variables/PaymasterFactoryABI.md +3 -0
- package/docs/api/@aastar/core/variables/PaymasterV4ABI.md +3 -0
- package/docs/api/@aastar/core/variables/ROLE_ANODE.md +3 -0
- package/docs/api/@aastar/core/variables/ROLE_COMMUNITY.md +3 -0
- package/docs/api/@aastar/core/variables/ROLE_ENDUSER.md +5 -0
- package/docs/api/@aastar/core/variables/ROLE_KMS.md +3 -0
- package/docs/api/@aastar/core/variables/ROLE_PAYMASTER_AOA.md +3 -0
- package/docs/api/@aastar/core/variables/ROLE_PAYMASTER_SUPER.md +3 -0
- package/docs/api/@aastar/core/variables/RegistryABI.md +3 -0
- package/docs/api/@aastar/core/variables/ReputationSystemABI.md +3 -0
- package/docs/api/@aastar/core/variables/ReputationSystemV3ABI.md +3 -0
- package/docs/api/@aastar/core/variables/SEPOLIA_CONTRACTS.md +159 -0
- package/docs/api/@aastar/core/variables/SEPOLIA_V2_VERSIONS.md +67 -0
- package/docs/api/@aastar/core/variables/SERVICE_FEE_RATE.md +5 -0
- package/docs/api/@aastar/core/variables/Simple7702AccountABI.md +3 -0
- package/docs/api/@aastar/core/variables/SimpleAccountABI.md +3 -0
- package/docs/api/@aastar/core/variables/SimpleAccountFactoryABI.md +3 -0
- package/docs/api/@aastar/core/variables/SimpleAccountFactoryV08ABI.md +3 -0
- package/docs/api/@aastar/core/variables/SimpleAccountV08ABI.md +3 -0
- package/docs/api/@aastar/core/variables/SuperPaymasterABI.md +3 -0
- package/docs/api/@aastar/core/variables/SuperPaymasterV3ABI.md +3 -0
- package/docs/api/@aastar/core/variables/TEST_ACCOUNT_ADDRESSES.md +11 -0
- package/docs/api/@aastar/core/variables/TEST_ACCOUNT_POOL_SIZE.md +5 -0
- package/docs/api/@aastar/core/variables/TEST_COMMUNITIES.md +19 -0
- package/docs/api/@aastar/core/variables/TEST_TOKEN_ADDRESSES.md +19 -0
- package/docs/api/@aastar/core/variables/TOKEN_ADDRESSES.md +11 -0
- package/docs/api/@aastar/core/variables/V2_SUMMARY.md +39 -0
- package/docs/api/@aastar/core/variables/xPNTsFactoryABI.md +3 -0
- package/docs/api/@aastar/core/variables/xPNTsTokenABI.md +3 -0
- package/docs/api/@aastar/paymaster/README.md +14 -0
- package/docs/api/@aastar/paymaster/classes/SuperPaymasterClient.md +163 -0
- package/docs/api/@aastar/paymaster/functions/checkEligibility.md +28 -0
- package/docs/api/@aastar/paymaster/functions/getPaymasterV4Middleware.md +32 -0
- package/docs/api/@aastar/paymaster/functions/getSuperPaymasterMiddleware.md +32 -0
- package/docs/api/@aastar/paymaster/type-aliases/PaymasterConfig.md +35 -0
- package/docs/api/@aastar/paymaster/type-aliases/PaymasterV4MiddlewareConfig.md +35 -0
- package/docs/api/@aastar/tokens/README.md +3 -0
- package/docs/api/@aastar/tokens/classes/FinanceClient.md +8653 -0
- package/docs/api/README.md +6 -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/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/old-solution.md +1078 -0
- package/docs/paper-data-collection.md +69 -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/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/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/ext/permissionless.js/.changeset/README.md +8 -0
- package/ext/permissionless.js/.changeset/config.json +11 -0
- package/ext/permissionless.js/.env-example +2 -0
- package/ext/permissionless.js/.github/actions/install-dependencies/action.yml +17 -0
- package/ext/permissionless.js/.github/dependabot.yaml +10 -0
- package/ext/permissionless.js/.github/workflows/canary.yml +49 -0
- package/ext/permissionless.js/.github/workflows/on-pull-request.yml +61 -0
- package/ext/permissionless.js/.github/workflows/on-push-to-main.yml +59 -0
- package/ext/permissionless.js/.github/workflows/prune-tags.yml +92 -0
- package/ext/permissionless.js/.github/workflows/verify.yml +114 -0
- package/ext/permissionless.js/.size-limit.json +13 -0
- package/ext/permissionless.js/LICENSE +21 -0
- package/ext/permissionless.js/assets/banner.png +0 -0
- package/ext/permissionless.js/biome.json +46 -0
- package/ext/permissionless.js/bun.lock +2340 -0
- package/ext/permissionless.js/bun.lockb +0 -0
- package/ext/permissionless.js/package.json +82 -0
- package/ext/permissionless.js/packages/mock-paymaster/CHANGELOG.md +31 -0
- package/ext/permissionless.js/packages/mock-paymaster/constants.ts +84 -0
- package/ext/permissionless.js/packages/mock-paymaster/helpers/abi.ts +1048 -0
- package/ext/permissionless.js/packages/mock-paymaster/helpers/erc20-utils.ts +105 -0
- package/ext/permissionless.js/packages/mock-paymaster/helpers/schema.ts +307 -0
- package/ext/permissionless.js/packages/mock-paymaster/helpers/utils.ts +78 -0
- package/ext/permissionless.js/packages/mock-paymaster/index.ts +63 -0
- package/ext/permissionless.js/packages/mock-paymaster/package.json +33 -0
- package/ext/permissionless.js/packages/mock-paymaster/relay.ts +424 -0
- package/ext/permissionless.js/packages/mock-paymaster/setup.ts +163 -0
- package/ext/permissionless.js/packages/mock-paymaster/singletonPaymasters.ts +230 -0
- package/ext/permissionless.js/packages/permissionless/CHANGELOG.md +893 -0
- package/ext/permissionless.js/packages/permissionless/README.md +122 -0
- package/ext/permissionless.js/packages/permissionless/accounts/biconomy/abi/BiconomySmartAccountAbi.ts +128 -0
- package/ext/permissionless.js/packages/permissionless/accounts/biconomy/toBiconomySmartAccount.ts +374 -0
- package/ext/permissionless.js/packages/permissionless/accounts/decodeCalls.test.ts +505 -0
- package/ext/permissionless.js/packages/permissionless/accounts/etherspot/abi/EtherspotBootstrapAbi.ts +94 -0
- package/ext/permissionless.js/packages/permissionless/accounts/etherspot/constants.ts +27 -0
- package/ext/permissionless.js/packages/permissionless/accounts/etherspot/toEtherspotSmartAccount.ts +369 -0
- package/ext/permissionless.js/packages/permissionless/accounts/etherspot/utils/getInitMSAData.ts +56 -0
- package/ext/permissionless.js/packages/permissionless/accounts/etherspot/utils/getNonceKey.ts +21 -0
- package/ext/permissionless.js/packages/permissionless/accounts/etherspot/utils/wrapMessageHash.ts +43 -0
- package/ext/permissionless.js/packages/permissionless/accounts/index.ts +86 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/abi/KernelAccountAbi.ts +87 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/abi/KernelV3AccountAbi.ts +813 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/abi/KernelV3FactoryAbi.ts +12 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/abi/KernelV3MetaFactoryAbi.ts +17 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/constants.ts +14 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/to7702KernelSmartAccount.ts +63 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/toEcdsaKernelSmartAccount.ts +62 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/toKernelSmartAccount.ts +984 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/utils/decodeCallData.ts +43 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/utils/encodeCallData.ts +57 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/utils/getNonceKey.ts +33 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/utils/isKernelV2.ts +6 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/utils/isWebAuthnAccount.ts +8 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/utils/signMessage.ts +115 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/utils/signTypedData.ts +97 -0
- package/ext/permissionless.js/packages/permissionless/accounts/kernel/utils/wrapMessageHash.ts +44 -0
- package/ext/permissionless.js/packages/permissionless/accounts/light/toLightSmartAccount.ts +496 -0
- package/ext/permissionless.js/packages/permissionless/accounts/nexus/toNexusSmartAccount.ts +351 -0
- package/ext/permissionless.js/packages/permissionless/accounts/safe/index.ts +14 -0
- package/ext/permissionless.js/packages/permissionless/accounts/safe/signUserOperation.test.ts +275 -0
- package/ext/permissionless.js/packages/permissionless/accounts/safe/signUserOperation.ts +316 -0
- package/ext/permissionless.js/packages/permissionless/accounts/safe/toSafeSmartAccount.ts +1980 -0
- package/ext/permissionless.js/packages/permissionless/accounts/simple/to7702SimpleSmartAccount.ts +51 -0
- package/ext/permissionless.js/packages/permissionless/accounts/simple/toSimpleSmartAccount.ts +585 -0
- package/ext/permissionless.js/packages/permissionless/accounts/thirdweb/toThirdwebSmartAccount.ts +221 -0
- package/ext/permissionless.js/packages/permissionless/accounts/thirdweb/utils/decodeCallData.ts +87 -0
- package/ext/permissionless.js/packages/permissionless/accounts/thirdweb/utils/encodeCallData.ts +81 -0
- package/ext/permissionless.js/packages/permissionless/accounts/thirdweb/utils/getAccountAddress.ts +48 -0
- package/ext/permissionless.js/packages/permissionless/accounts/thirdweb/utils/getFactoryData.ts +40 -0
- package/ext/permissionless.js/packages/permissionless/accounts/thirdweb/utils/signMessage.ts +33 -0
- package/ext/permissionless.js/packages/permissionless/accounts/thirdweb/utils/signTypedData.ts +67 -0
- package/ext/permissionless.js/packages/permissionless/accounts/trust/toTrustSmartAccount.ts +232 -0
- package/ext/permissionless.js/packages/permissionless/accounts/trust/utils/decodeCallData.ts +87 -0
- package/ext/permissionless.js/packages/permissionless/accounts/trust/utils/encodeCallData.ts +81 -0
- package/ext/permissionless.js/packages/permissionless/accounts/trust/utils/getFactoryData.ts +51 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/accountId.test.ts +39 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/accountId.ts +93 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/installModule.test.ts +216 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/installModule.ts +99 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/installModules.test.ts +237 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/installModules.ts +96 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/isModuleInstalled.test.ts +72 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/isModuleInstalled.ts +132 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/supportsExecutionMode.test.ts +108 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/supportsExecutionMode.ts +158 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/supportsModule.test.ts +35 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/supportsModule.ts +120 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/uninstallModule.test.ts +129 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/uninstallModule.ts +98 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/uninstallModules.test.ts +117 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579/uninstallModules.ts +87 -0
- package/ext/permissionless.js/packages/permissionless/actions/erc7579.ts +103 -0
- package/ext/permissionless.js/packages/permissionless/actions/etherspot/getUserOperationGasPrice.ts +32 -0
- package/ext/permissionless.js/packages/permissionless/actions/etherspot.ts +4 -0
- package/ext/permissionless.js/packages/permissionless/actions/index.ts +9 -0
- package/ext/permissionless.js/packages/permissionless/actions/package.json +6 -0
- package/ext/permissionless.js/packages/permissionless/actions/passkeyServer/getCredentials.ts +47 -0
- package/ext/permissionless.js/packages/permissionless/actions/passkeyServer/startAuthentication.ts +39 -0
- package/ext/permissionless.js/packages/permissionless/actions/passkeyServer/startRegistration.ts +126 -0
- package/ext/permissionless.js/packages/permissionless/actions/passkeyServer/verifyAuthentication.ts +142 -0
- package/ext/permissionless.js/packages/permissionless/actions/passkeyServer/verifyRegistration.ts +132 -0
- package/ext/permissionless.js/packages/permissionless/actions/passkeyServer.ts +17 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/estimateErc20PaymasterCost.ts +102 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/getTokenQuotes.test.ts +90 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/getTokenQuotes.ts +77 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/getUserOperationGasPrice.test.ts +82 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/getUserOperationGasPrice.ts +67 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/getUserOperationStatus.test.ts +199 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/getUserOperationStatus.ts +49 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/sendCompressedUserOperation.ts +59 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/sponsorUserOperation.test.ts +236 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/sponsorUserOperation.ts +151 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/validateSponsorshipPolicies.test.ts +153 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico/validateSponsorshipPolicies.ts +74 -0
- package/ext/permissionless.js/packages/permissionless/actions/pimlico.ts +38 -0
- package/ext/permissionless.js/packages/permissionless/actions/public/getAccountNonce.test.ts +96 -0
- package/ext/permissionless.js/packages/permissionless/actions/public/getAccountNonce.ts +75 -0
- package/ext/permissionless.js/packages/permissionless/actions/public/getSenderAddress.test.ts +154 -0
- package/ext/permissionless.js/packages/permissionless/actions/public/getSenderAddress.ts +129 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount/getCallsStatus.test.ts +255 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount/getCallsStatus.ts +91 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount/sendCalls.test.ts +571 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount/sendCalls.ts +38 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount/sendTransaction.test.ts +416 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount/sendTransaction.ts +133 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount/signMessage.test.ts +219 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount/signMessage.ts +73 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount/signTypedData.test.ts +228 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount/signTypedData.ts +157 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount/writeContract.ts +70 -0
- package/ext/permissionless.js/packages/permissionless/actions/smartAccount.ts +7 -0
- package/ext/permissionless.js/packages/permissionless/clients/createSmartAccountClient.ts +181 -0
- package/ext/permissionless.js/packages/permissionless/clients/decorators/passkeyServer.ts +57 -0
- package/ext/permissionless.js/packages/permissionless/clients/decorators/pimlico.ts +189 -0
- package/ext/permissionless.js/packages/permissionless/clients/decorators/smartAccount.ts +350 -0
- package/ext/permissionless.js/packages/permissionless/clients/index.ts +2 -0
- package/ext/permissionless.js/packages/permissionless/clients/passkeyServer.ts +69 -0
- package/ext/permissionless.js/packages/permissionless/clients/pimlico.ts +124 -0
- package/ext/permissionless.js/packages/permissionless/errors/index.ts +17 -0
- package/ext/permissionless.js/packages/permissionless/experimental/pimlico/index.ts +1 -0
- package/ext/permissionless.js/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts +523 -0
- package/ext/permissionless.js/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts +369 -0
- package/ext/permissionless.js/packages/permissionless/index.ts +3 -0
- package/ext/permissionless.js/packages/permissionless/package.json +102 -0
- package/ext/permissionless.js/packages/permissionless/types/etherspot.ts +12 -0
- package/ext/permissionless.js/packages/permissionless/types/package.json +6 -0
- package/ext/permissionless.js/packages/permissionless/types/passkeyServer.ts +125 -0
- package/ext/permissionless.js/packages/permissionless/types/pimlico.ts +151 -0
- package/ext/permissionless.js/packages/permissionless/utils/decode7579Calls.ts +133 -0
- package/ext/permissionless.js/packages/permissionless/utils/decodeNonce.test.ts +40 -0
- package/ext/permissionless.js/packages/permissionless/utils/decodeNonce.ts +10 -0
- package/ext/permissionless.js/packages/permissionless/utils/deepHexlify.test.ts +57 -0
- package/ext/permissionless.js/packages/permissionless/utils/deepHexlify.ts +35 -0
- package/ext/permissionless.js/packages/permissionless/utils/encode7579Calls.test.ts +69 -0
- package/ext/permissionless.js/packages/permissionless/utils/encode7579Calls.ts +114 -0
- package/ext/permissionless.js/packages/permissionless/utils/encodeInstallModule.ts +91 -0
- package/ext/permissionless.js/packages/permissionless/utils/encodeNonce.test.ts +38 -0
- package/ext/permissionless.js/packages/permissionless/utils/encodeNonce.ts +8 -0
- package/ext/permissionless.js/packages/permissionless/utils/encodeUninstallModule.ts +88 -0
- package/ext/permissionless.js/packages/permissionless/utils/erc20AllowanceOverride.test.ts +59 -0
- package/ext/permissionless.js/packages/permissionless/utils/erc20AllowanceOverride.ts +66 -0
- package/ext/permissionless.js/packages/permissionless/utils/erc20BalanceOverride.test.ts +57 -0
- package/ext/permissionless.js/packages/permissionless/utils/erc20BalanceOverride.ts +49 -0
- package/ext/permissionless.js/packages/permissionless/utils/getAddressFromInitCodeOrPaymasterAndData.test.ts +31 -0
- package/ext/permissionless.js/packages/permissionless/utils/getAddressFromInitCodeOrPaymasterAndData.ts +13 -0
- package/ext/permissionless.js/packages/permissionless/utils/getEstimationCallData.ts +297 -0
- package/ext/permissionless.js/packages/permissionless/utils/getPackedUserOperation.test.ts +204 -0
- package/ext/permissionless.js/packages/permissionless/utils/getPackedUserOperation.ts +122 -0
- package/ext/permissionless.js/packages/permissionless/utils/getRequiredPrefund.test.ts +90 -0
- package/ext/permissionless.js/packages/permissionless/utils/getRequiredPrefund.ts +56 -0
- package/ext/permissionless.js/packages/permissionless/utils/index.ts +43 -0
- package/ext/permissionless.js/packages/permissionless/utils/isSmartAccountDeployed.ts +13 -0
- package/ext/permissionless.js/packages/permissionless/utils/ox.ts +48 -0
- package/ext/permissionless.js/packages/permissionless/utils/toOwner.ts +89 -0
- package/ext/permissionless.js/packages/permissionless/vitest.config.ts +31 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/constants/accounts/biconomy.ts +22 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/constants/accounts/etherspot.ts +12 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/constants/accounts/kernel.ts +63 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/constants/accounts/light.ts +10 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/constants/accounts/nexus.ts +16 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/constants/accounts/safe.ts +75 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/constants/accounts/simple.ts +16 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/constants/accounts/thirdweb.ts +7 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/constants/accounts/trust.ts +26 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/constants/core.ts +24 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/constants/index.ts +10 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/index.ts +783 -0
- package/ext/permissionless.js/packages/permissionless-test/mock-aa-infra/alto/instance.ts +290 -0
- package/ext/permissionless.js/packages/permissionless-test/src/testWithRpc.ts +128 -0
- package/ext/permissionless.js/packages/permissionless-test/src/types.ts +12 -0
- package/ext/permissionless.js/packages/permissionless-test/src/utils.ts +1091 -0
- package/ext/permissionless.js/packages/wagmi/CHANGELOG.md +53 -0
- package/ext/permissionless.js/packages/wagmi/README.md +93 -0
- package/ext/permissionless.js/packages/wagmi/context.ts +22 -0
- package/ext/permissionless.js/packages/wagmi/hooks/useAvailableCapabilities.ts +43 -0
- package/ext/permissionless.js/packages/wagmi/hooks/useSendTransaction.ts +164 -0
- package/ext/permissionless.js/packages/wagmi/hooks/useWaitForTransactionReceipt.ts +427 -0
- package/ext/permissionless.js/packages/wagmi/index.ts +15 -0
- package/ext/permissionless.js/packages/wagmi/package.json +26 -0
- package/ext/permissionless.js/packages/wagmi/utils/observe.ts +76 -0
- package/ext/permissionless.js/packages/wagmi-demo/README.md +1 -0
- package/ext/permissionless.js/packages/wagmi-demo/biome.json +13 -0
- package/ext/permissionless.js/packages/wagmi-demo/index.html +12 -0
- package/ext/permissionless.js/packages/wagmi-demo/package.json +16 -0
- package/ext/permissionless.js/packages/wagmi-demo/src/App.tsx +98 -0
- package/ext/permissionless.js/packages/wagmi-demo/src/PasskeyServerDemo.tsx +286 -0
- package/ext/permissionless.js/packages/wagmi-demo/src/PasskeysDemo.tsx +457 -0
- package/ext/permissionless.js/packages/wagmi-demo/src/index.css +21 -0
- package/ext/permissionless.js/packages/wagmi-demo/src/main.tsx +275 -0
- package/ext/permissionless.js/packages/wagmi-demo/src/vite-env.d.ts +1 -0
- package/ext/permissionless.js/packages/wagmi-demo/src/wagmi.ts +33 -0
- package/ext/permissionless.js/packages/wagmi-demo/tsconfig.json +25 -0
- package/ext/permissionless.js/packages/wagmi-demo/tsconfig.node.json +12 -0
- package/ext/permissionless.js/packages/wagmi-demo/vite.config.ts +7 -0
- package/ext/permissionless.js/tsconfig/tsconfig.base.json +42 -0
- package/ext/permissionless.js/tsconfig/tsconfig.mock-paymaster.cjs.json +11 -0
- package/ext/permissionless.js/tsconfig/tsconfig.mock-paymaster.esm.json +9 -0
- package/ext/permissionless.js/tsconfig/tsconfig.mock-paymaster.json +17 -0
- package/ext/permissionless.js/tsconfig/tsconfig.mock-paymaster.types.json +13 -0
- package/ext/permissionless.js/tsconfig/tsconfig.permissionless.cjs.json +11 -0
- package/ext/permissionless.js/tsconfig/tsconfig.permissionless.esm.json +9 -0
- package/ext/permissionless.js/tsconfig/tsconfig.permissionless.json +18 -0
- package/ext/permissionless.js/tsconfig/tsconfig.permissionless.types.json +13 -0
- package/ext/permissionless.js/tsconfig/tsconfig.wagmi.esm.json +8 -0
- package/ext/permissionless.js/tsconfig/tsconfig.wagmi.json +19 -0
- package/ext/permissionless.js/tsconfig/tsconfig.wagmi.types.json +12 -0
- package/extract_abis.sh +140 -0
- package/extract_addresses_to_env.sh +67 -0
- package/final_safe_harmonize.py +77 -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 +53 -21
- package/packages/account/package.json +20 -0
- package/packages/account/src/accounts/simple.ts +84 -0
- package/packages/account/src/eoa.ts +31 -0
- package/packages/account/src/index.ts +61 -0
- package/packages/account/tsconfig.json +12 -0
- package/packages/analytics/package.json +21 -0
- package/packages/analytics/src/index.ts +145 -0
- package/packages/analytics/tsconfig.json +16 -0
- package/packages/community/package.json +22 -0
- package/packages/community/src/index.ts +306 -0
- package/packages/community/tsconfig.json +8 -0
- package/packages/core/package.json +22 -0
- package/packages/core/src/abis/BLSAggregator.json +572 -0
- package/packages/core/src/abis/BLSValidator.json +26 -0
- package/packages/core/src/abis/DVTValidator.json +370 -0
- package/packages/core/src/abis/Eip7702Support.json +24 -0
- package/packages/core/src/abis/EntryPoint.json +1379 -0
- package/packages/core/src/abis/GToken.json +523 -0
- package/packages/core/src/abis/GTokenStaking.json +931 -0
- package/packages/core/src/abis/LegacyAccount.json +625 -0
- package/packages/core/src/abis/MySBT.json +1586 -0
- package/packages/core/src/abis/Paymaster.json +1205 -0
- package/packages/core/src/abis/PaymasterFactory.json +650 -0
- package/packages/core/src/abis/PaymasterV4_2.json +1183 -0
- package/packages/core/src/abis/Registry.json +1636 -0
- package/packages/core/src/abis/ReputationSystem.json +477 -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 +625 -0
- package/packages/core/src/abis/SimpleAccountFactory.json +108 -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 +1399 -0
- package/packages/core/src/abis/UserOperationLib.json +57 -0
- package/packages/core/src/abis/aPNTs.json +1173 -0
- package/packages/core/src/abis/index.ts +68 -0
- package/packages/core/src/abis/xPNTsFactory.json +728 -0
- package/packages/core/src/abis/xPNTsToken.json +1173 -0
- package/packages/core/src/actions/aggregator.ts +41 -0
- package/packages/core/src/actions/dvt.ts +53 -0
- package/packages/core/src/actions/factory.ts +41 -0
- package/packages/core/src/actions/index.ts +10 -0
- package/packages/core/src/actions/paymasterV4.ts +263 -0
- package/packages/core/src/actions/registry.ts +120 -0
- package/packages/core/src/actions/reputation.ts +27 -0
- package/packages/core/src/actions/sbt.ts +97 -0
- package/packages/core/src/actions/staking.ts +79 -0
- package/packages/core/src/actions/superPaymaster.ts +117 -0
- package/packages/core/src/actions/tokens.ts +65 -0
- package/packages/core/src/branding.ts +32 -0
- package/packages/core/src/clients.ts +13 -0
- package/packages/core/src/communities.ts +93 -0
- package/packages/core/src/constants.ts +81 -0
- package/packages/core/src/contract-addresses.ts +101 -0
- package/packages/core/src/contract-versions.ts +374 -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 +19 -0
- package/packages/core/src/networks.ts +127 -0
- package/packages/core/src/requirementChecker.ts +225 -0
- package/packages/core/src/roles.ts +244 -0
- package/packages/core/src/utils.ts +23 -0
- package/packages/core/tsconfig.json +12 -0
- package/packages/dapp/package.json +27 -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 +13 -0
- package/packages/enduser/package.json +21 -0
- package/packages/enduser/src/index.ts +138 -0
- package/packages/enduser/tsconfig.json +8 -0
- package/packages/identity/package.json +22 -0
- package/packages/identity/src/index.ts +82 -0
- package/packages/identity/src/mysbt.ts +48 -0
- package/packages/identity/tsconfig.json +12 -0
- package/packages/operator/package.json +21 -0
- package/packages/operator/src/index.ts +172 -0
- package/packages/operator/tsconfig.json +8 -0
- package/packages/paymaster/package.json +22 -0
- package/packages/paymaster/src/SuperPaymaster/index.ts +168 -0
- package/packages/paymaster/src/V4/index.ts +123 -0
- package/packages/paymaster/src/index.ts +5 -0
- package/packages/paymaster/tsconfig.json +12 -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 +8 -0
- package/packages/sdk/examples/config.json +1 -0
- package/packages/sdk/examples/regression_test.ts +106 -0
- package/packages/sdk/package.json +32 -0
- package/packages/sdk/src/clients/admin.ts +54 -0
- package/packages/sdk/src/clients/community.ts +403 -0
- package/packages/sdk/src/clients/endUser.ts +173 -0
- package/packages/sdk/src/clients/operator.ts +277 -0
- package/packages/sdk/src/errors/decoder.ts +48 -0
- package/{dist/index.js → packages/sdk/src/index.ts} +9 -1
- package/packages/sdk/src/utils/errorHandler.ts +167 -0
- package/packages/sdk/src/utils/funding.ts +280 -0
- package/packages/sdk/src/utils/keys.ts +159 -0
- package/packages/sdk/src/utils/roleData.ts +151 -0
- package/packages/sdk/src/utils/validation.ts +356 -0
- package/packages/sdk/tsconfig.json +12 -0
- package/packages/tokens/package.json +22 -0
- package/packages/tokens/src/index.ts +245 -0
- package/packages/tokens/tsconfig.json +12 -0
- package/pnpm-workspace.yaml +2 -0
- package/run_full_regression.sh +215 -0
- package/run_sdk_regression.sh +213 -0
- package/safe_harmonize.py +107 -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 +271 -0
- package/scripts/02_test_eoa.ts +50 -0
- package/scripts/03_test_standard_aa.ts +173 -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 +217 -0
- package/scripts/05_1_deposit.ts +48 -0
- package/scripts/05_test_superpaymaster.ts +380 -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 +384 -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 +279 -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 +125 -0
- package/scripts/15_test_dvt_bls_full.ts +133 -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 +89 -0
- package/scripts/19_sdk_experiment_runner.ts.backup +391 -0
- package/scripts/20_sdk_full_capability.ts +95 -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 +216 -0
- package/scripts/collect_industry_baseline.ts +236 -0
- package/scripts/complete_env_config.ts +97 -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_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/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 +72 -0
- package/scripts/generate_env_from_deployment.ts +109 -0
- package/scripts/publish_all.sh +39 -0
- package/scripts/quick_setup.ts +124 -0
- package/scripts/run_automated_experiment.sh +121 -0
- package/scripts/run_daily_experiment.ts +70 -0
- package/scripts/security_audit.sh +172 -0
- package/scripts/sync_config_to_env.ts +88 -0
- package/scripts/test_groups.ts +267 -0
- package/scripts/test_multi_community_anvil.ts +276 -0
- package/scripts/test_new_sdk_apis_sepolia.ts +115 -0
- package/scripts/test_sdk_join_idempotent.ts +233 -0
- package/scripts/test_simple_sepolia.ts +44 -0
- package/scripts/v2_regression/00_validate_env.ts +77 -0
- package/scripts/v2_regression/01_setup_and_fund.ts +132 -0
- package/scripts/v2_regression/02_operator_onboarding.ts +300 -0
- package/scripts/v2_regression/03_community_registry.ts +173 -0
- package/scripts/v2_regression/04_enduser_flow.ts +174 -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/validate_environment.ts +140 -0
- package/sdk_experiment_data.csv +2 -0
- package/surgical_harmonize.py +83 -0
- package/tsconfig.json +15 -0
- package/typedoc.json +25 -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.map +0 -1
|
@@ -0,0 +1,1980 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Account,
|
|
3
|
+
type Address,
|
|
4
|
+
type Assign,
|
|
5
|
+
type Chain,
|
|
6
|
+
type Client,
|
|
7
|
+
type Hex,
|
|
8
|
+
type JsonRpcAccount,
|
|
9
|
+
type LocalAccount,
|
|
10
|
+
type OneOf,
|
|
11
|
+
type SignableMessage,
|
|
12
|
+
type Transport,
|
|
13
|
+
type TypedData,
|
|
14
|
+
type TypedDataDefinition,
|
|
15
|
+
type WalletClient,
|
|
16
|
+
concat,
|
|
17
|
+
decodeFunctionData,
|
|
18
|
+
encodeAbiParameters,
|
|
19
|
+
encodeFunctionData,
|
|
20
|
+
encodePacked,
|
|
21
|
+
getAddress,
|
|
22
|
+
getContractAddress,
|
|
23
|
+
hashMessage,
|
|
24
|
+
hashTypedData,
|
|
25
|
+
hexToBigInt,
|
|
26
|
+
keccak256,
|
|
27
|
+
pad,
|
|
28
|
+
size,
|
|
29
|
+
slice,
|
|
30
|
+
toBytes,
|
|
31
|
+
toHex,
|
|
32
|
+
zeroAddress
|
|
33
|
+
} from "viem"
|
|
34
|
+
import {
|
|
35
|
+
type SmartAccount,
|
|
36
|
+
type SmartAccountImplementation,
|
|
37
|
+
type UserOperation,
|
|
38
|
+
type WebAuthnAccount,
|
|
39
|
+
entryPoint06Abi,
|
|
40
|
+
entryPoint07Abi,
|
|
41
|
+
entryPoint07Address,
|
|
42
|
+
toSmartAccount
|
|
43
|
+
} from "viem/account-abstraction"
|
|
44
|
+
import { getChainId, readContract } from "viem/actions"
|
|
45
|
+
import { getAction } from "viem/utils"
|
|
46
|
+
import { getAccountNonce } from "../../actions/public/getAccountNonce.js"
|
|
47
|
+
import { decode7579Calls } from "../../utils/decode7579Calls.js"
|
|
48
|
+
import { encode7579Calls } from "../../utils/encode7579Calls.js"
|
|
49
|
+
import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed.js"
|
|
50
|
+
import { getOxExports } from "../../utils/ox.js"
|
|
51
|
+
import { type EthereumProvider, toOwner } from "../../utils/toOwner.js"
|
|
52
|
+
import {
|
|
53
|
+
concatSignatures,
|
|
54
|
+
getWebAuthnSignature,
|
|
55
|
+
signUserOperation
|
|
56
|
+
} from "./signUserOperation.js"
|
|
57
|
+
|
|
58
|
+
export type SafeVersion = "1.4.1" | "1.5.0"
|
|
59
|
+
|
|
60
|
+
const multiSendAbi = [
|
|
61
|
+
{
|
|
62
|
+
inputs: [
|
|
63
|
+
{
|
|
64
|
+
internalType: "bytes",
|
|
65
|
+
name: "transactions",
|
|
66
|
+
type: "bytes"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
name: "multiSend",
|
|
70
|
+
outputs: [],
|
|
71
|
+
stateMutability: "payable",
|
|
72
|
+
type: "function"
|
|
73
|
+
}
|
|
74
|
+
] as const
|
|
75
|
+
|
|
76
|
+
const initSafe7579Abi = [
|
|
77
|
+
{
|
|
78
|
+
type: "function",
|
|
79
|
+
name: "initSafe7579",
|
|
80
|
+
inputs: [
|
|
81
|
+
{
|
|
82
|
+
name: "safe7579",
|
|
83
|
+
type: "address",
|
|
84
|
+
internalType: "address"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "executors",
|
|
88
|
+
type: "tuple[]",
|
|
89
|
+
internalType: "struct ModuleInit[]",
|
|
90
|
+
components: [
|
|
91
|
+
{
|
|
92
|
+
name: "module",
|
|
93
|
+
type: "address",
|
|
94
|
+
internalType: "address"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "initData",
|
|
98
|
+
type: "bytes",
|
|
99
|
+
internalType: "bytes"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "fallbacks",
|
|
105
|
+
type: "tuple[]",
|
|
106
|
+
internalType: "struct ModuleInit[]",
|
|
107
|
+
components: [
|
|
108
|
+
{
|
|
109
|
+
name: "module",
|
|
110
|
+
type: "address",
|
|
111
|
+
internalType: "address"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "initData",
|
|
115
|
+
type: "bytes",
|
|
116
|
+
internalType: "bytes"
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "hooks",
|
|
122
|
+
type: "tuple[]",
|
|
123
|
+
internalType: "struct ModuleInit[]",
|
|
124
|
+
components: [
|
|
125
|
+
{
|
|
126
|
+
name: "module",
|
|
127
|
+
type: "address",
|
|
128
|
+
internalType: "address"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "initData",
|
|
132
|
+
type: "bytes",
|
|
133
|
+
internalType: "bytes"
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "attesters",
|
|
139
|
+
type: "address[]",
|
|
140
|
+
internalType: "address[]"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "threshold",
|
|
144
|
+
type: "uint8",
|
|
145
|
+
internalType: "uint8"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
outputs: [],
|
|
149
|
+
stateMutability: "nonpayable"
|
|
150
|
+
}
|
|
151
|
+
] as const
|
|
152
|
+
|
|
153
|
+
const preValidationSetupAbi = [
|
|
154
|
+
{
|
|
155
|
+
type: "function",
|
|
156
|
+
name: "preValidationSetup",
|
|
157
|
+
inputs: [
|
|
158
|
+
{
|
|
159
|
+
name: "initHash",
|
|
160
|
+
type: "bytes32",
|
|
161
|
+
internalType: "bytes32"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "to",
|
|
165
|
+
type: "address",
|
|
166
|
+
internalType: "address"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "preInit",
|
|
170
|
+
type: "bytes",
|
|
171
|
+
internalType: "bytes"
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
outputs: [],
|
|
175
|
+
stateMutability: "nonpayable"
|
|
176
|
+
}
|
|
177
|
+
] as const
|
|
178
|
+
|
|
179
|
+
const enableModulesAbi = [
|
|
180
|
+
{
|
|
181
|
+
inputs: [
|
|
182
|
+
{
|
|
183
|
+
internalType: "address[]",
|
|
184
|
+
name: "modules",
|
|
185
|
+
type: "address[]"
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
name: "enableModules",
|
|
189
|
+
outputs: [],
|
|
190
|
+
stateMutability: "nonpayable",
|
|
191
|
+
type: "function"
|
|
192
|
+
}
|
|
193
|
+
] as const
|
|
194
|
+
|
|
195
|
+
const safeWebAuthnSharedSignerAbi = [
|
|
196
|
+
{
|
|
197
|
+
inputs: [
|
|
198
|
+
{
|
|
199
|
+
components: [
|
|
200
|
+
{
|
|
201
|
+
internalType: "uint256",
|
|
202
|
+
name: "x",
|
|
203
|
+
type: "uint256"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
internalType: "uint256",
|
|
207
|
+
name: "y",
|
|
208
|
+
type: "uint256"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
internalType: "P256.Verifiers",
|
|
212
|
+
name: "verifiers",
|
|
213
|
+
type: "uint176"
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
internalType: "struct SafeWebAuthnSharedSigner.Signer",
|
|
217
|
+
name: "signer",
|
|
218
|
+
type: "tuple"
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
name: "configure",
|
|
222
|
+
outputs: [],
|
|
223
|
+
stateMutability: "nonpayable",
|
|
224
|
+
type: "function"
|
|
225
|
+
}
|
|
226
|
+
] as const
|
|
227
|
+
|
|
228
|
+
const setupAbi = [
|
|
229
|
+
{
|
|
230
|
+
inputs: [
|
|
231
|
+
{
|
|
232
|
+
internalType: "address[]",
|
|
233
|
+
name: "_owners",
|
|
234
|
+
type: "address[]"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
internalType: "uint256",
|
|
238
|
+
name: "_threshold",
|
|
239
|
+
type: "uint256"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
internalType: "address",
|
|
243
|
+
name: "to",
|
|
244
|
+
type: "address"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
internalType: "bytes",
|
|
248
|
+
name: "data",
|
|
249
|
+
type: "bytes"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
internalType: "address",
|
|
253
|
+
name: "fallbackHandler",
|
|
254
|
+
type: "address"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
internalType: "address",
|
|
258
|
+
name: "paymentToken",
|
|
259
|
+
type: "address"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
internalType: "uint256",
|
|
263
|
+
name: "payment",
|
|
264
|
+
type: "uint256"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
internalType: "address payable",
|
|
268
|
+
name: "paymentReceiver",
|
|
269
|
+
type: "address"
|
|
270
|
+
}
|
|
271
|
+
],
|
|
272
|
+
name: "setup",
|
|
273
|
+
outputs: [],
|
|
274
|
+
stateMutability: "nonpayable",
|
|
275
|
+
type: "function"
|
|
276
|
+
}
|
|
277
|
+
] as const
|
|
278
|
+
|
|
279
|
+
const createProxyWithNonceAbi = [
|
|
280
|
+
{
|
|
281
|
+
inputs: [
|
|
282
|
+
{
|
|
283
|
+
internalType: "address",
|
|
284
|
+
name: "_singleton",
|
|
285
|
+
type: "address"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
internalType: "bytes",
|
|
289
|
+
name: "initializer",
|
|
290
|
+
type: "bytes"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
internalType: "uint256",
|
|
294
|
+
name: "saltNonce",
|
|
295
|
+
type: "uint256"
|
|
296
|
+
}
|
|
297
|
+
],
|
|
298
|
+
name: "createProxyWithNonce",
|
|
299
|
+
outputs: [
|
|
300
|
+
{
|
|
301
|
+
internalType: "contract SafeProxy",
|
|
302
|
+
name: "proxy",
|
|
303
|
+
type: "address"
|
|
304
|
+
}
|
|
305
|
+
],
|
|
306
|
+
stateMutability: "nonpayable",
|
|
307
|
+
type: "function"
|
|
308
|
+
}
|
|
309
|
+
] as const
|
|
310
|
+
|
|
311
|
+
const setupSafeAbi = [
|
|
312
|
+
{
|
|
313
|
+
type: "function",
|
|
314
|
+
name: "setupSafe",
|
|
315
|
+
inputs: [
|
|
316
|
+
{
|
|
317
|
+
name: "initData",
|
|
318
|
+
type: "tuple",
|
|
319
|
+
internalType: "struct Safe7579Launchpad.InitData",
|
|
320
|
+
components: [
|
|
321
|
+
{
|
|
322
|
+
name: "singleton",
|
|
323
|
+
type: "address",
|
|
324
|
+
internalType: "address"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: "owners",
|
|
328
|
+
type: "address[]",
|
|
329
|
+
internalType: "address[]"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
name: "threshold",
|
|
333
|
+
type: "uint256",
|
|
334
|
+
internalType: "uint256"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "setupTo",
|
|
338
|
+
type: "address",
|
|
339
|
+
internalType: "address"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
name: "setupData",
|
|
343
|
+
type: "bytes",
|
|
344
|
+
internalType: "bytes"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: "safe7579",
|
|
348
|
+
type: "address",
|
|
349
|
+
internalType: "contract ISafe7579"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
name: "validators",
|
|
353
|
+
type: "tuple[]",
|
|
354
|
+
internalType: "struct ModuleInit[]",
|
|
355
|
+
components: [
|
|
356
|
+
{
|
|
357
|
+
name: "module",
|
|
358
|
+
type: "address",
|
|
359
|
+
internalType: "address"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
name: "initData",
|
|
363
|
+
type: "bytes",
|
|
364
|
+
internalType: "bytes"
|
|
365
|
+
}
|
|
366
|
+
]
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: "callData",
|
|
370
|
+
type: "bytes",
|
|
371
|
+
internalType: "bytes"
|
|
372
|
+
}
|
|
373
|
+
]
|
|
374
|
+
}
|
|
375
|
+
],
|
|
376
|
+
outputs: [],
|
|
377
|
+
stateMutability: "nonpayable"
|
|
378
|
+
}
|
|
379
|
+
] as const
|
|
380
|
+
|
|
381
|
+
const executeUserOpWithErrorStringAbi = [
|
|
382
|
+
{
|
|
383
|
+
inputs: [
|
|
384
|
+
{
|
|
385
|
+
internalType: "address",
|
|
386
|
+
name: "to",
|
|
387
|
+
type: "address"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
internalType: "uint256",
|
|
391
|
+
name: "value",
|
|
392
|
+
type: "uint256"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
internalType: "bytes",
|
|
396
|
+
name: "data",
|
|
397
|
+
type: "bytes"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
internalType: "uint8",
|
|
401
|
+
name: "operation",
|
|
402
|
+
type: "uint8"
|
|
403
|
+
}
|
|
404
|
+
],
|
|
405
|
+
name: "executeUserOpWithErrorString",
|
|
406
|
+
outputs: [],
|
|
407
|
+
stateMutability: "nonpayable",
|
|
408
|
+
type: "function"
|
|
409
|
+
}
|
|
410
|
+
] as const
|
|
411
|
+
|
|
412
|
+
export const EIP712_SAFE_OPERATION_TYPE_V06 = {
|
|
413
|
+
SafeOp: [
|
|
414
|
+
{ type: "address", name: "safe" },
|
|
415
|
+
{ type: "uint256", name: "nonce" },
|
|
416
|
+
{ type: "bytes", name: "initCode" },
|
|
417
|
+
{ type: "bytes", name: "callData" },
|
|
418
|
+
{ type: "uint256", name: "callGasLimit" },
|
|
419
|
+
{ type: "uint256", name: "verificationGasLimit" },
|
|
420
|
+
{ type: "uint256", name: "preVerificationGas" },
|
|
421
|
+
{ type: "uint256", name: "maxFeePerGas" },
|
|
422
|
+
{ type: "uint256", name: "maxPriorityFeePerGas" },
|
|
423
|
+
{ type: "bytes", name: "paymasterAndData" },
|
|
424
|
+
{ type: "uint48", name: "validAfter" },
|
|
425
|
+
{ type: "uint48", name: "validUntil" },
|
|
426
|
+
{ type: "address", name: "entryPoint" }
|
|
427
|
+
]
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export const EIP712_SAFE_OPERATION_TYPE_V07 = {
|
|
431
|
+
SafeOp: [
|
|
432
|
+
{ type: "address", name: "safe" },
|
|
433
|
+
{ type: "uint256", name: "nonce" },
|
|
434
|
+
{ type: "bytes", name: "initCode" },
|
|
435
|
+
{ type: "bytes", name: "callData" },
|
|
436
|
+
{ type: "uint128", name: "verificationGasLimit" },
|
|
437
|
+
{ type: "uint128", name: "callGasLimit" },
|
|
438
|
+
{ type: "uint256", name: "preVerificationGas" },
|
|
439
|
+
{ type: "uint128", name: "maxPriorityFeePerGas" },
|
|
440
|
+
{ type: "uint128", name: "maxFeePerGas" },
|
|
441
|
+
{ type: "bytes", name: "paymasterAndData" },
|
|
442
|
+
{ type: "uint48", name: "validAfter" },
|
|
443
|
+
{ type: "uint48", name: "validUntil" },
|
|
444
|
+
{ type: "address", name: "entryPoint" }
|
|
445
|
+
]
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const SAFE_VERSION_TO_ADDRESSES_MAP: {
|
|
449
|
+
[key in SafeVersion]: {
|
|
450
|
+
"0.6"?: {
|
|
451
|
+
SAFE_MODULE_SETUP_ADDRESS: Address
|
|
452
|
+
SAFE_4337_MODULE_ADDRESS: Address
|
|
453
|
+
SAFE_PROXY_FACTORY_ADDRESS: Address
|
|
454
|
+
SAFE_SINGLETON_ADDRESS: Address
|
|
455
|
+
MULTI_SEND_ADDRESS: Address
|
|
456
|
+
MULTI_SEND_CALL_ONLY_ADDRESS: Address
|
|
457
|
+
WEB_AUTHN_SHARED_SIGNER_ADDRESS?: never
|
|
458
|
+
SAFE_P256_VERIFIER_ADDRESS?: never
|
|
459
|
+
}
|
|
460
|
+
"0.7": {
|
|
461
|
+
SAFE_MODULE_SETUP_ADDRESS: Address
|
|
462
|
+
SAFE_4337_MODULE_ADDRESS: Address
|
|
463
|
+
SAFE_PROXY_FACTORY_ADDRESS: Address
|
|
464
|
+
SAFE_SINGLETON_ADDRESS: Address
|
|
465
|
+
MULTI_SEND_ADDRESS: Address
|
|
466
|
+
MULTI_SEND_CALL_ONLY_ADDRESS: Address
|
|
467
|
+
WEB_AUTHN_SHARED_SIGNER_ADDRESS: Address
|
|
468
|
+
SAFE_P256_VERIFIER_ADDRESS: Address
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
} = {
|
|
472
|
+
"1.4.1": {
|
|
473
|
+
"0.6": {
|
|
474
|
+
SAFE_MODULE_SETUP_ADDRESS:
|
|
475
|
+
"0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",
|
|
476
|
+
SAFE_4337_MODULE_ADDRESS:
|
|
477
|
+
"0xa581c4A4DB7175302464fF3C06380BC3270b4037",
|
|
478
|
+
SAFE_PROXY_FACTORY_ADDRESS:
|
|
479
|
+
"0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
|
|
480
|
+
SAFE_SINGLETON_ADDRESS:
|
|
481
|
+
"0x41675C099F32341bf84BFc5382aF534df5C7461a",
|
|
482
|
+
MULTI_SEND_ADDRESS: "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",
|
|
483
|
+
MULTI_SEND_CALL_ONLY_ADDRESS:
|
|
484
|
+
"0x9641d764fc13c8B624c04430C7356C1C7C8102e2"
|
|
485
|
+
},
|
|
486
|
+
"0.7": {
|
|
487
|
+
SAFE_MODULE_SETUP_ADDRESS:
|
|
488
|
+
"0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47",
|
|
489
|
+
SAFE_4337_MODULE_ADDRESS:
|
|
490
|
+
"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226",
|
|
491
|
+
SAFE_PROXY_FACTORY_ADDRESS:
|
|
492
|
+
"0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
|
|
493
|
+
SAFE_SINGLETON_ADDRESS:
|
|
494
|
+
"0x41675C099F32341bf84BFc5382aF534df5C7461a",
|
|
495
|
+
MULTI_SEND_ADDRESS: "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",
|
|
496
|
+
MULTI_SEND_CALL_ONLY_ADDRESS:
|
|
497
|
+
"0x9641d764fc13c8B624c04430C7356C1C7C8102e2",
|
|
498
|
+
WEB_AUTHN_SHARED_SIGNER_ADDRESS:
|
|
499
|
+
"0x94a4F6affBd8975951142c3999aEAB7ecee555c2",
|
|
500
|
+
SAFE_P256_VERIFIER_ADDRESS:
|
|
501
|
+
"0xA86e0054C51E4894D88762a017ECc5E5235f5DBA"
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
"1.5.0": {
|
|
505
|
+
"0.7": {
|
|
506
|
+
SAFE_MODULE_SETUP_ADDRESS:
|
|
507
|
+
"0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47",
|
|
508
|
+
SAFE_4337_MODULE_ADDRESS:
|
|
509
|
+
"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226",
|
|
510
|
+
SAFE_PROXY_FACTORY_ADDRESS:
|
|
511
|
+
"0x14F2982D601c9458F93bd70B218933A6f8165e7b",
|
|
512
|
+
SAFE_SINGLETON_ADDRESS:
|
|
513
|
+
"0xFf51A5898e281Db6DfC7855790607438dF2ca44b",
|
|
514
|
+
MULTI_SEND_ADDRESS: "0x218543288004CD07832472D464648173c77D7eB7",
|
|
515
|
+
MULTI_SEND_CALL_ONLY_ADDRESS:
|
|
516
|
+
"0xA83c336B20401Af773B6219BA5027174338D1836",
|
|
517
|
+
WEB_AUTHN_SHARED_SIGNER_ADDRESS:
|
|
518
|
+
"0x94a4F6affBd8975951142c3999aEAB7ecee555c2",
|
|
519
|
+
SAFE_P256_VERIFIER_ADDRESS:
|
|
520
|
+
"0xA86e0054C51E4894D88762a017ECc5E5235f5DBA"
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const adjustVInSignature = (
|
|
526
|
+
signingMethod: "eth_sign" | "eth_signTypedData",
|
|
527
|
+
signature: string
|
|
528
|
+
): Hex => {
|
|
529
|
+
const ETHEREUM_V_VALUES = [0, 1, 27, 28]
|
|
530
|
+
const MIN_VALID_V_VALUE_FOR_SAFE_ECDSA = 27
|
|
531
|
+
let signatureV = Number.parseInt(signature.slice(-2), 16)
|
|
532
|
+
if (!ETHEREUM_V_VALUES.includes(signatureV)) {
|
|
533
|
+
throw new Error("Invalid signature")
|
|
534
|
+
}
|
|
535
|
+
if (signingMethod === "eth_sign") {
|
|
536
|
+
if (signatureV < MIN_VALID_V_VALUE_FOR_SAFE_ECDSA) {
|
|
537
|
+
signatureV += MIN_VALID_V_VALUE_FOR_SAFE_ECDSA
|
|
538
|
+
}
|
|
539
|
+
signatureV += 4
|
|
540
|
+
}
|
|
541
|
+
if (signingMethod === "eth_signTypedData") {
|
|
542
|
+
if (signatureV < MIN_VALID_V_VALUE_FOR_SAFE_ECDSA) {
|
|
543
|
+
signatureV += MIN_VALID_V_VALUE_FOR_SAFE_ECDSA
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return (signature.slice(0, -2) + signatureV.toString(16)) as Hex
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const generateSafeMessageMessage = <
|
|
550
|
+
const TTypedData extends TypedData | { [key: string]: unknown },
|
|
551
|
+
TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData
|
|
552
|
+
>(
|
|
553
|
+
message: SignableMessage | TypedDataDefinition<TTypedData, TPrimaryType>
|
|
554
|
+
): Hex => {
|
|
555
|
+
const signableMessage = message as SignableMessage
|
|
556
|
+
|
|
557
|
+
if (typeof signableMessage === "string" || signableMessage.raw) {
|
|
558
|
+
return hashMessage(signableMessage)
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
return hashTypedData(
|
|
562
|
+
message as TypedDataDefinition<TTypedData, TPrimaryType>
|
|
563
|
+
)
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
const encodeInternalTransaction = (tx: {
|
|
567
|
+
to: Address
|
|
568
|
+
data: Address
|
|
569
|
+
value: bigint
|
|
570
|
+
operation: 0 | 1
|
|
571
|
+
}): string => {
|
|
572
|
+
const encoded = encodePacked(
|
|
573
|
+
// uint8 = 1 byte for operation
|
|
574
|
+
// address = 20 bytes for to address
|
|
575
|
+
// uint256 = 32 bytes for value
|
|
576
|
+
// uint256 = 32 bytes for data length
|
|
577
|
+
// bytes = dynamic length for data
|
|
578
|
+
["uint8", "address", "uint256", "uint256", "bytes"],
|
|
579
|
+
[
|
|
580
|
+
tx.operation,
|
|
581
|
+
tx.to,
|
|
582
|
+
tx.value,
|
|
583
|
+
BigInt(tx.data.slice(2).length / 2),
|
|
584
|
+
tx.data
|
|
585
|
+
]
|
|
586
|
+
)
|
|
587
|
+
return encoded.slice(2)
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const encodeMultiSend = (
|
|
591
|
+
txs: {
|
|
592
|
+
to: Address
|
|
593
|
+
data: Address
|
|
594
|
+
value: bigint
|
|
595
|
+
operation: 0 | 1
|
|
596
|
+
}[]
|
|
597
|
+
): Hex => {
|
|
598
|
+
const data: Hex = `0x${txs
|
|
599
|
+
.map((tx) => encodeInternalTransaction(tx))
|
|
600
|
+
.join("")}`
|
|
601
|
+
|
|
602
|
+
return encodeFunctionData({
|
|
603
|
+
abi: multiSendAbi,
|
|
604
|
+
functionName: "multiSend",
|
|
605
|
+
args: [data]
|
|
606
|
+
})
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
const get7579LaunchPadInitData = ({
|
|
610
|
+
safe4337ModuleAddress,
|
|
611
|
+
safeSingletonAddress,
|
|
612
|
+
erc7579LaunchpadAddress,
|
|
613
|
+
safeWebAuthnSharedSignerAddress,
|
|
614
|
+
owners,
|
|
615
|
+
validators,
|
|
616
|
+
executors,
|
|
617
|
+
fallbacks,
|
|
618
|
+
hooks,
|
|
619
|
+
attesters,
|
|
620
|
+
threshold,
|
|
621
|
+
attestersThreshold
|
|
622
|
+
}: {
|
|
623
|
+
safe4337ModuleAddress: Address
|
|
624
|
+
safeSingletonAddress: Address
|
|
625
|
+
erc7579LaunchpadAddress: Address
|
|
626
|
+
safeWebAuthnSharedSignerAddress?: Address
|
|
627
|
+
owners: OwnersArray<readonly (RegularOwner | WebAuthnAccount)[]>
|
|
628
|
+
executors: {
|
|
629
|
+
address: Address
|
|
630
|
+
context: Address
|
|
631
|
+
}[]
|
|
632
|
+
validators: { address: Address; context: Address }[]
|
|
633
|
+
fallbacks: { address: Address; context: Address }[]
|
|
634
|
+
hooks: { address: Address; context: Address }[]
|
|
635
|
+
attesters: Address[]
|
|
636
|
+
threshold: bigint
|
|
637
|
+
attestersThreshold: number
|
|
638
|
+
}) => {
|
|
639
|
+
const ownerAddresses = owners.map((owner) => {
|
|
640
|
+
if ("type" in owner && owner.type === "webAuthn") {
|
|
641
|
+
if (!safeWebAuthnSharedSignerAddress) {
|
|
642
|
+
throw new Error("safeWebAuthnSharedSignerAddress not defined")
|
|
643
|
+
}
|
|
644
|
+
return safeWebAuthnSharedSignerAddress
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if ("address" in owner && owner.address) {
|
|
648
|
+
return owner.address
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
throw new Error("Incorrect owner found")
|
|
652
|
+
})
|
|
653
|
+
|
|
654
|
+
const initData = {
|
|
655
|
+
singleton: safeSingletonAddress,
|
|
656
|
+
owners: ownerAddresses,
|
|
657
|
+
threshold: threshold,
|
|
658
|
+
setupTo: erc7579LaunchpadAddress,
|
|
659
|
+
setupData: encodeFunctionData({
|
|
660
|
+
abi: initSafe7579Abi,
|
|
661
|
+
functionName: "initSafe7579",
|
|
662
|
+
args: [
|
|
663
|
+
safe4337ModuleAddress, // SAFE_7579_ADDRESS,
|
|
664
|
+
executors.map((executor) => ({
|
|
665
|
+
module: executor.address,
|
|
666
|
+
initData: executor.context
|
|
667
|
+
})),
|
|
668
|
+
fallbacks.map((fallback) => ({
|
|
669
|
+
module: fallback.address,
|
|
670
|
+
initData: fallback.context
|
|
671
|
+
})),
|
|
672
|
+
hooks.map((hook) => ({
|
|
673
|
+
module: hook.address,
|
|
674
|
+
initData: hook.context
|
|
675
|
+
})),
|
|
676
|
+
attesters.sort((left, right) =>
|
|
677
|
+
left.toLowerCase().localeCompare(right.toLowerCase())
|
|
678
|
+
),
|
|
679
|
+
attestersThreshold
|
|
680
|
+
]
|
|
681
|
+
}),
|
|
682
|
+
safe7579: safe4337ModuleAddress,
|
|
683
|
+
validators: validators
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
return initData
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export const isWebAuthnAccount = (
|
|
690
|
+
owner: RegularOwner | WebAuthnAccount
|
|
691
|
+
): owner is WebAuthnAccount => {
|
|
692
|
+
return "type" in owner && owner.type === "webAuthn"
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
const getInitializerCode = async ({
|
|
696
|
+
owners,
|
|
697
|
+
threshold,
|
|
698
|
+
safeModuleSetupAddress,
|
|
699
|
+
safe4337ModuleAddress,
|
|
700
|
+
safeWebAuthnSharedSignerAddress,
|
|
701
|
+
safeP256VerifierAddress,
|
|
702
|
+
multiSendAddress,
|
|
703
|
+
safeSingletonAddress,
|
|
704
|
+
erc7579LaunchpadAddress,
|
|
705
|
+
setupTransactions = [],
|
|
706
|
+
safeModules = [],
|
|
707
|
+
validators = [],
|
|
708
|
+
executors = [],
|
|
709
|
+
fallbacks = [],
|
|
710
|
+
hooks = [],
|
|
711
|
+
attesters = [],
|
|
712
|
+
attestersThreshold = 0,
|
|
713
|
+
paymentToken = zeroAddress,
|
|
714
|
+
payment = BigInt(0),
|
|
715
|
+
paymentReceiver = zeroAddress
|
|
716
|
+
}: {
|
|
717
|
+
owners: OwnersArray<readonly (RegularOwner | WebAuthnAccount)[]>
|
|
718
|
+
threshold: bigint
|
|
719
|
+
safeSingletonAddress: Address
|
|
720
|
+
safeModuleSetupAddress: Address
|
|
721
|
+
safe4337ModuleAddress: Address
|
|
722
|
+
safeWebAuthnSharedSignerAddress?: Address
|
|
723
|
+
safeP256VerifierAddress?: Address
|
|
724
|
+
multiSendAddress: Address
|
|
725
|
+
erc7579LaunchpadAddress?: Address
|
|
726
|
+
setupTransactions?: {
|
|
727
|
+
to: Address
|
|
728
|
+
data: Address
|
|
729
|
+
value: bigint
|
|
730
|
+
}[]
|
|
731
|
+
safeModules?: Address[]
|
|
732
|
+
validators?: { address: Address; context: Address }[]
|
|
733
|
+
executors?: {
|
|
734
|
+
address: Address
|
|
735
|
+
context: Address
|
|
736
|
+
}[]
|
|
737
|
+
fallbacks?: { address: Address; context: Address }[]
|
|
738
|
+
hooks?: { address: Address; context: Address }[]
|
|
739
|
+
attesters?: Address[]
|
|
740
|
+
attestersThreshold?: number
|
|
741
|
+
paymentToken?: Address
|
|
742
|
+
payment?: bigint
|
|
743
|
+
paymentReceiver?: Address
|
|
744
|
+
}) => {
|
|
745
|
+
if (erc7579LaunchpadAddress) {
|
|
746
|
+
const initData = get7579LaunchPadInitData({
|
|
747
|
+
safe4337ModuleAddress,
|
|
748
|
+
safeSingletonAddress,
|
|
749
|
+
safeWebAuthnSharedSignerAddress,
|
|
750
|
+
erc7579LaunchpadAddress,
|
|
751
|
+
owners,
|
|
752
|
+
validators,
|
|
753
|
+
executors,
|
|
754
|
+
fallbacks,
|
|
755
|
+
threshold,
|
|
756
|
+
hooks,
|
|
757
|
+
attesters,
|
|
758
|
+
attestersThreshold
|
|
759
|
+
})
|
|
760
|
+
|
|
761
|
+
const initHash = keccak256(
|
|
762
|
+
encodeAbiParameters(
|
|
763
|
+
[
|
|
764
|
+
{
|
|
765
|
+
internalType: "address",
|
|
766
|
+
name: "singleton",
|
|
767
|
+
type: "address"
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
internalType: "address[]",
|
|
771
|
+
name: "owners",
|
|
772
|
+
type: "address[]"
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
internalType: "uint256",
|
|
776
|
+
name: "threshold",
|
|
777
|
+
type: "uint256"
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
internalType: "address",
|
|
781
|
+
name: "setupTo",
|
|
782
|
+
type: "address"
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
internalType: "bytes",
|
|
786
|
+
name: "setupData",
|
|
787
|
+
type: "bytes"
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
internalType: "contract ISafe7579",
|
|
791
|
+
name: "safe7579",
|
|
792
|
+
type: "address"
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
internalType: "struct ModuleInit[]",
|
|
796
|
+
name: "validators",
|
|
797
|
+
type: "tuple[]",
|
|
798
|
+
components: [
|
|
799
|
+
{
|
|
800
|
+
internalType: "address",
|
|
801
|
+
name: "module",
|
|
802
|
+
type: "address"
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
internalType: "bytes",
|
|
806
|
+
name: "initData",
|
|
807
|
+
type: "bytes"
|
|
808
|
+
}
|
|
809
|
+
]
|
|
810
|
+
}
|
|
811
|
+
],
|
|
812
|
+
[
|
|
813
|
+
initData.singleton,
|
|
814
|
+
initData.owners,
|
|
815
|
+
initData.threshold,
|
|
816
|
+
initData.setupTo,
|
|
817
|
+
initData.setupData,
|
|
818
|
+
initData.safe7579,
|
|
819
|
+
initData.validators.map((validator) => ({
|
|
820
|
+
module: validator.address,
|
|
821
|
+
initData: validator.context
|
|
822
|
+
}))
|
|
823
|
+
]
|
|
824
|
+
)
|
|
825
|
+
)
|
|
826
|
+
|
|
827
|
+
return encodeFunctionData({
|
|
828
|
+
abi: preValidationSetupAbi,
|
|
829
|
+
functionName: "preValidationSetup",
|
|
830
|
+
args: [initHash, zeroAddress, "0x"]
|
|
831
|
+
})
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
const webAuthnOwner = owners.reduce<WebAuthnAccount | undefined>(
|
|
835
|
+
(acc, owner) => {
|
|
836
|
+
if (isWebAuthnAccount(owner)) {
|
|
837
|
+
return owner
|
|
838
|
+
}
|
|
839
|
+
return acc
|
|
840
|
+
},
|
|
841
|
+
undefined
|
|
842
|
+
)
|
|
843
|
+
|
|
844
|
+
const ownerAddresses = owners.map((owner) => {
|
|
845
|
+
if (isWebAuthnAccount(owner)) {
|
|
846
|
+
if (!safeWebAuthnSharedSignerAddress) {
|
|
847
|
+
throw new Error("safeWebAuthnSharedSignerAddress not defined")
|
|
848
|
+
}
|
|
849
|
+
return safeWebAuthnSharedSignerAddress
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
if ("address" in owner && owner.address) {
|
|
853
|
+
return owner.address
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
throw new Error("Incorrect owner found")
|
|
857
|
+
})
|
|
858
|
+
|
|
859
|
+
const multiCalls = [
|
|
860
|
+
{
|
|
861
|
+
to: safeModuleSetupAddress,
|
|
862
|
+
data: encodeFunctionData({
|
|
863
|
+
abi: enableModulesAbi,
|
|
864
|
+
functionName: "enableModules",
|
|
865
|
+
args: [[safe4337ModuleAddress, ...safeModules]]
|
|
866
|
+
}),
|
|
867
|
+
value: BigInt(0),
|
|
868
|
+
operation: 1 as 0 | 1
|
|
869
|
+
}
|
|
870
|
+
]
|
|
871
|
+
|
|
872
|
+
if (
|
|
873
|
+
webAuthnOwner &&
|
|
874
|
+
safeWebAuthnSharedSignerAddress &&
|
|
875
|
+
safeP256VerifierAddress
|
|
876
|
+
) {
|
|
877
|
+
const { PublicKey } = await getOxExports()
|
|
878
|
+
const parsedPublicKey = PublicKey.fromHex(webAuthnOwner.publicKey)
|
|
879
|
+
|
|
880
|
+
multiCalls.push({
|
|
881
|
+
to: safeWebAuthnSharedSignerAddress,
|
|
882
|
+
data: encodeFunctionData({
|
|
883
|
+
abi: safeWebAuthnSharedSignerAbi,
|
|
884
|
+
functionName: "configure",
|
|
885
|
+
args: [
|
|
886
|
+
{
|
|
887
|
+
x: parsedPublicKey.x,
|
|
888
|
+
y: parsedPublicKey.y,
|
|
889
|
+
verifiers: BigInt(safeP256VerifierAddress)
|
|
890
|
+
}
|
|
891
|
+
]
|
|
892
|
+
}),
|
|
893
|
+
value: BigInt(0),
|
|
894
|
+
operation: 1 as 0 | 1
|
|
895
|
+
})
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
for (const tx of setupTransactions) {
|
|
899
|
+
multiCalls.push({
|
|
900
|
+
...tx,
|
|
901
|
+
operation: 0 as 0 | 1
|
|
902
|
+
})
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
const multiSendCallData = encodeMultiSend(multiCalls)
|
|
906
|
+
|
|
907
|
+
return encodeFunctionData({
|
|
908
|
+
abi: setupAbi,
|
|
909
|
+
functionName: "setup",
|
|
910
|
+
args: [
|
|
911
|
+
ownerAddresses,
|
|
912
|
+
threshold,
|
|
913
|
+
multiSendAddress,
|
|
914
|
+
multiSendCallData,
|
|
915
|
+
safe4337ModuleAddress,
|
|
916
|
+
paymentToken,
|
|
917
|
+
payment,
|
|
918
|
+
paymentReceiver
|
|
919
|
+
]
|
|
920
|
+
})
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
export function getPaymasterAndData(unpackedUserOperation: UserOperation) {
|
|
924
|
+
return unpackedUserOperation.paymaster
|
|
925
|
+
? concat([
|
|
926
|
+
unpackedUserOperation.paymaster,
|
|
927
|
+
pad(
|
|
928
|
+
toHex(
|
|
929
|
+
unpackedUserOperation.paymasterVerificationGasLimit ||
|
|
930
|
+
BigInt(0)
|
|
931
|
+
),
|
|
932
|
+
{
|
|
933
|
+
size: 16
|
|
934
|
+
}
|
|
935
|
+
),
|
|
936
|
+
pad(
|
|
937
|
+
toHex(
|
|
938
|
+
unpackedUserOperation.paymasterPostOpGasLimit || BigInt(0)
|
|
939
|
+
),
|
|
940
|
+
{
|
|
941
|
+
size: 16
|
|
942
|
+
}
|
|
943
|
+
),
|
|
944
|
+
unpackedUserOperation.paymasterData || ("0x" as Hex)
|
|
945
|
+
])
|
|
946
|
+
: "0x"
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
const getAccountInitCode = async ({
|
|
950
|
+
owners,
|
|
951
|
+
threshold,
|
|
952
|
+
safeModuleSetupAddress,
|
|
953
|
+
safe4337ModuleAddress,
|
|
954
|
+
safeSingletonAddress,
|
|
955
|
+
erc7579LaunchpadAddress,
|
|
956
|
+
safeWebAuthnSharedSignerAddress,
|
|
957
|
+
safeP256VerifierAddress,
|
|
958
|
+
multiSendAddress,
|
|
959
|
+
paymentToken,
|
|
960
|
+
payment,
|
|
961
|
+
paymentReceiver,
|
|
962
|
+
saltNonce = BigInt(0),
|
|
963
|
+
setupTransactions = [],
|
|
964
|
+
safeModules = [],
|
|
965
|
+
validators = [],
|
|
966
|
+
executors = [],
|
|
967
|
+
fallbacks = [],
|
|
968
|
+
hooks = [],
|
|
969
|
+
attesters = [],
|
|
970
|
+
attestersThreshold = 0
|
|
971
|
+
}: {
|
|
972
|
+
owners: OwnersArray<readonly (RegularOwner | WebAuthnAccount)[]>
|
|
973
|
+
threshold: bigint
|
|
974
|
+
safeModuleSetupAddress: Address
|
|
975
|
+
safe4337ModuleAddress: Address
|
|
976
|
+
safeSingletonAddress: Address
|
|
977
|
+
multiSendAddress: Address
|
|
978
|
+
safeWebAuthnSharedSignerAddress?: Address
|
|
979
|
+
safeP256VerifierAddress?: Address
|
|
980
|
+
erc7579LaunchpadAddress?: Address
|
|
981
|
+
saltNonce?: bigint
|
|
982
|
+
setupTransactions?: {
|
|
983
|
+
to: Address
|
|
984
|
+
data: Address
|
|
985
|
+
value: bigint
|
|
986
|
+
}[]
|
|
987
|
+
safeModules?: Address[]
|
|
988
|
+
validators?: { address: Address; context: Address }[]
|
|
989
|
+
executors?: {
|
|
990
|
+
address: Address
|
|
991
|
+
context: Address
|
|
992
|
+
}[]
|
|
993
|
+
fallbacks?: { address: Address; context: Address }[]
|
|
994
|
+
hooks?: { address: Address; context: Address }[]
|
|
995
|
+
attesters?: Address[]
|
|
996
|
+
attestersThreshold?: number
|
|
997
|
+
paymentToken?: Address
|
|
998
|
+
payment?: bigint
|
|
999
|
+
paymentReceiver?: Address
|
|
1000
|
+
}): Promise<Hex> => {
|
|
1001
|
+
const initializer = await getInitializerCode({
|
|
1002
|
+
owners,
|
|
1003
|
+
threshold,
|
|
1004
|
+
safeModuleSetupAddress,
|
|
1005
|
+
safeWebAuthnSharedSignerAddress,
|
|
1006
|
+
safeP256VerifierAddress,
|
|
1007
|
+
safe4337ModuleAddress,
|
|
1008
|
+
multiSendAddress,
|
|
1009
|
+
setupTransactions,
|
|
1010
|
+
safeSingletonAddress,
|
|
1011
|
+
safeModules,
|
|
1012
|
+
erc7579LaunchpadAddress,
|
|
1013
|
+
validators,
|
|
1014
|
+
executors,
|
|
1015
|
+
fallbacks,
|
|
1016
|
+
hooks,
|
|
1017
|
+
attesters,
|
|
1018
|
+
attestersThreshold,
|
|
1019
|
+
paymentToken,
|
|
1020
|
+
payment,
|
|
1021
|
+
paymentReceiver
|
|
1022
|
+
})
|
|
1023
|
+
|
|
1024
|
+
const initCodeCallData = encodeFunctionData({
|
|
1025
|
+
abi: createProxyWithNonceAbi,
|
|
1026
|
+
functionName: "createProxyWithNonce",
|
|
1027
|
+
args: [
|
|
1028
|
+
erc7579LaunchpadAddress ?? safeSingletonAddress,
|
|
1029
|
+
initializer,
|
|
1030
|
+
saltNonce
|
|
1031
|
+
]
|
|
1032
|
+
})
|
|
1033
|
+
|
|
1034
|
+
return initCodeCallData
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
export const getDefaultAddresses = (
|
|
1038
|
+
safeVersion: SafeVersion,
|
|
1039
|
+
entryPointVersion: "0.6" | "0.7",
|
|
1040
|
+
{
|
|
1041
|
+
addModuleLibAddress: _addModuleLibAddress,
|
|
1042
|
+
safeModuleSetupAddress: _safeModuleSetupAddress,
|
|
1043
|
+
safe4337ModuleAddress: _safe4337ModuleAddress,
|
|
1044
|
+
safeProxyFactoryAddress: _safeProxyFactoryAddress,
|
|
1045
|
+
safeSingletonAddress: _safeSingletonAddress,
|
|
1046
|
+
multiSendAddress: _multiSendAddress,
|
|
1047
|
+
multiSendCallOnlyAddress: _multiSendCallOnlyAddress,
|
|
1048
|
+
safeWebAuthnSharedSignerAddress: _safeWebAuthnSharedSignerAddress,
|
|
1049
|
+
safeP256VerifierAddress: _safeP256VerifierAddress
|
|
1050
|
+
}: {
|
|
1051
|
+
addModuleLibAddress?: Address
|
|
1052
|
+
safeModuleSetupAddress?: Address
|
|
1053
|
+
safe4337ModuleAddress?: Address
|
|
1054
|
+
safeProxyFactoryAddress?: Address
|
|
1055
|
+
safeSingletonAddress?: Address
|
|
1056
|
+
multiSendAddress?: Address
|
|
1057
|
+
multiSendCallOnlyAddress?: Address
|
|
1058
|
+
safeWebAuthnSharedSignerAddress?: Address
|
|
1059
|
+
safeP256VerifierAddress?: Address
|
|
1060
|
+
}
|
|
1061
|
+
) => {
|
|
1062
|
+
const versionAddresses =
|
|
1063
|
+
SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion][entryPointVersion]
|
|
1064
|
+
|
|
1065
|
+
if (!versionAddresses) {
|
|
1066
|
+
throw new Error(
|
|
1067
|
+
`Safe version ${safeVersion} does not support EntryPoint version ${entryPointVersion}`
|
|
1068
|
+
)
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
const safeModuleSetupAddress =
|
|
1072
|
+
_safeModuleSetupAddress ??
|
|
1073
|
+
_addModuleLibAddress ??
|
|
1074
|
+
versionAddresses.SAFE_MODULE_SETUP_ADDRESS
|
|
1075
|
+
const safe4337ModuleAddress =
|
|
1076
|
+
_safe4337ModuleAddress ?? versionAddresses.SAFE_4337_MODULE_ADDRESS
|
|
1077
|
+
const safeProxyFactoryAddress =
|
|
1078
|
+
_safeProxyFactoryAddress ?? versionAddresses.SAFE_PROXY_FACTORY_ADDRESS
|
|
1079
|
+
const safeSingletonAddress =
|
|
1080
|
+
_safeSingletonAddress ?? versionAddresses.SAFE_SINGLETON_ADDRESS
|
|
1081
|
+
const multiSendAddress =
|
|
1082
|
+
_multiSendAddress ?? versionAddresses.MULTI_SEND_ADDRESS
|
|
1083
|
+
|
|
1084
|
+
const multiSendCallOnlyAddress =
|
|
1085
|
+
_multiSendCallOnlyAddress ??
|
|
1086
|
+
versionAddresses.MULTI_SEND_CALL_ONLY_ADDRESS
|
|
1087
|
+
|
|
1088
|
+
const safeWebAuthnSharedSignerAddress =
|
|
1089
|
+
_safeWebAuthnSharedSignerAddress ??
|
|
1090
|
+
versionAddresses.WEB_AUTHN_SHARED_SIGNER_ADDRESS
|
|
1091
|
+
const safeP256VerifierAddress =
|
|
1092
|
+
_safeP256VerifierAddress ?? versionAddresses.SAFE_P256_VERIFIER_ADDRESS
|
|
1093
|
+
|
|
1094
|
+
return {
|
|
1095
|
+
safeModuleSetupAddress,
|
|
1096
|
+
safe4337ModuleAddress,
|
|
1097
|
+
safeProxyFactoryAddress,
|
|
1098
|
+
safeSingletonAddress,
|
|
1099
|
+
multiSendAddress,
|
|
1100
|
+
multiSendCallOnlyAddress,
|
|
1101
|
+
safeWebAuthnSharedSignerAddress,
|
|
1102
|
+
safeP256VerifierAddress
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
type GetErc7579Params<TErc7579 extends Address | undefined> =
|
|
1107
|
+
TErc7579 extends undefined
|
|
1108
|
+
? {
|
|
1109
|
+
safeModuleSetupAddress?: Address
|
|
1110
|
+
multiSendAddress?: Address
|
|
1111
|
+
multiSendCallOnlyAddress?: Address
|
|
1112
|
+
// @deprecated This field is deprecated. It is recommended to make any setup transactions in the userOperation's calldata.
|
|
1113
|
+
setupTransactions?: {
|
|
1114
|
+
to: Address
|
|
1115
|
+
data: Address
|
|
1116
|
+
value: bigint
|
|
1117
|
+
}[]
|
|
1118
|
+
safeModules?: Address[]
|
|
1119
|
+
}
|
|
1120
|
+
: {
|
|
1121
|
+
validators?: { address: Address; context: Address }[]
|
|
1122
|
+
executors?: {
|
|
1123
|
+
address: Address
|
|
1124
|
+
context: Address
|
|
1125
|
+
}[]
|
|
1126
|
+
fallbacks?: { address: Address; context: Address }[]
|
|
1127
|
+
hooks?: { address: Address; context: Address }[]
|
|
1128
|
+
attesters?: Address[]
|
|
1129
|
+
attestersThreshold?: number
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
type RegularOwner =
|
|
1133
|
+
| Account
|
|
1134
|
+
| WalletClient<Transport, Chain | undefined, Account>
|
|
1135
|
+
| EthereumProvider
|
|
1136
|
+
|
|
1137
|
+
type ValidateAtMostOneWebAuthn<
|
|
1138
|
+
T extends readonly unknown[],
|
|
1139
|
+
SeenWebAuthn extends boolean = false
|
|
1140
|
+
> = T extends readonly []
|
|
1141
|
+
? true
|
|
1142
|
+
: T extends readonly [infer H, ...infer Rest]
|
|
1143
|
+
? H extends WebAuthnAccount
|
|
1144
|
+
? SeenWebAuthn extends true
|
|
1145
|
+
? false
|
|
1146
|
+
: ValidateAtMostOneWebAuthn<Rest, true>
|
|
1147
|
+
: H extends RegularOwner
|
|
1148
|
+
? ValidateAtMostOneWebAuthn<Rest, SeenWebAuthn>
|
|
1149
|
+
: false
|
|
1150
|
+
: true
|
|
1151
|
+
|
|
1152
|
+
type OwnersArray<T extends readonly (RegularOwner | WebAuthnAccount)[]> =
|
|
1153
|
+
ValidateAtMostOneWebAuthn<T> extends true ? T : never
|
|
1154
|
+
|
|
1155
|
+
export type ToSafeSmartAccountParameters<
|
|
1156
|
+
entryPointVersion extends "0.6" | "0.7",
|
|
1157
|
+
TErc7579 extends Address | undefined
|
|
1158
|
+
> = {
|
|
1159
|
+
client: Client<
|
|
1160
|
+
Transport,
|
|
1161
|
+
Chain | undefined,
|
|
1162
|
+
JsonRpcAccount | LocalAccount | undefined
|
|
1163
|
+
>
|
|
1164
|
+
owners: OwnersArray<readonly (RegularOwner | WebAuthnAccount)[]>
|
|
1165
|
+
threshold?: bigint
|
|
1166
|
+
version: SafeVersion
|
|
1167
|
+
entryPoint?: {
|
|
1168
|
+
address: Address
|
|
1169
|
+
version: entryPointVersion
|
|
1170
|
+
}
|
|
1171
|
+
safe4337ModuleAddress?: Address
|
|
1172
|
+
erc7579LaunchpadAddress?: TErc7579
|
|
1173
|
+
safeProxyFactoryAddress?: Address
|
|
1174
|
+
safeSingletonAddress?: Address
|
|
1175
|
+
safeWebAuthnSharedSignerAddress?: Address
|
|
1176
|
+
safeP256VerifierAddress?: Address
|
|
1177
|
+
address?: Address
|
|
1178
|
+
saltNonce?: bigint
|
|
1179
|
+
validUntil?: number
|
|
1180
|
+
validAfter?: number
|
|
1181
|
+
nonceKey?: bigint
|
|
1182
|
+
paymentToken?: Address
|
|
1183
|
+
payment?: bigint
|
|
1184
|
+
paymentReceiver?: Address
|
|
1185
|
+
onchainIdentifier?: Hex
|
|
1186
|
+
} & GetErc7579Params<TErc7579>
|
|
1187
|
+
|
|
1188
|
+
function isErc7579Args<entryPointVersion extends "0.6" | "0.7" = "0.7">(
|
|
1189
|
+
args: ToSafeSmartAccountParameters<entryPointVersion, Address | undefined>
|
|
1190
|
+
): args is ToSafeSmartAccountParameters<entryPointVersion, Address> {
|
|
1191
|
+
return args.erc7579LaunchpadAddress !== undefined
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
const proxyCreationCodeAbi = [
|
|
1195
|
+
{
|
|
1196
|
+
inputs: [],
|
|
1197
|
+
name: "proxyCreationCode",
|
|
1198
|
+
outputs: [
|
|
1199
|
+
{
|
|
1200
|
+
internalType: "bytes",
|
|
1201
|
+
name: "",
|
|
1202
|
+
type: "bytes"
|
|
1203
|
+
}
|
|
1204
|
+
],
|
|
1205
|
+
stateMutability: "pure",
|
|
1206
|
+
type: "function"
|
|
1207
|
+
}
|
|
1208
|
+
] as const
|
|
1209
|
+
|
|
1210
|
+
const getAccountAddress = async ({
|
|
1211
|
+
client,
|
|
1212
|
+
owners,
|
|
1213
|
+
threshold,
|
|
1214
|
+
safeModuleSetupAddress,
|
|
1215
|
+
safe4337ModuleAddress,
|
|
1216
|
+
safeProxyFactoryAddress,
|
|
1217
|
+
safeSingletonAddress,
|
|
1218
|
+
multiSendAddress,
|
|
1219
|
+
safeWebAuthnSharedSignerAddress,
|
|
1220
|
+
safeP256VerifierAddress,
|
|
1221
|
+
erc7579LaunchpadAddress,
|
|
1222
|
+
paymentToken,
|
|
1223
|
+
payment,
|
|
1224
|
+
paymentReceiver,
|
|
1225
|
+
setupTransactions = [],
|
|
1226
|
+
safeModules = [],
|
|
1227
|
+
saltNonce = BigInt(0),
|
|
1228
|
+
validators = [],
|
|
1229
|
+
executors = [],
|
|
1230
|
+
fallbacks = [],
|
|
1231
|
+
hooks = [],
|
|
1232
|
+
attesters = [],
|
|
1233
|
+
attestersThreshold = 0
|
|
1234
|
+
}: {
|
|
1235
|
+
client: Client
|
|
1236
|
+
owners: OwnersArray<readonly (RegularOwner | WebAuthnAccount)[]>
|
|
1237
|
+
threshold: bigint
|
|
1238
|
+
safeModuleSetupAddress: Address
|
|
1239
|
+
safe4337ModuleAddress: Address
|
|
1240
|
+
safeProxyFactoryAddress: Address
|
|
1241
|
+
safeSingletonAddress: Address
|
|
1242
|
+
safeWebAuthnSharedSignerAddress?: Address
|
|
1243
|
+
safeP256VerifierAddress?: Address
|
|
1244
|
+
multiSendAddress: Address
|
|
1245
|
+
setupTransactions: {
|
|
1246
|
+
to: Address
|
|
1247
|
+
data: Address
|
|
1248
|
+
value: bigint
|
|
1249
|
+
}[]
|
|
1250
|
+
paymentToken?: Address
|
|
1251
|
+
payment?: bigint
|
|
1252
|
+
paymentReceiver?: Address
|
|
1253
|
+
safeModules?: Address[]
|
|
1254
|
+
saltNonce?: bigint
|
|
1255
|
+
erc7579LaunchpadAddress?: Address
|
|
1256
|
+
validators?: { address: Address; context: Address }[]
|
|
1257
|
+
executors?: {
|
|
1258
|
+
address: Address
|
|
1259
|
+
context: Address
|
|
1260
|
+
}[]
|
|
1261
|
+
fallbacks?: { address: Address; context: Address }[]
|
|
1262
|
+
hooks?: { address: Address; context: Address }[]
|
|
1263
|
+
attesters?: Address[]
|
|
1264
|
+
attestersThreshold?: number
|
|
1265
|
+
}): Promise<Address> => {
|
|
1266
|
+
const proxyCreationCode = await readContract(client, {
|
|
1267
|
+
abi: proxyCreationCodeAbi,
|
|
1268
|
+
address: safeProxyFactoryAddress,
|
|
1269
|
+
functionName: "proxyCreationCode"
|
|
1270
|
+
})
|
|
1271
|
+
|
|
1272
|
+
const initializer = await getInitializerCode({
|
|
1273
|
+
owners,
|
|
1274
|
+
threshold,
|
|
1275
|
+
safeModuleSetupAddress,
|
|
1276
|
+
safe4337ModuleAddress,
|
|
1277
|
+
safeWebAuthnSharedSignerAddress,
|
|
1278
|
+
safeP256VerifierAddress,
|
|
1279
|
+
multiSendAddress,
|
|
1280
|
+
setupTransactions,
|
|
1281
|
+
safeSingletonAddress,
|
|
1282
|
+
safeModules,
|
|
1283
|
+
erc7579LaunchpadAddress,
|
|
1284
|
+
validators,
|
|
1285
|
+
executors,
|
|
1286
|
+
fallbacks,
|
|
1287
|
+
hooks,
|
|
1288
|
+
attesters,
|
|
1289
|
+
attestersThreshold,
|
|
1290
|
+
paymentToken,
|
|
1291
|
+
payment,
|
|
1292
|
+
paymentReceiver
|
|
1293
|
+
})
|
|
1294
|
+
|
|
1295
|
+
const deploymentCode = encodePacked(
|
|
1296
|
+
["bytes", "uint256"],
|
|
1297
|
+
[
|
|
1298
|
+
proxyCreationCode,
|
|
1299
|
+
hexToBigInt(erc7579LaunchpadAddress ?? safeSingletonAddress)
|
|
1300
|
+
]
|
|
1301
|
+
)
|
|
1302
|
+
|
|
1303
|
+
const salt = keccak256(
|
|
1304
|
+
encodePacked(
|
|
1305
|
+
["bytes32", "uint256"],
|
|
1306
|
+
[keccak256(encodePacked(["bytes"], [initializer])), saltNonce]
|
|
1307
|
+
)
|
|
1308
|
+
)
|
|
1309
|
+
|
|
1310
|
+
return getContractAddress({
|
|
1311
|
+
from: safeProxyFactoryAddress,
|
|
1312
|
+
salt,
|
|
1313
|
+
bytecode: deploymentCode,
|
|
1314
|
+
opcode: "CREATE2"
|
|
1315
|
+
})
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
export type SafeSmartAccountImplementation<
|
|
1319
|
+
entryPointVersion extends "0.6" | "0.7" = "0.7"
|
|
1320
|
+
> = Assign<
|
|
1321
|
+
SmartAccountImplementation<
|
|
1322
|
+
entryPointVersion extends "0.6"
|
|
1323
|
+
? typeof entryPoint06Abi
|
|
1324
|
+
: typeof entryPoint07Abi,
|
|
1325
|
+
entryPointVersion
|
|
1326
|
+
// {
|
|
1327
|
+
// // entryPoint === ENTRYPOINT_ADDRESS_V06 ? "0.2.2" : "0.3.0-beta"
|
|
1328
|
+
// abi: entryPointVersion extends "0.6" ? typeof BiconomyAbi
|
|
1329
|
+
// factory: { abi: typeof FactoryAbi; address: Address }
|
|
1330
|
+
// }
|
|
1331
|
+
>,
|
|
1332
|
+
{ sign: NonNullable<SmartAccountImplementation["sign"]> }
|
|
1333
|
+
>
|
|
1334
|
+
|
|
1335
|
+
export type ToSafeSmartAccountReturnType<
|
|
1336
|
+
entryPointVersion extends "0.6" | "0.7" = "0.7"
|
|
1337
|
+
> = SmartAccount<SafeSmartAccountImplementation<entryPointVersion>>
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* @description Creates an Simple Account from a private key.
|
|
1341
|
+
*
|
|
1342
|
+
* @returns A Private Key Simple Account.
|
|
1343
|
+
*/
|
|
1344
|
+
export async function toSafeSmartAccount<
|
|
1345
|
+
entryPointVersion extends "0.6" | "0.7",
|
|
1346
|
+
TErc7579 extends Address | undefined
|
|
1347
|
+
>(
|
|
1348
|
+
parameters: ToSafeSmartAccountParameters<entryPointVersion, TErc7579>
|
|
1349
|
+
): Promise<ToSafeSmartAccountReturnType<entryPointVersion>> {
|
|
1350
|
+
const {
|
|
1351
|
+
client,
|
|
1352
|
+
owners: _owners,
|
|
1353
|
+
address,
|
|
1354
|
+
threshold = BigInt(_owners.length),
|
|
1355
|
+
version,
|
|
1356
|
+
safe4337ModuleAddress: _safe4337ModuleAddress,
|
|
1357
|
+
safeProxyFactoryAddress: _safeProxyFactoryAddress,
|
|
1358
|
+
safeSingletonAddress: _safeSingletonAddress,
|
|
1359
|
+
erc7579LaunchpadAddress,
|
|
1360
|
+
saltNonce = BigInt(0),
|
|
1361
|
+
validUntil = 0,
|
|
1362
|
+
validAfter = 0,
|
|
1363
|
+
nonceKey,
|
|
1364
|
+
paymentToken,
|
|
1365
|
+
payment,
|
|
1366
|
+
paymentReceiver,
|
|
1367
|
+
onchainIdentifier
|
|
1368
|
+
} = parameters
|
|
1369
|
+
|
|
1370
|
+
const owners = await Promise.all(
|
|
1371
|
+
_owners.map(async (owner) => {
|
|
1372
|
+
if ("account" in owner) {
|
|
1373
|
+
return owner.account
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
if ("request" in owner) {
|
|
1377
|
+
return toOwner({
|
|
1378
|
+
owner: owner as EthereumProvider
|
|
1379
|
+
})
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
return owner
|
|
1383
|
+
})
|
|
1384
|
+
)
|
|
1385
|
+
|
|
1386
|
+
const localOwners = await Promise.all(
|
|
1387
|
+
_owners
|
|
1388
|
+
.filter((owner) => {
|
|
1389
|
+
if ("type" in owner && owner.type === "local") {
|
|
1390
|
+
return true
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
if ("request" in owner) {
|
|
1394
|
+
return true
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
if ("account" in owner) {
|
|
1398
|
+
// walletClient
|
|
1399
|
+
return true
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
if (isWebAuthnAccount(owner)) {
|
|
1403
|
+
return true
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
return false
|
|
1407
|
+
})
|
|
1408
|
+
.map((owner) => {
|
|
1409
|
+
if (isWebAuthnAccount(owner)) {
|
|
1410
|
+
return owner
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
return toOwner({
|
|
1414
|
+
owner: owner as OneOf<
|
|
1415
|
+
| LocalAccount
|
|
1416
|
+
| EthereumProvider
|
|
1417
|
+
| WalletClient<Transport, Chain | undefined, Account>
|
|
1418
|
+
>
|
|
1419
|
+
})
|
|
1420
|
+
})
|
|
1421
|
+
)
|
|
1422
|
+
|
|
1423
|
+
const entryPoint = {
|
|
1424
|
+
address: parameters.entryPoint?.address ?? entryPoint07Address,
|
|
1425
|
+
abi:
|
|
1426
|
+
(parameters.entryPoint?.version ?? "0.7") === "0.6"
|
|
1427
|
+
? entryPoint06Abi
|
|
1428
|
+
: entryPoint07Abi,
|
|
1429
|
+
version: parameters.entryPoint?.version ?? "0.7"
|
|
1430
|
+
} as const
|
|
1431
|
+
|
|
1432
|
+
let _safeModuleSetupAddress: Address | undefined = undefined
|
|
1433
|
+
let _multiSendAddress: Address | undefined = undefined
|
|
1434
|
+
let _multiSendCallOnlyAddress: Address | undefined = undefined
|
|
1435
|
+
let safeModules: Address[] | undefined = undefined
|
|
1436
|
+
let setupTransactions: {
|
|
1437
|
+
to: Address
|
|
1438
|
+
data: Hex
|
|
1439
|
+
value: bigint
|
|
1440
|
+
}[] = []
|
|
1441
|
+
let validators: { address: Address; context: Address }[] = []
|
|
1442
|
+
let executors: { address: Address; context: Address }[] = []
|
|
1443
|
+
let fallbacks: { address: Address; context: Address }[] = []
|
|
1444
|
+
let hooks: { address: Address; context: Address }[] = []
|
|
1445
|
+
let attesters: Address[] = []
|
|
1446
|
+
let attestersThreshold = 0
|
|
1447
|
+
|
|
1448
|
+
if (!isErc7579Args(parameters)) {
|
|
1449
|
+
_safeModuleSetupAddress = parameters.safeModuleSetupAddress
|
|
1450
|
+
_multiSendAddress = parameters.multiSendAddress
|
|
1451
|
+
_multiSendCallOnlyAddress = parameters.multiSendCallOnlyAddress
|
|
1452
|
+
safeModules = parameters.safeModules
|
|
1453
|
+
setupTransactions = parameters.setupTransactions ?? []
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
if (isErc7579Args(parameters)) {
|
|
1457
|
+
validators = parameters.validators ?? []
|
|
1458
|
+
executors = parameters.executors ?? []
|
|
1459
|
+
fallbacks = parameters.fallbacks ?? []
|
|
1460
|
+
hooks = parameters.hooks ?? []
|
|
1461
|
+
attesters = parameters.attesters ?? []
|
|
1462
|
+
attestersThreshold = parameters.attestersThreshold ?? 0
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
const {
|
|
1466
|
+
safeModuleSetupAddress,
|
|
1467
|
+
safe4337ModuleAddress,
|
|
1468
|
+
safeProxyFactoryAddress,
|
|
1469
|
+
safeSingletonAddress,
|
|
1470
|
+
multiSendAddress,
|
|
1471
|
+
multiSendCallOnlyAddress,
|
|
1472
|
+
safeWebAuthnSharedSignerAddress,
|
|
1473
|
+
safeP256VerifierAddress
|
|
1474
|
+
} = getDefaultAddresses(version, entryPoint.version, {
|
|
1475
|
+
safeModuleSetupAddress: _safeModuleSetupAddress,
|
|
1476
|
+
safe4337ModuleAddress: _safe4337ModuleAddress,
|
|
1477
|
+
safeProxyFactoryAddress: _safeProxyFactoryAddress,
|
|
1478
|
+
safeSingletonAddress: _safeSingletonAddress,
|
|
1479
|
+
multiSendAddress: _multiSendAddress,
|
|
1480
|
+
multiSendCallOnlyAddress: _multiSendCallOnlyAddress,
|
|
1481
|
+
safeWebAuthnSharedSignerAddress:
|
|
1482
|
+
parameters.safeWebAuthnSharedSignerAddress,
|
|
1483
|
+
safeP256VerifierAddress: parameters.safeP256VerifierAddress
|
|
1484
|
+
})
|
|
1485
|
+
|
|
1486
|
+
let accountAddress: Address | undefined = address
|
|
1487
|
+
|
|
1488
|
+
let chainId: number
|
|
1489
|
+
|
|
1490
|
+
const getMemoizedChainId = async () => {
|
|
1491
|
+
if (chainId) return chainId
|
|
1492
|
+
chainId = client.chain
|
|
1493
|
+
? client.chain.id
|
|
1494
|
+
: await getAction(client, getChainId, "getChainId")({})
|
|
1495
|
+
return chainId
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
const getFactoryArgs = async () => {
|
|
1499
|
+
return {
|
|
1500
|
+
factory: safeProxyFactoryAddress,
|
|
1501
|
+
factoryData: await getAccountInitCode({
|
|
1502
|
+
owners,
|
|
1503
|
+
threshold,
|
|
1504
|
+
safeModuleSetupAddress,
|
|
1505
|
+
safe4337ModuleAddress,
|
|
1506
|
+
safeSingletonAddress,
|
|
1507
|
+
safeWebAuthnSharedSignerAddress,
|
|
1508
|
+
safeP256VerifierAddress,
|
|
1509
|
+
multiSendAddress,
|
|
1510
|
+
erc7579LaunchpadAddress,
|
|
1511
|
+
saltNonce,
|
|
1512
|
+
setupTransactions,
|
|
1513
|
+
safeModules,
|
|
1514
|
+
validators,
|
|
1515
|
+
executors,
|
|
1516
|
+
fallbacks,
|
|
1517
|
+
hooks,
|
|
1518
|
+
attesters,
|
|
1519
|
+
attestersThreshold,
|
|
1520
|
+
paymentToken,
|
|
1521
|
+
payment,
|
|
1522
|
+
paymentReceiver
|
|
1523
|
+
})
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
return toSmartAccount({
|
|
1528
|
+
client,
|
|
1529
|
+
entryPoint,
|
|
1530
|
+
getFactoryArgs,
|
|
1531
|
+
async getAddress() {
|
|
1532
|
+
if (accountAddress) return accountAddress
|
|
1533
|
+
|
|
1534
|
+
// Get the sender address based on the init code
|
|
1535
|
+
accountAddress = await getAccountAddress({
|
|
1536
|
+
client,
|
|
1537
|
+
owners,
|
|
1538
|
+
threshold,
|
|
1539
|
+
safeModuleSetupAddress,
|
|
1540
|
+
safe4337ModuleAddress,
|
|
1541
|
+
safeProxyFactoryAddress,
|
|
1542
|
+
safeSingletonAddress,
|
|
1543
|
+
safeWebAuthnSharedSignerAddress,
|
|
1544
|
+
safeP256VerifierAddress,
|
|
1545
|
+
multiSendAddress,
|
|
1546
|
+
erc7579LaunchpadAddress,
|
|
1547
|
+
saltNonce,
|
|
1548
|
+
setupTransactions,
|
|
1549
|
+
safeModules,
|
|
1550
|
+
validators,
|
|
1551
|
+
executors,
|
|
1552
|
+
fallbacks,
|
|
1553
|
+
hooks,
|
|
1554
|
+
attesters,
|
|
1555
|
+
attestersThreshold,
|
|
1556
|
+
paymentToken,
|
|
1557
|
+
payment,
|
|
1558
|
+
paymentReceiver
|
|
1559
|
+
})
|
|
1560
|
+
|
|
1561
|
+
return accountAddress
|
|
1562
|
+
},
|
|
1563
|
+
async encodeCalls(calls) {
|
|
1564
|
+
const hasMultipleCalls = calls.length > 1
|
|
1565
|
+
|
|
1566
|
+
if (erc7579LaunchpadAddress) {
|
|
1567
|
+
const safeDeployed = await isSmartAccountDeployed(
|
|
1568
|
+
client,
|
|
1569
|
+
await this.getAddress()
|
|
1570
|
+
)
|
|
1571
|
+
|
|
1572
|
+
if (!safeDeployed) {
|
|
1573
|
+
const initData = get7579LaunchPadInitData({
|
|
1574
|
+
safe4337ModuleAddress,
|
|
1575
|
+
safeSingletonAddress,
|
|
1576
|
+
erc7579LaunchpadAddress,
|
|
1577
|
+
safeWebAuthnSharedSignerAddress,
|
|
1578
|
+
owners,
|
|
1579
|
+
threshold,
|
|
1580
|
+
validators,
|
|
1581
|
+
executors,
|
|
1582
|
+
fallbacks,
|
|
1583
|
+
hooks,
|
|
1584
|
+
attesters,
|
|
1585
|
+
attestersThreshold
|
|
1586
|
+
})
|
|
1587
|
+
|
|
1588
|
+
return encodeFunctionData({
|
|
1589
|
+
abi: setupSafeAbi,
|
|
1590
|
+
functionName: "setupSafe",
|
|
1591
|
+
args: [
|
|
1592
|
+
{
|
|
1593
|
+
...initData,
|
|
1594
|
+
validators: initData.validators.map(
|
|
1595
|
+
(validator) => ({
|
|
1596
|
+
module: validator.address,
|
|
1597
|
+
initData: validator.context
|
|
1598
|
+
})
|
|
1599
|
+
),
|
|
1600
|
+
callData: encode7579Calls({
|
|
1601
|
+
mode: {
|
|
1602
|
+
type: hasMultipleCalls
|
|
1603
|
+
? "batchcall"
|
|
1604
|
+
: "call",
|
|
1605
|
+
revertOnError: false,
|
|
1606
|
+
selector: "0x",
|
|
1607
|
+
context: "0x"
|
|
1608
|
+
},
|
|
1609
|
+
callData: calls
|
|
1610
|
+
})
|
|
1611
|
+
}
|
|
1612
|
+
]
|
|
1613
|
+
})
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
return encode7579Calls({
|
|
1617
|
+
mode: {
|
|
1618
|
+
type: hasMultipleCalls ? "batchcall" : "call",
|
|
1619
|
+
revertOnError: false,
|
|
1620
|
+
selector: "0x",
|
|
1621
|
+
context: "0x"
|
|
1622
|
+
},
|
|
1623
|
+
callData: calls
|
|
1624
|
+
})
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
let to: Address
|
|
1628
|
+
let value: bigint
|
|
1629
|
+
let data: Hex
|
|
1630
|
+
let operationType = 0
|
|
1631
|
+
|
|
1632
|
+
if (hasMultipleCalls) {
|
|
1633
|
+
to = multiSendCallOnlyAddress
|
|
1634
|
+
value = BigInt(0)
|
|
1635
|
+
|
|
1636
|
+
data = encodeMultiSend(
|
|
1637
|
+
calls.map((tx) => ({
|
|
1638
|
+
to: tx.to,
|
|
1639
|
+
value: tx.value ?? 0n,
|
|
1640
|
+
data: tx.data ?? "0x",
|
|
1641
|
+
operation: 0
|
|
1642
|
+
}))
|
|
1643
|
+
)
|
|
1644
|
+
operationType = 1
|
|
1645
|
+
} else {
|
|
1646
|
+
const call = calls.length === 0 ? undefined : calls[0]
|
|
1647
|
+
|
|
1648
|
+
if (!call) {
|
|
1649
|
+
throw new Error("No calls to encode")
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
to = call.to
|
|
1653
|
+
data = call.data ?? "0x"
|
|
1654
|
+
value = call.value ?? 0n
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
const calldata = encodeFunctionData({
|
|
1658
|
+
abi: executeUserOpWithErrorStringAbi,
|
|
1659
|
+
functionName: "executeUserOpWithErrorString",
|
|
1660
|
+
args: [to, value, data, operationType]
|
|
1661
|
+
})
|
|
1662
|
+
|
|
1663
|
+
if (onchainIdentifier) {
|
|
1664
|
+
return concat([calldata, onchainIdentifier])
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
return calldata
|
|
1668
|
+
},
|
|
1669
|
+
async decodeCalls(callData) {
|
|
1670
|
+
try {
|
|
1671
|
+
const decoded = decodeFunctionData({
|
|
1672
|
+
abi: setupSafeAbi,
|
|
1673
|
+
data: callData
|
|
1674
|
+
})
|
|
1675
|
+
|
|
1676
|
+
return decode7579Calls(decoded.args[0].callData).callData
|
|
1677
|
+
} catch {}
|
|
1678
|
+
|
|
1679
|
+
try {
|
|
1680
|
+
return decode7579Calls(callData).callData
|
|
1681
|
+
} catch {}
|
|
1682
|
+
|
|
1683
|
+
const decoded = decodeFunctionData({
|
|
1684
|
+
abi: executeUserOpWithErrorStringAbi,
|
|
1685
|
+
data: callData
|
|
1686
|
+
})
|
|
1687
|
+
|
|
1688
|
+
const to = decoded.args[0]
|
|
1689
|
+
const value = decoded.args[1]
|
|
1690
|
+
const data = decoded.args[2]
|
|
1691
|
+
|
|
1692
|
+
if (to === multiSendCallOnlyAddress) {
|
|
1693
|
+
const decodedMultiSend = decodeFunctionData({
|
|
1694
|
+
abi: multiSendAbi,
|
|
1695
|
+
data: data
|
|
1696
|
+
})
|
|
1697
|
+
|
|
1698
|
+
const dataToDecode = decodedMultiSend.args[0]
|
|
1699
|
+
const transactions: {
|
|
1700
|
+
to: Address
|
|
1701
|
+
value: bigint
|
|
1702
|
+
data: Hex
|
|
1703
|
+
}[] = []
|
|
1704
|
+
|
|
1705
|
+
let position = 0
|
|
1706
|
+
const dataLength = size(dataToDecode)
|
|
1707
|
+
|
|
1708
|
+
while (position < dataLength) {
|
|
1709
|
+
// skip the operation type
|
|
1710
|
+
position += 1
|
|
1711
|
+
|
|
1712
|
+
const to = getAddress(
|
|
1713
|
+
slice(dataToDecode, position, position + 20)
|
|
1714
|
+
)
|
|
1715
|
+
position += 20
|
|
1716
|
+
|
|
1717
|
+
const value = BigInt(
|
|
1718
|
+
slice(dataToDecode, position, position + 32)
|
|
1719
|
+
)
|
|
1720
|
+
position += 32
|
|
1721
|
+
|
|
1722
|
+
const dataLength = Number(
|
|
1723
|
+
BigInt(slice(dataToDecode, position, position + 32)) *
|
|
1724
|
+
BigInt(2)
|
|
1725
|
+
)
|
|
1726
|
+
|
|
1727
|
+
position += 32
|
|
1728
|
+
|
|
1729
|
+
const data = slice(
|
|
1730
|
+
dataToDecode,
|
|
1731
|
+
position,
|
|
1732
|
+
position + dataLength
|
|
1733
|
+
)
|
|
1734
|
+
position += dataLength
|
|
1735
|
+
|
|
1736
|
+
transactions.push({ to, value, data })
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
return transactions
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
return [{ to, value, data }]
|
|
1743
|
+
},
|
|
1744
|
+
async getNonce(args) {
|
|
1745
|
+
return getAccountNonce(client, {
|
|
1746
|
+
address: await this.getAddress(),
|
|
1747
|
+
entryPointAddress: entryPoint.address,
|
|
1748
|
+
key: nonceKey ?? args?.key
|
|
1749
|
+
})
|
|
1750
|
+
},
|
|
1751
|
+
async getStubSignature() {
|
|
1752
|
+
const signatures = owners.map((owner) => {
|
|
1753
|
+
let signer = safeWebAuthnSharedSignerAddress
|
|
1754
|
+
let dynamic = true
|
|
1755
|
+
let data: Hex =
|
|
1756
|
+
"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
|
|
1757
|
+
|
|
1758
|
+
if (isWebAuthnAccount(owner)) {
|
|
1759
|
+
data = encodeAbiParameters(
|
|
1760
|
+
[
|
|
1761
|
+
{ name: "authenticatorData", type: "bytes" },
|
|
1762
|
+
{ name: "clientDataJSON", type: "string" },
|
|
1763
|
+
{ name: "signature", type: "uint256[2]" }
|
|
1764
|
+
],
|
|
1765
|
+
[
|
|
1766
|
+
"0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d00000000",
|
|
1767
|
+
'"origin":"http://somelargdomainheresothatwehaveenoughbytes.com","crossOrigin":false',
|
|
1768
|
+
[
|
|
1769
|
+
44941127272049826721201904734628716258498742255959991581049806490182030242267n,
|
|
1770
|
+
9910254599581058084911561569808925251374718953855182016200087235935345969636n
|
|
1771
|
+
]
|
|
1772
|
+
]
|
|
1773
|
+
)
|
|
1774
|
+
} else {
|
|
1775
|
+
signer = owner.address
|
|
1776
|
+
dynamic = false
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
if (!signer) {
|
|
1780
|
+
throw new Error("No signer found")
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
return {
|
|
1784
|
+
signer,
|
|
1785
|
+
data,
|
|
1786
|
+
dynamic
|
|
1787
|
+
}
|
|
1788
|
+
})
|
|
1789
|
+
|
|
1790
|
+
return encodePacked(
|
|
1791
|
+
["uint48", "uint48", "bytes"],
|
|
1792
|
+
[0, 0, concatSignatures(signatures)]
|
|
1793
|
+
)
|
|
1794
|
+
},
|
|
1795
|
+
async sign({ hash }) {
|
|
1796
|
+
return this.signMessage({ message: hash })
|
|
1797
|
+
},
|
|
1798
|
+
async signMessage({ message }) {
|
|
1799
|
+
if (localOwners.length < Number(threshold)) {
|
|
1800
|
+
throw new Error(
|
|
1801
|
+
"Owners length mismatch, currently not supported"
|
|
1802
|
+
)
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
if (erc7579LaunchpadAddress && version === "1.5.0") {
|
|
1806
|
+
throw new Error("Safe 7579 & version 1.5.0 are not compatible")
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
const messageHash = hashTypedData({
|
|
1810
|
+
domain: {
|
|
1811
|
+
chainId: await getMemoizedChainId(),
|
|
1812
|
+
verifyingContract: await this.getAddress()
|
|
1813
|
+
},
|
|
1814
|
+
types: {
|
|
1815
|
+
SafeMessage: [{ name: "message", type: "bytes" }]
|
|
1816
|
+
},
|
|
1817
|
+
primaryType: "SafeMessage",
|
|
1818
|
+
message: {
|
|
1819
|
+
message: generateSafeMessageMessage(message)
|
|
1820
|
+
}
|
|
1821
|
+
})
|
|
1822
|
+
|
|
1823
|
+
const signatures = await Promise.all(
|
|
1824
|
+
localOwners.map(async (localOwner) => {
|
|
1825
|
+
let signer = safeWebAuthnSharedSignerAddress
|
|
1826
|
+
let data: Hex
|
|
1827
|
+
let dynamic = true
|
|
1828
|
+
|
|
1829
|
+
if (isWebAuthnAccount(localOwner)) {
|
|
1830
|
+
data = await getWebAuthnSignature({
|
|
1831
|
+
owner: localOwner,
|
|
1832
|
+
hash: messageHash
|
|
1833
|
+
})
|
|
1834
|
+
} else {
|
|
1835
|
+
signer = localOwner.address
|
|
1836
|
+
data = adjustVInSignature(
|
|
1837
|
+
"eth_sign",
|
|
1838
|
+
await localOwner.signMessage({
|
|
1839
|
+
message: {
|
|
1840
|
+
raw: toBytes(messageHash)
|
|
1841
|
+
}
|
|
1842
|
+
})
|
|
1843
|
+
)
|
|
1844
|
+
dynamic = false
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
if (!signer) {
|
|
1848
|
+
throw new Error("no signer found")
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
return {
|
|
1852
|
+
signer,
|
|
1853
|
+
dynamic,
|
|
1854
|
+
data
|
|
1855
|
+
}
|
|
1856
|
+
})
|
|
1857
|
+
)
|
|
1858
|
+
|
|
1859
|
+
const signatureBytes = concatSignatures(signatures)
|
|
1860
|
+
|
|
1861
|
+
return erc7579LaunchpadAddress
|
|
1862
|
+
? concat([zeroAddress, signatureBytes])
|
|
1863
|
+
: signatureBytes
|
|
1864
|
+
},
|
|
1865
|
+
async signTypedData(typedData) {
|
|
1866
|
+
if (localOwners.length < Number(threshold)) {
|
|
1867
|
+
throw new Error(
|
|
1868
|
+
"Owners length mismatch, currently not supported"
|
|
1869
|
+
)
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
if (erc7579LaunchpadAddress && version === "1.5.0") {
|
|
1873
|
+
throw new Error("Safe 7579 & version 1.5.0 are not compatible")
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
const signatures = await Promise.all(
|
|
1877
|
+
localOwners.map(async (localOwner) => {
|
|
1878
|
+
let signer = safeWebAuthnSharedSignerAddress
|
|
1879
|
+
let data: Hex
|
|
1880
|
+
let dynamic = true
|
|
1881
|
+
|
|
1882
|
+
if (isWebAuthnAccount(localOwner)) {
|
|
1883
|
+
const messageHash = hashTypedData({
|
|
1884
|
+
domain: {
|
|
1885
|
+
chainId: await getMemoizedChainId(),
|
|
1886
|
+
verifyingContract: await this.getAddress()
|
|
1887
|
+
},
|
|
1888
|
+
types: {
|
|
1889
|
+
SafeMessage: [
|
|
1890
|
+
{ name: "message", type: "bytes" }
|
|
1891
|
+
]
|
|
1892
|
+
},
|
|
1893
|
+
primaryType: "SafeMessage",
|
|
1894
|
+
message: {
|
|
1895
|
+
message: generateSafeMessageMessage(typedData)
|
|
1896
|
+
}
|
|
1897
|
+
})
|
|
1898
|
+
|
|
1899
|
+
data = await getWebAuthnSignature({
|
|
1900
|
+
owner: localOwner,
|
|
1901
|
+
hash: messageHash
|
|
1902
|
+
})
|
|
1903
|
+
} else {
|
|
1904
|
+
signer = localOwner.address
|
|
1905
|
+
data = adjustVInSignature(
|
|
1906
|
+
"eth_signTypedData",
|
|
1907
|
+
await localOwner.signTypedData({
|
|
1908
|
+
domain: {
|
|
1909
|
+
chainId: await getMemoizedChainId(),
|
|
1910
|
+
verifyingContract: await this.getAddress()
|
|
1911
|
+
},
|
|
1912
|
+
types: {
|
|
1913
|
+
SafeMessage: [
|
|
1914
|
+
{ name: "message", type: "bytes" }
|
|
1915
|
+
]
|
|
1916
|
+
},
|
|
1917
|
+
primaryType: "SafeMessage",
|
|
1918
|
+
message: {
|
|
1919
|
+
message:
|
|
1920
|
+
generateSafeMessageMessage(typedData)
|
|
1921
|
+
}
|
|
1922
|
+
})
|
|
1923
|
+
)
|
|
1924
|
+
dynamic = false
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
if (!signer) {
|
|
1928
|
+
throw new Error("no signer found")
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
return {
|
|
1932
|
+
signer,
|
|
1933
|
+
dynamic,
|
|
1934
|
+
data
|
|
1935
|
+
}
|
|
1936
|
+
})
|
|
1937
|
+
)
|
|
1938
|
+
|
|
1939
|
+
const signatureBytes = concatSignatures(signatures)
|
|
1940
|
+
|
|
1941
|
+
return erc7579LaunchpadAddress
|
|
1942
|
+
? concat([zeroAddress, signatureBytes])
|
|
1943
|
+
: signatureBytes
|
|
1944
|
+
},
|
|
1945
|
+
async signUserOperation(parameters) {
|
|
1946
|
+
const { chainId = await getMemoizedChainId(), ...userOperation } =
|
|
1947
|
+
parameters
|
|
1948
|
+
|
|
1949
|
+
if (localOwners.length < Number(threshold)) {
|
|
1950
|
+
throw new Error(
|
|
1951
|
+
"Owners length mismatch use SafeSmartAccount.signUserOperation from `permissionless/accounts/safe`"
|
|
1952
|
+
)
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
let signatures: Hex | undefined = undefined
|
|
1956
|
+
|
|
1957
|
+
for (const owner of localOwners) {
|
|
1958
|
+
signatures = await signUserOperation({
|
|
1959
|
+
...userOperation,
|
|
1960
|
+
version,
|
|
1961
|
+
entryPoint,
|
|
1962
|
+
owners: localOwners,
|
|
1963
|
+
account: owner,
|
|
1964
|
+
chainId,
|
|
1965
|
+
signatures,
|
|
1966
|
+
validAfter,
|
|
1967
|
+
validUntil,
|
|
1968
|
+
safe4337ModuleAddress,
|
|
1969
|
+
safeWebAuthnSharedSignerAddress
|
|
1970
|
+
})
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
if (!signatures) {
|
|
1974
|
+
throw new Error("No signatures found")
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
return signatures
|
|
1978
|
+
}
|
|
1979
|
+
}) as Promise<ToSafeSmartAccountReturnType<entryPointVersion>>
|
|
1980
|
+
}
|