-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.js
More file actions
90 lines (82 loc) · 2.05 KB
/
init.js
File metadata and controls
90 lines (82 loc) · 2.05 KB
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
const fs = require("fs");
const path = "../aivia-ethereum-protocol/";
const SDKPath = "./src/ABI/";
const networkId = 777;
let contracts;
try {
contracts = require("./test/contracts");
} catch (error) {
contracts = {};
}
const list = [
"ProjectAudit",
"AssetsRegistry",
"Proxy",
"EntryPoint",
"ProjectsRegistry",
"SCRegistry",
"RPC",
"ERC20Mintable",
"ProjectConfig",
"ConfigWithPermissions",
"AIV",
"TrueUSD",
"PlatformRegistry",
"TPLRegistry",
"CustodiansRegistry",
"EternalStorage"
];
if (!fs.existsSync(SDKPath)) {
fs.mkdirSync(SDKPath);
}
if (process.env.MODE === "dev") {
fs.writeFile("./test/projects.json", "[]", () =>
console.info("successfully clean /test/projects.json")
);
fs.writeFile("./test/contracts.json", "{}", () =>
console.info("successfully clean /test/contracts.json")
);
fs.writeFile(
"./test/history.json",
`[{
"AUM": 0,
"totalSupply": 0,
"PL": 0,
"NET": 0,
"rate": 0.025
}]`,
() => console.info("successfully clean /test/history.json")
);
process.stdout.write("\x1Bc");
fs.copyFile(`${path}/config/users.json`, "./test/users.json", (err) => {
if (err) throw err;
console.info("users.json was copied to destination.txt");
});
}
list.forEach((fileName) => {
fs.readFile(
`${path}build/contracts/${fileName}.json`,
"utf8",
(err, data) => {
const json = JSON.parse(data);
const ABI = json.abi;
if (process.env.MODE === "dev") {
if (json.networks[networkId]) {
contracts[fileName] = json.networks[networkId].address;
fs.writeFile(
"./test/contracts.json",
new Uint8Array(Buffer.from(JSON.stringify(contracts, null, 2))),
(error) => {
if (error) throw error;
}
);
}
}
const text = `module.exports = ${JSON.stringify(ABI, null, 2)}`;
const file = new Uint8Array(Buffer.from(text));
fs.writeFile(`${SDKPath + fileName}.js`, file, (error) => {
if (error) throw error;
});
}
);
});