-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
639 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/*global process*/ | ||
|
||
const { ethers } = require("hardhat"); | ||
const { LedgerSigner } = require("@anders-t/ethers-ledger"); | ||
|
||
async function main() { | ||
const fs = require("fs"); | ||
const globalsFile = "globals.json"; | ||
const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); | ||
let parsedData = JSON.parse(dataFromJSON); | ||
const useLedger = parsedData.useLedger; | ||
const derivationPath = parsedData.derivationPath; | ||
const providerName = parsedData.providerName; | ||
const gasPriceInGwei = parsedData.gasPriceInGwei; | ||
|
||
let networkURL = parsedData.networkURL; | ||
if (providerName === "polygon") { | ||
if (!process.env.ALCHEMY_API_KEY_MATIC) { | ||
console.log("set ALCHEMY_API_KEY_MATIC env variable"); | ||
} | ||
networkURL += process.env.ALCHEMY_API_KEY_MATIC; | ||
} else if (providerName === "polygonAmoy") { | ||
if (!process.env.ALCHEMY_API_KEY_AMOY) { | ||
console.log("set ALCHEMY_API_KEY_AMOY env variable"); | ||
return; | ||
} | ||
networkURL += process.env.ALCHEMY_API_KEY_AMOY; | ||
} | ||
|
||
const provider = new ethers.providers.JsonRpcProvider(networkURL); | ||
const signers = await ethers.getSigners(); | ||
|
||
let EOA; | ||
if (useLedger) { | ||
EOA = new LedgerSigner(provider, derivationPath); | ||
} else { | ||
EOA = signers[0]; | ||
} | ||
// EOA address | ||
const deployer = await EOA.getAddress(); | ||
console.log("EOA is:", deployer); | ||
|
||
// Transaction signing and execution | ||
console.log("7. EOA to deploy Contributors"); | ||
console.log("You are signing the following transaction: Contributors.connect(EOA).deploy()"); | ||
const gasPrice = ethers.utils.parseUnits(gasPriceInGwei, "gwei"); | ||
const Contributors = await ethers.getContractFactory("Contributors"); | ||
const contributors = await Contributors.connect(EOA).deploy({ gasPrice }); | ||
const result = await contributors.deployed(); | ||
|
||
// Transaction details | ||
console.log("Contract deployment: Contributors"); | ||
console.log("Contract address:", contributors.address); | ||
console.log("Transaction:", result.deployTransaction.hash); | ||
|
||
// Wait for half a minute for the transaction completion | ||
await new Promise(r => setTimeout(r, 30000)); | ||
|
||
// Writing updated parameters back to the JSON file | ||
parsedData.contributorsAddress = contributors.address; | ||
fs.writeFileSync(globalsFile, JSON.stringify(parsedData)); | ||
|
||
// Contract verification | ||
if (parsedData.contractVerification) { | ||
const execSync = require("child_process").execSync; | ||
execSync("npx hardhat verify --network " + providerName + " " + contributors.address, { encoding: "utf-8" }); | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/*global process*/ | ||
|
||
const { ethers } = require("hardhat"); | ||
const { LedgerSigner } = require("@anders-t/ethers-ledger"); | ||
|
||
async function main() { | ||
const fs = require("fs"); | ||
const globalsFile = "globals.json"; | ||
const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); | ||
let parsedData = JSON.parse(dataFromJSON); | ||
const useLedger = parsedData.useLedger; | ||
const derivationPath = parsedData.derivationPath; | ||
const providerName = parsedData.providerName; | ||
const gasPriceInGwei = parsedData.gasPriceInGwei; | ||
const contributorsAddress = parsedData.contributorsAddress; | ||
|
||
let networkURL = parsedData.networkURL; | ||
if (providerName === "polygon") { | ||
if (!process.env.ALCHEMY_API_KEY_MATIC) { | ||
console.log("set ALCHEMY_API_KEY_MATIC env variable"); | ||
} | ||
networkURL += process.env.ALCHEMY_API_KEY_MATIC; | ||
} else if (providerName === "polygonAmoy") { | ||
if (!process.env.ALCHEMY_API_KEY_AMOY) { | ||
console.log("set ALCHEMY_API_KEY_AMOY env variable"); | ||
return; | ||
} | ||
networkURL += process.env.ALCHEMY_API_KEY_AMOY; | ||
} | ||
|
||
const provider = new ethers.providers.JsonRpcProvider(networkURL); | ||
const signers = await ethers.getSigners(); | ||
|
||
let EOA; | ||
if (useLedger) { | ||
EOA = new LedgerSigner(provider, derivationPath); | ||
} else { | ||
EOA = signers[0]; | ||
} | ||
// EOA address | ||
const deployer = await EOA.getAddress(); | ||
console.log("EOA is:", deployer); | ||
|
||
// Assemble the contributors proxy data | ||
const contributors = await ethers.getContractAt("Contributors", contributorsAddress); | ||
const proxyData = contributors.interface.encodeFunctionData("initialize", []); | ||
|
||
// Transaction signing and execution | ||
console.log("8. EOA to deploy ContributorsProxy"); | ||
console.log("You are signing the following transaction: ContributorsProxy.connect(EOA).deploy()"); | ||
const gasPrice = ethers.utils.parseUnits(gasPriceInGwei, "gwei"); | ||
const ContributorsProxy = await ethers.getContractFactory("ContributorsProxy"); | ||
const contributorsProxy = await ContributorsProxy.connect(EOA).deploy(contributorsAddress, proxyData, { gasPrice }); | ||
const result = await contributorsProxy.deployed(); | ||
|
||
// Transaction details | ||
console.log("Contract deployment: ContributorsProxy"); | ||
console.log("Contract address:", contributorsProxy.address); | ||
console.log("Transaction:", result.deployTransaction.hash); | ||
|
||
// Wait for half a minute for the transaction completion | ||
await new Promise(r => setTimeout(r, 30000)); | ||
|
||
// Writing updated parameters back to the JSON file | ||
parsedData.contributorsProxyAddress = contributorsProxy.address; | ||
fs.writeFileSync(globalsFile, JSON.stringify(parsedData)); | ||
|
||
// Contract verification | ||
if (parsedData.contractVerification) { | ||
const execSync = require("child_process").execSync; | ||
execSync("npx hardhat verify --constructor-args scripts/deployment/verify_08_contributors_proxy.js --network " + providerName + " " + contributorsProxy.address, { encoding: "utf-8" }); | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.