Author Topic: [API] list_account_balances inconsistent "amount" type (string/Int)  (Read 1493 times)

0 Members and 1 Guest are viewing this topic.

Xeldal

  • Guest
is this the intended function?   surely I'm not the only one who's run into this.  If this is only a problem in my mind, I'd appreciate someone pointing it out.

Currently the API is a mess to try and use.  BTS1 API was bad but BTS2 is actually worse.  To get the information I need anywhere else It generally takes 1 API call.  With BitShares it takes 3 or 4.   Not to mention all these special cases where sometimes its presented one way and other times another.  What should take 50 lines of code ends up taking 200.

I saw the two different types too.  My guess is that some amounts are too large to be stored in an 'integer' type (since it depends on the interpreter/programming language  which receives the json message) and hence they use 'string' type for larger values (larger than an integer type can hold).

I see.  Thanks.  If thats the case maybe we should just return everything as a string.  I don't know standard practice but it seems odd that we would mix types like that.

Offline cube

  • Hero Member
  • *****
  • Posts: 1404
  • Bit by bit, we will get there!
    • View Profile
  • BitShares: bitcube
is this the intended function?   surely I'm not the only one who's run into this.  If this is only a problem in my mind, I'd appreciate someone pointing it out.

Currently the API is a mess to try and use.  BTS1 API was bad but BTS2 is actually worse.  To get the information I need anywhere else It generally takes 1 API call.  With BitShares it takes 3 or 4.   Not to mention all these special cases where sometimes its presented one way and other times another.  What should take 50 lines of code ends up taking 200.

I saw the two different types too.  My guess is that some amounts are too large to be stored in an 'integer' type (since it depends on the interpreter/programming language  which receives the json message) and hence they use 'string' type for larger values (larger than an integer type can hold).
ID: bitcube
bitcube is a dedicated witness and committe member. Please vote for bitcube.

Xeldal

  • Guest
is this the intended function?   surely I'm not the only one who's run into this.  If this is only a problem in my mind, I'd appreciate someone pointing it out.

Currently the API is a mess to try and use.  BTS1 API was bad but BTS2 is actually worse.  To get the information I need anywhere else It generally takes 1 API call.  With BitShares it takes 3 or 4.   Not to mention all these special cases where sometimes its presented one way and other times another.  What should take 50 lines of code ends up taking 200.   



Xeldal

  • Guest
In addition.  From API call "get_limit_orders BTS BTC 10" .  9 out of 10 amount entries are Integers and 1 is a string for the same 1.3.0 asset.

wtf?  is the string entry an old order placed under a different version? or is it something else?
Quote
  },{
    "id": "1.7.1599",
    "expiration": "2020-10-23T19:07:31",
    "seller": "1.2.137",
    "for_sale": 568625028,
    "sell_price": {
      "base": {
        "amount": 888000000,    <--------Integer
        "asset_id": "1.3.0"             <---BTS
      },
      "quote": {
        "amount": 12000000,
        "asset_id": "1.3.103"     
      }
    }
  },{
    "id": "1.7.1533",
    "expiration": "2020-10-23T09:30:05",
    "seller": "1.2.34307",
    "for_sale": "7325100000",     
    "sell_price": {
      "base": {
        "amount": "7325100000",     <----------String
        "asset_id": "1.3.0"                  <-----BTS
      },
      "quote": {
        "amount": 100000000,
        "asset_id": "1.3.103"
      }
    }
  },{

Xeldal

  • Guest
Noticed in the return from list_account_balances all "amount" fields are integers with the exception of asset "1.3.0" (BTS) which returns as a string?

Is there a reason for this?

BitShares-2.15.294-x64-cli-tools

Quote
[
   {
      "amount":"11271",   <----- String
      "asset_id":"1.3.0"
   },
   {
      "amount":49990,      <------- Integer
      "asset_id":"1.3.535"
   },
   {
      "amount":4808,    <------- Integer
      "asset_id":"1.3.103"
   },
   {
      "amount":449,    <------- Integer
      "asset_id":"1.3.113"
   },
   {
      "amount":5007,
      "asset_id":"1.3.121"
   },
   {
      "amount":10,
      "asset_id":"1.3.127"
   }
]