From 9a316ea53b4765463bc5283f6d4a52d58dbde25c Mon Sep 17 00:00:00 2001 From: Tim Schwarz <4171783+tmjssz@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:02:26 +0000 Subject: [PATCH 1/8] Define base types for CreateCall contract --- .../CreateCall/CreateCallBaseContract.ts | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 packages/protocol-kit/src/contracts/AbiType/CreateCall/CreateCallBaseContract.ts diff --git a/packages/protocol-kit/src/contracts/AbiType/CreateCall/CreateCallBaseContract.ts b/packages/protocol-kit/src/contracts/AbiType/CreateCall/CreateCallBaseContract.ts new file mode 100644 index 000000000..ec7ac24e0 --- /dev/null +++ b/packages/protocol-kit/src/contracts/AbiType/CreateCall/CreateCallBaseContract.ts @@ -0,0 +1,128 @@ +import { + Abi, + AbiParametersToPrimitiveTypes, + ExtractAbiFunction, + ExtractAbiFunctionNames +} from 'abitype' +import { SafeVersion } from '@safe-global/safe-core-sdk-types' +import { + EthersTransactionOptions, + EthersTransactionResult +} from '@safe-global/protocol-kit/adapters/ethers' +import { + Web3TransactionOptions, + Web3TransactionResult +} from '@safe-global/protocol-kit/adapters/web3' + +/** + * Encodes a function call for a CreateCall contract. + * + * @template CreateCallContractAbi - The ABI of the CreateCall contract. + * @template CreateCallFunction - The function to encode, derived from the ABI. + */ +export type EncodeCreateCallFunction< + CreateCallContractAbi extends Abi, // Abi of the CreateCall Contract, + CreateCallFunction extends + ExtractAbiFunctionNames = ExtractAbiFunctionNames +> = ( + functionToEncode: CreateCallFunction, + args: AbiParametersToPrimitiveTypes< + ExtractAbiFunction['inputs'], + 'inputs' + > +) => string + +export type GetAddressCreateCallFunction = () => Promise + +/** + * Estimates the gas required for a function call on a CreateCall contract. + * + * @template CreateCallContractAbi - The ABI of the CreateCall contract. + * @template CreateCallFunction - The function for which gas is being estimated, derived from the ABI. + */ +export type EstimateGasCreateCallFunction< + CreateCallContractAbi extends Abi, // Abi of the CreateCall Contract, + TransactionOptions extends EthersTransactionOptions | Web3TransactionOptions, + CreateCallFunction extends + ExtractAbiFunctionNames = ExtractAbiFunctionNames +> = ( + functionToEncode: CreateCallFunction, + params: AbiParametersToPrimitiveTypes< + ExtractAbiFunction['inputs'], + 'inputs' + >, + options?: TransactionOptions +) => Promise + +/** + * Extracts the names of read-only functions (view or pure) from a given CreateCall contract ABI. + * + * @template CreateCallContractAbi - The ABI of the CreateCall contract. + * @type {CreateCallContractReadFunctions} + */ +export type CreateCallContractReadFunctions = + ExtractAbiFunctionNames + +/** + * Deploys a new contract using the create opcode. + * + * @template CreateCallContractAbi - The ABI of the CreateCall contract. + */ +export type PerformCreateFunction< + CreateCallContractAbi extends Abi, // Abi of the CreateCall Contract, + TransactionOptions extends EthersTransactionOptions | Web3TransactionOptions +> = ( + args: AbiParametersToPrimitiveTypes< + ExtractAbiFunction['inputs'] + >, + options?: TransactionOptions +) => Promise + +/** + * Deploys a new contract using the create2 opcode. + * + * @template CreateCallContractAbi - The ABI of the CreateCall contract. + */ +export type PerformCreate2Function< + CreateCallContractAbi extends Abi, // Abi of the CreateCall Contract, + TransactionOptions extends EthersTransactionOptions | Web3TransactionOptions +> = ( + args: AbiParametersToPrimitiveTypes< + ExtractAbiFunction['inputs'] + >, + options?: TransactionOptions +) => Promise + +type CreateCallBaseContract = { + [ProxyFactoryFunction in CreateCallContractReadFunctions]: ( + // parameters + args: AbiParametersToPrimitiveTypes< + ExtractAbiFunction['inputs'], + 'inputs' + > + // returned values as a Promise + ) => Promise< + AbiParametersToPrimitiveTypes< + ExtractAbiFunction['outputs'], + 'outputs' + > + > +} & { + safeVersion: SafeVersion + encode: EncodeCreateCallFunction + getAddress: GetAddressCreateCallFunction + estimateGas: EstimateGasCreateCallFunction< + CreateCallContractAbi, + EthersTransactionOptions | Web3TransactionOptions + > + performCreate: PerformCreateFunction< + CreateCallContractAbi, + EthersTransactionOptions | Web3TransactionOptions + > + performCreate2: PerformCreate2Function< + CreateCallContractAbi, + EthersTransactionOptions | Web3TransactionOptions + > +} + +export default CreateCallBaseContract From a61df7ffc94554f9fdc682f69d5dbbffbb0001d2 Mon Sep 17 00:00:00 2001 From: Tim Schwarz <4171783+tmjssz@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:03:40 +0000 Subject: [PATCH 2/8] Define CreateCallBaseContract class --- .../src/adapters/CreateCallBaseContract.ts | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 packages/protocol-kit/src/adapters/CreateCallBaseContract.ts diff --git a/packages/protocol-kit/src/adapters/CreateCallBaseContract.ts b/packages/protocol-kit/src/adapters/CreateCallBaseContract.ts new file mode 100644 index 000000000..14e738769 --- /dev/null +++ b/packages/protocol-kit/src/adapters/CreateCallBaseContract.ts @@ -0,0 +1,61 @@ +import { contractName, getContractDeployment } from '@safe-global/protocol-kit/contracts/config' +import { SafeVersion } from '@safe-global/safe-core-sdk-types' + +/** + * Abstract class CreateCallBaseContract serves as a base for creating a CreateCallBaseContract contract for a specific adapter (Ethers.js, Web3.js, or viem.js) + * This class is designed to be extended by adapter-specific abstract classes, such as CreateCallBaseContractEthers, CreateCallBaseContractWeb3, and CreateCallBaseContractViem. + * It includes the core logic for selecting the appropriate ABI and the address from CreateCall deployments. + * + * @template CreateCallContractAbiType - The ABI associated with the CreateCall contract. + * + * Example subclasses extending this base class: + * - CreateCallBaseContractEthers extends CreateCallBaseContract + * - CreateCallBaseContractWeb3 extends CreateCallBaseContract + * - CreateCallBaseContractViem extends CreateCallBaseContract + */ +abstract class CreateCallBaseContract { + contractAbi: CreateCallContractAbiType + contractAddress: string + + contractName: contractName + abstract safeVersion: SafeVersion + + abstract contract: unknown // This needs to be implemented for each adapter. + abstract adapter: unknown // This needs to be implemented for each adapter. + + /** + * Constructs a new CreateCallBaseContract instance. + * + * @param chainId - The chain ID of the contract. + * @param defaultAbi - The hardcoded ABI of the CreateCall contract. + * @param safeVersion - The version of the CreateCall contract. + * @param customContractAddress - Optional custom address for the contract. + * @param customContractAbi - Optional custom ABI for the contract. + * @throws Will throw an error if the contract address is invalid. + */ + constructor( + chainId: bigint, + defaultAbi: CreateCallContractAbiType, + safeVersion: SafeVersion, + customContractAddress?: string, + customContractAbi?: CreateCallContractAbiType + ) { + this.contractName = 'createCallVersion' + + const deployment = getContractDeployment(safeVersion, chainId, this.contractName) + + const contractAddress = customContractAddress || deployment?.defaultAddress + + if (!contractAddress) { + throw new Error('Invalid contract address') + } + + this.contractAddress = contractAddress + this.contractAbi = + customContractAbi || + (deployment?.abi as CreateCallContractAbiType) || // this cast is required because abi is set as any[] in safe-deployments + defaultAbi // if no customAbi and no abi is present in the safe-deployments we use our hardcoded abi + } +} + +export default CreateCallBaseContract From e90b965232c9aef87a9447cbca941b08f496abb0 Mon Sep 17 00:00:00 2001 From: Tim Schwarz <4171783+tmjssz@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:04:45 +0000 Subject: [PATCH 3/8] Create adapter-specific base classes for CreateCall contract --- .../CreateCallBaseContractEthers.ts | 59 +++++++++++++++++++ .../CreateCall/CreateCallBaseContractWeb3.ts | 55 +++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallBaseContractEthers.ts create mode 100644 packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallBaseContractWeb3.ts diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallBaseContractEthers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallBaseContractEthers.ts new file mode 100644 index 000000000..375eaf99e --- /dev/null +++ b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallBaseContractEthers.ts @@ -0,0 +1,59 @@ +import { Contract, ContractRunner, InterfaceAbi } from 'ethers' + +import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import CreateCallBaseContract from '@safe-global/protocol-kit/adapters/CreateCallBaseContract' +import { SafeVersion } from '@safe-global/safe-core-sdk-types' + +/** + * Abstract class CreateCallBaseContractEthers extends CreateCallBaseContract to specifically integrate with the Ethers.js v6 library. + * It is designed to be instantiated for different versions of the Safe contract. + * + * This abstract class sets up the Ethers v6 Contract object that interacts with a CreateCall contract version. + * + * Subclasses of CreateCallBaseContractEthers are expected to represent specific versions of the contract. + * + * @template CreateCallContractAbiType - The ABI type specific to the version of the CreateCall contract, extending InterfaceAbi from Ethers. + * @extends CreateCallBaseContract - Extends the generic CreateCallBaseContract with Ethers-specific implementation. + * + * Example subclasses: + * - CreateCallContract_v1_4_1_Ethers extends CreateCallBaseContractEthers + * - CreateCallContract_v1_3_0_Ethers extends CreateCallBaseContractEthers + */ +abstract class CreateCallBaseContractEthers< + CreateCallContractAbiType extends InterfaceAbi +> extends CreateCallBaseContract { + contract: Contract + adapter: EthersAdapter + + /** + * @constructor + * Constructs an instance of CreateCallBaseContractEthers. + * + * @param chainId - The chain ID of the contract. + * @param ethersAdapter - An instance of EthersAdapter. + * @param defaultAbi - The default ABI for the CreateCall contract. It should be compatible with the specific version of the contract. + * @param safeVersion - The version of the Safe contract. + * @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. + * @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used. + */ + constructor( + chainId: bigint, + ethersAdapter: EthersAdapter, + defaultAbi: CreateCallContractAbiType, + safeVersion: SafeVersion, + customContractAddress?: string, + customContractAbi?: CreateCallContractAbiType, + runner?: ContractRunner | null + ) { + super(chainId, defaultAbi, safeVersion, customContractAddress, customContractAbi) + + this.adapter = ethersAdapter + this.contract = new Contract( + this.contractAddress, + this.contractAbi, + runner || this.adapter.getSigner() + ) + } +} + +export default CreateCallBaseContractEthers diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallBaseContractWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallBaseContractWeb3.ts new file mode 100644 index 000000000..cf7b0e0dc --- /dev/null +++ b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallBaseContractWeb3.ts @@ -0,0 +1,55 @@ +import Contract from 'web3-eth-contract' +import { AbiItem } from 'web3-utils' + +import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' +import CreateCallBaseContract from '@safe-global/protocol-kit/adapters/CreateCallBaseContract' +import { SafeVersion } from '@safe-global/safe-core-sdk-types' + +/** + * Abstract class CreateCallBaseContractWeb3 extends CreateCallBaseContract to specifically integrate with the Web3.js v6 library. + * It is designed to be instantiated for different versions of the Safe contract. + * + * This abstract class sets up the Web3 v6 Contract object that interacts with a CreateCall contract version. + * + * Subclasses of CreateCallBaseContractWeb3 are expected to represent specific versions of the contract. + * + * @template CreateCallContractAbiType - The ABI type specific to the version of the CreateCall contract, extending InterfaceAbi from Web3. + * @extends CreateCallBaseContract - Extends the generic CreateCallBaseContract with Web3-specific implementation. + * + * Example subclasses: + * - CreateCallContract_v1_4_1_Web3 extends CreateCallBaseContractWeb3 + * - CreateCallContract_v1_3_0_Web3 extends CreateCallBaseContractWeb3 + */ +abstract class CreateCallBaseContractWeb3< + CreateCallContractAbiType extends AbiItem[] +> extends CreateCallBaseContract { + contract: Contract + adapter: Web3Adapter + + /** + * @constructor + * Constructs an instance of CreateCallBaseContractWeb3. + * + * @param chainId - The chain ID of the contract. + * @param web3Adapter - An instance of Web3Adapter. + * @param defaultAbi - The default ABI for the CreateCall contract. It should be compatible with the specific version of the contract. + * @param safeVersion - The version of the Safe contract. + * @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. + * @param customContractAbi - Optional custom ABI for the contract. If not provided, the ABI is derived from the Safe deployments or the defaultAbi is used. + */ + constructor( + chainId: bigint, + web3Adapter: Web3Adapter, + defaultAbi: CreateCallContractAbiType, + safeVersion: SafeVersion, + customContractAddress?: string, + customContractAbi?: CreateCallContractAbiType + ) { + super(chainId, defaultAbi, safeVersion, customContractAddress, customContractAbi) + + this.adapter = web3Adapter + this.contract = web3Adapter.getContract(this.contractAddress, this.contractAbi) + } +} + +export default CreateCallBaseContractWeb3 From da3ae1ce081f2c1d430d0a3fc1bdb758b741a4f9 Mon Sep 17 00:00:00 2001 From: Tim Schwarz <4171783+tmjssz@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:06:54 +0000 Subject: [PATCH 4/8] Define version-specific types for CreateCall contract by using the ABIs --- .../v1.3.0/CreateCallContract_v1_3_0.ts | 22 ++ .../v1.4.1/CreateCallContract_v1_4_1.ts | 22 ++ .../assets/CreateCall/v1.3.0/create_call.ts | 269 ++++++++++++++++++ .../assets/CreateCall/v1.4.1/create_call.ts | 108 +++++++ 4 files changed, 421 insertions(+) create mode 100644 packages/protocol-kit/src/contracts/AbiType/CreateCall/v1.3.0/CreateCallContract_v1_3_0.ts create mode 100644 packages/protocol-kit/src/contracts/AbiType/CreateCall/v1.4.1/CreateCallContract_v1_4_1.ts create mode 100644 packages/protocol-kit/src/contracts/AbiType/assets/CreateCall/v1.3.0/create_call.ts create mode 100644 packages/protocol-kit/src/contracts/AbiType/assets/CreateCall/v1.4.1/create_call.ts diff --git a/packages/protocol-kit/src/contracts/AbiType/CreateCall/v1.3.0/CreateCallContract_v1_3_0.ts b/packages/protocol-kit/src/contracts/AbiType/CreateCall/v1.3.0/CreateCallContract_v1_3_0.ts new file mode 100644 index 000000000..1d32289e1 --- /dev/null +++ b/packages/protocol-kit/src/contracts/AbiType/CreateCall/v1.3.0/CreateCallContract_v1_3_0.ts @@ -0,0 +1,22 @@ +import { narrow } from 'abitype' +import createCall_1_3_0_ContractArtifacts from '@safe-global/protocol-kit/contracts/AbiType/assets/CreateCall/v1.3.0/create_call' +import CreateCallBaseContract from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/CreateCallBaseContract' + +const createCallContract_v1_3_0_AbiTypes = narrow(createCall_1_3_0_ContractArtifacts.abi) + +/** + * Represents the ABI of the CreateCall contract version 1.3.0. + * + * @type {CreateCallContract_v1_3_0_Abi} + */ +export type CreateCallContract_v1_3_0_Abi = typeof createCallContract_v1_3_0_AbiTypes + +/** + * Represents the contract type for a CreateCall contract version 1.3.0 defining read and write methods. + * Utilizes the generic CreateCallBaseContract with the ABI specific to version 1.3.0. + * + * @type {CreateCallContract_v1_3_0_Contract} + */ +type CreateCallContract_v1_3_0_Contract = CreateCallBaseContract + +export default CreateCallContract_v1_3_0_Contract diff --git a/packages/protocol-kit/src/contracts/AbiType/CreateCall/v1.4.1/CreateCallContract_v1_4_1.ts b/packages/protocol-kit/src/contracts/AbiType/CreateCall/v1.4.1/CreateCallContract_v1_4_1.ts new file mode 100644 index 000000000..c48b1e384 --- /dev/null +++ b/packages/protocol-kit/src/contracts/AbiType/CreateCall/v1.4.1/CreateCallContract_v1_4_1.ts @@ -0,0 +1,22 @@ +import { narrow } from 'abitype' +import createCall_1_4_1_ContractArtifacts from '@safe-global/protocol-kit/contracts/AbiType/assets/CreateCall/v1.4.1/create_call' +import CreateCallBaseContract from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/CreateCallBaseContract' + +const createCallContract_v1_4_1_AbiTypes = narrow(createCall_1_4_1_ContractArtifacts.abi) + +/** + * Represents the ABI of the CreateCall contract version 1.4.1. + * + * @type {CreateCallContract_v1_4_1_Abi} + */ +export type CreateCallContract_v1_4_1_Abi = typeof createCallContract_v1_4_1_AbiTypes + +/** + * Represents the contract type for a CreateCall contract version 1.4.1 defining read and write methods. + * Utilizes the generic CreateCallBaseContract with the ABI specific to version 1.4.1. + * + * @type {CreateCallContract_v1_4_1_Contract} + */ +type CreateCallContract_v1_4_1_Contract = CreateCallBaseContract + +export default CreateCallContract_v1_4_1_Contract diff --git a/packages/protocol-kit/src/contracts/AbiType/assets/CreateCall/v1.3.0/create_call.ts b/packages/protocol-kit/src/contracts/AbiType/assets/CreateCall/v1.3.0/create_call.ts new file mode 100644 index 000000000..1222c402b --- /dev/null +++ b/packages/protocol-kit/src/contracts/AbiType/assets/CreateCall/v1.3.0/create_call.ts @@ -0,0 +1,269 @@ +// Source: https://github.com/safe-global/safe-deployments/blob/main/src/assets/v1.3.0/create_call.json +export default { + defaultAddress: '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + released: true, + contractName: 'CreateCall', + version: '1.3.0', + networkAddresses: { + '1': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '3': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '4': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '5': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '10': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '11': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '12': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '18': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '25': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '28': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '30': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '31': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '39': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '40': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '41': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '42': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '43': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '44': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '46': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '50': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '51': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '56': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '57': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '61': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '63': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '69': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '71': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '81': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '82': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '83': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '97': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '100': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '106': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '108': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '109': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '111': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '122': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '123': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '137': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '148': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '155': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '169': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '195': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '204': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '246': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '250': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '252': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '255': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '280': '0xcB8e5E438c5c2b45FbE17B02Ca9aF91509a8ad56', + '288': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '291': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '300': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '321': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '322': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '324': '0xcB8e5E438c5c2b45FbE17B02Ca9aF91509a8ad56', + '336': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '338': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '420': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '424': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '570': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '588': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '592': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '595': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '599': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '686': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '787': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '919': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1001': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '1008': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1030': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1088': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '1101': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1111': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '1112': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '1115': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1116': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1230': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '1231': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '1284': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1285': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1287': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1294': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '1442': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '1559': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '1663': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '1807': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1890': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1891': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1984': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1998': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '2001': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '2002': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '2008': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '2019': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '2020': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '2021': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '2221': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '2222': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '2358': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '3737': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '3776': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '4002': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '4202': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '4337': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '4460': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '4689': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '4918': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '4919': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '5000': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '5001': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '5003': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '5700': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '6102': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '7001': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '7332': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '7341': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '7700': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '8192': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '8194': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '8217': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '8453': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '9000': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '9001': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '9728': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '10000': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '10001': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '10081': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '10200': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '10242': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '10243': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '11235': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '11437': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '11891': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '12357': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '13337': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '17000': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '17172': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '18231': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '23294': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '23295': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '34443': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '42161': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '42170': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '42220': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '43113': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '43114': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '43288': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '44787': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '45000': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '47805': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '54211': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '56288': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '57000': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '58008': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '59140': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '59144': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '71401': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '71402': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '73799': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '80001': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '80085': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '81457': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '84531': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '84532': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '103454': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '167008': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '200101': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '200202': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '333999': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '421611': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '421613': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '421614': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '534351': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '534352': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '534353': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '622277': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '713715': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '7777777': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '11155111': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '11155420': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '168587773': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '222000222': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '245022926': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '245022934': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '333000333': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '999999999': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1313161554': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1313161555': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '1666600000': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '1666700000': '0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d', + '11297108099': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4', + '11297108109': '0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4' + }, + abi: [ + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'newContract', + type: 'address' + } + ], + name: 'ContractCreation', + type: 'event' + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'value', + type: 'uint256' + }, + { + internalType: 'bytes', + name: 'deploymentData', + type: 'bytes' + } + ], + name: 'performCreate', + outputs: [ + { + internalType: 'address', + name: 'newContract', + type: 'address' + } + ], + stateMutability: 'nonpayable', + type: 'function' + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'value', + type: 'uint256' + }, + { + internalType: 'bytes', + name: 'deploymentData', + type: 'bytes' + }, + { + internalType: 'bytes32', + name: 'salt', + type: 'bytes32' + } + ], + name: 'performCreate2', + outputs: [ + { + internalType: 'address', + name: 'newContract', + type: 'address' + } + ], + stateMutability: 'nonpayable', + type: 'function' + } + ] +} as const diff --git a/packages/protocol-kit/src/contracts/AbiType/assets/CreateCall/v1.4.1/create_call.ts b/packages/protocol-kit/src/contracts/AbiType/assets/CreateCall/v1.4.1/create_call.ts new file mode 100644 index 000000000..bf32f3144 --- /dev/null +++ b/packages/protocol-kit/src/contracts/AbiType/assets/CreateCall/v1.4.1/create_call.ts @@ -0,0 +1,108 @@ +// Source: https://github.com/safe-global/safe-deployments/blob/main/src/assets/v1.4.1/create_call.json +export default { + defaultAddress: '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + released: true, + contractName: 'CreateCall', + version: '1.4.1', + networkAddresses: { + '1': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '5': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '10': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '56': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '71': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '97': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '100': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '137': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '1030': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '1101': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '1442': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '3636': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '4337': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '7771': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '8192': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '8194': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '8453': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '10242': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '10243': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '11235': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '13337': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '17000': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '42161': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '42220': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '54211': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '80001': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '81457': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '84531': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '84532': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '11155111': '0x9b35Af71d77eaf8d7e40252370304687390A1A52', + '11155420': '0x9b35Af71d77eaf8d7e40252370304687390A1A52' + }, + abi: [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'newContract', + type: 'address' + } + ], + name: 'ContractCreation', + type: 'event' + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'value', + type: 'uint256' + }, + { + internalType: 'bytes', + name: 'deploymentData', + type: 'bytes' + } + ], + name: 'performCreate', + outputs: [ + { + internalType: 'address', + name: 'newContract', + type: 'address' + } + ], + stateMutability: 'nonpayable', + type: 'function' + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'value', + type: 'uint256' + }, + { + internalType: 'bytes', + name: 'deploymentData', + type: 'bytes' + }, + { + internalType: 'bytes32', + name: 'salt', + type: 'bytes32' + } + ], + name: 'performCreate2', + outputs: [ + { + internalType: 'address', + name: 'newContract', + type: 'address' + } + ], + stateMutability: 'nonpayable', + type: 'function' + } + ] +} as const From 6233e97af6cd5edc506b8e67454ce161a1554711 Mon Sep 17 00:00:00 2001 From: Tim Schwarz <4171783+tmjssz@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:10:06 +0000 Subject: [PATCH 5/8] Implement CreateCall contract for Ethers.js --- .../src/adapters/ethers/EthersAdapter.ts | 10 +- .../CreateCall/CreateCallEthersContract.ts | 67 ---------- .../CreateCallContract_V1_3_0_Ethers.ts | 122 ++++++++++++++++++ .../CreateCallEthersContract_V1_3_0_Ethers.ts | 10 -- .../CreateCallContract_V1_4_1_Ethers.ts | 122 ++++++++++++++++++ .../CreateCallEthersContract_V1_4_1_Ethers.ts | 10 -- .../contracts/contractInstancesEthers.ts | 44 +++++-- .../protocol-kit/src/adapters/ethers/index.ts | 4 +- packages/protocol-kit/src/index.ts | 4 +- 9 files changed, 285 insertions(+), 108 deletions(-) delete mode 100644 packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallEthersContract.ts create mode 100644 packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Ethers.ts delete mode 100644 packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Ethers.ts create mode 100644 packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Ethers.ts delete mode 100644 packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Ethers.ts diff --git a/packages/protocol-kit/src/adapters/ethers/EthersAdapter.ts b/packages/protocol-kit/src/adapters/ethers/EthersAdapter.ts index 676416f58..41af95c0e 100644 --- a/packages/protocol-kit/src/adapters/ethers/EthersAdapter.ts +++ b/packages/protocol-kit/src/adapters/ethers/EthersAdapter.ts @@ -1,5 +1,6 @@ import { generateTypedData, validateEip3770Address } from '@safe-global/protocol-kit/utils' import { + CreateCallContract, EIP712TypedDataMessage, EIP712TypedDataTx, Eip3770Address, @@ -11,7 +12,6 @@ import { } from '@safe-global/safe-core-sdk-types' import { ethers, TransactionResponse, AbstractSigner, Provider } from 'ethers' import CompatibilityFallbackHandlerContractEthers from './contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerEthersContract' -import CreateCallEthersContract from './contracts/CreateCall/CreateCallEthersContract' import SafeContractEthers from './contracts/Safe/SafeContractEthers' import SimulateTxAccessorEthersContract from './contracts/SimulateTxAccessor/SimulateTxAccessorEthersContract' import { @@ -220,16 +220,16 @@ class EthersAdapter implements EthAdapter { async getCreateCallContract({ safeVersion, singletonDeployment, - customContractAddress - }: GetContractProps): Promise { + customContractAddress, + customContractAbi + }: GetContractProps): Promise { const chainId = await this.getChainId() const contractAddress = customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()] if (!contractAddress) { throw new Error('Invalid CreateCall contract address') } - const signerOrProvider = this.#signer || this.#provider - return getCreateCallContractInstance(safeVersion, contractAddress, signerOrProvider) + return getCreateCallContractInstance(safeVersion, contractAddress, this, customContractAbi) } async getSimulateTxAccessorContract({ diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallEthersContract.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallEthersContract.ts deleted file mode 100644 index 78aac08c3..000000000 --- a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/CreateCallEthersContract.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { - EthersTransactionOptions, - EthersTransactionResult -} from '@safe-global/protocol-kit/adapters/ethers/types' -import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' -import { - Create_call as CreateCall_V1_3_0, - Create_callInterface as CreateCallContractInterface -} from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Create_call' -import { Create_call as CreateCall_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Create_call' -import { CreateCallContract } from '@safe-global/safe-core-sdk-types' - -abstract class CreateCallEthersContract implements CreateCallContract { - constructor(public contract: CreateCall_V1_4_1 | CreateCall_V1_3_0) {} - - getAddress(): Promise { - return this.contract.getAddress() - } - - async performCreate2( - value: string, - deploymentData: string, - salt: string, - options?: EthersTransactionOptions - ): Promise { - if (options && !options.gasLimit) { - options.gasLimit = await this.estimateGas('performCreate2', [value, deploymentData, salt], { - ...options - }) - } - const txResponse = await this.contract.performCreate2(value, deploymentData, salt) - return toTxResult(txResponse, options) - } - - async performCreate( - value: string, - deploymentData: string, - options?: EthersTransactionOptions - ): Promise { - if (options && !options.gasLimit) { - options.gasLimit = await this.estimateGas('performCreate', [value, deploymentData], { - ...options - }) - } - const txResponse = await this.contract.performCreate(value, deploymentData, { ...options }) - return toTxResult(txResponse, options) - } - - encode: CreateCallContractInterface['encodeFunctionData'] = ( - methodName: any, - params: any - ): string => { - return this.contract.interface.encodeFunctionData(methodName, params) - } - - async estimateGas( - methodName: string, - params: any[], - options: EthersTransactionOptions - ): Promise { - const method = this.contract.getFunction(methodName) - - return (await method.estimateGas(...params, options)).toString() - } -} - -export default CreateCallEthersContract diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Ethers.ts new file mode 100644 index 000000000..a773b7490 --- /dev/null +++ b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Ethers.ts @@ -0,0 +1,122 @@ +import CreateCallBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/CreateCall/CreateCallBaseContractEthers' +import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import { + EthersTransactionOptions, + EthersTransactionResult +} from '@safe-global/protocol-kit/adapters/ethers/types' +import CreateCallContract_v1_3_0_Contract, { + CreateCallContract_v1_3_0_Abi +} from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/v1.3.0/CreateCallContract_v1_3_0' +import CreateCall_1_3_0_ContractArtifacts from '@safe-global/protocol-kit/contracts/AbiType/assets/CreateCall/v1.3.0/create_call' +import { SafeVersion } from '@safe-global/safe-core-sdk-types' +import { + EncodeCreateCallFunction, + EstimateGasCreateCallFunction, + GetAddressCreateCallFunction +} from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/CreateCallBaseContract' +import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' + +/** + * CreateCallContract_V1_3_0_Ethers is the implementation specific to the CreateCall contract version 1.3.0. + * + * This class specializes in handling interactions with the CreateCall contract version 1.3.0 using Ethers.js v6. + * + * @extends CreateCallBaseContractEthers - Inherits from CreateCallBaseContractEthers with ABI specific to CreateCall contract version 1.3.0. + * @implements CreateCallContract_v1_3_0_Contract - Implements the interface specific to CreateCall contract version 1.3.0. + */ +class CreateCallContract_V1_3_0_Ethers + extends CreateCallBaseContractEthers + implements CreateCallContract_v1_3_0_Contract +{ + safeVersion: SafeVersion + + /** + * Constructs an instance of CreateCallContract_V1_3_0_Ethers + * + * @param chainId - The chain ID where the contract resides. + * @param ethersAdapter - An instance of EthersAdapter. + * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the CreateCall deployments based on the chainId and safeVersion. + * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.3.0 is used. + */ + constructor( + chainId: bigint, + ethersAdapter: EthersAdapter, + customContractAddress?: string, + customContractAbi?: CreateCallContract_v1_3_0_Abi + ) { + const safeVersion = '1.3.0' + const defaultAbi = CreateCall_1_3_0_ContractArtifacts.abi + + super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + + this.safeVersion = safeVersion + } + + getAddress: GetAddressCreateCallFunction = () => { + return this.contract.getAddress() + } + + encode: EncodeCreateCallFunction = (functionToEncode, args) => { + return this.contract.interface.encodeFunctionData(functionToEncode, args) + } + + estimateGas: EstimateGasCreateCallFunction< + CreateCallContract_v1_3_0_Abi, + EthersTransactionOptions + > = (functionToEstimate, args, options = {}) => { + const contractMethodToEstimate = this.contract.getFunction(functionToEstimate) + + return contractMethodToEstimate.estimateGas(...args, options) + } + + async performCreate( + args: readonly [value: bigint, deploymentData: string], + options?: EthersTransactionOptions + ): Promise { + if (options && !options.gasLimit) { + options.gasLimit = (await this.estimateGas('performCreate', args, { ...options })).toString() + } + const txResponse = await this.contract.performCreate(...args, { ...options }) + return toTxResult(txResponse, options) + } + + async performCreate2( + args: readonly [value: bigint, deploymentData: string, salt: string], + options?: EthersTransactionOptions + ): Promise { + if (options && !options.gasLimit) { + options.gasLimit = (await this.estimateGas('performCreate2', args, { ...options })).toString() + } + const txResponse = await this.contract.performCreate2(...args) + return toTxResult(txResponse, options) + } + + // TODO: Remove this mapper after remove Typechain + mapToTypechainContract(): any { + return { + contract: this.contract, + + getAddress: this.getAddress.bind(this), + + encode: this.encode.bind(this), + + estimateGas: async (...args: Parameters) => + (await this.estimateGas(...args)).toString(), + + performCreate: async ( + value: string, + deploymentData: string, + options?: EthersTransactionOptions + ) => this.performCreate([BigInt(value), deploymentData], options), + + performCreate2: async ( + value: string, + deploymentData: string, + salt: string, + options?: EthersTransactionOptions + ) => this.performCreate2([BigInt(value), deploymentData, salt], options) + } + } +} + +export default CreateCallContract_V1_3_0_Ethers diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Ethers.ts deleted file mode 100644 index 3f954e55b..000000000 --- a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Ethers.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Create_call as CreateCall } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/Create_call' -import CreateCallEthersContract from '../CreateCallEthersContract' - -class CreateCallContract_V1_3_0_Ethers extends CreateCallEthersContract { - constructor(public contract: CreateCall) { - super(contract) - } -} - -export default CreateCallContract_V1_3_0_Ethers diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Ethers.ts new file mode 100644 index 000000000..591082b4b --- /dev/null +++ b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Ethers.ts @@ -0,0 +1,122 @@ +import CreateCallBaseContractEthers from '@safe-global/protocol-kit/adapters/ethers/contracts/CreateCall/CreateCallBaseContractEthers' +import EthersAdapter from '@safe-global/protocol-kit/adapters/ethers/EthersAdapter' +import { + EthersTransactionOptions, + EthersTransactionResult +} from '@safe-global/protocol-kit/adapters/ethers/types' +import CreateCallContract_v1_4_1_Contract, { + CreateCallContract_v1_4_1_Abi +} from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/v1.4.1/CreateCallContract_v1_4_1' +import CreateCall_1_4_1_ContractArtifacts from '@safe-global/protocol-kit/contracts/AbiType/assets/CreateCall/v1.4.1/create_call' +import { SafeVersion } from '@safe-global/safe-core-sdk-types' +import { + EncodeCreateCallFunction, + EstimateGasCreateCallFunction, + GetAddressCreateCallFunction +} from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/CreateCallBaseContract' +import { toTxResult } from '@safe-global/protocol-kit/adapters/ethers/utils' + +/** + * CreateCallContract_V1_4_1_Ethers is the implementation specific to the CreateCall contract version 1.4.1. + * + * This class specializes in handling interactions with the CreateCall contract version 1.4.1 using Ethers.js v6. + * + * @extends CreateCallBaseContractEthers - Inherits from CreateCallBaseContractEthers with ABI specific to CreateCall contract version 1.4.1. + * @implements CreateCallContract_v1_4_1_Contract - Implements the interface specific to CreateCall contract version 1.4.1. + */ +class CreateCallContract_V1_4_1_Ethers + extends CreateCallBaseContractEthers + implements CreateCallContract_v1_4_1_Contract +{ + safeVersion: SafeVersion + + /** + * Constructs an instance of CreateCallContract_V1_4_1_Ethers + * + * @param chainId - The chain ID where the contract resides. + * @param ethersAdapter - An instance of EthersAdapter. + * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the CreateCall deployments based on the chainId and safeVersion. + * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.4.1 is used. + */ + constructor( + chainId: bigint, + ethersAdapter: EthersAdapter, + customContractAddress?: string, + customContractAbi?: CreateCallContract_v1_4_1_Abi + ) { + const safeVersion = '1.4.1' + const defaultAbi = CreateCall_1_4_1_ContractArtifacts.abi + + super(chainId, ethersAdapter, defaultAbi, safeVersion, customContractAddress, customContractAbi) + + this.safeVersion = safeVersion + } + + getAddress: GetAddressCreateCallFunction = () => { + return this.contract.getAddress() + } + + encode: EncodeCreateCallFunction = (functionToEncode, args) => { + return this.contract.interface.encodeFunctionData(functionToEncode, args) + } + + estimateGas: EstimateGasCreateCallFunction< + CreateCallContract_v1_4_1_Abi, + EthersTransactionOptions + > = (functionToEstimate, args, options = {}) => { + const contractMethodToEstimate = this.contract.getFunction(functionToEstimate) + + return contractMethodToEstimate.estimateGas(...args, options) + } + + async performCreate( + args: readonly [value: bigint, deploymentData: string], + options?: EthersTransactionOptions + ): Promise { + if (options && !options.gasLimit) { + options.gasLimit = (await this.estimateGas('performCreate', args, { ...options })).toString() + } + const txResponse = await this.contract.performCreate(...args, { ...options }) + return toTxResult(txResponse, options) + } + + async performCreate2( + args: readonly [value: bigint, deploymentData: string, salt: string], + options?: EthersTransactionOptions + ): Promise { + if (options && !options.gasLimit) { + options.gasLimit = (await this.estimateGas('performCreate2', args, { ...options })).toString() + } + const txResponse = await this.contract.performCreate2(...args) + return toTxResult(txResponse, options) + } + + // TODO: Remove this mapper after remove Typechain + mapToTypechainContract(): any { + return { + contract: this.contract, + + getAddress: this.getAddress.bind(this), + + encode: this.encode.bind(this), + + estimateGas: async (...args: Parameters) => + (await this.estimateGas(...args)).toString(), + + performCreate: async ( + value: string, + deploymentData: string, + options?: EthersTransactionOptions + ) => this.performCreate([BigInt(value), deploymentData], options), + + performCreate2: async ( + value: string, + deploymentData: string, + salt: string, + options?: EthersTransactionOptions + ) => this.performCreate2([BigInt(value), deploymentData, salt], options) + } + } +} + +export default CreateCallContract_V1_4_1_Ethers diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Ethers.ts deleted file mode 100644 index 6bad21fa7..000000000 --- a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Ethers.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Create_call as CreateCall } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/Create_call' -import CreateCallEthersContract from '../CreateCallEthersContract' - -class CreateCallContract_V1_4_1_Ethers extends CreateCallEthersContract { - constructor(public contract: CreateCall) { - super(contract) - } -} - -export default CreateCallContract_V1_4_1_Ethers diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts index 300a03bb1..adfa68e4f 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts +++ b/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts @@ -1,16 +1,18 @@ import { AbstractSigner, Provider } from 'ethers' import { AbiItem } from 'web3-utils' import { Compatibility_fallback_handler__factory as CompatibilityFallbackHandler_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/factories/Compatibility_fallback_handler__factory' -import { Create_call__factory as CreateCall_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/factories/Create_call__factory' import { Simulate_tx_accessor__factory as SimulateTxAccessor_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.3.0/factories/Simulate_tx_accessor__factory' import { Compatibility_fallback_handler__factory as CompatibilityFallbackHandler_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/factories/Compatibility_fallback_handler__factory' -import { Create_call__factory as CreateCall_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/factories/Create_call__factory' import { Simulate_tx_accessor__factory as SimulateTxAccessor_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/ethers-v6/v1.4.1/factories/Simulate_tx_accessor__factory' -import { SafeVersion, SignMessageLibContract } from '@safe-global/safe-core-sdk-types' +import { + CreateCallContract, + SafeVersion, + SignMessageLibContract +} from '@safe-global/safe-core-sdk-types' import CompatibilityFallbackHandler_V1_3_0_Ethers from './CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Ethers' import CompatibilityFallbackHandler_V1_4_1_Ethers from './CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Ethers' -import CreateCallContract_V1_3_0_Ethers from './CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Ethers' -import CreateCallContract_V1_4_1_Ethers from './CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Ethers' +import CreateCallContract_V1_3_0_Ethers from './CreateCall/v1.3.0/CreateCallContract_V1_3_0_Ethers' +import CreateCallContract_V1_4_1_Ethers from './CreateCall/v1.4.1/CreateCallContract_V1_4_1_Ethers' import MultiSendContract_V1_1_1_Ethers from './MultiSend/v1.1.1/MultiSendContract_V1_1_1_Ethers' import MultiSendContract_V1_3_0_Ethers from './MultiSend/v1.3.0/MultiSendContract_V1_3_0_Ethers' import MultiSendContract_V1_4_1_Ethers from './MultiSend/v1.4.1/MultiSendContract_V1_4_1_Ethers' @@ -46,6 +48,8 @@ import { SafeProxyFactoryContract_v1_0_0_Abi } from '@safe-global/protocol-kit/c import { SafeProxyFactoryContract_v1_1_1_Abi } from '@safe-global/protocol-kit/contracts/AbiType/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1' import { SafeProxyFactoryContract_v1_3_0_Abi } from '@safe-global/protocol-kit/contracts/AbiType/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0' import { SafeProxyFactoryContract_v1_4_1_Abi } from '@safe-global/protocol-kit/contracts/AbiType/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1' +import { CreateCallContract_v1_4_1_Abi } from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/v1.4.1/CreateCallContract_v1_4_1' +import { CreateCallContract_v1_3_0_Abi } from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/v1.3.0/CreateCallContract_v1_3_0' export async function getSafeContractInstance( safeVersion: SafeVersion, @@ -306,22 +310,38 @@ export async function getSignMessageLibContractInstance( } } -export function getCreateCallContractInstance( +export async function getCreateCallContractInstance( safeVersion: SafeVersion, contractAddress: string, - signerOrProvider: AbstractSigner | Provider -): CreateCallContract_V1_4_1_Ethers | CreateCallContract_V1_3_0_Ethers { + ethersAdapter: EthersAdapter, + customContractAbi?: AbiItem | AbiItem[] | undefined +): Promise { + const chainId = await ethersAdapter.getChainId() let createCallContract switch (safeVersion) { case '1.4.1': - createCallContract = CreateCall_V1_4_1.connect(contractAddress, signerOrProvider) - return new CreateCallContract_V1_4_1_Ethers(createCallContract) + createCallContract = new CreateCallContract_V1_4_1_Ethers( + chainId, + ethersAdapter, + contractAddress, + customContractAbi as unknown as CreateCallContract_v1_4_1_Abi + ) + + // TODO: Remove this mapper after remove typechain + return createCallContract.mapToTypechainContract() case '1.3.0': case '1.2.0': case '1.1.1': case '1.0.0': - createCallContract = CreateCall_V1_3_0.connect(contractAddress, signerOrProvider) - return new CreateCallContract_V1_3_0_Ethers(createCallContract) + createCallContract = new CreateCallContract_V1_3_0_Ethers( + chainId, + ethersAdapter, + contractAddress, + customContractAbi as unknown as CreateCallContract_v1_3_0_Abi + ) + + // TODO: Remove this mapper after remove typechain + return createCallContract.mapToTypechainContract() default: throw new Error('Invalid Safe version') } diff --git a/packages/protocol-kit/src/adapters/ethers/index.ts b/packages/protocol-kit/src/adapters/ethers/index.ts index fa5ce35e2..d660a0d91 100644 --- a/packages/protocol-kit/src/adapters/ethers/index.ts +++ b/packages/protocol-kit/src/adapters/ethers/index.ts @@ -1,5 +1,5 @@ import EthersAdapter, { EthersAdapterConfig } from './EthersAdapter' -import CreateCallEthersContract from './contracts/CreateCall/CreateCallEthersContract' +import CreateCallBaseContractEthers from './contracts/CreateCall/CreateCallBaseContractEthers' import MultiSendBaseContractEthers from './contracts/MultiSend/MultiSendBaseContractEthers' import MultiSendCallOnlyBaseContractEthers from './contracts/MultiSend/MultiSendCallOnlyBaseContractEthers' import SafeContractEthers from './contracts/Safe/SafeContractEthers' @@ -8,7 +8,7 @@ import SignMessageLibBaseContractEthers from './contracts/SignMessageLib/SignMes import { EthersTransactionOptions, EthersTransactionResult } from './types' export { - CreateCallEthersContract, + CreateCallBaseContractEthers, EthersAdapter, EthersAdapterConfig, EthersTransactionOptions, diff --git a/packages/protocol-kit/src/index.ts b/packages/protocol-kit/src/index.ts index c6aef8148..bdccdde37 100644 --- a/packages/protocol-kit/src/index.ts +++ b/packages/protocol-kit/src/index.ts @@ -1,6 +1,6 @@ import Safe from './Safe' import { - CreateCallEthersContract, + CreateCallBaseContractEthers, EthersAdapter, EthersAdapterConfig, EthersTransactionOptions, @@ -103,7 +103,7 @@ export { ConnectSafeConfigWithSafeAddress, ContractManager, ContractNetworksConfig, - CreateCallEthersContract, + CreateCallBaseContractEthers, CreateCallWeb3Contract, createERC20TokenTransferTransaction, CreateTransactionProps, From a2f53f1021873cb09d8ed5489d115a8c5744d99a Mon Sep 17 00:00:00 2001 From: Tim Schwarz <4171783+tmjssz@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:11:01 +0000 Subject: [PATCH 6/8] Implement CreateCall contract for Web3.js --- .../src/adapters/web3/Web3Adapter.ts | 12 +- .../CreateCall/CreateCallWeb3Contract.ts | 61 -------- .../v1.3.0/CreateCallContract_V1_3_0_Web3.ts | 131 ++++++++++++++++++ .../CreateCallEthersContract_V1_3_0_Web3.ts | 10 -- .../v1.4.1/CreateCallContract_V1_4_1_Web3.ts | 131 ++++++++++++++++++ .../CreateCallEthersContract_V1_4_1_Web3.ts | 10 -- .../web3/contracts/contractInstancesWeb3.ts | 45 ++++-- .../protocol-kit/src/adapters/web3/index.ts | 4 +- packages/protocol-kit/src/index.ts | 4 +- 9 files changed, 305 insertions(+), 103 deletions(-) delete mode 100644 packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallWeb3Contract.ts create mode 100644 packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Web3.ts delete mode 100644 packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Web3.ts create mode 100644 packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Web3.ts delete mode 100644 packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Web3.ts diff --git a/packages/protocol-kit/src/adapters/web3/Web3Adapter.ts b/packages/protocol-kit/src/adapters/web3/Web3Adapter.ts index f7e1a6769..8bae0e3cd 100644 --- a/packages/protocol-kit/src/adapters/web3/Web3Adapter.ts +++ b/packages/protocol-kit/src/adapters/web3/Web3Adapter.ts @@ -6,7 +6,8 @@ import { EthAdapterTransaction, GetContractProps, SafeEIP712Args, - SignMessageLibContract + SignMessageLibContract, + CreateCallContract } from '@safe-global/safe-core-sdk-types' import Web3 from 'web3' import { Transaction } from 'web3-core' @@ -17,7 +18,6 @@ import { AbiItem } from 'web3-utils' // Migration guide https://docs.web3js.org/docs/guides/web3_migration_guide#types import type { JsonRPCResponse, Provider } from 'web3/providers' import CompatibilityFallbackHandlerWeb3Contract from './contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerWeb3Contract' -import CreateCallWeb3Contract from './contracts/CreateCall/CreateCallWeb3Contract' import SafeContractWeb3 from './contracts/Safe/SafeContractWeb3' import SimulateTxAccessorWeb3Contract from './contracts/SimulateTxAccessor/SimulateTxAccessorWeb3Contract' import { @@ -208,18 +208,14 @@ class Web3Adapter implements EthAdapter { singletonDeployment, customContractAddress, customContractAbi - }: GetContractProps): Promise { + }: GetContractProps): Promise { const chainId = await this.getChainId() const contractAddress = customContractAddress ?? singletonDeployment?.networkAddresses[chainId.toString()] if (!contractAddress) { throw new Error('Invalid CreateCall contract address') } - const createCallContract = this.getContract( - contractAddress, - customContractAbi ?? (singletonDeployment?.abi as AbiItem[]) - ) - return getCreateCallContractInstance(safeVersion, createCallContract) + return getCreateCallContractInstance(safeVersion, contractAddress, this, customContractAbi) } async getSimulateTxAccessorContract({ diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallWeb3Contract.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallWeb3Contract.ts deleted file mode 100644 index 54adbf12e..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/CreateCallWeb3Contract.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { - Web3TransactionOptions, - Web3TransactionResult -} from '@safe-global/protocol-kit/adapters/web3/types' -import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils' -import { Create_call as CreateCall_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Create_call' -import { Create_call as CreateCall_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Create_call' -import { CreateCallContract } from '@safe-global/safe-core-sdk-types' - -abstract class CreateCallWeb3Contract implements CreateCallContract { - constructor(public contract: CreateCall_V1_4_1 | CreateCall_V1_3_0) {} - - getAddress(): Promise { - return Promise.resolve(this.contract.options.address) - } - - async performCreate2( - value: string, - deploymentData: string, - salt: string, - options?: Web3TransactionOptions - ): Promise { - if (options && !options.gas) { - options.gas = await this.estimateGas('performCreate2', [value, deploymentData, salt], { - ...options - }) - } - const txResponse = this.contract.methods - .performCreate2(value, deploymentData, salt) - .send(options) - return toTxResult(txResponse, options) - } - - async performCreate( - value: string, - deploymentData: string, - options?: Web3TransactionOptions - ): Promise { - if (options && !options.gas) { - options.gas = await this.estimateGas('performCreate', [value, deploymentData], { ...options }) - } - const txResponse = this.contract.methods.performCreate(value, deploymentData).send(options) - return toTxResult(txResponse, options) - } - - encode(methodName: string, params: any[]): string { - return (this.contract as any).methods[methodName](...params).encodeABI() - } - - async estimateGas( - methodName: string, - params: any[], - options: Web3TransactionOptions - ): Promise { - return ( - await (this.contract.methods as any)[methodName](...params).estimateGas(options) - ).toString() - } -} - -export default CreateCallWeb3Contract diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Web3.ts new file mode 100644 index 000000000..3d3442b6b --- /dev/null +++ b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Web3.ts @@ -0,0 +1,131 @@ +import CreateCallBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/CreateCall/CreateCallBaseContractWeb3' +import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' +import { + DeepWriteable, + Web3TransactionOptions, + Web3TransactionResult +} from '@safe-global/protocol-kit/adapters/web3/types' +import CreateCallContract_v1_3_0_Contract, { + CreateCallContract_v1_3_0_Abi +} from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/v1.3.0/CreateCallContract_v1_3_0' +import CreateCall_1_3_0_ContractArtifacts from '@safe-global/protocol-kit/contracts/AbiType/assets/CreateCall/v1.3.0/create_call' +import { SafeVersion } from '@safe-global/safe-core-sdk-types' +import { + EncodeCreateCallFunction, + EstimateGasCreateCallFunction, + GetAddressCreateCallFunction +} from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/CreateCallBaseContract' +import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils' + +/** + * CreateCallContract_V1_3_0_Web3 is the implementation specific to the CreateCall contract version 1.3.0. + * + * This class specializes in handling interactions with the CreateCall contract version 1.3.0 using Web3.js. + * + * @extends CreateCallBaseContractWeb3 - Inherits from CreateCallBaseContractWeb3 with ABI specific to CreateCall contract version 1.3.0. + * @implements CreateCallContract_v1_3_0_Contract - Implements the interface specific to CreateCall contract version 1.3.0. + */ +class CreateCallContract_V1_3_0_Web3 + extends CreateCallBaseContractWeb3> + implements CreateCallContract_v1_3_0_Contract +{ + safeVersion: SafeVersion + + /** + * Constructs an instance of CreateCallContract_V1_3_0_Web3 + * + * @param chainId - The chain ID where the contract resides. + * @param web3Adapter - An instance of Web3Adapter. + * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the CreateCall deployments based on the chainId and safeVersion. + * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.3.0 is used. + */ + constructor( + chainId: bigint, + web3Adapter: Web3Adapter, + customContractAddress?: string, + customContractAbi?: CreateCallContract_v1_3_0_Abi + ) { + const safeVersion = '1.3.0' + const defaultAbi = + CreateCall_1_3_0_ContractArtifacts.abi as DeepWriteable + + super( + chainId, + web3Adapter, + defaultAbi, + safeVersion, + customContractAddress, + customContractAbi as DeepWriteable + ) + + this.safeVersion = safeVersion + } + + getAddress: GetAddressCreateCallFunction = () => { + return Promise.resolve(this.contract.options.address) + } + + encode: EncodeCreateCallFunction = (functionToEncode, args) => { + return this.contract.methods[functionToEncode](...args).encodeABI() + } + + estimateGas: EstimateGasCreateCallFunction< + CreateCallContract_v1_3_0_Abi, + Web3TransactionOptions + > = async (functionToEstimate, args, options = {}) => { + return ( + await this.contract.methods[functionToEstimate](...args).estimateGas(options) + ).toString() + } + + async performCreate( + args: readonly [value: bigint, deploymentData: string], + options?: Web3TransactionOptions + ): Promise { + if (options && !options.gas) { + options.gas = (await this.estimateGas('performCreate', args, { ...options })).toString() + } + const txResponse = this.contract.methods.performCreate(...args).send(options) + return toTxResult(txResponse, options) + } + + async performCreate2( + args: readonly [value: bigint, deploymentData: string, salt: string], + options?: Web3TransactionOptions + ): Promise { + if (options && !options.gas) { + options.gas = (await this.estimateGas('performCreate2', args, { ...options })).toString() + } + const txResponse = this.contract.methods.performCreate2(...args).send(options) + return toTxResult(txResponse, options) + } + + // TODO: Remove this mapper after remove Typechain + mapToTypechainContract(): any { + return { + contract: this.contract, + + getAddress: this.getAddress.bind(this), + + encode: this.encode.bind(this), + + estimateGas: async (...args: Parameters) => + (await this.estimateGas(...args)).toString(), + + performCreate: async ( + value: string, + deploymentData: string, + options?: Web3TransactionOptions + ) => this.performCreate([BigInt(value), deploymentData], options), + + performCreate2: async ( + value: string, + deploymentData: string, + salt: string, + options?: Web3TransactionOptions + ) => this.performCreate2([BigInt(value), deploymentData, salt], options) + } + } +} + +export default CreateCallContract_V1_3_0_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Web3.ts deleted file mode 100644 index c5a3fce5e..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Web3.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Create_call as CreateCall } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Create_call' -import CreateCallWeb3Contract from '../CreateCallWeb3Contract' - -class CreateCallContract_V1_3_0_Web3 extends CreateCallWeb3Contract { - constructor(public contract: CreateCall) { - super(contract) - } -} - -export default CreateCallContract_V1_3_0_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Web3.ts new file mode 100644 index 000000000..ce962ad63 --- /dev/null +++ b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Web3.ts @@ -0,0 +1,131 @@ +import CreateCallBaseContractWeb3 from '@safe-global/protocol-kit/adapters/web3/contracts/CreateCall/CreateCallBaseContractWeb3' +import Web3Adapter from '@safe-global/protocol-kit/adapters/web3/Web3Adapter' +import { + DeepWriteable, + Web3TransactionOptions, + Web3TransactionResult +} from '@safe-global/protocol-kit/adapters/web3/types' +import CreateCallContract_v1_4_1_Contract, { + CreateCallContract_v1_4_1_Abi +} from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/v1.4.1/CreateCallContract_v1_4_1' +import CreateCall_1_4_1_ContractArtifacts from '@safe-global/protocol-kit/contracts/AbiType/assets/CreateCall/v1.4.1/create_call' +import { SafeVersion } from '@safe-global/safe-core-sdk-types' +import { + EncodeCreateCallFunction, + EstimateGasCreateCallFunction, + GetAddressCreateCallFunction +} from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/CreateCallBaseContract' +import { toTxResult } from '@safe-global/protocol-kit/adapters/web3/utils' + +/** + * CreateCallContract_V1_4_1_Web3 is the implementation specific to the CreateCall contract version 1.4.1. + * + * This class specializes in handling interactions with the CreateCall contract version 1.4.1 using Web3.js. + * + * @extends CreateCallBaseContractWeb3 - Inherits from CreateCallBaseContractWeb3 with ABI specific to CreateCall contract version 1.4.1. + * @implements CreateCallContract_v1_4_1_Contract - Implements the interface specific to CreateCall contract version 1.4.1. + */ +class CreateCallContract_V1_4_1_Web3 + extends CreateCallBaseContractWeb3> + implements CreateCallContract_v1_4_1_Contract +{ + safeVersion: SafeVersion + + /** + * Constructs an instance of CreateCallContract_V1_4_1_Web3 + * + * @param chainId - The chain ID where the contract resides. + * @param web3Adapter - An instance of Web3Adapter. + * @param customContractAddress - Optional custom address for the contract. If not provided, the address is derived from the CreateCall deployments based on the chainId and safeVersion. + * @param customContractAbi - Optional custom ABI for the contract. If not provided, the default ABI for version 1.4.1 is used. + */ + constructor( + chainId: bigint, + web3Adapter: Web3Adapter, + customContractAddress?: string, + customContractAbi?: CreateCallContract_v1_4_1_Abi + ) { + const safeVersion = '1.4.1' + const defaultAbi = + CreateCall_1_4_1_ContractArtifacts.abi as DeepWriteable + + super( + chainId, + web3Adapter, + defaultAbi, + safeVersion, + customContractAddress, + customContractAbi as DeepWriteable + ) + + this.safeVersion = safeVersion + } + + getAddress: GetAddressCreateCallFunction = () => { + return Promise.resolve(this.contract.options.address) + } + + encode: EncodeCreateCallFunction = (functionToEncode, args) => { + return this.contract.methods[functionToEncode](...args).encodeABI() + } + + estimateGas: EstimateGasCreateCallFunction< + CreateCallContract_v1_4_1_Abi, + Web3TransactionOptions + > = async (functionToEstimate, args, options = {}) => { + return ( + await this.contract.methods[functionToEstimate](...args).estimateGas(options) + ).toString() + } + + async performCreate( + args: readonly [value: bigint, deploymentData: string], + options?: Web3TransactionOptions + ): Promise { + if (options && !options.gas) { + options.gas = (await this.estimateGas('performCreate', args, { ...options })).toString() + } + const txResponse = this.contract.methods.performCreate(...args).send(options) + return toTxResult(txResponse, options) + } + + async performCreate2( + args: readonly [value: bigint, deploymentData: string, salt: string], + options?: Web3TransactionOptions + ): Promise { + if (options && !options.gas) { + options.gas = (await this.estimateGas('performCreate2', args, { ...options })).toString() + } + const txResponse = this.contract.methods.performCreate2(...args).send(options) + return toTxResult(txResponse, options) + } + + // TODO: Remove this mapper after remove Typechain + mapToTypechainContract(): any { + return { + contract: this.contract, + + getAddress: this.getAddress.bind(this), + + encode: this.encode.bind(this), + + estimateGas: async (...args: Parameters) => + (await this.estimateGas(...args)).toString(), + + performCreate: async ( + value: string, + deploymentData: string, + options?: Web3TransactionOptions + ) => this.performCreate([BigInt(value), deploymentData], options), + + performCreate2: async ( + value: string, + deploymentData: string, + salt: string, + options?: Web3TransactionOptions + ) => this.performCreate2([BigInt(value), deploymentData, salt], options) + } + } +} + +export default CreateCallContract_V1_4_1_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Web3.ts deleted file mode 100644 index 78032edb1..000000000 --- a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Web3.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Create_call as CreateCall } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Create_call' -import CreateCallWeb3Contract from '../CreateCallWeb3Contract' - -class CreateCallContract_V1_4_1_Web3 extends CreateCallWeb3Contract { - constructor(public contract: CreateCall) { - super(contract) - } -} - -export default CreateCallContract_V1_4_1_Web3 diff --git a/packages/protocol-kit/src/adapters/web3/contracts/contractInstancesWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/contractInstancesWeb3.ts index 46437b3ff..ceb2fe63f 100644 --- a/packages/protocol-kit/src/adapters/web3/contracts/contractInstancesWeb3.ts +++ b/packages/protocol-kit/src/adapters/web3/contracts/contractInstancesWeb3.ts @@ -19,16 +19,18 @@ import { SafeProxyFactoryContract_v1_1_1_Abi } from '@safe-global/protocol-kit/c import { SafeProxyFactoryContract_v1_3_0_Abi } from '@safe-global/protocol-kit/contracts/AbiType/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0' import { SafeProxyFactoryContract_v1_4_1_Abi } from '@safe-global/protocol-kit/contracts/AbiType/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1' import { Compatibility_fallback_handler as CompatibilityFallbackHandler_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Compatibility_fallback_handler' -import { Create_call as CreateCall_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Create_call' import { Simulate_tx_accessor as SimulateTxAccessor_V1_3_0 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.3.0/Simulate_tx_accessor' import { Compatibility_fallback_handler as CompatibilityFallbackHandler_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Compatibility_fallback_handler' -import { Create_call as CreateCall_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Create_call' import { Simulate_tx_accessor as SimulateTxAccessor_V1_4_1 } from '@safe-global/protocol-kit/typechain/src/web3-v1/v1.4.1/Simulate_tx_accessor' -import { SafeVersion, SignMessageLibContract } from '@safe-global/safe-core-sdk-types' +import { + CreateCallContract, + SafeVersion, + SignMessageLibContract +} from '@safe-global/safe-core-sdk-types' import CompatibilityFallbackHandler_V1_3_0_Web3 from './CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Web3' import CompatibilityFallbackHandler_V1_4_1_Web3 from './CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Web3' -import CreateCallContract_V1_3_0_Web3 from './CreateCall/v1.3.0/CreateCallEthersContract_V1_3_0_Web3' -import CreateCallContract_V1_4_1_Web3 from './CreateCall/v1.4.1/CreateCallEthersContract_V1_4_1_Web3' +import CreateCallContract_V1_3_0_Web3 from './CreateCall/v1.3.0/CreateCallContract_V1_3_0_Web3' +import CreateCallContract_V1_4_1_Web3 from './CreateCall/v1.4.1/CreateCallContract_V1_4_1_Web3' import MultiSendContract_V1_1_1_Web3 from './MultiSend/v1.1.1/MultiSendContract_V1_1_1_Web3' import MultiSendContract_V1_3_0_Web3 from './MultiSend/v1.3.0/MultiSendContract_V1_3_0_Web3' import MultiSendContract_V1_4_1_Web3 from './MultiSend/v1.4.1/MultiSendContract_V1_4_1_Web3' @@ -45,6 +47,8 @@ import { MultiSendCallOnlyContract_v1_3_0_Abi as MultiSendCallOnlyContract_v1_3_ import { MultiSendCallOnlyContract_v1_4_1_Abi as MultiSendCallOnlyContract_v1_4_1_Abi_Readonly } from '@safe-global/protocol-kit/contracts/AbiType/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1' import { SignMessageLibContract_v1_4_1_Abi as SignMessageLibContract_v1_4_1_Abi_Readonly } from '@safe-global/protocol-kit/contracts/AbiType/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1' import { SignMessageLibContract_v1_3_0_Abi as SignMessageLibContract_v1_3_0_Abi_Readonly } from '@safe-global/protocol-kit/contracts/AbiType/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0' +import { CreateCallContract_v1_4_1_Abi } from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/v1.4.1/CreateCallContract_v1_4_1' +import { CreateCallContract_v1_3_0_Abi } from '@safe-global/protocol-kit/contracts/AbiType/CreateCall/v1.3.0/CreateCallContract_v1_3_0' import { DeepWriteable } from '../types' type MultiSendContract_v1_1_1_Abi = DeepWriteable @@ -305,18 +309,39 @@ export async function getSignMessageLibContractInstance( } } -export function getCreateCallContractInstance( +export async function getCreateCallContractInstance( safeVersion: SafeVersion, - createCallContract: CreateCall_V1_4_1 | CreateCall_V1_3_0 -): CreateCallContract_V1_4_1_Web3 | CreateCallContract_V1_3_0_Web3 { + contractAddress: string, + web3Adapter: Web3Adapter, + customContractAbi?: AbiItem | AbiItem[] | undefined +): Promise { + const chainId = await web3Adapter.getChainId() + let createCallContract + switch (safeVersion) { case '1.4.1': - return new CreateCallContract_V1_4_1_Web3(createCallContract as CreateCall_V1_4_1) + createCallContract = new CreateCallContract_V1_4_1_Web3( + chainId, + web3Adapter, + contractAddress, + customContractAbi as unknown as CreateCallContract_v1_4_1_Abi + ) + + // TODO: Remove this mapper after remove typechain + return createCallContract.mapToTypechainContract() case '1.3.0': case '1.2.0': case '1.1.1': case '1.0.0': - return new CreateCallContract_V1_3_0_Web3(createCallContract as CreateCall_V1_3_0) + createCallContract = new CreateCallContract_V1_3_0_Web3( + chainId, + web3Adapter, + contractAddress, + customContractAbi as unknown as CreateCallContract_v1_3_0_Abi + ) + + // TODO: Remove this mapper after remove typechain + return createCallContract.mapToTypechainContract() default: throw new Error('Invalid Safe version') } diff --git a/packages/protocol-kit/src/adapters/web3/index.ts b/packages/protocol-kit/src/adapters/web3/index.ts index 5c185c070..8318273e0 100644 --- a/packages/protocol-kit/src/adapters/web3/index.ts +++ b/packages/protocol-kit/src/adapters/web3/index.ts @@ -1,5 +1,5 @@ import Web3Adapter, { Web3AdapterConfig } from './Web3Adapter' -import CreateCallWeb3Contract from './contracts/CreateCall/CreateCallWeb3Contract' +import CreateCallBaseContractWeb3 from './contracts/CreateCall/CreateCallBaseContractWeb3' import MultiSendBaseContractWeb3 from './contracts/MultiSend/MultiSendBaseContractWeb3' import MultiSendCallOnlyBaseContractWeb3 from './contracts/MultiSend/MultiSendCallOnlyBaseContractWeb3' import SafeContractWeb3 from './contracts/Safe/SafeContractWeb3' @@ -8,7 +8,7 @@ import SignMessageLibBaseContractWeb3 from './contracts/SignMessageLib/SignMessa import { Web3TransactionOptions, Web3TransactionResult } from './types' export { - CreateCallWeb3Contract, + CreateCallBaseContractWeb3, MultiSendCallOnlyBaseContractWeb3, MultiSendBaseContractWeb3, SafeContractWeb3, diff --git a/packages/protocol-kit/src/index.ts b/packages/protocol-kit/src/index.ts index bdccdde37..ee900d9c7 100644 --- a/packages/protocol-kit/src/index.ts +++ b/packages/protocol-kit/src/index.ts @@ -12,7 +12,7 @@ import { SignMessageLibBaseContractEthers } from './adapters/ethers' import { - CreateCallWeb3Contract, + CreateCallBaseContractWeb3, MultiSendBaseContractWeb3, MultiSendCallOnlyBaseContractWeb3, SafeContractWeb3, @@ -104,7 +104,7 @@ export { ContractManager, ContractNetworksConfig, CreateCallBaseContractEthers, - CreateCallWeb3Contract, + CreateCallBaseContractWeb3, createERC20TokenTransferTransaction, CreateTransactionProps, DEFAULT_SAFE_VERSION, From 1c3fddbc04b14f04b00bebaa5087816347873e53 Mon Sep 17 00:00:00 2001 From: Tim Schwarz <4171783+tmjssz@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:11:32 +0000 Subject: [PATCH 7/8] Remove CreateCall contract from typechain generation script --- packages/protocol-kit/scripts/generateTypechainFiles.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/protocol-kit/scripts/generateTypechainFiles.ts b/packages/protocol-kit/scripts/generateTypechainFiles.ts index 916dc2749..d6c767089 100644 --- a/packages/protocol-kit/scripts/generateTypechainFiles.ts +++ b/packages/protocol-kit/scripts/generateTypechainFiles.ts @@ -17,12 +17,10 @@ const safeContractsPath = '../../node_modules/@safe-global/safe-deployments/dist const safeContracts_V1_4_1 = [ `${safeContractsPath}/v1.4.1/compatibility_fallback_handler.json`, - `${safeContractsPath}/v1.4.1/create_call.json`, `${safeContractsPath}/v1.4.1/simulate_tx_accessor.json` ].join(' ') const safeContracts_V1_3_0 = [ `${safeContractsPath}/v1.3.0/compatibility_fallback_handler.json`, - `${safeContractsPath}/v1.3.0/create_call.json`, `${safeContractsPath}/v1.3.0/simulate_tx_accessor.json` ].join(' ') From bfeb244d4901258d7c7c174c5063c2a34db19eaf Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Wed, 27 Mar 2024 14:19:07 +0100 Subject: [PATCH 8/8] rename version to lowercase --- ...t_V1_3_0_Ethers.ts => CreateCallContract_v1_3_0_Ethers.ts} | 0 ...t_V1_4_1_Ethers.ts => CreateCallContract_v1_4_1_Ethers.ts} | 0 .../src/adapters/ethers/contracts/contractInstancesEthers.ts | 4 ++-- ...tract_V1_3_0_Web3.ts => CreateCallContract_v1_3_0_Web3.ts} | 0 ...tract_V1_4_1_Web3.ts => CreateCallContract_v1_4_1_Web3.ts} | 0 .../src/adapters/web3/contracts/contractInstancesWeb3.ts | 4 ++-- 6 files changed, 4 insertions(+), 4 deletions(-) rename packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/{CreateCallContract_V1_3_0_Ethers.ts => CreateCallContract_v1_3_0_Ethers.ts} (100%) rename packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/{CreateCallContract_V1_4_1_Ethers.ts => CreateCallContract_v1_4_1_Ethers.ts} (100%) rename packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/{CreateCallContract_V1_3_0_Web3.ts => CreateCallContract_v1_3_0_Web3.ts} (100%) rename packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/{CreateCallContract_V1_4_1_Web3.ts => CreateCallContract_v1_4_1_Web3.ts} (100%) diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Ethers.ts similarity index 100% rename from packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Ethers.ts rename to packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Ethers.ts diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Ethers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Ethers.ts similarity index 100% rename from packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Ethers.ts rename to packages/protocol-kit/src/adapters/ethers/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Ethers.ts diff --git a/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts b/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts index adfa68e4f..2280320f4 100644 --- a/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts +++ b/packages/protocol-kit/src/adapters/ethers/contracts/contractInstancesEthers.ts @@ -11,8 +11,8 @@ import { } from '@safe-global/safe-core-sdk-types' import CompatibilityFallbackHandler_V1_3_0_Ethers from './CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Ethers' import CompatibilityFallbackHandler_V1_4_1_Ethers from './CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Ethers' -import CreateCallContract_V1_3_0_Ethers from './CreateCall/v1.3.0/CreateCallContract_V1_3_0_Ethers' -import CreateCallContract_V1_4_1_Ethers from './CreateCall/v1.4.1/CreateCallContract_V1_4_1_Ethers' +import CreateCallContract_V1_3_0_Ethers from './CreateCall/v1.3.0/CreateCallContract_v1_3_0_Ethers' +import CreateCallContract_V1_4_1_Ethers from './CreateCall/v1.4.1/CreateCallContract_v1_4_1_Ethers' import MultiSendContract_V1_1_1_Ethers from './MultiSend/v1.1.1/MultiSendContract_V1_1_1_Ethers' import MultiSendContract_V1_3_0_Ethers from './MultiSend/v1.3.0/MultiSendContract_V1_3_0_Ethers' import MultiSendContract_V1_4_1_Ethers from './MultiSend/v1.4.1/MultiSendContract_V1_4_1_Ethers' diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Web3.ts similarity index 100% rename from packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_V1_3_0_Web3.ts rename to packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0_Web3.ts diff --git a/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Web3.ts b/packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Web3.ts similarity index 100% rename from packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_V1_4_1_Web3.ts rename to packages/protocol-kit/src/adapters/web3/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1_Web3.ts diff --git a/packages/protocol-kit/src/adapters/web3/contracts/contractInstancesWeb3.ts b/packages/protocol-kit/src/adapters/web3/contracts/contractInstancesWeb3.ts index ceb2fe63f..187a5e36b 100644 --- a/packages/protocol-kit/src/adapters/web3/contracts/contractInstancesWeb3.ts +++ b/packages/protocol-kit/src/adapters/web3/contracts/contractInstancesWeb3.ts @@ -29,8 +29,8 @@ import { } from '@safe-global/safe-core-sdk-types' import CompatibilityFallbackHandler_V1_3_0_Web3 from './CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandler_V1_3_0_Web3' import CompatibilityFallbackHandler_V1_4_1_Web3 from './CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandler_V1_4_1_Web3' -import CreateCallContract_V1_3_0_Web3 from './CreateCall/v1.3.0/CreateCallContract_V1_3_0_Web3' -import CreateCallContract_V1_4_1_Web3 from './CreateCall/v1.4.1/CreateCallContract_V1_4_1_Web3' +import CreateCallContract_V1_3_0_Web3 from './CreateCall/v1.3.0/CreateCallContract_v1_3_0_Web3' +import CreateCallContract_V1_4_1_Web3 from './CreateCall/v1.4.1/CreateCallContract_v1_4_1_Web3' import MultiSendContract_V1_1_1_Web3 from './MultiSend/v1.1.1/MultiSendContract_V1_1_1_Web3' import MultiSendContract_V1_3_0_Web3 from './MultiSend/v1.3.0/MultiSendContract_V1_3_0_Web3' import MultiSendContract_V1_4_1_Web3 from './MultiSend/v1.4.1/MultiSendContract_V1_4_1_Web3'