Skip to content
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: use shared Aragon truffle config #559

Merged
merged 3 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"repository": "https://github.com/aragon/aragonOS",
"license": "(GPL-3.0-or-later OR MIT)",
"devDependencies": {
"@aragon/truffle-config-v4": "^1.0.0",
"@codechecks/client": "^0.1.5",
"coveralls": "^2.13.3",
"eth-ens-namehash": "^2.0.8",
Expand All @@ -52,8 +53,6 @@
"dependencies": {
"mkdirp": "^0.5.1",
"truffle-flattener": "^1.2.9",
"homedir": "^0.6.0",
"truffle-hdwallet-provider": "0.0.3",
"truffle-hdwallet-provider-privkey": "0.3.0"
"homedir": "^0.6.0"
}
}
118 changes: 1 addition & 117 deletions truffle-config.js
Original file line number Diff line number Diff line change
@@ -1,117 +1 @@
const homedir = require('homedir')
const path = require('path')

const HDWalletProvider = require('truffle-hdwallet-provider')
const HDWalletProviderPrivkey = require('truffle-hdwallet-provider-privkey')

const DEFAULT_MNEMONIC = 'stumble story behind hurt patient ball whisper art swift tongue ice alien'

const defaultRPC = (network) =>
`https://${network}.infura.io`

const configFilePath = (filename) =>
path.join(homedir(), `.aragon/${filename}`)

const mnemonic = () => {
try {
return require(configFilePath('mnemonic.json')).mnemonic
} catch (e) {
return DEFAULT_MNEMONIC
}
}

const settingsForNetwork = (network) => {
try {
return require(configFilePath(`${network}_key.json`))
} catch (e) {
return { }
}
}

// Lazily loaded provider
const providerForNetwork = (network) => (
() => {
let { rpc, keys } = settingsForNetwork(network)

rpc = rpc || defaultRPC(network)

if (!keys || keys.length == 0) {
return new HDWalletProvider(mnemonic(), rpc)
}

return new HDWalletProviderPrivkey(keys, rpc)
}
)

const mochaGasSettings = {
reporter: 'eth-gas-reporter',
reporterOptions : {
currency: 'USD',
gasPrice: 3
}
}

const mocha = process.env.GAS_REPORTER ? mochaGasSettings : {}

module.exports = {
networks: {
rpc: {
network_id: 15,
host: 'localhost',
port: 8545,
gas: 6.9e6,
gasPrice: 15000000001
},
devnet: {
network_id: 16,
host: 'localhost',
port: 8535,
gas: 6.9e6,
gasPrice: 15000000001
},
mainnet: {
network_id: 1,
provider: providerForNetwork('mainnet'),
gas: 7.9e6,
gasPrice: 3000000001
},
ropsten: {
network_id: 3,
provider: providerForNetwork('ropsten'),
gas: 4.712e6
},
rinkeby: {
network_id: 4,
provider: providerForNetwork('rinkeby'),
gas: 6.9e6,
gasPrice: 15000000001
},
kovan: {
network_id: 42,
provider: providerForNetwork('kovan'),
gas: 6.9e6
},
coverage: {
host: "localhost",
network_id: "*",
port: 8555,
gas: 0xffffffffff,
gasPrice: 0x01
},
development: {
host: 'localhost',
network_id: '*',
port: 8545,
gas: 6.9e6,
gasPrice: 15000000001
},
},
build: {},
mocha,
solc: {
optimizer: {
enabled: true,
runs: 10000
}
},
}
module.exports = require('@aragon/truffle-config-v4/truffle-config')