-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
80 lines (70 loc) · 2.19 KB
/
config.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
const path = require("path");
module.exports = {
paths: [{
src: './sources/cardano-token-registry/mappings',
verified: true,
version: 1,
mapper: (json) => {
const token = {};
if (json.subject) {
token.policyId = json.subject.slice(0, 56);
token.subject = json.subject;
} else {
return;
}
if (!json.decimals) {
token.decimals = 0;
} else {
token.decimals = json.decimals.value;
}
if (!json.ticker) {
token.ticker = ''
} else {
token.ticker = json.ticker.value.trim();
}
if (!json.description) {
token.description = ''
} else {
token.description = json.description.value.trim();
}
if (!json.name) {
token.name = ''
} else {
token.name = json.name.value.trim();
}
if (json.url && json.url.value) {
token.url = json.url.value.trim();
} else {
token.url = ''
}
let buffer;
if (json.logo && json.logo.value && json.subject) {
const byteString = json.logo.value
buffer = Buffer.from(byteString, 'base64');
}
return {
info: token,
img: buffer ? {
content: buffer,
type: 'buffer'
} : undefined
}
}
}, {
src: './sources/cardano-tokens/mappings',
verified: false,
version: 2,
mapper: (json) => {
const jsonCopy = Object.assign({}, json);
delete jsonCopy['logo'];
return {
info: {
...jsonCopy
},
img: json.logo && json.logo.type === 'url' && !json.logo.content.startsWith('http') ? {
content: path.join('./sources/cardano-tokens/images', json.logo.content)
} : json.logo
}
}
}]
}