generated from aragon/aragon-react-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buidler.config.js
137 lines (122 loc) · 3.62 KB
/
buidler.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
const { usePlugin } = require("@nomiclabs/buidler/config");
// usePlugin("@nomiclabs/buidler-truffle5");
const hooks = require("./scripts/buidler-hooks");
const private = require("./private");
usePlugin("@aragon/buidler-aragon");
const DEBUG = true;
task("accounts", "Prints the list of accounts", async () => {
const accounts = await web3.eth.getAccounts();
for (const account of accounts) {
console.log(account);
}
});
task("blockNumber", "Prints the block number", async () => {
const blockNumber = await web3.eth.getBlockNumber();
console.log(blockNumber);
});
task("balance", "Prints an account's balance")
.addPositionalParam("account", "The account's address")
.setAction(async (taskArgs) => {
const balance = await web3.eth.getBalance(await addr(taskArgs.account));
console.log(web3.utils.fromWei(balance, "ether"), "ETH");
});
task("send", "Send ETH")
.addParam("from", "From address or account index")
.addOptionalParam("to", "To address or account index")
.addOptionalParam("amount", "Amount to send in ether")
.addOptionalParam("data", "Data included in transaction")
.addOptionalParam("gasPrice", "Price you are willing to pay in gwei")
.addOptionalParam("gasLimit", "Limit of how much gas to spend")
.setAction(async (taskArgs) => {
let from = await addr(taskArgs.from);
debug(`Normalized from address: ${from}`);
let to;
if (taskArgs.to) {
to = await addr(taskArgs.to);
debug(`Normalized to address: ${to}`);
}
let txparams = {
from: from,
to: to,
value: web3.utils.toWei(taskArgs.amount ? taskArgs.amount : "0", "ether"),
gasPrice: web3.utils.toWei(
taskArgs.gasPrice ? taskArgs.gasPrice : "1.001",
"gwei"
),
gas: taskArgs.gasLimit ? taskArgs.gasLimit : "24000",
};
if (taskArgs.data !== undefined) {
txparams["data"] = taskArgs.data;
debug(`Adding data to payload: ${txparams["data"]}`);
}
debug(txparams.gasPrice / 1000000000 + " gwei");
debug(JSON.stringify(txparams, null, 2));
return await send(txparams);
});
function send(txparams) {
return new Promise((resolve, reject) => {
web3.eth.sendTransaction(txparams, (error, transactionHash) => {
if (error) {
debug(`Error: ${error}`);
}
debug(`transactionHash: ${transactionHash}`);
//checkForReceipt(2, params, transactionHash, resolve)
});
});
}
function debug(text) {
if (DEBUG) {
console.log(text);
}
}
async function addr(addr) {
if (web3.utils.isAddress(addr)) {
return web3.utils.toChecksumAddress(addr);
} else {
let accounts = await web3.eth.getAccounts();
if (accounts[addr] !== undefined) {
return accounts[addr];
} else {
throw `Could not normalize address: ${addr}`;
}
}
}
module.exports = {
defaultNetwork: "localhost",
networks: {
localhost: {
url: "http://localhost:8545",
},
// localhost: {
// url: "http://161.97.97.238:8547",
// accounts: [`0x${private.DEVVPS_KEYS[0]}`],
// },
devvps: {
url: "http://161.97.97.238:8547",
accounts: [`0x${private.DEVVPS_KEYS[0]}`],
},
buidlerevm: {},
kovan: {
url: `https://kovan.infura.io/v3/${private.INFURA_PROJECT_ID}`,
accounts: [`0x${private.KOVAN_PRIVATE_KEY}`],
},
},
solc: {
version: "0.4.24",
optimizer: {
enabled: true,
runs: 10000,
},
},
etherscan: {
apiKey: private.ETHERSCAN_APIKEY,
},
aragon: {
appServePort: 8011,
clientServePort: 3000,
appSrcPath: "app/",
appBuildOutputPath: "dist/",
appName: "v-governance",
hooks, // Path to script hooks
},
};