1 | let args = process.argv.slice(2);
|
2 | let copy_from = args[0];
|
3 | let network_id = args[1];
|
4 |
|
5 | let path = require("path")
|
6 | let fs = require("fs")
|
7 | let package_path = __dirname;
|
8 | let contracts_path = __dirname+'/'+copy_from;
|
9 | let package_art = fs.readdirSync(package_path)
|
10 | for(let n of package_art){
|
11 | let n_parts= n.split(".");
|
12 | if(n_parts.length > 1 && n_parts[1]=='json'){
|
13 | let c_art = require(path.join(contracts_path,n));
|
14 | let p_art = require(path.join(package_path,n))
|
15 | if(c_art.hasOwnProperty('networks') &&
|
16 | c_art.networks.hasOwnProperty(network_id) &&
|
17 | p_art.hasOwnProperty('networks') &&
|
18 | p_art.networks.hasOwnProperty(network_id)
|
19 | )
|
20 | {
|
21 | let address_42 = c_art.networks["42"].address;
|
22 | p_art.networks["42"]["address"] = address_42;
|
23 | if(!fs.existsSync(__dirname+"/../contracts_temp")) {
|
24 | console.log(__dirname);
|
25 | fs.mkdirSync(__dirname+"/../contracts_temp")
|
26 | }
|
27 | fs.writeFileSync(__dirname+"/../contracts_temp/" +n,JSON.stringify(p_art,null,2));
|
28 |
|
29 | }
|
30 |
|
31 | }
|
32 | };
|