From 5184b9166cf6a87c47790c0b06b0d82413a5c37c Mon Sep 17 00:00:00 2001 From: Juuso Takalainen Date: Thu, 30 May 2024 12:58:41 +0300 Subject: [PATCH] fix: deploy scripts updated to ethers v6 also deployed DATAv2 to Peaq chain --- scripts/deploy-1-datav2.js | 12 +++++++----- scripts/deploy-2-migrator.js | 4 ++-- scripts/deploy-without-migrator.js | 18 ++++++++++-------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/scripts/deploy-1-datav2.js b/scripts/deploy-1-datav2.js index 12380e4..da27d24 100644 --- a/scripts/deploy-1-datav2.js +++ b/scripts/deploy-1-datav2.js @@ -1,12 +1,13 @@ -const { ContractFactory, Wallet, getDefaultProvider } = require("ethers") +const { ContractFactory, Wallet, JsonRpcProvider, getDefaultProvider } = require("ethers") const DATAv2Json = require("../artifacts/contracts/DATAv2.sol/DATAv2.json") -const { KEY } = process.env +const { KEY, ETHEREUM_RPC_URL } = process.env if (!KEY) { throw new Error("Please provide env variable KEY") } -const provider = getDefaultProvider() +const provider = ETHEREUM_RPC_URL ? new JsonRpcProvider(ETHEREUM_RPC_URL) : getDefaultProvider() +const explorerUrl = "https://etherscan.io/tx" const deployer = new Wallet(KEY, provider) console.log("Deploying contracts from %s", deployer.address) @@ -14,11 +15,12 @@ async function main() { const DATAv2 = new ContractFactory(DATAv2Json.abi, DATAv2Json.bytecode, deployer) const token = await DATAv2.deploy() - console.log("Follow deployment: https://etherscan.io/tx/%s", token.deployTransaction.hash) + console.log("Follow deployment: %s/%s", explorerUrl, token.deploymentTransaction().hash) await token.waitForDeployment() + const tokenAddress = await token.getAddress() - console.log("DATAv2 deployed to:", token.address) + console.log("DATAv2 deployed to:", tokenAddress) } // We recommend this pattern to be able to use async/await everywhere diff --git a/scripts/deploy-2-migrator.js b/scripts/deploy-2-migrator.js index 313a5bb..1734b93 100644 --- a/scripts/deploy-2-migrator.js +++ b/scripts/deploy-2-migrator.js @@ -17,11 +17,11 @@ async function main() { const DataTokenMigrator = new ContractFactory(DataTokenMigratorJson.abi, DataTokenMigratorJson.bytecode, deployer) const migrator = await DataTokenMigrator.deploy(oldTokenAddress, newTokenAddress) - console.log("Follow deployment: https://etherscan.io/tx/%s", migrator.deployTransaction.hash) + console.log("Follow deployment: https://etherscan.io/tx/%s", migrator.deploymentTransaction().hash) await migrator.waitForDeployment() - console.log("DataTokenMigrator deployed to:", migrator.address) + console.log("DataTokenMigrator deployed to:", await migrator.getAddress()) } // We recommend this pattern to be able to use async/await everywhere diff --git a/scripts/deploy-without-migrator.js b/scripts/deploy-without-migrator.js index ce58d08..5855ea1 100755 --- a/scripts/deploy-without-migrator.js +++ b/scripts/deploy-without-migrator.js @@ -1,8 +1,12 @@ #!/usr/bin/env node +// PEAQ chain +const providerUrl = "https://peaq.api.onfinality.io/public" +const explorerUrl = "https://peaq.subscan.io/tx" + // Binance Smart Chain -const providerUrl = "https://bsc-dataseed.binance.org/" -const explorerUrl = "https://bscscan.com/tx" +// const providerUrl = "https://bsc-dataseed.binance.org/" +// const explorerUrl = "https://bscscan.com/tx" // Matic's Polygon // const providerUrl = "https://polygon-rpc.com" @@ -15,7 +19,7 @@ const DATAv2Json = require("../artifacts/contracts/DATAv2.sol/DATAv2.json") // const DATAv2Json = require("../artifacts/contracts/DATAv2onPolygon.sol/DATAv2onPolygon.json") -const { ContractFactory, Wallet, providers: { JsonRpcProvider }, utils: { id } } = require("ethers") +const { ContractFactory, Wallet, JsonRpcProvider, id } = require("ethers") const { KEY } = process.env if (!KEY) { throw new Error("Please provide env variable KEY") } @@ -27,14 +31,14 @@ console.log("Deploying contracts from %s", deployer.address) const adminAddress = "0x42355e7dc0A872C465bE9DE4AcAAAcB5709Ce813" async function main() { - const DATAv2 = new ContractFactory(DATAv2Json.abi, DATAv2Json.bytecode, deployer) const token = await DATAv2.deploy() // plain token // const token = await DATAv2.deploy("0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa") // Matic's Polygon version of the token - console.log("Follow deployment: %s/%s", explorerUrl, token.deployTransaction.hash) + console.log("Follow deployment: %s/%s", explorerUrl, token.deploymentTransaction().hash) await token.waitForDeployment() - console.log("DATAv2 deployed to:", token.address) + const tokenAddress = await token.getAddress() + console.log("DATAv2 deployed to:", tokenAddress) const tx1 = await token.grantRole(id("MINTER_ROLE"), adminAddress) console.log("Follow grant minter tx: %s/%s", explorerUrl, tx1.hash) @@ -47,8 +51,6 @@ async function main() { console.log("Transaction receipt: ", tr2) } -// We recommend this pattern to be able to use async/await everywhere -// and properly handle errors. main() .then(() => process.exit(0)) .catch(error => {