-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: adding deployment scripts #34
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
528f7c1
chore: adding deployment scripts
kupermind aaa2039
doc: v.1.4.0-internal-audit
63eedea
doc: v.1.4.0-internal-audit
bc9a4e9
refactor: NFT fix
kupermind 3918217
chore: set initial contribute agent statuses
kupermind fda1740
Merge remote-tracking branch 'origin/v.1.4.0-internal-audit' into scr…
kupermind e5eb2de
addressing audit remarks and adding graphics
kupermind 4dca0fd
chore: adding optimus deployment script for mode
kupermind 80d45c2
test: add more tests
kupermind 4783cd9
chore: missing ABIs
kupermind b9b5919
chore: adding ABIs
kupermind 4c0c33d
chore: testnet re-deployment
kupermind b57872f
doc: update contribute flowchart
kupermind 7bd49bb
doc: update contribute flowchart
kupermind 011463c
test: next to full coverage
kupermind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,8 @@ require("@nomicfoundation/hardhat-toolbox"); | |
|
||
const ALCHEMY_API_KEY_MAINNET = process.env.ALCHEMY_API_KEY_MAINNET; | ||
const ALCHEMY_API_KEY_MATIC = process.env.ALCHEMY_API_KEY_MATIC; | ||
const ALCHEMY_API_KEY_GOERLI = process.env.ALCHEMY_API_KEY_GOERLI; | ||
const ALCHEMY_API_KEY_MUMBAI = process.env.ALCHEMY_API_KEY_MUMBAI; | ||
const ALCHEMY_API_KEY_SEPOLIA = process.env.ALCHEMY_API_KEY_SEPOLIA; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixing the hardhat config and adding more chains |
||
const ALCHEMY_API_KEY_AMOY = process.env.ALCHEMY_API_KEY_AMOY; | ||
let TESTNET_MNEMONIC = process.env.TESTNET_MNEMONIC; | ||
|
||
const accounts = { | ||
|
@@ -32,8 +32,10 @@ if (!TESTNET_MNEMONIC) { | |
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY; | ||
const POLYGONSCAN_API_KEY = process.env.POLYGONSCAN_API_KEY; | ||
const GNOSISSCAN_API_KEY = process.env.GNOSISSCAN_API_KEY; | ||
const CHIADOSCAN_API_KEY = "10200"; | ||
const ARBISCAN_API_KEY = process.env.ARBISCAN_API_KEY; | ||
const OPSCAN_API_KEY = process.env.OPSCAN_API_KEY; | ||
const BASESCAN_API_KEY = process.env.BASESCAN_API_KEY; | ||
const CELOSCAN_API_KEY = process.env.CELOSCAN_API_KEY; | ||
|
||
module.exports = { | ||
networks: { | ||
|
@@ -55,31 +57,85 @@ module.exports = { | |
accounts: accounts, | ||
chainId: 100, | ||
}, | ||
goerli: { | ||
url: "https://eth-goerli.g.alchemy.com/v2/" + ALCHEMY_API_KEY_GOERLI, | ||
arbitrumOne: { | ||
url: "https://arb1.arbitrum.io/rpc", | ||
accounts: accounts, | ||
chainId: 5, | ||
chainId: 42161, | ||
}, | ||
polygonMumbai: { | ||
url: "https://polygon-mumbai.g.alchemy.com/v2/" + ALCHEMY_API_KEY_MUMBAI, | ||
optimistic: { | ||
url: "https://optimism.drpc.org", | ||
accounts: accounts, | ||
chainId: 10, | ||
}, | ||
base: { | ||
url: "https://mainnet.base.org", | ||
accounts: accounts, | ||
chainId: 8453, | ||
}, | ||
celo: { | ||
url: "https://forno.celo.org", | ||
accounts: accounts, | ||
chainId: 42220, | ||
}, | ||
mode: { | ||
url: "https://mainnet.mode.network", | ||
accounts: accounts, | ||
chainId: 34443, | ||
}, | ||
sepolia: { | ||
url: "https://eth-sepolia.g.alchemy.com/v2/" + ALCHEMY_API_KEY_SEPOLIA, | ||
accounts: accounts, | ||
chainId: 11155111, | ||
}, | ||
polygonAmoy: { | ||
url: "https://polygon-amoy.g.alchemy.com/v2/" + ALCHEMY_API_KEY_AMOY, | ||
accounts: accounts, | ||
chainId: 80002 | ||
}, | ||
chiado: { | ||
url: "https://rpc.chiadochain.net", | ||
accounts: accounts, | ||
chainId: 10200 | ||
}, | ||
optimistic: { | ||
url: "https://optimism.drpc.org", | ||
arbitrumSepolia: { | ||
url: "https://sepolia-rollup.arbitrum.io/rpc", | ||
accounts: accounts, | ||
chainId: 10, | ||
chainId: 421614, | ||
}, | ||
optimisticSepolia: { | ||
url: "https://sepolia.optimism.io", | ||
accounts: accounts, | ||
chainId: 11155420, | ||
}, | ||
baseSepolia: { | ||
url: "https://sepolia.base.org", | ||
accounts: accounts, | ||
chainId: 84532, | ||
}, | ||
celoAlfajores: { | ||
url: "https://alfajores-forno.celo-testnet.org", | ||
accounts: accounts, | ||
chainId: 44787, | ||
}, | ||
modeSepolia: { | ||
url: "https://sepolia.mode.network", | ||
accounts: accounts, | ||
chainId: 919, | ||
}, | ||
hardhat: { | ||
allowUnlimitedContractSize: true | ||
}, | ||
}, | ||
etherscan: { | ||
customChains: [ | ||
{ | ||
network: "polygonAmoy", | ||
chainId: 80002, | ||
urls: { | ||
apiURL: "https://api-amoy.polygonscan.com/api", | ||
browserURL: "https://amoy.polygonscan.com/" | ||
} | ||
}, | ||
{ | ||
network: "chiado", | ||
chainId: 10200, | ||
|
@@ -96,6 +152,14 @@ module.exports = { | |
browserURL: "https://gnosisscan.io/" | ||
}, | ||
}, | ||
{ | ||
network: "arbitrumSepolia", | ||
chainId: 421614, | ||
urls: { | ||
apiURL: "https://api-sepolia.arbiscan.io/api", | ||
browserURL: "https://sepolia.arbiscan.io" | ||
}, | ||
}, | ||
{ | ||
network: "optimistic", | ||
chainId: 10, | ||
|
@@ -104,15 +168,80 @@ module.exports = { | |
browserURL: "https://optimistic.etherscan.io" | ||
}, | ||
}, | ||
{ | ||
network: "optimisticSepolia", | ||
chainId: 11155420, | ||
urls: { | ||
apiURL: "https://api-sepolia-optimism.etherscan.io/api", | ||
browserURL: "https://sepolia-optimistic.etherscan.io" | ||
}, | ||
}, | ||
{ | ||
network: "base", | ||
chainId: 8453, | ||
urls: { | ||
apiURL: "https://api.basescan.org/api", | ||
browserURL: "https://basescan.org" | ||
}, | ||
}, | ||
{ | ||
network: "baseSepolia", | ||
chainId: 84532, | ||
urls: { | ||
apiURL: "https://base-sepolia.blockscout.com/api", | ||
browserURL: "https://base-sepolia.blockscout.com/" | ||
}, | ||
}, | ||
{ | ||
network: "celo", | ||
chainId: 42220, | ||
urls: { | ||
apiURL: "https://api.celoscan.io/api", | ||
browserURL: "https://explorer.celo.org/" | ||
}, | ||
}, | ||
{ | ||
network: "celoAlfajores", | ||
chainId: 44787, | ||
urls: { | ||
apiURL: "https://api-alfajores.celoscan.io/api", | ||
browserURL: "https://alfajores-blockscout.celo-testnet.org/" | ||
}, | ||
}, | ||
{ | ||
network: "mode", | ||
chainId: 34443, | ||
urls: { | ||
apiURL: "https://explorer.mode.network/api", | ||
browserURL: "https://explorer.mode.network" | ||
}, | ||
}, | ||
{ | ||
network: "modeSepolia", | ||
chainId: 919, | ||
urls: { | ||
apiURL: "https://sepolia.explorer.mode.network/api", | ||
browserURL: "https://sepolia.explorer.mode.network" | ||
}, | ||
}, | ||
], | ||
apiKey: { | ||
mainnet: ETHERSCAN_API_KEY, | ||
polygon: POLYGONSCAN_API_KEY, | ||
gnosis: GNOSISSCAN_API_KEY, | ||
goerli: ETHERSCAN_API_KEY, | ||
polygonMumbai: POLYGONSCAN_API_KEY, | ||
chiado: CHIADOSCAN_API_KEY, | ||
arbitrumOne: ARBISCAN_API_KEY, | ||
optimistic: OPSCAN_API_KEY, | ||
base: BASESCAN_API_KEY, | ||
celo: CELOSCAN_API_KEY, | ||
sepolia: ETHERSCAN_API_KEY, | ||
polygonAmoy: POLYGONSCAN_API_KEY, | ||
chiado: GNOSISSCAN_API_KEY, | ||
arbitrumSepolia: ARBISCAN_API_KEY, | ||
optimisticSepolia: OPSCAN_API_KEY, | ||
baseSepolia: OPSCAN_API_KEY, | ||
celoAlfajores: CELOSCAN_API_KEY, | ||
mode: OPSCAN_API_KEY, | ||
modeSepolia: OPSCAN_API_KEY, | ||
} | ||
}, | ||
solidity: { | ||
|
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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deployment is tested |
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cyclic dependency, need to deploy blanc and change the manager later.