-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
73 lines (60 loc) · 1.74 KB
/
index.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
import './config/installSesLockdown.js';
import unserialize from './viewer.js';
const loadAbciQuery = async (node, subPath = '', dataMode = false, height) => {
try{
const mode = dataMode ? 'data' : 'children';
// legacy mode
const options = {
method: 'POST',
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'abci_query',
params: {
path: '/custom/vstorage/' + mode + '/' + subPath,
height: height && height.toString()
},
}),
};
console.log('>>> Options body:', options.body);
const res = await fetch(node, options);
const vResponse = (await res.json()).result.response;
if(vResponse.value){
const parsedValue = JSON.parse(atob(vResponse.value));
if(!dataMode) {
if(parsedValue.children.length) {
console.log('>>> ' + parsedValue.children.length + ' Children');
console.log(parsedValue.children)
} else {
console.warn('>>> No children');
}
console.warn('Now trying data...');
loadAbciQuery(node, subPath, true);
return;
}
//show data
const values = JSON.parse(parsedValue.value).values;
values.map(v => {
const m = unserialize(JSON.parse(v));
console.log(Object.keys(m));
console.log(m);
});
} else{
console.log('>>> No value');
console.log(vResponse.log);
}
}
catch(e){
console.log(e);
}
};
const rcps = {
agoric :{
mainA: 'https://main-a.rpc.agoric.net',
main: 'https://main.rpc.agoric.net',
},
polkachu: {
main:'https://agoric-rpc.polkachu.com/'
},
}
loadAbciQuery(rcps.agoric.mainA, 'published.wallet');