Skip to content

Commit

Permalink
ListApp: migrate to hardhat
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel committed May 31, 2021
1 parent 619784d commit d5df3ed
Show file tree
Hide file tree
Showing 9 changed files with 7,907 additions and 52 deletions.
15 changes: 15 additions & 0 deletions list/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# network specific node uri : `"ETH_NODE_URI_" + networkName.toUpperCase()`
ETH_NODE_URI_MAINNET=https://mainnet.eth.aragon.network
ETH_NODE_URI_RINKEBY=https://rinkeby.eth.aragon.network

# generic node uri (if no specific found) :
ETH_NODE_URI=https://{{networkName}}.infura.io/v3/<apiKey>

# network specific mnemonic : `"MNEMONIC_ " + networkName.toUpperCase()`
MNEMONIC_MAINNET=<mnemonic for mainnet>
# generic mnemonic (if no specific found):
MNEMONIC=<mnemonic>

# pinata pinning service keys
PINATA_KEY=
PINATA_SECRET_KEY=
1 change: 0 additions & 1 deletion list/.gitattributes

This file was deleted.

7 changes: 5 additions & 2 deletions list/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
node_modules
artifacts
.cache
cache
artifacts
dist
ipfs.cmd
package-lock.json
.DS_STORE
coverage.json
coverage
.env
.DS_STORE
34 changes: 0 additions & 34 deletions list/buidler.config.js

This file was deleted.

121 changes: 121 additions & 0 deletions list/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
require("dotenv").config();

require("@1hive/hardhat-aragon");
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-truffle5");
require("@nomiclabs/hardhat-web3");
require("hardhat-deploy");
require("hardhat-gas-reporter");
require("solidity-coverage");

const { node_url, accounts } = require("./utils/network");

