@safe-global/protocol-kit 5.2.2 → 6.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/dist/cjs/src/index.cjs +7534 -0
- package/dist/cjs/test-utils/index.cjs +4118 -0
- package/dist/esm/src/index.mjs +7639 -0
- package/dist/esm/test-utils/index.mjs +4217 -0
- package/dist/src/Safe.d.ts +3 -2
- package/dist/src/Safe.d.ts.map +1 -0
- package/dist/src/SafeProvider.d.ts +1 -0
- package/dist/src/SafeProvider.d.ts.map +1 -0
- package/dist/src/contracts/BaseContract.d.ts +1 -0
- package/dist/src/contracts/BaseContract.d.ts.map +1 -0
- package/dist/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract.d.ts +1 -0
- package/dist/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract.d.ts.map +1 -0
- package/dist/src/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0.d.ts +1 -0
- package/dist/src/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0.d.ts.map +1 -0
- package/dist/src/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1.d.ts +1 -0
- package/dist/src/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1.d.ts.map +1 -0
- package/dist/src/contracts/CreateCall/CreateCallBaseContract.d.ts +1 -0
- package/dist/src/contracts/CreateCall/CreateCallBaseContract.d.ts.map +1 -0
- package/dist/src/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0.d.ts +1 -0
- package/dist/src/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0.d.ts.map +1 -0
- package/dist/src/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1.d.ts +1 -0
- package/dist/src/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1.d.ts.map +1 -0
- package/dist/src/contracts/MultiSend/MultiSendBaseContract.d.ts +1 -0
- package/dist/src/contracts/MultiSend/MultiSendBaseContract.d.ts.map +1 -0
- package/dist/src/contracts/MultiSend/MultiSendCallOnlyBaseContract.d.ts +1 -0
- package/dist/src/contracts/MultiSend/MultiSendCallOnlyBaseContract.d.ts.map +1 -0
- package/dist/src/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1.d.ts +1 -0
- package/dist/src/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1.d.ts.map +1 -0
- package/dist/src/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0.d.ts +1 -0
- package/dist/src/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0.d.ts.map +1 -0
- package/dist/src/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0.d.ts +1 -0
- package/dist/src/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0.d.ts.map +1 -0
- package/dist/src/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1.d.ts +1 -0
- package/dist/src/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1.d.ts.map +1 -0
- package/dist/src/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1.d.ts +1 -0
- package/dist/src/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1.d.ts.map +1 -0
- package/dist/src/contracts/Safe/SafeBaseContract.d.ts +1 -0
- package/dist/src/contracts/Safe/SafeBaseContract.d.ts.map +1 -0
- package/dist/src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.d.ts +1 -0
- package/dist/src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.d.ts.map +1 -0
- package/dist/src/contracts/Safe/v1.1.1/SafeContract_v1_1_1.d.ts +1 -0
- package/dist/src/contracts/Safe/v1.1.1/SafeContract_v1_1_1.d.ts.map +1 -0
- package/dist/src/contracts/Safe/v1.2.0/SafeContract_v1_2_0.d.ts +1 -0
- package/dist/src/contracts/Safe/v1.2.0/SafeContract_v1_2_0.d.ts.map +1 -0
- package/dist/src/contracts/Safe/v1.3.0/SafeContract_v1_3_0.d.ts +1 -0
- package/dist/src/contracts/Safe/v1.3.0/SafeContract_v1_3_0.d.ts.map +1 -0
- package/dist/src/contracts/Safe/v1.4.1/SafeContract_v1_4_1.d.ts +1 -0
- package/dist/src/contracts/Safe/v1.4.1/SafeContract_v1_4_1.d.ts.map +1 -0
- package/dist/src/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract.d.ts +1 -0
- package/dist/src/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract.d.ts.map +1 -0
- package/dist/src/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0.d.ts +1 -0
- package/dist/src/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0.d.ts.map +1 -0
- package/dist/src/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1.d.ts +1 -0
- package/dist/src/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1.d.ts.map +1 -0
- package/dist/src/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0.d.ts +1 -0
- package/dist/src/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0.d.ts.map +1 -0
- package/dist/src/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1.d.ts +1 -0
- package/dist/src/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1.d.ts.map +1 -0
- package/dist/src/contracts/SafeWebAuthnSharedSigner/SafeWebAuthnSharedSignerBaseContract.d.ts +1 -0
- package/dist/src/contracts/SafeWebAuthnSharedSigner/SafeWebAuthnSharedSignerBaseContract.d.ts.map +1 -0
- package/dist/src/contracts/SafeWebAuthnSharedSigner/v0.2.1/SafeWebAuthnSharedSignerContract_v0_2_1.d.ts +1 -0
- package/dist/src/contracts/SafeWebAuthnSharedSigner/v0.2.1/SafeWebAuthnSharedSignerContract_v0_2_1.d.ts.map +1 -0
- package/dist/src/contracts/SafeWebAuthnSignerFactory/SafeWebAuthnSignerFactoryBaseContract.d.ts +1 -0
- package/dist/src/contracts/SafeWebAuthnSignerFactory/SafeWebAuthnSignerFactoryBaseContract.d.ts.map +1 -0
- package/dist/src/contracts/SafeWebAuthnSignerFactory/v0.2.1/SafeWebAuthnSignerFactoryContract_v0_2_1.d.ts +1 -0
- package/dist/src/contracts/SafeWebAuthnSignerFactory/v0.2.1/SafeWebAuthnSignerFactoryContract_v0_2_1.d.ts.map +1 -0
- package/dist/src/contracts/SignMessageLib/SignMessageLibBaseContract.d.ts +1 -0
- package/dist/src/contracts/SignMessageLib/SignMessageLibBaseContract.d.ts.map +1 -0
- package/dist/src/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0.d.ts +1 -0
- package/dist/src/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0.d.ts.map +1 -0
- package/dist/src/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1.d.ts +1 -0
- package/dist/src/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1.d.ts.map +1 -0
- package/dist/src/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract.d.ts +1 -0
- package/dist/src/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract.d.ts.map +1 -0
- package/dist/src/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0.d.ts +1 -0
- package/dist/src/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0.d.ts.map +1 -0
- package/dist/src/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1.d.ts +1 -0
- package/dist/src/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1.d.ts.map +1 -0
- package/dist/src/contracts/config.d.ts +1 -0
- package/dist/src/contracts/config.d.ts.map +1 -0
- package/dist/src/contracts/constants.d.ts +1 -0
- package/dist/src/contracts/constants.d.ts.map +1 -0
- package/dist/src/contracts/contractInstances.d.ts +1 -0
- package/dist/src/contracts/contractInstances.d.ts.map +1 -0
- package/dist/src/contracts/index.d.ts +1 -0
- package/dist/src/contracts/index.d.ts.map +1 -0
- package/dist/src/contracts/safeDeploymentContracts.d.ts +1 -0
- package/dist/src/contracts/safeDeploymentContracts.d.ts.map +1 -0
- package/dist/src/contracts/utils.d.ts +1 -0
- package/dist/src/contracts/utils.d.ts.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/managers/contractManager.d.ts +1 -0
- package/dist/src/managers/contractManager.d.ts.map +1 -0
- package/dist/src/managers/fallbackHandlerManager.d.ts +1 -0
- package/dist/src/managers/fallbackHandlerManager.d.ts.map +1 -0
- package/dist/src/managers/guardManager.d.ts +1 -0
- package/dist/src/managers/guardManager.d.ts.map +1 -0
- package/dist/src/managers/moduleManager.d.ts +1 -0
- package/dist/src/managers/moduleManager.d.ts.map +1 -0
- package/dist/src/managers/ownerManager.d.ts +1 -0
- package/dist/src/managers/ownerManager.d.ts.map +1 -0
- package/dist/src/types/contracts.d.ts +1 -0
- package/dist/src/types/contracts.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +1 -1
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/passkeys.d.ts +1 -0
- package/dist/src/types/passkeys.d.ts.map +1 -0
- package/dist/src/types/safeConfig.d.ts +1 -0
- package/dist/src/types/safeConfig.d.ts.map +1 -0
- package/dist/src/types/safeProvider.d.ts +1 -0
- package/dist/src/types/safeProvider.d.ts.map +1 -0
- package/dist/src/types/transactions.d.ts +1 -0
- package/dist/src/types/transactions.d.ts.map +1 -0
- package/dist/src/utils/address.d.ts +1 -0
- package/dist/src/utils/address.d.ts.map +1 -0
- package/dist/src/utils/block.d.ts +1 -0
- package/dist/src/utils/block.d.ts.map +1 -0
- package/dist/src/utils/constants.d.ts +1 -0
- package/dist/src/utils/constants.d.ts.map +1 -0
- package/dist/src/utils/eip-3770/config.d.ts +1 -0
- package/dist/src/utils/eip-3770/config.d.ts.map +1 -0
- package/dist/src/utils/eip-3770/index.d.ts +1 -0
- package/dist/src/utils/eip-3770/index.d.ts.map +1 -0
- package/dist/src/utils/eip-712/encode.d.ts +1 -0
- package/dist/src/utils/eip-712/encode.d.ts.map +1 -0
- package/dist/src/utils/eip-712/index.d.ts +1 -0
- package/dist/src/utils/eip-712/index.d.ts.map +1 -0
- package/dist/src/utils/erc-20/index.d.ts +1 -0
- package/dist/src/utils/erc-20/index.d.ts.map +1 -0
- package/dist/src/utils/getProtocolKitVersion.d.ts +1 -0
- package/dist/src/utils/getProtocolKitVersion.d.ts.map +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/memoized.d.ts +1 -0
- package/dist/src/utils/memoized.d.ts.map +1 -0
- package/dist/src/utils/messages/SafeMessage.d.ts +1 -0
- package/dist/src/utils/messages/SafeMessage.d.ts.map +1 -0
- package/dist/src/utils/on-chain-tracking/generateOnChainIdentifier.d.ts +1 -0
- package/dist/src/utils/on-chain-tracking/generateOnChainIdentifier.d.ts.map +1 -0
- package/dist/src/utils/passkeys/PasskeyClient.d.ts +1 -0
- package/dist/src/utils/passkeys/PasskeyClient.d.ts.map +1 -0
- package/dist/src/utils/passkeys/createPasskeyDeploymentTransaction.d.ts +1 -0
- package/dist/src/utils/passkeys/createPasskeyDeploymentTransaction.d.ts.map +1 -0
- package/dist/src/utils/passkeys/extractPasskeyData.d.ts +1 -0
- package/dist/src/utils/passkeys/extractPasskeyData.d.ts.map +1 -0
- package/dist/src/utils/passkeys/getPasskeyOwnerAddress.d.ts +1 -0
- package/dist/src/utils/passkeys/getPasskeyOwnerAddress.d.ts.map +1 -0
- package/dist/src/utils/passkeys/index.d.ts +1 -0
- package/dist/src/utils/passkeys/index.d.ts.map +1 -0
- package/dist/src/utils/passkeys/isSharedSigner.d.ts +1 -0
- package/dist/src/utils/passkeys/isSharedSigner.d.ts.map +1 -0
- package/dist/src/utils/provider.d.ts +1 -0
- package/dist/src/utils/provider.d.ts.map +1 -0
- package/dist/src/utils/safeVersions.d.ts +1 -0
- package/dist/src/utils/safeVersions.d.ts.map +1 -0
- package/dist/src/utils/signatures/SafeSignature.d.ts +1 -0
- package/dist/src/utils/signatures/SafeSignature.d.ts.map +1 -0
- package/dist/src/utils/signatures/index.d.ts +1 -0
- package/dist/src/utils/signatures/index.d.ts.map +1 -0
- package/dist/src/utils/signatures/utils.d.ts +2 -2
- package/dist/src/utils/signatures/utils.d.ts.map +1 -0
- package/dist/src/utils/transactions/SafeTransaction.d.ts +1 -0
- package/dist/src/utils/transactions/SafeTransaction.d.ts.map +1 -0
- package/dist/src/utils/transactions/gas.d.ts +1 -0
- package/dist/src/utils/transactions/gas.d.ts.map +1 -0
- package/dist/src/utils/transactions/index.d.ts +1 -0
- package/dist/src/utils/transactions/index.d.ts.map +1 -0
- package/dist/src/utils/transactions/types.d.ts +1 -0
- package/dist/src/utils/transactions/types.d.ts.map +1 -0
- package/dist/src/utils/transactions/utils.d.ts +1 -0
- package/dist/src/utils/transactions/utils.d.ts.map +1 -0
- package/dist/src/utils/types.d.ts +1 -0
- package/dist/src/utils/types.d.ts.map +1 -0
- package/dist/test-utils/index.d.ts +3 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/test-utils/passkeys.d.ts +25 -0
- package/dist/test-utils/passkeys.d.ts.map +1 -0
- package/dist/test-utils/webauthnShim.d.ts +150 -0
- package/dist/test-utils/webauthnShim.d.ts.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +21 -5
- package/dist/src/Safe.js +0 -1409
- package/dist/src/Safe.js.map +0 -1
- package/dist/src/SafeProvider.js +0 -265
- package/dist/src/SafeProvider.js.map +0 -1
- package/dist/src/contracts/BaseContract.js +0 -163
- package/dist/src/contracts/BaseContract.js.map +0 -1
- package/dist/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract.js +0 -40
- package/dist/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract.js.map +0 -1
- package/dist/src/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0.js +0 -33
- package/dist/src/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0.js.map +0 -1
- package/dist/src/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1.js +0 -33
- package/dist/src/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1.js.map +0 -1
- package/dist/src/contracts/CreateCall/CreateCallBaseContract.js +0 -40
- package/dist/src/contracts/CreateCall/CreateCallBaseContract.js.map +0 -1
- package/dist/src/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0.js +0 -56
- package/dist/src/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0.js.map +0 -1
- package/dist/src/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1.js +0 -56
- package/dist/src/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1.js.map +0 -1
- package/dist/src/contracts/MultiSend/MultiSendBaseContract.js +0 -40
- package/dist/src/contracts/MultiSend/MultiSendBaseContract.js.map +0 -1
- package/dist/src/contracts/MultiSend/MultiSendCallOnlyBaseContract.js +0 -40
- package/dist/src/contracts/MultiSend/MultiSendCallOnlyBaseContract.js.map +0 -1
- package/dist/src/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1.js +0 -33
- package/dist/src/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1.js.map +0 -1
- package/dist/src/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0.js +0 -33
- package/dist/src/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0.js.map +0 -1
- package/dist/src/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0.js +0 -33
- package/dist/src/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0.js.map +0 -1
- package/dist/src/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1.js +0 -33
- package/dist/src/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1.js.map +0 -1
- package/dist/src/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1.js +0 -33
- package/dist/src/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1.js.map +0 -1
- package/dist/src/contracts/Safe/SafeBaseContract.js +0 -47
- package/dist/src/contracts/Safe/SafeBaseContract.js.map +0 -1
- package/dist/src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.js +0 -276
- package/dist/src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.js.map +0 -1
- package/dist/src/contracts/Safe/v1.1.1/SafeContract_v1_1_1.js +0 -248
- package/dist/src/contracts/Safe/v1.1.1/SafeContract_v1_1_1.js.map +0 -1
- package/dist/src/contracts/Safe/v1.2.0/SafeContract_v1_2_0.js +0 -253
- package/dist/src/contracts/Safe/v1.2.0/SafeContract_v1_2_0.js.map +0 -1
- package/dist/src/contracts/Safe/v1.3.0/SafeContract_v1_3_0.js +0 -267
- package/dist/src/contracts/Safe/v1.3.0/SafeContract_v1_3_0.js.map +0 -1
- package/dist/src/contracts/Safe/v1.4.1/SafeContract_v1_4_1.js +0 -267
- package/dist/src/contracts/Safe/v1.4.1/SafeContract_v1_4_1.js.map +0 -1
- package/dist/src/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract.js +0 -43
- package/dist/src/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract.js.map +0 -1
- package/dist/src/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0.js +0 -63
- package/dist/src/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0.js.map +0 -1
- package/dist/src/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1.js +0 -79
- package/dist/src/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1.js.map +0 -1
- package/dist/src/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0.js +0 -79
- package/dist/src/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0.js.map +0 -1
- package/dist/src/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1.js +0 -72
- package/dist/src/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1.js.map +0 -1
- package/dist/src/contracts/SafeWebAuthnSharedSigner/SafeWebAuthnSharedSignerBaseContract.js +0 -39
- package/dist/src/contracts/SafeWebAuthnSharedSigner/SafeWebAuthnSharedSignerBaseContract.js.map +0 -1
- package/dist/src/contracts/SafeWebAuthnSharedSigner/v0.2.1/SafeWebAuthnSharedSignerContract_v0_2_1.js +0 -59
- package/dist/src/contracts/SafeWebAuthnSharedSigner/v0.2.1/SafeWebAuthnSharedSignerContract_v0_2_1.js.map +0 -1
- package/dist/src/contracts/SafeWebAuthnSignerFactory/SafeWebAuthnSignerFactoryBaseContract.js +0 -39
- package/dist/src/contracts/SafeWebAuthnSignerFactory/SafeWebAuthnSignerFactoryBaseContract.js.map +0 -1
- package/dist/src/contracts/SafeWebAuthnSignerFactory/v0.2.1/SafeWebAuthnSignerFactoryContract_v0_2_1.js +0 -52
- package/dist/src/contracts/SafeWebAuthnSignerFactory/v0.2.1/SafeWebAuthnSignerFactoryContract_v0_2_1.js.map +0 -1
- package/dist/src/contracts/SignMessageLib/SignMessageLibBaseContract.js +0 -40
- package/dist/src/contracts/SignMessageLib/SignMessageLibBaseContract.js.map +0 -1
- package/dist/src/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0.js +0 -49
- package/dist/src/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0.js.map +0 -1
- package/dist/src/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1.js +0 -49
- package/dist/src/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1.js.map +0 -1
- package/dist/src/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract.js +0 -40
- package/dist/src/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract.js.map +0 -1
- package/dist/src/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0.js +0 -42
- package/dist/src/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0.js.map +0 -1
- package/dist/src/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1.js +0 -42
- package/dist/src/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1.js.map +0 -1
- package/dist/src/contracts/config.js +0 -130
- package/dist/src/contracts/config.js.map +0 -1
- package/dist/src/contracts/constants.js +0 -8
- package/dist/src/contracts/constants.js.map +0 -1
- package/dist/src/contracts/contractInstances.js +0 -222
- package/dist/src/contracts/contractInstances.js.map +0 -1
- package/dist/src/contracts/index.js +0 -19
- package/dist/src/contracts/index.js.map +0 -1
- package/dist/src/contracts/safeDeploymentContracts.js +0 -95
- package/dist/src/contracts/safeDeploymentContracts.js.map +0 -1
- package/dist/src/contracts/utils.js +0 -324
- package/dist/src/contracts/utils.js.map +0 -1
- package/dist/src/index.js +0 -93
- package/dist/src/index.js.map +0 -1
- package/dist/src/managers/contractManager.js +0 -90
- package/dist/src/managers/contractManager.js.map +0 -1
- package/dist/src/managers/fallbackHandlerManager.js +0 -73
- package/dist/src/managers/fallbackHandlerManager.js.map +0 -1
- package/dist/src/managers/guardManager.js +0 -73
- package/dist/src/managers/guardManager.js.map +0 -1
- package/dist/src/managers/moduleManager.js +0 -88
- package/dist/src/managers/moduleManager.js.map +0 -1
- package/dist/src/managers/ownerManager.js +0 -124
- package/dist/src/managers/ownerManager.js.map +0 -1
- package/dist/src/types/contracts.js +0 -3
- package/dist/src/types/contracts.js.map +0 -1
- package/dist/src/types/index.js +0 -23
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/types/passkeys.js +0 -3
- package/dist/src/types/passkeys.js.map +0 -1
- package/dist/src/types/safeConfig.js +0 -3
- package/dist/src/types/safeConfig.js.map +0 -1
- package/dist/src/types/safeProvider.js +0 -3
- package/dist/src/types/safeProvider.js.map +0 -1
- package/dist/src/types/signing.d.ts +0 -8
- package/dist/src/types/signing.js +0 -12
- package/dist/src/types/signing.js.map +0 -1
- package/dist/src/types/transactions.js +0 -3
- package/dist/src/types/transactions.js.map +0 -1
- package/dist/src/utils/address.js +0 -21
- package/dist/src/utils/address.js.map +0 -1
- package/dist/src/utils/block.js +0 -14
- package/dist/src/utils/block.js.map +0 -1
- package/dist/src/utils/constants.js +0 -8
- package/dist/src/utils/constants.js.map +0 -1
- package/dist/src/utils/eip-3770/config.js +0 -376
- package/dist/src/utils/eip-3770/config.js.map +0 -1
- package/dist/src/utils/eip-3770/index.js +0 -47
- package/dist/src/utils/eip-3770/index.js.map +0 -1
- package/dist/src/utils/eip-712/encode.js +0 -127
- package/dist/src/utils/eip-712/encode.js.map +0 -1
- package/dist/src/utils/eip-712/index.js +0 -105
- package/dist/src/utils/eip-712/index.js.map +0 -1
- package/dist/src/utils/erc-20/index.js +0 -84
- package/dist/src/utils/erc-20/index.js.map +0 -1
- package/dist/src/utils/getProtocolKitVersion.js +0 -6
- package/dist/src/utils/getProtocolKitVersion.js.map +0 -1
- package/dist/src/utils/index.js +0 -24
- package/dist/src/utils/index.js.map +0 -1
- package/dist/src/utils/memoized.js +0 -41
- package/dist/src/utils/memoized.js.map +0 -1
- package/dist/src/utils/messages/SafeMessage.js +0 -20
- package/dist/src/utils/messages/SafeMessage.js.map +0 -1
- package/dist/src/utils/on-chain-tracking/generateOnChainIdentifier.js +0 -46
- package/dist/src/utils/on-chain-tracking/generateOnChainIdentifier.js.map +0 -1
- package/dist/src/utils/passkeys/PasskeyClient.js +0 -171
- package/dist/src/utils/passkeys/PasskeyClient.js.map +0 -1
- package/dist/src/utils/passkeys/createPasskeyDeploymentTransaction.js +0 -35
- package/dist/src/utils/passkeys/createPasskeyDeploymentTransaction.js.map +0 -1
- package/dist/src/utils/passkeys/extractPasskeyData.js +0 -232
- package/dist/src/utils/passkeys/extractPasskeyData.js.map +0 -1
- package/dist/src/utils/passkeys/getPasskeyOwnerAddress.js +0 -31
- package/dist/src/utils/passkeys/getPasskeyOwnerAddress.js.map +0 -1
- package/dist/src/utils/passkeys/index.js +0 -20
- package/dist/src/utils/passkeys/index.js.map +0 -1
- package/dist/src/utils/passkeys/isSharedSigner.js +0 -26
- package/dist/src/utils/passkeys/isSharedSigner.js.map +0 -1
- package/dist/src/utils/provider.js +0 -12
- package/dist/src/utils/provider.js.map +0 -1
- package/dist/src/utils/safeVersions.js +0 -54
- package/dist/src/utils/safeVersions.js.map +0 -1
- package/dist/src/utils/signatures/SafeSignature.js +0 -42
- package/dist/src/utils/signatures/SafeSignature.js.map +0 -1
- package/dist/src/utils/signatures/index.js +0 -19
- package/dist/src/utils/signatures/index.js.map +0 -1
- package/dist/src/utils/signatures/utils.js +0 -174
- package/dist/src/utils/signatures/utils.js.map +0 -1
- package/dist/src/utils/transactions/SafeTransaction.js +0 -20
- package/dist/src/utils/transactions/SafeTransaction.js.map +0 -1
- package/dist/src/utils/transactions/gas.js +0 -398
- package/dist/src/utils/transactions/gas.js.map +0 -1
- package/dist/src/utils/transactions/index.js +0 -21
- package/dist/src/utils/transactions/index.js.map +0 -1
- package/dist/src/utils/transactions/types.js +0 -3
- package/dist/src/utils/transactions/types.js.map +0 -1
- package/dist/src/utils/transactions/utils.js +0 -217
- package/dist/src/utils/transactions/utils.js.map +0 -1
- package/dist/src/utils/types.js +0 -66
- package/dist/src/utils/types.js.map +0 -1
package/dist/src/Safe.js
DELETED
|
@@ -1,1409 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
var _Safe_instances, _a, _Safe_predictedSafe, _Safe_safeProvider, _Safe_contractManager, _Safe_ownerManager, _Safe_moduleManager, _Safe_guardManager, _Safe_fallbackHandlerManager, _Safe_MAGIC_VALUE, _Safe_MAGIC_VALUE_BYTES, _Safe_onchainIdentifier, _Safe_initializeProtocolKit, _Safe_addPreValidatedSignature, _Safe_isReadyToExecute, _Safe_getFallbackHandlerContract;
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const types_kit_1 = require("@safe-global/types-kit");
|
|
19
|
-
const utils_1 = require("./contracts/utils");
|
|
20
|
-
const config_1 = require("./contracts/config");
|
|
21
|
-
const contractManager_1 = __importDefault(require("./managers/contractManager"));
|
|
22
|
-
const fallbackHandlerManager_1 = __importDefault(require("./managers/fallbackHandlerManager"));
|
|
23
|
-
const guardManager_1 = __importDefault(require("./managers/guardManager"));
|
|
24
|
-
const moduleManager_1 = __importDefault(require("./managers/moduleManager"));
|
|
25
|
-
const ownerManager_1 = __importDefault(require("./managers/ownerManager"));
|
|
26
|
-
const types_1 = require("./types");
|
|
27
|
-
const utils_2 = require("./utils");
|
|
28
|
-
const SafeTransaction_1 = __importDefault(require("./utils/transactions/SafeTransaction"));
|
|
29
|
-
const utils_3 = require("./utils/transactions/utils");
|
|
30
|
-
const types_2 = require("./utils/types");
|
|
31
|
-
const safeDeploymentContracts_1 = require("./contracts/safeDeploymentContracts");
|
|
32
|
-
const SafeMessage_1 = __importDefault(require("./utils/messages/SafeMessage"));
|
|
33
|
-
const satisfies_1 = __importDefault(require("semver/functions/satisfies"));
|
|
34
|
-
const SafeProvider_1 = __importDefault(require("./SafeProvider"));
|
|
35
|
-
const types_3 = require("./utils/types");
|
|
36
|
-
const getPasskeyOwnerAddress_1 = __importDefault(require("./utils/passkeys/getPasskeyOwnerAddress"));
|
|
37
|
-
const createPasskeyDeploymentTransaction_1 = __importDefault(require("./utils/passkeys/createPasskeyDeploymentTransaction"));
|
|
38
|
-
const generateOnChainIdentifier_1 = __importDefault(require("./utils/on-chain-tracking/generateOnChainIdentifier"));
|
|
39
|
-
const getProtocolKitVersion_1 = require("./utils/getProtocolKitVersion");
|
|
40
|
-
const EQ_OR_GT_1_4_1 = '>=1.4.1';
|
|
41
|
-
const EQ_OR_GT_1_3_0 = '>=1.3.0';
|
|
42
|
-
class Safe {
|
|
43
|
-
constructor() {
|
|
44
|
-
_Safe_instances.add(this);
|
|
45
|
-
_Safe_predictedSafe.set(this, void 0);
|
|
46
|
-
_Safe_safeProvider.set(this, void 0);
|
|
47
|
-
_Safe_contractManager.set(this, void 0);
|
|
48
|
-
_Safe_ownerManager.set(this, void 0);
|
|
49
|
-
_Safe_moduleManager.set(this, void 0);
|
|
50
|
-
_Safe_guardManager.set(this, void 0);
|
|
51
|
-
_Safe_fallbackHandlerManager.set(this, void 0);
|
|
52
|
-
_Safe_MAGIC_VALUE.set(this, '0x1626ba7e');
|
|
53
|
-
_Safe_MAGIC_VALUE_BYTES.set(this, '0x20c13b0b'
|
|
54
|
-
// on-chain Analytics
|
|
55
|
-
);
|
|
56
|
-
// on-chain Analytics
|
|
57
|
-
_Safe_onchainIdentifier.set(this, ''
|
|
58
|
-
/**
|
|
59
|
-
* Creates an instance of the Safe Core SDK.
|
|
60
|
-
* @param config - Ethers Safe configuration
|
|
61
|
-
* @returns The Safe Core SDK instance
|
|
62
|
-
* @throws "The SDK must be initialized with a safeAddress or a predictedSafe"
|
|
63
|
-
* @throws "SafeProxy contract is not deployed on the current network"
|
|
64
|
-
* @throws "MultiSend contract is not deployed on the current network"
|
|
65
|
-
* @throws "MultiSendCallOnly contract is not deployed on the current network"
|
|
66
|
-
*/
|
|
67
|
-
);
|
|
68
|
-
/**
|
|
69
|
-
* Call the CompatibilityFallbackHandler getMessageHash method
|
|
70
|
-
*
|
|
71
|
-
* @param messageHash The hash of the message
|
|
72
|
-
* @returns Returns the Safe message hash to be signed
|
|
73
|
-
* @link https://github.com/safe-global/safe-contracts/blob/8ffae95faa815acf86ec8b50021ebe9f96abde10/contracts/handler/CompatibilityFallbackHandler.sol#L26-L28
|
|
74
|
-
*/
|
|
75
|
-
this.getSafeMessageHash = async (messageHash) => {
|
|
76
|
-
const safeAddress = await this.getAddress();
|
|
77
|
-
const safeVersion = this.getContractVersion();
|
|
78
|
-
const chainId = await this.getChainId();
|
|
79
|
-
return (0, utils_2.calculateSafeMessageHash)(safeAddress, messageHash, safeVersion, chainId);
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Call the CompatibilityFallbackHandler isValidSignature method
|
|
83
|
-
*
|
|
84
|
-
* @param messageHash The hash of the message
|
|
85
|
-
* @param signature The signature to be validated or '0x'. You can send as signature one of the following:
|
|
86
|
-
* 1) An array of SafeSignature. In this case the signatures are concatenated for validation (buildSignatureBytes())
|
|
87
|
-
* 2) The concatenated signatures as string
|
|
88
|
-
* 3) '0x' if you want to validate an onchain message (Approved hash)
|
|
89
|
-
* @returns A boolean indicating if the signature is valid
|
|
90
|
-
* @link https://github.com/safe-global/safe-contracts/blob/main/contracts/handler/CompatibilityFallbackHandler.sol
|
|
91
|
-
*/
|
|
92
|
-
this.isValidSignature = async (messageHash, signature = '0x') => {
|
|
93
|
-
const safeAddress = await this.getAddress();
|
|
94
|
-
const fallbackHandler = await __classPrivateFieldGet(this, _Safe_instances, "m", _Safe_getFallbackHandlerContract).call(this);
|
|
95
|
-
const signatureToCheck = signature && Array.isArray(signature) ? (0, utils_2.buildSignatureBytes)(signature) : signature;
|
|
96
|
-
// both bytes and bytes32 ends up being resolved to a bytes-like structure which is represented by a `0x` prefixed address.
|
|
97
|
-
// because there is an overload going on, named-tuples (https://www.typescriptlang.org/play/?ts=4.0.2#example/named-tuples) are used to solve the ambiguity.
|
|
98
|
-
const bytes32Tuple = [
|
|
99
|
-
(0, types_3.asHash)(messageHash),
|
|
100
|
-
(0, types_3.asHex)(signatureToCheck)
|
|
101
|
-
];
|
|
102
|
-
const data = fallbackHandler.encode('isValidSignature', bytes32Tuple);
|
|
103
|
-
const bytesTuple = [
|
|
104
|
-
(0, types_3.asHash)(messageHash),
|
|
105
|
-
(0, types_3.asHex)(signatureToCheck)
|
|
106
|
-
];
|
|
107
|
-
const bytesData = fallbackHandler.encode('isValidSignature', bytesTuple);
|
|
108
|
-
try {
|
|
109
|
-
const isValidSignatureResponse = await Promise.all([
|
|
110
|
-
__classPrivateFieldGet(this, _Safe_safeProvider, "f").call({
|
|
111
|
-
from: safeAddress,
|
|
112
|
-
to: safeAddress,
|
|
113
|
-
data: data
|
|
114
|
-
}),
|
|
115
|
-
__classPrivateFieldGet(this, _Safe_safeProvider, "f").call({
|
|
116
|
-
from: safeAddress,
|
|
117
|
-
to: safeAddress,
|
|
118
|
-
data: bytesData
|
|
119
|
-
})
|
|
120
|
-
]);
|
|
121
|
-
return (!!isValidSignatureResponse.length &&
|
|
122
|
-
(isValidSignatureResponse[0].slice(0, 10).toLowerCase() === __classPrivateFieldGet(this, _Safe_MAGIC_VALUE, "f") ||
|
|
123
|
-
isValidSignatureResponse[1].slice(0, 10).toLowerCase() === __classPrivateFieldGet(this, _Safe_MAGIC_VALUE_BYTES, "f")));
|
|
124
|
-
}
|
|
125
|
-
catch (error) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
this.getContractInfo = ({ contractAddress }) => {
|
|
130
|
-
return (0, config_1.getContractInfo)(contractAddress);
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Creates an instance of the Safe Core SDK.
|
|
135
|
-
* @param config - Ethers Safe configuration
|
|
136
|
-
* @returns The Safe Core SDK instance
|
|
137
|
-
* @throws "The SDK must be initialized with a safeAddress or a predictedSafe"
|
|
138
|
-
* @throws "SafeProxy contract is not deployed on the current network"
|
|
139
|
-
* @throws "MultiSend contract is not deployed on the current network"
|
|
140
|
-
* @throws "MultiSendCallOnly contract is not deployed on the current network"
|
|
141
|
-
*/
|
|
142
|
-
static async init(config) {
|
|
143
|
-
const protocolKit = new _a();
|
|
144
|
-
await __classPrivateFieldGet(protocolKit, _Safe_instances, "m", _Safe_initializeProtocolKit).call(protocolKit, config);
|
|
145
|
-
return protocolKit;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Returns a new instance of the Safe Core SDK.
|
|
149
|
-
* @param config - Connect Safe configuration
|
|
150
|
-
* @throws "A safeAddress and a predictedSafe cannot be connected at the same time"
|
|
151
|
-
* @throws "SafeProxy contract is not deployed on the current network"
|
|
152
|
-
* @throws "MultiSend contract is not deployed on the current network"
|
|
153
|
-
* @throws "MultiSendCallOnly contract is not deployed on the current network"
|
|
154
|
-
*/
|
|
155
|
-
async connect(config) {
|
|
156
|
-
const { provider, signer, safeAddress, predictedSafe, isL1SafeSingleton, contractNetworks } = config;
|
|
157
|
-
const configProps = {
|
|
158
|
-
provider: provider || __classPrivateFieldGet(this, _Safe_safeProvider, "f").provider,
|
|
159
|
-
signer,
|
|
160
|
-
isL1SafeSingleton: isL1SafeSingleton || __classPrivateFieldGet(this, _Safe_contractManager, "f").isL1SafeSingleton,
|
|
161
|
-
contractNetworks: contractNetworks || __classPrivateFieldGet(this, _Safe_contractManager, "f").contractNetworks
|
|
162
|
-
};
|
|
163
|
-
// A new existing Safe is connected to the Signer
|
|
164
|
-
if (safeAddress) {
|
|
165
|
-
return await _a.init({
|
|
166
|
-
safeAddress,
|
|
167
|
-
...configProps
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
// A new predicted Safe is connected to the Signer
|
|
171
|
-
if (predictedSafe) {
|
|
172
|
-
return await _a.init({
|
|
173
|
-
predictedSafe,
|
|
174
|
-
...configProps
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
// The previous predicted Safe is connected to a new Signer
|
|
178
|
-
if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f")) {
|
|
179
|
-
return await _a.init({
|
|
180
|
-
predictedSafe: __classPrivateFieldGet(this, _Safe_predictedSafe, "f"),
|
|
181
|
-
...configProps
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
// The previous existing Safe is connected to a new Signer
|
|
185
|
-
return await _a.init({
|
|
186
|
-
safeAddress: await this.getAddress(),
|
|
187
|
-
...configProps
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Returns the initialization code to deploy a Safe account based on the predicted address.
|
|
192
|
-
*
|
|
193
|
-
* @returns The Safe configuration
|
|
194
|
-
*/
|
|
195
|
-
async getInitCode() {
|
|
196
|
-
if (!__classPrivateFieldGet(this, _Safe_predictedSafe, "f")) {
|
|
197
|
-
throw new Error('The Safe already exists');
|
|
198
|
-
}
|
|
199
|
-
const chainId = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getChainId();
|
|
200
|
-
return (0, utils_1.getPredictedSafeAddressInitCode)({
|
|
201
|
-
safeProvider: __classPrivateFieldGet(this, _Safe_safeProvider, "f"),
|
|
202
|
-
chainId,
|
|
203
|
-
customContracts: __classPrivateFieldGet(this, _Safe_contractManager, "f").contractNetworks?.[chainId.toString()],
|
|
204
|
-
...__classPrivateFieldGet(this, _Safe_predictedSafe, "f")
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Returns the predicted Safe configuration.
|
|
209
|
-
* @returns {PredictedSafeProps | undefined} The predicted Safe configuration
|
|
210
|
-
*/
|
|
211
|
-
getPredictedSafe() {
|
|
212
|
-
return __classPrivateFieldGet(this, _Safe_predictedSafe, "f");
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Returns the address of the current SafeProxy contract.
|
|
216
|
-
*
|
|
217
|
-
* @returns The address of the SafeProxy contract
|
|
218
|
-
*/
|
|
219
|
-
async getAddress() {
|
|
220
|
-
if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f")) {
|
|
221
|
-
const safeVersion = this.getContractVersion();
|
|
222
|
-
if (!(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ACCOUNT_ABSTRACTION, safeVersion)) {
|
|
223
|
-
throw new Error('Account Abstraction functionality is not available for Safes with version lower than v1.3.0');
|
|
224
|
-
}
|
|
225
|
-
const chainId = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getChainId();
|
|
226
|
-
return (0, utils_1.predictSafeAddress)({
|
|
227
|
-
safeProvider: __classPrivateFieldGet(this, _Safe_safeProvider, "f"),
|
|
228
|
-
chainId,
|
|
229
|
-
isL1SafeSingleton: __classPrivateFieldGet(this, _Safe_contractManager, "f").isL1SafeSingleton,
|
|
230
|
-
customContracts: __classPrivateFieldGet(this, _Safe_contractManager, "f").contractNetworks?.[chainId.toString()],
|
|
231
|
-
...__classPrivateFieldGet(this, _Safe_predictedSafe, "f")
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
|
|
235
|
-
throw new Error('Safe is not deployed');
|
|
236
|
-
}
|
|
237
|
-
return __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.getAddress();
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Returns the ContractManager
|
|
241
|
-
*
|
|
242
|
-
* @returns The current ContractManager
|
|
243
|
-
* */
|
|
244
|
-
getContractManager() {
|
|
245
|
-
return __classPrivateFieldGet(this, _Safe_contractManager, "f");
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Returns the current SafeProvider.
|
|
249
|
-
*
|
|
250
|
-
* @returns The current SafeProvider
|
|
251
|
-
*/
|
|
252
|
-
getSafeProvider() {
|
|
253
|
-
return __classPrivateFieldGet(this, _Safe_safeProvider, "f");
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Returns the address of the MultiSend contract.
|
|
257
|
-
*
|
|
258
|
-
* @returns The address of the MultiSend contract
|
|
259
|
-
*/
|
|
260
|
-
getMultiSendAddress() {
|
|
261
|
-
return __classPrivateFieldGet(this, _Safe_contractManager, "f").multiSendContract.getAddress();
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Returns the address of the MultiSendCallOnly contract.
|
|
265
|
-
*
|
|
266
|
-
* @returns The address of the MultiSendCallOnly contract
|
|
267
|
-
*/
|
|
268
|
-
getMultiSendCallOnlyAddress() {
|
|
269
|
-
return __classPrivateFieldGet(this, _Safe_contractManager, "f").multiSendCallOnlyContract.getAddress();
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Checks if the current Safe is deployed.
|
|
273
|
-
*
|
|
274
|
-
* @returns TRUE if the Safe contract is deployed
|
|
275
|
-
*/
|
|
276
|
-
async isSafeDeployed() {
|
|
277
|
-
const safeAddress = await this.getAddress();
|
|
278
|
-
const isSafeDeployed = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").isContractDeployed(safeAddress);
|
|
279
|
-
return isSafeDeployed;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Returns the Safe Singleton contract version.
|
|
283
|
-
*
|
|
284
|
-
* @returns The Safe Singleton contract version
|
|
285
|
-
*/
|
|
286
|
-
getContractVersion() {
|
|
287
|
-
if (__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
|
|
288
|
-
return __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.safeVersion;
|
|
289
|
-
}
|
|
290
|
-
if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f")?.safeDeploymentConfig?.safeVersion) {
|
|
291
|
-
return __classPrivateFieldGet(this, _Safe_predictedSafe, "f").safeDeploymentConfig.safeVersion;
|
|
292
|
-
}
|
|
293
|
-
return config_1.DEFAULT_SAFE_VERSION;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Returns the list of Safe owner accounts.
|
|
297
|
-
*
|
|
298
|
-
* @returns The list of owners
|
|
299
|
-
*/
|
|
300
|
-
async getOwners() {
|
|
301
|
-
if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f")?.safeAccountConfig.owners) {
|
|
302
|
-
return Promise.resolve(__classPrivateFieldGet(this, _Safe_predictedSafe, "f").safeAccountConfig.owners);
|
|
303
|
-
}
|
|
304
|
-
return __classPrivateFieldGet(this, _Safe_ownerManager, "f").getOwners();
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Returns the Safe nonce.
|
|
308
|
-
*
|
|
309
|
-
* @returns The Safe nonce
|
|
310
|
-
*/
|
|
311
|
-
async getNonce() {
|
|
312
|
-
if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
|
|
313
|
-
return Promise.resolve(0);
|
|
314
|
-
}
|
|
315
|
-
const nonce = await __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.getNonce();
|
|
316
|
-
return Number(nonce);
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Returns the Safe threshold.
|
|
320
|
-
*
|
|
321
|
-
* @returns The Safe threshold
|
|
322
|
-
*/
|
|
323
|
-
async getThreshold() {
|
|
324
|
-
if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f")?.safeAccountConfig.threshold) {
|
|
325
|
-
return Promise.resolve(__classPrivateFieldGet(this, _Safe_predictedSafe, "f").safeAccountConfig.threshold);
|
|
326
|
-
}
|
|
327
|
-
return __classPrivateFieldGet(this, _Safe_ownerManager, "f").getThreshold();
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Returns the chainId of the connected network.
|
|
331
|
-
*
|
|
332
|
-
* @returns The chainId of the connected network
|
|
333
|
-
*/
|
|
334
|
-
async getChainId() {
|
|
335
|
-
return __classPrivateFieldGet(this, _Safe_safeProvider, "f").getChainId();
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Returns the ETH balance of the Safe.
|
|
339
|
-
*
|
|
340
|
-
* @returns The ETH balance of the Safe
|
|
341
|
-
*/
|
|
342
|
-
async getBalance() {
|
|
343
|
-
return __classPrivateFieldGet(this, _Safe_safeProvider, "f").getBalance(await this.getAddress());
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Returns the address of the FallbackHandler contract.
|
|
347
|
-
*
|
|
348
|
-
* @returns The address of the FallbackHandler contract
|
|
349
|
-
*/
|
|
350
|
-
getFallbackHandler() {
|
|
351
|
-
return __classPrivateFieldGet(this, _Safe_fallbackHandlerManager, "f").getFallbackHandler();
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Returns the enabled Safe guard or 0x address if no guards are enabled.
|
|
355
|
-
*
|
|
356
|
-
* @returns The address of the enabled Safe guard
|
|
357
|
-
* @throws "Current version of the Safe does not support Safe transaction guards functionality"
|
|
358
|
-
*/
|
|
359
|
-
async getGuard() {
|
|
360
|
-
return __classPrivateFieldGet(this, _Safe_guardManager, "f").getGuard();
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Returns the list of addresses of all the enabled Safe modules.
|
|
364
|
-
*
|
|
365
|
-
* @returns The list of addresses of all the enabled Safe modules
|
|
366
|
-
*/
|
|
367
|
-
async getModules() {
|
|
368
|
-
return __classPrivateFieldGet(this, _Safe_moduleManager, "f").getModules();
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Returns the list of addresses of all the enabled Safe modules. The list will start on the next position address in relation to start.
|
|
372
|
-
*
|
|
373
|
-
* @param start - The address to be "offsetted" from the list, should be SENTINEL_ADDRESS otherwise.
|
|
374
|
-
* @param pageSize - The size of the page. It will be the max length of the returning array. Must be greater then 0.
|
|
375
|
-
* @returns The list of addresses of all the enabled Safe modules
|
|
376
|
-
*/
|
|
377
|
-
async getModulesPaginated(start, pageSize = 10) {
|
|
378
|
-
return __classPrivateFieldGet(this, _Safe_moduleManager, "f").getModulesPaginated(start, pageSize);
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Checks if a specific Safe module is enabled for the current Safe.
|
|
382
|
-
*
|
|
383
|
-
* @param moduleAddress - The desired module address
|
|
384
|
-
* @returns TRUE if the module is enabled
|
|
385
|
-
*/
|
|
386
|
-
async isModuleEnabled(moduleAddress) {
|
|
387
|
-
return __classPrivateFieldGet(this, _Safe_moduleManager, "f").isModuleEnabled(moduleAddress);
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Checks if a specific address is an owner of the current Safe.
|
|
391
|
-
*
|
|
392
|
-
* @param ownerAddress - The account address
|
|
393
|
-
* @returns TRUE if the account is an owner
|
|
394
|
-
*/
|
|
395
|
-
async isOwner(ownerAddress) {
|
|
396
|
-
if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f")?.safeAccountConfig.owners) {
|
|
397
|
-
return Promise.resolve(__classPrivateFieldGet(this, _Safe_predictedSafe, "f")?.safeAccountConfig.owners.some((owner) => (0, utils_2.sameString)(owner, ownerAddress)));
|
|
398
|
-
}
|
|
399
|
-
return __classPrivateFieldGet(this, _Safe_ownerManager, "f").isOwner(ownerAddress);
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Returns a Safe transaction ready to be signed by the owners.
|
|
403
|
-
*
|
|
404
|
-
* @param createTransactionProps - The createTransaction props
|
|
405
|
-
* @returns The Safe transaction
|
|
406
|
-
* @throws "Invalid empty array of transactions"
|
|
407
|
-
*/
|
|
408
|
-
async createTransaction({ transactions, onlyCalls = false, options }) {
|
|
409
|
-
const safeVersion = this.getContractVersion();
|
|
410
|
-
if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f") && !(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ACCOUNT_ABSTRACTION, safeVersion)) {
|
|
411
|
-
throw new Error('Account Abstraction functionality is not available for Safes with version lower than v1.3.0');
|
|
412
|
-
}
|
|
413
|
-
if (transactions.length === 0) {
|
|
414
|
-
throw new Error('Invalid empty array of transactions');
|
|
415
|
-
}
|
|
416
|
-
let newTransaction;
|
|
417
|
-
if (transactions.length > 1) {
|
|
418
|
-
const multiSendContract = onlyCalls
|
|
419
|
-
? __classPrivateFieldGet(this, _Safe_contractManager, "f").multiSendCallOnlyContract
|
|
420
|
-
: __classPrivateFieldGet(this, _Safe_contractManager, "f").multiSendContract;
|
|
421
|
-
const multiSendData = (0, utils_3.encodeMultiSendData)(transactions.map(utils_3.standardizeMetaTransactionData));
|
|
422
|
-
const multiSendTransaction = {
|
|
423
|
-
...options,
|
|
424
|
-
to: multiSendContract.getAddress(),
|
|
425
|
-
value: '0',
|
|
426
|
-
data: multiSendContract.encode('multiSend', [(0, types_3.asHex)(multiSendData)]),
|
|
427
|
-
operation: types_kit_1.OperationType.DelegateCall
|
|
428
|
-
};
|
|
429
|
-
newTransaction = multiSendTransaction;
|
|
430
|
-
}
|
|
431
|
-
else {
|
|
432
|
-
newTransaction = { ...options, ...transactions[0] };
|
|
433
|
-
}
|
|
434
|
-
if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f")) {
|
|
435
|
-
return new SafeTransaction_1.default(await (0, utils_3.standardizeSafeTransactionData)({
|
|
436
|
-
predictedSafe: __classPrivateFieldGet(this, _Safe_predictedSafe, "f"),
|
|
437
|
-
provider: __classPrivateFieldGet(this, _Safe_safeProvider, "f").provider,
|
|
438
|
-
tx: newTransaction,
|
|
439
|
-
contractNetworks: __classPrivateFieldGet(this, _Safe_contractManager, "f").contractNetworks
|
|
440
|
-
}));
|
|
441
|
-
}
|
|
442
|
-
if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
|
|
443
|
-
throw new Error('Safe is not deployed');
|
|
444
|
-
}
|
|
445
|
-
return new SafeTransaction_1.default(await (0, utils_3.standardizeSafeTransactionData)({
|
|
446
|
-
safeContract: __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract,
|
|
447
|
-
provider: __classPrivateFieldGet(this, _Safe_safeProvider, "f").provider,
|
|
448
|
-
tx: newTransaction,
|
|
449
|
-
contractNetworks: __classPrivateFieldGet(this, _Safe_contractManager, "f").contractNetworks
|
|
450
|
-
}));
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Returns a Safe transaction ready to be signed by the owners that invalidates the pending Safe transaction/s with a specific nonce.
|
|
454
|
-
*
|
|
455
|
-
* @param nonce - The nonce of the transaction/s that are going to be rejected
|
|
456
|
-
* @returns The Safe transaction that invalidates the pending Safe transaction/s
|
|
457
|
-
*/
|
|
458
|
-
async createRejectionTransaction(nonce) {
|
|
459
|
-
const safeTransactionData = {
|
|
460
|
-
to: await this.getAddress(),
|
|
461
|
-
value: '0',
|
|
462
|
-
data: '0x'
|
|
463
|
-
};
|
|
464
|
-
const options = {
|
|
465
|
-
nonce,
|
|
466
|
-
safeTxGas: '0'
|
|
467
|
-
};
|
|
468
|
-
return this.createTransaction({ transactions: [safeTransactionData], options });
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Copies a Safe transaction
|
|
472
|
-
*
|
|
473
|
-
* @param safeTransaction - The Safe transaction
|
|
474
|
-
* @returns The new Safe transaction
|
|
475
|
-
*/
|
|
476
|
-
async copyTransaction(safeTransaction) {
|
|
477
|
-
const { to, value, data, operation, ...options } = safeTransaction.data;
|
|
478
|
-
const safeTransactionData = {
|
|
479
|
-
to,
|
|
480
|
-
value,
|
|
481
|
-
data,
|
|
482
|
-
operation
|
|
483
|
-
};
|
|
484
|
-
const signedSafeTransaction = await this.createTransaction({
|
|
485
|
-
transactions: [safeTransactionData],
|
|
486
|
-
options
|
|
487
|
-
});
|
|
488
|
-
safeTransaction.signatures.forEach((signature) => {
|
|
489
|
-
signedSafeTransaction.addSignature(signature);
|
|
490
|
-
});
|
|
491
|
-
return signedSafeTransaction;
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* Returns the transaction hash of a Safe transaction.
|
|
495
|
-
*
|
|
496
|
-
* @param safeTransaction - The Safe transaction
|
|
497
|
-
* @returns The hash of the Safe transaction
|
|
498
|
-
*/
|
|
499
|
-
async getTransactionHash(safeTransaction) {
|
|
500
|
-
const safeAddress = await this.getAddress();
|
|
501
|
-
const safeVersion = this.getContractVersion();
|
|
502
|
-
const chainId = await this.getChainId();
|
|
503
|
-
return (0, utils_2.calculateSafeTransactionHash)(safeAddress, safeTransaction.data, safeVersion, chainId);
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Signs a hash using the current signer account.
|
|
507
|
-
*
|
|
508
|
-
* @param hash - The hash to sign
|
|
509
|
-
* @returns The Safe signature
|
|
510
|
-
*/
|
|
511
|
-
async signHash(hash) {
|
|
512
|
-
const isPasskeySigner = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").isPasskeySigner();
|
|
513
|
-
const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
|
|
514
|
-
if (isPasskeySigner && signerAddress) {
|
|
515
|
-
let signature = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").signMessage(hash);
|
|
516
|
-
signature = await (0, utils_2.adjustVInSignature)(types_1.SigningMethod.ETH_SIGN, signature, hash, signerAddress);
|
|
517
|
-
const safeSignature = new utils_2.EthSafeSignature(signerAddress, signature, true);
|
|
518
|
-
return safeSignature;
|
|
519
|
-
}
|
|
520
|
-
const signature = await (0, utils_2.generateSignature)(__classPrivateFieldGet(this, _Safe_safeProvider, "f"), hash);
|
|
521
|
-
return signature;
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Returns a Safe message ready to be signed by the owners.
|
|
525
|
-
*
|
|
526
|
-
* @param message - The message
|
|
527
|
-
* @returns The Safe message
|
|
528
|
-
*/
|
|
529
|
-
createMessage(message) {
|
|
530
|
-
return new SafeMessage_1.default(message);
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Returns the Safe message with a new signature
|
|
534
|
-
*
|
|
535
|
-
* @param message The message to be signed
|
|
536
|
-
* @param signingMethod The signature type
|
|
537
|
-
* @param preimageSafeAddress If the preimage is required, the address of the Safe that will be used to calculate the preimage.
|
|
538
|
-
* This field is mandatory for 1.4.1 contract versions Because the safe uses the old EIP-1271 interface which uses `bytes` instead of `bytes32` for the message
|
|
539
|
-
* we need to use the pre-image of the message to calculate the message hash
|
|
540
|
-
* https://github.com/safe-global/safe-contracts/blob/192c7dc67290940fcbc75165522bb86a37187069/test/core/Safe.Signatures.spec.ts#L229-L233
|
|
541
|
-
* @returns The signed Safe message
|
|
542
|
-
*/
|
|
543
|
-
async signMessage(message, signingMethod = types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4, preimageSafeAddress) {
|
|
544
|
-
const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
|
|
545
|
-
if (!signerAddress) {
|
|
546
|
-
throw new Error('The protocol-kit requires a signer to use this method');
|
|
547
|
-
}
|
|
548
|
-
const addressIsOwner = await this.isOwner(signerAddress);
|
|
549
|
-
if (!addressIsOwner) {
|
|
550
|
-
throw new Error('Messages can only be signed by Safe owners');
|
|
551
|
-
}
|
|
552
|
-
const safeVersion = this.getContractVersion();
|
|
553
|
-
if (signingMethod === types_1.SigningMethod.SAFE_SIGNATURE &&
|
|
554
|
-
(0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_4_1) &&
|
|
555
|
-
!preimageSafeAddress) {
|
|
556
|
-
throw new Error('The parent Safe account address is mandatory for contract signatures');
|
|
557
|
-
}
|
|
558
|
-
let signature;
|
|
559
|
-
if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4) {
|
|
560
|
-
signature = await this.signTypedData(message, 'v4');
|
|
561
|
-
}
|
|
562
|
-
else if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V3) {
|
|
563
|
-
signature = await this.signTypedData(message, 'v3');
|
|
564
|
-
}
|
|
565
|
-
else if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA) {
|
|
566
|
-
signature = await this.signTypedData(message, undefined);
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
const chainId = await this.getChainId();
|
|
570
|
-
if (!(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ETH_SIGN, safeVersion)) {
|
|
571
|
-
throw new Error('eth_sign is only supported by Safes >= v1.1.0');
|
|
572
|
-
}
|
|
573
|
-
let safeMessageHash;
|
|
574
|
-
if (signingMethod === types_1.SigningMethod.SAFE_SIGNATURE &&
|
|
575
|
-
preimageSafeAddress &&
|
|
576
|
-
(0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_4_1)) {
|
|
577
|
-
const messageHashData = (0, utils_2.preimageSafeMessageHash)(preimageSafeAddress, (0, utils_2.hashSafeMessage)(message.data), safeVersion, chainId);
|
|
578
|
-
safeMessageHash = await this.getSafeMessageHash(messageHashData);
|
|
579
|
-
}
|
|
580
|
-
else {
|
|
581
|
-
safeMessageHash = await this.getSafeMessageHash((0, utils_2.hashSafeMessage)(message.data));
|
|
582
|
-
}
|
|
583
|
-
signature = await this.signHash(safeMessageHash);
|
|
584
|
-
}
|
|
585
|
-
const signedSafeMessage = this.createMessage(message.data);
|
|
586
|
-
message.signatures.forEach((signature) => {
|
|
587
|
-
signedSafeMessage.addSignature(signature);
|
|
588
|
-
});
|
|
589
|
-
signedSafeMessage.addSignature(signature);
|
|
590
|
-
return signedSafeMessage;
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* Signs a transaction according to the EIP-712 using the current signer account.
|
|
594
|
-
*
|
|
595
|
-
* @param eip712Data - The Safe Transaction or message hash to be signed
|
|
596
|
-
* @param methodVersion - EIP-712 version. Optional
|
|
597
|
-
* @returns The Safe signature
|
|
598
|
-
*/
|
|
599
|
-
async signTypedData(eip712Data, methodVersion) {
|
|
600
|
-
const safeEIP712Args = {
|
|
601
|
-
safeAddress: await this.getAddress(),
|
|
602
|
-
safeVersion: this.getContractVersion(),
|
|
603
|
-
chainId: await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getChainId(),
|
|
604
|
-
data: eip712Data.data
|
|
605
|
-
};
|
|
606
|
-
return (0, utils_2.generateEIP712Signature)(__classPrivateFieldGet(this, _Safe_safeProvider, "f"), safeEIP712Args, methodVersion);
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Adds the signature of the current signer to the Safe transaction object.
|
|
610
|
-
*
|
|
611
|
-
* @param safeTransaction - The Safe transaction to be signed
|
|
612
|
-
* @param signingMethod - Method followed to sign a transaction. Optional. Default value is "eth_sign"
|
|
613
|
-
* @param preimageSafeAddress - If the preimage is required, the address of the Safe that will be used to calculate the preimage
|
|
614
|
-
* This field is mandatory for 1.3.0 and 1.4.1 contract versions Because the safe uses the old EIP-1271 interface which uses `bytes` instead of `bytes32` for the message
|
|
615
|
-
* we need to use the pre-image of the message to calculate the message hash
|
|
616
|
-
* https://github.com/safe-global/safe-contracts/blob/192c7dc67290940fcbc75165522bb86a37187069/test/core/Safe.Signatures.spec.ts#L229-L233
|
|
617
|
-
* @returns The signed Safe transaction
|
|
618
|
-
* @throws "Transactions can only be signed by Safe owners"
|
|
619
|
-
*/
|
|
620
|
-
async signTransaction(safeTransaction, signingMethod = types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4, preimageSafeAddress) {
|
|
621
|
-
const transaction = (0, utils_2.isSafeMultisigTransactionResponse)(safeTransaction)
|
|
622
|
-
? await this.toSafeTransactionType(safeTransaction)
|
|
623
|
-
: safeTransaction;
|
|
624
|
-
const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
|
|
625
|
-
if (!signerAddress) {
|
|
626
|
-
throw new Error('The protocol-kit requires a signer to use this method');
|
|
627
|
-
}
|
|
628
|
-
const addressIsOwner = await this.isOwner(signerAddress);
|
|
629
|
-
if (!addressIsOwner) {
|
|
630
|
-
throw new Error('Transactions can only be signed by Safe owners');
|
|
631
|
-
}
|
|
632
|
-
const safeVersion = this.getContractVersion();
|
|
633
|
-
if (signingMethod === types_1.SigningMethod.SAFE_SIGNATURE &&
|
|
634
|
-
(0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_3_0) &&
|
|
635
|
-
!preimageSafeAddress) {
|
|
636
|
-
throw new Error('The parent Safe account address is mandatory for contract signatures');
|
|
637
|
-
}
|
|
638
|
-
let signature;
|
|
639
|
-
const isPasskeySigner = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").isPasskeySigner();
|
|
640
|
-
if (isPasskeySigner) {
|
|
641
|
-
const txHash = await this.getTransactionHash(transaction);
|
|
642
|
-
signature = await this.signHash(txHash);
|
|
643
|
-
}
|
|
644
|
-
else if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4) {
|
|
645
|
-
signature = await this.signTypedData(transaction, 'v4');
|
|
646
|
-
}
|
|
647
|
-
else if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V3) {
|
|
648
|
-
signature = await this.signTypedData(transaction, 'v3');
|
|
649
|
-
}
|
|
650
|
-
else if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA) {
|
|
651
|
-
signature = await this.signTypedData(transaction, undefined);
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
const safeVersion = this.getContractVersion();
|
|
655
|
-
const chainId = await this.getChainId();
|
|
656
|
-
if (!(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ETH_SIGN, safeVersion)) {
|
|
657
|
-
throw new Error('eth_sign is only supported by Safes >= v1.1.0');
|
|
658
|
-
}
|
|
659
|
-
let txHash;
|
|
660
|
-
// IMPORTANT: because the safe uses the old EIP-1271 interface which uses `bytes` instead of `bytes32` for the message
|
|
661
|
-
// we need to use the pre-image of the transaction hash to calculate the message hash
|
|
662
|
-
// https://github.com/safe-global/safe-contracts/blob/192c7dc67290940fcbc75165522bb86a37187069/test/core/Safe.Signatures.spec.ts#L229-L233
|
|
663
|
-
if (signingMethod === types_1.SigningMethod.SAFE_SIGNATURE &&
|
|
664
|
-
(0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_3_0) &&
|
|
665
|
-
preimageSafeAddress) {
|
|
666
|
-
const txHashData = (0, utils_2.preimageSafeTransactionHash)(preimageSafeAddress, safeTransaction.data, safeVersion, chainId);
|
|
667
|
-
txHash = await this.getSafeMessageHash(txHashData);
|
|
668
|
-
}
|
|
669
|
-
else {
|
|
670
|
-
txHash = await this.getTransactionHash(transaction);
|
|
671
|
-
}
|
|
672
|
-
signature = await this.signHash(txHash);
|
|
673
|
-
}
|
|
674
|
-
const signedSafeTransaction = await this.copyTransaction(transaction);
|
|
675
|
-
signedSafeTransaction.addSignature(signature);
|
|
676
|
-
return signedSafeTransaction;
|
|
677
|
-
}
|
|
678
|
-
/**
|
|
679
|
-
* Approves on-chain a hash using the current signer account.
|
|
680
|
-
*
|
|
681
|
-
* @param hash - The hash to approve
|
|
682
|
-
* @param options - The Safe transaction execution options. Optional
|
|
683
|
-
* @returns The Safe transaction response
|
|
684
|
-
* @throws "Transaction hashes can only be approved by Safe owners"
|
|
685
|
-
* @throws "Cannot specify gas and gasLimit together in transaction options"
|
|
686
|
-
*/
|
|
687
|
-
async approveTransactionHash(hash, options) {
|
|
688
|
-
if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
|
|
689
|
-
throw new Error('Safe is not deployed');
|
|
690
|
-
}
|
|
691
|
-
const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
|
|
692
|
-
if (!signerAddress) {
|
|
693
|
-
throw new Error('The protocol-kit requires a signer to use this method');
|
|
694
|
-
}
|
|
695
|
-
const addressIsOwner = await this.isOwner(signerAddress);
|
|
696
|
-
if (!addressIsOwner) {
|
|
697
|
-
throw new Error('Transaction hashes can only be approved by Safe owners');
|
|
698
|
-
}
|
|
699
|
-
return __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.approveHash(hash, {
|
|
700
|
-
from: signerAddress,
|
|
701
|
-
...options
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
/**
|
|
705
|
-
* Returns a list of owners who have approved a specific Safe transaction.
|
|
706
|
-
*
|
|
707
|
-
* @param txHash - The Safe transaction hash
|
|
708
|
-
* @returns The list of owners
|
|
709
|
-
*/
|
|
710
|
-
async getOwnersWhoApprovedTx(txHash) {
|
|
711
|
-
if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
|
|
712
|
-
return [];
|
|
713
|
-
}
|
|
714
|
-
const owners = await this.getOwners();
|
|
715
|
-
const ownersWhoApproved = [];
|
|
716
|
-
for (const owner of owners) {
|
|
717
|
-
const [approved] = await __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.approvedHashes([
|
|
718
|
-
(0, types_3.asHex)(owner),
|
|
719
|
-
(0, types_3.asHash)(txHash)
|
|
720
|
-
]);
|
|
721
|
-
if (approved > 0) {
|
|
722
|
-
ownersWhoApproved.push(owner);
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
return ownersWhoApproved;
|
|
726
|
-
}
|
|
727
|
-
/**
|
|
728
|
-
* Returns the Safe transaction to enable the fallback handler.
|
|
729
|
-
*
|
|
730
|
-
* @param address - The new fallback handler address
|
|
731
|
-
* @param options - The transaction optional properties
|
|
732
|
-
* @returns The Safe transaction ready to be signed
|
|
733
|
-
* @throws "Invalid fallback handler address provided"
|
|
734
|
-
* @throws "Fallback handler provided is already enabled"
|
|
735
|
-
* @throws "Current version of the Safe does not support the fallback handler functionality"
|
|
736
|
-
*/
|
|
737
|
-
async createEnableFallbackHandlerTx(fallbackHandlerAddress, options) {
|
|
738
|
-
const safeVersion = await this.getContractVersion();
|
|
739
|
-
if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f") && !(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ACCOUNT_ABSTRACTION, safeVersion)) {
|
|
740
|
-
throw new Error('Account Abstraction functionality is not available for Safes with version lower than v1.3.0');
|
|
741
|
-
}
|
|
742
|
-
const safeTransactionData = {
|
|
743
|
-
to: await this.getAddress(),
|
|
744
|
-
value: '0',
|
|
745
|
-
data: await __classPrivateFieldGet(this, _Safe_fallbackHandlerManager, "f").encodeEnableFallbackHandlerData(fallbackHandlerAddress)
|
|
746
|
-
};
|
|
747
|
-
const safeTransaction = await this.createTransaction({
|
|
748
|
-
transactions: [safeTransactionData],
|
|
749
|
-
options
|
|
750
|
-
});
|
|
751
|
-
return safeTransaction;
|
|
752
|
-
}
|
|
753
|
-
/**
|
|
754
|
-
* Returns the Safe transaction to disable the fallback handler.
|
|
755
|
-
*
|
|
756
|
-
* @param options - The transaction optional properties
|
|
757
|
-
* @returns The Safe transaction ready to be signed
|
|
758
|
-
* @throws "There is no fallback handler enabled yet"
|
|
759
|
-
* @throws "Current version of the Safe does not support the fallback handler functionality"
|
|
760
|
-
*/
|
|
761
|
-
async createDisableFallbackHandlerTx(options) {
|
|
762
|
-
const safeVersion = await this.getContractVersion();
|
|
763
|
-
if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f") && !(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ACCOUNT_ABSTRACTION, safeVersion)) {
|
|
764
|
-
throw new Error('Account Abstraction functionality is not available for Safes with version lower than v1.3.0');
|
|
765
|
-
}
|
|
766
|
-
const safeTransactionData = {
|
|
767
|
-
to: await this.getAddress(),
|
|
768
|
-
value: '0',
|
|
769
|
-
data: await __classPrivateFieldGet(this, _Safe_fallbackHandlerManager, "f").encodeDisableFallbackHandlerData()
|
|
770
|
-
};
|
|
771
|
-
const safeTransaction = await this.createTransaction({
|
|
772
|
-
transactions: [safeTransactionData],
|
|
773
|
-
options
|
|
774
|
-
});
|
|
775
|
-
return safeTransaction;
|
|
776
|
-
}
|
|
777
|
-
/**
|
|
778
|
-
* Returns the Safe transaction to enable a Safe guard.
|
|
779
|
-
*
|
|
780
|
-
* @param guardAddress - The desired guard address
|
|
781
|
-
* @param options - The transaction optional properties
|
|
782
|
-
* @returns The Safe transaction ready to be signed
|
|
783
|
-
* @throws "Invalid guard address provided"
|
|
784
|
-
* @throws "Guard provided is already enabled"
|
|
785
|
-
* @throws "Current version of the Safe does not support Safe transaction guards functionality"
|
|
786
|
-
*/
|
|
787
|
-
async createEnableGuardTx(guardAddress, options) {
|
|
788
|
-
const safeTransactionData = {
|
|
789
|
-
to: await this.getAddress(),
|
|
790
|
-
value: '0',
|
|
791
|
-
data: await __classPrivateFieldGet(this, _Safe_guardManager, "f").encodeEnableGuardData(guardAddress)
|
|
792
|
-
};
|
|
793
|
-
const safeTransaction = await this.createTransaction({
|
|
794
|
-
transactions: [safeTransactionData],
|
|
795
|
-
options
|
|
796
|
-
});
|
|
797
|
-
return safeTransaction;
|
|
798
|
-
}
|
|
799
|
-
/**
|
|
800
|
-
* Returns the Safe transaction to disable a Safe guard.
|
|
801
|
-
*
|
|
802
|
-
* @param options - The transaction optional properties
|
|
803
|
-
* @returns The Safe transaction ready to be signed
|
|
804
|
-
* @throws "There is no guard enabled yet"
|
|
805
|
-
* @throws "Current version of the Safe does not support Safe transaction guards functionality"
|
|
806
|
-
*/
|
|
807
|
-
async createDisableGuardTx(options) {
|
|
808
|
-
const safeTransactionData = {
|
|
809
|
-
to: await this.getAddress(),
|
|
810
|
-
value: '0',
|
|
811
|
-
data: await __classPrivateFieldGet(this, _Safe_guardManager, "f").encodeDisableGuardData()
|
|
812
|
-
};
|
|
813
|
-
const safeTransaction = await this.createTransaction({
|
|
814
|
-
transactions: [safeTransactionData],
|
|
815
|
-
options
|
|
816
|
-
});
|
|
817
|
-
return safeTransaction;
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* Returns the Safe transaction to enable a Safe module.
|
|
821
|
-
*
|
|
822
|
-
* @param moduleAddress - The desired module address
|
|
823
|
-
* @param options - The transaction optional properties
|
|
824
|
-
* @returns The Safe transaction ready to be signed
|
|
825
|
-
* @throws "Invalid module address provided"
|
|
826
|
-
* @throws "Module provided is already enabled"
|
|
827
|
-
*/
|
|
828
|
-
async createEnableModuleTx(moduleAddress, options) {
|
|
829
|
-
const safeTransactionData = {
|
|
830
|
-
to: await this.getAddress(),
|
|
831
|
-
value: '0',
|
|
832
|
-
data: await __classPrivateFieldGet(this, _Safe_moduleManager, "f").encodeEnableModuleData(moduleAddress)
|
|
833
|
-
};
|
|
834
|
-
const safeTransaction = await this.createTransaction({
|
|
835
|
-
transactions: [safeTransactionData],
|
|
836
|
-
options
|
|
837
|
-
});
|
|
838
|
-
return safeTransaction;
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* Returns the Safe transaction to disable a Safe module.
|
|
842
|
-
*
|
|
843
|
-
* @param moduleAddress - The desired module address
|
|
844
|
-
* @param options - The transaction optional properties
|
|
845
|
-
* @returns The Safe transaction ready to be signed
|
|
846
|
-
* @throws "Invalid module address provided"
|
|
847
|
-
* @throws "Module provided is not enabled already"
|
|
848
|
-
*/
|
|
849
|
-
async createDisableModuleTx(moduleAddress, options) {
|
|
850
|
-
const safeTransactionData = {
|
|
851
|
-
to: await this.getAddress(),
|
|
852
|
-
value: '0',
|
|
853
|
-
data: await __classPrivateFieldGet(this, _Safe_moduleManager, "f").encodeDisableModuleData(moduleAddress)
|
|
854
|
-
};
|
|
855
|
-
const safeTransaction = await this.createTransaction({
|
|
856
|
-
transactions: [safeTransactionData],
|
|
857
|
-
options
|
|
858
|
-
});
|
|
859
|
-
return safeTransaction;
|
|
860
|
-
}
|
|
861
|
-
/**
|
|
862
|
-
* Returns the Safe transaction to add an owner and optionally change the threshold.
|
|
863
|
-
*
|
|
864
|
-
* @param params - The transaction params
|
|
865
|
-
* @param options - The transaction optional properties
|
|
866
|
-
* @returns The Safe transaction ready to be signed
|
|
867
|
-
* @throws "Invalid owner address provided"
|
|
868
|
-
* @throws "Address provided is already an owner"
|
|
869
|
-
* @throws "Threshold needs to be greater than 0"
|
|
870
|
-
* @throws "Threshold cannot exceed owner count"
|
|
871
|
-
*/
|
|
872
|
-
async createAddOwnerTx(params, options) {
|
|
873
|
-
const isPasskey = (0, utils_3.isPasskeyParam)(params);
|
|
874
|
-
const ownerAddress = isPasskey
|
|
875
|
-
? await (0, getPasskeyOwnerAddress_1.default)(this, params.passkey)
|
|
876
|
-
: params.ownerAddress;
|
|
877
|
-
const { threshold } = params;
|
|
878
|
-
const addOwnerTransaction = {
|
|
879
|
-
to: await this.getAddress(),
|
|
880
|
-
value: '0',
|
|
881
|
-
data: await __classPrivateFieldGet(this, _Safe_ownerManager, "f").encodeAddOwnerWithThresholdData(ownerAddress, threshold)
|
|
882
|
-
};
|
|
883
|
-
const transactions = [addOwnerTransaction];
|
|
884
|
-
// The passkey Signer is a contract compliant with EIP-1271 standards, we need to check if it has been deployed.
|
|
885
|
-
if (isPasskey && !(await __classPrivateFieldGet(this, _Safe_safeProvider, "f").isContractDeployed(ownerAddress))) {
|
|
886
|
-
// If it has not been deployed, we need to create a batch that includes both the Signer contract deployment and the addOwner transaction
|
|
887
|
-
const passkeyDeploymentTransaction = await (0, createPasskeyDeploymentTransaction_1.default)(this, params.passkey);
|
|
888
|
-
transactions.push(passkeyDeploymentTransaction);
|
|
889
|
-
}
|
|
890
|
-
const safeTransaction = await this.createTransaction({
|
|
891
|
-
transactions,
|
|
892
|
-
options
|
|
893
|
-
});
|
|
894
|
-
return safeTransaction;
|
|
895
|
-
}
|
|
896
|
-
/**
|
|
897
|
-
* Returns the Safe transaction to remove an owner and optionally change the threshold.
|
|
898
|
-
*
|
|
899
|
-
* @param params - The transaction params
|
|
900
|
-
* @param options - The transaction optional properties
|
|
901
|
-
* @returns The Safe transaction ready to be signed
|
|
902
|
-
* @throws "Invalid owner address provided"
|
|
903
|
-
* @throws "Address provided is not an owner"
|
|
904
|
-
* @throws "Threshold needs to be greater than 0"
|
|
905
|
-
* @throws "Threshold cannot exceed owner count"
|
|
906
|
-
*/
|
|
907
|
-
async createRemoveOwnerTx(params, options) {
|
|
908
|
-
const { threshold } = params;
|
|
909
|
-
const isPasskey = (0, utils_3.isPasskeyParam)(params);
|
|
910
|
-
const ownerAddress = isPasskey
|
|
911
|
-
? await (0, getPasskeyOwnerAddress_1.default)(this, params.passkey)
|
|
912
|
-
: params.ownerAddress;
|
|
913
|
-
const safeTransactionData = {
|
|
914
|
-
to: await this.getAddress(),
|
|
915
|
-
value: '0',
|
|
916
|
-
data: await __classPrivateFieldGet(this, _Safe_ownerManager, "f").encodeRemoveOwnerData(ownerAddress, threshold)
|
|
917
|
-
};
|
|
918
|
-
const safeTransaction = await this.createTransaction({
|
|
919
|
-
transactions: [safeTransactionData],
|
|
920
|
-
options
|
|
921
|
-
});
|
|
922
|
-
return safeTransaction;
|
|
923
|
-
}
|
|
924
|
-
/**
|
|
925
|
-
* Returns the Safe transaction to replace an owner of the Safe with a new one.
|
|
926
|
-
*
|
|
927
|
-
* @param params - The transaction params
|
|
928
|
-
* @param options - The transaction optional properties
|
|
929
|
-
* @returns The Safe transaction ready to be signed
|
|
930
|
-
* @throws "Invalid new owner address provided"
|
|
931
|
-
* @throws "Invalid old owner address provided"
|
|
932
|
-
* @throws "New address provided is already an owner"
|
|
933
|
-
* @throws "Old address provided is not an owner"
|
|
934
|
-
*/
|
|
935
|
-
async createSwapOwnerTx(params, options) {
|
|
936
|
-
const oldOwnerAddress = (0, utils_3.isOldOwnerPasskey)(params)
|
|
937
|
-
? await (0, getPasskeyOwnerAddress_1.default)(this, params.oldOwnerPasskey)
|
|
938
|
-
: params.oldOwnerAddress;
|
|
939
|
-
const newOwnerAddress = (0, utils_3.isNewOwnerPasskey)(params)
|
|
940
|
-
? await (0, getPasskeyOwnerAddress_1.default)(this, params.newOwnerPasskey)
|
|
941
|
-
: params.newOwnerAddress;
|
|
942
|
-
const swapOwnerTransaction = {
|
|
943
|
-
to: await this.getAddress(),
|
|
944
|
-
value: '0',
|
|
945
|
-
data: await __classPrivateFieldGet(this, _Safe_ownerManager, "f").encodeSwapOwnerData(oldOwnerAddress, newOwnerAddress)
|
|
946
|
-
};
|
|
947
|
-
const transactions = [swapOwnerTransaction];
|
|
948
|
-
// The passkey Signer is a contract compliant with EIP-1271 standards, we need to check if it has been deployed.
|
|
949
|
-
if ((0, utils_3.isNewOwnerPasskey)(params) &&
|
|
950
|
-
!(await __classPrivateFieldGet(this, _Safe_safeProvider, "f").isContractDeployed(newOwnerAddress))) {
|
|
951
|
-
// If it has not been deployed, we need to create a batch that includes both the Signer contract deployment and the addOwner transaction
|
|
952
|
-
const passkeyDeploymentTransaction = await (0, createPasskeyDeploymentTransaction_1.default)(this, params.newOwnerPasskey);
|
|
953
|
-
transactions.push(passkeyDeploymentTransaction);
|
|
954
|
-
}
|
|
955
|
-
const safeTransaction = await this.createTransaction({
|
|
956
|
-
transactions,
|
|
957
|
-
options
|
|
958
|
-
});
|
|
959
|
-
return safeTransaction;
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Returns the Safe transaction to change the threshold.
|
|
963
|
-
*
|
|
964
|
-
* @param threshold - The new threshold
|
|
965
|
-
* @param options - The transaction optional properties
|
|
966
|
-
* @returns The Safe transaction ready to be signed
|
|
967
|
-
* @throws "Threshold needs to be greater than 0"
|
|
968
|
-
* @throws "Threshold cannot exceed owner count"
|
|
969
|
-
*/
|
|
970
|
-
async createChangeThresholdTx(threshold, options) {
|
|
971
|
-
const safeTransactionData = {
|
|
972
|
-
to: await this.getAddress(),
|
|
973
|
-
value: '0',
|
|
974
|
-
data: await __classPrivateFieldGet(this, _Safe_ownerManager, "f").encodeChangeThresholdData(threshold)
|
|
975
|
-
};
|
|
976
|
-
const safeTransaction = await this.createTransaction({
|
|
977
|
-
transactions: [safeTransactionData],
|
|
978
|
-
options
|
|
979
|
-
});
|
|
980
|
-
return safeTransaction;
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
|
-
* Converts a transaction from type SafeMultisigTransactionResponse to type SafeTransaction
|
|
984
|
-
*
|
|
985
|
-
* @param serviceTransactionResponse - The transaction to convert
|
|
986
|
-
* @returns The converted transaction with type SafeTransaction
|
|
987
|
-
*/
|
|
988
|
-
async toSafeTransactionType(serviceTransactionResponse) {
|
|
989
|
-
const safeTransactionData = {
|
|
990
|
-
to: serviceTransactionResponse.to,
|
|
991
|
-
value: serviceTransactionResponse.value,
|
|
992
|
-
data: serviceTransactionResponse.data || '0x',
|
|
993
|
-
operation: serviceTransactionResponse.operation
|
|
994
|
-
};
|
|
995
|
-
const options = {
|
|
996
|
-
safeTxGas: serviceTransactionResponse.safeTxGas.toString(),
|
|
997
|
-
baseGas: serviceTransactionResponse.baseGas.toString(),
|
|
998
|
-
gasPrice: serviceTransactionResponse.gasPrice,
|
|
999
|
-
gasToken: serviceTransactionResponse.gasToken,
|
|
1000
|
-
refundReceiver: serviceTransactionResponse.refundReceiver,
|
|
1001
|
-
nonce: serviceTransactionResponse.nonce
|
|
1002
|
-
};
|
|
1003
|
-
const safeTransaction = await this.createTransaction({
|
|
1004
|
-
transactions: [safeTransactionData],
|
|
1005
|
-
options
|
|
1006
|
-
});
|
|
1007
|
-
serviceTransactionResponse.confirmations?.map((confirmation) => {
|
|
1008
|
-
const signature = new utils_2.EthSafeSignature(confirmation.owner, confirmation.signature);
|
|
1009
|
-
safeTransaction.addSignature(signature);
|
|
1010
|
-
});
|
|
1011
|
-
return safeTransaction;
|
|
1012
|
-
}
|
|
1013
|
-
/**
|
|
1014
|
-
* Checks if a Safe transaction can be executed successfully with no errors.
|
|
1015
|
-
*
|
|
1016
|
-
* @param safeTransaction - The Safe transaction to check
|
|
1017
|
-
* @param options - The Safe transaction execution options. Optional
|
|
1018
|
-
* @returns TRUE if the Safe transaction can be executed successfully with no errors
|
|
1019
|
-
*/
|
|
1020
|
-
async isValidTransaction(safeTransaction, options) {
|
|
1021
|
-
if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
|
|
1022
|
-
throw new Error('Safe is not deployed');
|
|
1023
|
-
}
|
|
1024
|
-
const transaction = (0, utils_2.isSafeMultisigTransactionResponse)(safeTransaction)
|
|
1025
|
-
? await this.toSafeTransactionType(safeTransaction)
|
|
1026
|
-
: safeTransaction;
|
|
1027
|
-
const signedSafeTransaction = await this.copyTransaction(transaction);
|
|
1028
|
-
const txHash = await this.getTransactionHash(signedSafeTransaction);
|
|
1029
|
-
const ownersWhoApprovedTx = await this.getOwnersWhoApprovedTx(txHash);
|
|
1030
|
-
for (const owner of ownersWhoApprovedTx) {
|
|
1031
|
-
signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(owner));
|
|
1032
|
-
}
|
|
1033
|
-
const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
|
|
1034
|
-
if (!signerAddress) {
|
|
1035
|
-
throw new Error('The protocol-kit requires a signer to use this method');
|
|
1036
|
-
}
|
|
1037
|
-
const addressIsOwner = await this.isOwner(signerAddress);
|
|
1038
|
-
if (addressIsOwner) {
|
|
1039
|
-
signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(signerAddress));
|
|
1040
|
-
}
|
|
1041
|
-
const isTxValid = await __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.isValidTransaction(signedSafeTransaction, {
|
|
1042
|
-
from: signerAddress,
|
|
1043
|
-
...options
|
|
1044
|
-
});
|
|
1045
|
-
return isTxValid;
|
|
1046
|
-
}
|
|
1047
|
-
/**
|
|
1048
|
-
* Executes a Safe transaction.
|
|
1049
|
-
*
|
|
1050
|
-
* @param safeTransaction - The Safe transaction to execute
|
|
1051
|
-
* @param options - The Safe transaction execution options. Optional
|
|
1052
|
-
* @returns The Safe transaction response
|
|
1053
|
-
* @throws "No signer provided"
|
|
1054
|
-
* @throws "There are X signatures missing"
|
|
1055
|
-
* @throws "Cannot specify gas and gasLimit together in transaction options"
|
|
1056
|
-
*/
|
|
1057
|
-
async executeTransaction(safeTransaction, options) {
|
|
1058
|
-
if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
|
|
1059
|
-
throw new Error('Safe is not deployed');
|
|
1060
|
-
}
|
|
1061
|
-
const transaction = (0, utils_2.isSafeMultisigTransactionResponse)(safeTransaction)
|
|
1062
|
-
? await this.toSafeTransactionType(safeTransaction)
|
|
1063
|
-
: safeTransaction;
|
|
1064
|
-
const signedSafeTransaction = await __classPrivateFieldGet(this, _Safe_instances, "m", _Safe_addPreValidatedSignature).call(this, transaction);
|
|
1065
|
-
await __classPrivateFieldGet(this, _Safe_instances, "m", _Safe_isReadyToExecute).call(this, signedSafeTransaction);
|
|
1066
|
-
const value = BigInt(signedSafeTransaction.data.value);
|
|
1067
|
-
if (value !== 0n) {
|
|
1068
|
-
const balance = await this.getBalance();
|
|
1069
|
-
if (value > balance) {
|
|
1070
|
-
throw new Error('Not enough Ether funds');
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
|
|
1074
|
-
if (__classPrivateFieldGet(this, _Safe_onchainIdentifier, "f")) {
|
|
1075
|
-
const encodedTransaction = await this.getEncodedTransaction(signedSafeTransaction);
|
|
1076
|
-
const transaction = {
|
|
1077
|
-
to: await this.getAddress(),
|
|
1078
|
-
value: 0n,
|
|
1079
|
-
data: encodedTransaction + __classPrivateFieldGet(this, _Safe_onchainIdentifier, "f")
|
|
1080
|
-
};
|
|
1081
|
-
const signer = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getExternalSigner();
|
|
1082
|
-
if (!signer) {
|
|
1083
|
-
throw new Error('A signer must be set');
|
|
1084
|
-
}
|
|
1085
|
-
const hash = await signer.sendTransaction({
|
|
1086
|
-
...transaction,
|
|
1087
|
-
account: signer.account,
|
|
1088
|
-
...options
|
|
1089
|
-
});
|
|
1090
|
-
const provider = __classPrivateFieldGet(this, _Safe_safeProvider, "f").getExternalProvider();
|
|
1091
|
-
return (0, utils_1.toTxResult)(provider, hash, options);
|
|
1092
|
-
}
|
|
1093
|
-
const txResponse = await __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.execTransaction(signedSafeTransaction, {
|
|
1094
|
-
from: signerAddress,
|
|
1095
|
-
...options
|
|
1096
|
-
});
|
|
1097
|
-
return txResponse;
|
|
1098
|
-
}
|
|
1099
|
-
/**
|
|
1100
|
-
* Returns the Safe Transaction encoded
|
|
1101
|
-
*
|
|
1102
|
-
* @async
|
|
1103
|
-
* @param {SafeTransaction} safeTransaction - The Safe transaction to be encoded.
|
|
1104
|
-
* @returns {Promise<string>} The encoded transaction
|
|
1105
|
-
*
|
|
1106
|
-
*/
|
|
1107
|
-
async getEncodedTransaction(safeTransaction) {
|
|
1108
|
-
const safeVersion = this.getContractVersion();
|
|
1109
|
-
const chainId = await this.getChainId();
|
|
1110
|
-
const customContracts = __classPrivateFieldGet(this, _Safe_contractManager, "f").contractNetworks?.[chainId.toString()];
|
|
1111
|
-
const isL1SafeSingleton = __classPrivateFieldGet(this, _Safe_contractManager, "f").isL1SafeSingleton;
|
|
1112
|
-
const safeSingletonContract = await (0, safeDeploymentContracts_1.getSafeContract)({
|
|
1113
|
-
safeProvider: __classPrivateFieldGet(this, _Safe_safeProvider, "f"),
|
|
1114
|
-
safeVersion,
|
|
1115
|
-
isL1SafeSingleton,
|
|
1116
|
-
customContracts
|
|
1117
|
-
});
|
|
1118
|
-
const encodedTransaction = safeSingletonContract.encode('execTransaction', [
|
|
1119
|
-
safeTransaction.data.to,
|
|
1120
|
-
safeTransaction.data.value,
|
|
1121
|
-
safeTransaction.data.data,
|
|
1122
|
-
safeTransaction.data.operation,
|
|
1123
|
-
safeTransaction.data.safeTxGas,
|
|
1124
|
-
safeTransaction.data.baseGas,
|
|
1125
|
-
safeTransaction.data.gasPrice,
|
|
1126
|
-
safeTransaction.data.gasToken,
|
|
1127
|
-
safeTransaction.data.refundReceiver,
|
|
1128
|
-
safeTransaction.encodedSignatures()
|
|
1129
|
-
]);
|
|
1130
|
-
return encodedTransaction;
|
|
1131
|
-
}
|
|
1132
|
-
/**
|
|
1133
|
-
* Wraps a Safe transaction into a Safe deployment batch.
|
|
1134
|
-
*
|
|
1135
|
-
* This function creates a transaction batch of 2 transactions, which includes the
|
|
1136
|
-
* deployment of the Safe and the provided Safe transaction.
|
|
1137
|
-
*
|
|
1138
|
-
* @async
|
|
1139
|
-
* @param {SafeTransaction} safeTransaction - The Safe transaction to be wrapped into the deployment batch.
|
|
1140
|
-
* @param {TransactionOptions} [transactionOptions] - Optional. Options for the transaction, such as from, gas price, gas limit, etc.
|
|
1141
|
-
* @returns {Promise<Transaction>} A promise that resolves to a Transaction object representing the prepared batch of transactions.
|
|
1142
|
-
* @throws Will throw an error if the safe is already deployed.
|
|
1143
|
-
*
|
|
1144
|
-
*/
|
|
1145
|
-
async wrapSafeTransactionIntoDeploymentBatch(safeTransaction, transactionOptions) {
|
|
1146
|
-
const isSafeDeployed = await this.isSafeDeployed();
|
|
1147
|
-
// if the safe is already deployed throws an error
|
|
1148
|
-
if (isSafeDeployed) {
|
|
1149
|
-
throw new Error('Safe already deployed');
|
|
1150
|
-
}
|
|
1151
|
-
// we create the deployment transaction
|
|
1152
|
-
const safeDeploymentTransaction = await this.createSafeDeploymentTransaction();
|
|
1153
|
-
// remove the onchain idendifier if it is included
|
|
1154
|
-
if (safeDeploymentTransaction.data.endsWith(__classPrivateFieldGet(this, _Safe_onchainIdentifier, "f"))) {
|
|
1155
|
-
safeDeploymentTransaction.data = safeDeploymentTransaction.data.replace(__classPrivateFieldGet(this, _Safe_onchainIdentifier, "f"), '');
|
|
1156
|
-
}
|
|
1157
|
-
// First transaction of the batch: The Safe deployment Transaction
|
|
1158
|
-
const safeDeploymentBatchTransaction = {
|
|
1159
|
-
to: safeDeploymentTransaction.to,
|
|
1160
|
-
value: safeDeploymentTransaction.value,
|
|
1161
|
-
data: safeDeploymentTransaction.data,
|
|
1162
|
-
operation: types_kit_1.OperationType.Call
|
|
1163
|
-
};
|
|
1164
|
-
// Second transaction of the batch: The Safe Transaction
|
|
1165
|
-
const safeBatchTransaction = {
|
|
1166
|
-
to: await this.getAddress(),
|
|
1167
|
-
value: '0',
|
|
1168
|
-
data: await this.getEncodedTransaction(safeTransaction),
|
|
1169
|
-
operation: types_kit_1.OperationType.Call
|
|
1170
|
-
};
|
|
1171
|
-
// transactions for the batch
|
|
1172
|
-
const transactions = [safeDeploymentBatchTransaction, safeBatchTransaction];
|
|
1173
|
-
// this is the transaction with the batch
|
|
1174
|
-
const safeDeploymentBatch = await this.createTransactionBatch(transactions, transactionOptions, !!__classPrivateFieldGet(this, _Safe_onchainIdentifier, "f") // include the on chain identifier
|
|
1175
|
-
);
|
|
1176
|
-
return safeDeploymentBatch;
|
|
1177
|
-
}
|
|
1178
|
-
/**
|
|
1179
|
-
* Creates a transaction to deploy a Safe Account.
|
|
1180
|
-
*
|
|
1181
|
-
* @returns {Promise<Transaction>} Returns a promise that resolves to an Ethereum transaction with the fields `to`, `value`, and `data`, which can be used to deploy the Safe Account.
|
|
1182
|
-
*/
|
|
1183
|
-
async createSafeDeploymentTransaction() {
|
|
1184
|
-
if (!__classPrivateFieldGet(this, _Safe_predictedSafe, "f")) {
|
|
1185
|
-
throw new Error('Predict Safe should be present to build the Safe deployement transaction');
|
|
1186
|
-
}
|
|
1187
|
-
const { safeAccountConfig, safeDeploymentConfig = {} } = __classPrivateFieldGet(this, _Safe_predictedSafe, "f");
|
|
1188
|
-
(0, utils_1.validateSafeAccountConfig)(safeAccountConfig);
|
|
1189
|
-
(0, utils_1.validateSafeDeploymentConfig)(safeDeploymentConfig);
|
|
1190
|
-
const safeProvider = __classPrivateFieldGet(this, _Safe_safeProvider, "f");
|
|
1191
|
-
const chainId = await safeProvider.getChainId();
|
|
1192
|
-
const safeVersion = safeDeploymentConfig?.safeVersion || config_1.DEFAULT_SAFE_VERSION;
|
|
1193
|
-
const saltNonce = safeDeploymentConfig?.saltNonce || (0, utils_1.getChainSpecificDefaultSaltNonce)(chainId);
|
|
1194
|
-
// we only check if the safe is deployed if safeVersion >= 1.3.0
|
|
1195
|
-
if ((0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ACCOUNT_ABSTRACTION, safeVersion)) {
|
|
1196
|
-
const isSafeDeployed = await this.isSafeDeployed();
|
|
1197
|
-
// if the safe is already deployed throws an error
|
|
1198
|
-
if (isSafeDeployed) {
|
|
1199
|
-
throw new Error('Safe already deployed');
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
const isL1SafeSingleton = __classPrivateFieldGet(this, _Safe_contractManager, "f").isL1SafeSingleton;
|
|
1203
|
-
const customContracts = __classPrivateFieldGet(this, _Safe_contractManager, "f").contractNetworks?.[chainId.toString()];
|
|
1204
|
-
const deploymentType = __classPrivateFieldGet(this, _Safe_predictedSafe, "f").safeDeploymentConfig?.deploymentType;
|
|
1205
|
-
const safeSingletonContract = await (0, safeDeploymentContracts_1.getSafeContract)({
|
|
1206
|
-
safeProvider,
|
|
1207
|
-
safeVersion,
|
|
1208
|
-
isL1SafeSingleton,
|
|
1209
|
-
customContracts,
|
|
1210
|
-
deploymentType
|
|
1211
|
-
});
|
|
1212
|
-
// we use the SafeProxyFactory.sol contract, see: https://github.com/safe-global/safe-contracts/blob/main/contracts/proxies/SafeProxyFactory.sol
|
|
1213
|
-
const safeProxyFactoryContract = await (0, safeDeploymentContracts_1.getSafeProxyFactoryContract)({
|
|
1214
|
-
safeProvider,
|
|
1215
|
-
safeVersion,
|
|
1216
|
-
customContracts,
|
|
1217
|
-
deploymentType
|
|
1218
|
-
});
|
|
1219
|
-
// this is the call to the setup method that sets the threshold & owners of the new Safe, see: https://github.com/safe-global/safe-contracts/blob/main/contracts/Safe.sol#L95
|
|
1220
|
-
const initializer = await (0, utils_1.encodeSetupCallData)({
|
|
1221
|
-
safeProvider,
|
|
1222
|
-
safeContract: safeSingletonContract,
|
|
1223
|
-
safeAccountConfig: safeAccountConfig,
|
|
1224
|
-
customContracts,
|
|
1225
|
-
deploymentType
|
|
1226
|
-
});
|
|
1227
|
-
const safeDeployTransactionData = {
|
|
1228
|
-
to: safeProxyFactoryContract.getAddress(),
|
|
1229
|
-
value: '0',
|
|
1230
|
-
// we use the createProxyWithNonce method to create the Safe in a deterministic address, see: https://github.com/safe-global/safe-contracts/blob/main/contracts/proxies/SafeProxyFactory.sol#L52
|
|
1231
|
-
data: safeProxyFactoryContract.encode('createProxyWithNonce', [
|
|
1232
|
-
(0, types_3.asHex)(safeSingletonContract.getAddress()),
|
|
1233
|
-
(0, types_3.asHex)(initializer), // call to the setup method to set the threshold & owners of the new Safe
|
|
1234
|
-
BigInt(saltNonce)
|
|
1235
|
-
])
|
|
1236
|
-
};
|
|
1237
|
-
if (__classPrivateFieldGet(this, _Safe_onchainIdentifier, "f")) {
|
|
1238
|
-
safeDeployTransactionData.data += __classPrivateFieldGet(this, _Safe_onchainIdentifier, "f");
|
|
1239
|
-
}
|
|
1240
|
-
return safeDeployTransactionData;
|
|
1241
|
-
}
|
|
1242
|
-
/**
|
|
1243
|
-
* This function creates a batch of the provided Safe transactions using the MultiSend contract.
|
|
1244
|
-
* It groups the transactions together into a single transaction which can then be executed atomically.
|
|
1245
|
-
*
|
|
1246
|
-
* @async
|
|
1247
|
-
* @function createTransactionBatch
|
|
1248
|
-
* @param {MetaTransactionData[]} transactions - An array of MetaTransactionData objects to be batched together.
|
|
1249
|
-
* @param {TransactionOption} [transactionOptions] - Optional TransactionOption object to specify additional options for the transaction batch.
|
|
1250
|
-
* @param {boolean} [includeOnchainIdentifier=false] - A flag indicating whether to append the onchain identifier to the data field of the resulting transaction.
|
|
1251
|
-
* @returns {Promise<Transaction>} A Promise that resolves with the created transaction batch.
|
|
1252
|
-
*
|
|
1253
|
-
*/
|
|
1254
|
-
async createTransactionBatch(transactions, transactionOptions, includeOnchainIdentifier = false) {
|
|
1255
|
-
// we use the MultiSend contract to create the batch, see: https://github.com/safe-global/safe-contracts/blob/main/contracts/libraries/MultiSendCallOnly.sol
|
|
1256
|
-
const multiSendCallOnlyContract = __classPrivateFieldGet(this, _Safe_contractManager, "f").multiSendCallOnlyContract;
|
|
1257
|
-
// multiSend method with the transactions encoded
|
|
1258
|
-
const batchData = multiSendCallOnlyContract.encode('multiSend', [
|
|
1259
|
-
(0, types_3.asHex)((0, utils_3.encodeMultiSendData)(transactions)) // encoded transactions
|
|
1260
|
-
]);
|
|
1261
|
-
const transactionBatch = {
|
|
1262
|
-
...transactionOptions, // optional transaction options like from, gasLimit, gasPrice...
|
|
1263
|
-
to: multiSendCallOnlyContract.getAddress(),
|
|
1264
|
-
value: '0',
|
|
1265
|
-
data: batchData
|
|
1266
|
-
};
|
|
1267
|
-
if (includeOnchainIdentifier) {
|
|
1268
|
-
transactionBatch.data += __classPrivateFieldGet(this, _Safe_onchainIdentifier, "f");
|
|
1269
|
-
}
|
|
1270
|
-
return transactionBatch;
|
|
1271
|
-
}
|
|
1272
|
-
getOnchainIdentifier() {
|
|
1273
|
-
return __classPrivateFieldGet(this, _Safe_onchainIdentifier, "f");
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
_a = Safe, _Safe_predictedSafe = new WeakMap(), _Safe_safeProvider = new WeakMap(), _Safe_contractManager = new WeakMap(), _Safe_ownerManager = new WeakMap(), _Safe_moduleManager = new WeakMap(), _Safe_guardManager = new WeakMap(), _Safe_fallbackHandlerManager = new WeakMap(), _Safe_MAGIC_VALUE = new WeakMap(), _Safe_MAGIC_VALUE_BYTES = new WeakMap(), _Safe_onchainIdentifier = new WeakMap(), _Safe_instances = new WeakSet(), _Safe_initializeProtocolKit =
|
|
1277
|
-
/**
|
|
1278
|
-
* Initializes the Safe Core SDK instance.
|
|
1279
|
-
* @param config - Safe configuration
|
|
1280
|
-
* @throws "Signer must be connected to a provider"
|
|
1281
|
-
* @throws "SafeProxy contract is not deployed on the current network"
|
|
1282
|
-
* @throws "MultiSend contract is not deployed on the current network"
|
|
1283
|
-
* @throws "MultiSendCallOnly contract is not deployed on the current network"
|
|
1284
|
-
*/
|
|
1285
|
-
async function _Safe_initializeProtocolKit(config) {
|
|
1286
|
-
const { provider, signer, isL1SafeSingleton, contractNetworks, onchainAnalytics } = config;
|
|
1287
|
-
if (onchainAnalytics?.project) {
|
|
1288
|
-
const { project, platform } = onchainAnalytics;
|
|
1289
|
-
__classPrivateFieldSet(this, _Safe_onchainIdentifier, (0, generateOnChainIdentifier_1.default)({
|
|
1290
|
-
project,
|
|
1291
|
-
platform,
|
|
1292
|
-
tool: 'protocol-kit',
|
|
1293
|
-
toolVersion: (0, getProtocolKitVersion_1.getProtocolKitVersion)()
|
|
1294
|
-
}), "f");
|
|
1295
|
-
}
|
|
1296
|
-
__classPrivateFieldSet(this, _Safe_safeProvider, await SafeProvider_1.default.init({
|
|
1297
|
-
provider,
|
|
1298
|
-
signer,
|
|
1299
|
-
safeVersion: config_1.DEFAULT_SAFE_VERSION,
|
|
1300
|
-
contractNetworks
|
|
1301
|
-
}), "f");
|
|
1302
|
-
if ((0, types_2.isSafeConfigWithPredictedSafe)(config)) {
|
|
1303
|
-
__classPrivateFieldSet(this, _Safe_predictedSafe, config.predictedSafe, "f");
|
|
1304
|
-
__classPrivateFieldSet(this, _Safe_contractManager, await contractManager_1.default.init({
|
|
1305
|
-
provider,
|
|
1306
|
-
predictedSafe: __classPrivateFieldGet(this, _Safe_predictedSafe, "f"),
|
|
1307
|
-
isL1SafeSingleton,
|
|
1308
|
-
contractNetworks
|
|
1309
|
-
}, __classPrivateFieldGet(this, _Safe_safeProvider, "f")), "f");
|
|
1310
|
-
}
|
|
1311
|
-
else {
|
|
1312
|
-
__classPrivateFieldSet(this, _Safe_contractManager, await contractManager_1.default.init({
|
|
1313
|
-
provider,
|
|
1314
|
-
safeAddress: config.safeAddress,
|
|
1315
|
-
isL1SafeSingleton,
|
|
1316
|
-
contractNetworks
|
|
1317
|
-
}, __classPrivateFieldGet(this, _Safe_safeProvider, "f")), "f");
|
|
1318
|
-
}
|
|
1319
|
-
const safeVersion = this.getContractVersion();
|
|
1320
|
-
__classPrivateFieldSet(this, _Safe_safeProvider, await SafeProvider_1.default.init({
|
|
1321
|
-
provider,
|
|
1322
|
-
signer,
|
|
1323
|
-
safeVersion,
|
|
1324
|
-
contractNetworks
|
|
1325
|
-
}), "f");
|
|
1326
|
-
__classPrivateFieldSet(this, _Safe_ownerManager, new ownerManager_1.default(__classPrivateFieldGet(this, _Safe_safeProvider, "f"), __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract), "f");
|
|
1327
|
-
__classPrivateFieldSet(this, _Safe_moduleManager, new moduleManager_1.default(__classPrivateFieldGet(this, _Safe_safeProvider, "f"), __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract), "f");
|
|
1328
|
-
__classPrivateFieldSet(this, _Safe_guardManager, new guardManager_1.default(__classPrivateFieldGet(this, _Safe_safeProvider, "f"), __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract), "f");
|
|
1329
|
-
__classPrivateFieldSet(this, _Safe_fallbackHandlerManager, new fallbackHandlerManager_1.default(__classPrivateFieldGet(this, _Safe_safeProvider, "f"), __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract), "f");
|
|
1330
|
-
const isPasskeySigner = signer && typeof signer !== 'string';
|
|
1331
|
-
if (isPasskeySigner) {
|
|
1332
|
-
const safeAddress = await this.getAddress();
|
|
1333
|
-
const owners = await this.getOwners();
|
|
1334
|
-
__classPrivateFieldSet(this, _Safe_safeProvider, await SafeProvider_1.default.init({
|
|
1335
|
-
provider,
|
|
1336
|
-
signer,
|
|
1337
|
-
safeVersion,
|
|
1338
|
-
contractNetworks,
|
|
1339
|
-
safeAddress,
|
|
1340
|
-
owners
|
|
1341
|
-
}), "f");
|
|
1342
|
-
}
|
|
1343
|
-
}, _Safe_addPreValidatedSignature =
|
|
1344
|
-
/**
|
|
1345
|
-
* Adds a PreValidatedSignature to the transaction if the threshold is not reached.
|
|
1346
|
-
*
|
|
1347
|
-
* @async
|
|
1348
|
-
* @param {SafeTransaction} transaction - The transaction to add a signature to.
|
|
1349
|
-
* @returns {Promise<SafeTransaction>} A promise that resolves to the signed transaction.
|
|
1350
|
-
*/
|
|
1351
|
-
async function _Safe_addPreValidatedSignature(transaction) {
|
|
1352
|
-
const signedSafeTransaction = await this.copyTransaction(transaction);
|
|
1353
|
-
const txHash = await this.getTransactionHash(signedSafeTransaction);
|
|
1354
|
-
const ownersWhoApprovedTx = await this.getOwnersWhoApprovedTx(txHash);
|
|
1355
|
-
for (const owner of ownersWhoApprovedTx) {
|
|
1356
|
-
signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(owner));
|
|
1357
|
-
}
|
|
1358
|
-
const owners = await this.getOwners();
|
|
1359
|
-
const threshold = await this.getThreshold();
|
|
1360
|
-
const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
|
|
1361
|
-
if (threshold > signedSafeTransaction.signatures.size &&
|
|
1362
|
-
signerAddress &&
|
|
1363
|
-
owners.includes(signerAddress)) {
|
|
1364
|
-
signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(signerAddress));
|
|
1365
|
-
}
|
|
1366
|
-
return signedSafeTransaction;
|
|
1367
|
-
}, _Safe_isReadyToExecute =
|
|
1368
|
-
/**
|
|
1369
|
-
* Checks if the transaction has enough signatures to be executed.
|
|
1370
|
-
*
|
|
1371
|
-
* @async
|
|
1372
|
-
* @param {SafeTransaction} transaction - The Safe transaction to check.
|
|
1373
|
-
* @throws Will throw an error if the required number of signatures is not met.
|
|
1374
|
-
*/
|
|
1375
|
-
async function _Safe_isReadyToExecute(transaction) {
|
|
1376
|
-
const threshold = await this.getThreshold();
|
|
1377
|
-
if (threshold > transaction.signatures.size) {
|
|
1378
|
-
const signaturesMissing = threshold - transaction.signatures.size;
|
|
1379
|
-
throw new Error(`There ${signaturesMissing > 1 ? 'are' : 'is'} ${signaturesMissing} signature${signaturesMissing > 1 ? 's' : ''} missing`);
|
|
1380
|
-
}
|
|
1381
|
-
}, _Safe_getFallbackHandlerContract =
|
|
1382
|
-
/**
|
|
1383
|
-
* Get the fallback handler contract
|
|
1384
|
-
*
|
|
1385
|
-
* @returns The fallback Handler contract
|
|
1386
|
-
*/
|
|
1387
|
-
async function _Safe_getFallbackHandlerContract() {
|
|
1388
|
-
if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
|
|
1389
|
-
throw new Error('Safe is not deployed');
|
|
1390
|
-
}
|
|
1391
|
-
const safeVersion = __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.safeVersion ?? config_1.DEFAULT_SAFE_VERSION;
|
|
1392
|
-
const chainId = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getChainId();
|
|
1393
|
-
const compatibilityFallbackHandlerContract = await (0, safeDeploymentContracts_1.getCompatibilityFallbackHandlerContract)({
|
|
1394
|
-
safeProvider: __classPrivateFieldGet(this, _Safe_safeProvider, "f"),
|
|
1395
|
-
safeVersion,
|
|
1396
|
-
customContracts: __classPrivateFieldGet(this, _Safe_contractManager, "f").contractNetworks?.[chainId.toString()]
|
|
1397
|
-
});
|
|
1398
|
-
return compatibilityFallbackHandlerContract;
|
|
1399
|
-
};
|
|
1400
|
-
/**
|
|
1401
|
-
* This method creates a signer to be used with the init method
|
|
1402
|
-
* @param {Credential} credential - The credential to be used to create the signer. Can be generated in the web with navigator.credentials.create
|
|
1403
|
-
* @returns {PasskeyArgType} - The signer to be used with the init method
|
|
1404
|
-
*/
|
|
1405
|
-
Safe.createPasskeySigner = async (credential) => {
|
|
1406
|
-
return (0, utils_2.extractPasskeyData)(credential);
|
|
1407
|
-
};
|
|
1408
|
-
exports.default = Safe;
|
|
1409
|
-
//# sourceMappingURL=Safe.js.map
|