@alchemy/smart-accounts 0.0.0-alpha.0
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/LICENSE +21 -0
- package/dist/esm/errors/EntityIdOverrideError.d.ts +11 -0
- package/dist/esm/errors/EntityIdOverrideError.js +19 -0
- package/dist/esm/errors/EntityIdOverrideError.js.map +1 -0
- package/dist/esm/errors/InvalidDeferredActionNonceError.d.ts +11 -0
- package/dist/esm/errors/InvalidDeferredActionNonceError.js +19 -0
- package/dist/esm/errors/InvalidDeferredActionNonceError.js.map +1 -0
- package/dist/esm/errors/InvalidEntityIdError.d.ts +13 -0
- package/dist/esm/errors/InvalidEntityIdError.js +21 -0
- package/dist/esm/errors/InvalidEntityIdError.js.map +1 -0
- package/dist/esm/errors/InvalidNonceKeyError.d.ts +13 -0
- package/dist/esm/errors/InvalidNonceKeyError.js +21 -0
- package/dist/esm/errors/InvalidNonceKeyError.js.map +1 -0
- package/dist/esm/errors/InvalidOwnerError.d.ts +13 -0
- package/dist/esm/errors/InvalidOwnerError.js +21 -0
- package/dist/esm/errors/InvalidOwnerError.js.map +1 -0
- package/dist/esm/errors/permissionBuilderErrors.d.ts +150 -0
- package/dist/esm/errors/permissionBuilderErrors.js +233 -0
- package/dist/esm/errors/permissionBuilderErrors.js.map +1 -0
- package/dist/esm/index.d.ts +59 -0
- package/dist/esm/index.js +40 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/light-account/abis/LightAccountAbi_v1.d.ts +532 -0
- package/dist/esm/light-account/abis/LightAccountAbi_v1.js +379 -0
- package/dist/esm/light-account/abis/LightAccountAbi_v1.js.map +1 -0
- package/dist/esm/light-account/abis/LightAccountAbi_v2.d.ts +491 -0
- package/dist/esm/light-account/abis/LightAccountAbi_v2.js +355 -0
- package/dist/esm/light-account/abis/LightAccountAbi_v2.js.map +1 -0
- package/dist/esm/light-account/abis/LightAccountFactoryAbi_v1.d.ts +55 -0
- package/dist/esm/light-account/abis/LightAccountFactoryAbi_v1.js +75 -0
- package/dist/esm/light-account/abis/LightAccountFactoryAbi_v1.js.map +1 -0
- package/dist/esm/light-account/abis/LightAccountFactoryAbi_v2.d.ts +256 -0
- package/dist/esm/light-account/abis/LightAccountFactoryAbi_v2.js +210 -0
- package/dist/esm/light-account/abis/LightAccountFactoryAbi_v2.js.map +1 -0
- package/dist/esm/light-account/abis/MultiOwnerLightAccountAbi.d.ts +507 -0
- package/dist/esm/light-account/abis/MultiOwnerLightAccountAbi.js +372 -0
- package/dist/esm/light-account/abis/MultiOwnerLightAccountAbi.js.map +1 -0
- package/dist/esm/light-account/abis/MultiOwnerLightAccountFactoryAbi.d.ts +286 -0
- package/dist/esm/light-account/abis/MultiOwnerLightAccountFactoryAbi.js +229 -0
- package/dist/esm/light-account/abis/MultiOwnerLightAccountFactoryAbi.js.map +1 -0
- package/dist/esm/light-account/abis/OZ_ERC1967Proxy.d.ts +13 -0
- package/dist/esm/light-account/abis/OZ_ERC1967Proxy.js +20 -0
- package/dist/esm/light-account/abis/OZ_ERC1967Proxy.js.map +1 -0
- package/dist/esm/light-account/accounts/account.d.ts +22 -0
- package/dist/esm/light-account/accounts/account.js +86 -0
- package/dist/esm/light-account/accounts/account.js.map +1 -0
- package/dist/esm/light-account/accounts/base.d.ts +28 -0
- package/dist/esm/light-account/accounts/base.js +170 -0
- package/dist/esm/light-account/accounts/base.js.map +1 -0
- package/dist/esm/light-account/accounts/calldataCodec.d.ts +3 -0
- package/dist/esm/light-account/accounts/calldataCodec.js +74 -0
- package/dist/esm/light-account/accounts/calldataCodec.js.map +1 -0
- package/dist/esm/light-account/accounts/multi-owner-account.d.ts +20 -0
- package/dist/esm/light-account/accounts/multi-owner-account.js +79 -0
- package/dist/esm/light-account/accounts/multi-owner-account.js.map +1 -0
- package/dist/esm/light-account/decorators/multiOwner.d.ts +17 -0
- package/dist/esm/light-account/decorators/multiOwner.js +38 -0
- package/dist/esm/light-account/decorators/multiOwner.js.map +1 -0
- package/dist/esm/light-account/decorators/singleOwner.d.ts +16 -0
- package/dist/esm/light-account/decorators/singleOwner.js +35 -0
- package/dist/esm/light-account/decorators/singleOwner.js.map +1 -0
- package/dist/esm/light-account/lightAccountStaticImpl.d.ts +24 -0
- package/dist/esm/light-account/lightAccountStaticImpl.js +112 -0
- package/dist/esm/light-account/lightAccountStaticImpl.js.map +1 -0
- package/dist/esm/light-account/predictAddress.d.ts +35 -0
- package/dist/esm/light-account/predictAddress.js +113 -0
- package/dist/esm/light-account/predictAddress.js.map +1 -0
- package/dist/esm/light-account/registry.d.ts +7115 -0
- package/dist/esm/light-account/registry.js +18 -0
- package/dist/esm/light-account/registry.js.map +1 -0
- package/dist/esm/light-account/utils.d.ts +1454 -0
- package/dist/esm/light-account/utils.js +65 -0
- package/dist/esm/light-account/utils.js.map +1 -0
- package/dist/esm/logger.d.ts +2 -0
- package/dist/esm/logger.js +8 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/ma-v1/abis/IStandardExecutor.d.ts +50 -0
- package/dist/esm/ma-v1/abis/IStandardExecutor.js +32 -0
- package/dist/esm/ma-v1/abis/IStandardExecutor.js.map +1 -0
- package/dist/esm/ma-v1/abis/MultiOwnerModularAccountFactory.d.ts +234 -0
- package/dist/esm/ma-v1/abis/MultiOwnerModularAccountFactory.js +191 -0
- package/dist/esm/ma-v1/abis/MultiOwnerModularAccountFactory.js.map +1 -0
- package/dist/esm/ma-v1/abis/MultiOwnerPlugin.d.ts +698 -0
- package/dist/esm/ma-v1/abis/MultiOwnerPlugin.js +529 -0
- package/dist/esm/ma-v1/abis/MultiOwnerPlugin.js.map +1 -0
- package/dist/esm/ma-v1/abis/MultiOwnerPluginExecutionFunction.d.ts +67 -0
- package/dist/esm/ma-v1/abis/MultiOwnerPluginExecutionFunction.js +38 -0
- package/dist/esm/ma-v1/abis/MultiOwnerPluginExecutionFunction.js.map +1 -0
- package/dist/esm/ma-v1/abis/UpgradeableModularAccount.d.ts +880 -0
- package/dist/esm/ma-v1/abis/UpgradeableModularAccount.js +646 -0
- package/dist/esm/ma-v1/abis/UpgradeableModularAccount.js.map +1 -0
- package/dist/esm/ma-v1/account.d.ts +16 -0
- package/dist/esm/ma-v1/account.js +17 -0
- package/dist/esm/ma-v1/account.js.map +1 -0
- package/dist/esm/ma-v1/accounts/base.d.ts +29 -0
- package/dist/esm/ma-v1/accounts/base.js +150 -0
- package/dist/esm/ma-v1/accounts/base.js.map +1 -0
- package/dist/esm/ma-v1/accounts/multi-owner-account.d.ts +22 -0
- package/dist/esm/ma-v1/accounts/multi-owner-account.js +101 -0
- package/dist/esm/ma-v1/accounts/multi-owner-account.js.map +1 -0
- package/dist/esm/ma-v1/decorators/multiOwner.d.ts +17 -0
- package/dist/esm/ma-v1/decorators/multiOwner.js +38 -0
- package/dist/esm/ma-v1/decorators/multiOwner.js.map +1 -0
- package/dist/esm/ma-v1/mav1StaticImpl.d.ts +15 -0
- package/dist/esm/ma-v1/mav1StaticImpl.js +38 -0
- package/dist/esm/ma-v1/mav1StaticImpl.js.map +1 -0
- package/dist/esm/ma-v1/predictAddress.d.ts +28 -0
- package/dist/esm/ma-v1/predictAddress.js +51 -0
- package/dist/esm/ma-v1/predictAddress.js.map +1 -0
- package/dist/esm/ma-v2/abis/accountFactoryAbi.d.ts +348 -0
- package/dist/esm/ma-v2/abis/accountFactoryAbi.js +645 -0
- package/dist/esm/ma-v2/abis/accountFactoryAbi.js.map +1 -0
- package/dist/esm/ma-v2/abis/entityIdAndNonceReader.d.ts +9 -0
- package/dist/esm/ma-v2/abis/entityIdAndNonceReader.js +24 -0
- package/dist/esm/ma-v2/abis/entityIdAndNonceReader.js.map +1 -0
- package/dist/esm/ma-v2/abis/modularAccountAbi.d.ts +954 -0
- package/dist/esm/ma-v2/abis/modularAccountAbi.js +1242 -0
- package/dist/esm/ma-v2/abis/modularAccountAbi.js.map +1 -0
- package/dist/esm/ma-v2/abis/semiModularAccountBytecodeAbi.d.ts +991 -0
- package/dist/esm/ma-v2/abis/semiModularAccountBytecodeAbi.js +1289 -0
- package/dist/esm/ma-v2/abis/semiModularAccountBytecodeAbi.js.map +1 -0
- package/dist/esm/ma-v2/abis/semiModularAccountStorageAbi.d.ts +1001 -0
- package/dist/esm/ma-v2/abis/semiModularAccountStorageAbi.js +1302 -0
- package/dist/esm/ma-v2/abis/semiModularAccountStorageAbi.js.map +1 -0
- package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.d.ts +330 -0
- package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.js +260 -0
- package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.js.map +1 -0
- package/dist/esm/ma-v2/accounts/account.d.ts +32 -0
- package/dist/esm/ma-v2/accounts/account.js +134 -0
- package/dist/esm/ma-v2/accounts/account.js.map +1 -0
- package/dist/esm/ma-v2/accounts/base.d.ts +40 -0
- package/dist/esm/ma-v2/accounts/base.js +371 -0
- package/dist/esm/ma-v2/accounts/base.js.map +1 -0
- package/dist/esm/ma-v2/decorators/deferralActions.d.ts +51 -0
- package/dist/esm/ma-v2/decorators/deferralActions.js +100 -0
- package/dist/esm/ma-v2/decorators/deferralActions.js.map +1 -0
- package/dist/esm/ma-v2/decorators/installValidation.d.ts +71 -0
- package/dist/esm/ma-v2/decorators/installValidation.js +137 -0
- package/dist/esm/ma-v2/decorators/installValidation.js.map +1 -0
- package/dist/esm/ma-v2/mav2StaticImpl.d.ts +37 -0
- package/dist/esm/ma-v2/mav2StaticImpl.js +88 -0
- package/dist/esm/ma-v2/mav2StaticImpl.js.map +1 -0
- package/dist/esm/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.d.ts +556 -0
- package/dist/esm/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.js +716 -0
- package/dist/esm/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.js.map +1 -0
- package/dist/esm/ma-v2/modules/allowlist-module/module.d.ts +593 -0
- package/dist/esm/ma-v2/modules/allowlist-module/module.js +70 -0
- package/dist/esm/ma-v2/modules/allowlist-module/module.js.map +1 -0
- package/dist/esm/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.d.ts +312 -0
- package/dist/esm/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js +404 -0
- package/dist/esm/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js.map +1 -0
- package/dist/esm/ma-v2/modules/native-token-limit-module/module.d.ts +322 -0
- package/dist/esm/ma-v2/modules/native-token-limit-module/module.js +14 -0
- package/dist/esm/ma-v2/modules/native-token-limit-module/module.js.map +1 -0
- package/dist/esm/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.d.ts +186 -0
- package/dist/esm/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js +242 -0
- package/dist/esm/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js.map +1 -0
- package/dist/esm/ma-v2/modules/paymaster-guard-module/module.d.ts +196 -0
- package/dist/esm/ma-v2/modules/paymaster-guard-module/module.js +25 -0
- package/dist/esm/ma-v2/modules/paymaster-guard-module/module.js.map +1 -0
- package/dist/esm/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.d.ts +45 -0
- package/dist/esm/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js +331 -0
- package/dist/esm/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js.map +1 -0
- package/dist/esm/ma-v2/modules/single-signer-validation/module.d.ts +10 -0
- package/dist/esm/ma-v2/modules/single-signer-validation/module.js +16 -0
- package/dist/esm/ma-v2/modules/single-signer-validation/module.js.map +1 -0
- package/dist/esm/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.d.ts +229 -0
- package/dist/esm/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.js +296 -0
- package/dist/esm/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.js.map +1 -0
- package/dist/esm/ma-v2/modules/time-range-module/module.d.ts +254 -0
- package/dist/esm/ma-v2/modules/time-range-module/module.js +62 -0
- package/dist/esm/ma-v2/modules/time-range-module/module.js.map +1 -0
- package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +287 -0
- package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js +374 -0
- package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js.map +1 -0
- package/dist/esm/ma-v2/modules/webauthn-validation/module.d.ts +11 -0
- package/dist/esm/ma-v2/modules/webauthn-validation/module.js +16 -0
- package/dist/esm/ma-v2/modules/webauthn-validation/module.js.map +1 -0
- package/dist/esm/ma-v2/permissionBuilder.d.ts +158 -0
- package/dist/esm/ma-v2/permissionBuilder.js +557 -0
- package/dist/esm/ma-v2/permissionBuilder.js.map +1 -0
- package/dist/esm/ma-v2/predictAddress.d.ts +37 -0
- package/dist/esm/ma-v2/predictAddress.js +73 -0
- package/dist/esm/ma-v2/predictAddress.js.map +1 -0
- package/dist/esm/ma-v2/types.d.ts +57 -0
- package/dist/esm/ma-v2/types.js +9 -0
- package/dist/esm/ma-v2/types.js.map +1 -0
- package/dist/esm/ma-v2/utils/account.d.ts +85 -0
- package/dist/esm/ma-v2/utils/account.js +96 -0
- package/dist/esm/ma-v2/utils/account.js.map +1 -0
- package/dist/esm/ma-v2/utils/deferredActions.d.ts +29 -0
- package/dist/esm/ma-v2/utils/deferredActions.js +38 -0
- package/dist/esm/ma-v2/utils/deferredActions.js.map +1 -0
- package/dist/esm/ma-v2/utils/hooks.d.ts +55 -0
- package/dist/esm/ma-v2/utils/hooks.js +78 -0
- package/dist/esm/ma-v2/utils/hooks.js.map +1 -0
- package/dist/esm/ma-v2/utils/signature.d.ts +63 -0
- package/dist/esm/ma-v2/utils/signature.js +84 -0
- package/dist/esm/ma-v2/utils/signature.js.map +1 -0
- package/dist/esm/test-utils/getAccountAddressViaEntryPoint.d.ts +18 -0
- package/dist/esm/test-utils/getAccountAddressViaEntryPoint.js +31 -0
- package/dist/esm/test-utils/getAccountAddressViaEntryPoint.js.map +1 -0
- package/dist/esm/types.d.ts +30 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.d.ts +6 -0
- package/dist/esm/utils.js +52 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/version.d.ts +1 -0
- package/dist/esm/version.js +4 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/types/errors/EntityIdOverrideError.d.ts +12 -0
- package/dist/types/errors/EntityIdOverrideError.d.ts.map +1 -0
- package/dist/types/errors/InvalidDeferredActionNonceError.d.ts +12 -0
- package/dist/types/errors/InvalidDeferredActionNonceError.d.ts.map +1 -0
- package/dist/types/errors/InvalidEntityIdError.d.ts +14 -0
- package/dist/types/errors/InvalidEntityIdError.d.ts.map +1 -0
- package/dist/types/errors/InvalidNonceKeyError.d.ts +14 -0
- package/dist/types/errors/InvalidNonceKeyError.d.ts.map +1 -0
- package/dist/types/errors/InvalidOwnerError.d.ts +14 -0
- package/dist/types/errors/InvalidOwnerError.d.ts.map +1 -0
- package/dist/types/errors/permissionBuilderErrors.d.ts +151 -0
- package/dist/types/errors/permissionBuilderErrors.d.ts.map +1 -0
- package/dist/types/index.d.ts +60 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/light-account/abis/LightAccountAbi_v1.d.ts +533 -0
- package/dist/types/light-account/abis/LightAccountAbi_v1.d.ts.map +1 -0
- package/dist/types/light-account/abis/LightAccountAbi_v2.d.ts +492 -0
- package/dist/types/light-account/abis/LightAccountAbi_v2.d.ts.map +1 -0
- package/dist/types/light-account/abis/LightAccountFactoryAbi_v1.d.ts +56 -0
- package/dist/types/light-account/abis/LightAccountFactoryAbi_v1.d.ts.map +1 -0
- package/dist/types/light-account/abis/LightAccountFactoryAbi_v2.d.ts +257 -0
- package/dist/types/light-account/abis/LightAccountFactoryAbi_v2.d.ts.map +1 -0
- package/dist/types/light-account/abis/MultiOwnerLightAccountAbi.d.ts +508 -0
- package/dist/types/light-account/abis/MultiOwnerLightAccountAbi.d.ts.map +1 -0
- package/dist/types/light-account/abis/MultiOwnerLightAccountFactoryAbi.d.ts +287 -0
- package/dist/types/light-account/abis/MultiOwnerLightAccountFactoryAbi.d.ts.map +1 -0
- package/dist/types/light-account/abis/OZ_ERC1967Proxy.d.ts +14 -0
- package/dist/types/light-account/abis/OZ_ERC1967Proxy.d.ts.map +1 -0
- package/dist/types/light-account/accounts/account.d.ts +23 -0
- package/dist/types/light-account/accounts/account.d.ts.map +1 -0
- package/dist/types/light-account/accounts/base.d.ts +29 -0
- package/dist/types/light-account/accounts/base.d.ts.map +1 -0
- package/dist/types/light-account/accounts/calldataCodec.d.ts +4 -0
- package/dist/types/light-account/accounts/calldataCodec.d.ts.map +1 -0
- package/dist/types/light-account/accounts/multi-owner-account.d.ts +21 -0
- package/dist/types/light-account/accounts/multi-owner-account.d.ts.map +1 -0
- package/dist/types/light-account/decorators/multiOwner.d.ts +18 -0
- package/dist/types/light-account/decorators/multiOwner.d.ts.map +1 -0
- package/dist/types/light-account/decorators/singleOwner.d.ts +17 -0
- package/dist/types/light-account/decorators/singleOwner.d.ts.map +1 -0
- package/dist/types/light-account/lightAccountStaticImpl.d.ts +25 -0
- package/dist/types/light-account/lightAccountStaticImpl.d.ts.map +1 -0
- package/dist/types/light-account/predictAddress.d.ts +36 -0
- package/dist/types/light-account/predictAddress.d.ts.map +1 -0
- package/dist/types/light-account/registry.d.ts +7116 -0
- package/dist/types/light-account/registry.d.ts.map +1 -0
- package/dist/types/light-account/utils.d.ts +1455 -0
- package/dist/types/light-account/utils.d.ts.map +1 -0
- package/dist/types/logger.d.ts +3 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/ma-v1/abis/IStandardExecutor.d.ts +51 -0
- package/dist/types/ma-v1/abis/IStandardExecutor.d.ts.map +1 -0
- package/dist/types/ma-v1/abis/MultiOwnerModularAccountFactory.d.ts +235 -0
- package/dist/types/ma-v1/abis/MultiOwnerModularAccountFactory.d.ts.map +1 -0
- package/dist/types/ma-v1/abis/MultiOwnerPlugin.d.ts +699 -0
- package/dist/types/ma-v1/abis/MultiOwnerPlugin.d.ts.map +1 -0
- package/dist/types/ma-v1/abis/MultiOwnerPluginExecutionFunction.d.ts +68 -0
- package/dist/types/ma-v1/abis/MultiOwnerPluginExecutionFunction.d.ts.map +1 -0
- package/dist/types/ma-v1/abis/UpgradeableModularAccount.d.ts +881 -0
- package/dist/types/ma-v1/abis/UpgradeableModularAccount.d.ts.map +1 -0
- package/dist/types/ma-v1/account.d.ts +17 -0
- package/dist/types/ma-v1/account.d.ts.map +1 -0
- package/dist/types/ma-v1/accounts/base.d.ts +30 -0
- package/dist/types/ma-v1/accounts/base.d.ts.map +1 -0
- package/dist/types/ma-v1/accounts/multi-owner-account.d.ts +23 -0
- package/dist/types/ma-v1/accounts/multi-owner-account.d.ts.map +1 -0
- package/dist/types/ma-v1/decorators/multiOwner.d.ts +18 -0
- package/dist/types/ma-v1/decorators/multiOwner.d.ts.map +1 -0
- package/dist/types/ma-v1/mav1StaticImpl.d.ts +16 -0
- package/dist/types/ma-v1/mav1StaticImpl.d.ts.map +1 -0
- package/dist/types/ma-v1/predictAddress.d.ts +29 -0
- package/dist/types/ma-v1/predictAddress.d.ts.map +1 -0
- package/dist/types/ma-v2/abis/accountFactoryAbi.d.ts +349 -0
- package/dist/types/ma-v2/abis/accountFactoryAbi.d.ts.map +1 -0
- package/dist/types/ma-v2/abis/entityIdAndNonceReader.d.ts +10 -0
- package/dist/types/ma-v2/abis/entityIdAndNonceReader.d.ts.map +1 -0
- package/dist/types/ma-v2/abis/modularAccountAbi.d.ts +955 -0
- package/dist/types/ma-v2/abis/modularAccountAbi.d.ts.map +1 -0
- package/dist/types/ma-v2/abis/semiModularAccountBytecodeAbi.d.ts +992 -0
- package/dist/types/ma-v2/abis/semiModularAccountBytecodeAbi.d.ts.map +1 -0
- package/dist/types/ma-v2/abis/semiModularAccountStorageAbi.d.ts +1002 -0
- package/dist/types/ma-v2/abis/semiModularAccountStorageAbi.d.ts.map +1 -0
- package/dist/types/ma-v2/abis/webAuthnFactoryAbi.d.ts +331 -0
- package/dist/types/ma-v2/abis/webAuthnFactoryAbi.d.ts.map +1 -0
- package/dist/types/ma-v2/accounts/account.d.ts +33 -0
- package/dist/types/ma-v2/accounts/account.d.ts.map +1 -0
- package/dist/types/ma-v2/accounts/base.d.ts +41 -0
- package/dist/types/ma-v2/accounts/base.d.ts.map +1 -0
- package/dist/types/ma-v2/decorators/deferralActions.d.ts +52 -0
- package/dist/types/ma-v2/decorators/deferralActions.d.ts.map +1 -0
- package/dist/types/ma-v2/decorators/installValidation.d.ts +72 -0
- package/dist/types/ma-v2/decorators/installValidation.d.ts.map +1 -0
- package/dist/types/ma-v2/mav2StaticImpl.d.ts +38 -0
- package/dist/types/ma-v2/mav2StaticImpl.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.d.ts +557 -0
- package/dist/types/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/allowlist-module/module.d.ts +594 -0
- package/dist/types/ma-v2/modules/allowlist-module/module.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.d.ts +313 -0
- package/dist/types/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/native-token-limit-module/module.d.ts +323 -0
- package/dist/types/ma-v2/modules/native-token-limit-module/module.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.d.ts +187 -0
- package/dist/types/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/paymaster-guard-module/module.d.ts +197 -0
- package/dist/types/ma-v2/modules/paymaster-guard-module/module.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.d.ts +46 -0
- package/dist/types/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/single-signer-validation/module.d.ts +11 -0
- package/dist/types/ma-v2/modules/single-signer-validation/module.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.d.ts +230 -0
- package/dist/types/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/time-range-module/module.d.ts +255 -0
- package/dist/types/ma-v2/modules/time-range-module/module.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +288 -0
- package/dist/types/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts.map +1 -0
- package/dist/types/ma-v2/modules/webauthn-validation/module.d.ts +12 -0
- package/dist/types/ma-v2/modules/webauthn-validation/module.d.ts.map +1 -0
- package/dist/types/ma-v2/permissionBuilder.d.ts +159 -0
- package/dist/types/ma-v2/permissionBuilder.d.ts.map +1 -0
- package/dist/types/ma-v2/predictAddress.d.ts +38 -0
- package/dist/types/ma-v2/predictAddress.d.ts.map +1 -0
- package/dist/types/ma-v2/types.d.ts +58 -0
- package/dist/types/ma-v2/types.d.ts.map +1 -0
- package/dist/types/ma-v2/utils/account.d.ts +86 -0
- package/dist/types/ma-v2/utils/account.d.ts.map +1 -0
- package/dist/types/ma-v2/utils/deferredActions.d.ts +30 -0
- package/dist/types/ma-v2/utils/deferredActions.d.ts.map +1 -0
- package/dist/types/ma-v2/utils/hooks.d.ts +56 -0
- package/dist/types/ma-v2/utils/hooks.d.ts.map +1 -0
- package/dist/types/ma-v2/utils/signature.d.ts +64 -0
- package/dist/types/ma-v2/utils/signature.d.ts.map +1 -0
- package/dist/types/test-utils/getAccountAddressViaEntryPoint.d.ts +19 -0
- package/dist/types/test-utils/getAccountAddressViaEntryPoint.d.ts.map +1 -0
- package/dist/types/types.d.ts +31 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils.d.ts +7 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/version.d.ts +2 -0
- package/dist/types/version.d.ts.map +1 -0
- package/package.json +63 -0
- package/src/errors/EntityIdOverrideError.ts +15 -0
- package/src/errors/InvalidDeferredActionNonceError.ts +15 -0
- package/src/errors/InvalidEntityIdError.ts +19 -0
- package/src/errors/InvalidNonceKeyError.ts +19 -0
- package/src/errors/InvalidOwnerError.ts +17 -0
- package/src/errors/permissionBuilderErrors.ts +212 -0
- package/src/index.ts +152 -0
- package/src/light-account/abis/LightAccountAbi_v1.ts +378 -0
- package/src/light-account/abis/LightAccountAbi_v2.ts +354 -0
- package/src/light-account/abis/LightAccountFactoryAbi_v1.ts +74 -0
- package/src/light-account/abis/LightAccountFactoryAbi_v2.ts +209 -0
- package/src/light-account/abis/MultiOwnerLightAccountAbi.ts +371 -0
- package/src/light-account/abis/MultiOwnerLightAccountFactoryAbi.ts +228 -0
- package/src/light-account/abis/OZ_ERC1967Proxy.ts +19 -0
- package/src/light-account/accounts/account.ts +154 -0
- package/src/light-account/accounts/base.ts +340 -0
- package/src/light-account/accounts/calldataCodec.ts +101 -0
- package/src/light-account/accounts/multi-owner-account.ts +138 -0
- package/src/light-account/decorators/multiOwner.ts +69 -0
- package/src/light-account/decorators/singleOwner.ts +61 -0
- package/src/light-account/lightAccountStaticImpl.ts +172 -0
- package/src/light-account/predictAddress.ts +174 -0
- package/src/light-account/registry.ts +72 -0
- package/src/light-account/utils.ts +95 -0
- package/src/logger.ts +9 -0
- package/src/ma-v1/abis/IStandardExecutor.ts +31 -0
- package/src/ma-v1/abis/MultiOwnerModularAccountFactory.ts +190 -0
- package/src/ma-v1/abis/MultiOwnerPlugin.ts +528 -0
- package/src/ma-v1/abis/MultiOwnerPluginExecutionFunction.ts +37 -0
- package/src/ma-v1/abis/UpgradeableModularAccount.ts +645 -0
- package/src/ma-v1/account.ts +19 -0
- package/src/ma-v1/accounts/base.ts +245 -0
- package/src/ma-v1/accounts/multi-owner-account.ts +162 -0
- package/src/ma-v1/decorators/multiOwner.ts +69 -0
- package/src/ma-v1/mav1StaticImpl.ts +53 -0
- package/src/ma-v1/predictAddress.ts +85 -0
- package/src/ma-v2/abis/accountFactoryAbi.ts +644 -0
- package/src/ma-v2/abis/entityIdAndNonceReader.ts +23 -0
- package/src/ma-v2/abis/modularAccountAbi.ts +1241 -0
- package/src/ma-v2/abis/semiModularAccountBytecodeAbi.ts +1288 -0
- package/src/ma-v2/abis/semiModularAccountStorageAbi.ts +1301 -0
- package/src/ma-v2/abis/webAuthnFactoryAbi.ts +259 -0
- package/src/ma-v2/accounts/account.ts +211 -0
- package/src/ma-v2/accounts/base.ts +569 -0
- package/src/ma-v2/decorators/deferralActions.ts +193 -0
- package/src/ma-v2/decorators/installValidation.ts +257 -0
- package/src/ma-v2/mav2StaticImpl.ts +134 -0
- package/src/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.ts +715 -0
- package/src/ma-v2/modules/allowlist-module/module.ts +116 -0
- package/src/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.ts +403 -0
- package/src/ma-v2/modules/native-token-limit-module/module.ts +21 -0
- package/src/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.ts +241 -0
- package/src/ma-v2/modules/paymaster-guard-module/module.ts +35 -0
- package/src/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.ts +330 -0
- package/src/ma-v2/modules/single-signer-validation/module.ts +24 -0
- package/src/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.ts +295 -0
- package/src/ma-v2/modules/time-range-module/module.ts +96 -0
- package/src/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.ts +373 -0
- package/src/ma-v2/modules/webauthn-validation/module.ts +28 -0
- package/src/ma-v2/permissionBuilder.ts +761 -0
- package/src/ma-v2/predictAddress.ts +149 -0
- package/src/ma-v2/types.ts +73 -0
- package/src/ma-v2/utils/account.ts +137 -0
- package/src/ma-v2/utils/deferredActions.ts +66 -0
- package/src/ma-v2/utils/hooks.ts +79 -0
- package/src/ma-v2/utils/signature.ts +129 -0
- package/src/test-utils/getAccountAddressViaEntryPoint.ts +43 -0
- package/src/types.ts +58 -0
- package/src/utils.ts +85 -0
- package/src/version.ts +3 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Address,
|
|
3
|
+
type Chain,
|
|
4
|
+
type Client,
|
|
5
|
+
type Hex,
|
|
6
|
+
type JsonRpcAccount,
|
|
7
|
+
type LocalAccount,
|
|
8
|
+
type Transport,
|
|
9
|
+
type Hash,
|
|
10
|
+
type TypedDataDefinition,
|
|
11
|
+
encodeFunctionData,
|
|
12
|
+
} from "viem";
|
|
13
|
+
import {
|
|
14
|
+
entryPoint06Abi,
|
|
15
|
+
toSmartAccount,
|
|
16
|
+
type SmartAccount,
|
|
17
|
+
type SmartAccountImplementation,
|
|
18
|
+
entryPoint06Address,
|
|
19
|
+
getUserOperationHash,
|
|
20
|
+
} from "viem/account-abstraction";
|
|
21
|
+
import type { SignatureRequest } from "../../types.js";
|
|
22
|
+
import { IStandardExecutorAbi } from "../abis/IStandardExecutor.js";
|
|
23
|
+
import { signMessage, signTypedData } from "viem/actions";
|
|
24
|
+
import {
|
|
25
|
+
decodeFunctionData,
|
|
26
|
+
getAction,
|
|
27
|
+
hashMessage,
|
|
28
|
+
hashTypedData,
|
|
29
|
+
isAddressEqual,
|
|
30
|
+
} from "viem/utils";
|
|
31
|
+
import { BaseError } from "@alchemy/common";
|
|
32
|
+
|
|
33
|
+
type MaV1AccountType = "MultiOwnerModularAccountV1"; // Currently no SDK v5 support for "MultiSigModularAccountV1".
|
|
34
|
+
|
|
35
|
+
export type BaseMaV1AccountImplementation = SmartAccountImplementation<
|
|
36
|
+
typeof entryPoint06Abi,
|
|
37
|
+
"0.6",
|
|
38
|
+
{
|
|
39
|
+
source: MaV1AccountType;
|
|
40
|
+
prepareSignature: (request: SignatureRequest) => Promise<SignatureRequest>;
|
|
41
|
+
formatSignature: (signature: Hex) => Promise<Hex>;
|
|
42
|
+
},
|
|
43
|
+
false
|
|
44
|
+
>;
|
|
45
|
+
|
|
46
|
+
export type ModularAccountV1Base = SmartAccount<BaseMaV1AccountImplementation>;
|
|
47
|
+
|
|
48
|
+
export type ToModularAccountV1BaseParams<
|
|
49
|
+
TTransport extends Transport = Transport,
|
|
50
|
+
> = {
|
|
51
|
+
client: Client<TTransport, Chain, JsonRpcAccount | LocalAccount | undefined>;
|
|
52
|
+
accountAddress: Address;
|
|
53
|
+
owner: JsonRpcAccount | LocalAccount;
|
|
54
|
+
getFactoryArgs: () => Promise<{
|
|
55
|
+
factory?: Address | undefined;
|
|
56
|
+
factoryData?: Hex | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
get712Wrapper: (msg: Hash) => Promise<TypedDataDefinition>;
|
|
59
|
+
type: MaV1AccountType;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Creates a ModularAccountV1Base instance.
|
|
64
|
+
*
|
|
65
|
+
* @param {ToModularAccountV1BaseParams<TTransport>} params The parameters for creating a ModularAccountV1Base instance
|
|
66
|
+
* @returns {Promise<ModularAccountV1Base>} A promise that resolves to a ModularAccountV1Base instance
|
|
67
|
+
*/
|
|
68
|
+
export async function toModularAccountV1Base<
|
|
69
|
+
TTransport extends Transport = Transport,
|
|
70
|
+
>({
|
|
71
|
+
client,
|
|
72
|
+
accountAddress,
|
|
73
|
+
owner,
|
|
74
|
+
getFactoryArgs,
|
|
75
|
+
get712Wrapper,
|
|
76
|
+
type,
|
|
77
|
+
}: ToModularAccountV1BaseParams<TTransport>): Promise<ModularAccountV1Base> {
|
|
78
|
+
const entryPoint = {
|
|
79
|
+
abi: entryPoint06Abi,
|
|
80
|
+
address: entryPoint06Address,
|
|
81
|
+
version: "0.6" as const,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const prepareSignature = async (
|
|
85
|
+
params: SignatureRequest,
|
|
86
|
+
): Promise<SignatureRequest> => {
|
|
87
|
+
const data = await get712Wrapper(
|
|
88
|
+
params.type === "personal_sign"
|
|
89
|
+
? hashMessage(params.data)
|
|
90
|
+
: hashTypedData(params.data),
|
|
91
|
+
);
|
|
92
|
+
return {
|
|
93
|
+
type: "eth_signTypedData_v4",
|
|
94
|
+
data,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const formatSignature = async (signature: Hex): Promise<Hex> => {
|
|
99
|
+
return signature;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return await toSmartAccount({
|
|
103
|
+
getFactoryArgs,
|
|
104
|
+
client,
|
|
105
|
+
entryPoint,
|
|
106
|
+
|
|
107
|
+
async getAddress() {
|
|
108
|
+
return accountAddress;
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
async encodeCalls(calls) {
|
|
112
|
+
if (!calls.length) {
|
|
113
|
+
throw new BaseError("No calls to encode.");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (calls.length === 1) {
|
|
117
|
+
const call = calls[0];
|
|
118
|
+
|
|
119
|
+
// If the call is to the account itself, we need to avoid wrapping it in an `execute` call.
|
|
120
|
+
if (isAddressEqual(call.to, accountAddress)) {
|
|
121
|
+
if (call.data == null) {
|
|
122
|
+
throw new BaseError("Data is required for an account self-call.");
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return call.data;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return encodeFunctionData({
|
|
129
|
+
abi: IStandardExecutorAbi,
|
|
130
|
+
functionName: "execute",
|
|
131
|
+
args: [call.to, call.value ?? 0n, call.data ?? "0x"],
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return encodeFunctionData({
|
|
136
|
+
abi: IStandardExecutorAbi,
|
|
137
|
+
functionName: "executeBatch",
|
|
138
|
+
args: [
|
|
139
|
+
calls.map((call) => ({
|
|
140
|
+
target: call.to,
|
|
141
|
+
value: call.value ?? 0n,
|
|
142
|
+
data: call.data ?? "0x",
|
|
143
|
+
})),
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
// Inverse of `encodeCalls`.
|
|
149
|
+
async decodeCalls(data) {
|
|
150
|
+
const decoded = decodeFunctionData({
|
|
151
|
+
abi: IStandardExecutorAbi,
|
|
152
|
+
data,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
if (decoded.functionName === "execute") {
|
|
156
|
+
return [
|
|
157
|
+
{
|
|
158
|
+
to: decoded.args[0],
|
|
159
|
+
value: decoded.args[1],
|
|
160
|
+
data: decoded.args[2],
|
|
161
|
+
},
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (decoded.functionName === "executeBatch") {
|
|
166
|
+
return decoded.args[0].map((call) => ({
|
|
167
|
+
to: call.target,
|
|
168
|
+
value: call.value,
|
|
169
|
+
data: call.data,
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// If the data is not for an `execute` or `executeBatch` call, we treat it as a single call to the account itself.
|
|
174
|
+
return [
|
|
175
|
+
{
|
|
176
|
+
to: accountAddress,
|
|
177
|
+
data,
|
|
178
|
+
},
|
|
179
|
+
];
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
async getStubSignature() {
|
|
183
|
+
return "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
async signMessage({ message }) {
|
|
187
|
+
const signMessageAction = getAction(client, signMessage, "signMessage");
|
|
188
|
+
const signTypedDataAction = getAction(
|
|
189
|
+
client,
|
|
190
|
+
signTypedData,
|
|
191
|
+
"signTypedData",
|
|
192
|
+
);
|
|
193
|
+
const { type, data } = await prepareSignature({
|
|
194
|
+
type: "personal_sign",
|
|
195
|
+
data: message,
|
|
196
|
+
});
|
|
197
|
+
return type === "personal_sign"
|
|
198
|
+
? signMessageAction({ account: owner, message: data })
|
|
199
|
+
: signTypedDataAction({ ...data, account: owner });
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
async signTypedData(params) {
|
|
203
|
+
const signMessageAction = getAction(client, signMessage, "signMessage");
|
|
204
|
+
const signTypedDataAction = getAction(
|
|
205
|
+
client,
|
|
206
|
+
signTypedData,
|
|
207
|
+
"signTypedData",
|
|
208
|
+
);
|
|
209
|
+
const { type, data } = await prepareSignature({
|
|
210
|
+
type: "eth_signTypedData_v4",
|
|
211
|
+
data: params as TypedDataDefinition, // TODO(v5): try harder to avoid this cast?
|
|
212
|
+
});
|
|
213
|
+
return type === "personal_sign"
|
|
214
|
+
? signMessageAction({ account: owner, message: data })
|
|
215
|
+
: signTypedDataAction({ ...data, account: owner });
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
async signUserOperation(parameters) {
|
|
219
|
+
const { chainId = client.chain.id, ...userOperation } = parameters;
|
|
220
|
+
const userOpHash = getUserOperationHash({
|
|
221
|
+
chainId,
|
|
222
|
+
entryPointAddress: entryPoint.address,
|
|
223
|
+
entryPointVersion: entryPoint.version,
|
|
224
|
+
userOperation: {
|
|
225
|
+
...userOperation,
|
|
226
|
+
sender: accountAddress,
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const signMessageAction = getAction(client, signMessage, "signMessage");
|
|
231
|
+
return signMessageAction({
|
|
232
|
+
account: owner,
|
|
233
|
+
message: {
|
|
234
|
+
raw: userOpHash,
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
extend: {
|
|
240
|
+
source: type,
|
|
241
|
+
prepareSignature,
|
|
242
|
+
formatSignature,
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hexToBigInt,
|
|
3
|
+
type Address,
|
|
4
|
+
type Chain,
|
|
5
|
+
type Client,
|
|
6
|
+
type Hex,
|
|
7
|
+
type JsonRpcAccount,
|
|
8
|
+
type LocalAccount,
|
|
9
|
+
type OneOf,
|
|
10
|
+
type Transport,
|
|
11
|
+
encodeFunctionData,
|
|
12
|
+
type Hash,
|
|
13
|
+
type TypedDataDefinition,
|
|
14
|
+
} from "viem";
|
|
15
|
+
import { toModularAccountV1Base, type ModularAccountV1Base } from "./base.js";
|
|
16
|
+
import { lowerAddress, BaseError } from "@alchemy/common";
|
|
17
|
+
import { DefaultMaV1Address, DefaultMaV1PluginAddress } from "../account.js";
|
|
18
|
+
import { MultiOwnerModularAccountFactoryAbi } from "../abis/MultiOwnerModularAccountFactory.js";
|
|
19
|
+
import { predictMultiOwnerModularAccountV1Address } from "../predictAddress.js";
|
|
20
|
+
import { MultiOwnerPluginExecutionFunctionAbi } from "../abis/MultiOwnerPluginExecutionFunction.js";
|
|
21
|
+
import { readContract } from "viem/actions";
|
|
22
|
+
import { getAction } from "viem/utils";
|
|
23
|
+
import { MultiOwnerPluginAbi } from "../abis/MultiOwnerPlugin.js";
|
|
24
|
+
|
|
25
|
+
export type MultiOwnerModularAccountV1 = ModularAccountV1Base & {
|
|
26
|
+
encodeUpdateOwners: (
|
|
27
|
+
ownersToAdd: Address[],
|
|
28
|
+
ownersToRemove: Address[],
|
|
29
|
+
) => Hex;
|
|
30
|
+
getOwnerAddresses: () => Promise<readonly Address[]>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type ToMultiOwnerModularAccountV1Params = {
|
|
34
|
+
client: Client<Transport, Chain, JsonRpcAccount | LocalAccount | undefined>;
|
|
35
|
+
owners: [OneOf<JsonRpcAccount | LocalAccount>, ...{ address: Address }[]];
|
|
36
|
+
salt?: bigint;
|
|
37
|
+
accountAddress?: Address;
|
|
38
|
+
factoryAddress?: Address;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates a multi-owner MAv1 account.
|
|
43
|
+
*
|
|
44
|
+
* @param {ToMultiOwnerModularAccountV1Params} param0 - The parameters for creating a multi-owner MAv1 account.
|
|
45
|
+
* @returns {Promise<MultiOwnerModularAccountV1<TSigner>>} A multi-owner MAv1 account.
|
|
46
|
+
*/
|
|
47
|
+
export async function toMultiOwnerModularAccountV1({
|
|
48
|
+
client,
|
|
49
|
+
salt = 0n,
|
|
50
|
+
owners,
|
|
51
|
+
accountAddress: accountAddress_,
|
|
52
|
+
factoryAddress = DefaultMaV1Address.MULTI_OWNER_MAV1_FACTORY,
|
|
53
|
+
}: ToMultiOwnerModularAccountV1Params): Promise<MultiOwnerModularAccountV1> {
|
|
54
|
+
const signer = owners[0];
|
|
55
|
+
|
|
56
|
+
const dedupedOwners = Array.from(
|
|
57
|
+
new Set(owners.map((it) => lowerAddress(it.address))),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const sortedOwners = dedupedOwners.sort((a, b) => {
|
|
61
|
+
const bigintA = hexToBigInt(a);
|
|
62
|
+
const bigintB = hexToBigInt(b);
|
|
63
|
+
return bigintA < bigintB ? -1 : bigintA > bigintB ? 1 : 0;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const accountAddress =
|
|
67
|
+
accountAddress_ ??
|
|
68
|
+
predictMultiOwnerModularAccountV1Address({
|
|
69
|
+
factoryAddress,
|
|
70
|
+
salt,
|
|
71
|
+
ownerAddresses: sortedOwners,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const getFactoryArgs = async () => {
|
|
75
|
+
const factoryData = encodeFunctionData({
|
|
76
|
+
abi: MultiOwnerModularAccountFactoryAbi,
|
|
77
|
+
functionName: "createAccount",
|
|
78
|
+
args: [salt, sortedOwners],
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
factory: factoryAddress,
|
|
83
|
+
factoryData,
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const get712Wrapper = async (msg: Hash): Promise<TypedDataDefinition> => {
|
|
88
|
+
const readContractAction = getAction(client, readContract, "readContract");
|
|
89
|
+
|
|
90
|
+
const [, name, version, chainId, verifyingContract, salt] =
|
|
91
|
+
await readContractAction({
|
|
92
|
+
abi: MultiOwnerPluginAbi,
|
|
93
|
+
address: DefaultMaV1PluginAddress.MULTI_OWNER,
|
|
94
|
+
functionName: "eip712Domain",
|
|
95
|
+
account: accountAddress,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
domain: {
|
|
100
|
+
chainId: Number(chainId),
|
|
101
|
+
name,
|
|
102
|
+
salt,
|
|
103
|
+
verifyingContract,
|
|
104
|
+
version,
|
|
105
|
+
},
|
|
106
|
+
types: {
|
|
107
|
+
AlchemyModularAccountMessage: [{ name: "message", type: "bytes" }],
|
|
108
|
+
},
|
|
109
|
+
message: {
|
|
110
|
+
message: msg,
|
|
111
|
+
},
|
|
112
|
+
primaryType: "AlchemyModularAccountMessage",
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const baseAccount = await toModularAccountV1Base({
|
|
117
|
+
client,
|
|
118
|
+
owner: signer,
|
|
119
|
+
accountAddress,
|
|
120
|
+
getFactoryArgs,
|
|
121
|
+
type: "MultiOwnerModularAccountV1",
|
|
122
|
+
get712Wrapper,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
...baseAccount,
|
|
127
|
+
|
|
128
|
+
encodeUpdateOwners: (ownersToAdd: Address[], ownersToRemove: Address[]) => {
|
|
129
|
+
return encodeFunctionData({
|
|
130
|
+
abi: MultiOwnerPluginExecutionFunctionAbi,
|
|
131
|
+
functionName: "updateOwners",
|
|
132
|
+
args: [ownersToAdd, ownersToRemove],
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
async getOwnerAddresses(): Promise<readonly Address[]> {
|
|
137
|
+
const readContractAction = getAction(
|
|
138
|
+
client,
|
|
139
|
+
readContract,
|
|
140
|
+
"readContract",
|
|
141
|
+
);
|
|
142
|
+
const ownersOnChain = await readContractAction({
|
|
143
|
+
address: DefaultMaV1PluginAddress.MULTI_OWNER,
|
|
144
|
+
abi: MultiOwnerPluginAbi,
|
|
145
|
+
functionName: "ownersOf",
|
|
146
|
+
args: [accountAddress],
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
if (
|
|
150
|
+
!ownersOnChain
|
|
151
|
+
.map((it) => lowerAddress(it))
|
|
152
|
+
.includes(lowerAddress(signer.address))
|
|
153
|
+
) {
|
|
154
|
+
throw new BaseError(
|
|
155
|
+
"on-chain owners does not include the current signer",
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return ownersOnChain;
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
|
|
2
|
+
import { sendUserOperation, type SmartAccount } from "viem/account-abstraction";
|
|
3
|
+
import { getAction } from "viem/utils";
|
|
4
|
+
import type { GetAccountParameter } from "../../types.js";
|
|
5
|
+
import { AccountNotFoundError } from "@alchemy/common";
|
|
6
|
+
import type { MultiOwnerModularAccountV1 } from "../accounts/multi-owner-account.js";
|
|
7
|
+
|
|
8
|
+
export type MultiOwnerModularAccountV1Actions<
|
|
9
|
+
TAccount extends MultiOwnerModularAccountV1 | undefined =
|
|
10
|
+
| MultiOwnerModularAccountV1
|
|
11
|
+
| undefined,
|
|
12
|
+
> = {
|
|
13
|
+
updateOwners: (
|
|
14
|
+
args: {
|
|
15
|
+
ownersToAdd: Address[];
|
|
16
|
+
ownersToRemove: Address[];
|
|
17
|
+
} & GetAccountParameter<TAccount, MultiOwnerModularAccountV1>,
|
|
18
|
+
) => Promise<Hex>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function isMultiOwnerModularAccountV1(
|
|
22
|
+
account: SmartAccount,
|
|
23
|
+
): account is MultiOwnerModularAccountV1 {
|
|
24
|
+
return "source" in account && account.source === "MultiOwnerModularAccountV1";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Generates client actions for a multi-owner MAv1 account, including the ability to update owners.
|
|
29
|
+
*
|
|
30
|
+
* @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
|
|
31
|
+
* @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner modular account
|
|
32
|
+
*/
|
|
33
|
+
export function multiOwnerModularAccountV1Actions<
|
|
34
|
+
TTransport extends Transport = Transport,
|
|
35
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
36
|
+
TAccount extends SmartAccount | undefined = SmartAccount | undefined,
|
|
37
|
+
>(
|
|
38
|
+
client: Client<TTransport, TChain, TAccount>,
|
|
39
|
+
): MultiOwnerModularAccountV1Actions<
|
|
40
|
+
IsUndefined<TAccount> extends true ? undefined : MultiOwnerModularAccountV1
|
|
41
|
+
> {
|
|
42
|
+
return {
|
|
43
|
+
// TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that
|
|
44
|
+
// implicitly do a sendUserOperation internally. These are non-composable with batching
|
|
45
|
+
// and have a number of other issues that are solved with viem writeContract.
|
|
46
|
+
updateOwners: async (args) => {
|
|
47
|
+
const { ownersToAdd, ownersToRemove, account = client.account } = args;
|
|
48
|
+
|
|
49
|
+
if (!account || !isMultiOwnerModularAccountV1(account)) {
|
|
50
|
+
throw new AccountNotFoundError();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);
|
|
54
|
+
|
|
55
|
+
const action = getAction(client, sendUserOperation, "sendUserOperation");
|
|
56
|
+
const result = await action({
|
|
57
|
+
calls: [
|
|
58
|
+
{
|
|
59
|
+
to: account.address,
|
|
60
|
+
data,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
account,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return result;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type Address, encodeFunctionData } from "viem";
|
|
2
|
+
import { entryPoint06Abi, entryPoint06Address } from "viem/account-abstraction";
|
|
3
|
+
import { lowerAddress } from "@alchemy/common";
|
|
4
|
+
import type { StaticSmartAccountImplementation } from "../types";
|
|
5
|
+
import { MultiOwnerModularAccountFactoryAbi } from "./abis/MultiOwnerModularAccountFactory.js";
|
|
6
|
+
import { UpgradeableModularAccountAbi } from "./abis/UpgradeableModularAccount.js";
|
|
7
|
+
import { DefaultMaV1Address } from "./account.js";
|
|
8
|
+
import { predictMultiOwnerModularAccountV1Address } from "./predictAddress.js";
|
|
9
|
+
|
|
10
|
+
export type MultiOwnerModularAccountV1FactoryArgs = {
|
|
11
|
+
owners: Address[];
|
|
12
|
+
salt: bigint;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Static implementation logic for ModularAccountV1.
|
|
17
|
+
*
|
|
18
|
+
* TODO(v5): update JSDoc format when doc-gen supports structs or records.
|
|
19
|
+
*/
|
|
20
|
+
export const multiOwnerModularAccountStaticImpl: StaticSmartAccountImplementation<
|
|
21
|
+
false,
|
|
22
|
+
"0.6",
|
|
23
|
+
MultiOwnerModularAccountV1FactoryArgs,
|
|
24
|
+
typeof entryPoint06Abi,
|
|
25
|
+
typeof UpgradeableModularAccountAbi,
|
|
26
|
+
typeof MultiOwnerModularAccountFactoryAbi
|
|
27
|
+
> = {
|
|
28
|
+
entryPoint: {
|
|
29
|
+
abi: entryPoint06Abi,
|
|
30
|
+
address: entryPoint06Address,
|
|
31
|
+
version: "0.6",
|
|
32
|
+
},
|
|
33
|
+
accountAbi: UpgradeableModularAccountAbi,
|
|
34
|
+
factoryAbi: MultiOwnerModularAccountFactoryAbi,
|
|
35
|
+
getFactoryData: (factoryArgs: MultiOwnerModularAccountV1FactoryArgs) => {
|
|
36
|
+
return encodeFunctionData({
|
|
37
|
+
abi: MultiOwnerModularAccountFactoryAbi,
|
|
38
|
+
functionName: "createAccount",
|
|
39
|
+
args: [factoryArgs.salt, factoryArgs.owners],
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
accountImplementation: lowerAddress(
|
|
43
|
+
DefaultMaV1Address.IMPLEMENTATION_ADDRESS,
|
|
44
|
+
),
|
|
45
|
+
factoryAddress: lowerAddress(DefaultMaV1Address.MULTI_OWNER_MAV1_FACTORY),
|
|
46
|
+
predictAccountAddress: (args) => {
|
|
47
|
+
return predictMultiOwnerModularAccountV1Address({
|
|
48
|
+
salt: args.salt,
|
|
49
|
+
ownerAddresses: args.owners,
|
|
50
|
+
factoryAddress: DefaultMaV1Address.MULTI_OWNER_MAV1_FACTORY,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Address,
|
|
3
|
+
getContractAddress,
|
|
4
|
+
encodeAbiParameters,
|
|
5
|
+
keccak256,
|
|
6
|
+
concatHex,
|
|
7
|
+
type Hex,
|
|
8
|
+
} from "viem";
|
|
9
|
+
import { DefaultMaV1Address } from "./account.js";
|
|
10
|
+
import { BaseError } from "@alchemy/common";
|
|
11
|
+
|
|
12
|
+
export type PredictMultiOwnerModularAccountV1AddressParams = {
|
|
13
|
+
salt: bigint;
|
|
14
|
+
/* Owner addresses must be already deduped, sorted in ascending order, and have the signer address included. */
|
|
15
|
+
ownerAddresses: Address[];
|
|
16
|
+
factoryAddress?: Address;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Predicts the address of a MultiOwnerModularAccountV1 smart account before deployment.
|
|
21
|
+
*
|
|
22
|
+
* This function uses CREATE2 to deterministically compute the account address based on the factory address,
|
|
23
|
+
* salt, and owner addresses. The predicted address will match the actual deployed address if the same
|
|
24
|
+
* parameters are used during deployment.
|
|
25
|
+
*
|
|
26
|
+
* @param {PredictMultiOwnerModularAccountV1AddressParams} params The parameters for predicting the account address
|
|
27
|
+
* @param {bigint} params.salt A unique value used to generate different account addresses for the same set of owners
|
|
28
|
+
* @param {Address[]} params.ownerAddresses Array of owner addresses that will control the account. Must be deduplicated, sorted in ascending order, and include the signer address. Cannot be empty and must contain at most 100 addresses.
|
|
29
|
+
* @param {Address} [params.factoryAddress] The factory contract address that will deploy the account. Defaults to the standard MultiOwnerModularAccountV1 factory address.
|
|
30
|
+
* @returns {Address} The predicted address where the account will be deployed
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const predictedAddress = predictMultiOwnerModularAccountV1Address({
|
|
35
|
+
* salt: 0n,
|
|
36
|
+
* ownerAddresses: ["0x1234...", "0x5678..."]
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export const predictMultiOwnerModularAccountV1Address = ({
|
|
41
|
+
salt,
|
|
42
|
+
ownerAddresses,
|
|
43
|
+
factoryAddress = DefaultMaV1Address.MULTI_OWNER_MAV1_FACTORY,
|
|
44
|
+
}: PredictMultiOwnerModularAccountV1AddressParams): Address => {
|
|
45
|
+
if (ownerAddresses.length === 0) {
|
|
46
|
+
throw new BaseError("Owners array cannot be empty");
|
|
47
|
+
}
|
|
48
|
+
if (ownerAddresses.length > 100) {
|
|
49
|
+
throw new Error("Maximum 100 owners on creation");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const combinedSalt = getCombinedSalt(salt, ownerAddresses);
|
|
53
|
+
|
|
54
|
+
const initCodeHash = getERC1967ProxyInitCodeHash(
|
|
55
|
+
DefaultMaV1Address.IMPLEMENTATION_ADDRESS,
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return getContractAddress({
|
|
59
|
+
from: factoryAddress,
|
|
60
|
+
opcode: "CREATE2",
|
|
61
|
+
salt: combinedSalt,
|
|
62
|
+
bytecodeHash: initCodeHash,
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function getCombinedSalt(salt: bigint, owners: Address[]): Hex {
|
|
67
|
+
const encodedOwners = encodeAbiParameters([{ type: "address[]" }], [owners]);
|
|
68
|
+
const saltAndOwners = encodeAbiParameters(
|
|
69
|
+
[{ type: "uint256" }, { type: "bytes" }],
|
|
70
|
+
[salt, encodedOwners],
|
|
71
|
+
);
|
|
72
|
+
return keccak256(saltAndOwners);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getERC1967ProxyInitCodeHash(implementationAddress: Address): Hex {
|
|
76
|
+
const ERC1967_PROXY_BYTECODE =
|
|
77
|
+
"0x60406080815261042c908138038061001681610218565b93843982019181818403126102135780516001600160a01b038116808203610213576020838101516001600160401b0394919391858211610213570186601f820112156102135780519061007161006c83610253565b610218565b918083528583019886828401011161021357888661008f930161026e565b813b156101b9577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916841790556000927fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8480a28051158015906101b2575b61010b575b855160e790816103458239f35b855194606086019081118682101761019e578697849283926101889952602788527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c87890152660819985a5b195960ca1b8a8901525190845af4913d15610194573d9061017a61006c83610253565b91825281943d92013e610291565b508038808080806100fe565b5060609250610291565b634e487b7160e01b84526041600452602484fd5b50826100f9565b855162461bcd60e51b815260048101859052602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b600080fd5b6040519190601f01601f191682016001600160401b0381118382101761023d57604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161023d57601f01601f191660200190565b60005b8381106102815750506000910152565b8181015183820152602001610271565b919290156102f357508151156102a5575090565b3b156102ae5790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156103065750805190602001fd5b6044604051809262461bcd60e51b825260206004830152610336815180928160248601526020868601910161026e565b601f01601f19168101030190fdfe60806040523615605f5773ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54166000808092368280378136915af43d82803e15605b573d90f35b3d90fd5b73ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54166000808092368280378136915af43d82803e15605b573d90f3fea26469706673582212208f3104255ee3c201238ea03e118ee6ec0a2cff51cbfbdc3af1727982a5a959a564736f6c63430008160033" as const;
|
|
78
|
+
|
|
79
|
+
const constructorArgs = encodeAbiParameters(
|
|
80
|
+
[{ type: "address" }, { type: "bytes" }],
|
|
81
|
+
[implementationAddress, "0x"],
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return keccak256(concatHex([ERC1967_PROXY_BYTECODE, constructorArgs]));
|
|
85
|
+
}
|