-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtruffle.js
138 lines (121 loc) · 4.66 KB
/
truffle.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
138
var path = require('path');
var Web3 = require('web3');
const bitcore = require('bitcore-lib');
const web3 = new Web3();
var HDWalletProvider = require("truffle-hdwallet-provider");
const fs = require('fs');
const config = JSON.parse(fs.readFileSync("config.json").toString());
let PRIVATE_KEY = config["privateKey"];
let PRIVATE_KEY_DEPLOYER = config["privateKeyDeploy"];
let PRIVATE_KEY_NAV = config["privateKeyNav"];
if (!PRIVATE_KEY_NAV || !PRIVATE_KEY)
{
if (!PRIVATE_KEY_NAV)
{
console.log("Generating NAV private key...");
PRIVATE_KEY_NAV = bitcore.HDPrivateKey().toString();
config["privateKeyNav"] = PRIVATE_KEY_NAV;
}
console.log("Please don't forget to back up config.json!\n");
}
const XPUBKEY = bitcore.HDPrivateKey(PRIVATE_KEY_NAV).hdPublicKey.toString();
var foundPubKey = false;
for (var i in config["coldStorage"]["keys"])
{
var key = config["coldStorage"]["keys"][i];
if (key == XPUBKEY)
{
foundPubKey = true;
break;
}
}
if (!foundPubKey)
{
config["coldStorage"]["keys"].push(XPUBKEY);
}
config["publicKeyNav"] = XPUBKEY;
fs.writeFileSync("config.json", JSON.stringify(config, null, 4));
const options = {
timeout: 30000, // ms
clientConfig: {
// Useful if requests are large
maxReceivedFrameSize: 100000000, // bytes - default: 1MiB
maxReceivedMessageSize: 100000000, // bytes - default: 8MiB
// Useful to keep a connection alive
keepalive: true,
keepaliveInterval: -1 // ms
},
// Enable auto reconnection
reconnect: {
auto: true,
delay: 2000, // ms
maxAttempts: 60,
onTimeout: false
}
};
module.exports = {
compilers: {
solc: {
version: "^0.6.0",
}
},
contracts_build_directory: path.join(__dirname, "/dapp/src/contracts"),
contracts_directory: path.join(__dirname, "/contracts"),
networks: {
development: {
provider: function() {
return PRIVATE_KEY_DEPLOYER ? new HDWalletProvider(PRIVATE_KEY_DEPLOYER, config["networks"]["123"]["ethProvider"]) : new Web3.providers.HttpProvider(config["networks"]["123"]["ethProvider"])
},
wsprovider: function() {
const webSocketProvider = new Web3.providers.WebsocketProvider(config["networks"]["123"]["ethWssProvider"], options)
if (!PRIVATE_KEY) return webSocketProvider;
HDWalletProvider.prototype.on = webSocketProvider.on.bind(webSocketProvider)
return new HDWalletProvider(PRIVATE_KEY, webSocketProvider)
},
gas: 6000000,
gasPrice: 40000000000,
network_id: "123" // Match any network id
},
bscmainnet: {
provider: function() {
return PRIVATE_KEY_DEPLOYER ? new HDWalletProvider(PRIVATE_KEY_DEPLOYER, config["networks"]["56"]["ethProvider"]) : new Web3.providers.HttpProvider(config["networks"]["56"]["ethProvider"])
},
wsprovider: function() {
const webSocketProvider = new Web3.providers.WebsocketProvider(config["networks"]["56"]["ethWssProvider"], options)
if (!PRIVATE_KEY) return webSocketProvider;
HDWalletProvider.prototype.on = webSocketProvider.on.bind(webSocketProvider)
return new HDWalletProvider(PRIVATE_KEY, webSocketProvider)
},
gas: 6000000,
gasPrice: 40000000000,
network_id: "56" // Match any network id
},
bsctestnet: {
provider: function() {
return PRIVATE_KEY_DEPLOYER ? new HDWalletProvider(PRIVATE_KEY_DEPLOYER, config["networks"]["97"]["ethProvider"]) : new Web3.providers.HttpProvider(config["networks"]["97"]["ethProvider"])
},
wsprovider: function() {
const webSocketProvider = new Web3.providers.WebsocketProvider(config["networks"]["97"]["ethWssProvider"], options)
if (!PRIVATE_KEY) return webSocketProvider;
HDWalletProvider.prototype.on = webSocketProvider.on.bind(webSocketProvider)
return new HDWalletProvider(PRIVATE_KEY, webSocketProvider)
},
gas: 6000000,
gasPrice: 40000000000,
network_id: "97" // Match any network id
},
ropsten: {
provider: function() {
return PRIVATE_KEY_DEPLOYER ? new HDWalletProvider(PRIVATE_KEY_DEPLOYER, config["networks"]["3"]["ethProvider"]) : new Web3.providers.HttpProvider(config["networks"]["3"]["ethProvider"])
},
wsprovider: function() {
const webSocketProvider = new Web3.providers.WebsocketProvider(config["networks"]["3"]["ethWssProvider"], options)
if (!PRIVATE_KEY) return webSocketProvider;
HDWalletProvider.prototype.on = webSocketProvider.on.bind(webSocketProvider)
return new HDWalletProvider(PRIVATE_KEY, webSocketProvider)
},
network_id: "3",
gas: 6000000
}
},
};