-
Notifications
You must be signed in to change notification settings - Fork 10
/
verify.js
executable file
·46 lines (36 loc) · 1.16 KB
/
verify.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
const fs = require("fs");
const path = require("path");
let error = false;
const assets = {};
const propsAsset = ["caip-19", "symbol", "trustwallet-uid"];
fs.readdirSync("assets")
.filter((dir) => fs.statSync(path.join("assets", dir)).isDirectory())
.forEach((dir) => {
const fileAsset = path.join("assets", dir, "asset.json"); // HARD-CODED
const jsonAsset = fs.readFileSync(fileAsset, "utf-8");
try {
const asset = JSON.parse(jsonAsset);
// check properties
propsAsset.forEach((prop) => {
if (!asset.hasOwnProperty(prop)) {
error = true;
console.error(`${fileAsset} is missing property '${prop}'.`);
}
});
// check symbol
const symbol = asset.symbol.toLowerCase();
if (symbol != dir) {
error = true;
console.error(`Invalid directory or symbol for ${fileAsset}.`);
}
if (assets[symbol]) {
error = true;
console.error(`Duplicate symbol '${asset.symbol}' in ${fileAsset}'.`);
}
// add to assets
assets[symbol] = true;
} catch (e) {
console.error(fileAsset, e.message);
}
});
process.exit(error ? -1 : 0);