forked from amis-erc20/bZx-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
19_dev_deploy_test_tokens.js
61 lines (50 loc) · 1.9 KB
/
19_dev_deploy_test_tokens.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
var TokenRegistry = artifacts.require("TokenRegistry");
var TestNetFaucet = artifacts.require("TestNetFaucet");
var TestNetOracle = artifacts.require("TestNetOracle");
const path = require("path");
const config = require("../protocol-config.js");
module.exports = (deployer, network, accounts) => {
//if (true) return;
if (network == "development" || network == "develop" || network == "testnet" || network == "coverage")
network = "development";
else {
// comment out if we need to deploy to other networks
return;
}
if (network != "mainnet" && network != "ropsten") {
let tokens = [];
deployer.then(async () => {
var oracle = await TestNetOracle.deployed();
for(let i=0; i <= 9; i++) {
let t = await artifacts.require("TestToken"+i);
await deployer.deploy(t);
await tokens.push(t);
if (i == 9) {
await oracle.setRates(
t.address,
config["addresses"][network]["ZeroEx"]["WETH9"],
web3.utils.toWei("1", "ether")
);
} else {
await oracle.setRates(
t.address,
config["addresses"][network]["ZeroEx"]["WETH9"],
web3.utils.toWei(((Math.floor(Math.random() * 100) + 2)/1000).toString(), "ether")
);
}
}
var registry = await TokenRegistry.deployed();
var faucet = await TestNetFaucet.deployed();
var token, name, symbol;
for (var i = 0; i <= 9; ++i) {
token = await tokens[i].deployed();
name = await token.name.call();
symbol = await token.symbol.call();
await registry.addToken(token.address, name, symbol, 18, "");
// transfer a large amount to faucet
await token.transfer(faucet.address, web3.utils.toWei("100000000000000000", "ether"));
}
console.log(` > [${parseInt(path.basename(__filename))}] Test Tokens deploy: #done`);
});
}
};