asch-cli icon indicating copy to clipboard operation
asch-cli copied to clipboard

update function to api v2

Open bassjobsen opened this issue 7 years ago • 1 comments

according https://github.com/AschPlatform/asch-docs/blob/master/http_api/en.md

bassjobsen avatar Aug 27 '18 20:08 bassjobsen

@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:

a1300 avatar Sep 17 '18 15:09 a1300