-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.js
More file actions
49 lines (44 loc) · 909 Bytes
/
Copy pathexample.js
File metadata and controls
49 lines (44 loc) · 909 Bytes
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
"use strict";
const Web3 = require("web3");
const moment = require("moment");
const Mapper = require("./");
function bNToString(val) {
return Web3.utils.BN(val).toString();
}
const mapper = new Mapper({
mapping: {
state: [
{
key: "stateName",
transform: function (val) {
const index = Number(val.toString());
const states = ["Funding", "Active", "Matured"];
return states[index];
},
},
{
key: "state",
transform: val => val.toNumber(),
},
],
maturityDeadline: {
transform: function (val) {
return moment.unix(val.toNumber());
},
},
},
types: {
bytes: Web3.utils.hexToUtf8,
int: bNToString,
uint: bNToString,
},
workingDirectory: __dirname,
});
(async () => {
try {
const values = await mapper.map("Token", "0x468d834b0FAc4B9D8B2E90bE1cE35A891Ff96Ae9");
console.log(values);
} catch (err) {
console.error(err);
}
})();