asch-cli
asch-cli copied to clipboard
update function to api v2
according https://github.com/AschPlatform/asch-docs/blob/master/http_api/en.md
@bassjobsen
Review:
1
please use string interpolation instead of + adding strings
Example:
- getApi().get('/api/v2/accounts/' + address, null, function (err, result) {
+ getApi().get(`/api/v2/accounts/${address}`, null, function (err, result) {
2
I get an error if I call getBalance without an address. You don't need to necessary fix this. It depends upon how similar functions handle this:
bin/asch-cli getbalance
Error:
/home/a1300/test/asch-cli/plugins/api.js:50
console.log(err || result.account.xas);
^
TypeError: Cannot read property 'xas' of undefined
3
If I call bin/asch-cli getbalance AHMCKebuL2nRYDgszf9J2KjVZzAw95WUyB and the address wasn't initated before (it has no entry in the Account table) then it throws an error:
Response:
{
"success": true,
"unconfirmedAccount": null,
"latestBlock": {
"height": -1
},
"version": {
"version": "1.5.0",
"build": "DEFAULT_BUILD_TIME",
"net": "testnet"
}
}
Error:
/home/a1300/test/asch-cli/plugins/api.js:51
console.log(err || result.account.xas);
^
TypeError: Cannot read property 'xas' of undefined
Please fix the small problems. Thanks :+1: