zwalletcli icon indicating copy to clipboard operation
zwalletcli copied to clipboard

WIP: Convert min stake and max stake values in zwalletcli to ZCN ,mZCN and other formats

Open hm90121 opened this issue 4 years ago • 7 comments

Hello @vudn95 here is a sample output for ./zwallet mn-info command.

{
   "simple_miner":{
      "id":"110b07984a6592ae67f1830366f47c835f6f5f262be19ee4aedd1b9acf870aee",
      "n2n_host":"five.devnet-0chain.net",
      "host":"five.devnet-0chain.net",
      "port":31202,
      "path":"miner02",
      "public_key":"7f7a0515ae68eadee6eac5915519802911c7c7341d1ef23d913728aed47dc8090548a56031732d16916e203c4e41c2a32d022fe56758ba3956cc73b112f0961c",
      "short_name":"localhost.m02",
      "build_tag":"40058cb8b6aeeb95e61229702f29de4c7118ebaf",
      "total_stake":0,
      "delegate_wallet":"110b07984a6592ae67f1830366f47c835f6f5f262be19ee4aedd1b9acf870aee",
      "service_charge":0.1,
      "number_of_delegates":10,
      "min_stake":0,
      "max_stake":1000000000000,
      "stat":{
         "generator_rewards":187795440000000
      },
      "node_type":"miner",
      "last_health_check":1620947267
   }
}
Here min_stake and max_stake values have to be converted into ZCN and other formats
Also, in any other places or responses or flags in zwalletcli where these value types are used,they have to be converted to ZCN and other formats.

the value conversion table is as follows:
1 ZCN = 1,000 mZCN = 1,000,000 µZCN
0.1 ZCN = 100 mZCN = 100,000 µZCN
0.01 ZCN = 10 mZCN = 10,000 µZCN
0.001 ZCN = 1 mZCN = 1,000 µZCN
0.0001 ZCN = 0.1 mZCN = 100 µZCN
0.00001 ZCN = 0.01 mZCN = 10 µZCN
0.000001 ZCN = 0.001 mZCN = 1 µZCN
0.0000001 ZCN = 0.0001 mZCN = 0.1 µZCN
0.00000001 ZCN = 0.00001 mZCN = 0.01 µZCN
0.000000001 ZCN = 0.000001 mZCN = 0.001 µZCN
0.0000000001 ZCN = 0.0000001 mZCN = 0.0001 µZCN = 1 sas (Saswata, smallest unit, nickname) (edited)





hm90121 avatar May 13 '21 23:05 hm90121

All ZCN related information need to change in the CLI input/output

guruhubb avatar May 14 '21 00:05 guruhubb

@guruhubb,

So the default unit for ZCN will be 1 sas, which is equal to 10^-9 ZCN, right? If so, it means that an account with a balance of 1000,000,000 will have 1 ZCN. I think the best way to solve this is to use a common token type "ZCN" across all the applications with a unified encoding, decoding, computation, formatting, and parsing logic. It will bring consistency in usage of ZCN type across all repos. Let me know what you think.

bbist avatar May 16 '21 05:05 bbist

Yes it makes sense to manage the common logic for calculation and presentation organized at one place.

guruhubb avatar May 18 '21 20:05 guruhubb

It's 10^-10

sculptex avatar May 30 '21 11:05 sculptex

I don't think this is in the realm of CLI output which should remain in Saswata (10^-10) (smallest units). Only for GUI and formatted commands should currency formatting be used, certainly not in JSON output

sculptex avatar Jul 11 '21 22:07 sculptex

PLEASE UPDATE THIS COMMENT IF YOU FIND SOME CLI OUTPUT THAT DOESN'T FORMAT TOKEN (except JSON).

List of commands ZCN is used for CLI output:

Zwalletcli:

  1. getbalance (L32)
  2. minersc (L230)
  3. mswallet (L353)
  4. vesting (L77)

Zboxcli:

  1. getallocation (L99,L115-L121,L136-L138)
  2. readpool (L32,L39)
  3. stakepool (L17,L44,L84)

bbist avatar Sep 08 '21 10:09 bbist

Please can we offer a standardized option for all commands to return results, (especially those returning ZCN currency balance) as json via --json option as per :-

https://github.com/0chain/zwalletcli/blob/staging/cmd/getbalance.go (^ Link updated since merged)

sculptex avatar May 16 '22 20:05 sculptex