Skip to content

Commit

Permalink
Improve BaseContract logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yagopv committed Sep 24, 2024
1 parent aa9c1e6 commit fc42f97
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/protocol-kit/src/contracts/BaseContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class BaseContract<ContractAbiType extends Abi> {
) {
const deployment = getContractDeployment(safeVersion, chainId, contractName)

let contractAddress = customContractAddress || deployment?.networkAddresses[chainId.toString()]
const contractAddress =
customContractAddress || deployment?.networkAddresses[chainId.toString()]

if (!contractAddress) {
throw new Error(`Invalid ${contractName.replace('Version', '')} contract address`)
Expand All @@ -78,15 +79,13 @@ class BaseContract<ContractAbiType extends Abi> {
? deployment?.deployments[safeProvider.deploymentType]?.address
: undefined

contractAddress =
Array.isArray(contractAddress) && contractAddress.length
? contractAddress.find((a) => a === customDeploymentTypeAddress) || contractAddress[0]
: contractAddress.toString()

this.chainId = chainId
this.contractName = contractName
this.safeVersion = safeVersion
this.contractAddress = contractAddress
this.contractAddress =
Array.isArray(contractAddress) && contractAddress.length
? contractAddress.find((a) => a === customDeploymentTypeAddress) || contractAddress[0]
: contractAddress.toString()

this.contractAbi =
customContractAbi ||
Expand Down

0 comments on commit fc42f97

Please sign in to comment.