process.removeAllListeners("warning");
module.exports = {
solidity: {
version: "0.4.24",
settings: {
optimizer: {
enabled: true,
runs: 10000,
},
},
},
aragon: {
appEnsName: "dcl-list22.open.aragonpm.eth",
appContractName: "ListApp",
appRoles: [
{
name: "Add an item to the list",
id: "ADD_ROLE",
params: [],
},
{
name: "Remove an item from the list",
id: "REMOVE_ROLE",
params: [],
},
],
},
networks: {
hardhat: {
// process.env.HARDHAT_FORK will specify the network that the fork is made from.
// this line ensure the use of the corresponding accounts
accounts: accounts(process.env.HARDHAT_FORK),
forking: process.env.HARDHAT_FORK
? {
url: node_url(process.env.HARDHAT_FORK),
blockNumber: process.env.HARDHAT_FORK_NUMBER
? parseInt(process.env.HARDHAT_FORK_NUMBER)
: undefined,
}
: undefined,
},
localhost: {
url: node_url("localhost"),
accounts: accounts(),
ensRegistry: "0x4E065c622d584Fbe5D9078C3081840155FA69581",
},
mainnet: {
url: node_url("mainnet"),
accounts: accounts("mainnet"),
},
rinkeby: {
url: node_url("rinkeby"),
accounts: accounts("rinkeby"),
ensRegistry: "0x98Df287B6C145399Aaa709692c8D308357bC085D",
},
ropsten: {
url: node_url("ropsten"),
accounts: accounts("ropsten"),
ensRegistry: "0x6afe2cacee211ea9179992f89dc61ff25c61e923",
},
xdai: {
url: node_url("xdai"),
accounts: accounts("xdai"),
ensRegistry: "0xaafca6b0c89521752e559650206d7c925fd0e530",
},
polygon: {
url: node_url("polygon"),
accounts: accounts("polygon"),
ensRegistry: "0x4E065c622d584Fbe5D9078C3081840155FA69581",
},
frame: {
url: "http://localhost:1248",
httpHeaders: { origin: "hardhat" },
},
},
ipfs: {
pinata: {
key: process.env.PINATA_KEY || "",
secret: process.env.PINATA_SECRET_KEY || "",
},
},
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
},
mocha: {
timeout: 0,
},
external: process.env.HARDHAT_FORK
? {
contracts: [
{
artifacts: "node_modules/@aragon/os/build/contracts",
},
],
deployments: {
// process.env.HARDHAT_FORK will specify the network that the fork is made from.
// these lines allow it to fetch the deployments from the network being forked from both for node and deploy task
hardhat: ["deployments/" + process.env.HARDHAT_FORK],
localhost: ["deployments/" + process.env.HARDHAT_FORK],
},
}
: {
contracts: [
{
artifacts: "node_modules/@aragon/os/build/contracts",
},
],
},
};
36 changes: 22 additions & 14 deletions list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@
"version": "0.0.1",
"description": "placeholder-app-description",
"scripts": {
"postinstall": "npm run compile && npm run build-app",
"build-app": "cd app && npm install && cd ..",
"compile": "buidler compile --force",
"test": "buidler test --network buidlerevm",
"start": "buidler start",
"publish:major": "buidler publish major",
"publish:minor": "buidler publish minor",
"publish:patch": "buidler publish patch"
"console": "hardhat console",
"compile": "hardhat compile --force",
"devchain": "hardhat node",
"build": "cd app && yarn build",
"test": "hardhat test",
"test:gas": "REPORT_GAS=true hardhat test --network localhost",
"coverage": "hardhat coverage",
"publish:major": "hardhat publish major",
"publish:minor": "hardhat publish minor",
"publish:patch": "hardhat publish patch"
},
"dependencies": {
"@aragon/os": "^4.4.0"
},
"devDependencies": {
"@aragon/buidler-aragon": "^0.2.0",
"@1hive/hardhat-aragon": "^0.0.5",
"@aragon/contract-test-helpers": "0.0.1",
"@nomiclabs/buidler": "^1.3.0",
"@nomiclabs/buidler-etherscan": "^1.3.0",
"@nomiclabs/buidler-truffle5": "^1.3.0",
"@nomiclabs/buidler-web3": "^1.3.0",
"web3": "^1.2.0"
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-truffle5": "^2.0.0",
"@nomiclabs/hardhat-web3": "^2.0.0",
"chai": "^4.2.0",
"dotenv": "^9.0.2",
"ethers": "^5.1.4",
"hardhat": "^2.3.0",
"hardhat-deploy": "^0.7.5",
"hardhat-gas-reporter": "^1.0.4",
"solidity-coverage": "^0.7.16",
"web3": "^1.3.6"
}
}
1 change: 0 additions & 1 deletion list/truffle.js

This file was deleted.

54 changes: 54 additions & 0 deletions list/utils/network.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
require("dotenv").config();

function node_url(networkName) {
if (networkName) {
const uri = process.env["ETH_NODE_URI_" + networkName.toUpperCase()];
if (uri && uri !== "") {
return uri;
}
}

if (networkName === "localhost") {
// do not use ETH_NODE_URI
return "http://localhost:8545";
}

let uri = process.env.ETH_NODE_URI;
if (uri) {
uri = uri.replace("{{networkName}}", networkName);
}
if (!uri || uri === "") {
// throw new Error(`environment variable "ETH_NODE_URI" not configured `);
return "";
}
if (uri.indexOf("{{") >= 0) {
throw new Error(
`invalid uri or network not supported by node provider : ${uri}`
);
}
return uri;
}

function getMnemonic(networkName) {
if (networkName) {
const mnemonic = process.env["MNEMONIC_" + networkName.toUpperCase()];
if (mnemonic && mnemonic !== "") {
return mnemonic;
}
}

const mnemonic = process.env.MNEMONIC;
if (!mnemonic || mnemonic === "") {
return "test test test test test test test test test test test junk";
}
return mnemonic;
}

function accounts(networkName) {
return { mnemonic: getMnemonic(networkName) };
}

module.exports = {
accounts,
node_url,
};
Loading

0 comments on commit d5df3ed

Please # to comment.