Skip to content

Commit

Permalink
initialize hardhat
Browse files Browse the repository at this point in the history
  • Loading branch information
HristiyanG committed Apr 6, 2021
1 parent 00d98ef commit 6af2ca8
Show file tree
Hide file tree
Showing 8 changed files with 21,219 additions and 5,875 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ node_modules
/localDeploy
/run
/vendor
/artifacts
/cache

# Secrets
.secret
Expand Down
12 changes: 2 additions & 10 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
const fs = require('fs');

const privateKeys =
JSON.parse(fs.readFileSync('config/accounts.json'))["private_keys"]
const accounts = Object.entries(privateKeys)
.map(entry => ({
secretKey: `0x${entry[1]}`,
balance: '0x01158e460913d00000'
}))
const {getAccountsWithBalance} = require('./config/getAccounts')

module.exports = {
port: 8555,
testCommand: 'mocha --timeout 5000',
measureStatementCoverage: false,
providerOptions: { accounts }
providerOptions: { accounts: getAccountsWithBalance('secretKey') }
};
23 changes: 23 additions & 0 deletions config/getAccounts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const fs = require('fs');
const privateKeys = JSON.parse(fs.readFileSync('config/accounts.json'))["private_keys"]

function getAccountsWithBalance(secretPropName) {
return Object.entries(privateKeys)
.map(entry => ({
[secretPropName]: `0x${entry[1]}`,
balance: '0x02b5e3af16b1880000' // 50 ETH
}
))
}

function getAccounts() {
return Object.entries(privateKeys)
.map(
entry => `0x${entry[1]}`
)
}

module.exports = {
getAccounts,
getAccountsWithBalance,
};
40 changes: 40 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require("@nomiclabs/hardhat-truffle5"); // todo do not use truffle plugin for tests
require("solidity-coverage");
require('hardhat-contract-sizer');
require('dotenv').config();
const {getAccounts, getAccountsWithBalance} = require('./config/getAccounts') //todo getAccounts might not be required

const INFURA_KEY = process.env.INFURA_API_KEY;
const DEPLOYER_PRIVATE_KEY = process.env.PK;

module.exports = {
solidity: {
version: "0.7.1",
settings: {
optimizer: {
enabled: true,
runs: 10
}
}
},
defaultNetwork: "hardhat",
networks: {
hardhat: {
accounts: getAccountsWithBalance('privateKey'),
chainId: 1
},
test: {
url: `http://${process.env.HOST}:${process.env.PORT}`,
},
rinkeby: {
url: `https://rinkeby.infura.io/v3/${INFURA_KEY}`,
accounts: [
DEPLOYER_PRIVATE_KEY,
]
},
},
mocha: {
timeout: 120000
}
};

2 changes: 1 addition & 1 deletion migrations/1_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Cashier = artifacts.require("Cashier");
const BosonRouter = artifacts.require("BosonRouter")
const FundLimitsOracle = artifacts.require('FundLimitsOracle');

module.exports = function(deployer, network, accounts) {
module.exports = async function(deployer, network, accounts) {
console.log("network: ", network);
console.log("accounts: ", accounts);

Expand Down
Loading

0 comments on commit 6af2ca8

Please sign in to comment.