@safe-global/protocol-kit 5.2.2 → 6.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
|
@@ -0,0 +1,4217 @@
|
|
|
1
|
+
// test-utils/webauthnShim.ts
|
|
2
|
+
import { p256 } from "@noble/curves/p256";
|
|
3
|
+
import { ethers } from "ethers";
|
|
4
|
+
import CBOR from "cbor";
|
|
5
|
+
function base64UrlEncode(data) {
|
|
6
|
+
const buffer = typeof data === "string" ? Buffer.from(data.replace(/^0x/, ""), "hex") : Buffer.from(data);
|
|
7
|
+
return buffer.toString("base64url");
|
|
8
|
+
}
|
|
9
|
+
function userVerificationFlag(userVerification = "preferred") {
|
|
10
|
+
switch (userVerification) {
|
|
11
|
+
case "preferred":
|
|
12
|
+
return 1;
|
|
13
|
+
case "required":
|
|
14
|
+
return 4;
|
|
15
|
+
default:
|
|
16
|
+
throw new Error(`user verification requirement ${userVerification} not supported`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function b2ab(buf) {
|
|
20
|
+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
21
|
+
}
|
|
22
|
+
function isEqualArray(a, b) {
|
|
23
|
+
if (a.length != b.length) return false;
|
|
24
|
+
for (let i = 0; i < a.length; i++) if (a[i] != b[i]) return false;
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
function encodeWebAuthnSigningMessage(clientData, authenticatorData) {
|
|
28
|
+
return ethers.getBytes(
|
|
29
|
+
ethers.concat([
|
|
30
|
+
authenticatorData,
|
|
31
|
+
ethers.sha256(ethers.toUtf8Bytes(JSON.stringify(clientData)))
|
|
32
|
+
])
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
var Credential = class {
|
|
36
|
+
constructor(rp, user, pk) {
|
|
37
|
+
this.rp = rp;
|
|
38
|
+
this.user = user;
|
|
39
|
+
this.pk = pk || p256.utils.normPrivateKeyToScalar(p256.utils.randomPrivateKey());
|
|
40
|
+
this.id = ethers.dataSlice(
|
|
41
|
+
ethers.keccak256(ethers.dataSlice(p256.getPublicKey(this.pk, false), 1)),
|
|
42
|
+
12
|
|
43
|
+
);
|
|
44
|
+
this.rawId = ethers.getBytes(this.id);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Computes the COSE encoded public key for this credential.
|
|
48
|
+
* See <https://datatracker.ietf.org/doc/html/rfc8152>.
|
|
49
|
+
*
|
|
50
|
+
* @returns Hex-encoded COSE-encoded public key
|
|
51
|
+
*/
|
|
52
|
+
cosePublicKey() {
|
|
53
|
+
const pubk = p256.getPublicKey(this.pk, false);
|
|
54
|
+
const x = pubk.subarray(1, 33);
|
|
55
|
+
const y = pubk.subarray(33, 65);
|
|
56
|
+
const key = /* @__PURE__ */ new Map();
|
|
57
|
+
key.set(-1, 1);
|
|
58
|
+
key.set(-2, b2ab(x));
|
|
59
|
+
key.set(-3, b2ab(y));
|
|
60
|
+
key.set(1, 2);
|
|
61
|
+
key.set(3, -7);
|
|
62
|
+
return ethers.hexlify(CBOR.encode(key));
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var WebAuthnCredentials = class {
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new instance of the WebAuthn credentials.
|
|
68
|
+
* @param privateKey The private key to use for the credentials. If not provided, a random key will be generated.
|
|
69
|
+
*/
|
|
70
|
+
constructor(privateKey) {
|
|
71
|
+
this.privateKey = privateKey;
|
|
72
|
+
this.credentials = [];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* This is a shim for `navigator.credentials.create` method.
|
|
76
|
+
* See <https://w3c.github.io/webappsec-credential-management/#dom-credentialscontainer-create>.
|
|
77
|
+
*
|
|
78
|
+
* @param options The public key credential creation options.
|
|
79
|
+
* @returns A public key credential with an attestation response.
|
|
80
|
+
*/
|
|
81
|
+
create({
|
|
82
|
+
publicKey
|
|
83
|
+
}) {
|
|
84
|
+
if (!publicKey.pubKeyCredParams.some(({ alg }) => alg === -7)) {
|
|
85
|
+
throw new Error("unsupported signature algorithm(s)");
|
|
86
|
+
}
|
|
87
|
+
const credential = new Credential(publicKey.rp.id, publicKey.user.id, this.privateKey);
|
|
88
|
+
this.credentials.push(credential);
|
|
89
|
+
const clientData = {
|
|
90
|
+
type: "webauthn.create",
|
|
91
|
+
challenge: base64UrlEncode(publicKey.challenge),
|
|
92
|
+
origin: `https://${publicKey.rp.id}`
|
|
93
|
+
};
|
|
94
|
+
const attestationObject = {
|
|
95
|
+
authData: b2ab(
|
|
96
|
+
ethers.getBytes(
|
|
97
|
+
ethers.solidityPacked(
|
|
98
|
+
["bytes32", "uint8", "uint32", "bytes16", "uint16", "bytes", "bytes"],
|
|
99
|
+
[
|
|
100
|
+
ethers.sha256(ethers.toUtf8Bytes(publicKey.rp.id)),
|
|
101
|
+
64 + userVerificationFlag(publicKey.userVerification),
|
|
102
|
+
// flags = attested_data + user_present
|
|
103
|
+
0,
|
|
104
|
+
// signCount
|
|
105
|
+
`0x${"42".repeat(16)}`,
|
|
106
|
+
// aaguid
|
|
107
|
+
ethers.dataLength(credential.id),
|
|
108
|
+
credential.id,
|
|
109
|
+
credential.cosePublicKey()
|
|
110
|
+
]
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
),
|
|
114
|
+
fmt: "none",
|
|
115
|
+
attStmt: {}
|
|
116
|
+
};
|
|
117
|
+
return {
|
|
118
|
+
id: base64UrlEncode(credential.rawId),
|
|
119
|
+
rawId: credential.rawId.slice(),
|
|
120
|
+
response: {
|
|
121
|
+
clientDataJSON: b2ab(ethers.toUtf8Bytes(JSON.stringify(clientData))),
|
|
122
|
+
attestationObject: b2ab(CBOR.encode(attestationObject)),
|
|
123
|
+
getPublicKey: () => b2ab(p256.getPublicKey(credential.pk, false))
|
|
124
|
+
},
|
|
125
|
+
type: "public-key"
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* This is a shim for `navigator.credentials.get` method.
|
|
130
|
+
* See <https://w3c.github.io/webappsec-credential-management/#dom-credentialscontainer-get>.
|
|
131
|
+
*
|
|
132
|
+
* @param options The public key credential request options.
|
|
133
|
+
* @returns A public key credential with an assertion response.
|
|
134
|
+
*/
|
|
135
|
+
get({
|
|
136
|
+
publicKey
|
|
137
|
+
}) {
|
|
138
|
+
const credential = publicKey.allowCredentials.flatMap(({ id }) => this.credentials.filter((c) => isEqualArray(c.rawId, id))).at(0);
|
|
139
|
+
if (credential === void 0) {
|
|
140
|
+
throw new Error("credential not found");
|
|
141
|
+
}
|
|
142
|
+
const clientData = {
|
|
143
|
+
type: "webauthn.get",
|
|
144
|
+
challenge: base64UrlEncode(publicKey.challenge),
|
|
145
|
+
origin: `https://${credential.rp}`
|
|
146
|
+
};
|
|
147
|
+
const authenticatorData = ethers.solidityPacked(
|
|
148
|
+
["bytes32", "uint8", "uint32"],
|
|
149
|
+
[
|
|
150
|
+
ethers.sha256(ethers.toUtf8Bytes(credential.rp)),
|
|
151
|
+
userVerificationFlag(publicKey.userVerification),
|
|
152
|
+
// flags = user_present
|
|
153
|
+
0
|
|
154
|
+
// signCount
|
|
155
|
+
]
|
|
156
|
+
);
|
|
157
|
+
const message = encodeWebAuthnSigningMessage(clientData, authenticatorData);
|
|
158
|
+
const signature = p256.sign(message, credential.pk, {
|
|
159
|
+
lowS: false,
|
|
160
|
+
prehash: true
|
|
161
|
+
});
|
|
162
|
+
return {
|
|
163
|
+
id: base64UrlEncode(credential.rawId),
|
|
164
|
+
rawId: credential.rawId.slice(),
|
|
165
|
+
response: {
|
|
166
|
+
clientDataJSON: b2ab(ethers.toUtf8Bytes(JSON.stringify(clientData))),
|
|
167
|
+
authenticatorData: b2ab(ethers.getBytes(authenticatorData)),
|
|
168
|
+
signature: b2ab(signature.toDERRawBytes(false)),
|
|
169
|
+
userHandle: credential.user
|
|
170
|
+
},
|
|
171
|
+
type: "public-key"
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// test-utils/passkeys.ts
|
|
177
|
+
import { keccak256 as keccak2563, toBytes as toBytes4 } from "viem";
|
|
178
|
+
|
|
179
|
+
// src/utils/types.ts
|
|
180
|
+
import { isHex, defineChain, etherUnits } from "viem";
|
|
181
|
+
import * as allChains from "viem/chains";
|
|
182
|
+
function asHash(hash) {
|
|
183
|
+
return hash;
|
|
184
|
+
}
|
|
185
|
+
function asHex(hex) {
|
|
186
|
+
return isHex(hex) ? hex : `0x${hex}`;
|
|
187
|
+
}
|
|
188
|
+
function getChainById(chainId) {
|
|
189
|
+
const chain = Object.values(allChains).find((chain2) => chain2.id === Number(chainId));
|
|
190
|
+
if (chain) {
|
|
191
|
+
return chain;
|
|
192
|
+
} else {
|
|
193
|
+
return defineChain({
|
|
194
|
+
id: Number(chainId),
|
|
195
|
+
name: "Custom",
|
|
196
|
+
nativeCurrency: {
|
|
197
|
+
decimals: etherUnits.wei,
|
|
198
|
+
name: "Ether",
|
|
199
|
+
symbol: "ETH"
|
|
200
|
+
},
|
|
201
|
+
rpcUrls: {
|
|
202
|
+
default: {
|
|
203
|
+
http: [],
|
|
204
|
+
webSocket: []
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// src/utils/constants.ts
|
|
212
|
+
import { zeroAddress } from "viem";
|
|
213
|
+
var SENTINEL_ADDRESS = "0x0000000000000000000000000000000000000001";
|
|
214
|
+
|
|
215
|
+
// src/utils/address.ts
|
|
216
|
+
function sameString(str1, str2) {
|
|
217
|
+
return !!str1 && !!str2 && str1.toLowerCase() === str2.toLowerCase();
|
|
218
|
+
}
|
|
219
|
+
function isSentinelAddress(address) {
|
|
220
|
+
return sameString(address, SENTINEL_ADDRESS);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/utils/eip-3770/index.ts
|
|
224
|
+
import { isAddress } from "viem";
|
|
225
|
+
|
|
226
|
+
// src/utils/eip-3770/config.ts
|
|
227
|
+
var networks = [
|
|
228
|
+
{ chainId: 1n, shortName: "eth" },
|
|
229
|
+
{ chainId: 3n, shortName: "rop" },
|
|
230
|
+
{ chainId: 4n, shortName: "rin" },
|
|
231
|
+
{ chainId: 5n, shortName: "gor" },
|
|
232
|
+
{ chainId: 10n, shortName: "oeth" },
|
|
233
|
+
{ chainId: 11n, shortName: "meta" },
|
|
234
|
+
{ chainId: 12n, shortName: "kal" },
|
|
235
|
+
{ chainId: 14n, shortName: "flr" },
|
|
236
|
+
{ chainId: 16n, shortName: "cflr" },
|
|
237
|
+
{ chainId: 18n, shortName: "tst" },
|
|
238
|
+
{ chainId: 19n, shortName: "sgb" },
|
|
239
|
+
{ chainId: 25n, shortName: "cro" },
|
|
240
|
+
{ chainId: 28n, shortName: "bobarinkeby" },
|
|
241
|
+
{ chainId: 30n, shortName: "rsk" },
|
|
242
|
+
{ chainId: 31n, shortName: "trsk" },
|
|
243
|
+
{ chainId: 39n, shortName: "u2u" },
|
|
244
|
+
{ chainId: 40n, shortName: "telosevm" },
|
|
245
|
+
{ chainId: 41n, shortName: "telosevmtestnet" },
|
|
246
|
+
{ chainId: 42n, shortName: "kov" },
|
|
247
|
+
{ chainId: 43n, shortName: "pangolin" },
|
|
248
|
+
{ chainId: 44n, shortName: "crab" },
|
|
249
|
+
{ chainId: 46n, shortName: "darwinia" },
|
|
250
|
+
{ chainId: 50n, shortName: "xdc" },
|
|
251
|
+
{ chainId: 51n, shortName: "txdc" },
|
|
252
|
+
{ chainId: 56n, shortName: "bnb" },
|
|
253
|
+
{ chainId: 57n, shortName: "sys" },
|
|
254
|
+
{ chainId: 61n, shortName: "etc" },
|
|
255
|
+
{ chainId: 63n, shortName: "metc" },
|
|
256
|
+
{ chainId: 69n, shortName: "okov" },
|
|
257
|
+
{ chainId: 71n, shortName: "cfxtest" },
|
|
258
|
+
{ chainId: 81n, shortName: "joc" },
|
|
259
|
+
{ chainId: 82n, shortName: "meter" },
|
|
260
|
+
{ chainId: 83n, shortName: "meter-test" },
|
|
261
|
+
{ chainId: 88n, shortName: "vic" },
|
|
262
|
+
{ chainId: 96n, shortName: "bkc" },
|
|
263
|
+
{ chainId: 97n, shortName: "bnbt" },
|
|
264
|
+
{ chainId: 100n, shortName: "gno" },
|
|
265
|
+
{ chainId: 106n, shortName: "vlx" },
|
|
266
|
+
{ chainId: 108n, shortName: "tt" },
|
|
267
|
+
{ chainId: 109n, shortName: "shibariumecosystem" },
|
|
268
|
+
{ chainId: 111n, shortName: "etl" },
|
|
269
|
+
{ chainId: 114n, shortName: "c2flr" },
|
|
270
|
+
{ chainId: 122n, shortName: "fuse" },
|
|
271
|
+
{ chainId: 123n, shortName: "spark" },
|
|
272
|
+
{ chainId: 130n, shortName: "unichain" },
|
|
273
|
+
{ chainId: 133n, shortName: "HSKT" },
|
|
274
|
+
{ chainId: 137n, shortName: "matic" },
|
|
275
|
+
{ chainId: 146n, shortName: "sonic" },
|
|
276
|
+
{ chainId: 148n, shortName: "shimmerevm" },
|
|
277
|
+
{ chainId: 155n, shortName: "tenet-testnet" },
|
|
278
|
+
{ chainId: 169n, shortName: "manta" },
|
|
279
|
+
{ chainId: 177n, shortName: "hsk" },
|
|
280
|
+
{ chainId: 179n, shortName: "abey" },
|
|
281
|
+
{ chainId: 181n, shortName: "water" },
|
|
282
|
+
{ chainId: 195n, shortName: "tokb" },
|
|
283
|
+
{ chainId: 196n, shortName: "okb" },
|
|
284
|
+
{ chainId: 204n, shortName: "opbnb" },
|
|
285
|
+
{ chainId: 240n, shortName: "zkTCRO" },
|
|
286
|
+
{ chainId: 246n, shortName: "ewt" },
|
|
287
|
+
{ chainId: 250n, shortName: "ftm" },
|
|
288
|
+
{ chainId: 252n, shortName: "fraxtal" },
|
|
289
|
+
{ chainId: 255n, shortName: "kroma" },
|
|
290
|
+
{ chainId: 274n, shortName: "lachain" },
|
|
291
|
+
{ chainId: 280n, shortName: "zksync-goerli" },
|
|
292
|
+
{ chainId: 282n, shortName: "zkTCRO" },
|
|
293
|
+
{ chainId: 288n, shortName: "boba" },
|
|
294
|
+
{ chainId: 291n, shortName: "orderly" },
|
|
295
|
+
{ chainId: 300n, shortName: "zksync-sepolia" },
|
|
296
|
+
{ chainId: 314n, shortName: "filecoin" },
|
|
297
|
+
{ chainId: 321n, shortName: "kcs" },
|
|
298
|
+
{ chainId: 322n, shortName: "kcst" },
|
|
299
|
+
{ chainId: 324n, shortName: "zksync" },
|
|
300
|
+
{ chainId: 336n, shortName: "sdn" },
|
|
301
|
+
{ chainId: 338n, shortName: "tcro" },
|
|
302
|
+
{ chainId: 360n, shortName: "shape" },
|
|
303
|
+
{ chainId: 369n, shortName: "pls" },
|
|
304
|
+
{ chainId: 388n, shortName: "zkCRO" },
|
|
305
|
+
{ chainId: 418n, shortName: "latestnet" },
|
|
306
|
+
{ chainId: 420n, shortName: "ogor" },
|
|
307
|
+
{ chainId: 424n, shortName: "PGN" },
|
|
308
|
+
{ chainId: 466n, shortName: "appchain" },
|
|
309
|
+
{ chainId: 478n, shortName: "formnetwork" },
|
|
310
|
+
{ chainId: 480n, shortName: "wc" },
|
|
311
|
+
{ chainId: 530n, shortName: "FxCore" },
|
|
312
|
+
{ chainId: 570n, shortName: "sys-rollux" },
|
|
313
|
+
{ chainId: 588n, shortName: "metis-stardust" },
|
|
314
|
+
{ chainId: 592n, shortName: "astr" },
|
|
315
|
+
{ chainId: 595n, shortName: "maca" },
|
|
316
|
+
{ chainId: 599n, shortName: "metis-goerli" },
|
|
317
|
+
{ chainId: 648n, shortName: "ace" },
|
|
318
|
+
{ chainId: 686n, shortName: "kar" },
|
|
319
|
+
{ chainId: 690n, shortName: "redstone" },
|
|
320
|
+
{ chainId: 787n, shortName: "aca" },
|
|
321
|
+
{ chainId: 919n, shortName: "modesep" },
|
|
322
|
+
{ chainId: 938n, shortName: "haust" },
|
|
323
|
+
{ chainId: 943n, shortName: "t4pls" },
|
|
324
|
+
{ chainId: 970n, shortName: "ccn" },
|
|
325
|
+
{ chainId: 995n, shortName: "5ire" },
|
|
326
|
+
{ chainId: 1001n, shortName: "baobab" },
|
|
327
|
+
{ chainId: 1008n, shortName: "eun" },
|
|
328
|
+
{ chainId: 1030n, shortName: "cfx" },
|
|
329
|
+
{ chainId: 1088n, shortName: "metis-andromeda" },
|
|
330
|
+
{ chainId: 1101n, shortName: "zkevm" },
|
|
331
|
+
{ chainId: 1111n, shortName: "wemix" },
|
|
332
|
+
{ chainId: 1112n, shortName: "twemix" },
|
|
333
|
+
{ chainId: 1114n, shortName: "tcore2" },
|
|
334
|
+
{ chainId: 1115n, shortName: "tcore" },
|
|
335
|
+
{ chainId: 1116n, shortName: "core" },
|
|
336
|
+
{ chainId: 1125n, shortName: "taker" },
|
|
337
|
+
{ chainId: 1135n, shortName: "lisk" },
|
|
338
|
+
{ chainId: 1230n, shortName: "UltronTestnet" },
|
|
339
|
+
{ chainId: 1231n, shortName: "UltronMainnet" },
|
|
340
|
+
{ chainId: 1284n, shortName: "mbeam" },
|
|
341
|
+
{ chainId: 1285n, shortName: "mriver" },
|
|
342
|
+
{ chainId: 1287n, shortName: "mbase" },
|
|
343
|
+
{ chainId: 1294n, shortName: "bobabeam" },
|
|
344
|
+
{ chainId: 1329n, shortName: "sei" },
|
|
345
|
+
{ chainId: 1337n, shortName: "geth" },
|
|
346
|
+
{ chainId: 1442n, shortName: "testnet-zkEVM-mango" },
|
|
347
|
+
{ chainId: 1513n, shortName: "Story" },
|
|
348
|
+
{ chainId: 1516n, shortName: "story-testnet" },
|
|
349
|
+
{ chainId: 1559n, shortName: "tenet" },
|
|
350
|
+
{ chainId: 1625n, shortName: "gravity" },
|
|
351
|
+
{ chainId: 1663n, shortName: "Gobi" },
|
|
352
|
+
{ chainId: 1729n, shortName: "reya" },
|
|
353
|
+
{ chainId: 1750n, shortName: "metall2" },
|
|
354
|
+
{ chainId: 1807n, shortName: "rana" },
|
|
355
|
+
{ chainId: 1811n, shortName: "lif3-testnet" },
|
|
356
|
+
{ chainId: 1890n, shortName: "lightlink_phoenix" },
|
|
357
|
+
{ chainId: 1891n, shortName: "lightlink_pegasus" },
|
|
358
|
+
{ chainId: 1923n, shortName: "swell-l2" },
|
|
359
|
+
{ chainId: 1924n, shortName: "swell-l2-testnet" },
|
|
360
|
+
{ chainId: 1984n, shortName: "euntest" },
|
|
361
|
+
{ chainId: 1998n, shortName: "kyoto-testnet" },
|
|
362
|
+
{ chainId: 2000n, shortName: "dc" },
|
|
363
|
+
{ chainId: 2001n, shortName: "milkada" },
|
|
364
|
+
{ chainId: 2002n, shortName: "milkalgo" },
|
|
365
|
+
{ chainId: 2008n, shortName: "cloudwalk_testnet" },
|
|
366
|
+
{ chainId: 2019n, shortName: "pmint_test" },
|
|
367
|
+
{ chainId: 2020n, shortName: "pmint" },
|
|
368
|
+
{ chainId: 2021n, shortName: "edg" },
|
|
369
|
+
{ chainId: 2039n, shortName: "aleph" },
|
|
370
|
+
{ chainId: 2187n, shortName: "g7" },
|
|
371
|
+
{ chainId: 2192n, shortName: "snax" },
|
|
372
|
+
{ chainId: 2221n, shortName: "tkava" },
|
|
373
|
+
{ chainId: 2222n, shortName: "kava" },
|
|
374
|
+
{ chainId: 2331n, shortName: "rss3-testnet" },
|
|
375
|
+
{ chainId: 2358n, shortName: "kroma-sepolia" },
|
|
376
|
+
{ chainId: 2442n, shortName: "zkevm-testnet-cardona" },
|
|
377
|
+
{ chainId: 2810n, shortName: "hmorph" },
|
|
378
|
+
{ chainId: 2818n, shortName: "morph" },
|
|
379
|
+
{ chainId: 3338n, shortName: "PEAQ" },
|
|
380
|
+
{ chainId: 3501n, shortName: "JFIN" },
|
|
381
|
+
{ chainId: 3636n, shortName: "BTNX" },
|
|
382
|
+
{ chainId: 3737n, shortName: "csb" },
|
|
383
|
+
{ chainId: 3776n, shortName: "astrzk" },
|
|
384
|
+
{ chainId: 4002n, shortName: "tftm" },
|
|
385
|
+
{ chainId: 4061n, shortName: "Nahmii3Mainnet" },
|
|
386
|
+
{ chainId: 4062n, shortName: "Nahmii3Testnet" },
|
|
387
|
+
{ chainId: 4078n, shortName: "muster" },
|
|
388
|
+
{ chainId: 4157n, shortName: "crossfi-testnet" },
|
|
389
|
+
{ chainId: 4162n, shortName: "SXR" },
|
|
390
|
+
{ chainId: 4202n, shortName: "lisksep" },
|
|
391
|
+
{ chainId: 4337n, shortName: "beam" },
|
|
392
|
+
{ chainId: 4460n, shortName: "orderlyl2" },
|
|
393
|
+
{ chainId: 4653n, shortName: "gold" },
|
|
394
|
+
{ chainId: 4661n, shortName: "appchaintestnet" },
|
|
395
|
+
{ chainId: 4689n, shortName: "iotex-mainnet" },
|
|
396
|
+
{ chainId: 4918n, shortName: "txvm" },
|
|
397
|
+
{ chainId: 4919n, shortName: "xvm" },
|
|
398
|
+
{ chainId: 5000n, shortName: "mantle" },
|
|
399
|
+
{ chainId: 5001n, shortName: "mantle-testnet" },
|
|
400
|
+
{ chainId: 5003n, shortName: "mnt-sep" },
|
|
401
|
+
{ chainId: 5115n, shortName: "citrea-testnet" },
|
|
402
|
+
{ chainId: 5165n, shortName: "ftn" },
|
|
403
|
+
{ chainId: 5611n, shortName: "obnbt" },
|
|
404
|
+
{ chainId: 5700n, shortName: "tsys" },
|
|
405
|
+
{ chainId: 6001n, shortName: "bouncebit-mainnet" },
|
|
406
|
+
{ chainId: 6102n, shortName: "cascadia" },
|
|
407
|
+
{ chainId: 6321n, shortName: "eaura" },
|
|
408
|
+
{ chainId: 6322n, shortName: "aura" },
|
|
409
|
+
{ chainId: 6398n, shortName: "connext-sepolia" },
|
|
410
|
+
{ chainId: 6688n, shortName: "iris" },
|
|
411
|
+
{ chainId: 7000n, shortName: "zetachain-mainnet" },
|
|
412
|
+
{ chainId: 7001n, shortName: "zetachain-testnet" },
|
|
413
|
+
{ chainId: 7171n, shortName: "bitrock" },
|
|
414
|
+
{ chainId: 7200n, shortName: "xsat" },
|
|
415
|
+
{ chainId: 7332n, shortName: "EON" },
|
|
416
|
+
{ chainId: 7341n, shortName: "shyft" },
|
|
417
|
+
{ chainId: 7560n, shortName: "cyeth" },
|
|
418
|
+
{ chainId: 7700n, shortName: "canto" },
|
|
419
|
+
{ chainId: 7771n, shortName: "tbitrock" },
|
|
420
|
+
{ chainId: 8192n, shortName: "tqf" },
|
|
421
|
+
{ chainId: 8194n, shortName: "ttqf" },
|
|
422
|
+
{ chainId: 8217n, shortName: "cypress" },
|
|
423
|
+
{ chainId: 8329n, shortName: "lrz" },
|
|
424
|
+
{ chainId: 8453n, shortName: "base" },
|
|
425
|
+
{ chainId: 8822n, shortName: "iotaevm" },
|
|
426
|
+
{ chainId: 9000n, shortName: "evmos-testnet" },
|
|
427
|
+
{ chainId: 9001n, shortName: "evmos" },
|
|
428
|
+
{ chainId: 9700n, shortName: "MainnetDev" },
|
|
429
|
+
{ chainId: 9728n, shortName: "boba-testnet" },
|
|
430
|
+
{ chainId: 10000n, shortName: "smartbch" },
|
|
431
|
+
{ chainId: 10001n, shortName: "smartbchtest" },
|
|
432
|
+
{ chainId: 10081n, shortName: "joct" },
|
|
433
|
+
{ chainId: 10200n, shortName: "chi" },
|
|
434
|
+
{ chainId: 10242n, shortName: "aa" },
|
|
435
|
+
{ chainId: 10243n, shortName: "aat" },
|
|
436
|
+
{ chainId: 10849n, shortName: "lamina1" },
|
|
437
|
+
{ chainId: 11011n, shortName: "shapesep" },
|
|
438
|
+
{ chainId: 11111n, shortName: "WAGMI" },
|
|
439
|
+
{ chainId: 11235n, shortName: "islm" },
|
|
440
|
+
{ chainId: 11437n, shortName: "shyftt" },
|
|
441
|
+
{ chainId: 11501n, shortName: "bevm" },
|
|
442
|
+
{ chainId: 11503n, shortName: "bevm-test" },
|
|
443
|
+
{ chainId: 11820n, shortName: "artela-mainnet" },
|
|
444
|
+
{ chainId: 11891n, shortName: "Arianee" },
|
|
445
|
+
{ chainId: 12324n, shortName: "l3x" },
|
|
446
|
+
{ chainId: 12325n, shortName: "l3x-testnet" },
|
|
447
|
+
{ chainId: 12357n, shortName: "rei-testnet" },
|
|
448
|
+
{ chainId: 12553n, shortName: "rss3" },
|
|
449
|
+
{ chainId: 13337n, shortName: "beam-testnet" },
|
|
450
|
+
{ chainId: 13371n, shortName: "imx" },
|
|
451
|
+
{ chainId: 13473n, shortName: "imx-testnet" },
|
|
452
|
+
{ chainId: 13746n, shortName: "g7t" },
|
|
453
|
+
{ chainId: 14800n, shortName: "vana-moksha" },
|
|
454
|
+
{ chainId: 17000n, shortName: "holesky" },
|
|
455
|
+
{ chainId: 17069n, shortName: "garnet" },
|
|
456
|
+
{ chainId: 17172n, shortName: "eclipse" },
|
|
457
|
+
{ chainId: 18231n, shortName: "unreal-old" },
|
|
458
|
+
{ chainId: 18233n, shortName: "unreal" },
|
|
459
|
+
{ chainId: 22776n, shortName: "mapo" },
|
|
460
|
+
{ chainId: 23294n, shortName: "sapphire" },
|
|
461
|
+
{ chainId: 23295n, shortName: "sapphire-testnet" },
|
|
462
|
+
{ chainId: 25327n, shortName: "Everclear" },
|
|
463
|
+
{ chainId: 28979n, shortName: "kimbonet-testnet" },
|
|
464
|
+
{ chainId: 31611n, shortName: "mezo" },
|
|
465
|
+
{ chainId: 32769n, shortName: "zil" },
|
|
466
|
+
{ chainId: 33101n, shortName: "zil-testnet" },
|
|
467
|
+
{ chainId: 33139n, shortName: "apechain" },
|
|
468
|
+
{ chainId: 33401n, shortName: "slingshot" },
|
|
469
|
+
{ chainId: 34443n, shortName: "mode" },
|
|
470
|
+
{ chainId: 35441n, shortName: "q" },
|
|
471
|
+
{ chainId: 35443n, shortName: "q-testnet" },
|
|
472
|
+
{ chainId: 37111n, shortName: "lens-sepolia" },
|
|
473
|
+
{ chainId: 41455n, shortName: "aleph-zero" },
|
|
474
|
+
{ chainId: 42161n, shortName: "arb1" },
|
|
475
|
+
{ chainId: 42170n, shortName: "arb-nova" },
|
|
476
|
+
{ chainId: 42220n, shortName: "celo" },
|
|
477
|
+
{ chainId: 42421n, shortName: "rwa" },
|
|
478
|
+
{ chainId: 42793n, shortName: "etlk" },
|
|
479
|
+
{ chainId: 43111n, shortName: "hemi" },
|
|
480
|
+
{ chainId: 43113n, shortName: "fuji" },
|
|
481
|
+
{ chainId: 43114n, shortName: "avax" },
|
|
482
|
+
{ chainId: 43288n, shortName: "boba-avax" },
|
|
483
|
+
{ chainId: 44787n, shortName: "alfa" },
|
|
484
|
+
{ chainId: 45000n, shortName: "autobahnnetwork" },
|
|
485
|
+
{ chainId: 47763n, shortName: "neox-mainnet" },
|
|
486
|
+
{ chainId: 47805n, shortName: "rei" },
|
|
487
|
+
{ chainId: 48899n, shortName: "zircuit-testnet" },
|
|
488
|
+
{ chainId: 48900n, shortName: "zircuit-mainnet" },
|
|
489
|
+
{ chainId: 53457n, shortName: "dodochain" },
|
|
490
|
+
{ chainId: 54211n, shortName: "islmt" },
|
|
491
|
+
{ chainId: 56288n, shortName: "boba-bnb" },
|
|
492
|
+
{ chainId: 57000n, shortName: "tsys-rollux" },
|
|
493
|
+
{ chainId: 57054n, shortName: "blaze" },
|
|
494
|
+
{ chainId: 57073n, shortName: "ink" },
|
|
495
|
+
{ chainId: 58008n, shortName: "sepPGN" },
|
|
496
|
+
{ chainId: 59140n, shortName: "linea-goerli" },
|
|
497
|
+
{ chainId: 59141n, shortName: "linea-sepolia" },
|
|
498
|
+
{ chainId: 59144n, shortName: "linea" },
|
|
499
|
+
{ chainId: 60808n, shortName: "bob" },
|
|
500
|
+
{ chainId: 61166n, shortName: "treasure" },
|
|
501
|
+
{ chainId: 71401n, shortName: "gw-testnet-v1" },
|
|
502
|
+
{ chainId: 71402n, shortName: "gw-mainnet-v1" },
|
|
503
|
+
{ chainId: 73799n, shortName: "vt" },
|
|
504
|
+
{ chainId: 80001n, shortName: "maticmum" },
|
|
505
|
+
{ chainId: 80002n, shortName: "polygonamoy" },
|
|
506
|
+
{ chainId: 80084n, shortName: "berachainbArtio" },
|
|
507
|
+
{ chainId: 80085n, shortName: "berachainArtio" },
|
|
508
|
+
{ chainId: 80094n, shortName: "berachain" },
|
|
509
|
+
{ chainId: 81457n, shortName: "blastmainnet" },
|
|
510
|
+
{ chainId: 83291n, shortName: "lrz-testnet" },
|
|
511
|
+
{ chainId: 84531n, shortName: "basegor" },
|
|
512
|
+
{ chainId: 84532n, shortName: "basesep" },
|
|
513
|
+
{ chainId: 90001n, shortName: "dhobyghaut" },
|
|
514
|
+
{ chainId: 97435n, shortName: "sling" },
|
|
515
|
+
{ chainId: 98864n, shortName: "plume-devnet" },
|
|
516
|
+
{ chainId: 98865n, shortName: "plume" },
|
|
517
|
+
{ chainId: 103454n, shortName: "masatest" },
|
|
518
|
+
{ chainId: 105105n, shortName: "stratis" },
|
|
519
|
+
{ chainId: 111188n, shortName: "re-al" },
|
|
520
|
+
{ chainId: 128123n, shortName: "etlt" },
|
|
521
|
+
{ chainId: 167000n, shortName: "tko-mainnet" },
|
|
522
|
+
{ chainId: 167008n, shortName: "tko-katla" },
|
|
523
|
+
{ chainId: 167009n, shortName: "tko-hekla" },
|
|
524
|
+
{ chainId: 175188n, shortName: "lpy" },
|
|
525
|
+
{ chainId: 200101n, shortName: "milktada" },
|
|
526
|
+
{ chainId: 200202n, shortName: "milktalgo" },
|
|
527
|
+
{ chainId: 200810n, shortName: "btrt" },
|
|
528
|
+
{ chainId: 205205n, shortName: "auroria" },
|
|
529
|
+
{ chainId: 314159n, shortName: "filecoin-calibration" },
|
|
530
|
+
{ chainId: 328527n, shortName: "nal" },
|
|
531
|
+
{ chainId: 333999n, shortName: "olympus" },
|
|
532
|
+
{ chainId: 381931n, shortName: "metal" },
|
|
533
|
+
{ chainId: 421611n, shortName: "arb-rinkeby" },
|
|
534
|
+
{ chainId: 421613n, shortName: "arb-goerli" },
|
|
535
|
+
{ chainId: 421614n, shortName: "arb-sep" },
|
|
536
|
+
{ chainId: 444444n, shortName: "syndr" },
|
|
537
|
+
{ chainId: 490000n, shortName: "ATN" },
|
|
538
|
+
{ chainId: 534351n, shortName: "scr-sepolia" },
|
|
539
|
+
{ chainId: 534352n, shortName: "scr" },
|
|
540
|
+
{ chainId: 534353n, shortName: "scr-alpha" },
|
|
541
|
+
{ chainId: 543210n, shortName: "zero-network" },
|
|
542
|
+
{ chainId: 555666n, shortName: "eclipset" },
|
|
543
|
+
{ chainId: 622277n, shortName: "rth" },
|
|
544
|
+
{ chainId: 656476n, shortName: "open-campus-codex" },
|
|
545
|
+
{ chainId: 660279n, shortName: "xai" },
|
|
546
|
+
{ chainId: 668668n, shortName: "cnw" },
|
|
547
|
+
{ chainId: 713715n, shortName: "sei-devnet" },
|
|
548
|
+
{ chainId: 743111n, shortName: "hemi-sep" },
|
|
549
|
+
{ chainId: 763373n, shortName: "inksepolia" },
|
|
550
|
+
{ chainId: 764984n, shortName: "lamina1test" },
|
|
551
|
+
{ chainId: 808813n, shortName: "bob-sepolia" },
|
|
552
|
+
{ chainId: 810180n, shortName: "zklink-nova" },
|
|
553
|
+
{ chainId: 839999n, shortName: "txsat" },
|
|
554
|
+
{ chainId: 978657n, shortName: "treasure-ruby" },
|
|
555
|
+
{ chainId: 984122n, shortName: "forma" },
|
|
556
|
+
{ chainId: 1501869n, shortName: "water9" },
|
|
557
|
+
{ chainId: 3441006n, shortName: "mantaSepoliaTestnet" },
|
|
558
|
+
{ chainId: 4457845n, shortName: "zero-sepolia" },
|
|
559
|
+
{ chainId: 6038361n, shortName: "azkyt" },
|
|
560
|
+
{ chainId: 7225878n, shortName: "saakuru" },
|
|
561
|
+
{ chainId: 7777777n, shortName: "zora" },
|
|
562
|
+
{ chainId: 9999999n, shortName: "fluence" },
|
|
563
|
+
{ chainId: 11155111n, shortName: "sep" },
|
|
564
|
+
{ chainId: 11155420n, shortName: "opsep" },
|
|
565
|
+
{ chainId: 12227332n, shortName: "neox-t4" },
|
|
566
|
+
{ chainId: 52164803n, shortName: "fluence-testnet" },
|
|
567
|
+
{ chainId: 94204209n, shortName: "polygon-blackberry" },
|
|
568
|
+
{ chainId: 111557560n, shortName: "cysep" },
|
|
569
|
+
{ chainId: 123420111n, shortName: "opcelestia-raspberry" },
|
|
570
|
+
{ chainId: 161221135n, shortName: "plume-testnet" },
|
|
571
|
+
{ chainId: 168587773n, shortName: "blastsepolia" },
|
|
572
|
+
{ chainId: 222000222n, shortName: "kanazawa" },
|
|
573
|
+
{ chainId: 245022926n, shortName: "neonevm-devnet" },
|
|
574
|
+
{ chainId: 245022934n, shortName: "neonevm-mainnet" },
|
|
575
|
+
{ chainId: 253368190n, shortName: "flame" },
|
|
576
|
+
{ chainId: 328527624n, shortName: "nalsep" },
|
|
577
|
+
{ chainId: 333000333n, shortName: "meld" },
|
|
578
|
+
{ chainId: 476462898n, shortName: "Skopje" },
|
|
579
|
+
{ chainId: 666666666n, shortName: "degen-chain" },
|
|
580
|
+
{ chainId: 888888888n, shortName: "ancient8" },
|
|
581
|
+
{ chainId: 999999999n, shortName: "zsep" },
|
|
582
|
+
{ chainId: 1313161554n, shortName: "aurora" },
|
|
583
|
+
{ chainId: 1313161555n, shortName: "aurora-testnet" },
|
|
584
|
+
{ chainId: 1511670449n, shortName: "GPT" },
|
|
585
|
+
{ chainId: 1570754601n, shortName: "hst-test" },
|
|
586
|
+
{ chainId: 1666600000n, shortName: "hmy-s0" },
|
|
587
|
+
{ chainId: 1666700000n, shortName: "hmy-b-s0" },
|
|
588
|
+
{ chainId: 11297108099n, shortName: "tpalm" },
|
|
589
|
+
{ chainId: 11297108109n, shortName: "palm" },
|
|
590
|
+
{ chainId: 37714555429n, shortName: "xaitestnet" },
|
|
591
|
+
{ chainId: 88153591557n, shortName: "arb-blueberry" },
|
|
592
|
+
{ chainId: 123420000220n, shortName: "fluence-stage" },
|
|
593
|
+
{ chainId: 920637907288165n, shortName: "kkrt-starknet-sepolia" }
|
|
594
|
+
];
|
|
595
|
+
if (process.env.TEST_NETWORK === "hardhat") {
|
|
596
|
+
networks.push({ shortName: "local", chainId: 31337n });
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// src/utils/eip-3770/index.ts
|
|
600
|
+
function parseEip3770Address(fullAddress) {
|
|
601
|
+
const parts = fullAddress.split(":");
|
|
602
|
+
const address = parts.length > 1 ? parts[1] : parts[0];
|
|
603
|
+
const prefix = parts.length > 1 ? parts[0] : "";
|
|
604
|
+
return { prefix, address };
|
|
605
|
+
}
|
|
606
|
+
function getEip3770NetworkPrefixFromChainId(chainId) {
|
|
607
|
+
const network = networks.find((network2) => chainId === network2.chainId);
|
|
608
|
+
if (!network) {
|
|
609
|
+
throw new Error("No network prefix supported for the current chainId");
|
|
610
|
+
}
|
|
611
|
+
return network.shortName;
|
|
612
|
+
}
|
|
613
|
+
function isValidEip3770NetworkPrefix(prefix) {
|
|
614
|
+
return networks.some(({ shortName }) => shortName === prefix);
|
|
615
|
+
}
|
|
616
|
+
function validateEip3770NetworkPrefix(prefix, currentChainId) {
|
|
617
|
+
const isCurrentNetworkPrefix = prefix === getEip3770NetworkPrefixFromChainId(currentChainId);
|
|
618
|
+
if (!isValidEip3770NetworkPrefix(prefix) || !isCurrentNetworkPrefix) {
|
|
619
|
+
throw new Error("The network prefix must match the current network");
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
function validateEthereumAddress(address) {
|
|
623
|
+
if (!isAddress(address)) {
|
|
624
|
+
throw new Error(`Invalid Ethereum address ${address}`);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
function validateEip3770Address(fullAddress, currentChainId) {
|
|
628
|
+
const { address, prefix } = parseEip3770Address(fullAddress);
|
|
629
|
+
validateEthereumAddress(address);
|
|
630
|
+
if (prefix) {
|
|
631
|
+
validateEip3770NetworkPrefix(prefix, currentChainId);
|
|
632
|
+
}
|
|
633
|
+
return { address, prefix };
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// src/utils/eip-712/index.ts
|
|
637
|
+
import { hashMessage as performMessageHash } from "viem";
|
|
638
|
+
import semverSatisfies from "semver/functions/satisfies.js";
|
|
639
|
+
|
|
640
|
+
// src/utils/eip-712/encode.ts
|
|
641
|
+
import {
|
|
642
|
+
keccak256,
|
|
643
|
+
concat,
|
|
644
|
+
encodeAbiParameters,
|
|
645
|
+
getTypesForEIP712Domain,
|
|
646
|
+
validateTypedData,
|
|
647
|
+
hashDomain,
|
|
648
|
+
toHex
|
|
649
|
+
} from "viem";
|
|
650
|
+
function encodeField({
|
|
651
|
+
types,
|
|
652
|
+
name,
|
|
653
|
+
type,
|
|
654
|
+
value
|
|
655
|
+
}) {
|
|
656
|
+
if (types[type] !== void 0) {
|
|
657
|
+
return [{ type: "bytes32" }, keccak256(encodeData({ data: value, primaryType: type, types }))];
|
|
658
|
+
}
|
|
659
|
+
if (type === "bytes") {
|
|
660
|
+
const prepend = value.length % 2 ? "0" : "";
|
|
661
|
+
value = `0x${prepend + value.slice(2)}`;
|
|
662
|
+
return [{ type: "bytes32" }, keccak256(value)];
|
|
663
|
+
}
|
|
664
|
+
if (type === "string") return [{ type: "bytes32" }, keccak256(toHex(value))];
|
|
665
|
+
if (type.lastIndexOf("]") === type.length - 1) {
|
|
666
|
+
const parsedType = type.slice(0, type.lastIndexOf("["));
|
|
667
|
+
const typeValuePairs = value.map(
|
|
668
|
+
(item) => encodeField({
|
|
669
|
+
name,
|
|
670
|
+
type: parsedType,
|
|
671
|
+
types,
|
|
672
|
+
value: item
|
|
673
|
+
})
|
|
674
|
+
);
|
|
675
|
+
return [
|
|
676
|
+
{ type: "bytes32" },
|
|
677
|
+
keccak256(
|
|
678
|
+
encodeAbiParameters(
|
|
679
|
+
typeValuePairs.map(([t]) => t),
|
|
680
|
+
typeValuePairs.map(([, v]) => v)
|
|
681
|
+
)
|
|
682
|
+
)
|
|
683
|
+
];
|
|
684
|
+
}
|
|
685
|
+
return [{ type }, value];
|
|
686
|
+
}
|
|
687
|
+
function findTypeDependencies({
|
|
688
|
+
primaryType: primaryType_,
|
|
689
|
+
types
|
|
690
|
+
}, results = /* @__PURE__ */ new Set()) {
|
|
691
|
+
const match = primaryType_.match(/^\w*/u);
|
|
692
|
+
const primaryType = match?.[0] || "";
|
|
693
|
+
if (results.has(primaryType) || types[primaryType] === void 0) {
|
|
694
|
+
return results;
|
|
695
|
+
}
|
|
696
|
+
results.add(primaryType);
|
|
697
|
+
for (const field of types[primaryType]) {
|
|
698
|
+
findTypeDependencies({ primaryType: field.type, types }, results);
|
|
699
|
+
}
|
|
700
|
+
return results;
|
|
701
|
+
}
|
|
702
|
+
function encodeType({
|
|
703
|
+
primaryType,
|
|
704
|
+
types
|
|
705
|
+
}) {
|
|
706
|
+
let result = "";
|
|
707
|
+
const unsortedDeps = findTypeDependencies({ primaryType, types });
|
|
708
|
+
unsortedDeps.delete(primaryType);
|
|
709
|
+
const deps = [primaryType, ...Array.from(unsortedDeps).sort()];
|
|
710
|
+
for (const type of deps) {
|
|
711
|
+
result += `${type}(${types[type].map(({ name, type: t }) => `${t} ${name}`).join(",")})`;
|
|
712
|
+
}
|
|
713
|
+
return result;
|
|
714
|
+
}
|
|
715
|
+
function hashType({
|
|
716
|
+
primaryType,
|
|
717
|
+
types
|
|
718
|
+
}) {
|
|
719
|
+
const encodedHashType = toHex(encodeType({ primaryType, types }));
|
|
720
|
+
return keccak256(encodedHashType);
|
|
721
|
+
}
|
|
722
|
+
function encodeData({
|
|
723
|
+
data,
|
|
724
|
+
primaryType,
|
|
725
|
+
types
|
|
726
|
+
}) {
|
|
727
|
+
const encodedTypes = [{ type: "bytes32" }];
|
|
728
|
+
const encodedValues = [hashType({ primaryType, types })];
|
|
729
|
+
for (const field of types[primaryType]) {
|
|
730
|
+
const [type, value] = encodeField({
|
|
731
|
+
types,
|
|
732
|
+
name: field.name,
|
|
733
|
+
type: field.type,
|
|
734
|
+
value: data[field.name]
|
|
735
|
+
});
|
|
736
|
+
encodedTypes.push(type);
|
|
737
|
+
encodedValues.push(value);
|
|
738
|
+
}
|
|
739
|
+
return encodeAbiParameters(encodedTypes, encodedValues);
|
|
740
|
+
}
|
|
741
|
+
function hashStruct({
|
|
742
|
+
data,
|
|
743
|
+
primaryType,
|
|
744
|
+
types
|
|
745
|
+
}) {
|
|
746
|
+
const encoded = encodeData({
|
|
747
|
+
data,
|
|
748
|
+
primaryType,
|
|
749
|
+
types
|
|
750
|
+
});
|
|
751
|
+
return keccak256(encoded);
|
|
752
|
+
}
|
|
753
|
+
function deducePrimaryType(types) {
|
|
754
|
+
return Object.keys(types)[0];
|
|
755
|
+
}
|
|
756
|
+
function hashTypedData(typedData) {
|
|
757
|
+
const data = encodeTypedData(typedData);
|
|
758
|
+
return keccak256(asHex(data));
|
|
759
|
+
}
|
|
760
|
+
function encodeTypedData(typedData) {
|
|
761
|
+
typedData.primaryType = !typedData?.primaryType ? deducePrimaryType(typedData.types) : typedData?.primaryType;
|
|
762
|
+
const { domain = {}, message, primaryType } = typedData;
|
|
763
|
+
const types = {
|
|
764
|
+
EIP712Domain: getTypesForEIP712Domain({ domain }),
|
|
765
|
+
...typedData.types
|
|
766
|
+
};
|
|
767
|
+
validateTypedData({
|
|
768
|
+
domain,
|
|
769
|
+
message,
|
|
770
|
+
primaryType,
|
|
771
|
+
types
|
|
772
|
+
});
|
|
773
|
+
const parts = ["0x1901"];
|
|
774
|
+
if (domain)
|
|
775
|
+
parts.push(
|
|
776
|
+
hashDomain({
|
|
777
|
+
domain,
|
|
778
|
+
types
|
|
779
|
+
})
|
|
780
|
+
);
|
|
781
|
+
if (primaryType !== "EIP712Domain")
|
|
782
|
+
parts.push(
|
|
783
|
+
hashStruct({
|
|
784
|
+
data: message,
|
|
785
|
+
primaryType,
|
|
786
|
+
types
|
|
787
|
+
})
|
|
788
|
+
);
|
|
789
|
+
return concat(parts);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// src/utils/eip-712/index.ts
|
|
793
|
+
var EQ_OR_GT_1_3_0 = ">=1.3.0";
|
|
794
|
+
var EIP712_DOMAIN_BEFORE_V130 = [
|
|
795
|
+
{
|
|
796
|
+
type: "address",
|
|
797
|
+
name: "verifyingContract"
|
|
798
|
+
}
|
|
799
|
+
];
|
|
800
|
+
var EIP712_DOMAIN = [
|
|
801
|
+
{
|
|
802
|
+
type: "uint256",
|
|
803
|
+
name: "chainId"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
type: "address",
|
|
807
|
+
name: "verifyingContract"
|
|
808
|
+
}
|
|
809
|
+
];
|
|
810
|
+
function getEip712TxTypes(safeVersion) {
|
|
811
|
+
const eip712WithChainId = semverSatisfies(safeVersion, EQ_OR_GT_1_3_0);
|
|
812
|
+
return {
|
|
813
|
+
EIP712Domain: eip712WithChainId ? EIP712_DOMAIN : EIP712_DOMAIN_BEFORE_V130,
|
|
814
|
+
SafeTx: [
|
|
815
|
+
{ type: "address", name: "to" },
|
|
816
|
+
{ type: "uint256", name: "value" },
|
|
817
|
+
{ type: "bytes", name: "data" },
|
|
818
|
+
{ type: "uint8", name: "operation" },
|
|
819
|
+
{ type: "uint256", name: "safeTxGas" },
|
|
820
|
+
{ type: "uint256", name: "baseGas" },
|
|
821
|
+
{ type: "uint256", name: "gasPrice" },
|
|
822
|
+
{ type: "address", name: "gasToken" },
|
|
823
|
+
{ type: "address", name: "refundReceiver" },
|
|
824
|
+
{ type: "uint256", name: "nonce" }
|
|
825
|
+
]
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function getEip712MessageTypes(safeVersion) {
|
|
829
|
+
const eip712WithChainId = semverSatisfies(safeVersion, EQ_OR_GT_1_3_0);
|
|
830
|
+
return {
|
|
831
|
+
EIP712Domain: eip712WithChainId ? EIP712_DOMAIN : EIP712_DOMAIN_BEFORE_V130,
|
|
832
|
+
SafeMessage: [{ type: "bytes", name: "message" }]
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
var hashTypedData2 = (typedData) => {
|
|
836
|
+
return hashTypedData(typedData);
|
|
837
|
+
};
|
|
838
|
+
var hashMessage = (message) => {
|
|
839
|
+
return performMessageHash(message);
|
|
840
|
+
};
|
|
841
|
+
var hashSafeMessage = (message) => {
|
|
842
|
+
return typeof message === "string" ? hashMessage(message) : hashTypedData2(message);
|
|
843
|
+
};
|
|
844
|
+
function generateTypedData({
|
|
845
|
+
safeAddress,
|
|
846
|
+
safeVersion,
|
|
847
|
+
chainId,
|
|
848
|
+
data
|
|
849
|
+
}) {
|
|
850
|
+
const isSafeTransactionDataType = data.hasOwnProperty("to");
|
|
851
|
+
const eip712WithChainId = semverSatisfies(safeVersion, EQ_OR_GT_1_3_0);
|
|
852
|
+
let typedData;
|
|
853
|
+
if (isSafeTransactionDataType) {
|
|
854
|
+
const txData = data;
|
|
855
|
+
typedData = {
|
|
856
|
+
types: getEip712TxTypes(safeVersion),
|
|
857
|
+
domain: {
|
|
858
|
+
verifyingContract: safeAddress
|
|
859
|
+
},
|
|
860
|
+
primaryType: "SafeTx",
|
|
861
|
+
message: {
|
|
862
|
+
...txData,
|
|
863
|
+
value: txData.value,
|
|
864
|
+
safeTxGas: txData.safeTxGas,
|
|
865
|
+
baseGas: txData.baseGas,
|
|
866
|
+
gasPrice: txData.gasPrice,
|
|
867
|
+
nonce: txData.nonce
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
} else {
|
|
871
|
+
const message = data;
|
|
872
|
+
typedData = {
|
|
873
|
+
types: getEip712MessageTypes(safeVersion),
|
|
874
|
+
domain: {
|
|
875
|
+
verifyingContract: safeAddress
|
|
876
|
+
},
|
|
877
|
+
primaryType: "SafeMessage",
|
|
878
|
+
message: { message: hashSafeMessage(message) }
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
if (eip712WithChainId) {
|
|
882
|
+
typedData.domain.chainId = Number(chainId);
|
|
883
|
+
}
|
|
884
|
+
return typedData;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
// src/utils/safeVersions.ts
|
|
888
|
+
import semverSatisfies2 from "semver/functions/satisfies.js";
|
|
889
|
+
var SAFE_FEATURES_BY_VERSION = {
|
|
890
|
+
["SAFE_TX_GAS_OPTIONAL" /* SAFE_TX_GAS_OPTIONAL */]: ">=1.3.0",
|
|
891
|
+
["SAFE_TX_GUARDS" /* SAFE_TX_GUARDS */]: ">=1.3.0",
|
|
892
|
+
["SAFE_FALLBACK_HANDLER" /* SAFE_FALLBACK_HANDLER */]: ">=1.1.1",
|
|
893
|
+
["ETH_SIGN" /* ETH_SIGN */]: ">=1.1.0",
|
|
894
|
+
["ACCOUNT_ABSTRACTION" /* ACCOUNT_ABSTRACTION */]: ">=1.3.0",
|
|
895
|
+
["REQUIRED_TXGAS" /* REQUIRED_TXGAS */]: "<=1.2.0",
|
|
896
|
+
["SIMULATE_AND_REVERT" /* SIMULATE_AND_REVERT */]: ">=1.3.0",
|
|
897
|
+
["PASSKEY_SIGNER" /* PASSKEY_SIGNER */]: ">=1.3.0",
|
|
898
|
+
["SAFE_L2_CONTRACTS" /* SAFE_L2_CONTRACTS */]: ">=1.3.0"
|
|
899
|
+
};
|
|
900
|
+
var hasSafeFeature = (feature, version) => {
|
|
901
|
+
if (!(feature in SAFE_FEATURES_BY_VERSION)) {
|
|
902
|
+
return false;
|
|
903
|
+
}
|
|
904
|
+
return semverSatisfies2(version, SAFE_FEATURES_BY_VERSION[feature]);
|
|
905
|
+
};
|
|
906
|
+
|
|
907
|
+
// src/utils/signatures/utils.ts
|
|
908
|
+
import { recoverAddress } from "viem";
|
|
909
|
+
import {
|
|
910
|
+
SigningMethod
|
|
911
|
+
} from "@safe-global/types-kit";
|
|
912
|
+
import semverSatisfies3 from "semver/functions/satisfies.js";
|
|
913
|
+
|
|
914
|
+
// src/utils/transactions/gas.ts
|
|
915
|
+
import { BaseError } from "viem";
|
|
916
|
+
import { OperationType } from "@safe-global/types-kit";
|
|
917
|
+
import semverSatisfies5 from "semver/functions/satisfies.js";
|
|
918
|
+
|
|
919
|
+
// src/contracts/BaseContract.ts
|
|
920
|
+
import {
|
|
921
|
+
encodeFunctionData
|
|
922
|
+
} from "viem";
|
|
923
|
+
import { estimateContractGas, getTransactionReceipt } from "viem/actions";
|
|
924
|
+
|
|
925
|
+
// src/contracts/config.ts
|
|
926
|
+
import {
|
|
927
|
+
getCompatibilityFallbackHandlerDeployments,
|
|
928
|
+
getCreateCallDeployments,
|
|
929
|
+
getMultiSendCallOnlyDeployments,
|
|
930
|
+
getMultiSendDeployments,
|
|
931
|
+
getProxyFactoryDeployments,
|
|
932
|
+
getSafeL2SingletonDeployments,
|
|
933
|
+
getSafeSingletonDeployments,
|
|
934
|
+
getSignMessageLibDeployments,
|
|
935
|
+
getSimulateTxAccessorDeployments
|
|
936
|
+
} from "@safe-global/safe-deployments";
|
|
937
|
+
import {
|
|
938
|
+
getSafeWebAuthnSignerFactoryDeployment,
|
|
939
|
+
getSafeWebAuthnShareSignerDeployment
|
|
940
|
+
} from "@safe-global/safe-modules-deployments";
|
|
941
|
+
var DEFAULT_SAFE_VERSION = "1.3.0";
|
|
942
|
+
var safeDeploymentsVersions = {
|
|
943
|
+
"1.4.1": {
|
|
944
|
+
safeSingletonVersion: "1.4.1",
|
|
945
|
+
safeSingletonL2Version: "1.4.1",
|
|
946
|
+
safeProxyFactoryVersion: "1.4.1",
|
|
947
|
+
compatibilityFallbackHandler: "1.4.1",
|
|
948
|
+
multiSendVersion: "1.4.1",
|
|
949
|
+
multiSendCallOnlyVersion: "1.4.1",
|
|
950
|
+
signMessageLibVersion: "1.4.1",
|
|
951
|
+
createCallVersion: "1.4.1",
|
|
952
|
+
simulateTxAccessorVersion: "1.4.1",
|
|
953
|
+
safeWebAuthnSignerFactoryVersion: "0.2.1",
|
|
954
|
+
safeWebAuthnSharedSignerVersion: "0.2.1"
|
|
955
|
+
},
|
|
956
|
+
"1.3.0": {
|
|
957
|
+
safeSingletonVersion: "1.3.0",
|
|
958
|
+
safeSingletonL2Version: "1.3.0",
|
|
959
|
+
safeProxyFactoryVersion: "1.3.0",
|
|
960
|
+
compatibilityFallbackHandler: "1.3.0",
|
|
961
|
+
multiSendVersion: "1.3.0",
|
|
962
|
+
multiSendCallOnlyVersion: "1.3.0",
|
|
963
|
+
signMessageLibVersion: "1.3.0",
|
|
964
|
+
createCallVersion: "1.3.0",
|
|
965
|
+
simulateTxAccessorVersion: "1.3.0",
|
|
966
|
+
safeWebAuthnSignerFactoryVersion: "0.2.1",
|
|
967
|
+
safeWebAuthnSharedSignerVersion: "0.2.1"
|
|
968
|
+
},
|
|
969
|
+
"1.2.0": {
|
|
970
|
+
safeSingletonVersion: "1.2.0",
|
|
971
|
+
safeSingletonL2Version: void 0,
|
|
972
|
+
safeProxyFactoryVersion: "1.1.1",
|
|
973
|
+
compatibilityFallbackHandler: "1.3.0",
|
|
974
|
+
multiSendVersion: "1.1.1",
|
|
975
|
+
multiSendCallOnlyVersion: "1.3.0",
|
|
976
|
+
signMessageLibVersion: "1.3.0",
|
|
977
|
+
createCallVersion: "1.3.0",
|
|
978
|
+
safeWebAuthnSignerFactoryVersion: void 0,
|
|
979
|
+
safeWebAuthnSharedSignerVersion: void 0
|
|
980
|
+
},
|
|
981
|
+
"1.1.1": {
|
|
982
|
+
safeSingletonVersion: "1.1.1",
|
|
983
|
+
safeSingletonL2Version: void 0,
|
|
984
|
+
safeProxyFactoryVersion: "1.1.1",
|
|
985
|
+
compatibilityFallbackHandler: "1.3.0",
|
|
986
|
+
multiSendVersion: "1.1.1",
|
|
987
|
+
multiSendCallOnlyVersion: "1.3.0",
|
|
988
|
+
signMessageLibVersion: "1.3.0",
|
|
989
|
+
createCallVersion: "1.3.0",
|
|
990
|
+
safeWebAuthnSignerFactoryVersion: void 0,
|
|
991
|
+
safeWebAuthnSharedSignerVersion: void 0
|
|
992
|
+
},
|
|
993
|
+
"1.0.0": {
|
|
994
|
+
safeSingletonVersion: "1.0.0",
|
|
995
|
+
safeSingletonL2Version: void 0,
|
|
996
|
+
safeProxyFactoryVersion: "1.0.0",
|
|
997
|
+
compatibilityFallbackHandler: "1.3.0",
|
|
998
|
+
multiSendVersion: "1.1.1",
|
|
999
|
+
multiSendCallOnlyVersion: "1.3.0",
|
|
1000
|
+
signMessageLibVersion: "1.3.0",
|
|
1001
|
+
createCallVersion: "1.3.0",
|
|
1002
|
+
safeWebAuthnSignerFactoryVersion: void 0,
|
|
1003
|
+
safeWebAuthnSharedSignerVersion: void 0
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
var safeDeploymentsL1ChainIds = [
|
|
1007
|
+
1n
|
|
1008
|
+
// Ethereum Mainnet
|
|
1009
|
+
];
|
|
1010
|
+
var contractFunctions = {
|
|
1011
|
+
safeSingletonVersion: getSafeSingletonDeployments,
|
|
1012
|
+
safeSingletonL2Version: getSafeL2SingletonDeployments,
|
|
1013
|
+
safeProxyFactoryVersion: getProxyFactoryDeployments,
|
|
1014
|
+
compatibilityFallbackHandler: getCompatibilityFallbackHandlerDeployments,
|
|
1015
|
+
multiSendVersion: getMultiSendDeployments,
|
|
1016
|
+
multiSendCallOnlyVersion: getMultiSendCallOnlyDeployments,
|
|
1017
|
+
signMessageLibVersion: getSignMessageLibDeployments,
|
|
1018
|
+
createCallVersion: getCreateCallDeployments,
|
|
1019
|
+
simulateTxAccessorVersion: getSimulateTxAccessorDeployments,
|
|
1020
|
+
safeWebAuthnSignerFactoryVersion: getSafeWebAuthnSignerFactoryDeployment,
|
|
1021
|
+
safeWebAuthnSharedSignerVersion: getSafeWebAuthnShareSignerDeployment
|
|
1022
|
+
};
|
|
1023
|
+
function getContractDeployment(safeVersion, chainId, contractName3) {
|
|
1024
|
+
const contractVersion = safeDeploymentsVersions[safeVersion][contractName3];
|
|
1025
|
+
const filters = {
|
|
1026
|
+
version: contractVersion,
|
|
1027
|
+
network: chainId.toString(),
|
|
1028
|
+
released: true
|
|
1029
|
+
};
|
|
1030
|
+
const deployment = contractFunctions[contractName3](filters);
|
|
1031
|
+
return deployment;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// src/contracts/BaseContract.ts
|
|
1035
|
+
var BaseContract = class {
|
|
1036
|
+
/**
|
|
1037
|
+
* @constructor
|
|
1038
|
+
* Constructs an instance of BaseContract.
|
|
1039
|
+
*
|
|
1040
|
+
* @param contractName - The contract name.
|
|
1041
|
+
* @param chainId - The chain ID of the contract.
|
|
1042
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
1043
|
+
* @param defaultAbi - The default ABI for the contract. It should be compatible with the specific version of the contract.
|
|
1044
|
+
* @param safeVersion - The version of the Safe contract.
|
|
1045
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
1046
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used.
|
|
1047
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
1048
|
+
*/
|
|
1049
|
+
constructor(contractName3, chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi, deploymentType) {
|
|
1050
|
+
this.getAddress = () => {
|
|
1051
|
+
return this.contractAddress;
|
|
1052
|
+
};
|
|
1053
|
+
this.encode = (functionToEncode, args) => {
|
|
1054
|
+
const abi = this.contractAbi;
|
|
1055
|
+
const functionName = functionToEncode;
|
|
1056
|
+
const params = args;
|
|
1057
|
+
return encodeFunctionData({
|
|
1058
|
+
abi,
|
|
1059
|
+
functionName,
|
|
1060
|
+
args: params
|
|
1061
|
+
});
|
|
1062
|
+
};
|
|
1063
|
+
this.estimateGas = async (functionToEstimate, args, options = {}) => {
|
|
1064
|
+
const contractOptions = this.convertOptions(options);
|
|
1065
|
+
const abi = this.contractAbi;
|
|
1066
|
+
const params = args;
|
|
1067
|
+
return estimateContractGas(this.runner, {
|
|
1068
|
+
abi,
|
|
1069
|
+
functionName: functionToEstimate,
|
|
1070
|
+
address: this.getAddress(),
|
|
1071
|
+
args: params,
|
|
1072
|
+
...contractOptions
|
|
1073
|
+
});
|
|
1074
|
+
};
|
|
1075
|
+
const deployment = getContractDeployment(safeVersion, chainId, contractName3);
|
|
1076
|
+
const resolvedAddress = customContractAddress ?? this.#resolveAddress(
|
|
1077
|
+
deployment?.networkAddresses[chainId.toString()],
|
|
1078
|
+
deployment,
|
|
1079
|
+
deploymentType
|
|
1080
|
+
);
|
|
1081
|
+
if (!resolvedAddress) {
|
|
1082
|
+
throw new Error(`Invalid ${contractName3.replace("Version", "")} contract address`);
|
|
1083
|
+
}
|
|
1084
|
+
this.chainId = chainId;
|
|
1085
|
+
this.contractName = contractName3;
|
|
1086
|
+
this.safeVersion = safeVersion;
|
|
1087
|
+
this.contractAddress = resolvedAddress;
|
|
1088
|
+
this.contractAbi = customContractAbi || deployment?.abi || // this cast is required because abi is set as any[] in safe-deployments
|
|
1089
|
+
defaultAbi;
|
|
1090
|
+
this.runner = safeProvider.getExternalProvider();
|
|
1091
|
+
this.safeProvider = safeProvider;
|
|
1092
|
+
}
|
|
1093
|
+
#resolveAddress(networkAddresses, deployment, deploymentType) {
|
|
1094
|
+
if (!networkAddresses) {
|
|
1095
|
+
return void 0;
|
|
1096
|
+
}
|
|
1097
|
+
if (deploymentType && deployment && "deployments" in deployment) {
|
|
1098
|
+
const customDeploymentTypeAddress = deployment.deployments[deploymentType]?.address;
|
|
1099
|
+
if (typeof networkAddresses === "string") {
|
|
1100
|
+
return networkAddresses === customDeploymentTypeAddress ? customDeploymentTypeAddress : void 0;
|
|
1101
|
+
}
|
|
1102
|
+
return networkAddresses.find((address) => address === customDeploymentTypeAddress);
|
|
1103
|
+
}
|
|
1104
|
+
if (typeof networkAddresses === "string") {
|
|
1105
|
+
return networkAddresses;
|
|
1106
|
+
}
|
|
1107
|
+
return networkAddresses[0];
|
|
1108
|
+
}
|
|
1109
|
+
async init() {
|
|
1110
|
+
this.wallet = await this.safeProvider.getExternalSigner();
|
|
1111
|
+
}
|
|
1112
|
+
async getTransactionReceipt(hash) {
|
|
1113
|
+
return getTransactionReceipt(this.runner, { hash });
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Converts a type of TransactionOptions to a viem transaction type. The viem transaction type creates a clear distinction between the multiple transaction objects (e.g., post-London hard fork) and doesn't allow a union of fields.
|
|
1117
|
+
* See: https://github.com/wevm/viem/blob/viem%402.18.0/src/types/fee.ts and https://github.com/wevm/viem/blob/603227e2588366914fb79a902d23fd9afc353cc6/src/types/transaction.ts#L200
|
|
1118
|
+
*
|
|
1119
|
+
* @param options - Transaction options as expected throughout safe sdk and propagated on the results.
|
|
1120
|
+
*
|
|
1121
|
+
* @returns Options object compatible with Viem
|
|
1122
|
+
*/
|
|
1123
|
+
convertOptions(options) {
|
|
1124
|
+
const chain = this.getChain();
|
|
1125
|
+
if (!chain) throw new Error("Invalid chainId");
|
|
1126
|
+
const account = this.getWallet().account;
|
|
1127
|
+
if (!account) throw new Error("Invalid signer");
|
|
1128
|
+
const txOptions = convertTransactionOptions(options);
|
|
1129
|
+
return { chain, ...txOptions, account };
|
|
1130
|
+
}
|
|
1131
|
+
getChain() {
|
|
1132
|
+
return getChainById(this.chainId);
|
|
1133
|
+
}
|
|
1134
|
+
getWallet() {
|
|
1135
|
+
if (!this.wallet) throw new Error("A signer must be set");
|
|
1136
|
+
return this.wallet;
|
|
1137
|
+
}
|
|
1138
|
+
async write(functionName, args, options) {
|
|
1139
|
+
const converted = this.convertOptions(options);
|
|
1140
|
+
return await this.getWallet().writeContract({
|
|
1141
|
+
address: this.contractAddress,
|
|
1142
|
+
abi: this.contractAbi,
|
|
1143
|
+
functionName,
|
|
1144
|
+
args,
|
|
1145
|
+
...converted
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
async read(functionName, args) {
|
|
1149
|
+
return await this.runner.readContract({
|
|
1150
|
+
functionName,
|
|
1151
|
+
abi: this.contractAbi,
|
|
1152
|
+
address: this.contractAddress,
|
|
1153
|
+
args
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
};
|
|
1157
|
+
var BaseContract_default = BaseContract;
|
|
1158
|
+
|
|
1159
|
+
// src/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0.ts
|
|
1160
|
+
import {
|
|
1161
|
+
createCall_1_3_0_ContractArtifacts
|
|
1162
|
+
} from "@safe-global/types-kit";
|
|
1163
|
+
|
|
1164
|
+
// src/contracts/utils.ts
|
|
1165
|
+
import {
|
|
1166
|
+
concat as concat2,
|
|
1167
|
+
getContractAddress,
|
|
1168
|
+
isAddress as isAddress4,
|
|
1169
|
+
keccak256 as keccak2562,
|
|
1170
|
+
pad,
|
|
1171
|
+
parseAbi as parseAbi2,
|
|
1172
|
+
toHex as toHex3,
|
|
1173
|
+
toEventHash,
|
|
1174
|
+
decodeEventLog
|
|
1175
|
+
} from "viem";
|
|
1176
|
+
import { waitForTransactionReceipt } from "viem/actions";
|
|
1177
|
+
|
|
1178
|
+
// src/utils/block.ts
|
|
1179
|
+
function asBlockId(blockId) {
|
|
1180
|
+
return typeof blockId === "number" ? blockNumber(blockId) : blockTag(blockId);
|
|
1181
|
+
}
|
|
1182
|
+
function blockNumber(blockNumber2) {
|
|
1183
|
+
return { blockNumber: blockNumber2.toNumber() };
|
|
1184
|
+
}
|
|
1185
|
+
function blockTag(blockTag2) {
|
|
1186
|
+
return { blockTag: blockTag2 };
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
// src/SafeProvider.ts
|
|
1190
|
+
import {
|
|
1191
|
+
createPublicClient,
|
|
1192
|
+
createWalletClient,
|
|
1193
|
+
custom as custom2,
|
|
1194
|
+
http,
|
|
1195
|
+
getAddress,
|
|
1196
|
+
isAddress as isAddress3,
|
|
1197
|
+
decodeAbiParameters,
|
|
1198
|
+
encodeAbiParameters as encodeAbiParameters3,
|
|
1199
|
+
parseAbiParameters as parseAbiParameters2,
|
|
1200
|
+
toBytes as toBytes2,
|
|
1201
|
+
walletActions as walletActions2,
|
|
1202
|
+
publicActions,
|
|
1203
|
+
createClient as createClient2,
|
|
1204
|
+
rpcSchema
|
|
1205
|
+
} from "viem";
|
|
1206
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
1207
|
+
import {
|
|
1208
|
+
call,
|
|
1209
|
+
estimateGas,
|
|
1210
|
+
getBalance,
|
|
1211
|
+
getCode,
|
|
1212
|
+
getTransaction,
|
|
1213
|
+
getTransactionCount,
|
|
1214
|
+
getStorageAt,
|
|
1215
|
+
readContract
|
|
1216
|
+
} from "viem/actions";
|
|
1217
|
+
|
|
1218
|
+
// src/utils/provider.ts
|
|
1219
|
+
import { isAddress as isAddress2 } from "viem";
|
|
1220
|
+
|
|
1221
|
+
// src/utils/passkeys/extractPasskeyData.ts
|
|
1222
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
1223
|
+
import { getFCLP256VerifierDeployment } from "@safe-global/safe-modules-deployments";
|
|
1224
|
+
async function decodePublicKeyForWeb(publicKey) {
|
|
1225
|
+
const algorithm = {
|
|
1226
|
+
name: "ECDSA",
|
|
1227
|
+
namedCurve: "P-256",
|
|
1228
|
+
hash: { name: "SHA-256" }
|
|
1229
|
+
};
|
|
1230
|
+
const key = await crypto.subtle.importKey("spki", publicKey, algorithm, true, ["verify"]);
|
|
1231
|
+
const { x, y } = await crypto.subtle.exportKey("jwk", key);
|
|
1232
|
+
const isValidCoordinates = !!x && !!y;
|
|
1233
|
+
if (!isValidCoordinates) {
|
|
1234
|
+
throw new Error("Failed to generate passkey Coordinates. crypto.subtle.exportKey() failed");
|
|
1235
|
+
}
|
|
1236
|
+
return {
|
|
1237
|
+
x: "0x" + Buffer2.from(x, "base64").toString("hex"),
|
|
1238
|
+
y: "0x" + Buffer2.from(y, "base64").toString("hex")
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
function getDefaultFCLP256VerifierAddress(chainId) {
|
|
1242
|
+
const FCLP256VerifierDeployment = getFCLP256VerifierDeployment({
|
|
1243
|
+
version: "0.2.1",
|
|
1244
|
+
released: true,
|
|
1245
|
+
network: chainId
|
|
1246
|
+
});
|
|
1247
|
+
if (!FCLP256VerifierDeployment) {
|
|
1248
|
+
throw new Error(`Failed to load FCLP256Verifier deployment for chain ID ${chainId}`);
|
|
1249
|
+
}
|
|
1250
|
+
const verifierAddress = FCLP256VerifierDeployment.networkAddresses[chainId];
|
|
1251
|
+
if (!verifierAddress) {
|
|
1252
|
+
throw new Error(`FCLP256Verifier address not found for chain ID ${chainId}`);
|
|
1253
|
+
}
|
|
1254
|
+
return verifierAddress;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
// src/utils/passkeys/PasskeyClient.ts
|
|
1258
|
+
import {
|
|
1259
|
+
hexToBytes,
|
|
1260
|
+
encodeAbiParameters as encodeAbiParameters2,
|
|
1261
|
+
toHex as toHex2,
|
|
1262
|
+
toBytes,
|
|
1263
|
+
stringToBytes,
|
|
1264
|
+
isHex as isHex2,
|
|
1265
|
+
createClient,
|
|
1266
|
+
custom,
|
|
1267
|
+
walletActions,
|
|
1268
|
+
maxUint256,
|
|
1269
|
+
fromBytes,
|
|
1270
|
+
fromHex,
|
|
1271
|
+
parseAbiParameters,
|
|
1272
|
+
encodeFunctionData as encodeFunctionData2,
|
|
1273
|
+
parseAbi
|
|
1274
|
+
} from "viem";
|
|
1275
|
+
|
|
1276
|
+
// src/utils/passkeys/isSharedSigner.ts
|
|
1277
|
+
async function isSharedSigner(passkey, safeWebAuthnSharedSignerContract, safeAddress, owners, chainId) {
|
|
1278
|
+
const sharedSignerContractAddress = safeWebAuthnSharedSignerContract.contractAddress;
|
|
1279
|
+
if (safeAddress && owners.includes(sharedSignerContractAddress)) {
|
|
1280
|
+
const [sharedSignerSlot] = await safeWebAuthnSharedSignerContract.getConfiguration([
|
|
1281
|
+
asHex(safeAddress)
|
|
1282
|
+
]);
|
|
1283
|
+
const { x, y, verifiers } = sharedSignerSlot;
|
|
1284
|
+
const verifierAddress = passkey.customVerifierAddress || getDefaultFCLP256VerifierAddress(chainId);
|
|
1285
|
+
const isSharedSigner2 = BigInt(passkey.coordinates.x) === x && BigInt(passkey.coordinates.y) === y && BigInt(verifierAddress) === verifiers;
|
|
1286
|
+
return isSharedSigner2;
|
|
1287
|
+
}
|
|
1288
|
+
return false;
|
|
1289
|
+
}
|
|
1290
|
+
var isSharedSigner_default = isSharedSigner;
|
|
1291
|
+
|
|
1292
|
+
// src/utils/passkeys/PasskeyClient.ts
|
|
1293
|
+
var PASSKEY_CLIENT_KEY = "passkeyWallet";
|
|
1294
|
+
var PASSKEY_CLIENT_NAME = "Passkey Wallet Client";
|
|
1295
|
+
var sign = async (passkeyRawId, data, getFn) => {
|
|
1296
|
+
const getCredentials = getFn || navigator.credentials.get.bind(navigator.credentials);
|
|
1297
|
+
const assertion = await getCredentials({
|
|
1298
|
+
publicKey: {
|
|
1299
|
+
challenge: data,
|
|
1300
|
+
allowCredentials: [{ type: "public-key", id: passkeyRawId }],
|
|
1301
|
+
userVerification: "required"
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1304
|
+
const assertionResponse = assertion.response;
|
|
1305
|
+
if (!assertionResponse?.authenticatorData) {
|
|
1306
|
+
throw new Error("Failed to sign data with passkey Signer");
|
|
1307
|
+
}
|
|
1308
|
+
const { authenticatorData, signature, clientDataJSON } = assertionResponse;
|
|
1309
|
+
return encodeAbiParameters2(parseAbiParameters("bytes, bytes, uint256[2]"), [
|
|
1310
|
+
toHex2(new Uint8Array(authenticatorData)),
|
|
1311
|
+
extractClientDataFields(clientDataJSON),
|
|
1312
|
+
extractSignature(signature)
|
|
1313
|
+
]);
|
|
1314
|
+
};
|
|
1315
|
+
var signTransaction = () => {
|
|
1316
|
+
throw new Error("Passkey Signers cannot sign transactions, they can only sign data.");
|
|
1317
|
+
};
|
|
1318
|
+
var signTypedData = () => {
|
|
1319
|
+
throw new Error("Passkey Signers cannot sign signTypedData, they can only sign data.");
|
|
1320
|
+
};
|
|
1321
|
+
var createPasskeyClient = async (passkey, safeWebAuthnSignerFactoryContract, safeWebAuthnSharedSignerContract, provider, safeAddress, owners, chainId) => {
|
|
1322
|
+
const { rawId, coordinates, customVerifierAddress } = passkey;
|
|
1323
|
+
const passkeyRawId = hexToBytes(asHex(rawId));
|
|
1324
|
+
const verifierAddress = customVerifierAddress || getDefaultFCLP256VerifierAddress(chainId);
|
|
1325
|
+
const isPasskeySharedSigner = await isSharedSigner_default(
|
|
1326
|
+
passkey,
|
|
1327
|
+
safeWebAuthnSharedSignerContract,
|
|
1328
|
+
safeAddress,
|
|
1329
|
+
owners,
|
|
1330
|
+
chainId
|
|
1331
|
+
);
|
|
1332
|
+
let signerAddress;
|
|
1333
|
+
if (isPasskeySharedSigner) {
|
|
1334
|
+
signerAddress = safeWebAuthnSharedSignerContract.getAddress();
|
|
1335
|
+
} else {
|
|
1336
|
+
;
|
|
1337
|
+
[signerAddress] = await safeWebAuthnSignerFactoryContract.getSigner([
|
|
1338
|
+
BigInt(coordinates.x),
|
|
1339
|
+
BigInt(coordinates.y),
|
|
1340
|
+
fromHex(asHex(verifierAddress), "bigint")
|
|
1341
|
+
]);
|
|
1342
|
+
}
|
|
1343
|
+
return createClient({
|
|
1344
|
+
account: signerAddress,
|
|
1345
|
+
name: PASSKEY_CLIENT_NAME,
|
|
1346
|
+
key: PASSKEY_CLIENT_KEY,
|
|
1347
|
+
transport: custom(provider.transport)
|
|
1348
|
+
}).extend(walletActions).extend(() => ({
|
|
1349
|
+
signMessage({ message }) {
|
|
1350
|
+
if (typeof message === "string") {
|
|
1351
|
+
return sign(passkeyRawId, toBytes(message), passkey.getFn);
|
|
1352
|
+
}
|
|
1353
|
+
return sign(
|
|
1354
|
+
passkeyRawId,
|
|
1355
|
+
isHex2(message.raw) ? toBytes(message.raw) : message.raw,
|
|
1356
|
+
passkey.getFn
|
|
1357
|
+
);
|
|
1358
|
+
},
|
|
1359
|
+
signTransaction,
|
|
1360
|
+
signTypedData,
|
|
1361
|
+
encodeConfigure() {
|
|
1362
|
+
return encodeFunctionData2({
|
|
1363
|
+
abi: parseAbi(["function configure((uint256 x, uint256 y, uint176 verifiers) signer)"]),
|
|
1364
|
+
functionName: "configure",
|
|
1365
|
+
args: [
|
|
1366
|
+
{
|
|
1367
|
+
x: BigInt(passkey.coordinates.x),
|
|
1368
|
+
y: BigInt(passkey.coordinates.y),
|
|
1369
|
+
verifiers: fromHex(asHex(verifierAddress), "bigint")
|
|
1370
|
+
}
|
|
1371
|
+
]
|
|
1372
|
+
});
|
|
1373
|
+
},
|
|
1374
|
+
encodeCreateSigner() {
|
|
1375
|
+
return asHex(
|
|
1376
|
+
safeWebAuthnSignerFactoryContract.encode("createSigner", [
|
|
1377
|
+
BigInt(coordinates.x),
|
|
1378
|
+
BigInt(coordinates.y),
|
|
1379
|
+
BigInt(verifierAddress)
|
|
1380
|
+
])
|
|
1381
|
+
);
|
|
1382
|
+
},
|
|
1383
|
+
createDeployTxRequest() {
|
|
1384
|
+
const passkeySignerDeploymentTransaction = {
|
|
1385
|
+
to: safeWebAuthnSignerFactoryContract.getAddress(),
|
|
1386
|
+
value: "0",
|
|
1387
|
+
data: this.encodeCreateSigner()
|
|
1388
|
+
};
|
|
1389
|
+
return passkeySignerDeploymentTransaction;
|
|
1390
|
+
}
|
|
1391
|
+
}));
|
|
1392
|
+
};
|
|
1393
|
+
function decodeClientDataJSON(clientDataJSON) {
|
|
1394
|
+
const uint8Array = new Uint8Array(clientDataJSON);
|
|
1395
|
+
let result = "";
|
|
1396
|
+
for (let i = 0; i < uint8Array.length; i++) {
|
|
1397
|
+
result += String.fromCharCode(uint8Array[i]);
|
|
1398
|
+
}
|
|
1399
|
+
return result;
|
|
1400
|
+
}
|
|
1401
|
+
function extractClientDataFields(clientDataJSON) {
|
|
1402
|
+
const decodedClientDataJSON = decodeClientDataJSON(clientDataJSON);
|
|
1403
|
+
const match = decodedClientDataJSON.match(
|
|
1404
|
+
/^\{"type":"webauthn.get","challenge":"[A-Za-z0-9\-_]{43}",(.*)\}$/
|
|
1405
|
+
);
|
|
1406
|
+
if (!match) {
|
|
1407
|
+
throw new Error("challenge not found in client data JSON");
|
|
1408
|
+
}
|
|
1409
|
+
const [, fields] = match;
|
|
1410
|
+
return toHex2(stringToBytes(fields));
|
|
1411
|
+
}
|
|
1412
|
+
function extractSignature(signature) {
|
|
1413
|
+
const check = (x) => {
|
|
1414
|
+
if (!x) {
|
|
1415
|
+
throw new Error("invalid signature encoding");
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
const view = new DataView(
|
|
1419
|
+
signature instanceof ArrayBuffer ? signature : signature instanceof Uint8Array ? signature.buffer : new Uint8Array(signature).buffer
|
|
1420
|
+
);
|
|
1421
|
+
check(view.getUint8(0) === 48);
|
|
1422
|
+
check(view.getUint8(1) === view.byteLength - 2);
|
|
1423
|
+
const readInt = (offset) => {
|
|
1424
|
+
check(view.getUint8(offset) === 2);
|
|
1425
|
+
const len = view.getUint8(offset + 1);
|
|
1426
|
+
const start = offset + 2;
|
|
1427
|
+
const end = start + len;
|
|
1428
|
+
const n = fromBytes(new Uint8Array(view.buffer.slice(start, end)), "bigint");
|
|
1429
|
+
check(n < maxUint256);
|
|
1430
|
+
return [n, end];
|
|
1431
|
+
};
|
|
1432
|
+
const [r, sOffset] = readInt(2);
|
|
1433
|
+
const [s] = readInt(sOffset);
|
|
1434
|
+
return [r, s];
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
// src/utils/provider.ts
|
|
1438
|
+
var isEip1193Provider = (provider) => typeof provider !== "string";
|
|
1439
|
+
var isPrivateKey = (signer) => typeof signer === "string" && !isAddress2(signer);
|
|
1440
|
+
var isSignerPasskeyClient = (signer) => !!signer && signer.key === PASSKEY_CLIENT_KEY;
|
|
1441
|
+
|
|
1442
|
+
// src/SafeProvider.ts
|
|
1443
|
+
var SafeProvider = class _SafeProvider {
|
|
1444
|
+
#chain;
|
|
1445
|
+
#externalProvider;
|
|
1446
|
+
constructor({
|
|
1447
|
+
provider,
|
|
1448
|
+
signer
|
|
1449
|
+
}) {
|
|
1450
|
+
this.#externalProvider = createPublicClient({
|
|
1451
|
+
transport: isEip1193Provider(provider) ? custom2(provider) : http(provider)
|
|
1452
|
+
});
|
|
1453
|
+
this.provider = provider;
|
|
1454
|
+
this.signer = signer;
|
|
1455
|
+
this.#chain = void 0;
|
|
1456
|
+
}
|
|
1457
|
+
getExternalProvider() {
|
|
1458
|
+
return this.#externalProvider;
|
|
1459
|
+
}
|
|
1460
|
+
static async init({
|
|
1461
|
+
provider,
|
|
1462
|
+
signer,
|
|
1463
|
+
safeVersion = DEFAULT_SAFE_VERSION,
|
|
1464
|
+
contractNetworks,
|
|
1465
|
+
safeAddress,
|
|
1466
|
+
owners
|
|
1467
|
+
}) {
|
|
1468
|
+
const isPasskeySigner = signer && typeof signer !== "string";
|
|
1469
|
+
if (isPasskeySigner) {
|
|
1470
|
+
if (!hasSafeFeature("PASSKEY_SIGNER" /* PASSKEY_SIGNER */, safeVersion)) {
|
|
1471
|
+
throw new Error(
|
|
1472
|
+
"Current version of the Safe does not support the Passkey signer functionality"
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
const safeProvider = new _SafeProvider({
|
|
1476
|
+
provider
|
|
1477
|
+
});
|
|
1478
|
+
const chainId = await safeProvider.getChainId();
|
|
1479
|
+
const customContracts = contractNetworks?.[chainId.toString()];
|
|
1480
|
+
let passkeySigner;
|
|
1481
|
+
if (!isSignerPasskeyClient(signer)) {
|
|
1482
|
+
const safeWebAuthnSignerFactoryContract = await getSafeWebAuthnSignerFactoryContract({
|
|
1483
|
+
safeProvider,
|
|
1484
|
+
safeVersion,
|
|
1485
|
+
customContracts
|
|
1486
|
+
});
|
|
1487
|
+
const safeWebAuthnSharedSignerContract = await getSafeWebAuthnSharedSignerContract({
|
|
1488
|
+
safeProvider,
|
|
1489
|
+
safeVersion,
|
|
1490
|
+
customContracts
|
|
1491
|
+
});
|
|
1492
|
+
passkeySigner = await createPasskeyClient(
|
|
1493
|
+
signer,
|
|
1494
|
+
safeWebAuthnSignerFactoryContract,
|
|
1495
|
+
safeWebAuthnSharedSignerContract,
|
|
1496
|
+
safeProvider.getExternalProvider(),
|
|
1497
|
+
safeAddress || "",
|
|
1498
|
+
owners || [],
|
|
1499
|
+
chainId.toString()
|
|
1500
|
+
);
|
|
1501
|
+
} else {
|
|
1502
|
+
passkeySigner = signer;
|
|
1503
|
+
}
|
|
1504
|
+
return new _SafeProvider({
|
|
1505
|
+
provider,
|
|
1506
|
+
signer: passkeySigner
|
|
1507
|
+
});
|
|
1508
|
+
} else {
|
|
1509
|
+
return new _SafeProvider({
|
|
1510
|
+
provider,
|
|
1511
|
+
signer
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
async getExternalSigner() {
|
|
1516
|
+
const { transport, chain = await this.#getChain() } = this.getExternalProvider();
|
|
1517
|
+
if (isSignerPasskeyClient(this.signer)) {
|
|
1518
|
+
return this.signer;
|
|
1519
|
+
}
|
|
1520
|
+
if (isPrivateKey(this.signer)) {
|
|
1521
|
+
const account = privateKeyToAccount(asHex(this.signer));
|
|
1522
|
+
return createWalletClient({
|
|
1523
|
+
account,
|
|
1524
|
+
chain,
|
|
1525
|
+
transport: custom2(transport)
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
if (this.signer && typeof this.signer === "string") {
|
|
1529
|
+
return createWalletClient({
|
|
1530
|
+
account: this.signer,
|
|
1531
|
+
chain,
|
|
1532
|
+
transport: custom2(transport)
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
try {
|
|
1536
|
+
const wallet = createWalletClient({
|
|
1537
|
+
chain,
|
|
1538
|
+
transport: custom2(transport)
|
|
1539
|
+
});
|
|
1540
|
+
const [address] = await wallet.getAddresses();
|
|
1541
|
+
if (address) {
|
|
1542
|
+
const client = createClient2({
|
|
1543
|
+
account: address,
|
|
1544
|
+
transport: custom2(transport),
|
|
1545
|
+
chain: wallet.chain,
|
|
1546
|
+
rpcSchema: rpcSchema()
|
|
1547
|
+
}).extend(walletActions2).extend(publicActions);
|
|
1548
|
+
return client;
|
|
1549
|
+
}
|
|
1550
|
+
} catch {
|
|
1551
|
+
}
|
|
1552
|
+
return void 0;
|
|
1553
|
+
}
|
|
1554
|
+
async isPasskeySigner() {
|
|
1555
|
+
return isSignerPasskeyClient(this.signer);
|
|
1556
|
+
}
|
|
1557
|
+
isAddress(address) {
|
|
1558
|
+
return isAddress3(address);
|
|
1559
|
+
}
|
|
1560
|
+
async getEip3770Address(fullAddress) {
|
|
1561
|
+
const chainId = await this.getChainId();
|
|
1562
|
+
return validateEip3770Address(fullAddress, chainId);
|
|
1563
|
+
}
|
|
1564
|
+
async getBalance(address, blockTag2) {
|
|
1565
|
+
return getBalance(this.#externalProvider, {
|
|
1566
|
+
address,
|
|
1567
|
+
...asBlockId(blockTag2)
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1570
|
+
async getNonce(address, blockTag2) {
|
|
1571
|
+
return getTransactionCount(this.#externalProvider, {
|
|
1572
|
+
address,
|
|
1573
|
+
...asBlockId(blockTag2)
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
async getChainId() {
|
|
1577
|
+
const res = (await this.#getChain()).id;
|
|
1578
|
+
return BigInt(res);
|
|
1579
|
+
}
|
|
1580
|
+
getChecksummedAddress(address) {
|
|
1581
|
+
return getAddress(address);
|
|
1582
|
+
}
|
|
1583
|
+
async getContractCode(address, blockTag2) {
|
|
1584
|
+
const res = await getCode(this.#externalProvider, {
|
|
1585
|
+
address,
|
|
1586
|
+
...asBlockId(blockTag2)
|
|
1587
|
+
});
|
|
1588
|
+
return res ?? "0x";
|
|
1589
|
+
}
|
|
1590
|
+
async isContractDeployed(address, blockTag2) {
|
|
1591
|
+
const contractCode = await getCode(this.#externalProvider, {
|
|
1592
|
+
address,
|
|
1593
|
+
...asBlockId(blockTag2)
|
|
1594
|
+
});
|
|
1595
|
+
return !!contractCode;
|
|
1596
|
+
}
|
|
1597
|
+
async getStorageAt(address, position) {
|
|
1598
|
+
const content = await getStorageAt(this.#externalProvider, {
|
|
1599
|
+
address,
|
|
1600
|
+
slot: asHex(position)
|
|
1601
|
+
});
|
|
1602
|
+
const decodedContent = this.decodeParameters("address", asHex(content));
|
|
1603
|
+
return decodedContent[0];
|
|
1604
|
+
}
|
|
1605
|
+
async getTransaction(transactionHash) {
|
|
1606
|
+
return getTransaction(this.#externalProvider, {
|
|
1607
|
+
hash: asHash(transactionHash)
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
async getSignerAddress() {
|
|
1611
|
+
const externalSigner = await this.getExternalSigner();
|
|
1612
|
+
return externalSigner ? getAddress(externalSigner.account.address) : void 0;
|
|
1613
|
+
}
|
|
1614
|
+
async signMessage(message) {
|
|
1615
|
+
const signer = await this.getExternalSigner();
|
|
1616
|
+
const account = await this.getSignerAddress();
|
|
1617
|
+
if (!signer || !account) {
|
|
1618
|
+
throw new Error("SafeProvider must be initialized with a signer to use this method");
|
|
1619
|
+
}
|
|
1620
|
+
if (sameString(signer.account.address, account)) {
|
|
1621
|
+
return await signer?.signMessage({
|
|
1622
|
+
message: { raw: toBytes2(message) }
|
|
1623
|
+
});
|
|
1624
|
+
} else {
|
|
1625
|
+
return await signer?.signMessage({
|
|
1626
|
+
account,
|
|
1627
|
+
message: { raw: toBytes2(message) }
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
async signTypedData(safeEIP712Args) {
|
|
1632
|
+
const signer = await this.getExternalSigner();
|
|
1633
|
+
if (!signer) {
|
|
1634
|
+
throw new Error("SafeProvider must be initialized with a signer to use this method");
|
|
1635
|
+
}
|
|
1636
|
+
if (isTypedDataSigner(signer)) {
|
|
1637
|
+
const typedData = generateTypedData(safeEIP712Args);
|
|
1638
|
+
const { chainId, verifyingContract } = typedData.domain;
|
|
1639
|
+
const chain = chainId ? Number(chainId) : void 0;
|
|
1640
|
+
const domain = { verifyingContract, chainId: chain };
|
|
1641
|
+
const signature = await signer.signTypedData({
|
|
1642
|
+
domain,
|
|
1643
|
+
types: typedData.primaryType === "SafeMessage" ? { SafeMessage: typedData.types.SafeMessage } : { SafeTx: typedData.types.SafeTx },
|
|
1644
|
+
primaryType: typedData.primaryType,
|
|
1645
|
+
message: typedData.message
|
|
1646
|
+
});
|
|
1647
|
+
return signature;
|
|
1648
|
+
}
|
|
1649
|
+
throw new Error("The current signer does not implement EIP-712 to sign typed data");
|
|
1650
|
+
}
|
|
1651
|
+
async estimateGas(transaction) {
|
|
1652
|
+
const converted = toEstimateGasParameters(transaction);
|
|
1653
|
+
return (await estimateGas(this.#externalProvider, converted)).toString();
|
|
1654
|
+
}
|
|
1655
|
+
async call(transaction, blockTag2) {
|
|
1656
|
+
const converted = toTransactionRequest(transaction);
|
|
1657
|
+
const { data } = await call(this.#externalProvider, {
|
|
1658
|
+
...converted,
|
|
1659
|
+
...asBlockId(blockTag2)
|
|
1660
|
+
});
|
|
1661
|
+
return data ?? "0x";
|
|
1662
|
+
}
|
|
1663
|
+
async readContract(args) {
|
|
1664
|
+
return readContract(this.#externalProvider, args);
|
|
1665
|
+
}
|
|
1666
|
+
// TODO: fix anys
|
|
1667
|
+
encodeParameters(types, values) {
|
|
1668
|
+
return encodeAbiParameters3(parseAbiParameters2(types), values);
|
|
1669
|
+
}
|
|
1670
|
+
decodeParameters(types, values) {
|
|
1671
|
+
return decodeAbiParameters(parseAbiParameters2(types), asHex(values));
|
|
1672
|
+
}
|
|
1673
|
+
async #getChain() {
|
|
1674
|
+
if (this.#chain) return this.#chain;
|
|
1675
|
+
const chain = getChainById(BigInt(await this.#externalProvider.getChainId()));
|
|
1676
|
+
if (!chain) throw new Error("Invalid chainId");
|
|
1677
|
+
this.#chain = chain;
|
|
1678
|
+
return this.#chain;
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
var SafeProvider_default = SafeProvider;
|
|
1682
|
+
|
|
1683
|
+
// src/utils/memoized.ts
|
|
1684
|
+
function createMemoizedFunction(callback, cache = {}) {
|
|
1685
|
+
const replacer = createSafeContractSerializerReplacer();
|
|
1686
|
+
return (...args) => {
|
|
1687
|
+
const key = JSON.stringify(args, replacer);
|
|
1688
|
+
cache[key] = cache[key] || callback(...args);
|
|
1689
|
+
return cache[key];
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
function createSafeContractSerializerReplacer() {
|
|
1693
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1694
|
+
return (_, value) => {
|
|
1695
|
+
if (typeof value === "bigint") {
|
|
1696
|
+
return value.toString();
|
|
1697
|
+
}
|
|
1698
|
+
if (value instanceof SafeProvider_default && value !== null) {
|
|
1699
|
+
if (seen.has(value)) {
|
|
1700
|
+
return void 0;
|
|
1701
|
+
}
|
|
1702
|
+
seen.add(value);
|
|
1703
|
+
return {
|
|
1704
|
+
$safeProvider: {
|
|
1705
|
+
provider: typeof value.provider === "object" ? "EIP1193Provider" : value.provider,
|
|
1706
|
+
signer: value.signer
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
return value;
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
// src/contracts/utils.ts
|
|
1715
|
+
import semverSatisfies4 from "semver/functions/satisfies.js";
|
|
1716
|
+
var memoizedGetCompatibilityFallbackHandlerContract = createMemoizedFunction(
|
|
1717
|
+
getCompatibilityFallbackHandlerContract
|
|
1718
|
+
);
|
|
1719
|
+
var memoizedGetProxyFactoryContract = createMemoizedFunction(
|
|
1720
|
+
({
|
|
1721
|
+
safeProvider,
|
|
1722
|
+
safeVersion,
|
|
1723
|
+
customContracts,
|
|
1724
|
+
deploymentType
|
|
1725
|
+
}) => getSafeProxyFactoryContract({ safeProvider, safeVersion, customContracts, deploymentType })
|
|
1726
|
+
);
|
|
1727
|
+
var memoizedGetProxyCreationCode = createMemoizedFunction(
|
|
1728
|
+
async ({
|
|
1729
|
+
safeProvider,
|
|
1730
|
+
safeVersion,
|
|
1731
|
+
customContracts,
|
|
1732
|
+
chainId,
|
|
1733
|
+
deploymentType
|
|
1734
|
+
}) => {
|
|
1735
|
+
const safeProxyFactoryContract = await memoizedGetProxyFactoryContract({
|
|
1736
|
+
safeProvider,
|
|
1737
|
+
safeVersion,
|
|
1738
|
+
customContracts,
|
|
1739
|
+
chainId,
|
|
1740
|
+
deploymentType
|
|
1741
|
+
});
|
|
1742
|
+
return safeProxyFactoryContract.proxyCreationCode();
|
|
1743
|
+
}
|
|
1744
|
+
);
|
|
1745
|
+
var memoizedGetSafeContract = createMemoizedFunction(
|
|
1746
|
+
({
|
|
1747
|
+
safeProvider,
|
|
1748
|
+
safeVersion,
|
|
1749
|
+
isL1SafeSingleton,
|
|
1750
|
+
customContracts,
|
|
1751
|
+
deploymentType
|
|
1752
|
+
}) => getSafeContract({
|
|
1753
|
+
safeProvider,
|
|
1754
|
+
safeVersion,
|
|
1755
|
+
isL1SafeSingleton,
|
|
1756
|
+
customContracts,
|
|
1757
|
+
deploymentType
|
|
1758
|
+
})
|
|
1759
|
+
);
|
|
1760
|
+
function toTxResult(runner, hash, options) {
|
|
1761
|
+
return {
|
|
1762
|
+
hash,
|
|
1763
|
+
options,
|
|
1764
|
+
transactionResponse: {
|
|
1765
|
+
wait: async () => waitForTransactionReceipt(runner, { hash })
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
function isTypedDataSigner(signer) {
|
|
1770
|
+
const isPasskeySigner = !!signer?.passkeyRawId;
|
|
1771
|
+
return signer.signTypedData !== void 0 || !isPasskeySigner;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
// src/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1.ts
|
|
1775
|
+
import {
|
|
1776
|
+
createCall_1_4_1_ContractArtifacts
|
|
1777
|
+
} from "@safe-global/types-kit";
|
|
1778
|
+
|
|
1779
|
+
// src/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1.ts
|
|
1780
|
+
import {
|
|
1781
|
+
multisend_1_1_1_ContractArtifacts
|
|
1782
|
+
} from "@safe-global/types-kit";
|
|
1783
|
+
|
|
1784
|
+
// src/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0.ts
|
|
1785
|
+
import {
|
|
1786
|
+
multisend_1_3_0_ContractArtifacts
|
|
1787
|
+
} from "@safe-global/types-kit";
|
|
1788
|
+
|
|
1789
|
+
// src/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1.ts
|
|
1790
|
+
import {
|
|
1791
|
+
multisend_1_4_1_ContractArtifacts
|
|
1792
|
+
} from "@safe-global/types-kit";
|
|
1793
|
+
|
|
1794
|
+
// src/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0.ts
|
|
1795
|
+
import {
|
|
1796
|
+
multiSendCallOnly_1_3_0_ContractArtifacts
|
|
1797
|
+
} from "@safe-global/types-kit";
|
|
1798
|
+
|
|
1799
|
+
// src/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1.ts
|
|
1800
|
+
import {
|
|
1801
|
+
multiSendCallOnly_1_4_1_ContractArtifacts
|
|
1802
|
+
} from "@safe-global/types-kit";
|
|
1803
|
+
|
|
1804
|
+
// src/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0.ts
|
|
1805
|
+
import {
|
|
1806
|
+
signMessageLib_1_3_0_ContractArtifacts
|
|
1807
|
+
} from "@safe-global/types-kit";
|
|
1808
|
+
|
|
1809
|
+
// src/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1.ts
|
|
1810
|
+
import {
|
|
1811
|
+
signMessageLib_1_4_1_ContractArtifacts
|
|
1812
|
+
} from "@safe-global/types-kit";
|
|
1813
|
+
|
|
1814
|
+
// src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.ts
|
|
1815
|
+
import { simulateContract } from "viem/actions";
|
|
1816
|
+
|
|
1817
|
+
// src/contracts/Safe/SafeBaseContract.ts
|
|
1818
|
+
var SafeBaseContract = class extends BaseContract_default {
|
|
1819
|
+
/**
|
|
1820
|
+
* @constructor
|
|
1821
|
+
* Constructs an instance of SafeBaseContract.
|
|
1822
|
+
*
|
|
1823
|
+
* @param chainId - The chain ID of the contract.
|
|
1824
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
1825
|
+
* @param defaultAbi - The default ABI for the Safe contract. It should be compatible with the specific version of the Safe contract.
|
|
1826
|
+
* @param safeVersion - The version of the Safe contract.
|
|
1827
|
+
* @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
|
|
1828
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
1829
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used.
|
|
1830
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
1831
|
+
*/
|
|
1832
|
+
constructor(chainId, safeProvider, defaultAbi, safeVersion, isL1SafeSingleton = safeDeploymentsL1ChainIds.includes(chainId), customContractAddress, customContractAbi, deploymentType) {
|
|
1833
|
+
const isL1Contract = isL1SafeSingleton || !hasSafeFeature("SAFE_L2_CONTRACTS" /* SAFE_L2_CONTRACTS */, safeVersion);
|
|
1834
|
+
const contractName3 = isL1Contract ? "safeSingletonVersion" : "safeSingletonL2Version";
|
|
1835
|
+
super(
|
|
1836
|
+
contractName3,
|
|
1837
|
+
chainId,
|
|
1838
|
+
safeProvider,
|
|
1839
|
+
defaultAbi,
|
|
1840
|
+
safeVersion,
|
|
1841
|
+
customContractAddress,
|
|
1842
|
+
customContractAbi,
|
|
1843
|
+
deploymentType
|
|
1844
|
+
);
|
|
1845
|
+
this.contractName = contractName3;
|
|
1846
|
+
}
|
|
1847
|
+
};
|
|
1848
|
+
var SafeBaseContract_default = SafeBaseContract;
|
|
1849
|
+
|
|
1850
|
+
// src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.ts
|
|
1851
|
+
import {
|
|
1852
|
+
safe_1_0_0_ContractArtifacts
|
|
1853
|
+
} from "@safe-global/types-kit";
|
|
1854
|
+
var SafeContract_v1_0_0 = class extends SafeBaseContract_default {
|
|
1855
|
+
/**
|
|
1856
|
+
* Constructs an instance of SafeContract_v1_0_0
|
|
1857
|
+
*
|
|
1858
|
+
* @param chainId - The chain ID where the contract resides.
|
|
1859
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
1860
|
+
* @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
|
|
1861
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
1862
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.0.0 is used.
|
|
1863
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
1864
|
+
*/
|
|
1865
|
+
constructor(chainId, safeProvider, isL1SafeSingleton, customContractAddress, customContractAbi, deploymentType) {
|
|
1866
|
+
const safeVersion = "1.0.0";
|
|
1867
|
+
const defaultAbi = safe_1_0_0_ContractArtifacts.abi;
|
|
1868
|
+
super(
|
|
1869
|
+
chainId,
|
|
1870
|
+
safeProvider,
|
|
1871
|
+
defaultAbi,
|
|
1872
|
+
safeVersion,
|
|
1873
|
+
isL1SafeSingleton,
|
|
1874
|
+
customContractAddress,
|
|
1875
|
+
customContractAbi,
|
|
1876
|
+
deploymentType
|
|
1877
|
+
);
|
|
1878
|
+
/* ----- Specific v1.0.0 properties ----- */
|
|
1879
|
+
this.DOMAIN_SEPARATOR_TYPEHASH = async () => {
|
|
1880
|
+
return [await this.read("DOMAIN_SEPARATOR_TYPEHASH")];
|
|
1881
|
+
};
|
|
1882
|
+
this.SENTINEL_MODULES = async () => {
|
|
1883
|
+
return [await this.read("SENTINEL_MODULES")];
|
|
1884
|
+
};
|
|
1885
|
+
this.SENTINEL_OWNERS = async () => {
|
|
1886
|
+
return [await this.read("SENTINEL_OWNERS")];
|
|
1887
|
+
};
|
|
1888
|
+
this.SAFE_MSG_TYPEHASH = async () => {
|
|
1889
|
+
return [await this.read("SAFE_MSG_TYPEHASH")];
|
|
1890
|
+
};
|
|
1891
|
+
this.SAFE_TX_TYPEHASH = async () => {
|
|
1892
|
+
return [await this.read("SAFE_TX_TYPEHASH")];
|
|
1893
|
+
};
|
|
1894
|
+
/* ----- End of specific v1.0.0 properties ----- */
|
|
1895
|
+
/**
|
|
1896
|
+
* @returns Array[contractName]
|
|
1897
|
+
*/
|
|
1898
|
+
this.NAME = async () => {
|
|
1899
|
+
return [await this.read("NAME")];
|
|
1900
|
+
};
|
|
1901
|
+
/**
|
|
1902
|
+
* @returns Array[safeContractVersion]
|
|
1903
|
+
*/
|
|
1904
|
+
this.VERSION = async () => {
|
|
1905
|
+
return [await this.read("VERSION")];
|
|
1906
|
+
};
|
|
1907
|
+
/**
|
|
1908
|
+
* @param args - Array[owner, txHash]
|
|
1909
|
+
* @returns Array[approvedHashes]
|
|
1910
|
+
*/
|
|
1911
|
+
this.approvedHashes = async (args) => {
|
|
1912
|
+
return [await this.read("approvedHashes", args)];
|
|
1913
|
+
};
|
|
1914
|
+
/**
|
|
1915
|
+
* @returns Array[domainSeparator]
|
|
1916
|
+
*/
|
|
1917
|
+
this.domainSeparator = async () => {
|
|
1918
|
+
return [await this.read("domainSeparator")];
|
|
1919
|
+
};
|
|
1920
|
+
/**
|
|
1921
|
+
* Returns array of modules.
|
|
1922
|
+
* @returns Array[Array[modules]]
|
|
1923
|
+
*/
|
|
1924
|
+
this.getModules = async () => {
|
|
1925
|
+
return [await this.read("getModules")];
|
|
1926
|
+
};
|
|
1927
|
+
/**
|
|
1928
|
+
* Returns the list of Safe owner accounts.
|
|
1929
|
+
* @returns Array[Array[owners]]
|
|
1930
|
+
*/
|
|
1931
|
+
this.getOwners = async () => {
|
|
1932
|
+
return [await this.read("getOwners")];
|
|
1933
|
+
};
|
|
1934
|
+
/**
|
|
1935
|
+
* Returns the Safe threshold.
|
|
1936
|
+
* @returns Array[threshold]
|
|
1937
|
+
*/
|
|
1938
|
+
this.getThreshold = async () => {
|
|
1939
|
+
return [await this.read("getThreshold")];
|
|
1940
|
+
};
|
|
1941
|
+
/**
|
|
1942
|
+
* Checks if a specific address is an owner of the current Safe.
|
|
1943
|
+
* @param args - Array[address]
|
|
1944
|
+
* @returns Array[isOwner]
|
|
1945
|
+
*/
|
|
1946
|
+
this.isOwner = async (args) => {
|
|
1947
|
+
return [await this.read("isOwner", args)];
|
|
1948
|
+
};
|
|
1949
|
+
/**
|
|
1950
|
+
* Returns the Safe nonce.
|
|
1951
|
+
* @returns Array[nonce]
|
|
1952
|
+
*/
|
|
1953
|
+
this.nonce = async () => {
|
|
1954
|
+
return [await this.read("nonce")];
|
|
1955
|
+
};
|
|
1956
|
+
/**
|
|
1957
|
+
* @param args - Array[messageHash]
|
|
1958
|
+
* @returns Array[signedMessages]
|
|
1959
|
+
*/
|
|
1960
|
+
this.signedMessages = async (args) => {
|
|
1961
|
+
return [await this.read("signedMessages", args)];
|
|
1962
|
+
};
|
|
1963
|
+
/**
|
|
1964
|
+
* Returns hash of a message that can be signed by owners.
|
|
1965
|
+
* @param args - Array[message]
|
|
1966
|
+
* @returns Array[messageHash]
|
|
1967
|
+
*/
|
|
1968
|
+
this.getMessageHash = async (args) => {
|
|
1969
|
+
return [await this.read("getMessageHash", args)];
|
|
1970
|
+
};
|
|
1971
|
+
/**
|
|
1972
|
+
* Returns the bytes that are hashed to be signed by owners.
|
|
1973
|
+
* @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
|
|
1974
|
+
* @returns Array[encodedData]
|
|
1975
|
+
*/
|
|
1976
|
+
this.encodeTransactionData = async (args) => {
|
|
1977
|
+
return [await this.read("encodeTransactionData", args)];
|
|
1978
|
+
};
|
|
1979
|
+
/**
|
|
1980
|
+
* Returns hash to be signed by owners.
|
|
1981
|
+
* @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
|
|
1982
|
+
* @returns Array[transactionHash]
|
|
1983
|
+
*/
|
|
1984
|
+
this.getTransactionHash = async (args) => {
|
|
1985
|
+
return [await this.read("getTransactionHash", args)];
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Marks a hash as approved. This can be used to validate a hash that is used by a signature.
|
|
1990
|
+
* @param hash - The hash that should be marked as approved for signatures that are verified by this contract.
|
|
1991
|
+
* @param options - Optional transaction options.
|
|
1992
|
+
* @returns Transaction result.
|
|
1993
|
+
*/
|
|
1994
|
+
async approveHash(hash, options) {
|
|
1995
|
+
const gasLimit = options?.gasLimit || await this.estimateGas("approveHash", [asHash(hash)], options);
|
|
1996
|
+
return toTxResult(
|
|
1997
|
+
this.runner,
|
|
1998
|
+
await this.write("approveHash", [asHash(hash)], { ...options, gasLimit }),
|
|
1999
|
+
options
|
|
2000
|
+
);
|
|
2001
|
+
}
|
|
2002
|
+
/**
|
|
2003
|
+
* Executes a transaction.
|
|
2004
|
+
* @param safeTransaction - The Safe transaction to execute.
|
|
2005
|
+
* @param options - Transaction options.
|
|
2006
|
+
* @returns Transaction result.
|
|
2007
|
+
*/
|
|
2008
|
+
async execTransaction(safeTransaction, options) {
|
|
2009
|
+
const gasLimit = options?.gasLimit || await this.estimateGas(
|
|
2010
|
+
"execTransaction",
|
|
2011
|
+
[
|
|
2012
|
+
safeTransaction.data.to,
|
|
2013
|
+
BigInt(safeTransaction.data.value),
|
|
2014
|
+
asHex(safeTransaction.data.data),
|
|
2015
|
+
safeTransaction.data.operation,
|
|
2016
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2017
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2018
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2019
|
+
safeTransaction.data.gasToken,
|
|
2020
|
+
safeTransaction.data.refundReceiver,
|
|
2021
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2022
|
+
],
|
|
2023
|
+
options
|
|
2024
|
+
);
|
|
2025
|
+
const args = [
|
|
2026
|
+
safeTransaction.data.to,
|
|
2027
|
+
BigInt(safeTransaction.data.value),
|
|
2028
|
+
asHex(safeTransaction.data.data),
|
|
2029
|
+
safeTransaction.data.operation,
|
|
2030
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2031
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2032
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2033
|
+
safeTransaction.data.gasToken,
|
|
2034
|
+
safeTransaction.data.refundReceiver,
|
|
2035
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2036
|
+
];
|
|
2037
|
+
return toTxResult(
|
|
2038
|
+
this.runner,
|
|
2039
|
+
await this.write("execTransaction", args, { ...options, gasLimit }),
|
|
2040
|
+
options
|
|
2041
|
+
);
|
|
2042
|
+
}
|
|
2043
|
+
async getModulesPaginated([start, pageSize]) {
|
|
2044
|
+
if (pageSize <= 0) throw new Error("Invalid page size for fetching paginated modules");
|
|
2045
|
+
const size = Number(pageSize);
|
|
2046
|
+
const [array] = await this.getModules();
|
|
2047
|
+
if (isSentinelAddress(start)) {
|
|
2048
|
+
const next = pageSize < array.length ? array[size] : SENTINEL_ADDRESS;
|
|
2049
|
+
return [array.slice(0, size), next];
|
|
2050
|
+
} else {
|
|
2051
|
+
const moduleIndex = array.findIndex((module) => sameString(module, start));
|
|
2052
|
+
if (moduleIndex === -1) {
|
|
2053
|
+
return [[], SENTINEL_ADDRESS];
|
|
2054
|
+
}
|
|
2055
|
+
const nextElementIndex = moduleIndex + 1;
|
|
2056
|
+
const nextPageAddress = nextElementIndex + size < array.length ? array[nextElementIndex + size] : SENTINEL_ADDRESS;
|
|
2057
|
+
return [array.slice(moduleIndex + 1, nextElementIndex + size), nextPageAddress];
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Checks if a specific Safe module is enabled for the current Safe.
|
|
2062
|
+
* @param moduleAddress - The module address to check.
|
|
2063
|
+
* @returns True, if the module with the given address is enabled.
|
|
2064
|
+
*/
|
|
2065
|
+
async isModuleEnabled([moduleAddress]) {
|
|
2066
|
+
const [modules] = await this.getModules();
|
|
2067
|
+
const isModuleEnabled = modules.some(
|
|
2068
|
+
(enabledModuleAddress) => sameString(enabledModuleAddress, moduleAddress)
|
|
2069
|
+
);
|
|
2070
|
+
return [isModuleEnabled];
|
|
2071
|
+
}
|
|
2072
|
+
/**
|
|
2073
|
+
* Checks whether a given Safe transaction can be executed successfully with no errors.
|
|
2074
|
+
* @param safeTransaction - The Safe transaction to check.
|
|
2075
|
+
* @param options - Optional transaction options.
|
|
2076
|
+
* @returns True, if the given transactions is valid.
|
|
2077
|
+
*/
|
|
2078
|
+
async isValidTransaction(safeTransaction, options = {}) {
|
|
2079
|
+
try {
|
|
2080
|
+
const gasLimit = options?.gasLimit || await this.estimateGas(
|
|
2081
|
+
"execTransaction",
|
|
2082
|
+
[
|
|
2083
|
+
safeTransaction.data.to,
|
|
2084
|
+
BigInt(safeTransaction.data.value),
|
|
2085
|
+
asHex(safeTransaction.data.data),
|
|
2086
|
+
safeTransaction.data.operation,
|
|
2087
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2088
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2089
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2090
|
+
safeTransaction.data.gasToken,
|
|
2091
|
+
safeTransaction.data.refundReceiver,
|
|
2092
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2093
|
+
],
|
|
2094
|
+
options
|
|
2095
|
+
);
|
|
2096
|
+
const converted = this.convertOptions({ ...options, gasLimit });
|
|
2097
|
+
const txResult = await simulateContract(this.runner, {
|
|
2098
|
+
address: this.contractAddress,
|
|
2099
|
+
functionName: "execTransaction",
|
|
2100
|
+
abi: this.contractAbi,
|
|
2101
|
+
args: [
|
|
2102
|
+
safeTransaction.data.to,
|
|
2103
|
+
BigInt(safeTransaction.data.value),
|
|
2104
|
+
asHex(safeTransaction.data.data),
|
|
2105
|
+
safeTransaction.data.operation,
|
|
2106
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2107
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2108
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2109
|
+
safeTransaction.data.gasToken,
|
|
2110
|
+
safeTransaction.data.refundReceiver,
|
|
2111
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2112
|
+
],
|
|
2113
|
+
...converted
|
|
2114
|
+
});
|
|
2115
|
+
return txResult.result;
|
|
2116
|
+
} catch (error) {
|
|
2117
|
+
return false;
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
/**
|
|
2121
|
+
* returns the nonce of the Safe contract.
|
|
2122
|
+
*
|
|
2123
|
+
* @returns {Promise<bigint>} A promise that resolves to the nonce of the Safe contract.
|
|
2124
|
+
*/
|
|
2125
|
+
async getNonce() {
|
|
2126
|
+
const [nonce] = await this.nonce();
|
|
2127
|
+
return nonce;
|
|
2128
|
+
}
|
|
2129
|
+
};
|
|
2130
|
+
var SafeContract_v1_0_0_default = SafeContract_v1_0_0;
|
|
2131
|
+
|
|
2132
|
+
// src/contracts/Safe/v1.1.1/SafeContract_v1_1_1.ts
|
|
2133
|
+
import { simulateContract as simulateContract2 } from "viem/actions";
|
|
2134
|
+
import {
|
|
2135
|
+
safe_1_1_1_ContractArtifacts
|
|
2136
|
+
} from "@safe-global/types-kit";
|
|
2137
|
+
var SafeContract_v1_1_1 = class extends SafeBaseContract_default {
|
|
2138
|
+
/**
|
|
2139
|
+
* Constructs an instance of SafeContract_v1_1_1
|
|
2140
|
+
*
|
|
2141
|
+
* @param chainId - The chain ID where the contract resides.
|
|
2142
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
2143
|
+
* @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
|
|
2144
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
2145
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.1.1 is used.
|
|
2146
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
2147
|
+
*/
|
|
2148
|
+
constructor(chainId, safeProvider, isL1SafeSingleton, customContractAddress, customContractAbi, deploymentType) {
|
|
2149
|
+
const safeVersion = "1.1.1";
|
|
2150
|
+
const defaultAbi = safe_1_1_1_ContractArtifacts.abi;
|
|
2151
|
+
super(
|
|
2152
|
+
chainId,
|
|
2153
|
+
safeProvider,
|
|
2154
|
+
defaultAbi,
|
|
2155
|
+
safeVersion,
|
|
2156
|
+
isL1SafeSingleton,
|
|
2157
|
+
customContractAddress,
|
|
2158
|
+
customContractAbi,
|
|
2159
|
+
deploymentType
|
|
2160
|
+
);
|
|
2161
|
+
/**
|
|
2162
|
+
* @returns Array[contractName]
|
|
2163
|
+
*/
|
|
2164
|
+
this.NAME = async () => {
|
|
2165
|
+
return [await this.read("NAME")];
|
|
2166
|
+
};
|
|
2167
|
+
/**
|
|
2168
|
+
* @returns Array[safeContractVersion]
|
|
2169
|
+
*/
|
|
2170
|
+
this.VERSION = async () => {
|
|
2171
|
+
return [await this.read("VERSION")];
|
|
2172
|
+
};
|
|
2173
|
+
/**
|
|
2174
|
+
* @param args - Array[owner, txHash]
|
|
2175
|
+
* @returns Array[approvedHashes]
|
|
2176
|
+
*/
|
|
2177
|
+
this.approvedHashes = async (args) => {
|
|
2178
|
+
return [await this.read("approvedHashes", args)];
|
|
2179
|
+
};
|
|
2180
|
+
/**
|
|
2181
|
+
* @returns Array[domainSeparator]
|
|
2182
|
+
*/
|
|
2183
|
+
this.domainSeparator = async () => {
|
|
2184
|
+
return [await this.read("domainSeparator")];
|
|
2185
|
+
};
|
|
2186
|
+
/**
|
|
2187
|
+
* Returns array of first 10 modules.
|
|
2188
|
+
* @returns Array[Array[modules]]
|
|
2189
|
+
*/
|
|
2190
|
+
this.getModules = async () => {
|
|
2191
|
+
return [await this.read("getModules")];
|
|
2192
|
+
};
|
|
2193
|
+
/**
|
|
2194
|
+
* Returns array of modules.
|
|
2195
|
+
* @param args - Array[start, pageSize]
|
|
2196
|
+
* @returns Array[Array[modules], next]
|
|
2197
|
+
*/
|
|
2198
|
+
this.getModulesPaginated = async (args) => {
|
|
2199
|
+
const [array, next] = await this.read("getModulesPaginated", args);
|
|
2200
|
+
return [array, next];
|
|
2201
|
+
};
|
|
2202
|
+
/**
|
|
2203
|
+
* Returns the list of Safe owner accounts.
|
|
2204
|
+
* @returns Array[Array[owners]]
|
|
2205
|
+
*/
|
|
2206
|
+
this.getOwners = async () => {
|
|
2207
|
+
return [await this.read("getOwners")];
|
|
2208
|
+
};
|
|
2209
|
+
/**
|
|
2210
|
+
* Returns the Safe threshold.
|
|
2211
|
+
* @returns Array[threshold]
|
|
2212
|
+
*/
|
|
2213
|
+
this.getThreshold = async () => {
|
|
2214
|
+
return [await this.read("getThreshold")];
|
|
2215
|
+
};
|
|
2216
|
+
/**
|
|
2217
|
+
* Checks if a specific address is an owner of the current Safe.
|
|
2218
|
+
* @param args - Array[address]
|
|
2219
|
+
* @returns Array[isOwner]
|
|
2220
|
+
*/
|
|
2221
|
+
this.isOwner = async (args) => {
|
|
2222
|
+
return [await this.read("isOwner", args)];
|
|
2223
|
+
};
|
|
2224
|
+
/**
|
|
2225
|
+
* Returns the Safe nonce.
|
|
2226
|
+
* @returns Array[nonce]
|
|
2227
|
+
*/
|
|
2228
|
+
this.nonce = async () => {
|
|
2229
|
+
return [await this.read("nonce")];
|
|
2230
|
+
};
|
|
2231
|
+
/**
|
|
2232
|
+
* @param args - Array[messageHash]
|
|
2233
|
+
* @returns Array[signedMessages]
|
|
2234
|
+
*/
|
|
2235
|
+
this.signedMessages = async (args) => {
|
|
2236
|
+
return [await this.read("signedMessages", args)];
|
|
2237
|
+
};
|
|
2238
|
+
/**
|
|
2239
|
+
* Returns hash of a message that can be signed by owners.
|
|
2240
|
+
* @param args - Array[message]
|
|
2241
|
+
* @returns Array[messageHash]
|
|
2242
|
+
*/
|
|
2243
|
+
this.getMessageHash = async (args) => {
|
|
2244
|
+
return [await this.read("getMessageHash", args)];
|
|
2245
|
+
};
|
|
2246
|
+
/**
|
|
2247
|
+
* Returns the bytes that are hashed to be signed by owners.
|
|
2248
|
+
* @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
|
|
2249
|
+
* @returns Array[encodedData]
|
|
2250
|
+
*/
|
|
2251
|
+
this.encodeTransactionData = async (args) => {
|
|
2252
|
+
return [await this.read("encodeTransactionData", args)];
|
|
2253
|
+
};
|
|
2254
|
+
/**
|
|
2255
|
+
* Returns hash to be signed by owners.
|
|
2256
|
+
* @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
|
|
2257
|
+
* @returns Array[transactionHash]
|
|
2258
|
+
*/
|
|
2259
|
+
this.getTransactionHash = async (args) => {
|
|
2260
|
+
return [await this.read("getTransactionHash", args)];
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
/**
|
|
2264
|
+
* Marks a hash as approved. This can be used to validate a hash that is used by a signature.
|
|
2265
|
+
* @param hash - The hash that should be marked as approved for signatures that are verified by this contract.
|
|
2266
|
+
* @param options - Optional transaction options.
|
|
2267
|
+
* @returns Transaction result.
|
|
2268
|
+
*/
|
|
2269
|
+
async approveHash(hash, options) {
|
|
2270
|
+
const gasLimit = options?.gasLimit || await this.estimateGas("approveHash", [asHash(hash)], options);
|
|
2271
|
+
return toTxResult(
|
|
2272
|
+
this.runner,
|
|
2273
|
+
await this.write("approveHash", [asHash(hash)], { ...options, gasLimit }),
|
|
2274
|
+
options
|
|
2275
|
+
);
|
|
2276
|
+
}
|
|
2277
|
+
/**
|
|
2278
|
+
* Executes a transaction.
|
|
2279
|
+
* @param safeTransaction - The Safe transaction to execute.
|
|
2280
|
+
* @param options - Transaction options.
|
|
2281
|
+
* @returns Transaction result.
|
|
2282
|
+
*/
|
|
2283
|
+
async execTransaction(safeTransaction, options) {
|
|
2284
|
+
const gasLimit = options?.gasLimit || await this.estimateGas(
|
|
2285
|
+
"execTransaction",
|
|
2286
|
+
[
|
|
2287
|
+
safeTransaction.data.to,
|
|
2288
|
+
BigInt(safeTransaction.data.value),
|
|
2289
|
+
asHex(safeTransaction.data.data),
|
|
2290
|
+
safeTransaction.data.operation,
|
|
2291
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2292
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2293
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2294
|
+
safeTransaction.data.gasToken,
|
|
2295
|
+
safeTransaction.data.refundReceiver,
|
|
2296
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2297
|
+
],
|
|
2298
|
+
options
|
|
2299
|
+
);
|
|
2300
|
+
const args = [
|
|
2301
|
+
safeTransaction.data.to,
|
|
2302
|
+
BigInt(safeTransaction.data.value),
|
|
2303
|
+
asHex(safeTransaction.data.data),
|
|
2304
|
+
safeTransaction.data.operation,
|
|
2305
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2306
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2307
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2308
|
+
safeTransaction.data.gasToken,
|
|
2309
|
+
safeTransaction.data.refundReceiver,
|
|
2310
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2311
|
+
];
|
|
2312
|
+
return toTxResult(
|
|
2313
|
+
this.runner,
|
|
2314
|
+
await this.write("execTransaction", args, { ...options, gasLimit }),
|
|
2315
|
+
options
|
|
2316
|
+
);
|
|
2317
|
+
}
|
|
2318
|
+
/**
|
|
2319
|
+
* Checks if a specific Safe module is enabled for the current Safe.
|
|
2320
|
+
* @param moduleAddress - The module address to check.
|
|
2321
|
+
* @returns True, if the module with the given address is enabled.
|
|
2322
|
+
*/
|
|
2323
|
+
async isModuleEnabled([moduleAddress]) {
|
|
2324
|
+
const [modules] = await this.getModules();
|
|
2325
|
+
const isModuleEnabled = modules.some(
|
|
2326
|
+
(enabledModuleAddress) => sameString(enabledModuleAddress, moduleAddress)
|
|
2327
|
+
);
|
|
2328
|
+
return [isModuleEnabled];
|
|
2329
|
+
}
|
|
2330
|
+
/**
|
|
2331
|
+
* Checks whether a given Safe transaction can be executed successfully with no errors.
|
|
2332
|
+
* @param safeTransaction - The Safe transaction to check.
|
|
2333
|
+
* @param options - Optional transaction options.
|
|
2334
|
+
* @returns True, if the given transactions is valid.
|
|
2335
|
+
*/
|
|
2336
|
+
async isValidTransaction(safeTransaction, options = {}) {
|
|
2337
|
+
try {
|
|
2338
|
+
const gasLimit = options?.gasLimit || await this.estimateGas(
|
|
2339
|
+
"execTransaction",
|
|
2340
|
+
[
|
|
2341
|
+
safeTransaction.data.to,
|
|
2342
|
+
BigInt(safeTransaction.data.value),
|
|
2343
|
+
asHex(safeTransaction.data.data),
|
|
2344
|
+
safeTransaction.data.operation,
|
|
2345
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2346
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2347
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2348
|
+
safeTransaction.data.gasToken,
|
|
2349
|
+
safeTransaction.data.refundReceiver,
|
|
2350
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2351
|
+
],
|
|
2352
|
+
options
|
|
2353
|
+
);
|
|
2354
|
+
const converted = this.convertOptions({ ...options, gasLimit });
|
|
2355
|
+
const txResult = await simulateContract2(this.runner, {
|
|
2356
|
+
address: this.contractAddress,
|
|
2357
|
+
functionName: "execTransaction",
|
|
2358
|
+
abi: this.contractAbi,
|
|
2359
|
+
args: [
|
|
2360
|
+
safeTransaction.data.to,
|
|
2361
|
+
BigInt(safeTransaction.data.value),
|
|
2362
|
+
asHex(safeTransaction.data.data),
|
|
2363
|
+
safeTransaction.data.operation,
|
|
2364
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2365
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2366
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2367
|
+
safeTransaction.data.gasToken,
|
|
2368
|
+
safeTransaction.data.refundReceiver,
|
|
2369
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2370
|
+
],
|
|
2371
|
+
...converted
|
|
2372
|
+
});
|
|
2373
|
+
return txResult.result;
|
|
2374
|
+
} catch (error) {
|
|
2375
|
+
return false;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
/**
|
|
2379
|
+
* returns the nonce of the Safe contract.
|
|
2380
|
+
*
|
|
2381
|
+
* @returns {Promise<bigint>} A promise that resolves to the nonce of the Safe contract.
|
|
2382
|
+
*/
|
|
2383
|
+
async getNonce() {
|
|
2384
|
+
const [nonce] = await this.nonce();
|
|
2385
|
+
return nonce;
|
|
2386
|
+
}
|
|
2387
|
+
};
|
|
2388
|
+
var SafeContract_v1_1_1_default = SafeContract_v1_1_1;
|
|
2389
|
+
|
|
2390
|
+
// src/contracts/Safe/v1.2.0/SafeContract_v1_2_0.ts
|
|
2391
|
+
import { simulateContract as simulateContract3 } from "viem/actions";
|
|
2392
|
+
import {
|
|
2393
|
+
safe_1_2_0_ContractArtifacts
|
|
2394
|
+
} from "@safe-global/types-kit";
|
|
2395
|
+
var SafeContract_v1_2_0 = class extends SafeBaseContract_default {
|
|
2396
|
+
/**
|
|
2397
|
+
* Constructs an instance of SafeContract_v1_2_0
|
|
2398
|
+
*
|
|
2399
|
+
* @param chainId - The chain ID where the contract resides.
|
|
2400
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
2401
|
+
* @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
|
|
2402
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
2403
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.2.0 is used.
|
|
2404
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
2405
|
+
*/
|
|
2406
|
+
constructor(chainId, safeProvider, isL1SafeSingleton, customContractAddress, customContractAbi, deploymentType) {
|
|
2407
|
+
const safeVersion = "1.2.0";
|
|
2408
|
+
const defaultAbi = safe_1_2_0_ContractArtifacts.abi;
|
|
2409
|
+
super(
|
|
2410
|
+
chainId,
|
|
2411
|
+
safeProvider,
|
|
2412
|
+
defaultAbi,
|
|
2413
|
+
safeVersion,
|
|
2414
|
+
isL1SafeSingleton,
|
|
2415
|
+
customContractAddress,
|
|
2416
|
+
customContractAbi,
|
|
2417
|
+
deploymentType
|
|
2418
|
+
);
|
|
2419
|
+
/**
|
|
2420
|
+
* @returns Array[contractName]
|
|
2421
|
+
*/
|
|
2422
|
+
this.NAME = async () => {
|
|
2423
|
+
return [await this.read("NAME")];
|
|
2424
|
+
};
|
|
2425
|
+
/**
|
|
2426
|
+
* @returns Array[safeContractVersion]
|
|
2427
|
+
*/
|
|
2428
|
+
this.VERSION = async () => {
|
|
2429
|
+
return [await this.read("VERSION")];
|
|
2430
|
+
};
|
|
2431
|
+
/**
|
|
2432
|
+
* @param args - Array[owner, txHash]
|
|
2433
|
+
* @returns Array[approvedHashes]
|
|
2434
|
+
*/
|
|
2435
|
+
this.approvedHashes = async (args) => {
|
|
2436
|
+
return [await this.read("approvedHashes", args)];
|
|
2437
|
+
};
|
|
2438
|
+
/**
|
|
2439
|
+
* @returns Array[domainSeparator]
|
|
2440
|
+
*/
|
|
2441
|
+
this.domainSeparator = async () => {
|
|
2442
|
+
return [await this.read("domainSeparator")];
|
|
2443
|
+
};
|
|
2444
|
+
/**
|
|
2445
|
+
* Returns array of first 10 modules.
|
|
2446
|
+
* @returns Array[Array[modules]]
|
|
2447
|
+
*/
|
|
2448
|
+
this.getModules = async () => {
|
|
2449
|
+
return [await this.read("getModules")];
|
|
2450
|
+
};
|
|
2451
|
+
/**
|
|
2452
|
+
* Returns array of modules.
|
|
2453
|
+
* @param args - Array[start, pageSize]
|
|
2454
|
+
* @returns Array[Array[modules], next]
|
|
2455
|
+
*/
|
|
2456
|
+
this.getModulesPaginated = async (args) => {
|
|
2457
|
+
const [array, next] = await this.read("getModulesPaginated", args);
|
|
2458
|
+
return [array, next];
|
|
2459
|
+
};
|
|
2460
|
+
/**
|
|
2461
|
+
* Returns the list of Safe owner accounts.
|
|
2462
|
+
* @returns Array[Array[owners]]
|
|
2463
|
+
*/
|
|
2464
|
+
this.getOwners = async () => {
|
|
2465
|
+
return [await this.read("getOwners")];
|
|
2466
|
+
};
|
|
2467
|
+
/**
|
|
2468
|
+
* Returns the Safe threshold.
|
|
2469
|
+
* @returns Array[threshold]
|
|
2470
|
+
*/
|
|
2471
|
+
this.getThreshold = async () => {
|
|
2472
|
+
return [await this.read("getThreshold")];
|
|
2473
|
+
};
|
|
2474
|
+
/**
|
|
2475
|
+
* Checks if a specific Safe module is enabled for the current Safe.
|
|
2476
|
+
* @param args - Array[moduleAddress]
|
|
2477
|
+
* @returns Array[isEnabled]
|
|
2478
|
+
*/
|
|
2479
|
+
this.isModuleEnabled = async (args) => {
|
|
2480
|
+
return [await this.read("isModuleEnabled", args)];
|
|
2481
|
+
};
|
|
2482
|
+
/**
|
|
2483
|
+
* Checks if a specific address is an owner of the current Safe.
|
|
2484
|
+
* @param args - Array[address]
|
|
2485
|
+
* @returns Array[isOwner]
|
|
2486
|
+
*/
|
|
2487
|
+
this.isOwner = async (args) => {
|
|
2488
|
+
return [await this.read("isOwner", args)];
|
|
2489
|
+
};
|
|
2490
|
+
/**
|
|
2491
|
+
* Returns the Safe nonce.
|
|
2492
|
+
* @returns Array[nonce]
|
|
2493
|
+
*/
|
|
2494
|
+
this.nonce = async () => {
|
|
2495
|
+
return [await this.read("nonce")];
|
|
2496
|
+
};
|
|
2497
|
+
/**
|
|
2498
|
+
* @param args - Array[messageHash]
|
|
2499
|
+
* @returns Array[signedMessages]
|
|
2500
|
+
*/
|
|
2501
|
+
this.signedMessages = async (args) => {
|
|
2502
|
+
return [await this.read("signedMessages", args)];
|
|
2503
|
+
};
|
|
2504
|
+
/**
|
|
2505
|
+
* @param args - Array[message]
|
|
2506
|
+
* @returns Array[messageHash]
|
|
2507
|
+
*/
|
|
2508
|
+
this.getMessageHash = async (args) => {
|
|
2509
|
+
return [await this.read("getMessageHash", args)];
|
|
2510
|
+
};
|
|
2511
|
+
/**
|
|
2512
|
+
* Encodes the data for a transaction to the Safe contract.
|
|
2513
|
+
*
|
|
2514
|
+
* @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
|
|
2515
|
+
* @returns Array[encodedData]
|
|
2516
|
+
*/
|
|
2517
|
+
this.encodeTransactionData = async (args) => {
|
|
2518
|
+
return [await this.read("encodeTransactionData", args)];
|
|
2519
|
+
};
|
|
2520
|
+
/**
|
|
2521
|
+
* Returns hash to be signed by owners.
|
|
2522
|
+
*
|
|
2523
|
+
* @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
|
|
2524
|
+
* @returns Array[transactionHash]
|
|
2525
|
+
*/
|
|
2526
|
+
this.getTransactionHash = async (args) => {
|
|
2527
|
+
return [await this.read("getTransactionHash", args)];
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2530
|
+
/**
|
|
2531
|
+
* Marks a hash as approved. This can be used to validate a hash that is used by a signature.
|
|
2532
|
+
* @param hash - The hash that should be marked as approved for signatures that are verified by this contract.
|
|
2533
|
+
* @param options - Optional transaction options.
|
|
2534
|
+
* @returns Transaction result.
|
|
2535
|
+
*/
|
|
2536
|
+
async approveHash(hash, options) {
|
|
2537
|
+
const gasLimit = options?.gasLimit || await this.estimateGas("approveHash", [asHash(hash)], options);
|
|
2538
|
+
return toTxResult(
|
|
2539
|
+
this.runner,
|
|
2540
|
+
await this.write("approveHash", [asHash(hash)], { ...options, gasLimit }),
|
|
2541
|
+
options
|
|
2542
|
+
);
|
|
2543
|
+
}
|
|
2544
|
+
/**
|
|
2545
|
+
* Executes a transaction.
|
|
2546
|
+
* @param safeTransaction - The Safe transaction to execute.
|
|
2547
|
+
* @param options - Transaction options.
|
|
2548
|
+
* @returns Transaction result.
|
|
2549
|
+
*/
|
|
2550
|
+
async execTransaction(safeTransaction, options) {
|
|
2551
|
+
const gasLimit = options?.gasLimit || await this.estimateGas(
|
|
2552
|
+
"execTransaction",
|
|
2553
|
+
[
|
|
2554
|
+
safeTransaction.data.to,
|
|
2555
|
+
BigInt(safeTransaction.data.value),
|
|
2556
|
+
asHex(safeTransaction.data.data),
|
|
2557
|
+
safeTransaction.data.operation,
|
|
2558
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2559
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2560
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2561
|
+
safeTransaction.data.gasToken,
|
|
2562
|
+
safeTransaction.data.refundReceiver,
|
|
2563
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2564
|
+
],
|
|
2565
|
+
options
|
|
2566
|
+
);
|
|
2567
|
+
const args = [
|
|
2568
|
+
safeTransaction.data.to,
|
|
2569
|
+
BigInt(safeTransaction.data.value),
|
|
2570
|
+
asHex(safeTransaction.data.data),
|
|
2571
|
+
safeTransaction.data.operation,
|
|
2572
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2573
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2574
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2575
|
+
safeTransaction.data.gasToken,
|
|
2576
|
+
safeTransaction.data.refundReceiver,
|
|
2577
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2578
|
+
];
|
|
2579
|
+
return toTxResult(
|
|
2580
|
+
this.runner,
|
|
2581
|
+
await this.write("execTransaction", args, { ...options, gasLimit }),
|
|
2582
|
+
options
|
|
2583
|
+
);
|
|
2584
|
+
}
|
|
2585
|
+
/**
|
|
2586
|
+
* Returns the chain id of the Safe contract. (Custom method - not defined in the Safe Contract)
|
|
2587
|
+
* @returns Array[chainId]
|
|
2588
|
+
*/
|
|
2589
|
+
async getChainId() {
|
|
2590
|
+
return [await Promise.resolve(this.chainId)];
|
|
2591
|
+
}
|
|
2592
|
+
/**
|
|
2593
|
+
* Checks whether a given Safe transaction can be executed successfully with no errors.
|
|
2594
|
+
* @param safeTransaction - The Safe transaction to check.
|
|
2595
|
+
* @param options - Optional transaction options.
|
|
2596
|
+
* @returns True, if the given transactions is valid.
|
|
2597
|
+
*/
|
|
2598
|
+
async isValidTransaction(safeTransaction, options = {}) {
|
|
2599
|
+
try {
|
|
2600
|
+
const gasLimit = options?.gasLimit || await this.estimateGas(
|
|
2601
|
+
"execTransaction",
|
|
2602
|
+
[
|
|
2603
|
+
safeTransaction.data.to,
|
|
2604
|
+
BigInt(safeTransaction.data.value),
|
|
2605
|
+
asHex(safeTransaction.data.data),
|
|
2606
|
+
safeTransaction.data.operation,
|
|
2607
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2608
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2609
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2610
|
+
safeTransaction.data.gasToken,
|
|
2611
|
+
safeTransaction.data.refundReceiver,
|
|
2612
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2613
|
+
],
|
|
2614
|
+
options
|
|
2615
|
+
);
|
|
2616
|
+
const converted = this.convertOptions({ ...options, gasLimit });
|
|
2617
|
+
const txResult = await simulateContract3(this.runner, {
|
|
2618
|
+
address: this.contractAddress,
|
|
2619
|
+
functionName: "execTransaction",
|
|
2620
|
+
abi: this.contractAbi,
|
|
2621
|
+
args: [
|
|
2622
|
+
safeTransaction.data.to,
|
|
2623
|
+
BigInt(safeTransaction.data.value),
|
|
2624
|
+
asHex(safeTransaction.data.data),
|
|
2625
|
+
safeTransaction.data.operation,
|
|
2626
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2627
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2628
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2629
|
+
safeTransaction.data.gasToken,
|
|
2630
|
+
safeTransaction.data.refundReceiver,
|
|
2631
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2632
|
+
],
|
|
2633
|
+
...converted
|
|
2634
|
+
});
|
|
2635
|
+
return txResult.result;
|
|
2636
|
+
} catch (error) {
|
|
2637
|
+
return false;
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
/**
|
|
2641
|
+
* returns the nonce of the Safe contract.
|
|
2642
|
+
*
|
|
2643
|
+
* @returns {Promise<bigint>} A promise that resolves to the nonce of the Safe contract.
|
|
2644
|
+
*/
|
|
2645
|
+
async getNonce() {
|
|
2646
|
+
const [nonce] = await this.nonce();
|
|
2647
|
+
return nonce;
|
|
2648
|
+
}
|
|
2649
|
+
};
|
|
2650
|
+
var SafeContract_v1_2_0_default = SafeContract_v1_2_0;
|
|
2651
|
+
|
|
2652
|
+
// src/contracts/Safe/v1.3.0/SafeContract_v1_3_0.ts
|
|
2653
|
+
import { simulateContract as simulateContract4 } from "viem/actions";
|
|
2654
|
+
import {
|
|
2655
|
+
safe_1_3_0_ContractArtifacts
|
|
2656
|
+
} from "@safe-global/types-kit";
|
|
2657
|
+
var SafeContract_v1_3_0 = class extends SafeBaseContract_default {
|
|
2658
|
+
/**
|
|
2659
|
+
* Constructs an instance of SafeContract_v1_3_0
|
|
2660
|
+
*
|
|
2661
|
+
* @param chainId - The chain ID where the contract resides.
|
|
2662
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
2663
|
+
* @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
|
|
2664
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
2665
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.3.0 is used.
|
|
2666
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
2667
|
+
*/
|
|
2668
|
+
constructor(chainId, safeProvider, isL1SafeSingleton, customContractAddress, customContractAbi, deploymentType) {
|
|
2669
|
+
const safeVersion = "1.3.0";
|
|
2670
|
+
const defaultAbi = safe_1_3_0_ContractArtifacts.abi;
|
|
2671
|
+
super(
|
|
2672
|
+
chainId,
|
|
2673
|
+
safeProvider,
|
|
2674
|
+
defaultAbi,
|
|
2675
|
+
safeVersion,
|
|
2676
|
+
isL1SafeSingleton,
|
|
2677
|
+
customContractAddress,
|
|
2678
|
+
customContractAbi,
|
|
2679
|
+
deploymentType
|
|
2680
|
+
);
|
|
2681
|
+
/**
|
|
2682
|
+
* @returns Array[safeContractVersion]
|
|
2683
|
+
*/
|
|
2684
|
+
this.VERSION = async () => {
|
|
2685
|
+
return [await this.read("VERSION")];
|
|
2686
|
+
};
|
|
2687
|
+
/**
|
|
2688
|
+
* @param args - Array[owner, txHash]
|
|
2689
|
+
* @returns Array[approvedHashes]
|
|
2690
|
+
*/
|
|
2691
|
+
this.approvedHashes = async (args) => {
|
|
2692
|
+
return [await this.read("approvedHashes", args)];
|
|
2693
|
+
};
|
|
2694
|
+
/**
|
|
2695
|
+
* Checks whether the signature provided is valid for the provided data, hash and number of required signatures.
|
|
2696
|
+
* Will revert otherwise.
|
|
2697
|
+
* @param args - Array[dataHash, data, signatures, requiredSignatures]
|
|
2698
|
+
* @returns Empty array
|
|
2699
|
+
*/
|
|
2700
|
+
this.checkNSignatures = async (args) => {
|
|
2701
|
+
await this.read("checkNSignatures", args);
|
|
2702
|
+
return [];
|
|
2703
|
+
};
|
|
2704
|
+
/**
|
|
2705
|
+
* Checks whether the signature provided is valid for the provided data and hash. Will revert otherwise.
|
|
2706
|
+
* @param args - Array[dataHash, data, signatures]
|
|
2707
|
+
* @returns Empty array
|
|
2708
|
+
*/
|
|
2709
|
+
this.checkSignatures = async (args) => {
|
|
2710
|
+
await this.read("checkSignatures", args);
|
|
2711
|
+
return [];
|
|
2712
|
+
};
|
|
2713
|
+
/**
|
|
2714
|
+
* @returns Array[domainSeparator]
|
|
2715
|
+
*/
|
|
2716
|
+
this.domainSeparator = async () => {
|
|
2717
|
+
return [await this.read("domainSeparator")];
|
|
2718
|
+
};
|
|
2719
|
+
/**
|
|
2720
|
+
* Encodes the data for a transaction to the Safe contract.
|
|
2721
|
+
* @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
|
|
2722
|
+
* @returns Array[encodedData]
|
|
2723
|
+
*/
|
|
2724
|
+
this.encodeTransactionData = async (args) => {
|
|
2725
|
+
return [await this.read("encodeTransactionData", args)];
|
|
2726
|
+
};
|
|
2727
|
+
/**
|
|
2728
|
+
* Returns array of modules.
|
|
2729
|
+
* @param args - Array[start, pageSize]
|
|
2730
|
+
* @returns Array[Array[modules], next]
|
|
2731
|
+
*/
|
|
2732
|
+
this.getModulesPaginated = async (args) => {
|
|
2733
|
+
const [array, next] = await this.read("getModulesPaginated", args);
|
|
2734
|
+
return [array, next];
|
|
2735
|
+
};
|
|
2736
|
+
/**
|
|
2737
|
+
* Returns the list of Safe owner accounts.
|
|
2738
|
+
* @returns Array[Array[owners]]
|
|
2739
|
+
*/
|
|
2740
|
+
this.getOwners = async () => {
|
|
2741
|
+
return [await this.read("getOwners")];
|
|
2742
|
+
};
|
|
2743
|
+
/**
|
|
2744
|
+
* Reads `length` bytes of storage in the currents contract
|
|
2745
|
+
* @param args - Array[offset, length]
|
|
2746
|
+
* @returns Array[storage]
|
|
2747
|
+
*/
|
|
2748
|
+
this.getStorageAt = async (args) => {
|
|
2749
|
+
return [await this.read("getStorageAt", args)];
|
|
2750
|
+
};
|
|
2751
|
+
/**
|
|
2752
|
+
* Returns the Safe threshold.
|
|
2753
|
+
* @returns Array[threshold]
|
|
2754
|
+
*/
|
|
2755
|
+
this.getThreshold = async () => {
|
|
2756
|
+
return [await this.read("getThreshold")];
|
|
2757
|
+
};
|
|
2758
|
+
/**
|
|
2759
|
+
* Returns hash to be signed by owners.
|
|
2760
|
+
* @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
|
|
2761
|
+
* @returns Array[transactionHash]
|
|
2762
|
+
*/
|
|
2763
|
+
this.getTransactionHash = async (args) => {
|
|
2764
|
+
return [await this.read("getTransactionHash", args)];
|
|
2765
|
+
};
|
|
2766
|
+
/**
|
|
2767
|
+
* Checks if a specific Safe module is enabled for the current Safe.
|
|
2768
|
+
* @param args - Array[moduleAddress]
|
|
2769
|
+
* @returns Array[isEnabled]
|
|
2770
|
+
*/
|
|
2771
|
+
this.isModuleEnabled = async (args) => {
|
|
2772
|
+
return [await this.read("isModuleEnabled", args)];
|
|
2773
|
+
};
|
|
2774
|
+
/**
|
|
2775
|
+
* Checks if a specific address is an owner of the current Safe.
|
|
2776
|
+
* @param args - Array[address]
|
|
2777
|
+
* @returns Array[isOwner]
|
|
2778
|
+
*/
|
|
2779
|
+
this.isOwner = async (args) => {
|
|
2780
|
+
return [await this.read("isOwner", args)];
|
|
2781
|
+
};
|
|
2782
|
+
/**
|
|
2783
|
+
* Returns the Safe nonce.
|
|
2784
|
+
* @returns Array[nonce]
|
|
2785
|
+
*/
|
|
2786
|
+
this.nonce = async () => {
|
|
2787
|
+
return [await this.read("nonce")];
|
|
2788
|
+
};
|
|
2789
|
+
/**
|
|
2790
|
+
* @param args - Array[messageHash]
|
|
2791
|
+
* @returns Array[signedMessages]
|
|
2792
|
+
*/
|
|
2793
|
+
this.signedMessages = async (args) => {
|
|
2794
|
+
return [await this.read("signedMessages", args)];
|
|
2795
|
+
};
|
|
2796
|
+
}
|
|
2797
|
+
/**
|
|
2798
|
+
* Checks whether a given Safe transaction can be executed successfully with no errors.
|
|
2799
|
+
* @param safeTransaction - The Safe transaction to check.
|
|
2800
|
+
* @param options - Optional transaction options.
|
|
2801
|
+
* @returns True, if the given transactions is valid.
|
|
2802
|
+
*/
|
|
2803
|
+
async isValidTransaction(safeTransaction, options = {}) {
|
|
2804
|
+
try {
|
|
2805
|
+
const gasLimit = options?.gasLimit || await this.estimateGas(
|
|
2806
|
+
"execTransaction",
|
|
2807
|
+
[
|
|
2808
|
+
safeTransaction.data.to,
|
|
2809
|
+
BigInt(safeTransaction.data.value),
|
|
2810
|
+
asHex(safeTransaction.data.data),
|
|
2811
|
+
safeTransaction.data.operation,
|
|
2812
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2813
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2814
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2815
|
+
safeTransaction.data.gasToken,
|
|
2816
|
+
safeTransaction.data.refundReceiver,
|
|
2817
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2818
|
+
],
|
|
2819
|
+
options
|
|
2820
|
+
);
|
|
2821
|
+
const converted = this.convertOptions({ ...options, gasLimit });
|
|
2822
|
+
const txResult = await simulateContract4(this.runner, {
|
|
2823
|
+
address: this.contractAddress,
|
|
2824
|
+
functionName: "execTransaction",
|
|
2825
|
+
abi: this.contractAbi,
|
|
2826
|
+
args: [
|
|
2827
|
+
safeTransaction.data.to,
|
|
2828
|
+
BigInt(safeTransaction.data.value),
|
|
2829
|
+
asHex(safeTransaction.data.data),
|
|
2830
|
+
safeTransaction.data.operation,
|
|
2831
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2832
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2833
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2834
|
+
safeTransaction.data.gasToken,
|
|
2835
|
+
safeTransaction.data.refundReceiver,
|
|
2836
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2837
|
+
],
|
|
2838
|
+
...converted
|
|
2839
|
+
});
|
|
2840
|
+
return txResult.result;
|
|
2841
|
+
} catch (error) {
|
|
2842
|
+
return false;
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
/**
|
|
2846
|
+
* Executes a transaction.
|
|
2847
|
+
* @param safeTransaction - The Safe transaction to execute.
|
|
2848
|
+
* @param options - Transaction options.
|
|
2849
|
+
* @returns Transaction result.
|
|
2850
|
+
*/
|
|
2851
|
+
async execTransaction(safeTransaction, options) {
|
|
2852
|
+
const gasLimit = options?.gasLimit || await this.estimateGas(
|
|
2853
|
+
"execTransaction",
|
|
2854
|
+
[
|
|
2855
|
+
safeTransaction.data.to,
|
|
2856
|
+
BigInt(safeTransaction.data.value),
|
|
2857
|
+
asHex(safeTransaction.data.data),
|
|
2858
|
+
safeTransaction.data.operation,
|
|
2859
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2860
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2861
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2862
|
+
safeTransaction.data.gasToken,
|
|
2863
|
+
safeTransaction.data.refundReceiver,
|
|
2864
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2865
|
+
],
|
|
2866
|
+
options
|
|
2867
|
+
);
|
|
2868
|
+
const args = [
|
|
2869
|
+
safeTransaction.data.to,
|
|
2870
|
+
BigInt(safeTransaction.data.value),
|
|
2871
|
+
asHex(safeTransaction.data.data),
|
|
2872
|
+
safeTransaction.data.operation,
|
|
2873
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
2874
|
+
BigInt(safeTransaction.data.baseGas),
|
|
2875
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
2876
|
+
safeTransaction.data.gasToken,
|
|
2877
|
+
safeTransaction.data.refundReceiver,
|
|
2878
|
+
asHex(safeTransaction.encodedSignatures())
|
|
2879
|
+
];
|
|
2880
|
+
return toTxResult(
|
|
2881
|
+
this.runner,
|
|
2882
|
+
await this.write("execTransaction", args, { ...options, gasLimit }),
|
|
2883
|
+
options
|
|
2884
|
+
);
|
|
2885
|
+
}
|
|
2886
|
+
/**
|
|
2887
|
+
* Returns array of first 10 modules.
|
|
2888
|
+
* @returns Array[modules]
|
|
2889
|
+
*/
|
|
2890
|
+
async getModules() {
|
|
2891
|
+
const [modules] = await this.getModulesPaginated([SENTINEL_ADDRESS, BigInt(10)]);
|
|
2892
|
+
return [modules.map((module) => module)];
|
|
2893
|
+
}
|
|
2894
|
+
/**
|
|
2895
|
+
* Marks a hash as approved. This can be used to validate a hash that is used by a signature.
|
|
2896
|
+
* @param hash - The hash that should be marked as approved for signatures that are verified by this contract.
|
|
2897
|
+
* @param options - Optional transaction options.
|
|
2898
|
+
* @returns Transaction result.
|
|
2899
|
+
*/
|
|
2900
|
+
async approveHash(hash, options) {
|
|
2901
|
+
const gasLimit = options?.gasLimit || await this.estimateGas("approveHash", [asHash(hash)], options);
|
|
2902
|
+
return toTxResult(
|
|
2903
|
+
this.runner,
|
|
2904
|
+
await this.write("approveHash", [asHash(hash)], { ...options, gasLimit }),
|
|
2905
|
+
options
|
|
2906
|
+
);
|
|
2907
|
+
}
|
|
2908
|
+
/**
|
|
2909
|
+
* Returns the chain id of the Safe contract. (Custom method - not defined in the Safe Contract)
|
|
2910
|
+
* @returns Array[chainId]
|
|
2911
|
+
*/
|
|
2912
|
+
async getChainId() {
|
|
2913
|
+
return [await Promise.resolve(this.chainId)];
|
|
2914
|
+
}
|
|
2915
|
+
/**
|
|
2916
|
+
* returns the nonce of the Safe contract.
|
|
2917
|
+
*
|
|
2918
|
+
* @returns {Promise<bigint>} A promise that resolves to the nonce of the Safe contract.
|
|
2919
|
+
*/
|
|
2920
|
+
async getNonce() {
|
|
2921
|
+
const [nonce] = await this.nonce();
|
|
2922
|
+
return nonce;
|
|
2923
|
+
}
|
|
2924
|
+
};
|
|
2925
|
+
var SafeContract_v1_3_0_default = SafeContract_v1_3_0;
|
|
2926
|
+
|
|
2927
|
+
// src/contracts/Safe/v1.4.1/SafeContract_v1_4_1.ts
|
|
2928
|
+
import { simulateContract as simulateContract5 } from "viem/actions";
|
|
2929
|
+
import {
|
|
2930
|
+
safe_1_4_1_ContractArtifacts
|
|
2931
|
+
} from "@safe-global/types-kit";
|
|
2932
|
+
var SafeContract_v1_4_1 = class extends SafeBaseContract_default {
|
|
2933
|
+
/**
|
|
2934
|
+
* Constructs an instance of SafeContract_v1_4_1
|
|
2935
|
+
*
|
|
2936
|
+
* @param chainId - The chain ID where the contract resides.
|
|
2937
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
2938
|
+
* @param isL1SafeSingleton - A flag indicating if the contract is a L1 Safe Singleton.
|
|
2939
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
2940
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.4.1 is used.
|
|
2941
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
2942
|
+
*/
|
|
2943
|
+
constructor(chainId, safeProvider, isL1SafeSingleton, customContractAddress, customContractAbi, deploymentType) {
|
|
2944
|
+
const safeVersion = "1.4.1";
|
|
2945
|
+
const defaultAbi = safe_1_4_1_ContractArtifacts.abi;
|
|
2946
|
+
super(
|
|
2947
|
+
chainId,
|
|
2948
|
+
safeProvider,
|
|
2949
|
+
defaultAbi,
|
|
2950
|
+
safeVersion,
|
|
2951
|
+
isL1SafeSingleton,
|
|
2952
|
+
customContractAddress,
|
|
2953
|
+
customContractAbi,
|
|
2954
|
+
deploymentType
|
|
2955
|
+
);
|
|
2956
|
+
/**
|
|
2957
|
+
* @returns Array[safeContractVersion]
|
|
2958
|
+
*/
|
|
2959
|
+
this.VERSION = async () => {
|
|
2960
|
+
return [await this.read("VERSION")];
|
|
2961
|
+
};
|
|
2962
|
+
/**
|
|
2963
|
+
* @param args - Array[owner, txHash]
|
|
2964
|
+
* @returns Array[approvedHashes]
|
|
2965
|
+
*/
|
|
2966
|
+
this.approvedHashes = async (args) => {
|
|
2967
|
+
return [await this.read("approvedHashes", args)];
|
|
2968
|
+
};
|
|
2969
|
+
/**
|
|
2970
|
+
* Checks whether the signature provided is valid for the provided data, hash and number of required signatures.
|
|
2971
|
+
* Will revert otherwise.
|
|
2972
|
+
* @param args - Array[dataHash, data, signatures, requiredSignatures]
|
|
2973
|
+
* @returns Empty array
|
|
2974
|
+
*/
|
|
2975
|
+
this.checkNSignatures = async (args) => {
|
|
2976
|
+
await this.read("checkNSignatures", args);
|
|
2977
|
+
return [];
|
|
2978
|
+
};
|
|
2979
|
+
/**
|
|
2980
|
+
* Checks whether the signature provided is valid for the provided data and hash. Will revert otherwise.
|
|
2981
|
+
* @param args - Array[dataHash, data, signatures]
|
|
2982
|
+
* @returns Empty array
|
|
2983
|
+
*/
|
|
2984
|
+
this.checkSignatures = async (args) => {
|
|
2985
|
+
await this.read("checkSignatures", args);
|
|
2986
|
+
return [];
|
|
2987
|
+
};
|
|
2988
|
+
/**
|
|
2989
|
+
* @returns Array[domainSeparator]
|
|
2990
|
+
*/
|
|
2991
|
+
this.domainSeparator = async () => {
|
|
2992
|
+
return [await this.read("domainSeparator")];
|
|
2993
|
+
};
|
|
2994
|
+
/**
|
|
2995
|
+
* Encodes the data for a transaction to the Safe contract.
|
|
2996
|
+
* @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
|
|
2997
|
+
* @returns Array[encodedData]
|
|
2998
|
+
*/
|
|
2999
|
+
this.encodeTransactionData = async (args) => {
|
|
3000
|
+
return [await this.read("encodeTransactionData", args)];
|
|
3001
|
+
};
|
|
3002
|
+
/**
|
|
3003
|
+
* Returns array of modules.
|
|
3004
|
+
* @param args - Array[start, pageSize]
|
|
3005
|
+
* @returns Array[Array[modules], next]
|
|
3006
|
+
*/
|
|
3007
|
+
this.getModulesPaginated = async (args) => {
|
|
3008
|
+
const [array, next] = await this.read("getModulesPaginated", args);
|
|
3009
|
+
return [array, next];
|
|
3010
|
+
};
|
|
3011
|
+
/**
|
|
3012
|
+
* Returns the list of Safe owner accounts.
|
|
3013
|
+
* @returns Array[Array[owners]]
|
|
3014
|
+
*/
|
|
3015
|
+
this.getOwners = async () => {
|
|
3016
|
+
return [await this.read("getOwners")];
|
|
3017
|
+
};
|
|
3018
|
+
/**
|
|
3019
|
+
* Reads `length` bytes of storage in the currents contract
|
|
3020
|
+
* @param args - Array[offset, length]
|
|
3021
|
+
* @returns Array[storage]
|
|
3022
|
+
*/
|
|
3023
|
+
this.getStorageAt = async (args) => {
|
|
3024
|
+
return [await this.read("getStorageAt", args)];
|
|
3025
|
+
};
|
|
3026
|
+
/**
|
|
3027
|
+
* Returns the Safe threshold.
|
|
3028
|
+
* @returns Array[threshold]
|
|
3029
|
+
*/
|
|
3030
|
+
this.getThreshold = async () => {
|
|
3031
|
+
return [await this.read("getThreshold")];
|
|
3032
|
+
};
|
|
3033
|
+
/**
|
|
3034
|
+
* Returns hash to be signed by owners.
|
|
3035
|
+
* @param args - Array[to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce]
|
|
3036
|
+
* @returns Array[transactionHash]
|
|
3037
|
+
*/
|
|
3038
|
+
this.getTransactionHash = async (args) => {
|
|
3039
|
+
return [await this.read("getTransactionHash", args)];
|
|
3040
|
+
};
|
|
3041
|
+
/**
|
|
3042
|
+
* Checks if a specific Safe module is enabled for the current Safe.
|
|
3043
|
+
* @param args - Array[moduleAddress]
|
|
3044
|
+
* @returns Array[isEnabled]
|
|
3045
|
+
*/
|
|
3046
|
+
this.isModuleEnabled = async (args) => {
|
|
3047
|
+
return [await this.read("isModuleEnabled", args)];
|
|
3048
|
+
};
|
|
3049
|
+
/**
|
|
3050
|
+
* Checks if a specific address is an owner of the current Safe.
|
|
3051
|
+
* @param args - Array[address]
|
|
3052
|
+
* @returns Array[isOwner]
|
|
3053
|
+
*/
|
|
3054
|
+
this.isOwner = async (args) => {
|
|
3055
|
+
return [await this.read("isOwner", args)];
|
|
3056
|
+
};
|
|
3057
|
+
/**
|
|
3058
|
+
* Returns the Safe nonce.
|
|
3059
|
+
* @returns Array[nonce]
|
|
3060
|
+
*/
|
|
3061
|
+
this.nonce = async () => {
|
|
3062
|
+
return [await this.read("nonce")];
|
|
3063
|
+
};
|
|
3064
|
+
/**
|
|
3065
|
+
* @param args - Array[messageHash]
|
|
3066
|
+
* @returns Array[signedMessages]
|
|
3067
|
+
*/
|
|
3068
|
+
this.signedMessages = async (args) => {
|
|
3069
|
+
return [await this.read("signedMessages", args)];
|
|
3070
|
+
};
|
|
3071
|
+
}
|
|
3072
|
+
/**
|
|
3073
|
+
* Checks whether a given Safe transaction can be executed successfully with no errors.
|
|
3074
|
+
* @param safeTransaction - The Safe transaction to check.
|
|
3075
|
+
* @param options - Optional transaction options.
|
|
3076
|
+
* @returns True, if the given transactions is valid.
|
|
3077
|
+
*/
|
|
3078
|
+
async isValidTransaction(safeTransaction, options = {}) {
|
|
3079
|
+
try {
|
|
3080
|
+
const gasLimit = options?.gasLimit || await this.estimateGas(
|
|
3081
|
+
"execTransaction",
|
|
3082
|
+
[
|
|
3083
|
+
safeTransaction.data.to,
|
|
3084
|
+
BigInt(safeTransaction.data.value),
|
|
3085
|
+
asHex(safeTransaction.data.data),
|
|
3086
|
+
safeTransaction.data.operation,
|
|
3087
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
3088
|
+
BigInt(safeTransaction.data.baseGas),
|
|
3089
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
3090
|
+
safeTransaction.data.gasToken,
|
|
3091
|
+
safeTransaction.data.refundReceiver,
|
|
3092
|
+
asHex(safeTransaction.encodedSignatures())
|
|
3093
|
+
],
|
|
3094
|
+
options
|
|
3095
|
+
);
|
|
3096
|
+
const converted = this.convertOptions({ ...options, gasLimit });
|
|
3097
|
+
const txResult = await simulateContract5(this.runner, {
|
|
3098
|
+
address: this.contractAddress,
|
|
3099
|
+
functionName: "execTransaction",
|
|
3100
|
+
abi: this.contractAbi,
|
|
3101
|
+
args: [
|
|
3102
|
+
safeTransaction.data.to,
|
|
3103
|
+
BigInt(safeTransaction.data.value),
|
|
3104
|
+
asHex(safeTransaction.data.data),
|
|
3105
|
+
safeTransaction.data.operation,
|
|
3106
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
3107
|
+
BigInt(safeTransaction.data.baseGas),
|
|
3108
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
3109
|
+
safeTransaction.data.gasToken,
|
|
3110
|
+
safeTransaction.data.refundReceiver,
|
|
3111
|
+
asHex(safeTransaction.encodedSignatures())
|
|
3112
|
+
],
|
|
3113
|
+
...converted
|
|
3114
|
+
});
|
|
3115
|
+
return txResult.result;
|
|
3116
|
+
} catch (error) {
|
|
3117
|
+
return false;
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
/**
|
|
3121
|
+
* Executes a transaction.
|
|
3122
|
+
* @param safeTransaction - The Safe transaction to execute.
|
|
3123
|
+
* @param options - Transaction options.
|
|
3124
|
+
* @returns Transaction result.
|
|
3125
|
+
*/
|
|
3126
|
+
async execTransaction(safeTransaction, options) {
|
|
3127
|
+
const gasLimit = options?.gasLimit || await this.estimateGas(
|
|
3128
|
+
"execTransaction",
|
|
3129
|
+
[
|
|
3130
|
+
safeTransaction.data.to,
|
|
3131
|
+
BigInt(safeTransaction.data.value),
|
|
3132
|
+
asHex(safeTransaction.data.data),
|
|
3133
|
+
safeTransaction.data.operation,
|
|
3134
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
3135
|
+
BigInt(safeTransaction.data.baseGas),
|
|
3136
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
3137
|
+
safeTransaction.data.gasToken,
|
|
3138
|
+
safeTransaction.data.refundReceiver,
|
|
3139
|
+
asHex(safeTransaction.encodedSignatures())
|
|
3140
|
+
],
|
|
3141
|
+
options
|
|
3142
|
+
);
|
|
3143
|
+
const args = [
|
|
3144
|
+
safeTransaction.data.to,
|
|
3145
|
+
BigInt(safeTransaction.data.value),
|
|
3146
|
+
asHex(safeTransaction.data.data),
|
|
3147
|
+
safeTransaction.data.operation,
|
|
3148
|
+
BigInt(safeTransaction.data.safeTxGas),
|
|
3149
|
+
BigInt(safeTransaction.data.baseGas),
|
|
3150
|
+
BigInt(safeTransaction.data.gasPrice),
|
|
3151
|
+
safeTransaction.data.gasToken,
|
|
3152
|
+
safeTransaction.data.refundReceiver,
|
|
3153
|
+
asHex(safeTransaction.encodedSignatures())
|
|
3154
|
+
];
|
|
3155
|
+
return toTxResult(
|
|
3156
|
+
this.runner,
|
|
3157
|
+
await this.write("execTransaction", args, { ...options, gasLimit }),
|
|
3158
|
+
options
|
|
3159
|
+
);
|
|
3160
|
+
}
|
|
3161
|
+
/**
|
|
3162
|
+
* Returns array of first 10 modules.
|
|
3163
|
+
* @returns Array[modules]
|
|
3164
|
+
*/
|
|
3165
|
+
async getModules() {
|
|
3166
|
+
const [modules] = await this.getModulesPaginated([SENTINEL_ADDRESS, BigInt(10)]);
|
|
3167
|
+
return [modules.map((module) => module)];
|
|
3168
|
+
}
|
|
3169
|
+
/**
|
|
3170
|
+
* Marks a hash as approved. This can be used to validate a hash that is used by a signature.
|
|
3171
|
+
* @param hash - The hash that should be marked as approved for signatures that are verified by this contract.
|
|
3172
|
+
* @param options - Optional transaction options.
|
|
3173
|
+
* @returns Transaction result.
|
|
3174
|
+
*/
|
|
3175
|
+
async approveHash(hash, options) {
|
|
3176
|
+
const gasLimit = options?.gasLimit || await this.estimateGas("approveHash", [asHash(hash)], options);
|
|
3177
|
+
return toTxResult(
|
|
3178
|
+
this.runner,
|
|
3179
|
+
await this.write("approveHash", [asHash(hash)], { ...options, gasLimit }),
|
|
3180
|
+
options
|
|
3181
|
+
);
|
|
3182
|
+
}
|
|
3183
|
+
/**
|
|
3184
|
+
* Returns the chain id of the Safe contract. (Custom method - not defined in the Safe Contract)
|
|
3185
|
+
* @returns Array[chainId]
|
|
3186
|
+
*/
|
|
3187
|
+
async getChainId() {
|
|
3188
|
+
return [await Promise.resolve(this.chainId)];
|
|
3189
|
+
}
|
|
3190
|
+
/**
|
|
3191
|
+
* returns the nonce of the Safe contract.
|
|
3192
|
+
*
|
|
3193
|
+
* @returns {Promise<bigint>} A promise that resolves to the nonce of the Safe contract.
|
|
3194
|
+
*/
|
|
3195
|
+
async getNonce() {
|
|
3196
|
+
const [nonce] = await this.nonce();
|
|
3197
|
+
return nonce;
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
var SafeContract_v1_4_1_default = SafeContract_v1_4_1;
|
|
3201
|
+
|
|
3202
|
+
// src/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract.ts
|
|
3203
|
+
var SafeProxyFactoryBaseContract = class extends BaseContract_default {
|
|
3204
|
+
/**
|
|
3205
|
+
* @constructor
|
|
3206
|
+
* Constructs an instance of SafeProxyFactoryBaseContract.
|
|
3207
|
+
*
|
|
3208
|
+
* @param chainId - The chain ID of the contract.
|
|
3209
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3210
|
+
* @param defaultAbi - The default ABI for the Safe contract. It should be compatible with the specific version of the contract.
|
|
3211
|
+
* @param safeVersion - The version of the Safe contract.
|
|
3212
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
3213
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used.
|
|
3214
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3215
|
+
*/
|
|
3216
|
+
constructor(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi, deploymentType) {
|
|
3217
|
+
const contractName3 = "safeProxyFactoryVersion";
|
|
3218
|
+
super(
|
|
3219
|
+
contractName3,
|
|
3220
|
+
chainId,
|
|
3221
|
+
safeProvider,
|
|
3222
|
+
defaultAbi,
|
|
3223
|
+
safeVersion,
|
|
3224
|
+
customContractAddress,
|
|
3225
|
+
customContractAbi,
|
|
3226
|
+
deploymentType
|
|
3227
|
+
);
|
|
3228
|
+
this.contractName = contractName3;
|
|
3229
|
+
}
|
|
3230
|
+
};
|
|
3231
|
+
var SafeProxyFactoryBaseContract_default = SafeProxyFactoryBaseContract;
|
|
3232
|
+
|
|
3233
|
+
// src/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0.ts
|
|
3234
|
+
import {
|
|
3235
|
+
safeProxyFactory_1_0_0_ContractArtifacts
|
|
3236
|
+
} from "@safe-global/types-kit";
|
|
3237
|
+
var SafeProxyFactoryContract_v1_0_0 = class extends SafeProxyFactoryBaseContract_default {
|
|
3238
|
+
/**
|
|
3239
|
+
* Constructs an instance of SafeProxyFactoryContract_v1_0_0
|
|
3240
|
+
*
|
|
3241
|
+
* @param chainId - The chain ID where the contract resides.
|
|
3242
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3243
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
3244
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.0.0 is used.
|
|
3245
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3246
|
+
*/
|
|
3247
|
+
constructor(chainId, safeProvider, customContractAddress, customContractAbi, deploymentType) {
|
|
3248
|
+
const safeVersion = "1.0.0";
|
|
3249
|
+
const defaultAbi = safeProxyFactory_1_0_0_ContractArtifacts.abi;
|
|
3250
|
+
super(
|
|
3251
|
+
chainId,
|
|
3252
|
+
safeProvider,
|
|
3253
|
+
defaultAbi,
|
|
3254
|
+
safeVersion,
|
|
3255
|
+
customContractAddress,
|
|
3256
|
+
customContractAbi,
|
|
3257
|
+
deploymentType
|
|
3258
|
+
);
|
|
3259
|
+
/**
|
|
3260
|
+
* Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
|
|
3261
|
+
* @returns Array[creationCode]
|
|
3262
|
+
*/
|
|
3263
|
+
this.proxyCreationCode = async () => {
|
|
3264
|
+
return [await this.read("proxyCreationCode")];
|
|
3265
|
+
};
|
|
3266
|
+
/**
|
|
3267
|
+
* Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
|
|
3268
|
+
* @returns Array[runtimeCode]
|
|
3269
|
+
*/
|
|
3270
|
+
this.proxyRuntimeCode = async () => {
|
|
3271
|
+
return [await this.read("proxyRuntimeCode")];
|
|
3272
|
+
};
|
|
3273
|
+
/**
|
|
3274
|
+
* Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
|
|
3275
|
+
* @param args - Array[masterCopy, data]
|
|
3276
|
+
* @returns Array[proxyAddress]
|
|
3277
|
+
*/
|
|
3278
|
+
this.createProxy = async (args) => {
|
|
3279
|
+
return [await this.write("createProxy", args)];
|
|
3280
|
+
};
|
|
3281
|
+
/**
|
|
3282
|
+
* Allows to create new proxy contract and execute a message call to the new proxy within one transaction.
|
|
3283
|
+
* @param args - Array[masterCopy, initializer, saltNonce]
|
|
3284
|
+
* @returns Array[proxyAddress]
|
|
3285
|
+
*/
|
|
3286
|
+
this.createProxyWithNonce = async (args) => {
|
|
3287
|
+
return [await this.write("createProxyWithNonce", args)];
|
|
3288
|
+
};
|
|
3289
|
+
}
|
|
3290
|
+
};
|
|
3291
|
+
var SafeProxyFactoryContract_v1_0_0_default = SafeProxyFactoryContract_v1_0_0;
|
|
3292
|
+
|
|
3293
|
+
// src/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1.ts
|
|
3294
|
+
import {
|
|
3295
|
+
safeProxyFactory_1_1_1_ContractArtifacts
|
|
3296
|
+
} from "@safe-global/types-kit";
|
|
3297
|
+
var SafeProxyFactoryContract_v1_1_1 = class extends SafeProxyFactoryBaseContract_default {
|
|
3298
|
+
/**
|
|
3299
|
+
* Constructs an instance of SafeProxyFactoryContract_v1_1_1
|
|
3300
|
+
*
|
|
3301
|
+
* @param chainId - The chain ID where the contract resides.
|
|
3302
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3303
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
3304
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.1.1 is used.
|
|
3305
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3306
|
+
*/
|
|
3307
|
+
constructor(chainId, safeProvider, customContractAddress, customContractAbi, deploymentType) {
|
|
3308
|
+
const safeVersion = "1.1.1";
|
|
3309
|
+
const defaultAbi = safeProxyFactory_1_1_1_ContractArtifacts.abi;
|
|
3310
|
+
super(
|
|
3311
|
+
chainId,
|
|
3312
|
+
safeProvider,
|
|
3313
|
+
defaultAbi,
|
|
3314
|
+
safeVersion,
|
|
3315
|
+
customContractAddress,
|
|
3316
|
+
customContractAbi,
|
|
3317
|
+
deploymentType
|
|
3318
|
+
);
|
|
3319
|
+
/**
|
|
3320
|
+
* Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
|
|
3321
|
+
* @returns Array[creationCode]
|
|
3322
|
+
*/
|
|
3323
|
+
this.proxyCreationCode = async () => {
|
|
3324
|
+
return [await this.read("proxyCreationCode")];
|
|
3325
|
+
};
|
|
3326
|
+
/**
|
|
3327
|
+
* Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
|
|
3328
|
+
* @returns Array[runtimeCode]
|
|
3329
|
+
*/
|
|
3330
|
+
this.proxyRuntimeCode = async () => {
|
|
3331
|
+
return [await this.read("proxyRuntimeCode")];
|
|
3332
|
+
};
|
|
3333
|
+
/**
|
|
3334
|
+
* Allows to get the address for a new proxy contact created via `createProxyWithNonce`.
|
|
3335
|
+
* @param args - Array[masterCopy, initializer, saltNonceBigInt]
|
|
3336
|
+
* @returns Array[proxyAddress]
|
|
3337
|
+
*/
|
|
3338
|
+
this.calculateCreateProxyWithNonceAddress = async (args) => {
|
|
3339
|
+
return [await this.write("calculateCreateProxyWithNonceAddress", args)];
|
|
3340
|
+
};
|
|
3341
|
+
/**
|
|
3342
|
+
* Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
|
|
3343
|
+
* @param args - Array[masterCopy, data]
|
|
3344
|
+
* @returns Array[proxyAddress]
|
|
3345
|
+
*/
|
|
3346
|
+
this.createProxy = async (args) => {
|
|
3347
|
+
return [await this.write("createProxy", args)];
|
|
3348
|
+
};
|
|
3349
|
+
/**
|
|
3350
|
+
* Allows to create new proxy contract, execute a message call to the new proxy and call a specified callback within one transaction.
|
|
3351
|
+
* @param args - Array[masterCopy, initializer, saltNonce, callback]
|
|
3352
|
+
* @returns Array[proxyAddress]
|
|
3353
|
+
*/
|
|
3354
|
+
this.createProxyWithCallback = async (args) => {
|
|
3355
|
+
return [await this.write("createProxyWithCallback", args)];
|
|
3356
|
+
};
|
|
3357
|
+
/**
|
|
3358
|
+
* Allows to create new proxy contract and execute a message call to the new proxy within one transaction.
|
|
3359
|
+
* @param args - Array[masterCopy, initializer, saltNonce]
|
|
3360
|
+
* @returns Array[proxyAddress]
|
|
3361
|
+
*/
|
|
3362
|
+
this.createProxyWithNonce = async (args) => {
|
|
3363
|
+
return [await this.write("createProxyWithNonce", args)];
|
|
3364
|
+
};
|
|
3365
|
+
}
|
|
3366
|
+
};
|
|
3367
|
+
var SafeProxyFactoryContract_v1_1_1_default = SafeProxyFactoryContract_v1_1_1;
|
|
3368
|
+
|
|
3369
|
+
// src/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0.ts
|
|
3370
|
+
import {
|
|
3371
|
+
safeProxyFactory_1_3_0_ContractArtifacts
|
|
3372
|
+
} from "@safe-global/types-kit";
|
|
3373
|
+
var SafeProxyFactoryContract_v1_3_0 = class extends SafeProxyFactoryBaseContract_default {
|
|
3374
|
+
/**
|
|
3375
|
+
* Constructs an instance of SafeProxyFactoryContract_v1_3_0
|
|
3376
|
+
*
|
|
3377
|
+
* @param chainId - The chain ID where the contract resides.
|
|
3378
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3379
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
3380
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.3.0 is used.
|
|
3381
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3382
|
+
*/
|
|
3383
|
+
constructor(chainId, safeProvider, customContractAddress, customContractAbi, deploymentType) {
|
|
3384
|
+
const safeVersion = "1.3.0";
|
|
3385
|
+
const defaultAbi = safeProxyFactory_1_3_0_ContractArtifacts.abi;
|
|
3386
|
+
super(
|
|
3387
|
+
chainId,
|
|
3388
|
+
safeProvider,
|
|
3389
|
+
defaultAbi,
|
|
3390
|
+
safeVersion,
|
|
3391
|
+
customContractAddress,
|
|
3392
|
+
customContractAbi,
|
|
3393
|
+
deploymentType
|
|
3394
|
+
);
|
|
3395
|
+
/**
|
|
3396
|
+
* Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
|
|
3397
|
+
* @returns Array[creationCode]
|
|
3398
|
+
*/
|
|
3399
|
+
this.proxyCreationCode = async () => {
|
|
3400
|
+
return [await this.read("proxyCreationCode")];
|
|
3401
|
+
};
|
|
3402
|
+
/**
|
|
3403
|
+
* Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
|
|
3404
|
+
* @returns Array[runtimeCode]
|
|
3405
|
+
*/
|
|
3406
|
+
this.proxyRuntimeCode = async () => {
|
|
3407
|
+
return [await this.read("proxyRuntimeCode")];
|
|
3408
|
+
};
|
|
3409
|
+
/**
|
|
3410
|
+
* Allows to get the address for a new proxy contact created via `createProxyWithNonce`.
|
|
3411
|
+
* @param args - Array[singleton, initializer, saltNonce]
|
|
3412
|
+
* @returns Array[proxyAddress]
|
|
3413
|
+
*/
|
|
3414
|
+
this.calculateCreateProxyWithNonceAddress = async (args) => {
|
|
3415
|
+
return [await this.write("calculateCreateProxyWithNonceAddress", args)];
|
|
3416
|
+
};
|
|
3417
|
+
/**
|
|
3418
|
+
* Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
|
|
3419
|
+
* @param args - Array[singleton, data]
|
|
3420
|
+
* @returns Array[proxyAddress]
|
|
3421
|
+
*/
|
|
3422
|
+
this.createProxy = async (args) => {
|
|
3423
|
+
return [await this.write("createProxy", args)];
|
|
3424
|
+
};
|
|
3425
|
+
/**
|
|
3426
|
+
* Allows to create new proxy contract, execute a message call to the new proxy and call a specified callback within one transaction.
|
|
3427
|
+
* @param args - Array[singleton, initializer, saltNonce, callback]
|
|
3428
|
+
* @returns Array[proxyAddress]
|
|
3429
|
+
*/
|
|
3430
|
+
this.createProxyWithCallback = async (args) => {
|
|
3431
|
+
return [await this.write("createProxyWithCallback", args)];
|
|
3432
|
+
};
|
|
3433
|
+
/**
|
|
3434
|
+
* Allows to create new proxy contract and execute a message call to the new proxy within one transaction.
|
|
3435
|
+
* @param args - Array[singleton, initializer, saltNonce]
|
|
3436
|
+
* @returns Array[proxyAddress]
|
|
3437
|
+
*/
|
|
3438
|
+
this.createProxyWithNonce = async (args) => {
|
|
3439
|
+
return [await this.write("createProxyWithNonce", args)];
|
|
3440
|
+
};
|
|
3441
|
+
}
|
|
3442
|
+
};
|
|
3443
|
+
var SafeProxyFactoryContract_v1_3_0_default = SafeProxyFactoryContract_v1_3_0;
|
|
3444
|
+
|
|
3445
|
+
// src/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1.ts
|
|
3446
|
+
import {
|
|
3447
|
+
safeProxyFactory_1_4_1_ContractArtifacts
|
|
3448
|
+
} from "@safe-global/types-kit";
|
|
3449
|
+
var SafeProxyFactoryContract_v1_4_1 = class extends SafeProxyFactoryBaseContract_default {
|
|
3450
|
+
/**
|
|
3451
|
+
* Constructs an instance of SafeProxyFactoryContract_v1_4_1
|
|
3452
|
+
*
|
|
3453
|
+
* @param chainId - The chain ID where the contract resides.
|
|
3454
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3455
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
3456
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.4.1 is used.
|
|
3457
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3458
|
+
*/
|
|
3459
|
+
constructor(chainId, safeProvider, customContractAddress, customContractAbi, deploymentType) {
|
|
3460
|
+
const safeVersion = "1.4.1";
|
|
3461
|
+
const defaultAbi = safeProxyFactory_1_4_1_ContractArtifacts.abi;
|
|
3462
|
+
super(
|
|
3463
|
+
chainId,
|
|
3464
|
+
safeProvider,
|
|
3465
|
+
defaultAbi,
|
|
3466
|
+
safeVersion,
|
|
3467
|
+
customContractAddress,
|
|
3468
|
+
customContractAbi,
|
|
3469
|
+
deploymentType
|
|
3470
|
+
);
|
|
3471
|
+
/**
|
|
3472
|
+
* Returns the ID of the chain the contract is currently deployed on.
|
|
3473
|
+
* @returns Array[chainId]
|
|
3474
|
+
*/
|
|
3475
|
+
this.getChainId = async () => {
|
|
3476
|
+
return [await this.read("getChainId")];
|
|
3477
|
+
};
|
|
3478
|
+
/**
|
|
3479
|
+
* Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
|
|
3480
|
+
* @returns Array[creationCode]
|
|
3481
|
+
*/
|
|
3482
|
+
this.proxyCreationCode = async () => {
|
|
3483
|
+
return [await this.read("proxyCreationCode")];
|
|
3484
|
+
};
|
|
3485
|
+
/**
|
|
3486
|
+
* Deploys a new chain-specific proxy with singleton and salt. Optionally executes an initializer call to a new proxy.
|
|
3487
|
+
* @param args - Array[singleton, initializer, saltNonce]
|
|
3488
|
+
* @returns Array[proxy]
|
|
3489
|
+
*/
|
|
3490
|
+
this.createChainSpecificProxyWithNonce = async (args) => {
|
|
3491
|
+
return [await this.write("createChainSpecificProxyWithNonce", args)];
|
|
3492
|
+
};
|
|
3493
|
+
/**
|
|
3494
|
+
* Deploy a new proxy with singleton and salt.
|
|
3495
|
+
* Optionally executes an initializer call to a new proxy and calls a specified callback address.
|
|
3496
|
+
* @param args - Array[singleton, initializer, saltNonce, callback]
|
|
3497
|
+
* @returns Array[proxy]
|
|
3498
|
+
*/
|
|
3499
|
+
this.createProxyWithCallback = async (args) => {
|
|
3500
|
+
return [await this.write("createProxyWithCallback", args)];
|
|
3501
|
+
};
|
|
3502
|
+
/**
|
|
3503
|
+
* Deploys a new proxy with singleton and salt. Optionally executes an initializer call to a new proxy.
|
|
3504
|
+
* @param args - Array[singleton, initializer, saltNonce]
|
|
3505
|
+
* @returns Array[proxy]
|
|
3506
|
+
*/
|
|
3507
|
+
this.createProxyWithNonce = async (args) => {
|
|
3508
|
+
return [await this.write("createProxyWithNonce", args)];
|
|
3509
|
+
};
|
|
3510
|
+
}
|
|
3511
|
+
};
|
|
3512
|
+
var SafeProxyFactoryContract_v1_4_1_default = SafeProxyFactoryContract_v1_4_1;
|
|
3513
|
+
|
|
3514
|
+
// src/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0.ts
|
|
3515
|
+
import {
|
|
3516
|
+
simulateTxAccessor_1_3_0_ContractArtifacts
|
|
3517
|
+
} from "@safe-global/types-kit";
|
|
3518
|
+
|
|
3519
|
+
// src/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1.ts
|
|
3520
|
+
import {
|
|
3521
|
+
simulateTxAccessor_1_4_1_ContractArtifacts
|
|
3522
|
+
} from "@safe-global/types-kit";
|
|
3523
|
+
|
|
3524
|
+
// src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract.ts
|
|
3525
|
+
var CompatibilityFallbackHandlerBaseContract = class extends BaseContract_default {
|
|
3526
|
+
/**
|
|
3527
|
+
* @constructor
|
|
3528
|
+
* Constructs an instance of CompatibilityFallbackHandlerBaseContract.
|
|
3529
|
+
*
|
|
3530
|
+
* @param chainId - The chain ID of the contract.
|
|
3531
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3532
|
+
* @param defaultAbi - The default ABI for the CompatibilityFallbackHandler contract. It should be compatible with the specific version of the contract.
|
|
3533
|
+
* @param safeVersion - The version of the Safe contract.
|
|
3534
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
3535
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used.
|
|
3536
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3537
|
+
*/
|
|
3538
|
+
constructor(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi, deploymentType) {
|
|
3539
|
+
const contractName3 = "compatibilityFallbackHandler";
|
|
3540
|
+
super(
|
|
3541
|
+
contractName3,
|
|
3542
|
+
chainId,
|
|
3543
|
+
safeProvider,
|
|
3544
|
+
defaultAbi,
|
|
3545
|
+
safeVersion,
|
|
3546
|
+
customContractAddress,
|
|
3547
|
+
customContractAbi,
|
|
3548
|
+
deploymentType
|
|
3549
|
+
);
|
|
3550
|
+
this.contractName = contractName3;
|
|
3551
|
+
}
|
|
3552
|
+
};
|
|
3553
|
+
var CompatibilityFallbackHandlerBaseContract_default = CompatibilityFallbackHandlerBaseContract;
|
|
3554
|
+
|
|
3555
|
+
// src/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0.ts
|
|
3556
|
+
import {
|
|
3557
|
+
compatibilityFallbackHandler_1_3_0_ContractArtifacts
|
|
3558
|
+
} from "@safe-global/types-kit";
|
|
3559
|
+
var CompatibilityFallbackHandlerContract_v1_3_0 = class extends CompatibilityFallbackHandlerBaseContract_default {
|
|
3560
|
+
/**
|
|
3561
|
+
* Constructs an instance of CompatibilityFallbackHandlerContract_v1_3_0
|
|
3562
|
+
*
|
|
3563
|
+
* @param chainId - The chain ID where the contract resides.
|
|
3564
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3565
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the CompatibilityFallbackHandler deployments based on the chainId and safeVersion.
|
|
3566
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.3.0 is used.
|
|
3567
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3568
|
+
*/
|
|
3569
|
+
constructor(chainId, safeProvider, customContractAddress, customContractAbi, deploymentType) {
|
|
3570
|
+
const safeVersion = "1.3.0";
|
|
3571
|
+
const defaultAbi = compatibilityFallbackHandler_1_3_0_ContractArtifacts.abi;
|
|
3572
|
+
super(
|
|
3573
|
+
chainId,
|
|
3574
|
+
safeProvider,
|
|
3575
|
+
defaultAbi,
|
|
3576
|
+
safeVersion,
|
|
3577
|
+
customContractAddress,
|
|
3578
|
+
customContractAbi,
|
|
3579
|
+
deploymentType
|
|
3580
|
+
);
|
|
3581
|
+
}
|
|
3582
|
+
};
|
|
3583
|
+
var CompatibilityFallbackHandlerContract_v1_3_0_default = CompatibilityFallbackHandlerContract_v1_3_0;
|
|
3584
|
+
|
|
3585
|
+
// src/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1.ts
|
|
3586
|
+
import {
|
|
3587
|
+
compatibilityFallbackHandler_1_4_1_ContractArtifacts
|
|
3588
|
+
} from "@safe-global/types-kit";
|
|
3589
|
+
var CompatibilityFallbackHandlerContract_v1_4_1 = class extends CompatibilityFallbackHandlerBaseContract_default {
|
|
3590
|
+
/**
|
|
3591
|
+
* Constructs an instance of CompatibilityFallbackHandlerContract_v1_4_1
|
|
3592
|
+
*
|
|
3593
|
+
* @param chainId - The chain ID where the contract resides.
|
|
3594
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3595
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the CompatibilityFallbackHandler deployments based on the chainId and safeVersion.
|
|
3596
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.4.1 is used.
|
|
3597
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3598
|
+
*/
|
|
3599
|
+
constructor(chainId, safeProvider, customContractAddress, customContractAbi, deploymentType) {
|
|
3600
|
+
const safeVersion = "1.4.1";
|
|
3601
|
+
const defaultAbi = compatibilityFallbackHandler_1_4_1_ContractArtifacts.abi;
|
|
3602
|
+
super(
|
|
3603
|
+
chainId,
|
|
3604
|
+
safeProvider,
|
|
3605
|
+
defaultAbi,
|
|
3606
|
+
safeVersion,
|
|
3607
|
+
customContractAddress,
|
|
3608
|
+
customContractAbi,
|
|
3609
|
+
deploymentType
|
|
3610
|
+
);
|
|
3611
|
+
}
|
|
3612
|
+
};
|
|
3613
|
+
var CompatibilityFallbackHandlerContract_v1_4_1_default = CompatibilityFallbackHandlerContract_v1_4_1;
|
|
3614
|
+
|
|
3615
|
+
// src/contracts/SafeWebAuthnSignerFactory/SafeWebAuthnSignerFactoryBaseContract.ts
|
|
3616
|
+
var SafeWebAuthnSignerFactoryBaseContract = class extends BaseContract_default {
|
|
3617
|
+
/**
|
|
3618
|
+
* @constructor
|
|
3619
|
+
* Constructs an instance of SafeWebAuthnSignerFactoryBaseContract.
|
|
3620
|
+
*
|
|
3621
|
+
* @param chainId - The chain ID of the contract.
|
|
3622
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3623
|
+
* @param defaultAbi - The default ABI for the Safe contract. It should be compatible with the specific version of the contract.
|
|
3624
|
+
* @param safeVersion - The version of the Safe contract.
|
|
3625
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
3626
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used.
|
|
3627
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3628
|
+
*/
|
|
3629
|
+
constructor(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi, deploymentType) {
|
|
3630
|
+
const contractName3 = "safeWebAuthnSignerFactoryVersion";
|
|
3631
|
+
super(
|
|
3632
|
+
contractName3,
|
|
3633
|
+
chainId,
|
|
3634
|
+
safeProvider,
|
|
3635
|
+
defaultAbi,
|
|
3636
|
+
safeVersion,
|
|
3637
|
+
customContractAddress,
|
|
3638
|
+
customContractAbi,
|
|
3639
|
+
deploymentType
|
|
3640
|
+
);
|
|
3641
|
+
this.contractName = contractName3;
|
|
3642
|
+
}
|
|
3643
|
+
};
|
|
3644
|
+
var SafeWebAuthnSignerFactoryBaseContract_default = SafeWebAuthnSignerFactoryBaseContract;
|
|
3645
|
+
|
|
3646
|
+
// src/contracts/SafeWebAuthnSignerFactory/v0.2.1/SafeWebAuthnSignerFactoryContract_v0_2_1.ts
|
|
3647
|
+
import {
|
|
3648
|
+
SafeWebAuthnSignerFactory_0_2_1_ContractArtifacts
|
|
3649
|
+
} from "@safe-global/types-kit";
|
|
3650
|
+
var SafeWebAuthnSignerFactoryContract_v0_2_1 = class extends SafeWebAuthnSignerFactoryBaseContract_default {
|
|
3651
|
+
/**
|
|
3652
|
+
* Constructs an instance of SafeWebAuthnSignerFactoryContract_v0_2_1
|
|
3653
|
+
*
|
|
3654
|
+
* @param chainId - The chain ID where the contract resides.
|
|
3655
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3656
|
+
* @param safeVersion - The version of the Safe contract.
|
|
3657
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
3658
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 0.2.1 is used.
|
|
3659
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3660
|
+
*/
|
|
3661
|
+
constructor(chainId, safeProvider, safeVersion, customContractAddress, customContractAbi, deploymentType) {
|
|
3662
|
+
const defaultAbi = SafeWebAuthnSignerFactory_0_2_1_ContractArtifacts.abi;
|
|
3663
|
+
super(
|
|
3664
|
+
chainId,
|
|
3665
|
+
safeProvider,
|
|
3666
|
+
defaultAbi,
|
|
3667
|
+
safeVersion,
|
|
3668
|
+
customContractAddress,
|
|
3669
|
+
customContractAbi,
|
|
3670
|
+
deploymentType
|
|
3671
|
+
);
|
|
3672
|
+
/**
|
|
3673
|
+
* Returns the address of the Signer.
|
|
3674
|
+
* @param args - Array[x, y, verifiers]
|
|
3675
|
+
* @returns Array[signer]
|
|
3676
|
+
*/
|
|
3677
|
+
this.getSigner = async (args) => {
|
|
3678
|
+
return [await this.read("getSigner", args)];
|
|
3679
|
+
};
|
|
3680
|
+
/**
|
|
3681
|
+
* Returns the address of the Signer and deploy the signer contract if its not deployed yet.
|
|
3682
|
+
* @param args - Array[x, y, verifiers]
|
|
3683
|
+
* @returns Array[signer]
|
|
3684
|
+
*/
|
|
3685
|
+
this.createSigner = async (args) => {
|
|
3686
|
+
return [await this.write("createSigner", args)];
|
|
3687
|
+
};
|
|
3688
|
+
this.isValidSignatureForSigner = async (args) => {
|
|
3689
|
+
return [await this.read("isValidSignatureForSigner", args)];
|
|
3690
|
+
};
|
|
3691
|
+
}
|
|
3692
|
+
};
|
|
3693
|
+
var SafeWebAuthnSignerFactoryContract_v0_2_1_default = SafeWebAuthnSignerFactoryContract_v0_2_1;
|
|
3694
|
+
|
|
3695
|
+
// src/contracts/SafeWebAuthnSharedSigner/SafeWebAuthnSharedSignerBaseContract.ts
|
|
3696
|
+
var SafeWebAuthnSharedSignerBaseContract = class extends BaseContract_default {
|
|
3697
|
+
/**
|
|
3698
|
+
* @constructor
|
|
3699
|
+
* Constructs an instance of SafeWebAuthnSharedSignerBaseContract.
|
|
3700
|
+
*
|
|
3701
|
+
* @param chainId - The chain ID of the contract.
|
|
3702
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3703
|
+
* @param defaultAbi - The default ABI for the Safe contract. It should be compatible with the specific version of the contract.
|
|
3704
|
+
* @param safeVersion - The version of the Safe contract.
|
|
3705
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
3706
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used.
|
|
3707
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3708
|
+
*/
|
|
3709
|
+
constructor(chainId, safeProvider, defaultAbi, safeVersion, customContractAddress, customContractAbi, deploymentType) {
|
|
3710
|
+
const contractName3 = "safeWebAuthnSharedSignerVersion";
|
|
3711
|
+
super(
|
|
3712
|
+
contractName3,
|
|
3713
|
+
chainId,
|
|
3714
|
+
safeProvider,
|
|
3715
|
+
defaultAbi,
|
|
3716
|
+
safeVersion,
|
|
3717
|
+
customContractAddress,
|
|
3718
|
+
customContractAbi,
|
|
3719
|
+
deploymentType
|
|
3720
|
+
);
|
|
3721
|
+
this.contractName = contractName3;
|
|
3722
|
+
}
|
|
3723
|
+
};
|
|
3724
|
+
var SafeWebAuthnSharedSignerBaseContract_default = SafeWebAuthnSharedSignerBaseContract;
|
|
3725
|
+
|
|
3726
|
+
// src/contracts/SafeWebAuthnSharedSigner/v0.2.1/SafeWebAuthnSharedSignerContract_v0_2_1.ts
|
|
3727
|
+
import {
|
|
3728
|
+
SafeWebAuthnSharedSigner_0_2_1_ContractArtifacts
|
|
3729
|
+
} from "@safe-global/types-kit";
|
|
3730
|
+
var SafeWebAuthnSharedSignerContract_v0_2_1 = class extends SafeWebAuthnSharedSignerBaseContract_default {
|
|
3731
|
+
/**
|
|
3732
|
+
* Constructs an instance of SafeWebAuthnSharedSignerContract_v0_2_1
|
|
3733
|
+
*
|
|
3734
|
+
* @param chainId - The chain ID where the contract resides.
|
|
3735
|
+
* @param safeProvider - An instance of SafeProvider.
|
|
3736
|
+
* @param safeVersion - The version of the Safe contract.
|
|
3737
|
+
* @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the Safe deployments based on the chainId and safeVersion.
|
|
3738
|
+
* @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 0.2.1 is used.
|
|
3739
|
+
* @param deploymentType - Optional deployment type for the contract. If not provided, the first deployment retrieved from the safe-deployments array will be used.
|
|
3740
|
+
*/
|
|
3741
|
+
constructor(chainId, safeProvider, safeVersion, customContractAddress, customContractAbi, deploymentType) {
|
|
3742
|
+
const defaultAbi = SafeWebAuthnSharedSigner_0_2_1_ContractArtifacts.abi;
|
|
3743
|
+
super(
|
|
3744
|
+
chainId,
|
|
3745
|
+
safeProvider,
|
|
3746
|
+
defaultAbi,
|
|
3747
|
+
safeVersion,
|
|
3748
|
+
customContractAddress,
|
|
3749
|
+
customContractAbi,
|
|
3750
|
+
deploymentType
|
|
3751
|
+
);
|
|
3752
|
+
/**
|
|
3753
|
+
* Return the signer configuration for the specified account.
|
|
3754
|
+
* @param args - Array[address]
|
|
3755
|
+
* @returns Array[signer]
|
|
3756
|
+
*/
|
|
3757
|
+
this.getConfiguration = async (args) => {
|
|
3758
|
+
return [await this.read("getConfiguration", args)];
|
|
3759
|
+
};
|
|
3760
|
+
/**
|
|
3761
|
+
* Sets the signer configuration for the calling account.
|
|
3762
|
+
* @param args - Array[signer]
|
|
3763
|
+
* @returns Array[]
|
|
3764
|
+
*/
|
|
3765
|
+
this.configure = async (args) => {
|
|
3766
|
+
await this.write("configure", args);
|
|
3767
|
+
return [];
|
|
3768
|
+
};
|
|
3769
|
+
this.isValidSignature = async (args) => {
|
|
3770
|
+
return [await this.read("isValidSignature", args)];
|
|
3771
|
+
};
|
|
3772
|
+
/**
|
|
3773
|
+
* @returns The starting storage slot on the account containing the signer data.
|
|
3774
|
+
*/
|
|
3775
|
+
this.SIGNER_SLOT = async () => {
|
|
3776
|
+
return [await this.read("SIGNER_SLOT")];
|
|
3777
|
+
};
|
|
3778
|
+
}
|
|
3779
|
+
};
|
|
3780
|
+
var SafeWebAuthnSharedSignerContract_v0_2_1_default = SafeWebAuthnSharedSignerContract_v0_2_1;
|
|
3781
|
+
|
|
3782
|
+
// src/contracts/contractInstances.ts
|
|
3783
|
+
async function getSafeContractInstance(safeVersion, safeProvider, contractAddress, customContractAbi, isL1SafeSingleton, deploymentType) {
|
|
3784
|
+
const chainId = await safeProvider.getChainId();
|
|
3785
|
+
let safeContractInstance;
|
|
3786
|
+
switch (safeVersion) {
|
|
3787
|
+
case "1.4.1":
|
|
3788
|
+
safeContractInstance = new SafeContract_v1_4_1_default(
|
|
3789
|
+
chainId,
|
|
3790
|
+
safeProvider,
|
|
3791
|
+
isL1SafeSingleton,
|
|
3792
|
+
contractAddress,
|
|
3793
|
+
customContractAbi,
|
|
3794
|
+
deploymentType
|
|
3795
|
+
);
|
|
3796
|
+
break;
|
|
3797
|
+
case "1.3.0":
|
|
3798
|
+
safeContractInstance = new SafeContract_v1_3_0_default(
|
|
3799
|
+
chainId,
|
|
3800
|
+
safeProvider,
|
|
3801
|
+
isL1SafeSingleton,
|
|
3802
|
+
contractAddress,
|
|
3803
|
+
customContractAbi,
|
|
3804
|
+
deploymentType
|
|
3805
|
+
);
|
|
3806
|
+
break;
|
|
3807
|
+
case "1.2.0":
|
|
3808
|
+
safeContractInstance = new SafeContract_v1_2_0_default(
|
|
3809
|
+
chainId,
|
|
3810
|
+
safeProvider,
|
|
3811
|
+
isL1SafeSingleton,
|
|
3812
|
+
contractAddress,
|
|
3813
|
+
customContractAbi,
|
|
3814
|
+
deploymentType
|
|
3815
|
+
);
|
|
3816
|
+
break;
|
|
3817
|
+
case "1.1.1":
|
|
3818
|
+
safeContractInstance = new SafeContract_v1_1_1_default(
|
|
3819
|
+
chainId,
|
|
3820
|
+
safeProvider,
|
|
3821
|
+
isL1SafeSingleton,
|
|
3822
|
+
contractAddress,
|
|
3823
|
+
customContractAbi,
|
|
3824
|
+
deploymentType
|
|
3825
|
+
);
|
|
3826
|
+
break;
|
|
3827
|
+
case "1.0.0":
|
|
3828
|
+
safeContractInstance = new SafeContract_v1_0_0_default(
|
|
3829
|
+
chainId,
|
|
3830
|
+
safeProvider,
|
|
3831
|
+
isL1SafeSingleton,
|
|
3832
|
+
contractAddress,
|
|
3833
|
+
customContractAbi,
|
|
3834
|
+
deploymentType
|
|
3835
|
+
);
|
|
3836
|
+
break;
|
|
3837
|
+
default:
|
|
3838
|
+
throw new Error("Invalid Safe version");
|
|
3839
|
+
}
|
|
3840
|
+
await safeContractInstance.init();
|
|
3841
|
+
return safeContractInstance;
|
|
3842
|
+
}
|
|
3843
|
+
async function getCompatibilityFallbackHandlerContractInstance(safeVersion, safeProvider, contractAddress, customContractAbi, deploymentType) {
|
|
3844
|
+
const chainId = await safeProvider.getChainId();
|
|
3845
|
+
let compatibilityFallbackHandlerInstance;
|
|
3846
|
+
switch (safeVersion) {
|
|
3847
|
+
case "1.4.1":
|
|
3848
|
+
compatibilityFallbackHandlerInstance = new CompatibilityFallbackHandlerContract_v1_4_1_default(
|
|
3849
|
+
chainId,
|
|
3850
|
+
safeProvider,
|
|
3851
|
+
contractAddress,
|
|
3852
|
+
customContractAbi,
|
|
3853
|
+
deploymentType
|
|
3854
|
+
);
|
|
3855
|
+
break;
|
|
3856
|
+
case "1.3.0":
|
|
3857
|
+
case "1.2.0":
|
|
3858
|
+
case "1.1.1":
|
|
3859
|
+
compatibilityFallbackHandlerInstance = new CompatibilityFallbackHandlerContract_v1_3_0_default(
|
|
3860
|
+
chainId,
|
|
3861
|
+
safeProvider,
|
|
3862
|
+
contractAddress,
|
|
3863
|
+
customContractAbi,
|
|
3864
|
+
deploymentType
|
|
3865
|
+
);
|
|
3866
|
+
break;
|
|
3867
|
+
default:
|
|
3868
|
+
throw new Error("Invalid Safe version");
|
|
3869
|
+
}
|
|
3870
|
+
await compatibilityFallbackHandlerInstance.init();
|
|
3871
|
+
return compatibilityFallbackHandlerInstance;
|
|
3872
|
+
}
|
|
3873
|
+
async function getSafeProxyFactoryContractInstance(safeVersion, safeProvider, contractAddress, customContractAbi, deploymentType) {
|
|
3874
|
+
const chainId = await safeProvider.getChainId();
|
|
3875
|
+
let safeProxyFactoryContractInstance;
|
|
3876
|
+
switch (safeVersion) {
|
|
3877
|
+
case "1.4.1":
|
|
3878
|
+
safeProxyFactoryContractInstance = new SafeProxyFactoryContract_v1_4_1_default(
|
|
3879
|
+
chainId,
|
|
3880
|
+
safeProvider,
|
|
3881
|
+
contractAddress,
|
|
3882
|
+
customContractAbi,
|
|
3883
|
+
deploymentType
|
|
3884
|
+
);
|
|
3885
|
+
break;
|
|
3886
|
+
case "1.3.0":
|
|
3887
|
+
safeProxyFactoryContractInstance = new SafeProxyFactoryContract_v1_3_0_default(
|
|
3888
|
+
chainId,
|
|
3889
|
+
safeProvider,
|
|
3890
|
+
contractAddress,
|
|
3891
|
+
customContractAbi,
|
|
3892
|
+
deploymentType
|
|
3893
|
+
);
|
|
3894
|
+
break;
|
|
3895
|
+
case "1.2.0":
|
|
3896
|
+
case "1.1.1":
|
|
3897
|
+
safeProxyFactoryContractInstance = new SafeProxyFactoryContract_v1_1_1_default(
|
|
3898
|
+
chainId,
|
|
3899
|
+
safeProvider,
|
|
3900
|
+
contractAddress,
|
|
3901
|
+
customContractAbi,
|
|
3902
|
+
deploymentType
|
|
3903
|
+
);
|
|
3904
|
+
break;
|
|
3905
|
+
case "1.0.0":
|
|
3906
|
+
safeProxyFactoryContractInstance = new SafeProxyFactoryContract_v1_0_0_default(
|
|
3907
|
+
chainId,
|
|
3908
|
+
safeProvider,
|
|
3909
|
+
contractAddress,
|
|
3910
|
+
customContractAbi,
|
|
3911
|
+
deploymentType
|
|
3912
|
+
);
|
|
3913
|
+
break;
|
|
3914
|
+
default:
|
|
3915
|
+
throw new Error("Invalid Safe version");
|
|
3916
|
+
}
|
|
3917
|
+
await safeProxyFactoryContractInstance.init();
|
|
3918
|
+
return safeProxyFactoryContractInstance;
|
|
3919
|
+
}
|
|
3920
|
+
async function getSafeWebAuthnSignerFactoryContractInstance(safeVersion, safeProvider, contractAddress, customContractAbi, deploymentType) {
|
|
3921
|
+
const chainId = await safeProvider.getChainId();
|
|
3922
|
+
switch (safeVersion) {
|
|
3923
|
+
case "1.4.1":
|
|
3924
|
+
case "1.3.0":
|
|
3925
|
+
const safeWebAuthnSignerFactoryContractInstance = new SafeWebAuthnSignerFactoryContract_v0_2_1_default(
|
|
3926
|
+
chainId,
|
|
3927
|
+
safeProvider,
|
|
3928
|
+
safeVersion,
|
|
3929
|
+
contractAddress,
|
|
3930
|
+
customContractAbi,
|
|
3931
|
+
deploymentType
|
|
3932
|
+
);
|
|
3933
|
+
await safeWebAuthnSignerFactoryContractInstance.init();
|
|
3934
|
+
return safeWebAuthnSignerFactoryContractInstance;
|
|
3935
|
+
default:
|
|
3936
|
+
throw new Error("Invalid Safe version");
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
async function getSafeWebAuthnSharedSignerContractInstance(safeVersion, safeProvider, contractAddress, customContractAbi, deploymentType) {
|
|
3940
|
+
const chainId = await safeProvider.getChainId();
|
|
3941
|
+
switch (safeVersion) {
|
|
3942
|
+
case "1.4.1":
|
|
3943
|
+
case "1.3.0":
|
|
3944
|
+
const safeWebAuthnSharedSignerContractInstance = new SafeWebAuthnSharedSignerContract_v0_2_1_default(
|
|
3945
|
+
chainId,
|
|
3946
|
+
safeProvider,
|
|
3947
|
+
safeVersion,
|
|
3948
|
+
contractAddress,
|
|
3949
|
+
customContractAbi,
|
|
3950
|
+
deploymentType
|
|
3951
|
+
);
|
|
3952
|
+
await safeWebAuthnSharedSignerContractInstance.init();
|
|
3953
|
+
return safeWebAuthnSharedSignerContractInstance;
|
|
3954
|
+
default:
|
|
3955
|
+
throw new Error("Invalid Safe version");
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
|
|
3959
|
+
// src/contracts/safeDeploymentContracts.ts
|
|
3960
|
+
async function getSafeContract({
|
|
3961
|
+
safeProvider,
|
|
3962
|
+
safeVersion,
|
|
3963
|
+
customSafeAddress,
|
|
3964
|
+
isL1SafeSingleton,
|
|
3965
|
+
customContracts,
|
|
3966
|
+
deploymentType
|
|
3967
|
+
}) {
|
|
3968
|
+
const safeContract = await getSafeContractInstance(
|
|
3969
|
+
safeVersion,
|
|
3970
|
+
safeProvider,
|
|
3971
|
+
customSafeAddress ?? customContracts?.safeSingletonAddress,
|
|
3972
|
+
customContracts?.safeSingletonAbi,
|
|
3973
|
+
isL1SafeSingleton,
|
|
3974
|
+
deploymentType
|
|
3975
|
+
);
|
|
3976
|
+
const isContractDeployed = await safeProvider.isContractDeployed(safeContract.getAddress());
|
|
3977
|
+
if (!isContractDeployed) {
|
|
3978
|
+
throw new Error("SafeProxy contract is not deployed on the current network");
|
|
3979
|
+
}
|
|
3980
|
+
return safeContract;
|
|
3981
|
+
}
|
|
3982
|
+
async function getSafeProxyFactoryContract({
|
|
3983
|
+
safeProvider,
|
|
3984
|
+
safeVersion,
|
|
3985
|
+
customContracts,
|
|
3986
|
+
deploymentType
|
|
3987
|
+
}) {
|
|
3988
|
+
const safeProxyFactoryContract = await getSafeProxyFactoryContractInstance(
|
|
3989
|
+
safeVersion,
|
|
3990
|
+
safeProvider,
|
|
3991
|
+
customContracts?.safeProxyFactoryAddress,
|
|
3992
|
+
customContracts?.safeProxyFactoryAbi,
|
|
3993
|
+
deploymentType
|
|
3994
|
+
);
|
|
3995
|
+
const isContractDeployed = await safeProvider.isContractDeployed(
|
|
3996
|
+
safeProxyFactoryContract.getAddress()
|
|
3997
|
+
);
|
|
3998
|
+
if (!isContractDeployed) {
|
|
3999
|
+
throw new Error("SafeProxyFactory contract is not deployed on the current network");
|
|
4000
|
+
}
|
|
4001
|
+
return safeProxyFactoryContract;
|
|
4002
|
+
}
|
|
4003
|
+
async function getCompatibilityFallbackHandlerContract({
|
|
4004
|
+
safeProvider,
|
|
4005
|
+
safeVersion,
|
|
4006
|
+
customContracts,
|
|
4007
|
+
deploymentType
|
|
4008
|
+
}) {
|
|
4009
|
+
const fallbackHandlerContract = await getCompatibilityFallbackHandlerContractInstance(
|
|
4010
|
+
safeVersion,
|
|
4011
|
+
safeProvider,
|
|
4012
|
+
customContracts?.fallbackHandlerAddress,
|
|
4013
|
+
customContracts?.fallbackHandlerAbi,
|
|
4014
|
+
deploymentType
|
|
4015
|
+
);
|
|
4016
|
+
const isContractDeployed = await safeProvider.isContractDeployed(
|
|
4017
|
+
fallbackHandlerContract.getAddress()
|
|
4018
|
+
);
|
|
4019
|
+
if (!isContractDeployed) {
|
|
4020
|
+
throw new Error("CompatibilityFallbackHandler contract is not deployed on the current network");
|
|
4021
|
+
}
|
|
4022
|
+
return fallbackHandlerContract;
|
|
4023
|
+
}
|
|
4024
|
+
async function getSafeWebAuthnSignerFactoryContract({
|
|
4025
|
+
safeProvider,
|
|
4026
|
+
safeVersion,
|
|
4027
|
+
customContracts,
|
|
4028
|
+
deploymentType
|
|
4029
|
+
}) {
|
|
4030
|
+
const safeWebAuthnSignerFactoryContract = await getSafeWebAuthnSignerFactoryContractInstance(
|
|
4031
|
+
safeVersion,
|
|
4032
|
+
safeProvider,
|
|
4033
|
+
customContracts?.safeWebAuthnSignerFactoryAddress,
|
|
4034
|
+
customContracts?.safeWebAuthnSignerFactoryAbi,
|
|
4035
|
+
deploymentType
|
|
4036
|
+
);
|
|
4037
|
+
const isContractDeployed = await safeProvider.isContractDeployed(
|
|
4038
|
+
safeWebAuthnSignerFactoryContract.getAddress()
|
|
4039
|
+
);
|
|
4040
|
+
if (!isContractDeployed) {
|
|
4041
|
+
throw new Error("safeWebAuthnSignerFactory contract is not deployed on the current network");
|
|
4042
|
+
}
|
|
4043
|
+
return safeWebAuthnSignerFactoryContract;
|
|
4044
|
+
}
|
|
4045
|
+
async function getSafeWebAuthnSharedSignerContract({
|
|
4046
|
+
safeProvider,
|
|
4047
|
+
safeVersion,
|
|
4048
|
+
customContracts,
|
|
4049
|
+
deploymentType
|
|
4050
|
+
}) {
|
|
4051
|
+
const safeWebAuthnSharedSignerContract = await getSafeWebAuthnSharedSignerContractInstance(
|
|
4052
|
+
safeVersion,
|
|
4053
|
+
safeProvider,
|
|
4054
|
+
customContracts?.safeWebAuthnSharedSignerAddress,
|
|
4055
|
+
customContracts?.safeWebAuthnSharedSignerAbi,
|
|
4056
|
+
deploymentType
|
|
4057
|
+
);
|
|
4058
|
+
const isContractDeployed = await safeProvider.isContractDeployed(
|
|
4059
|
+
safeWebAuthnSharedSignerContract.getAddress()
|
|
4060
|
+
);
|
|
4061
|
+
if (!isContractDeployed) {
|
|
4062
|
+
throw new Error("safeWebAuthnSharedSigner contract is not deployed on the current network");
|
|
4063
|
+
}
|
|
4064
|
+
return safeWebAuthnSharedSignerContract;
|
|
4065
|
+
}
|
|
4066
|
+
|
|
4067
|
+
// src/utils/transactions/gas.ts
|
|
4068
|
+
var CALL_DATA_BYTE_GAS_COST = 16;
|
|
4069
|
+
var ECRECOVER_GAS_COST = 6e3;
|
|
4070
|
+
var GAS_COST_PER_SIGNATURE = 1 * CALL_DATA_BYTE_GAS_COST + 2 * 32 * CALL_DATA_BYTE_GAS_COST + ECRECOVER_GAS_COST;
|
|
4071
|
+
|
|
4072
|
+
// src/utils/transactions/utils.ts
|
|
4073
|
+
import {
|
|
4074
|
+
OperationType as OperationType2
|
|
4075
|
+
} from "@safe-global/types-kit";
|
|
4076
|
+
import semverSatisfies6 from "semver/functions/satisfies.js";
|
|
4077
|
+
import {
|
|
4078
|
+
toBytes as toBytes3,
|
|
4079
|
+
getAddress as getAddress2,
|
|
4080
|
+
encodePacked,
|
|
4081
|
+
bytesToHex,
|
|
4082
|
+
decodeFunctionData,
|
|
4083
|
+
parseAbi as parseAbi3
|
|
4084
|
+
} from "viem";
|
|
4085
|
+
import { waitForTransactionReceipt as waitForTransactionReceiptViem } from "viem/actions";
|
|
4086
|
+
function toEstimateGasParameters(tx) {
|
|
4087
|
+
const params = isLegacyTransaction(tx) ? createLegacyTxOptions(tx) : createTxOptions(tx);
|
|
4088
|
+
if (tx.value) {
|
|
4089
|
+
params.value = BigInt(tx.value);
|
|
4090
|
+
}
|
|
4091
|
+
if (tx.to) {
|
|
4092
|
+
params.to = tx.to;
|
|
4093
|
+
}
|
|
4094
|
+
if (tx.data) {
|
|
4095
|
+
params.data = asHex(tx.data);
|
|
4096
|
+
}
|
|
4097
|
+
return params;
|
|
4098
|
+
}
|
|
4099
|
+
function toTransactionRequest(tx) {
|
|
4100
|
+
const params = isLegacyTransaction(tx) ? createLegacyTxOptions(tx) : createTxOptions(tx);
|
|
4101
|
+
if (tx.to) {
|
|
4102
|
+
params.to = tx.to;
|
|
4103
|
+
}
|
|
4104
|
+
if (tx.data) {
|
|
4105
|
+
params.data = asHex(tx.data);
|
|
4106
|
+
}
|
|
4107
|
+
return params;
|
|
4108
|
+
}
|
|
4109
|
+
function convertTransactionOptions(options) {
|
|
4110
|
+
return isLegacyTransaction(options) ? createLegacyTxOptions(options) : createTxOptions(options);
|
|
4111
|
+
}
|
|
4112
|
+
function isLegacyTransaction(options) {
|
|
4113
|
+
return !!options?.gasPrice;
|
|
4114
|
+
}
|
|
4115
|
+
function createLegacyTxOptions(options) {
|
|
4116
|
+
const converted = {};
|
|
4117
|
+
if (options?.from) {
|
|
4118
|
+
converted.account = options.from;
|
|
4119
|
+
}
|
|
4120
|
+
if (options?.gasLimit) {
|
|
4121
|
+
converted.gas = BigInt(options.gasLimit);
|
|
4122
|
+
}
|
|
4123
|
+
if (options?.gasPrice) {
|
|
4124
|
+
converted.gasPrice = BigInt(options.gasPrice);
|
|
4125
|
+
}
|
|
4126
|
+
if (options?.nonce) {
|
|
4127
|
+
converted.nonce = options.nonce;
|
|
4128
|
+
}
|
|
4129
|
+
return converted;
|
|
4130
|
+
}
|
|
4131
|
+
function createTxOptions(options) {
|
|
4132
|
+
const converted = {};
|
|
4133
|
+
if (options?.from) {
|
|
4134
|
+
converted.account = options.from;
|
|
4135
|
+
}
|
|
4136
|
+
if (options?.gasLimit) {
|
|
4137
|
+
converted.gas = BigInt(options.gasLimit);
|
|
4138
|
+
}
|
|
4139
|
+
if (options?.maxFeePerGas) {
|
|
4140
|
+
converted.maxFeePerGas = BigInt(options.maxFeePerGas);
|
|
4141
|
+
}
|
|
4142
|
+
if (options?.maxPriorityFeePerGas) {
|
|
4143
|
+
converted.maxPriorityFeePerGas = BigInt(options.maxPriorityFeePerGas);
|
|
4144
|
+
}
|
|
4145
|
+
if (options?.nonce) {
|
|
4146
|
+
converted.nonce = options.nonce;
|
|
4147
|
+
}
|
|
4148
|
+
return converted;
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
// test-utils/passkeys.ts
|
|
4152
|
+
var singleInstance;
|
|
4153
|
+
function getWebAuthnCredentials() {
|
|
4154
|
+
if (!singleInstance) {
|
|
4155
|
+
singleInstance = new WebAuthnCredentials();
|
|
4156
|
+
}
|
|
4157
|
+
return singleInstance;
|
|
4158
|
+
}
|
|
4159
|
+
async function deployPasskeysContract(passkeys, signer) {
|
|
4160
|
+
const toDeploy = passkeys.map(async (client) => {
|
|
4161
|
+
const { data, to, value } = client.createDeployTxRequest();
|
|
4162
|
+
const createPasskeySignerTransaction = {
|
|
4163
|
+
to,
|
|
4164
|
+
value: BigInt(value),
|
|
4165
|
+
data: asHex(data)
|
|
4166
|
+
};
|
|
4167
|
+
return await signer.sendTransaction(createPasskeySignerTransaction);
|
|
4168
|
+
});
|
|
4169
|
+
return Promise.all(toDeploy);
|
|
4170
|
+
}
|
|
4171
|
+
async function createMockPasskey(name, webAuthnCredentials) {
|
|
4172
|
+
const credentialsInstance = webAuthnCredentials ?? getWebAuthnCredentials();
|
|
4173
|
+
const passkeyCredential = credentialsInstance.create({
|
|
4174
|
+
publicKey: {
|
|
4175
|
+
rp: {
|
|
4176
|
+
name: "Safe",
|
|
4177
|
+
id: "safe.global"
|
|
4178
|
+
},
|
|
4179
|
+
user: {
|
|
4180
|
+
id: toBytes4(keccak2563(toBytes4(name))),
|
|
4181
|
+
name,
|
|
4182
|
+
displayName: name
|
|
4183
|
+
},
|
|
4184
|
+
challenge: toBytes4(Date.now()),
|
|
4185
|
+
pubKeyCredParams: [{ type: "public-key", alg: -7 }]
|
|
4186
|
+
}
|
|
4187
|
+
});
|
|
4188
|
+
const algorithm = {
|
|
4189
|
+
name: "ECDSA",
|
|
4190
|
+
namedCurve: "P-256",
|
|
4191
|
+
hash: { name: "SHA-256" }
|
|
4192
|
+
};
|
|
4193
|
+
const key = await crypto.subtle.importKey(
|
|
4194
|
+
"raw",
|
|
4195
|
+
passkeyCredential.response.getPublicKey(),
|
|
4196
|
+
algorithm,
|
|
4197
|
+
true,
|
|
4198
|
+
["verify"]
|
|
4199
|
+
);
|
|
4200
|
+
const exportedPublicKey = await crypto.subtle.exportKey("spki", key);
|
|
4201
|
+
const rawId = Buffer.from(passkeyCredential.rawId).toString("hex");
|
|
4202
|
+
const coordinates = await decodePublicKeyForWeb(exportedPublicKey);
|
|
4203
|
+
const passkey = {
|
|
4204
|
+
rawId,
|
|
4205
|
+
coordinates
|
|
4206
|
+
};
|
|
4207
|
+
return passkey;
|
|
4208
|
+
}
|
|
4209
|
+
export {
|
|
4210
|
+
WebAuthnCredentials,
|
|
4211
|
+
base64UrlEncode,
|
|
4212
|
+
createMockPasskey,
|
|
4213
|
+
deployPasskeysContract,
|
|
4214
|
+
encodeWebAuthnSigningMessage,
|
|
4215
|
+
getWebAuthnCredentials,
|
|
4216
|
+
userVerificationFlag
|
|
4217
|
+
};
|