WIP: Convert min stake and max stake values in zwalletcli to ZCN ,mZCN and other formats
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)
All ZCN related information need to change in the CLI input/output
@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.
Yes it makes sense to manage the common logic for calculation and presentation organized at one place.
It's 10^-10
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
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:
- getbalance (L32)
- minersc (L230)
- mswallet (L353)
- vesting (L77)
Zboxcli:
- getallocation (L99,L115-L121,L136-L138)
- readpool (L32,L39)
- stakepool (L17,L44,L84)
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)