-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathaggregate_types.js
47 lines (41 loc) · 1.21 KB
/
aggregate_types.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
#!node
// Read in the type definitions from all modules in the runtime and the runtime's own types
// Naively aggregates types and writes them to disk.
const fs = require('fs');
// A list of all the installed modules' folder names.
// Does not include system pallets because Apps already supports them.
// Redundant with construct_runtime!
const modules = [
"control",
"flow",
"signal",
"tangram",
"sense",
// "hypaspace",
// "airdrop",
// "currencies",
// "horizon",
// "payment"
]
// Types that are native to the runtime itself (ie come from lib.rs)
const runtimeOwnTypes = {
"Address": "MultiAddress",
"LookupSource": "MultiAddress",
"AccountInfo": "AccountInfoWithDualRefCount",
"AccountInfoWithDualRefCount": {
"nonce": "Index",
"consumers": "RefCount",
"providers": "RefCount",
"data": "AccountData"
}
}
// Loop through all modules aggregating types
let finalTypes = runtimeOwnTypes;
let moduleTypes;
for (let dirname of modules) {
let path = `./modules/${dirname}/types.json`;
moduleTypes = JSON.parse(fs.readFileSync(path, 'utf8'));
finalTypes = {...finalTypes, ...moduleTypes};
}
// Write output to disk
fs.writeFileSync("types.json", JSON.stringify(finalTypes, null, 2), 'utf8');