Skip to content

Commit

Permalink
Fix Gateway & Registry Diamond Upgrade script (#780)
Browse files Browse the repository at this point in the history
- use updated config format for ganache test net and use isolated port to avoid collisions
- quiet down ganache logging
  • Loading branch information
snissn authored Mar 13, 2024
1 parent d28073b commit e7fdce2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions contracts/scripts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const fs = require('fs')

export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'

const isolatedPort = 18678

export async function deployContractWithDeployer(
deployer: SignerWithAddress,
contractName: string,
Expand Down Expand Up @@ -89,9 +91,11 @@ export async function getFacets(diamondAddress: string): Promise<FacetMap> {
async function startGanache() {
return new Promise((resolve, reject) => {
const server = ganache.server({
gasPrice: '0x0', // Set gas price to 0
miner: { defaultGasPrice: '0x0' },
chain: { hardfork: 'berlin' },
logging: { quiet: true },
})
server.listen(8545, (err) => {
server.listen(isolatedPort, (err) => {
if (err) reject(err)
else resolve(server)
})
Expand All @@ -114,16 +118,16 @@ export async function getRuntimeBytecode(bytecode) {
}
const ganacheServer = await startGanache()

const provider = new providers.JsonRpcProvider('http://127.0.0.1:8545')
const provider = new providers.JsonRpcProvider(
`http://127.0.0.1:${isolatedPort}`,
)
const wallet = new Wallet(process.env.PRIVATE_KEY, provider)
const contractFactory = new ContractFactory([], bytecode, wallet)
const contract = await contractFactory.deploy()
const contract = await contractFactory.deploy({ gasPrice: 0 })
await contract.deployed()

const runtimeBytecode = await provider.getCode(contract.address)

await stopGanache(ganacheServer)

stopGanache(ganacheServer)
return runtimeBytecode
}

Expand Down

0 comments on commit e7fdce2

Please sign in to comment.