Skip to content

Commit

Permalink
Changed variable names;
Browse files Browse the repository at this point in the history
Improved output to user.
  • Loading branch information
- committed Jul 22, 2024
1 parent 4efd99a commit e2d486f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion scripts/keyless-deploy-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ const deployKeylessly = async (contractName, bytecodeWithArgs, gasLimit, wallet,

// const txHash = await ethers.provider.send(`eth_sendRawTransaction`, [txSignedSerialized])
const txResponse = await ethers.provider.broadcastTransaction(txSignedSerialized)
await txResponse.wait()
console.log(`txResponse: ${JSON.stringify(txResponse, null, 2)}`)
const txReceipt = await txResponse.wait()
console.log(`txReceipt: ${JSON.stringify(txReceipt, null, 2)}`)

if (await ethers.provider.getCode(addressExpected) !== `0x`) console.log(`${contractName} contract was successfully deployed to ${addressExpected} in transaction ${txResponse.hash}`)
else console.error(`${contractName} contract was not found at ${addressExpected}`)
Expand Down
15 changes: 9 additions & 6 deletions scripts/upgrade-TESTERC20UG.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,33 @@ async function main() {
const [wallet, wallet2] = await ethers.getSigners()
console.log(`Using network: ${network.name} (${network.config.chainId}), account: ${wallet.address} having ${await printNativeCurrencyBalance(wallet.address)} of native currency, RPC url: ${network.config.url}`)

const tokenContractName = `TESTERC20UGv1`
const implContractName = `TESTERC20UGv1`
const contractAddress = `0x18Fb2C4870cC1B9f9440CB0D87c41b25D486A062` // ERC1967Proxy address

const contract = await ethers.getContractAt(tokenContractName, contractAddress)
const contract = await ethers.getContractAt(implContractName, contractAddress)

// await contract.initialize(...constructorArgsOfToken) // 'Initializable: contract is already initialized'

console.log(`V: ${await contract.getV()}`)

// Upgrading
const tokenContractNameV2 = `TESTERC20UGv2`
const cfTokenV2 = await ethers.getContractFactory(tokenContractNameV2)

await upgrades.validateUpgrade(contract, cfTokenV2)
const implContractNameV2 = `TESTERC20UGv2`
const cfTokenV2 = await ethers.getContractFactory(implContractNameV2)

let implAddress = await upgrades.erc1967.getImplementationAddress(contractAddress)
console.log(`Old implementation address: ${implAddress}`)

await upgrades.validateUpgrade(contract, cfTokenV2)
console.log(`validation of upgrade to ${implContractNameV2} was successful. Now upgrading...`)

const upgraded = await upgrades.upgradeProxy(contractAddress, cfTokenV2)
console.log(`Upgraded V: ${await upgraded.getV()}`)

implAddress = await upgrades.erc1967.getImplementationAddress(contractAddress)
console.log(`New implementation address: ${implAddress}`)

console.log(`Continue to use the proxy address ${contractAddress} to operate with your contract`)


// VERIFY ON BLOCKCHAIN EXPLORER
if (![`hardhat`, `localhost`].includes(network.name)) {
Expand Down

0 comments on commit e2d486f

Please sign in to comment.