MCPcopy Create free account
hub / github.com/chainjet/platform / deployUpgradeableContract

Function deployUpgradeableContract

scripts/deploy.utils.ts:4–22  ·  view source on GitHub ↗
(
  contractName: string,
  proxyAddress?: string,
  initializeArgs: any[] = [],
)

Source from the content-addressed store, hash-verified

2import { ethers, upgrades } from 'hardhat'
3
4export async function deployUpgradeableContract<T extends Contract>(
5 contractName: string,
6 proxyAddress?: string,
7 initializeArgs: any[] = [],
8): Promise<T> {
9 const ContractFactory = await ethers.getContractFactory(contractName)
10
11 let proxy: T
12 if (proxyAddress) {
13 proxy = (await upgrades.upgradeProxy(proxyAddress, ContractFactory, { timeout: 1000 * 60 * 60 })) as T
14 } else {
15 proxy = (await upgrades.deployProxy(ContractFactory, initializeArgs, { timeout: 1000 * 60 * 60 })) as T
16 }
17
18 await proxy.deployed()
19 console.log(`${contractName} deployed to:`, proxy.address)
20
21 return proxy
22}

Callers 1

mainFunction · 0.90

Calls 1

logMethod · 0.80

Tested by

no test coverage detected