Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Web3 tests #148

Merged
merged 8 commits into from
Jan 19, 2022
Merged
Prev Previous commit
Next Next commit
Add ABI properties to ContractNetworkConfig
  • Loading branch information
germartinez committed Jan 18, 2022
commit bbbc0803f479189b5c351807d86fdd31c3c69311
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContractTransaction, Event } from '@ethersproject/contracts'
import { Event } from '@ethersproject/contracts'
import { ProxyFactory as ProxyFactory_V1_1_1 } from '../../../typechain/src/ethers-v5/v1.1.1/ProxyFactory'
import { ProxyFactory as ProxyFactory_V1_3_0 } from '../../../typechain/src/ethers-v5/v1.3.0/ProxyFactory'
import GnosisSafeProxyFactoryContract, { CreateProxyProps } from './GnosisSafeProxyFactoryContract'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PromiEvent, TransactionReceipt } from 'web3-core/types'
import { TransactionReceipt } from 'web3-core/types'
import { ProxyFactory as ProxyFactory_V1_1_1 } from '../../../typechain/src/web3-v1/v1.1.1/proxy_factory'
import { ProxyFactory as ProxyFactory_V1_3_0 } from '../../../typechain/src/web3-v1/v1.3.0/proxy_factory'
import GnosisSafeProxyFactoryContract, { CreateProxyProps } from './GnosisSafeProxyFactoryContract'
Expand Down
17 changes: 10 additions & 7 deletions packages/safe-core-sdk/src/managers/contractManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,39 @@ class ContractManager {
contractNetworks
}: SafeConfig): Promise<void> {
const chainId = await ethAdapter.getChainId()
const customContracts = contractNetworks?.[chainId]
this.#contractNetworks = contractNetworks
const temporarySafeContract = ethAdapter.getSafeContract({
safeVersion: SAFE_LAST_VERSION,
chainId,
isL1SafeMasterCopy,
customContractAddress: safeAddress
customContractAddress: safeAddress,
customContractAbi: customContracts?.safeMasterCopyAbi
})
if ((await ethAdapter.getContractCode(temporarySafeContract.getAddress())) === '0x') {
throw new Error('Safe Proxy contract is not deployed in the current network')
}
const safeVersion = (await temporarySafeContract.getVersion()) as SafeVersion

const customContracts = contractNetworks?.[chainId]
this.#contractNetworks = contractNetworks
this.#isL1SafeMasterCopy = isL1SafeMasterCopy
const safeContract = ethAdapter.getSafeContract({
safeVersion,
chainId,
isL1SafeMasterCopy,
customContractAddress: safeAddress
customContractAddress: safeAddress,
customContractAbi: customContracts?.safeMasterCopyAbi
})
if ((await ethAdapter.getContractCode(safeContract.getAddress())) === '0x') {
throw new Error('Safe Proxy contract is not deployed in the current network')
}
this.#safeContract = safeContract

const multiSendContract = await ethAdapter.getMultiSendContract(
const multiSendContract = await ethAdapter.getMultiSendContract({
safeVersion,
chainId,
customContracts?.multiSendAddress
)
customContractAddress: customContracts?.multiSendAddress,
customContractAbi: customContracts?.multiSendAbi
})
if ((await ethAdapter.getContractCode(multiSendContract.getAddress())) === '0x') {
throw new Error('Multi Send contract is not deployed in the current network')
}
Expand Down
12 changes: 7 additions & 5 deletions packages/safe-core-sdk/src/safeFactory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ class SafeFactory {
this.#contractNetworks = contractNetworks
const chainId = await this.#ethAdapter.getChainId()
const customContracts = contractNetworks?.[chainId]
const safeProxyFactoryContract = await ethAdapter.getSafeProxyFactoryContract(
this.#safeVersion,
const safeProxyFactoryContract = await ethAdapter.getSafeProxyFactoryContract({
safeVersion: this.#safeVersion,
chainId,
customContracts?.safeProxyFactoryAddress
)
customContractAddress: customContracts?.safeProxyFactoryAddress,
customContractAbi: customContracts?.safeProxyFactoryAbi
})
if ((await this.#ethAdapter.getContractCode(safeProxyFactoryContract.getAddress())) === '0x') {
throw new Error('Safe Proxy Factory contract is not deployed in the current network')
}
Expand All @@ -89,7 +90,8 @@ class SafeFactory {
safeVersion: this.#safeVersion,
chainId,
isL1SafeMasterCopy,
customContractAddress: customContracts?.safeMasterCopyAddress
customContractAddress: customContracts?.safeMasterCopyAddress,
customContractAbi: customContracts?.safeMasterCopyAbi
})
if ((await this.#ethAdapter.getContractCode(gnosisSafeContract.getAddress())) === '0x') {
throw new Error('Safe Proxy contract is not deployed in the current network')
Expand Down
6 changes: 6 additions & 0 deletions packages/safe-core-sdk/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ export interface AbiItem {
export interface ContractNetworkConfig {
/** multiSendAddress - Address of the MultiSend contract deployed on a specific network */
multiSendAddress: string
/** multiSendAbi - Abi of the MultiSend contract deployed on a specific network */
multiSendAbi?: AbiItem[]
/** safeMasterCopyAddress - Address of the Gnosis Safe Master Copy contract deployed on a specific network */
safeMasterCopyAddress: string
/** safeMasterCopyAbi - Abi of the Gnosis Safe Master Copy contract deployed on a specific network */
safeMasterCopyAbi?: AbiItem[]
/** safeProxyFactoryAddress - Address of the Gnosis Safe Proxy Factory contract deployed on a specific network */
safeProxyFactoryAddress: string
/** safeProxyFactoryAbi - Abi of the Gnosis Safe Proxy Factory contract deployed on a specific network */
safeProxyFactoryAbi?: AbiItem[]
}

export interface ContractNetworksConfig {
Expand Down