-
Notifications
You must be signed in to change notification settings - Fork 110
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
V2.2.1/migrate tests typescript #429
Open
atsignhandle
wants to merge
3
commits into
openlawteam:master
Choose a base branch
from
atsignhandle:v2.2.1/migrate-tests-typescript
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require("@nomiclabs/hardhat-waffle"); | ||
|
||
require("./tasks/accounts"); | ||
require("./tasks/deploy"); | ||
|
||
/** | ||
* @type import('hardhat/config').HardhatUserConfig | ||
*/ | ||
module.exports = { | ||
networks: { | ||
ganache: { | ||
url: "http://127.0.0.1:7545", // Localhost (default: none) | ||
}, | ||
rinkeby: { | ||
url: "https://rinkeby.infura.io/v3/6d106b8213de41e9921e1198c69a5cc4", | ||
gasPrice: 4000000000, | ||
accounts: { | ||
mnemonic: process.env.WALLET_MNEMONIC | ||
} | ||
}, | ||
ropsten: { | ||
url: "https://ropsten.infura.io/v3/6d106b8213de41e9921e1198c69a5cc4", | ||
gasPrice: 4000000000, | ||
accounts: { | ||
mnemonic: process.env.WALLET_MNEMONIC | ||
} | ||
} | ||
}, | ||
|
||
solidity: { | ||
version: "0.8.0", | ||
settings: { | ||
optimizer: { | ||
enabled: true, | ||
runs: 1000, | ||
}, | ||
}, | ||
}, | ||
}; |
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,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ -d "build/contracts" ] | ||
then | ||
rm -rf "build/contracts" | ||
fi | ||
mkdir -p "build/contracts" | ||
|
||
find "artifacts/contracts" -type f -name "*.json" -exec cp "{}" build/contracts \; | ||
|
||
find "build/contracts" -type f -name "*.dbg.json" -delete |
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,7 @@ | ||
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { | ||
const accounts = await hre.ethers.getSigners(); | ||
|
||
for (const account of accounts) { | ||
console.log(account.address); | ||
} | ||
}); |
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,249 @@ | ||||||
const { | ||||||
toBN, | ||||||
toWei, | ||||||
ETH_TOKEN, | ||||||
maximumChunks, | ||||||
unitPrice, | ||||||
numberOfUnits, | ||||||
} = require("../utils/ContractUtil.js"); | ||||||
|
||||||
const { deployDao, getNetworkDetails } = require("../utils/HardhatDeploymentUtil.js"); | ||||||
|
||||||
require("dotenv").config(); | ||||||
|
||||||
task("deploy", "Deply the list of contracts", async (taskArgs, hre) => { | ||||||
const network = hre.hardhatArguments.network; | ||||||
console.log(`Deploying tribute-contracts to ${network} network`); | ||||||
|
||||||
const { contracts } = require(`../deployment/${network}.config`); | ||||||
const hardHatImports = require("../utils/HardhatUtil.js")(contracts); | ||||||
const DaoArtifacts = hardHatImports.DaoArtifacts; | ||||||
|
||||||
let daoArtifacts; | ||||||
|
||||||
if (process.env.DAO_ARTIFACTS_CONTRACT_ADDR) { | ||||||
console.log(`Attach to existing DaoArtifacts contract`); | ||||||
daoArtifacts = await DaoArtifacts.attatch( | ||||||
process.env.DAO_ARTIFACTS_CONTRACT_ADDR | ||||||
); | ||||||
} else { | ||||||
console.log(`Creating new DaoArtifacts contract`); | ||||||
const daoArtifact = await (await DaoArtifacts).deploy(); | ||||||
daoArtifacts = await daoArtifact.deployed(); | ||||||
} | ||||||
|
||||||
console.log(`DaoArtifacts: ${daoArtifacts.address}`); | ||||||
|
||||||
const deployFunction = hardHatImports.deployFunctionFactory( | ||||||
hre, | ||||||
daoArtifacts | ||||||
); | ||||||
|
||||||
if (network === "mainnet") { | ||||||
res = await deployMainnetDao(deployFunction, network, hardHatImports); | ||||||
} else if (network === "ganache") { | ||||||
const accounts = await hre.ethers.getSigners(); | ||||||
res = await deployGanacheDao( | ||||||
deployFunction, | ||||||
network, | ||||||
accounts, | ||||||
hardHatImports | ||||||
); | ||||||
} else if (network === "rinkeby") { | ||||||
res = await deployRinkebyDao(deployFunction, network, hardHatImports); | ||||||
} else if (network === "test" || network === "coverage") { | ||||||
res = await deployTestDao( | ||||||
deployFunction, | ||||||
network, | ||||||
accounts, | ||||||
hardHatImports | ||||||
); | ||||||
} | ||||||
|
||||||
let { dao, extensions, testContracts } = res; | ||||||
|
||||||
if (dao) { | ||||||
await dao.finalizeDao(); | ||||||
console.log("************************"); | ||||||
console.log(`DaoRegistry: ${dao.address}`); | ||||||
console.log( | ||||||
`Multicall: ${ | ||||||
testContracts.multicall ? testContracts.multicall.address : "" | ||||||
}` | ||||||
); | ||||||
console.log(`BankExtension: ${extensions.bank.address}`); | ||||||
console.log( | ||||||
`NFTExtension: ${extensions.nft ? extensions.nft.address : ""}` | ||||||
); | ||||||
console.log( | ||||||
`ERC20Extension: ${ | ||||||
extensions.erc20Ext ? extensions.erc20Ext.address : "" | ||||||
}` | ||||||
); | ||||||
console.log("************************"); | ||||||
} else { | ||||||
console.log("************************"); | ||||||
console.log("no migration for network " + network); | ||||||
console.log("************************"); | ||||||
} | ||||||
}); | ||||||
|
||||||
const deployRinkebyDao = async (deployFunction, network, hardHatImports) => { | ||||||
if (!process.env.DAO_NAME) | ||||||
throw Error("Missing env var: DAO_NAME"); | ||||||
if (!process.env.DAO_OWNER_ADDR) | ||||||
throw Error("Missing env var: DAO_OWNER_ADDR"); | ||||||
if (!process.env.ERC20_TOKEN_NAME) | ||||||
throw Error("Missing env var: ERC20_TOKEN_NAME"); | ||||||
if (!process.env.ERC20_TOKEN_SYMBOL) | ||||||
throw Error("Missing env var: ERC20_TOKEN_SYMBOL"); | ||||||
if (!process.env.ERC20_TOKEN_DECIMALS) | ||||||
throw Error("Missing env var: ERC20_TOKEN_DECIMALS"); | ||||||
|
||||||
return await deployDao({ | ||||||
...hardHatImports, | ||||||
deployFunction, | ||||||
unitPrice: toBN(toWei("100", "finney")).toString(), | ||||||
nbUnits: toBN("100000").toString(), | ||||||
tokenAddr: ETH_TOKEN, | ||||||
erc20TokenName: process.env.ERC20_TOKEN_NAME, | ||||||
erc20TokenSymbol: process.env.ERC20_TOKEN_SYMBOL, | ||||||
erc20TokenDecimals: process.env.ERC20_TOKEN_DECIMALS, | ||||||
maxChunks: toBN("100000").toString(), | ||||||
votingPeriod: 600, // 600 secs = 10 mins | ||||||
gracePeriod: 600, // 600 secs = 10 mins | ||||||
offchainVoting: true, | ||||||
chainId: getNetworkDetails(network).chainId, | ||||||
deployTestTokens: true, | ||||||
finalize: false, | ||||||
maxExternalTokens: 100, | ||||||
couponCreatorAddress: process.env.COUPON_CREATOR_ADDR | ||||||
? process.env.COUPON_CREATOR_ADDR | ||||||
: process.env.DAO_OWNER_ADDR, | ||||||
daoName: process.env.DAO_NAME, | ||||||
owner: process.env.DAO_OWNER_ADDR, | ||||||
offchainAdmin: "0xedC10CFA90A135C41538325DD57FDB4c7b88faf7", | ||||||
}); | ||||||
}; | ||||||
|
||||||
const deployMainnetDao = async (deployFunction, network, hardHatImports) => { | ||||||
if (!process.env.DAO_NAME) | ||||||
throw Error("Missing env var: DAO_NAME"); | ||||||
if (!process.env.DAO_OWNER_ADDR) | ||||||
throw Error("Missing env var: DAO_OWNER_ADDR"); | ||||||
if (!process.env.ERC20_TOKEN_NAME) | ||||||
throw Error("Missing env var: ERC20_TOKEN_NAME"); | ||||||
if (!process.env.ERC20_TOKEN_SYMBOL) | ||||||
throw Error("Missing env var: ERC20_TOKEN_SYMBOL"); | ||||||
if (!process.env.ERC20_TOKEN_DECIMALS) | ||||||
throw Error("Missing env var: ERC20_TOKEN_DECIMALS"); | ||||||
if (!process.env.COUPON_CREATOR_ADDR) | ||||||
throw Error("Missing env var: COUPON_CREATOR_ADDR"); | ||||||
if (!process.env.OFFCHAIN_ADMIN_ADDR) | ||||||
throw Error("Missing env var: OFFCHAIN_ADMIN_ADDR"); | ||||||
if (!process.env.VOTING_PERIOD_SECONDS) | ||||||
throw Error("Missing env var: VOTING_PERIOD_SECONDS"); | ||||||
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. Codacy has a fix for the issue: Expected { after 'if' condition.
Suggested change
|
||||||
if (!process.env.GRACE_PERIOD_SECONDS) | ||||||
throw Error("Missing env var: GRACE_PERIOD_SECONDS"); | ||||||
|
||||||
return await deployDao({ | ||||||
...hardHatImports, | ||||||
deployFunction, | ||||||
unitPrice: toBN(toWei("100", "finney")), | ||||||
nbUnits: toBN("100000"), | ||||||
tokenAddr: ETH_TOKEN, | ||||||
erc20TokenName: process.env.ERC20_TOKEN_NAME, | ||||||
erc20TokenSymbol: process.env.ERC20_TOKEN_SYMBOL, | ||||||
erc20TokenDecimals: process.env.ERC20_TOKEN_DECIMALS, | ||||||
maxChunks: toBN("100000"), | ||||||
votingPeriod: parseInt(process.env.VOTING_PERIOD_SECONDS), | ||||||
gracePeriod: parseInt(process.env.GRACE_PERIOD_SECONDS), | ||||||
offchainVoting: true, | ||||||
chainId: getNetworkDetails(network).chainId, | ||||||
deployTestTokens: false, | ||||||
finalize: false, | ||||||
maxExternalTokens: 100, | ||||||
couponCreatorAddress: process.env.COUPON_CREATOR_ADDR, | ||||||
daoName: process.env.DAO_NAME, | ||||||
owner: process.env.DAO_OWNER_ADDR, | ||||||
offchainAdmin: process.env.OFFCHAIN_ADMIN_ADDR, | ||||||
}); | ||||||
}; | ||||||
|
||||||
const deployGanacheDao = async ( | ||||||
deployFunction, | ||||||
network, | ||||||
accounts, | ||||||
hardHatImports | ||||||
) => { | ||||||
if (!process.env.DAO_NAME) | ||||||
throw Error("Missing env var: DAO_NAME"); | ||||||
if (!process.env.ERC20_TOKEN_NAME) | ||||||
throw Error("Missing env var: ERC20_TOKEN_NAME"); | ||||||
if (!process.env.ERC20_TOKEN_SYMBOL) | ||||||
throw Error("Missing env var: ERC20_TOKEN_SYMBOL"); | ||||||
if (!process.env.ERC20_TOKEN_DECIMALS) | ||||||
throw Error("Missing env var: ERC20_TOKEN_DECIMALS"); | ||||||
return await deployDao({ | ||||||
...hardHatImports, | ||||||
deployFunction, | ||||||
unitPrice: toBN(toWei("100", "finney")).toString(), | ||||||
nbUnits: toBN("100000").toString(), | ||||||
tokenAddr: ETH_TOKEN, | ||||||
erc20TokenName: process.env.ERC20_TOKEN_NAME, | ||||||
erc20TokenSymbol: process.env.ERC20_TOKEN_SYMBOL, | ||||||
erc20TokenDecimals: process.env.ERC20_TOKEN_DECIMALS, | ||||||
maxChunks: toBN("100000").toString(), | ||||||
votingPeriod: 120, // 120 secs = 2 mins | ||||||
gracePeriod: 60, // 60 secs = 1 min | ||||||
offchainVoting: true, | ||||||
chainId: getNetworkDetails(network).chainId, | ||||||
deployTestTokens: true, | ||||||
finalize: false, | ||||||
maxExternalTokens: 100, | ||||||
couponCreatorAddress: process.env.COUPON_CREATOR_ADDR | ||||||
? process.env.COUPON_CREATOR_ADDR | ||||||
: accounts[0].address, | ||||||
daoName: process.env.DAO_NAME, | ||||||
owner: accounts[0].address, | ||||||
offchainAdmin: "0xedC10CFA90A135C41538325DD57FDB4c7b88faf7", | ||||||
}); | ||||||
}; | ||||||
|
||||||
const deployTestDao = async ( | ||||||
deployFunction, | ||||||
network, | ||||||
accounts, | ||||||
hardHatImports | ||||||
) => { | ||||||
if (!process.env.DAO_NAME) throw Error("Missing env var: DAO_NAME"); | ||||||
if (!process.env.ERC20_TOKEN_NAME) | ||||||
throw Error("Missing env var: ERC20_TOKEN_NAME"); | ||||||
if (!process.env.ERC20_TOKEN_SYMBOL) | ||||||
throw Error("Missing env var: ERC20_TOKEN_SYMBOL"); | ||||||
if (!process.env.ERC20_TOKEN_DECIMALS) | ||||||
throw Error("Missing env var: ERC20_TOKEN_DECIMALS"); | ||||||
|
||||||
return await deployDao({ | ||||||
...hardHatImports, | ||||||
deployFunction, | ||||||
unitPrice: unitPrice, | ||||||
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. Codacy has a fix for the issue: Expected property shorthand.
Suggested change
|
||||||
nbUnits: numberOfUnits, | ||||||
tokenAddr: ETH_TOKEN, | ||||||
erc20TokenName: process.env.ERC20_TOKEN_NAME, | ||||||
erc20TokenSymbol: process.env.ERC20_TOKEN_SYMBOL, | ||||||
erc20TokenDecimals: process.env.ERC20_TOKEN_DECIMALS, | ||||||
maxChunks: maximumChunks, | ||||||
votingPeriod: 10, // 10 secs | ||||||
gracePeriod: 1, // 1 sec | ||||||
offchainVoting: true, | ||||||
chainId: getNetworkDetails(network).chainId, | ||||||
deployTestTokens: false, | ||||||
finalize: false, | ||||||
maxExternalTokens: 100, | ||||||
couponCreatorAddress: "0x7D8cad0bbD68deb352C33e80fccd4D8e88b4aBb8", | ||||||
offchainAdmin: "0xedC10CFA90A135C41538325DD57FDB4c7b88faf7", | ||||||
daoName: process.env.DAO_NAME, | ||||||
owner: accounts[0], | ||||||
}); | ||||||
}; |
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.
Codacy has a fix for the issue: Expected { after 'if' condition.