Last active
January 11, 2020 03:50
-
-
Save eonwarped/d2d4f216b03c1ef1ba1ae010f4816fca to your computer and use it in GitHub Desktop.
looping through smt balances...
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 get_bal(start, limit) { | |
if (!limit) { | |
limit = 1000; | |
} | |
token_resp = fetch("https://testnet.steemitdev.com/", {"credentials":"omit","headers":{"accept":"application/json, text/plain, */*","accept-language":"en-US,en;q=0.9","content-type":"application/json","sec-fetch-mode":"cors","sec-fetch-site":"cross-site"},"referrer":"http://localhost:8080/themorningbowl/@davedickeyyall/new-weed-and-beneficiaries-on-themorningbowl","referrerPolicy":"no-referrer-when-downgrade","body":JSON.stringify({id:2,jsonrpc:"2.0",method:"call",params:["database_api","list_smt_tokens",{limit: limit, order: "by_symbol", "start": start}]}),"method":"POST","mode":"cors"}); | |
token_resp.then(x => x.json()).then(x => { x.result.tokens.forEach(y => { | |
if(y.token.liquid_symbol.nai == '@@333185944') { | |
console.log("found 333185944"); | |
console.log(y); | |
} | |
if(y.token.phase == 'launch_success' && y.token.current_supply > 0) { | |
console.log("launch success+supply: " + JSON.stringify(y.token.liquid_symbol)); | |
fetch("https://testnet.steemitdev.com/", {"credentials":"omit","headers":{"accept":"application/json, text/plain, */*","accept-language":"en-US,en;q=0.9","content-type":"application/json","sec-fetch-mode":"cors","sec-fetch-site":"cross-site"},"referrer":"http://localhost:8080/themorningbowl/@davedickeyyall/new-weed-and-beneficiaries-on-themorningbowl","referrerPolicy":"no-referrer-when-downgrade","body":JSON.stringify({id:2,jsonrpc:"2.0",method:"call",params:["database_api","list_smt_token_balances",{order: "by_account_symbol", limit: 10, start: ["petanque", y.token.liquid_symbol]}]}),"method":"POST","mode":"cors"}).then(x => x.json()).then(x => { | |
if (x.result.balances.length > 0) { | |
console.log(x.result); | |
} | |
}); | |
}}); | |
last_nai = x.result.tokens.pop().token.liquid_symbol; | |
console.log(last_nai); | |
if (last_nai && x.result.tokens.length == limit - 1) { | |
get_bal(last_nai, limit); | |
} | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment