Created
May 14, 2020 10:23
-
-
Save nicola-attico/84be6a46459e6cd93b2938b15944d22b to your computer and use it in GitHub Desktop.
User Balances Def V2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function executeQuery(v_table, v_query) { | |
var foo = new ECCCommandV2(); | |
var json = new JSON(); | |
var xmlDoc = new XMLDocument2(); | |
var w = new GlideRecord('u_wallet'); | |
var warr = []; | |
w.addQuery("u_company",""); | |
var a = 0; | |
w.query(); | |
while (w.next()) { | |
warr[a] = { | |
"sysid": w.getValue("sys_id"), | |
"u_address": w.getValue("u_address") | |
}; | |
a++; | |
} | |
// gs.log(JSON.stringify(warr), "777warr"); | |
var t = new GlideRecord('u_token_registry'); | |
var tarr = []; | |
var b = 0; | |
// t.addQuery('u_status', '=', 'deployed'); | |
t.query(); | |
while (t.next()) { | |
tarr[b] = { | |
"sysid": t.getValue("sys_id"), | |
"u_contract_address": t.getValue("u_contract_address") | |
}; | |
b++; | |
} | |
for (x = 0; x < warr.length; x++) { | |
for (y = 0; y < tarr.length; y++) { | |
var commandReturn = foo.runCommand("geth2", 'node /home/nicola/nowtoken/getBalances.js ' + tarr[y].u_contract_address + ' ' + warr[x].u_address); | |
var xmlPayload = commandReturn.response_payload_xml; | |
xmlDoc.parseXML(xmlPayload); | |
var myResponse = xmlDoc.getFirstNode('/results/result/stdout').getTextContent().toString(); | |
var myJSON = json.decode(myResponse); | |
gs.log("myJSON" + json.encode(myJSON), "myJSON"); | |
var map = {}; | |
map['u_wallet'] = warr[x].sysid; | |
map['u_token'] = tarr[y].sysid; | |
map['u_balance'] = myJSON.balance.slice(0, -18) || 0; | |
v_table.addRow(map); | |
} | |
} | |
})(v_table, v_query); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment