@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,193 @@
|
|
|
1
|
+
import {
|
|
2
|
+
concatHex,
|
|
3
|
+
type Hex,
|
|
4
|
+
type Client,
|
|
5
|
+
type Chain,
|
|
6
|
+
type Transport,
|
|
7
|
+
encodePacked,
|
|
8
|
+
size,
|
|
9
|
+
toHex,
|
|
10
|
+
maxUint152,
|
|
11
|
+
encodeDeployData,
|
|
12
|
+
hexToNumber,
|
|
13
|
+
isHex,
|
|
14
|
+
type TypedDataDefinition,
|
|
15
|
+
} from "viem";
|
|
16
|
+
import type { SmartAccount } from "viem/account-abstraction";
|
|
17
|
+
import { entityIdAndNonceReaderAbi } from "../abis/entityIdAndNonceReader.js";
|
|
18
|
+
import { getAction } from "viem/utils";
|
|
19
|
+
import { call } from "viem/actions";
|
|
20
|
+
import { InvalidNonceKeyError } from "../../errors/InvalidNonceKeyError.js";
|
|
21
|
+
import { buildFullNonceKey, isModularAccountV2 } from "../utils/account.js";
|
|
22
|
+
import { AccountNotFoundError, BaseError } from "@alchemy/common";
|
|
23
|
+
|
|
24
|
+
export const ENTITY_ID_AND_NONCE_READER_BYTECODE =
|
|
25
|
+
"0x608060405234801561001057600080fd5b506040516104f13803806104f183398101604081905261002f916101e5565b60006008826001600160c01b0316901c90506000808263ffffffff1611610057576001610059565b815b90506001600160a01b0385163b15610133575b60006001600160a01b03861663d31b575b6bffffffff0000000000000000604085901b166040516001600160e01b031960e084901b1681526001600160401b03199091166004820152602401600060405180830381865afa1580156100d5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526100fd91908101906103c6565b805190915060ff161580156101155750606081015151155b156101205750610133565b8161012a816104a4565b9250505061006c565b604051631aab3f0d60e11b81526001600160a01b03868116600483015264ffffffff01600160c01b038516600884901b64ffffffff0016176024830152600091908616906335567e1a90604401602060405180830381865afa15801561019d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c191906104d7565b90508060005260206000f35b6001600160a01b03811681146101e257600080fd5b50565b6000806000606084860312156101fa57600080fd5b8351610205816101cd565b6020850151909350610216816101cd565b60408501519092506001600160c01b038116811461023357600080fd5b809150509250925092565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b03811182821017156102765761027661023e565b60405290565b604051601f8201601f191681016001600160401b03811182821017156102a4576102a461023e565b604052919050565b60006001600160401b038211156102c5576102c561023e565b5060051b60200190565b600082601f8301126102e057600080fd5b81516102f36102ee826102ac565b61027c565b8082825260208201915060208360051b86010192508583111561031557600080fd5b602085015b8381101561034857805166ffffffffffffff198116811461033a57600080fd5b83526020928301920161031a565b5095945050505050565b600082601f83011261036357600080fd5b81516103716102ee826102ac565b8082825260208201915060208360051b86010192508583111561039357600080fd5b602085015b838110156103485780516001600160e01b0319811681146103b857600080fd5b835260209283019201610398565b6000602082840312156103d857600080fd5b81516001600160401b038111156103ee57600080fd5b82016080818503121561040057600080fd5b610408610254565b815160ff8116811461041957600080fd5b815260208201516001600160401b0381111561043457600080fd5b610440868285016102cf565b60208301525060408201516001600160401b0381111561045f57600080fd5b61046b868285016102cf565b60408301525060608201516001600160401b0381111561048a57600080fd5b61049686828501610352565b606083015250949350505050565b600063ffffffff821663ffffffff81036104ce57634e487b7160e01b600052601160045260246000fd5b60010192915050565b6000602082840312156104e957600080fd5b505191905056fe";
|
|
26
|
+
|
|
27
|
+
export type DeferredActionTypedData = TypedDataDefinition<
|
|
28
|
+
{
|
|
29
|
+
DeferredAction: [
|
|
30
|
+
{ name: "nonce"; type: "uint256" },
|
|
31
|
+
{ name: "deadline"; type: "uint48" },
|
|
32
|
+
{ name: "call"; type: "bytes" },
|
|
33
|
+
];
|
|
34
|
+
},
|
|
35
|
+
"DeferredAction"
|
|
36
|
+
>;
|
|
37
|
+
|
|
38
|
+
export type DeferredActionReturnData = {
|
|
39
|
+
typedData: DeferredActionTypedData;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type CreateDeferredActionTypedDataParams = {
|
|
43
|
+
callData: Hex;
|
|
44
|
+
deadline: number;
|
|
45
|
+
nonce: bigint;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type BuildPreSignatureDeferredActionDigestParams = {
|
|
49
|
+
typedData: DeferredActionTypedData;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type EntityIdAndNonceParams = {
|
|
53
|
+
entityId?: number;
|
|
54
|
+
nonceKey?: bigint;
|
|
55
|
+
isGlobalValidation: boolean;
|
|
56
|
+
isDeferredAction?: boolean;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type DeferralActions = {
|
|
60
|
+
createDeferredActionTypedDataObject: (
|
|
61
|
+
args: CreateDeferredActionTypedDataParams,
|
|
62
|
+
) => Promise<DeferredActionReturnData>;
|
|
63
|
+
buildPreSignatureDeferredActionDigest: (
|
|
64
|
+
args: BuildPreSignatureDeferredActionDigestParams,
|
|
65
|
+
) => Hex;
|
|
66
|
+
getEntityIdAndNonce: (
|
|
67
|
+
args: EntityIdAndNonceParams,
|
|
68
|
+
) => Promise<{ nonce: bigint; entityId: number }>;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Provides deferred action functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`.
|
|
73
|
+
*
|
|
74
|
+
* @param {ModularAccountV2Client} client - The client instance which provides account and sendUserOperation functionality.
|
|
75
|
+
* @returns {object} - An object containing three methods: `createDeferredActionTypedDataObject`, `buildDeferredActionDigest`, and `buildUserOperationWithDeferredAction`.
|
|
76
|
+
*/
|
|
77
|
+
export const deferralActions = <
|
|
78
|
+
TTransport extends Transport = Transport,
|
|
79
|
+
TChain extends Chain = Chain,
|
|
80
|
+
TAccount extends SmartAccount = SmartAccount,
|
|
81
|
+
>(
|
|
82
|
+
client: Client<TTransport, TChain, TAccount>,
|
|
83
|
+
): DeferralActions => {
|
|
84
|
+
const createDeferredActionTypedDataObject = async ({
|
|
85
|
+
callData,
|
|
86
|
+
deadline,
|
|
87
|
+
nonce,
|
|
88
|
+
}: CreateDeferredActionTypedDataParams): Promise<DeferredActionReturnData> => {
|
|
89
|
+
const account = client.account;
|
|
90
|
+
if (!account || !isModularAccountV2(account)) {
|
|
91
|
+
throw new AccountNotFoundError();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
typedData: {
|
|
96
|
+
domain: {
|
|
97
|
+
chainId: client.chain.id,
|
|
98
|
+
verifyingContract: client.account.address,
|
|
99
|
+
},
|
|
100
|
+
types: {
|
|
101
|
+
DeferredAction: [
|
|
102
|
+
{ name: "nonce", type: "uint256" },
|
|
103
|
+
{ name: "deadline", type: "uint48" },
|
|
104
|
+
{ name: "call", type: "bytes" },
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
primaryType: "DeferredAction",
|
|
108
|
+
message: {
|
|
109
|
+
nonce: nonce,
|
|
110
|
+
deadline: deadline,
|
|
111
|
+
call: callData,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const buildPreSignatureDeferredActionDigest = ({
|
|
118
|
+
typedData,
|
|
119
|
+
}: BuildPreSignatureDeferredActionDigestParams): Hex => {
|
|
120
|
+
const account = client.account;
|
|
121
|
+
if (!account || !isModularAccountV2(account)) {
|
|
122
|
+
throw new AccountNotFoundError();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const signerEntity = account.signerEntity;
|
|
126
|
+
const validationLocator =
|
|
127
|
+
(BigInt(signerEntity.entityId) << 8n) |
|
|
128
|
+
(signerEntity.isGlobalValidation ? 1n : 0n);
|
|
129
|
+
|
|
130
|
+
const encodedCallData = encodePacked(
|
|
131
|
+
["uint168", "uint48", "bytes"],
|
|
132
|
+
[validationLocator, typedData.message.deadline, typedData.message.call],
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
const encodedDataLength = size(encodedCallData);
|
|
136
|
+
const encodedData = concatHex([
|
|
137
|
+
toHex(encodedDataLength, { size: 4 }),
|
|
138
|
+
encodedCallData,
|
|
139
|
+
]);
|
|
140
|
+
return encodedData;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const getEntityIdAndNonce = async ({
|
|
144
|
+
entityId = 1,
|
|
145
|
+
nonceKey = 0n,
|
|
146
|
+
isGlobalValidation,
|
|
147
|
+
isDeferredAction = true,
|
|
148
|
+
}: EntityIdAndNonceParams) => {
|
|
149
|
+
const account = client.account;
|
|
150
|
+
if (!account || !isModularAccountV2(account)) {
|
|
151
|
+
throw new AccountNotFoundError();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (nonceKey > maxUint152) {
|
|
155
|
+
throw new InvalidNonceKeyError(nonceKey);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const bytecode = encodeDeployData({
|
|
159
|
+
abi: entityIdAndNonceReaderAbi,
|
|
160
|
+
bytecode: ENTITY_ID_AND_NONCE_READER_BYTECODE,
|
|
161
|
+
args: [
|
|
162
|
+
account.address,
|
|
163
|
+
account.entryPoint.address,
|
|
164
|
+
buildFullNonceKey({
|
|
165
|
+
nonceKey,
|
|
166
|
+
entityId,
|
|
167
|
+
isGlobalValidation,
|
|
168
|
+
isDeferredAction,
|
|
169
|
+
}),
|
|
170
|
+
],
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const action = getAction(client, call, "call");
|
|
174
|
+
const { data } = await action({ data: bytecode });
|
|
175
|
+
if (!data) {
|
|
176
|
+
throw new BaseError("No data returned from contract call");
|
|
177
|
+
}
|
|
178
|
+
if (!isHex(data)) {
|
|
179
|
+
throw new BaseError("Expected hex data from contract call");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
nonce: BigInt(data),
|
|
184
|
+
entityId: hexToNumber(`0x${data.slice(40, 48)}`),
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
createDeferredActionTypedDataObject,
|
|
190
|
+
buildPreSignatureDeferredActionDigest,
|
|
191
|
+
getEntityIdAndNonce,
|
|
192
|
+
};
|
|
193
|
+
};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Address,
|
|
3
|
+
type Client,
|
|
4
|
+
type Hex,
|
|
5
|
+
type IsUndefined,
|
|
6
|
+
type Chain,
|
|
7
|
+
type Transport,
|
|
8
|
+
zeroAddress,
|
|
9
|
+
concatHex,
|
|
10
|
+
encodeFunctionData,
|
|
11
|
+
} from "viem";
|
|
12
|
+
import type { HookConfig, ValidationConfig } from "../types.js";
|
|
13
|
+
import type { ModularAccountV2 } from "../accounts/account.js";
|
|
14
|
+
import type { GetAccountParameter } from "../../types.js";
|
|
15
|
+
import { semiModularAccountBytecodeAbi } from "../abis/semiModularAccountBytecodeAbi.js";
|
|
16
|
+
import { type SmartAccount, sendUserOperation } from "viem/account-abstraction";
|
|
17
|
+
import { getAction } from "viem/utils";
|
|
18
|
+
import { AccountNotFoundError } from "@alchemy/common";
|
|
19
|
+
import { EntityIdOverrideError } from "../../errors/EntityIdOverrideError.js";
|
|
20
|
+
import {
|
|
21
|
+
serializeHookConfig,
|
|
22
|
+
serializeValidationConfig,
|
|
23
|
+
} from "../utils/hooks.js";
|
|
24
|
+
import {
|
|
25
|
+
DEFAULT_OWNER_ENTITY_ID,
|
|
26
|
+
isModularAccountV2,
|
|
27
|
+
serializeModuleEntity,
|
|
28
|
+
} from "../utils/account.js";
|
|
29
|
+
|
|
30
|
+
export type InstallValidationParams<
|
|
31
|
+
TAccount extends SmartAccount | undefined = SmartAccount | undefined,
|
|
32
|
+
> = {
|
|
33
|
+
validationConfig: ValidationConfig;
|
|
34
|
+
selectors: Hex[];
|
|
35
|
+
installData: Hex;
|
|
36
|
+
hooks: {
|
|
37
|
+
hookConfig: HookConfig;
|
|
38
|
+
initData: Hex;
|
|
39
|
+
}[];
|
|
40
|
+
} & GetAccountParameter<TAccount, ModularAccountV2>;
|
|
41
|
+
|
|
42
|
+
export type UninstallValidationParams<
|
|
43
|
+
TAccount extends SmartAccount | undefined = SmartAccount | undefined,
|
|
44
|
+
> = {
|
|
45
|
+
moduleAddress: Address;
|
|
46
|
+
entityId: number;
|
|
47
|
+
uninstallData: Hex;
|
|
48
|
+
hookUninstallDatas: Hex[];
|
|
49
|
+
} & GetAccountParameter<TAccount, ModularAccountV2>;
|
|
50
|
+
|
|
51
|
+
export type InstallValidationActions<
|
|
52
|
+
TAccount extends SmartAccount | undefined = SmartAccount | undefined,
|
|
53
|
+
> = {
|
|
54
|
+
encodeInstallValidation: (
|
|
55
|
+
args: InstallValidationParams<TAccount>,
|
|
56
|
+
) => Promise<Hex>;
|
|
57
|
+
installValidation: (args: InstallValidationParams<TAccount>) => Promise<Hex>;
|
|
58
|
+
encodeUninstallValidation: (
|
|
59
|
+
args: UninstallValidationParams<TAccount>,
|
|
60
|
+
) => Promise<Hex>;
|
|
61
|
+
uninstallValidation: (
|
|
62
|
+
args: UninstallValidationParams<TAccount>,
|
|
63
|
+
) => Promise<Hex>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// TODO(v5): update jsdoc
|
|
67
|
+
/**
|
|
68
|
+
* Provides validation installation and uninstallation functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { createModularAccountV2Client, installValidationActions, getDefaultSingleSignerValidationModuleAddress, SingleSignerValidationModule } from "@alchemy/smart-accounts";
|
|
73
|
+
* import { Address } from "viem";
|
|
74
|
+
*
|
|
75
|
+
* const client = (await createModularAccountV2Client({ ... })).extend(installValidationActions);
|
|
76
|
+
* const sessionKeyAddress: Address = "0x1234";
|
|
77
|
+
* const sessionKeyEntityId: number = 1;
|
|
78
|
+
*
|
|
79
|
+
* await client.installValidation({
|
|
80
|
+
* validationConfig: {
|
|
81
|
+
* moduleAddress: getDefaultSingleSignerValidationModuleAddress(
|
|
82
|
+
* client.chain
|
|
83
|
+
* ),
|
|
84
|
+
* entityId: sessionKeyEntityId,
|
|
85
|
+
* isGlobal: true,
|
|
86
|
+
* isSignatureValidation: false,
|
|
87
|
+
* isUserOpValidation: true,
|
|
88
|
+
* },
|
|
89
|
+
* selectors: [],
|
|
90
|
+
* installData: SingleSignerValidationModule.encodeOnInstallData({
|
|
91
|
+
* entityId: sessionKeyEntityId,
|
|
92
|
+
* signer: sessionKeyAddress,
|
|
93
|
+
* }),
|
|
94
|
+
* hooks: [],
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* await client.uninstallValidation({
|
|
98
|
+
* moduleAddress: sessionKeyAddress,
|
|
99
|
+
* entityId: sessionKeyEntityId,
|
|
100
|
+
* uninstallData: SingleSignerValidationModule.encodeOnUninstallData({
|
|
101
|
+
* entityId: sessionKeyEntityId,
|
|
102
|
+
* }),
|
|
103
|
+
* hookUninstallDatas: [],
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @param {object} client - The client instance which provides account and sendUserOperation functionality.
|
|
109
|
+
* @returns {object} - An object containing two methods, `installValidation` and `uninstallValidation`.
|
|
110
|
+
*/
|
|
111
|
+
export function installValidationActions<
|
|
112
|
+
TTransport extends Transport = Transport,
|
|
113
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
114
|
+
TAccount extends SmartAccount | undefined = SmartAccount | undefined,
|
|
115
|
+
>(
|
|
116
|
+
client: Client<TTransport, TChain, TAccount>,
|
|
117
|
+
): InstallValidationActions<
|
|
118
|
+
IsUndefined<TAccount> extends true ? undefined : ModularAccountV2
|
|
119
|
+
> {
|
|
120
|
+
const encodeInstallValidation = async (
|
|
121
|
+
args: InstallValidationParams<
|
|
122
|
+
IsUndefined<TAccount> extends true ? undefined : ModularAccountV2
|
|
123
|
+
>,
|
|
124
|
+
) => {
|
|
125
|
+
const {
|
|
126
|
+
validationConfig,
|
|
127
|
+
selectors,
|
|
128
|
+
installData,
|
|
129
|
+
hooks,
|
|
130
|
+
account = client.account,
|
|
131
|
+
} = args;
|
|
132
|
+
|
|
133
|
+
if (!account || !isModularAccountV2(account)) {
|
|
134
|
+
throw new AccountNotFoundError();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// An entityId of zero is only allowed if we're installing or uninstalling hooks on the fallback validation.
|
|
138
|
+
if (
|
|
139
|
+
validationConfig.entityId === DEFAULT_OWNER_ENTITY_ID &&
|
|
140
|
+
validationConfig.moduleAddress !== zeroAddress
|
|
141
|
+
) {
|
|
142
|
+
throw new EntityIdOverrideError();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return account.encodeCallData(
|
|
146
|
+
encodeFunctionData({
|
|
147
|
+
abi: semiModularAccountBytecodeAbi,
|
|
148
|
+
functionName: "installValidation",
|
|
149
|
+
args: [
|
|
150
|
+
serializeValidationConfig(validationConfig),
|
|
151
|
+
selectors,
|
|
152
|
+
installData,
|
|
153
|
+
hooks.map((hook: { hookConfig: HookConfig; initData: Hex }) =>
|
|
154
|
+
concatHex([serializeHookConfig(hook.hookConfig), hook.initData]),
|
|
155
|
+
),
|
|
156
|
+
],
|
|
157
|
+
}),
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const encodeUninstallValidation = async (
|
|
162
|
+
args: UninstallValidationParams<
|
|
163
|
+
IsUndefined<TAccount> extends true ? undefined : ModularAccountV2
|
|
164
|
+
>,
|
|
165
|
+
) => {
|
|
166
|
+
const {
|
|
167
|
+
moduleAddress,
|
|
168
|
+
entityId,
|
|
169
|
+
uninstallData,
|
|
170
|
+
hookUninstallDatas,
|
|
171
|
+
account = client.account,
|
|
172
|
+
} = args;
|
|
173
|
+
|
|
174
|
+
if (!account || !isModularAccountV2(account)) {
|
|
175
|
+
throw new AccountNotFoundError();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return account.encodeCallData(
|
|
179
|
+
encodeFunctionData({
|
|
180
|
+
abi: semiModularAccountBytecodeAbi,
|
|
181
|
+
functionName: "uninstallValidation",
|
|
182
|
+
args: [
|
|
183
|
+
serializeModuleEntity({
|
|
184
|
+
moduleAddress,
|
|
185
|
+
entityId,
|
|
186
|
+
}),
|
|
187
|
+
uninstallData,
|
|
188
|
+
hookUninstallDatas,
|
|
189
|
+
],
|
|
190
|
+
}),
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
encodeInstallValidation,
|
|
196
|
+
encodeUninstallValidation,
|
|
197
|
+
installValidation: async (args) => {
|
|
198
|
+
const {
|
|
199
|
+
validationConfig,
|
|
200
|
+
selectors,
|
|
201
|
+
installData,
|
|
202
|
+
hooks,
|
|
203
|
+
account = client.account,
|
|
204
|
+
} = args;
|
|
205
|
+
|
|
206
|
+
if (!account || !isModularAccountV2(account)) {
|
|
207
|
+
throw new AccountNotFoundError();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const callData = await encodeInstallValidation({
|
|
211
|
+
validationConfig,
|
|
212
|
+
selectors,
|
|
213
|
+
installData,
|
|
214
|
+
hooks,
|
|
215
|
+
account,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const action = getAction(client, sendUserOperation, "sendUserOperation");
|
|
219
|
+
const result = await action({
|
|
220
|
+
callData,
|
|
221
|
+
account,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
return result;
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
uninstallValidation: async (args) => {
|
|
228
|
+
const {
|
|
229
|
+
moduleAddress,
|
|
230
|
+
entityId,
|
|
231
|
+
uninstallData,
|
|
232
|
+
hookUninstallDatas,
|
|
233
|
+
account = client.account,
|
|
234
|
+
} = args;
|
|
235
|
+
|
|
236
|
+
if (!account || !isModularAccountV2(account)) {
|
|
237
|
+
throw new AccountNotFoundError();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const callData = await encodeUninstallValidation({
|
|
241
|
+
moduleAddress,
|
|
242
|
+
entityId,
|
|
243
|
+
uninstallData,
|
|
244
|
+
hookUninstallDatas,
|
|
245
|
+
account,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const action = getAction(client, sendUserOperation, "sendUserOperation");
|
|
249
|
+
const result = await action({
|
|
250
|
+
callData,
|
|
251
|
+
account,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return result;
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { encodeFunctionData, type Address, type Hex } from "viem";
|
|
2
|
+
import { entryPoint07Abi, entryPoint07Address } from "viem/account-abstraction";
|
|
3
|
+
import { lowerAddress } from "@alchemy/common";
|
|
4
|
+
import type { StaticSmartAccountImplementation } from "../types.js";
|
|
5
|
+
import { semiModularAccountBytecodeAbi } from "./abis/semiModularAccountBytecodeAbi.js";
|
|
6
|
+
import { accountFactoryAbi } from "./abis/accountFactoryAbi.js";
|
|
7
|
+
import { webAuthnFactoryAbi } from "./abis/webAuthnFactoryAbi.js";
|
|
8
|
+
import { DefaultAddress as DefaultMAV2Address } from "./utils/account.js";
|
|
9
|
+
import { predictModularAccountV2Address } from "./predictAddress.js";
|
|
10
|
+
import { modularAccountAbi } from "./abis/modularAccountAbi.js";
|
|
11
|
+
import { parsePublicKey } from "webauthn-p256";
|
|
12
|
+
|
|
13
|
+
export type SemiModularAccountV2FactoryArgs = {
|
|
14
|
+
owner: Address;
|
|
15
|
+
salt: bigint;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type SemiModularAccountV2StaticImpl = StaticSmartAccountImplementation<
|
|
19
|
+
false,
|
|
20
|
+
"0.7",
|
|
21
|
+
SemiModularAccountV2FactoryArgs,
|
|
22
|
+
typeof entryPoint07Abi,
|
|
23
|
+
typeof semiModularAccountBytecodeAbi,
|
|
24
|
+
typeof accountFactoryAbi
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
// Shared entryPoint configuration across all modular account v2 implementations
|
|
28
|
+
const entryPoint = {
|
|
29
|
+
abi: entryPoint07Abi,
|
|
30
|
+
address: entryPoint07Address,
|
|
31
|
+
version: "0.7",
|
|
32
|
+
} as const;
|
|
33
|
+
|
|
34
|
+
// Shared base for semi-modular account implementations (SMA and 7702)
|
|
35
|
+
const semiModularAccountBase = {
|
|
36
|
+
entryPoint,
|
|
37
|
+
accountAbi: semiModularAccountBytecodeAbi,
|
|
38
|
+
} satisfies Partial<SemiModularAccountV2StaticImpl>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Static implementation logic for SemiModularAccountV2.
|
|
42
|
+
*
|
|
43
|
+
* TODO(v5): update JSDoc format when doc-gen supports structs or records.
|
|
44
|
+
*/
|
|
45
|
+
export const semiModularAccountV2StaticImpl: SemiModularAccountV2StaticImpl = {
|
|
46
|
+
...semiModularAccountBase,
|
|
47
|
+
accountImplementation: lowerAddress(DefaultMAV2Address.SMAV2_BYTECODE),
|
|
48
|
+
factoryAddress: lowerAddress(DefaultMAV2Address.MAV2_FACTORY),
|
|
49
|
+
factoryAbi: accountFactoryAbi,
|
|
50
|
+
getFactoryData: (args: SemiModularAccountV2FactoryArgs) => {
|
|
51
|
+
return encodeFunctionData({
|
|
52
|
+
abi: accountFactoryAbi,
|
|
53
|
+
functionName: "createSemiModularAccount",
|
|
54
|
+
args: [args.owner, args.salt],
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
predictAccountAddress: (args: SemiModularAccountV2FactoryArgs) => {
|
|
58
|
+
return predictModularAccountV2Address({
|
|
59
|
+
factoryAddress: DefaultMAV2Address.MAV2_FACTORY,
|
|
60
|
+
implementationAddress: DefaultMAV2Address.SMAV2_BYTECODE,
|
|
61
|
+
type: "SMA",
|
|
62
|
+
salt: args.salt,
|
|
63
|
+
ownerAddress: args.owner,
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type SemiModularAccount7702StaticImpl = StaticSmartAccountImplementation<
|
|
69
|
+
true,
|
|
70
|
+
"0.7",
|
|
71
|
+
SemiModularAccountV2FactoryArgs,
|
|
72
|
+
typeof entryPoint07Abi,
|
|
73
|
+
typeof semiModularAccountBytecodeAbi,
|
|
74
|
+
typeof accountFactoryAbi
|
|
75
|
+
>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Static implementation logic for SemiModularAccount7702.
|
|
79
|
+
*
|
|
80
|
+
* TODO(v5): update JSDoc format when doc-gen supports structs or records.
|
|
81
|
+
*/
|
|
82
|
+
export const semiModularAccount7702StaticImpl: SemiModularAccount7702StaticImpl =
|
|
83
|
+
{
|
|
84
|
+
...semiModularAccountBase,
|
|
85
|
+
delegationAddress: lowerAddress(DefaultMAV2Address.SMAV2_7702),
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type WebAuthnModularAccountV2FactoryArgs = {
|
|
89
|
+
ownerPublicKey: Hex;
|
|
90
|
+
salt: bigint;
|
|
91
|
+
entityId: number;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type WebAuthnModularAccountV2StaticImpl =
|
|
95
|
+
StaticSmartAccountImplementation<
|
|
96
|
+
false,
|
|
97
|
+
"0.7",
|
|
98
|
+
WebAuthnModularAccountV2FactoryArgs,
|
|
99
|
+
typeof entryPoint07Abi,
|
|
100
|
+
typeof modularAccountAbi,
|
|
101
|
+
typeof webAuthnFactoryAbi
|
|
102
|
+
>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Static implementation logic for WebAuthnModularAccountV2.
|
|
106
|
+
*
|
|
107
|
+
* TODO(v5): update JSDoc format when doc-gen supports structs or records.
|
|
108
|
+
*/
|
|
109
|
+
export const webAuthnModularAccountV2StaticImpl: WebAuthnModularAccountV2StaticImpl =
|
|
110
|
+
{
|
|
111
|
+
entryPoint,
|
|
112
|
+
accountAbi: modularAccountAbi,
|
|
113
|
+
accountImplementation: lowerAddress(DefaultMAV2Address.MAV2),
|
|
114
|
+
factoryAddress: lowerAddress(DefaultMAV2Address.MAV2_FACTORY_WEBAUTHN),
|
|
115
|
+
factoryAbi: webAuthnFactoryAbi,
|
|
116
|
+
getFactoryData: (args: WebAuthnModularAccountV2FactoryArgs) => {
|
|
117
|
+
const { x, y } = parsePublicKey(args.ownerPublicKey);
|
|
118
|
+
return encodeFunctionData({
|
|
119
|
+
abi: webAuthnFactoryAbi,
|
|
120
|
+
functionName: "createWebAuthnAccount",
|
|
121
|
+
args: [x, y, args.salt, args.entityId],
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
predictAccountAddress: (args: WebAuthnModularAccountV2FactoryArgs) => {
|
|
125
|
+
return predictModularAccountV2Address({
|
|
126
|
+
factoryAddress: DefaultMAV2Address.MAV2_FACTORY_WEBAUTHN,
|
|
127
|
+
implementationAddress: DefaultMAV2Address.MAV2,
|
|
128
|
+
type: "WebAuthn",
|
|
129
|
+
salt: args.salt,
|
|
130
|
+
ownerPublicKey: args.ownerPublicKey,
|
|
131
|
+
entityId: args.entityId,
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
};
|