@startale-scs/aa-sdk 0.0.1
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/README.md +20 -0
- package/dist/_cjs/account/decorators/getFactoryData.js +36 -0
- package/dist/_cjs/account/decorators/getFactoryData.js.map +1 -0
- package/dist/_cjs/account/decorators/getStartaleAccountAddress.js +18 -0
- package/dist/_cjs/account/decorators/getStartaleAccountAddress.js.map +1 -0
- package/dist/_cjs/account/decorators/index.js +6 -0
- package/dist/_cjs/account/decorators/index.js.map +1 -0
- package/dist/_cjs/account/index.js +6 -0
- package/dist/_cjs/account/index.js.map +1 -0
- package/dist/_cjs/account/toStartaleSmartAccount.js +251 -0
- package/dist/_cjs/account/toStartaleSmartAccount.js.map +1 -0
- package/dist/_cjs/account/utils/AccountNotFound.js +18 -0
- package/dist/_cjs/account/utils/AccountNotFound.js.map +1 -0
- package/dist/_cjs/account/utils/Constants.js +128 -0
- package/dist/_cjs/account/utils/Constants.js.map +1 -0
- package/dist/_cjs/account/utils/Helpers.js +39 -0
- package/dist/_cjs/account/utils/Helpers.js.map +1 -0
- package/dist/_cjs/account/utils/Logger.js +35 -0
- package/dist/_cjs/account/utils/Logger.js.map +1 -0
- package/dist/_cjs/account/utils/Types.js +3 -0
- package/dist/_cjs/account/utils/Types.js.map +1 -0
- package/dist/_cjs/account/utils/Utils.js +258 -0
- package/dist/_cjs/account/utils/Utils.js.map +1 -0
- package/dist/_cjs/account/utils/contractSimulation.js +27 -0
- package/dist/_cjs/account/utils/contractSimulation.js.map +1 -0
- package/dist/_cjs/account/utils/deepHexlify.js +26 -0
- package/dist/_cjs/account/utils/deepHexlify.js.map +1 -0
- package/dist/_cjs/account/utils/fromBundlerClient.js +45 -0
- package/dist/_cjs/account/utils/fromBundlerClient.js.map +1 -0
- package/dist/_cjs/account/utils/getAAError.js +37 -0
- package/dist/_cjs/account/utils/getAAError.js.map +1 -0
- package/dist/_cjs/account/utils/getChain.js +66 -0
- package/dist/_cjs/account/utils/getChain.js.map +1 -0
- package/dist/_cjs/account/utils/getVersion.js +46 -0
- package/dist/_cjs/account/utils/getVersion.js.map +1 -0
- package/dist/_cjs/account/utils/index.js +27 -0
- package/dist/_cjs/account/utils/index.js.map +1 -0
- package/dist/_cjs/account/utils/parseErrorMessage.js +79 -0
- package/dist/_cjs/account/utils/parseErrorMessage.js.map +1 -0
- package/dist/_cjs/account/utils/tenderlySimulation.js +52 -0
- package/dist/_cjs/account/utils/tenderlySimulation.js.map +1 -0
- package/dist/_cjs/account/utils/toInitData.js +13 -0
- package/dist/_cjs/account/utils/toInitData.js.map +1 -0
- package/dist/_cjs/account/utils/toInstallData.js +15 -0
- package/dist/_cjs/account/utils/toInstallData.js.map +1 -0
- package/dist/_cjs/account/utils/toSigner.js +81 -0
- package/dist/_cjs/account/utils/toSigner.js.map +1 -0
- package/dist/_cjs/clients/createHttpClient.js +42 -0
- package/dist/_cjs/clients/createHttpClient.js.map +1 -0
- package/dist/_cjs/clients/createSCSBundlerClient.js +45 -0
- package/dist/_cjs/clients/createSCSBundlerClient.js.map +1 -0
- package/dist/_cjs/clients/createSCSPaymasterClient.js +39 -0
- package/dist/_cjs/clients/createSCSPaymasterClient.js.map +1 -0
- package/dist/_cjs/clients/decorators/bundler/getGasFeeValues.js +34 -0
- package/dist/_cjs/clients/decorators/bundler/getGasFeeValues.js.map +1 -0
- package/dist/_cjs/clients/decorators/bundler/getUserOperationStatus.js +10 -0
- package/dist/_cjs/clients/decorators/bundler/getUserOperationStatus.js.map +1 -0
- package/dist/_cjs/clients/decorators/bundler/index.js +15 -0
- package/dist/_cjs/clients/decorators/bundler/index.js.map +1 -0
- package/dist/_cjs/clients/decorators/bundler/waitForConfirmedUserOperationReceipt.js +27 -0
- package/dist/_cjs/clients/decorators/bundler/waitForConfirmedUserOperationReceipt.js.map +1 -0
- package/dist/_cjs/clients/decorators/bundler/waitForUserOperationReceipt.js +13 -0
- package/dist/_cjs/clients/decorators/bundler/waitForUserOperationReceipt.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/accountId.js +65 -0
- package/dist/_cjs/clients/decorators/erc7579/accountId.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/getActiveHook.js +43 -0
- package/dist/_cjs/clients/decorators/erc7579/getActiveHook.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/getFallbackBySelector.js +56 -0
- package/dist/_cjs/clients/decorators/erc7579/getFallbackBySelector.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/getInstalledExecutors.js +63 -0
- package/dist/_cjs/clients/decorators/erc7579/getInstalledExecutors.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/getInstalledValidators.js +61 -0
- package/dist/_cjs/clients/decorators/erc7579/getInstalledValidators.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/getPreviousModule.js +37 -0
- package/dist/_cjs/clients/decorators/erc7579/getPreviousModule.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/index.js +64 -0
- package/dist/_cjs/clients/decorators/erc7579/index.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/installModule.js +94 -0
- package/dist/_cjs/clients/decorators/erc7579/installModule.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/installModules.js +25 -0
- package/dist/_cjs/clients/decorators/erc7579/installModules.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/isModuleInstalled.js +90 -0
- package/dist/_cjs/clients/decorators/erc7579/isModuleInstalled.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/supportsExecutionMode.js +102 -0
- package/dist/_cjs/clients/decorators/erc7579/supportsExecutionMode.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/supportsModule.js +90 -0
- package/dist/_cjs/clients/decorators/erc7579/supportsModule.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/uninstallFallback.js +61 -0
- package/dist/_cjs/clients/decorators/erc7579/uninstallFallback.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/uninstallModule.js +79 -0
- package/dist/_cjs/clients/decorators/erc7579/uninstallModule.js.map +1 -0
- package/dist/_cjs/clients/decorators/erc7579/uninstallModules.js +26 -0
- package/dist/_cjs/clients/decorators/erc7579/uninstallModules.js.map +1 -0
- package/dist/_cjs/clients/decorators/index.js +8 -0
- package/dist/_cjs/clients/decorators/index.js.map +1 -0
- package/dist/_cjs/clients/decorators/smartAccount/debugUserOperation.js +75 -0
- package/dist/_cjs/clients/decorators/smartAccount/debugUserOperation.js.map +1 -0
- package/dist/_cjs/clients/decorators/smartAccount/index.js +32 -0
- package/dist/_cjs/clients/decorators/smartAccount/index.js.map +1 -0
- package/dist/_cjs/clients/decorators/smartAccount/prepareTokenPaymasterUserOp.js +32 -0
- package/dist/_cjs/clients/decorators/smartAccount/prepareTokenPaymasterUserOp.js.map +1 -0
- package/dist/_cjs/clients/decorators/smartAccount/prepareUserOperationWithoutSignature.js +35 -0
- package/dist/_cjs/clients/decorators/smartAccount/prepareUserOperationWithoutSignature.js.map +1 -0
- package/dist/_cjs/clients/decorators/smartAccount/sendTokenPaymasterUserOp.js +21 -0
- package/dist/_cjs/clients/decorators/smartAccount/sendTokenPaymasterUserOp.js.map +1 -0
- package/dist/_cjs/clients/decorators/smartAccount/sendTransaction.js +41 -0
- package/dist/_cjs/clients/decorators/smartAccount/sendTransaction.js.map +1 -0
- package/dist/_cjs/clients/decorators/smartAccount/signMessage.js +14 -0
- package/dist/_cjs/clients/decorators/smartAccount/signMessage.js.map +1 -0
- package/dist/_cjs/clients/decorators/smartAccount/signTypedData.js +31 -0
- package/dist/_cjs/clients/decorators/smartAccount/signTypedData.js.map +1 -0
- package/dist/_cjs/clients/decorators/smartAccount/upgradeSmartAccount.js +61 -0
- package/dist/_cjs/clients/decorators/smartAccount/upgradeSmartAccount.js.map +1 -0
- package/dist/_cjs/clients/decorators/smartAccount/waitForTransactionReceipt.js +17 -0
- package/dist/_cjs/clients/decorators/smartAccount/waitForTransactionReceipt.js.map +1 -0
- package/dist/_cjs/clients/decorators/smartAccount/writeContract.js +20 -0
- package/dist/_cjs/clients/decorators/smartAccount/writeContract.js.map +1 -0
- package/dist/_cjs/clients/decorators/tokenPaymaster/getSupportedTokens.js +25 -0
- package/dist/_cjs/clients/decorators/tokenPaymaster/getSupportedTokens.js.map +1 -0
- package/dist/_cjs/clients/decorators/tokenPaymaster/getTokenPaymasterQuotes.js +35 -0
- package/dist/_cjs/clients/decorators/tokenPaymaster/getTokenPaymasterQuotes.js.map +1 -0
- package/dist/_cjs/clients/decorators/tokenPaymaster/index.js +11 -0
- package/dist/_cjs/clients/decorators/tokenPaymaster/index.js.map +1 -0
- package/dist/_cjs/clients/index.js +8 -0
- package/dist/_cjs/clients/index.js.map +1 -0
- package/dist/_cjs/constants/abi/AccountFactory.js +337 -0
- package/dist/_cjs/constants/abi/AccountFactory.js.map +1 -0
- package/dist/_cjs/constants/abi/AccountImplementationAbi.js +1179 -0
- package/dist/_cjs/constants/abi/AccountImplementationAbi.js.map +1 -0
- package/dist/_cjs/constants/abi/BootstrapAbi.js +730 -0
- package/dist/_cjs/constants/abi/BootstrapAbi.js.map +1 -0
- package/dist/_cjs/constants/abi/ComposabilityAbi.js +274 -0
- package/dist/_cjs/constants/abi/ComposabilityAbi.js.map +1 -0
- package/dist/_cjs/constants/abi/EIP1271Abi.js +31 -0
- package/dist/_cjs/constants/abi/EIP1271Abi.js.map +1 -0
- package/dist/_cjs/constants/abi/ERC7484RegistryAbi.js +17 -0
- package/dist/_cjs/constants/abi/ERC7484RegistryAbi.js.map +1 -0
- package/dist/_cjs/constants/abi/EntryPointABI.js +661 -0
- package/dist/_cjs/constants/abi/EntryPointABI.js.map +1 -0
- package/dist/_cjs/constants/abi/SmartSessionAbi.js +1472 -0
- package/dist/_cjs/constants/abi/SmartSessionAbi.js.map +1 -0
- package/dist/_cjs/constants/abi/TokenWithPermitAbi.js +622 -0
- package/dist/_cjs/constants/abi/TokenWithPermitAbi.js.map +1 -0
- package/dist/_cjs/constants/abi/UniActionPolicyAbi.js +62 -0
- package/dist/_cjs/constants/abi/UniActionPolicyAbi.js.map +1 -0
- package/dist/_cjs/constants/abi/UniswapSwapRouterAbi.js +486 -0
- package/dist/_cjs/constants/abi/UniswapSwapRouterAbi.js.map +1 -0
- package/dist/_cjs/constants/abi/index.js +14 -0
- package/dist/_cjs/constants/abi/index.js.map +1 -0
- package/dist/_cjs/constants/index.js +62 -0
- package/dist/_cjs/constants/index.js.map +1 -0
- package/dist/_cjs/index.js +13 -0
- package/dist/_cjs/index.js.map +1 -0
- package/dist/_cjs/modules/index.js +8 -0
- package/dist/_cjs/modules/index.js.map +1 -0
- package/dist/_cjs/modules/toEmptyExecutor.js +10 -0
- package/dist/_cjs/modules/toEmptyExecutor.js.map +1 -0
- package/dist/_cjs/modules/toEmptyHook.js +10 -0
- package/dist/_cjs/modules/toEmptyHook.js.map +1 -0
- package/dist/_cjs/modules/utils/Helpers.js +59 -0
- package/dist/_cjs/modules/utils/Helpers.js.map +1 -0
- package/dist/_cjs/modules/utils/Types.js +15 -0
- package/dist/_cjs/modules/utils/Types.js.map +1 -0
- package/dist/_cjs/modules/utils/Uid.js +14 -0
- package/dist/_cjs/modules/utils/Uid.js.map +1 -0
- package/dist/_cjs/modules/utils/composabilityCalls.js +117 -0
- package/dist/_cjs/modules/utils/composabilityCalls.js.map +1 -0
- package/dist/_cjs/modules/utils/index.js +9 -0
- package/dist/_cjs/modules/utils/index.js.map +1 -0
- package/dist/_cjs/modules/utils/runtimeAbiEncoding.js +276 -0
- package/dist/_cjs/modules/utils/runtimeAbiEncoding.js.map +1 -0
- package/dist/_cjs/modules/utils/toModule.js +39 -0
- package/dist/_cjs/modules/utils/toModule.js.map +1 -0
- package/dist/_cjs/modules/validators/default/index.js +5 -0
- package/dist/_cjs/modules/validators/default/index.js.map +1 -0
- package/dist/_cjs/modules/validators/default/toDefaultModule.js +18 -0
- package/dist/_cjs/modules/validators/default/toDefaultModule.js.map +1 -0
- package/dist/_cjs/modules/validators/index.js +9 -0
- package/dist/_cjs/modules/validators/index.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/decorators/addOwner.js +44 -0
- package/dist/_cjs/modules/validators/ownable/decorators/addOwner.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/decorators/getAddOwnerTx.js +42 -0
- package/dist/_cjs/modules/validators/ownable/decorators/getAddOwnerTx.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/decorators/getOwners.js +28 -0
- package/dist/_cjs/modules/validators/ownable/decorators/getOwners.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/decorators/getRemoveOwnerTx.js +38 -0
- package/dist/_cjs/modules/validators/ownable/decorators/getRemoveOwnerTx.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/decorators/getSetThresholdTx.js +32 -0
- package/dist/_cjs/modules/validators/ownable/decorators/getSetThresholdTx.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/decorators/getThreshold.js +28 -0
- package/dist/_cjs/modules/validators/ownable/decorators/getThreshold.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/decorators/index.js +70 -0
- package/dist/_cjs/modules/validators/ownable/decorators/index.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/decorators/multiSign.js +25 -0
- package/dist/_cjs/modules/validators/ownable/decorators/multiSign.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/decorators/prepareForMultiSign.js +22 -0
- package/dist/_cjs/modules/validators/ownable/decorators/prepareForMultiSign.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/decorators/removeOwner.js +44 -0
- package/dist/_cjs/modules/validators/ownable/decorators/removeOwner.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/decorators/setThreshold.js +39 -0
- package/dist/_cjs/modules/validators/ownable/decorators/setThreshold.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/index.js +6 -0
- package/dist/_cjs/modules/validators/ownable/index.js.map +1 -0
- package/dist/_cjs/modules/validators/ownable/toOwnableModule.js +16 -0
- package/dist/_cjs/modules/validators/ownable/toOwnableModule.js.map +1 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/Helpers.js +124 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/Helpers.js.map +1 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/Types.js +13 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/Types.js.map +1 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/decorators/grantPermission.js +38 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/decorators/grantPermission.js.map +1 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/decorators/index.js +27 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/decorators/index.js.map +1 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/decorators/preparePermission.js +127 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/decorators/preparePermission.js.map +1 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/decorators/usePermission.js +16 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/decorators/usePermission.js.map +1 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/index.js +8 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/index.js.map +1 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/toSmartSessionsValidator.js +49 -0
- package/dist/_cjs/modules/validators/smartSessionsValidator/toSmartSessionsValidator.js.map +1 -0
- package/dist/_cjs/modules/validators/toValidator.js +21 -0
- package/dist/_cjs/modules/validators/toValidator.js.map +1 -0
- package/dist/_cjs/package.json +1 -0
- package/dist/_esm/account/decorators/getFactoryData.js +31 -0
- package/dist/_esm/account/decorators/getFactoryData.js.map +1 -0
- package/dist/_esm/account/decorators/getStartaleAccountAddress.js +31 -0
- package/dist/_esm/account/decorators/getStartaleAccountAddress.js.map +1 -0
- package/dist/_esm/account/decorators/index.js +3 -0
- package/dist/_esm/account/decorators/index.js.map +1 -0
- package/dist/_esm/account/index.js +3 -0
- package/dist/_esm/account/index.js.map +1 -0
- package/dist/_esm/account/toStartaleSmartAccount.js +327 -0
- package/dist/_esm/account/toStartaleSmartAccount.js.map +1 -0
- package/dist/_esm/account/utils/AccountNotFound.js +17 -0
- package/dist/_esm/account/utils/AccountNotFound.js.map +1 -0
- package/dist/_esm/account/utils/Constants.js +129 -0
- package/dist/_esm/account/utils/Constants.js.map +1 -0
- package/dist/_esm/account/utils/Helpers.js +45 -0
- package/dist/_esm/account/utils/Helpers.js.map +1 -0
- package/dist/_esm/account/utils/Logger.js +50 -0
- package/dist/_esm/account/utils/Logger.js.map +1 -0
- package/dist/_esm/account/utils/Types.js +2 -0
- package/dist/_esm/account/utils/Types.js.map +1 -0
- package/dist/_esm/account/utils/Utils.js +319 -0
- package/dist/_esm/account/utils/Utils.js.map +1 -0
- package/dist/_esm/account/utils/contractSimulation.js +48 -0
- package/dist/_esm/account/utils/contractSimulation.js.map +1 -0
- package/dist/_esm/account/utils/deepHexlify.js +63 -0
- package/dist/_esm/account/utils/deepHexlify.js.map +1 -0
- package/dist/_esm/account/utils/fromBundlerClient.js +67 -0
- package/dist/_esm/account/utils/fromBundlerClient.js.map +1 -0
- package/dist/_esm/account/utils/getAAError.js +34 -0
- package/dist/_esm/account/utils/getAAError.js.map +1 -0
- package/dist/_esm/account/utils/getChain.js +117 -0
- package/dist/_esm/account/utils/getChain.js.map +1 -0
- package/dist/_esm/account/utils/getVersion.js +163 -0
- package/dist/_esm/account/utils/getVersion.js.map +1 -0
- package/dist/_esm/account/utils/index.js +19 -0
- package/dist/_esm/account/utils/index.js.map +1 -0
- package/dist/_esm/account/utils/parseErrorMessage.js +89 -0
- package/dist/_esm/account/utils/parseErrorMessage.js.map +1 -0
- package/dist/_esm/account/utils/tenderlySimulation.js +47 -0
- package/dist/_esm/account/utils/tenderlySimulation.js.map +1 -0
- package/dist/_esm/account/utils/toInitData.js +14 -0
- package/dist/_esm/account/utils/toInitData.js.map +1 -0
- package/dist/_esm/account/utils/toInstallData.js +16 -0
- package/dist/_esm/account/utils/toInstallData.js.map +1 -0
- package/dist/_esm/account/utils/toSigner.js +91 -0
- package/dist/_esm/account/utils/toSigner.js.map +1 -0
- package/dist/_esm/clients/createHttpClient.js +43 -0
- package/dist/_esm/clients/createHttpClient.js.map +1 -0
- package/dist/_esm/clients/createSCSBundlerClient.js +56 -0
- package/dist/_esm/clients/createSCSBundlerClient.js.map +1 -0
- package/dist/_esm/clients/createSCSPaymasterClient.js +74 -0
- package/dist/_esm/clients/createSCSPaymasterClient.js.map +1 -0
- package/dist/_esm/clients/decorators/bundler/getGasFeeValues.js +53 -0
- package/dist/_esm/clients/decorators/bundler/getGasFeeValues.js.map +1 -0
- package/dist/_esm/clients/decorators/bundler/getUserOperationStatus.js +8 -0
- package/dist/_esm/clients/decorators/bundler/getUserOperationStatus.js.map +1 -0
- package/dist/_esm/clients/decorators/bundler/index.js +11 -0
- package/dist/_esm/clients/decorators/bundler/index.js.map +1 -0
- package/dist/_esm/clients/decorators/bundler/waitForConfirmedUserOperationReceipt.js +26 -0
- package/dist/_esm/clients/decorators/bundler/waitForConfirmedUserOperationReceipt.js.map +1 -0
- package/dist/_esm/clients/decorators/bundler/waitForUserOperationReceipt.js +10 -0
- package/dist/_esm/clients/decorators/bundler/waitForUserOperationReceipt.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/accountId.js +77 -0
- package/dist/_esm/clients/decorators/erc7579/accountId.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/getActiveHook.js +52 -0
- package/dist/_esm/clients/decorators/erc7579/getActiveHook.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/getFallbackBySelector.js +67 -0
- package/dist/_esm/clients/decorators/erc7579/getFallbackBySelector.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/getInstalledExecutors.js +74 -0
- package/dist/_esm/clients/decorators/erc7579/getInstalledExecutors.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/getInstalledValidators.js +72 -0
- package/dist/_esm/clients/decorators/erc7579/getInstalledValidators.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/getPreviousModule.js +54 -0
- package/dist/_esm/clients/decorators/erc7579/getPreviousModule.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/index.js +48 -0
- package/dist/_esm/clients/decorators/erc7579/index.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/installModule.js +109 -0
- package/dist/_esm/clients/decorators/erc7579/installModule.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/installModules.js +41 -0
- package/dist/_esm/clients/decorators/erc7579/installModules.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/isModuleInstalled.js +106 -0
- package/dist/_esm/clients/decorators/erc7579/isModuleInstalled.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/supportsExecutionMode.js +120 -0
- package/dist/_esm/clients/decorators/erc7579/supportsExecutionMode.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/supportsModule.js +108 -0
- package/dist/_esm/clients/decorators/erc7579/supportsModule.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/uninstallFallback.js +76 -0
- package/dist/_esm/clients/decorators/erc7579/uninstallFallback.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/uninstallModule.js +94 -0
- package/dist/_esm/clients/decorators/erc7579/uninstallModule.js.map +1 -0
- package/dist/_esm/clients/decorators/erc7579/uninstallModules.js +42 -0
- package/dist/_esm/clients/decorators/erc7579/uninstallModules.js.map +1 -0
- package/dist/_esm/clients/decorators/index.js +5 -0
- package/dist/_esm/clients/decorators/index.js.map +1 -0
- package/dist/_esm/clients/decorators/smartAccount/debugUserOperation.js +105 -0
- package/dist/_esm/clients/decorators/smartAccount/debugUserOperation.js.map +1 -0
- package/dist/_esm/clients/decorators/smartAccount/index.js +28 -0
- package/dist/_esm/clients/decorators/smartAccount/index.js.map +1 -0
- package/dist/_esm/clients/decorators/smartAccount/prepareTokenPaymasterUserOp.js +60 -0
- package/dist/_esm/clients/decorators/smartAccount/prepareTokenPaymasterUserOp.js.map +1 -0
- package/dist/_esm/clients/decorators/smartAccount/prepareUserOperationWithoutSignature.js +36 -0
- package/dist/_esm/clients/decorators/smartAccount/prepareUserOperationWithoutSignature.js.map +1 -0
- package/dist/_esm/clients/decorators/smartAccount/sendTokenPaymasterUserOp.js +44 -0
- package/dist/_esm/clients/decorators/smartAccount/sendTokenPaymasterUserOp.js.map +1 -0
- package/dist/_esm/clients/decorators/smartAccount/sendTransaction.js +57 -0
- package/dist/_esm/clients/decorators/smartAccount/sendTransaction.js.map +1 -0
- package/dist/_esm/clients/decorators/smartAccount/signMessage.js +30 -0
- package/dist/_esm/clients/decorators/smartAccount/signMessage.js.map +1 -0
- package/dist/_esm/clients/decorators/smartAccount/signTypedData.js +82 -0
- package/dist/_esm/clients/decorators/smartAccount/signTypedData.js.map +1 -0
- package/dist/_esm/clients/decorators/smartAccount/upgradeSmartAccount.js +75 -0
- package/dist/_esm/clients/decorators/smartAccount/upgradeSmartAccount.js.map +1 -0
- package/dist/_esm/clients/decorators/smartAccount/waitForTransactionReceipt.js +14 -0
- package/dist/_esm/clients/decorators/smartAccount/waitForTransactionReceipt.js.map +1 -0
- package/dist/_esm/clients/decorators/smartAccount/writeContract.js +40 -0
- package/dist/_esm/clients/decorators/smartAccount/writeContract.js.map +1 -0
- package/dist/_esm/clients/decorators/tokenPaymaster/getSupportedTokens.js +35 -0
- package/dist/_esm/clients/decorators/tokenPaymaster/getSupportedTokens.js.map +1 -0
- package/dist/_esm/clients/decorators/tokenPaymaster/getTokenPaymasterQuotes.js +70 -0
- package/dist/_esm/clients/decorators/tokenPaymaster/getTokenPaymasterQuotes.js.map +1 -0
- package/dist/_esm/clients/decorators/tokenPaymaster/index.js +63 -0
- package/dist/_esm/clients/decorators/tokenPaymaster/index.js.map +1 -0
- package/dist/_esm/clients/index.js +5 -0
- package/dist/_esm/clients/index.js.map +1 -0
- package/dist/_esm/constants/abi/AccountFactory.js +334 -0
- package/dist/_esm/constants/abi/AccountFactory.js.map +1 -0
- package/dist/_esm/constants/abi/AccountImplementationAbi.js +1176 -0
- package/dist/_esm/constants/abi/AccountImplementationAbi.js.map +1 -0
- package/dist/_esm/constants/abi/BootstrapAbi.js +727 -0
- package/dist/_esm/constants/abi/BootstrapAbi.js.map +1 -0
- package/dist/_esm/constants/abi/ComposabilityAbi.js +271 -0
- package/dist/_esm/constants/abi/ComposabilityAbi.js.map +1 -0
- package/dist/_esm/constants/abi/EIP1271Abi.js +28 -0
- package/dist/_esm/constants/abi/EIP1271Abi.js.map +1 -0
- package/dist/_esm/constants/abi/ERC7484RegistryAbi.js +14 -0
- package/dist/_esm/constants/abi/ERC7484RegistryAbi.js.map +1 -0
- package/dist/_esm/constants/abi/EntryPointABI.js +658 -0
- package/dist/_esm/constants/abi/EntryPointABI.js.map +1 -0
- package/dist/_esm/constants/abi/SmartSessionAbi.js +1469 -0
- package/dist/_esm/constants/abi/SmartSessionAbi.js.map +1 -0
- package/dist/_esm/constants/abi/TokenWithPermitAbi.js +619 -0
- package/dist/_esm/constants/abi/TokenWithPermitAbi.js.map +1 -0
- package/dist/_esm/constants/abi/UniActionPolicyAbi.js +59 -0
- package/dist/_esm/constants/abi/UniActionPolicyAbi.js.map +1 -0
- package/dist/_esm/constants/abi/UniswapSwapRouterAbi.js +483 -0
- package/dist/_esm/constants/abi/UniswapSwapRouterAbi.js.map +1 -0
- package/dist/_esm/constants/abi/index.js +11 -0
- package/dist/_esm/constants/abi/index.js.map +1 -0
- package/dist/_esm/constants/index.js +29 -0
- package/dist/_esm/constants/index.js.map +1 -0
- package/dist/_esm/index.js +12 -0
- package/dist/_esm/index.js.map +1 -0
- package/dist/_esm/modules/index.js +6 -0
- package/dist/_esm/modules/index.js.map +1 -0
- package/dist/_esm/modules/toEmptyExecutor.js +6 -0
- package/dist/_esm/modules/toEmptyExecutor.js.map +1 -0
- package/dist/_esm/modules/toEmptyHook.js +6 -0
- package/dist/_esm/modules/toEmptyHook.js.map +1 -0
- package/dist/_esm/modules/utils/Helpers.js +81 -0
- package/dist/_esm/modules/utils/Helpers.js.map +1 -0
- package/dist/_esm/modules/utils/Types.js +12 -0
- package/dist/_esm/modules/utils/Types.js.map +1 -0
- package/dist/_esm/modules/utils/Uid.js +11 -0
- package/dist/_esm/modules/utils/Uid.js.map +1 -0
- package/dist/_esm/modules/utils/composabilityCalls.js +127 -0
- package/dist/_esm/modules/utils/composabilityCalls.js.map +1 -0
- package/dist/_esm/modules/utils/index.js +6 -0
- package/dist/_esm/modules/utils/index.js.map +1 -0
- package/dist/_esm/modules/utils/runtimeAbiEncoding.js +365 -0
- package/dist/_esm/modules/utils/runtimeAbiEncoding.js.map +1 -0
- package/dist/_esm/modules/utils/toModule.js +61 -0
- package/dist/_esm/modules/utils/toModule.js.map +1 -0
- package/dist/_esm/modules/validators/default/index.js +2 -0
- package/dist/_esm/modules/validators/default/index.js.map +1 -0
- package/dist/_esm/modules/validators/default/toDefaultModule.js +14 -0
- package/dist/_esm/modules/validators/default/toDefaultModule.js.map +1 -0
- package/dist/_esm/modules/validators/index.js +6 -0
- package/dist/_esm/modules/validators/index.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/decorators/addOwner.js +52 -0
- package/dist/_esm/modules/validators/ownable/decorators/addOwner.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/decorators/getAddOwnerTx.js +50 -0
- package/dist/_esm/modules/validators/ownable/decorators/getAddOwnerTx.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/decorators/getOwners.js +38 -0
- package/dist/_esm/modules/validators/ownable/decorators/getOwners.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/decorators/getRemoveOwnerTx.js +46 -0
- package/dist/_esm/modules/validators/ownable/decorators/getRemoveOwnerTx.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/decorators/getSetThresholdTx.js +48 -0
- package/dist/_esm/modules/validators/ownable/decorators/getSetThresholdTx.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/decorators/getThreshold.js +54 -0
- package/dist/_esm/modules/validators/ownable/decorators/getThreshold.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/decorators/index.js +57 -0
- package/dist/_esm/modules/validators/ownable/decorators/index.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/decorators/multiSign.js +22 -0
- package/dist/_esm/modules/validators/ownable/decorators/multiSign.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/decorators/prepareForMultiSign.js +21 -0
- package/dist/_esm/modules/validators/ownable/decorators/prepareForMultiSign.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/decorators/removeOwner.js +63 -0
- package/dist/_esm/modules/validators/ownable/decorators/removeOwner.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/decorators/setThreshold.js +62 -0
- package/dist/_esm/modules/validators/ownable/decorators/setThreshold.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/index.js +3 -0
- package/dist/_esm/modules/validators/ownable/index.js.map +1 -0
- package/dist/_esm/modules/validators/ownable/toOwnableModule.js +38 -0
- package/dist/_esm/modules/validators/ownable/toOwnableModule.js.map +1 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/Helpers.js +173 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/Helpers.js.map +1 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/Types.js +13 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/Types.js.map +1 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/decorators/grantPermission.js +79 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/decorators/grantPermission.js.map +1 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/decorators/index.js +40 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/decorators/index.js.map +1 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/decorators/preparePermission.js +191 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/decorators/preparePermission.js.map +1 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/decorators/usePermission.js +47 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/decorators/usePermission.js.map +1 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/index.js +5 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/index.js.map +1 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/toSmartSessionsValidator.js +82 -0
- package/dist/_esm/modules/validators/smartSessionsValidator/toSmartSessionsValidator.js.map +1 -0
- package/dist/_esm/modules/validators/toValidator.js +17 -0
- package/dist/_esm/modules/validators/toValidator.js.map +1 -0
- package/dist/_esm/package.json +1 -0
- package/dist/_types/account/decorators/getFactoryData.d.ts +25 -0
- package/dist/_types/account/decorators/getFactoryData.d.ts.map +1 -0
- package/dist/_types/account/decorators/getStartaleAccountAddress.d.ts +33 -0
- package/dist/_types/account/decorators/getStartaleAccountAddress.d.ts.map +1 -0
- package/dist/_types/account/decorators/index.d.ts +3 -0
- package/dist/_types/account/decorators/index.d.ts.map +1 -0
- package/dist/_types/account/index.d.ts +3 -0
- package/dist/_types/account/index.d.ts.map +1 -0
- package/dist/_types/account/toStartaleSmartAccount.d.ts +110 -0
- package/dist/_types/account/toStartaleSmartAccount.d.ts.map +1 -0
- package/dist/_types/account/utils/AccountNotFound.d.ts +10 -0
- package/dist/_types/account/utils/AccountNotFound.d.ts.map +1 -0
- package/dist/_types/account/utils/Constants.d.ts +73 -0
- package/dist/_types/account/utils/Constants.d.ts.map +1 -0
- package/dist/_types/account/utils/Helpers.d.ts +21 -0
- package/dist/_types/account/utils/Helpers.d.ts.map +1 -0
- package/dist/_types/account/utils/Logger.d.ts +20 -0
- package/dist/_types/account/utils/Logger.d.ts.map +1 -0
- package/dist/_types/account/utils/Types.d.ts +94 -0
- package/dist/_types/account/utils/Types.d.ts.map +1 -0
- package/dist/_types/account/utils/Utils.d.ts +129 -0
- package/dist/_types/account/utils/Utils.d.ts.map +1 -0
- package/dist/_types/account/utils/contractSimulation.d.ts +801 -0
- package/dist/_types/account/utils/contractSimulation.d.ts.map +1 -0
- package/dist/_types/account/utils/deepHexlify.d.ts +41 -0
- package/dist/_types/account/utils/deepHexlify.d.ts.map +1 -0
- package/dist/_types/account/utils/fromBundlerClient.d.ts +50 -0
- package/dist/_types/account/utils/fromBundlerClient.d.ts.map +1 -0
- package/dist/_types/account/utils/getAAError.d.ts +17 -0
- package/dist/_types/account/utils/getAAError.d.ts.map +1 -0
- package/dist/_types/account/utils/getChain.d.ts +64 -0
- package/dist/_types/account/utils/getChain.d.ts.map +1 -0
- package/dist/_types/account/utils/getVersion.d.ts +135 -0
- package/dist/_types/account/utils/getVersion.d.ts.map +1 -0
- package/dist/_types/account/utils/index.d.ts +19 -0
- package/dist/_types/account/utils/index.d.ts.map +1 -0
- package/dist/_types/account/utils/parseErrorMessage.d.ts +2 -0
- package/dist/_types/account/utils/parseErrorMessage.d.ts.map +1 -0
- package/dist/_types/account/utils/tenderlySimulation.d.ts +13 -0
- package/dist/_types/account/utils/tenderlySimulation.d.ts.map +1 -0
- package/dist/_types/account/utils/toInitData.d.ts +12 -0
- package/dist/_types/account/utils/toInitData.d.ts.map +1 -0
- package/dist/_types/account/utils/toInstallData.d.ts +8 -0
- package/dist/_types/account/utils/toInstallData.d.ts.map +1 -0
- package/dist/_types/account/utils/toSigner.d.ts +26 -0
- package/dist/_types/account/utils/toSigner.d.ts.map +1 -0
- package/dist/_types/clients/createHttpClient.d.ts +44 -0
- package/dist/_types/clients/createHttpClient.d.ts.map +1 -0
- package/dist/_types/clients/createSCSBundlerClient.d.ts +66 -0
- package/dist/_types/clients/createSCSBundlerClient.d.ts.map +1 -0
- package/dist/_types/clients/createSCSPaymasterClient.d.ts +71 -0
- package/dist/_types/clients/createSCSPaymasterClient.d.ts.map +1 -0
- package/dist/_types/clients/decorators/bundler/getGasFeeValues.d.ts +51 -0
- package/dist/_types/clients/decorators/bundler/getGasFeeValues.d.ts.map +1 -0
- package/dist/_types/clients/decorators/bundler/getUserOperationStatus.d.ts +17 -0
- package/dist/_types/clients/decorators/bundler/getUserOperationStatus.d.ts.map +1 -0
- package/dist/_types/clients/decorators/bundler/index.d.ts +61 -0
- package/dist/_types/clients/decorators/bundler/index.d.ts.map +1 -0
- package/dist/_types/clients/decorators/bundler/waitForConfirmedUserOperationReceipt.d.ts +8 -0
- package/dist/_types/clients/decorators/bundler/waitForConfirmedUserOperationReceipt.d.ts.map +1 -0
- package/dist/_types/clients/decorators/bundler/waitForUserOperationReceipt.d.ts +5 -0
- package/dist/_types/clients/decorators/bundler/waitForUserOperationReceipt.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/accountId.d.ts +21 -0
- package/dist/_types/clients/decorators/erc7579/accountId.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/getActiveHook.d.ts +35 -0
- package/dist/_types/clients/decorators/erc7579/getActiveHook.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/getFallbackBySelector.d.ts +43 -0
- package/dist/_types/clients/decorators/erc7579/getFallbackBySelector.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/getInstalledExecutors.d.ts +52 -0
- package/dist/_types/clients/decorators/erc7579/getInstalledExecutors.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/getInstalledValidators.d.ts +52 -0
- package/dist/_types/clients/decorators/erc7579/getInstalledValidators.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/getPreviousModule.d.ts +32 -0
- package/dist/_types/clients/decorators/erc7579/getPreviousModule.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/index.d.ts +165 -0
- package/dist/_types/clients/decorators/erc7579/index.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/installModule.d.ts +36 -0
- package/dist/_types/clients/decorators/erc7579/installModule.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/installModules.d.ts +36 -0
- package/dist/_types/clients/decorators/erc7579/installModules.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/isModuleInstalled.d.ts +54 -0
- package/dist/_types/clients/decorators/erc7579/isModuleInstalled.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/supportsExecutionMode.d.ts +54 -0
- package/dist/_types/clients/decorators/erc7579/supportsExecutionMode.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/supportsModule.d.ts +48 -0
- package/dist/_types/clients/decorators/erc7579/supportsModule.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/uninstallFallback.d.ts +35 -0
- package/dist/_types/clients/decorators/erc7579/uninstallFallback.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/uninstallModule.d.ts +35 -0
- package/dist/_types/clients/decorators/erc7579/uninstallModule.d.ts.map +1 -0
- package/dist/_types/clients/decorators/erc7579/uninstallModules.d.ts +32 -0
- package/dist/_types/clients/decorators/erc7579/uninstallModules.d.ts.map +1 -0
- package/dist/_types/clients/decorators/index.d.ts +5 -0
- package/dist/_types/clients/decorators/index.d.ts.map +1 -0
- package/dist/_types/clients/decorators/smartAccount/debugUserOperation.d.ts +35 -0
- package/dist/_types/clients/decorators/smartAccount/debugUserOperation.d.ts.map +1 -0
- package/dist/_types/clients/decorators/smartAccount/index.d.ts +315 -0
- package/dist/_types/clients/decorators/smartAccount/index.d.ts.map +1 -0
- package/dist/_types/clients/decorators/smartAccount/prepareTokenPaymasterUserOp.d.ts +51 -0
- package/dist/_types/clients/decorators/smartAccount/prepareTokenPaymasterUserOp.d.ts.map +1 -0
- package/dist/_types/clients/decorators/smartAccount/prepareUserOperationWithoutSignature.d.ts +16 -0
- package/dist/_types/clients/decorators/smartAccount/prepareUserOperationWithoutSignature.d.ts.map +1 -0
- package/dist/_types/clients/decorators/smartAccount/sendTokenPaymasterUserOp.d.ts +36 -0
- package/dist/_types/clients/decorators/smartAccount/sendTokenPaymasterUserOp.d.ts.map +1 -0
- package/dist/_types/clients/decorators/smartAccount/sendTransaction.d.ts +23 -0
- package/dist/_types/clients/decorators/smartAccount/sendTransaction.d.ts.map +1 -0
- package/dist/_types/clients/decorators/smartAccount/signMessage.d.ts +23 -0
- package/dist/_types/clients/decorators/smartAccount/signMessage.d.ts.map +1 -0
- package/dist/_types/clients/decorators/smartAccount/signTypedData.d.ts +60 -0
- package/dist/_types/clients/decorators/smartAccount/signTypedData.d.ts.map +1 -0
- package/dist/_types/clients/decorators/smartAccount/upgradeSmartAccount.d.ts +40 -0
- package/dist/_types/clients/decorators/smartAccount/upgradeSmartAccount.d.ts.map +1 -0
- package/dist/_types/clients/decorators/smartAccount/waitForTransactionReceipt.d.ts +6 -0
- package/dist/_types/clients/decorators/smartAccount/waitForTransactionReceipt.d.ts.map +1 -0
- package/dist/_types/clients/decorators/smartAccount/writeContract.d.ts +27 -0
- package/dist/_types/clients/decorators/smartAccount/writeContract.d.ts.map +1 -0
- package/dist/_types/clients/decorators/tokenPaymaster/getSupportedTokens.d.ts +16 -0
- package/dist/_types/clients/decorators/tokenPaymaster/getSupportedTokens.d.ts.map +1 -0
- package/dist/_types/clients/decorators/tokenPaymaster/getTokenPaymasterQuotes.d.ts +88 -0
- package/dist/_types/clients/decorators/tokenPaymaster/getTokenPaymasterQuotes.d.ts.map +1 -0
- package/dist/_types/clients/decorators/tokenPaymaster/index.d.ts +65 -0
- package/dist/_types/clients/decorators/tokenPaymaster/index.d.ts.map +1 -0
- package/dist/_types/clients/index.d.ts +5 -0
- package/dist/_types/clients/index.d.ts.map +1 -0
- package/dist/_types/constants/abi/AccountFactory.d.ts +259 -0
- package/dist/_types/constants/abi/AccountFactory.d.ts.map +1 -0
- package/dist/_types/constants/abi/AccountImplementationAbi.d.ts +903 -0
- package/dist/_types/constants/abi/AccountImplementationAbi.d.ts.map +1 -0
- package/dist/_types/constants/abi/BootstrapAbi.d.ts +554 -0
- package/dist/_types/constants/abi/BootstrapAbi.d.ts.map +1 -0
- package/dist/_types/constants/abi/ComposabilityAbi.d.ts +67 -0
- package/dist/_types/constants/abi/ComposabilityAbi.d.ts.map +1 -0
- package/dist/_types/constants/abi/EIP1271Abi.d.ts +54 -0
- package/dist/_types/constants/abi/EIP1271Abi.d.ts.map +1 -0
- package/dist/_types/constants/abi/ERC7484RegistryAbi.d.ts +16 -0
- package/dist/_types/constants/abi/ERC7484RegistryAbi.d.ts.map +1 -0
- package/dist/_types/constants/abi/EntryPointABI.d.ts +776 -0
- package/dist/_types/constants/abi/EntryPointABI.d.ts.map +1 -0
- package/dist/_types/constants/abi/SmartSessionAbi.d.ts +90 -0
- package/dist/_types/constants/abi/SmartSessionAbi.d.ts.map +1 -0
- package/dist/_types/constants/abi/TokenWithPermitAbi.d.ts +477 -0
- package/dist/_types/constants/abi/TokenWithPermitAbi.d.ts.map +1 -0
- package/dist/_types/constants/abi/UniActionPolicyAbi.d.ts +33 -0
- package/dist/_types/constants/abi/UniActionPolicyAbi.d.ts.map +1 -0
- package/dist/_types/constants/abi/UniswapSwapRouterAbi.d.ts +821 -0
- package/dist/_types/constants/abi/UniswapSwapRouterAbi.d.ts.map +1 -0
- package/dist/_types/constants/abi/index.d.ts +11 -0
- package/dist/_types/constants/abi/index.d.ts.map +1 -0
- package/dist/_types/constants/index.d.ts +16 -0
- package/dist/_types/constants/index.d.ts.map +1 -0
- package/dist/_types/index.d.ts +7 -0
- package/dist/_types/index.d.ts.map +1 -0
- package/dist/_types/modules/index.d.ts +6 -0
- package/dist/_types/modules/index.d.ts.map +1 -0
- package/dist/_types/modules/toEmptyExecutor.d.ts +3 -0
- package/dist/_types/modules/toEmptyExecutor.d.ts.map +1 -0
- package/dist/_types/modules/toEmptyHook.d.ts +3 -0
- package/dist/_types/modules/toEmptyHook.d.ts.map +1 -0
- package/dist/_types/modules/utils/Helpers.d.ts +48 -0
- package/dist/_types/modules/utils/Helpers.d.ts.map +1 -0
- package/dist/_types/modules/utils/Types.d.ts +103 -0
- package/dist/_types/modules/utils/Types.d.ts.map +1 -0
- package/dist/_types/modules/utils/Uid.d.ts +2 -0
- package/dist/_types/modules/utils/Uid.d.ts.map +1 -0
- package/dist/_types/modules/utils/composabilityCalls.d.ts +63 -0
- package/dist/_types/modules/utils/composabilityCalls.d.ts.map +1 -0
- package/dist/_types/modules/utils/index.d.ts +6 -0
- package/dist/_types/modules/utils/index.d.ts.map +1 -0
- package/dist/_types/modules/utils/runtimeAbiEncoding.d.ts +18 -0
- package/dist/_types/modules/utils/runtimeAbiEncoding.d.ts.map +1 -0
- package/dist/_types/modules/utils/toModule.d.ts +28 -0
- package/dist/_types/modules/utils/toModule.d.ts.map +1 -0
- package/dist/_types/modules/validators/default/index.d.ts +2 -0
- package/dist/_types/modules/validators/default/index.d.ts.map +1 -0
- package/dist/_types/modules/validators/default/toDefaultModule.d.ts +3 -0
- package/dist/_types/modules/validators/default/toDefaultModule.d.ts.map +1 -0
- package/dist/_types/modules/validators/index.d.ts +6 -0
- package/dist/_types/modules/validators/index.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/decorators/addOwner.d.ts +36 -0
- package/dist/_types/modules/validators/ownable/decorators/addOwner.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/decorators/getAddOwnerTx.d.ts +30 -0
- package/dist/_types/modules/validators/ownable/decorators/getAddOwnerTx.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/decorators/getOwners.d.ts +25 -0
- package/dist/_types/modules/validators/ownable/decorators/getOwners.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/decorators/getRemoveOwnerTx.d.ts +30 -0
- package/dist/_types/modules/validators/ownable/decorators/getRemoveOwnerTx.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/decorators/getSetThresholdTx.d.ts +39 -0
- package/dist/_types/modules/validators/ownable/decorators/getSetThresholdTx.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/decorators/getThreshold.d.ts +40 -0
- package/dist/_types/modules/validators/ownable/decorators/getThreshold.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/decorators/index.d.ts +37 -0
- package/dist/_types/modules/validators/ownable/decorators/index.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/decorators/multiSign.d.ts +11 -0
- package/dist/_types/modules/validators/ownable/decorators/multiSign.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/decorators/prepareForMultiSign.d.ts +25 -0
- package/dist/_types/modules/validators/ownable/decorators/prepareForMultiSign.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/decorators/removeOwner.d.ts +47 -0
- package/dist/_types/modules/validators/ownable/decorators/removeOwner.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/decorators/setThreshold.d.ts +51 -0
- package/dist/_types/modules/validators/ownable/decorators/setThreshold.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/index.d.ts +3 -0
- package/dist/_types/modules/validators/ownable/index.d.ts.map +1 -0
- package/dist/_types/modules/validators/ownable/toOwnableModule.d.ts +44 -0
- package/dist/_types/modules/validators/ownable/toOwnableModule.d.ts.map +1 -0
- package/dist/_types/modules/validators/smartSessionsValidator/Helpers.d.ts +110 -0
- package/dist/_types/modules/validators/smartSessionsValidator/Helpers.d.ts.map +1 -0
- package/dist/_types/modules/validators/smartSessionsValidator/Types.d.ts +223 -0
- package/dist/_types/modules/validators/smartSessionsValidator/Types.d.ts.map +1 -0
- package/dist/_types/modules/validators/smartSessionsValidator/decorators/grantPermission.d.ts +73 -0
- package/dist/_types/modules/validators/smartSessionsValidator/decorators/grantPermission.d.ts.map +1 -0
- package/dist/_types/modules/validators/smartSessionsValidator/decorators/index.d.ts +70 -0
- package/dist/_types/modules/validators/smartSessionsValidator/decorators/index.d.ts.map +1 -0
- package/dist/_types/modules/validators/smartSessionsValidator/decorators/preparePermission.d.ts +81 -0
- package/dist/_types/modules/validators/smartSessionsValidator/decorators/preparePermission.d.ts.map +1 -0
- package/dist/_types/modules/validators/smartSessionsValidator/decorators/usePermission.d.ts +63 -0
- package/dist/_types/modules/validators/smartSessionsValidator/decorators/usePermission.d.ts.map +1 -0
- package/dist/_types/modules/validators/smartSessionsValidator/index.d.ts +5 -0
- package/dist/_types/modules/validators/smartSessionsValidator/index.d.ts.map +1 -0
- package/dist/_types/modules/validators/smartSessionsValidator/toSmartSessionsValidator.d.ts +65 -0
- package/dist/_types/modules/validators/smartSessionsValidator/toSmartSessionsValidator.d.ts.map +1 -0
- package/dist/_types/modules/validators/toValidator.d.ts +45 -0
- package/dist/_types/modules/validators/toValidator.d.ts.map +1 -0
- package/package.json +134 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toEmptyExecutor.js","sourceRoot":"","sources":["../../../src/sdk/modules/toEmptyExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAG5C,MAAM,CAAC,MAAM,eAAe,GAAG,GAAiB,EAAE,CAAC,CAAC;IAClD,MAAM,EAAE,WAAW;IACnB,IAAI,EAAE,QAAQ;CACf,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toEmptyHook.js","sourceRoot":"","sources":["../../../src/sdk/modules/toEmptyHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAG5C,MAAM,CAAC,MAAM,WAAW,GAAG,GAAiB,EAAE,CAAC,CAAC;IAC9C,MAAM,EAAE,WAAW;IACnB,IAAI,EAAE,QAAQ;CACf,CAAC,CAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { isHex, pad, toHex } from "viem";
|
|
2
|
+
import { ERROR_MESSAGES } from "../../account/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Parses a reference value into a 32-byte hex string.
|
|
5
|
+
* Handles various input types including Ethereum addresses, numbers, booleans, and raw hex values.
|
|
6
|
+
*
|
|
7
|
+
* @param referenceValue - The value to convert to hex
|
|
8
|
+
* @returns A 32-byte hex string (66 characters including '0x' prefix)
|
|
9
|
+
*
|
|
10
|
+
* @throws {Error} If the resulting hex string is invalid or not 32 bytes
|
|
11
|
+
*/
|
|
12
|
+
export function parseReferenceValue(referenceValue) {
|
|
13
|
+
let result;
|
|
14
|
+
// Handle 20-byte Ethereum address
|
|
15
|
+
if (isHex(referenceValue) && referenceValue.length === 42) {
|
|
16
|
+
// Remove '0x' prefix, pad to 32 bytes (64 characters) on the left, then add '0x' prefix back
|
|
17
|
+
result = `0x${"0".repeat(24)}${referenceValue.slice(2)}`;
|
|
18
|
+
}
|
|
19
|
+
else if (referenceValue?.raw) {
|
|
20
|
+
result = referenceValue?.raw;
|
|
21
|
+
}
|
|
22
|
+
else if (typeof referenceValue === "bigint") {
|
|
23
|
+
result = pad(toHex(referenceValue), { size: 32 });
|
|
24
|
+
}
|
|
25
|
+
else if (typeof referenceValue === "number") {
|
|
26
|
+
result = pad(toHex(BigInt(referenceValue)), { size: 32 });
|
|
27
|
+
}
|
|
28
|
+
else if (typeof referenceValue === "boolean") {
|
|
29
|
+
result = pad(toHex(referenceValue), { size: 32 });
|
|
30
|
+
}
|
|
31
|
+
else if (isHex(referenceValue)) {
|
|
32
|
+
// review
|
|
33
|
+
result = referenceValue;
|
|
34
|
+
}
|
|
35
|
+
else if (typeof referenceValue === "string") {
|
|
36
|
+
result = pad(referenceValue, { size: 32 });
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// (typeof referenceValue === "object")
|
|
40
|
+
result = pad(toHex(referenceValue), { size: 32 });
|
|
41
|
+
}
|
|
42
|
+
if (!isHex(result) || result.length !== 66) {
|
|
43
|
+
throw new Error(ERROR_MESSAGES.INVALID_HEX);
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Extracts and validates the active module from a client's account.
|
|
49
|
+
*
|
|
50
|
+
* @param client - The viem Client instance with an optional modular smart account
|
|
51
|
+
* @returns The active module from the account
|
|
52
|
+
*
|
|
53
|
+
* @throws {Error} If no module is currently activated
|
|
54
|
+
*/
|
|
55
|
+
export const parseModule = (client) => {
|
|
56
|
+
const activeModule = client?.account?.getModule();
|
|
57
|
+
if (!activeModule) {
|
|
58
|
+
throw new Error(ERROR_MESSAGES.MODULE_NOT_ACTIVATED);
|
|
59
|
+
}
|
|
60
|
+
return activeModule;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Sanitizes an ECDSA signature by ensuring the 'v' value is either 27 or 28.
|
|
64
|
+
* Also ensures the signature has a '0x' prefix.
|
|
65
|
+
*
|
|
66
|
+
* @param signature - The hex signature to sanitize
|
|
67
|
+
* @returns A properly formatted signature with correct 'v' value
|
|
68
|
+
*/
|
|
69
|
+
export function sanitizeSignature(signature) {
|
|
70
|
+
let signature_ = signature;
|
|
71
|
+
const potentiallyIncorrectV = Number.parseInt(signature_.slice(-2), 16);
|
|
72
|
+
if (![27, 28].includes(potentiallyIncorrectV)) {
|
|
73
|
+
const correctV = potentiallyIncorrectV + 27;
|
|
74
|
+
signature_ = signature_.slice(0, -2) + correctV.toString(16);
|
|
75
|
+
}
|
|
76
|
+
if (signature.slice(0, 2) !== "0x") {
|
|
77
|
+
signature_ = `0x${signature_}`;
|
|
78
|
+
}
|
|
79
|
+
return signature_;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=Helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../../src/sdk/modules/utils/Helpers.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var SafeHookType;
|
|
2
|
+
(function (SafeHookType) {
|
|
3
|
+
SafeHookType[SafeHookType["GLOBAL"] = 0] = "GLOBAL";
|
|
4
|
+
SafeHookType[SafeHookType["SIG"] = 1] = "SIG";
|
|
5
|
+
})(SafeHookType || (SafeHookType = {}));
|
|
6
|
+
export const moduleTypeIds = {
|
|
7
|
+
validator: 1,
|
|
8
|
+
executor: 2,
|
|
9
|
+
fallback: 3,
|
|
10
|
+
hook: 4
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=Types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.js","sourceRoot":"","sources":["../../../../src/sdk/modules/utils/Types.ts"],"names":[],"mappings":"AA0BA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,mDAAU,CAAA;IACV,6CAAO,CAAA;AACT,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAQD,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;CACR,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// small uid generator, hex: 0-9, a-f (10 chars)
|
|
2
|
+
export const generateRandomHex = () => {
|
|
3
|
+
const hexChars = "0123456789abcdef";
|
|
4
|
+
let result = "";
|
|
5
|
+
for (let i = 0; i < 10; i++) {
|
|
6
|
+
const randomIndex = Math.floor(Math.random() * hexChars.length);
|
|
7
|
+
result += hexChars[randomIndex];
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=Uid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Uid.js","sourceRoot":"","sources":["../../../../src/sdk/modules/utils/Uid.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAW,EAAE;IAC5C,MAAM,QAAQ,GAAG,kBAAkB,CAAA;IACnC,IAAI,MAAM,GAAG,EAAE,CAAA;IAEf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC/D,MAAM,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAA;IACjC,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { encodeAbiParameters, encodeFunctionData, erc20Abi } from "viem";
|
|
2
|
+
import { encodeRuntimeFunctionData } from "./runtimeAbiEncoding.js";
|
|
3
|
+
export const InputParamFetcherType = {
|
|
4
|
+
RAW_BYTES: 0,
|
|
5
|
+
STATIC_CALL: 1
|
|
6
|
+
};
|
|
7
|
+
export const OutputParamFetcherType = {
|
|
8
|
+
EXEC_RESULT: 0,
|
|
9
|
+
STATIC_CALL: 1
|
|
10
|
+
};
|
|
11
|
+
export const ConstraintType = {
|
|
12
|
+
EQ: 0,
|
|
13
|
+
GTE: 1,
|
|
14
|
+
LTE: 2,
|
|
15
|
+
IN: 3
|
|
16
|
+
};
|
|
17
|
+
// Detects whether the value is runtime injected value or not
|
|
18
|
+
export const isRuntimeComposableValue = (value) => {
|
|
19
|
+
if (value &&
|
|
20
|
+
typeof value === "object" &&
|
|
21
|
+
!Array.isArray(value) &&
|
|
22
|
+
value.isRuntime) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
};
|
|
27
|
+
export const prepareInputParam = (fetcherType, paramData, constraints = []) => {
|
|
28
|
+
return { fetcherType, paramData, constraints };
|
|
29
|
+
};
|
|
30
|
+
export const prepareOutputParam = (fetcherType, paramData) => {
|
|
31
|
+
return { fetcherType, paramData };
|
|
32
|
+
};
|
|
33
|
+
export const prepareConstraint = (constraintType, referenceData) => {
|
|
34
|
+
return { constraintType, referenceData };
|
|
35
|
+
};
|
|
36
|
+
// type any is being implicitly used. The appropriate value validation happens in the runtime function
|
|
37
|
+
export const greaterThanOrEqualTo = (value) => {
|
|
38
|
+
return { type: ConstraintType.GTE, value };
|
|
39
|
+
};
|
|
40
|
+
// type any is being implicitly used. The appropriate value validation happens in the runtime function
|
|
41
|
+
export const lessThanOrEqualTo = (value) => {
|
|
42
|
+
return { type: ConstraintType.LTE, value };
|
|
43
|
+
};
|
|
44
|
+
// type any is being implicitly used. The appropriate value validation happens in the runtime function
|
|
45
|
+
export const equalTo = (value) => {
|
|
46
|
+
return { type: ConstraintType.EQ, value };
|
|
47
|
+
};
|
|
48
|
+
export const runtimeERC20BalanceOf = ({ targetAddress, tokenAddress, constraints = [] }) => {
|
|
49
|
+
const defaultFunctionSig = "balanceOf";
|
|
50
|
+
const encodedParam = encodeAbiParameters([{ type: "address" }, { type: "bytes" }], [
|
|
51
|
+
tokenAddress,
|
|
52
|
+
encodeFunctionData({
|
|
53
|
+
abi: erc20Abi,
|
|
54
|
+
functionName: defaultFunctionSig,
|
|
55
|
+
args: [targetAddress]
|
|
56
|
+
})
|
|
57
|
+
]);
|
|
58
|
+
const constraintsToAdd = [];
|
|
59
|
+
if (constraints.length > 0) {
|
|
60
|
+
for (const constraint of constraints) {
|
|
61
|
+
// Contraint type IN is ignored for the runtimeBalanceOf
|
|
62
|
+
// This is mostly a number/unit/int, so it makes sense to only have EQ, GTE, LTE
|
|
63
|
+
if (!Object.values(ConstraintType).slice(0, 3).includes(constraint.type)) {
|
|
64
|
+
throw new Error("Invalid contraint type");
|
|
65
|
+
}
|
|
66
|
+
// Handle value validation in a appropriate to runtime function
|
|
67
|
+
if (typeof constraint.value !== "bigint" ||
|
|
68
|
+
constraint.value < BigInt(0)) {
|
|
69
|
+
throw new Error("Invalid contraint value");
|
|
70
|
+
}
|
|
71
|
+
const valueHex = `0x${constraint.value.toString(16).padStart(64, "0")}`;
|
|
72
|
+
const encodedConstraintValue = encodeAbiParameters([{ type: "bytes32" }], [valueHex]);
|
|
73
|
+
constraintsToAdd.push(prepareConstraint(constraint.type, encodedConstraintValue));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
isRuntime: true,
|
|
78
|
+
inputParams: [
|
|
79
|
+
prepareInputParam(InputParamFetcherType.STATIC_CALL, encodedParam, constraintsToAdd)
|
|
80
|
+
],
|
|
81
|
+
outputParams: []
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export const isComposableCallRequired = (functionContext, args) => {
|
|
85
|
+
if (!functionContext.inputs || functionContext.inputs.length <= 0)
|
|
86
|
+
return false;
|
|
87
|
+
const isComposableCall = functionContext.inputs.some((input, inputIndex) => {
|
|
88
|
+
// Only struct and arrays has child elements and require iterating them internally.
|
|
89
|
+
// String and bytes are also dynamic but they are mostly treated as one single value for detection
|
|
90
|
+
if (input.type === "tuple") {
|
|
91
|
+
// Struct arguments are handled here
|
|
92
|
+
// Composable call detection
|
|
93
|
+
const isComposableCallDetected = Object.values(args[inputIndex]).some((internalArg) => isRuntimeComposableValue(internalArg));
|
|
94
|
+
return isComposableCallDetected;
|
|
95
|
+
}
|
|
96
|
+
if (input.type.match(/^(.*)\[(\d+)?\]$/)) {
|
|
97
|
+
// matches against both static and dynamic arrays.
|
|
98
|
+
// Array arguments are handled here
|
|
99
|
+
// Composable call detection
|
|
100
|
+
const isComposableCallDetected = args[inputIndex].some((internalArg) => isRuntimeComposableValue(internalArg));
|
|
101
|
+
return isComposableCallDetected;
|
|
102
|
+
}
|
|
103
|
+
// Below mentioned common values are handled here.
|
|
104
|
+
// intX, uintX, bytesX, bytes, string, bool, address are direct values and doesn't need iteration on child elements.
|
|
105
|
+
// Composable call detection
|
|
106
|
+
return isRuntimeComposableValue(args[inputIndex]);
|
|
107
|
+
});
|
|
108
|
+
return isComposableCall;
|
|
109
|
+
};
|
|
110
|
+
export const prepareComposableParams = (functionContext, args) => {
|
|
111
|
+
const composableParams = encodeRuntimeFunctionData(functionContext, args).map((calldata) => {
|
|
112
|
+
if (isRuntimeComposableValue(calldata)) {
|
|
113
|
+
// Just handling input params here. In future, we may need to add support for output params as well
|
|
114
|
+
return calldata?.inputParams;
|
|
115
|
+
}
|
|
116
|
+
// These are non runtime values which are encoded by the encodeRuntimeFunctionData helper.
|
|
117
|
+
// These params are injected are individual raw bytes which will be combined on the composable contract
|
|
118
|
+
return [
|
|
119
|
+
prepareInputParam(InputParamFetcherType.RAW_BYTES, calldata)
|
|
120
|
+
];
|
|
121
|
+
});
|
|
122
|
+
// Head Params,Head Params,Head Params + (len + Tail Params),(len + Tail Params),(len + Tail Params)
|
|
123
|
+
// Static type doesn't have tail
|
|
124
|
+
// Dynamic types have tail params where the head only have offset which points the dynamic param in tail
|
|
125
|
+
return composableParams.flat();
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=composabilityCalls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composabilityCalls.js","sourceRoot":"","sources":["../../../../src/sdk/modules/utils/composabilityCalls.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/sdk/modules/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
// If anyone wanted to get comfortable with ABI encoding specification
|
|
2
|
+
// Check this out: https://docs.soliditylang.org/en/develop/abi-spec.html
|
|
3
|
+
// If you are a video person ?
|
|
4
|
+
// Check this out: https://www.youtube.com/watch?v=upVloLUw5Z0
|
|
5
|
+
// Author Information:
|
|
6
|
+
// This code is created and audited by Venkatesh Rajendran
|
|
7
|
+
// Github: https://github.com/vr16x
|
|
8
|
+
// Reachout to me if there is any issues or doubts
|
|
9
|
+
// X: https://x.com/vr16x
|
|
10
|
+
import { AbiEncodingArrayLengthMismatchError, AbiEncodingBytesSizeMismatchError, AbiEncodingLengthMismatchError, BaseError, IntegerOutOfRangeError, InvalidAbiEncodingTypeError, InvalidAddressError, InvalidArrayError, boolToHex, concat, isAddress, numberToHex, padHex, size, slice, stringToHex, toFunctionSelector } from "viem";
|
|
11
|
+
import { isRuntimeComposableValue } from "./composabilityCalls.js";
|
|
12
|
+
// Total list of int and uint types used for regex matching against the data type
|
|
13
|
+
const integerRegex = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
|
|
14
|
+
// length in hex (0x....5) + Right padded string hex (0x4j34ng2....0000)
|
|
15
|
+
// Example: 0x00000.....50x4j34ng2....0000
|
|
16
|
+
const encodeString = (value) => {
|
|
17
|
+
const hexValue = stringToHex(value);
|
|
18
|
+
const partsLength = Math.ceil(size(hexValue) / 32);
|
|
19
|
+
const parts = [];
|
|
20
|
+
for (let i = 0; i < partsLength; i++) {
|
|
21
|
+
parts.push(padHex(slice(hexValue, i * 32, (i + 1) * 32), {
|
|
22
|
+
dir: "right"
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
dynamic: true,
|
|
27
|
+
data: [
|
|
28
|
+
concat([padHex(numberToHex(size(hexValue), { size: 32 })), ...parts]) // Concat string len + right padded string hex value
|
|
29
|
+
]
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
// The encoding for bytes also treated same as string if it is a bytes value
|
|
33
|
+
// Example: 0x00000.....50x4j34ng2....0000
|
|
34
|
+
// Encoding for static bytes type is straight forward. It will be simply converted into hex with padding on right
|
|
35
|
+
// No length is used for static bytes type
|
|
36
|
+
// 0x50x4j34ng2....00000000
|
|
37
|
+
const encodeBytes = (value, { param }) => {
|
|
38
|
+
const [, paramSize] = param.type.split("bytes");
|
|
39
|
+
// Checks if the value is runtime value which means the appropriate encoding already happened in composability integration
|
|
40
|
+
// In this case, we just need to determine whether the bytes is a static or dynamic value
|
|
41
|
+
if (isRuntimeComposableValue(value)) {
|
|
42
|
+
if (paramSize) {
|
|
43
|
+
return { dynamic: false, data: [value] };
|
|
44
|
+
}
|
|
45
|
+
return { dynamic: true, data: [value] };
|
|
46
|
+
}
|
|
47
|
+
const bytesSize = size(value);
|
|
48
|
+
// If there is no param size, it is bytes data type and trearted as dynamic value
|
|
49
|
+
if (!paramSize) {
|
|
50
|
+
let value_ = value;
|
|
51
|
+
// If the size is not divisible by 32 bytes, pad the end
|
|
52
|
+
// with empty bytes to the ceiling 32 bytes.
|
|
53
|
+
if (bytesSize % 32 !== 0)
|
|
54
|
+
value_ = padHex(value_, {
|
|
55
|
+
dir: "right",
|
|
56
|
+
size: Math.ceil((value.length - 2) / 2 / 32) * 32
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
dynamic: true,
|
|
60
|
+
data: [padHex(numberToHex(bytesSize, { size: 32 })), value_] // Length + Value
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Check for param size which is extracted from type with actual byte size
|
|
64
|
+
if (bytesSize !== Number.parseInt(paramSize))
|
|
65
|
+
throw new AbiEncodingBytesSizeMismatchError({
|
|
66
|
+
expectedSize: Number.parseInt(paramSize),
|
|
67
|
+
value: value
|
|
68
|
+
});
|
|
69
|
+
return { dynamic: false, data: [padHex(value, { dir: "right" })] }; // No length because of the static nature
|
|
70
|
+
};
|
|
71
|
+
// Number value is converted into 32 bytes hex
|
|
72
|
+
// Example: 0x000...0000002
|
|
73
|
+
const encodeNumber = (value, { signed, size = 256 }) => {
|
|
74
|
+
// Validating the boundry of uint and int types
|
|
75
|
+
if (typeof size === "number") {
|
|
76
|
+
const max = BigInt(2) ** (BigInt(size) - (signed ? BigInt(1) : BigInt(0))) - BigInt(1);
|
|
77
|
+
const min = signed ? -max - BigInt(1) : BigInt(0);
|
|
78
|
+
if (value > max || value < min)
|
|
79
|
+
throw new IntegerOutOfRangeError({
|
|
80
|
+
max: max.toString(),
|
|
81
|
+
min: min.toString(),
|
|
82
|
+
signed,
|
|
83
|
+
size: size / 8,
|
|
84
|
+
value: value.toString()
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// Simply converting a number into hex value
|
|
88
|
+
return {
|
|
89
|
+
dynamic: false,
|
|
90
|
+
data: [
|
|
91
|
+
numberToHex(value, {
|
|
92
|
+
size: 32,
|
|
93
|
+
signed
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
// Boolean value is converted into 32 bytes hex
|
|
99
|
+
// Example: 0x000...0000001 for true
|
|
100
|
+
// Example: 0x000...0000000 for false
|
|
101
|
+
const encodeBool = (value) => {
|
|
102
|
+
if (typeof value !== "boolean")
|
|
103
|
+
throw new BaseError(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
|
|
104
|
+
// Simply converting a bool into hex value
|
|
105
|
+
return { dynamic: false, data: [padHex(boolToHex(value))] };
|
|
106
|
+
};
|
|
107
|
+
// Address value is converted into 32 bytes hex
|
|
108
|
+
// Example: 0x000...g132gj1 for false
|
|
109
|
+
const encodeAddress = (value) => {
|
|
110
|
+
if (!isAddress(value))
|
|
111
|
+
throw new InvalidAddressError({ address: value });
|
|
112
|
+
// Simply converting a address into hex value
|
|
113
|
+
return { dynamic: false, data: [padHex(value.toLowerCase())] };
|
|
114
|
+
};
|
|
115
|
+
const encodeArray = (value, { length, param }) => {
|
|
116
|
+
// If there is no length mentioned in the array, it is a dynamic array
|
|
117
|
+
const dynamic = length === null;
|
|
118
|
+
if (!Array.isArray(value))
|
|
119
|
+
throw new InvalidArrayError(value);
|
|
120
|
+
// If there is a length specified, the static array length is validated with its elements count
|
|
121
|
+
if (!dynamic && value.length !== length)
|
|
122
|
+
throw new AbiEncodingArrayLengthMismatchError({
|
|
123
|
+
expectedLength: length,
|
|
124
|
+
givenLength: value.length,
|
|
125
|
+
type: `${param.type}[${length}]`
|
|
126
|
+
});
|
|
127
|
+
let dynamicChild = false;
|
|
128
|
+
const preparedParams = [];
|
|
129
|
+
for (let i = 0; i < value.length; i++) {
|
|
130
|
+
// The internal elements are encoded according to its data type.
|
|
131
|
+
const preparedParam = prepareParam({ param, value: value[i] });
|
|
132
|
+
// If any internal data type is dynamic, the array will be treated as dynamic
|
|
133
|
+
// No matter what whether the main array is static or dynamic
|
|
134
|
+
if (preparedParam.dynamic)
|
|
135
|
+
dynamicChild = true;
|
|
136
|
+
preparedParams.push(preparedParam);
|
|
137
|
+
}
|
|
138
|
+
// if the array itself dynamic or child element is dynamic ? The array is treated as dynamic
|
|
139
|
+
if (dynamic || dynamicChild) {
|
|
140
|
+
// Encoding the internal elements
|
|
141
|
+
const data = encodeParams(preparedParams);
|
|
142
|
+
// If the main array itself dynamic and has a atleast one element, the encoding will be
|
|
143
|
+
// length + list of elements appended one after other based on the internal data type encoding
|
|
144
|
+
// If it is a emtpy dynamic arrray ? zero length is added as encoding
|
|
145
|
+
if (dynamic) {
|
|
146
|
+
const length = numberToHex(preparedParams.length, { size: 32 });
|
|
147
|
+
return {
|
|
148
|
+
dynamic: true,
|
|
149
|
+
data: preparedParams.length > 0 ? [length, ...data] : [length] // The entire array will be placed at the tail
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
// If the main array is not dynamic but the child is dynamic ? The child element encoding already
|
|
153
|
+
// handled the length + data while encoding itself. So no need for length here.
|
|
154
|
+
// Array will be placed in head but the element pointer is stored here which points to the values in tail
|
|
155
|
+
if (dynamicChild)
|
|
156
|
+
return { dynamic: true, data: data };
|
|
157
|
+
}
|
|
158
|
+
// As the encoding for array can be nested as well. But finally we will flatten them
|
|
159
|
+
const data = preparedParams.flatMap(({ data }) => data);
|
|
160
|
+
// If the array is static, the elements are placed in the head with 32 bytes size per element
|
|
161
|
+
return {
|
|
162
|
+
dynamic: false,
|
|
163
|
+
data: data
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
// Static struct usually handled same as static data type and placed in head
|
|
167
|
+
// A struct with dynamic data type will be considered as dynamic in nature
|
|
168
|
+
const encodeTuple = (value, { param }) => {
|
|
169
|
+
let dynamic = false;
|
|
170
|
+
const preparedParams = [];
|
|
171
|
+
for (let i = 0; i < param.components.length; i++) {
|
|
172
|
+
const param_ = param.components[i];
|
|
173
|
+
const index = Array.isArray(value) ? i : param_.name;
|
|
174
|
+
// The internal elements will be encoded based on its data type. It will handle the nested data type encoding as well
|
|
175
|
+
const preparedParam = prepareParam({
|
|
176
|
+
param: param_,
|
|
177
|
+
value: value[index]
|
|
178
|
+
});
|
|
179
|
+
preparedParams.push(preparedParam);
|
|
180
|
+
// If any of the internal element of a tuple is dynamic ? The entire tuple is treated as dynamic tuple
|
|
181
|
+
if (preparedParam.dynamic)
|
|
182
|
+
dynamic = true;
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
dynamic,
|
|
186
|
+
data: dynamic
|
|
187
|
+
? encodeParams(preparedParams) // If the struct is dynamic, it will be placed in tail with a pointer/offset in head
|
|
188
|
+
: preparedParams.flatMap(({ data }) => data) // If the tuple is static, it is simply placed on after another in head
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
const getArrayComponents = (type) => {
|
|
192
|
+
const matches = type.match(/^(.*)\[(\d+)?\]$/);
|
|
193
|
+
return matches
|
|
194
|
+
? // Return `null` if the array is dynamic.
|
|
195
|
+
[matches[2] ? Number(matches[2]) : null, matches[1]]
|
|
196
|
+
: undefined;
|
|
197
|
+
};
|
|
198
|
+
const encodeParams = (preparedParams) => {
|
|
199
|
+
// 1. Compute the size of the static part of the parameters.
|
|
200
|
+
let staticSize = 0;
|
|
201
|
+
for (let i = 0; i < preparedParams.length; i++) {
|
|
202
|
+
const { dynamic, data } = preparedParams[i];
|
|
203
|
+
// If the data type is dynamic, only offset/pointer is placed in the head
|
|
204
|
+
// hence it only requires 32 bytes for head where the actual values will be placed in tail
|
|
205
|
+
if (dynamic) {
|
|
206
|
+
staticSize += 32;
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
// Most probably the size of this data array will be one for this instance.
|
|
210
|
+
const len = data.reduce((acc, val) => {
|
|
211
|
+
// If the value is runtime ? We always assume it is static value. hence we are adding 32 bytes.
|
|
212
|
+
// Dynamic runtime values are not supported by composability stack as of now.
|
|
213
|
+
// In future, if the composability stack support dynamic runtime types, this needs to be changed
|
|
214
|
+
if (isRuntimeComposableValue(val)) {
|
|
215
|
+
return acc + 32;
|
|
216
|
+
}
|
|
217
|
+
return acc + size(val);
|
|
218
|
+
}, 0);
|
|
219
|
+
staticSize += len;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// 2. Split the parameters into static and dynamic parts.
|
|
223
|
+
const staticParams = [];
|
|
224
|
+
const dynamicParams = [];
|
|
225
|
+
let dynamicSize = 0;
|
|
226
|
+
for (let i = 0; i < preparedParams.length; i++) {
|
|
227
|
+
const { dynamic, data } = preparedParams[i];
|
|
228
|
+
// If the param is dynamic ? Static param will be a offset and dynamic param is placed in tail
|
|
229
|
+
if (dynamic) {
|
|
230
|
+
// For the first dynamic param, there will be no dynamic value in tail. Which means the dynamic value will be place after all head elements
|
|
231
|
+
// length of all static type are calculated and dynamic value is placed after the calculated length
|
|
232
|
+
// From the next time, the static + dynamic length will be calculated to get a fresh pointer at the last where the dynamic value will be placed
|
|
233
|
+
staticParams.push(numberToHex(staticSize + dynamicSize, { size: 32 }));
|
|
234
|
+
dynamicParams.push(...data);
|
|
235
|
+
const len = data.reduce((acc, val) => {
|
|
236
|
+
// If the dynamic value contains a runtime value ? The result of runtime value is expected to be 32 bytes.
|
|
237
|
+
// We don't support dynamic value to be output of runtime value. If the composability stack supports dynamic runtime values ?
|
|
238
|
+
// This need to be changed
|
|
239
|
+
if (isRuntimeComposableValue(val)) {
|
|
240
|
+
return acc + 32;
|
|
241
|
+
}
|
|
242
|
+
// Actual size of dynamic value is calculated
|
|
243
|
+
return acc + size(val);
|
|
244
|
+
}, 0);
|
|
245
|
+
// Dynamic length is calculated. It will increase as the number of dynamic values present
|
|
246
|
+
// For second dynamic param, the pointer placed in head will sum the static size and existing dynamic values to find/point a new place after all
|
|
247
|
+
// dynamic values
|
|
248
|
+
dynamicSize += len;
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
staticParams.push(...data);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// 3. Concatenate static and dynamic parts.
|
|
255
|
+
// Static params are placed in head and dynamic params are placed in tail
|
|
256
|
+
return [...staticParams, ...dynamicParams];
|
|
257
|
+
};
|
|
258
|
+
const prepareParams = ({ params, values }) => {
|
|
259
|
+
const preparedParams = [];
|
|
260
|
+
for (let i = 0; i < params.length; i++) {
|
|
261
|
+
preparedParams.push(prepareParam({ param: params[i], value: values[i] }));
|
|
262
|
+
}
|
|
263
|
+
return preparedParams;
|
|
264
|
+
};
|
|
265
|
+
const prepareParam = ({ param, value }) => {
|
|
266
|
+
const runtimeValue = { dynamic: false, data: [value] };
|
|
267
|
+
// Detect whether the data type is array or not
|
|
268
|
+
const arrayComponents = getArrayComponents(param.type);
|
|
269
|
+
if (arrayComponents) {
|
|
270
|
+
// If it is array, the length might be some number or null.
|
|
271
|
+
// Null => Dynamic array, Some number => Static array
|
|
272
|
+
const [length, type] = arrayComponents;
|
|
273
|
+
// Runtime value is not required to be handled. As the internal types will be the runtime and it will be auto handled when
|
|
274
|
+
// handling the internal fields
|
|
275
|
+
return encodeArray(value, { length, param: { ...param, type } });
|
|
276
|
+
}
|
|
277
|
+
if (param.type === "address") {
|
|
278
|
+
// If the address is runtime value, the encoding is already happened in composability helper, simply return the runtime value
|
|
279
|
+
if (isRuntimeComposableValue(value))
|
|
280
|
+
return runtimeValue;
|
|
281
|
+
return encodeAddress(value);
|
|
282
|
+
}
|
|
283
|
+
if (param.type === "bool") {
|
|
284
|
+
// If the bool is runtime value, the encoding is already happened in composability helper, simply return the runtime value
|
|
285
|
+
if (isRuntimeComposableValue(value))
|
|
286
|
+
return runtimeValue;
|
|
287
|
+
return encodeBool(value);
|
|
288
|
+
}
|
|
289
|
+
if (param.type.startsWith("uint") || param.type.startsWith("int")) {
|
|
290
|
+
// If the uint/int is runtime value, the encoding is already happened in composability helper, simply return the runtime value
|
|
291
|
+
if (isRuntimeComposableValue(value))
|
|
292
|
+
return runtimeValue;
|
|
293
|
+
const signed = param.type.startsWith("int");
|
|
294
|
+
const [, , size = "256"] = integerRegex.exec(param.type) ?? [];
|
|
295
|
+
return encodeNumber(value, {
|
|
296
|
+
signed,
|
|
297
|
+
size: Number(size)
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
if (param.type.startsWith("bytes")) {
|
|
301
|
+
// Runtime value is handled inside this function itself
|
|
302
|
+
return encodeBytes(value, { param });
|
|
303
|
+
}
|
|
304
|
+
if (param.type === "string") {
|
|
305
|
+
// If the string is runtime value, the encoding is already happened in composability helper, simply return the runtime value
|
|
306
|
+
if (isRuntimeComposableValue(value))
|
|
307
|
+
return runtimeValue;
|
|
308
|
+
return encodeString(value);
|
|
309
|
+
}
|
|
310
|
+
if (param.type === "tuple") {
|
|
311
|
+
// Runtime value is not required to be handled. As the internal types will be the runtime and it will be auto handled when
|
|
312
|
+
// handling the internal fields
|
|
313
|
+
return encodeTuple(value, {
|
|
314
|
+
param: param
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
// If none of the type matches, invalid type is specified for encoding, so throw an error
|
|
318
|
+
throw new InvalidAbiEncodingTypeError(param.type, {
|
|
319
|
+
docsPath: "/docs/contract/encodeAbiParameters"
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
export const encodeRuntimeFunctionData = (functionContext, args) => {
|
|
323
|
+
// If there is no arguments to the function, no need for encoding at all.
|
|
324
|
+
if (!functionContext.inputs || functionContext.inputs.length === 0) {
|
|
325
|
+
return ["0x"];
|
|
326
|
+
}
|
|
327
|
+
// If the required inputs and arguments passed is not same, throw an error
|
|
328
|
+
if (functionContext.inputs.length !== args.length) {
|
|
329
|
+
throw new AbiEncodingLengthMismatchError({
|
|
330
|
+
expectedLength: functionContext?.inputs?.length,
|
|
331
|
+
givenLength: args.length
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
// Prepare the encoding
|
|
335
|
+
const preparedParams = prepareParams({
|
|
336
|
+
params: functionContext.inputs,
|
|
337
|
+
values: args
|
|
338
|
+
});
|
|
339
|
+
// Encoding the prepared data types based on static and dynamic natrue
|
|
340
|
+
const data = encodeParams(preparedParams);
|
|
341
|
+
// If there is no data, which means no encoding happened, return 0x
|
|
342
|
+
if (data.length === 0)
|
|
343
|
+
return ["0x"];
|
|
344
|
+
// Return theb encoded data. This is not a usual encoding function which returns the funSig + args encoding as a hex
|
|
345
|
+
// It returns only arguments in a array form which is very flexible to handle runtime values
|
|
346
|
+
return data;
|
|
347
|
+
};
|
|
348
|
+
export const getFunctionContextFromAbi = (functionSig, abi) => {
|
|
349
|
+
if (abi.length === 0) {
|
|
350
|
+
throw new Error("Invalid ABI");
|
|
351
|
+
}
|
|
352
|
+
const [functionInfo] = abi.filter((item) => item.type === "function" && item.name === functionSig);
|
|
353
|
+
if (!functionInfo) {
|
|
354
|
+
throw new Error(`${functionSig} not found on the ABI`);
|
|
355
|
+
}
|
|
356
|
+
const { inputs, name, outputs, stateMutability } = functionInfo;
|
|
357
|
+
return {
|
|
358
|
+
inputs,
|
|
359
|
+
name,
|
|
360
|
+
outputs,
|
|
361
|
+
functionType: ["view", "pure"].includes(stateMutability) ? "read" : "write",
|
|
362
|
+
functionSig: toFunctionSelector(functionInfo)
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
//# sourceMappingURL=runtimeAbiEncoding.js.map
|