Skip to content

Commit

Permalink
fix circular dependency issue caused by isContractDeployed:
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-goldman committed Dec 4, 2022
1 parent 38c62b5 commit 2652df5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-dragons-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chugsplash/core': patch
---

Fixes circular dependency issue caused by `isContractDeployed`
7 changes: 5 additions & 2 deletions packages/core/src/fund.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { OWNER_BOND_AMOUNT } from '@chugsplash/contracts'
import { ethers } from 'ethers'

import { getChugSplashManagerReadOnly, getDefaultProxyAddress } from './utils'
import {
getChugSplashManagerReadOnly,
getDefaultProxyAddress,
isContractDeployed,
} from './utils'
import {
ChugSplashActionBundle,
DeployImplementationAction,
Expand All @@ -10,7 +14,6 @@ import {
isSetImplementationAction,
isSetStorageAction,
} from './actions'
import { isContractDeployed } from './languages'
import { EXECUTION_BUFFER_MULTIPLIER } from './constants'

/**
Expand Down
15 changes: 6 additions & 9 deletions packages/core/src/languages/solidity/predeploys.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'assert'

import { ethers } from 'ethers'
import { Provider } from '@ethersproject/abstract-provider'
import {
OWNER_BOND_AMOUNT,
EXECUTOR_BOND_AMOUNT,
Expand Down Expand Up @@ -29,7 +28,12 @@ import {
import { Logger } from '@eth-optimism/common-ts'
import { sleep } from '@eth-optimism/core-utils'

import { getChugSplashRegistry, getProxyAt, getProxyAdmin } from '../../utils'
import {
getChugSplashRegistry,
getProxyAt,
getProxyAdmin,
isContractDeployed,
} from '../../utils'

export const initializeChugSplash = async (
provider: ethers.providers.JsonRpcProvider,
Expand Down Expand Up @@ -280,13 +284,6 @@ export const doDeterministicDeploy = async (
return new ethers.Contract(address, options.contract.abi, options.signer)
}

export const isContractDeployed = async (
address: string,
provider: Provider
): Promise<boolean> => {
return (await provider.getCode(address)) !== '0x'
}

export const monitorChugSplashSetup = async (
provider: ethers.providers.JsonRpcProvider
) => {
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {

import { ParsedChugSplashConfig } from './config'
import { ChugSplashActionBundle, ChugSplashActionType } from './actions'
import { isContractDeployed } from './languages'

export const computeBundleId = (
bundleRoot: string,
Expand Down Expand Up @@ -341,3 +340,10 @@ export const isProposer = async (
const ChugSplashManager = getChugSplashManagerReadOnly(provider, projectName)
return ChugSplashManager.proposers(address)
}

export const isContractDeployed = async (
address: string,
provider: providers.Provider
): Promise<boolean> => {
return (await provider.getCode(address)) !== '0x'
}

0 comments on commit 2652df5

Please sign in to comment.