denominated units for balances in events#750
Conversation
|
Currently blocked by #654 in subxt repo |
|
Updated documentation will follow after the approval from code owners |
ascjones
left a comment
There was a problem hiding this comment.
The main thing is the code in balance.rs needs to be tightened up a bit, needs more tests since there are bugs there.
Also I think we are missing decoding Balance for contract events, for that the decode_contract_event would need to check for fields with the type name Balance: https://github.com/paritytech/cargo-contract/blob/05494e2bd62b48c6b79b99bd91c0657ee8656103/crates/transcode/src/lib.rs#L250
ascjones
left a comment
There was a problem hiding this comment.
The handling of the decimal parsing is much better now 👍
The conversion from raw u128 to DenominatedBalance needs some testing and tidying up.
One big thing that looks to be missing is the handling of Balance values when actually interacting with contracts. We should be able to use a denominated balance when invoking e.g. https://github.com/paritytech/ink/blob/master/examples/erc20/lib.rs#L130.
And also when displaying the resulting contract Transfer event: https://github.com/paritytech/ink/blob/master/examples/erc20/lib.rs#L27.
This needs to be done in https://github.com/paritytech/cargo-contract/blob/05494e2bd62b48c6b79b99bd91c0657ee8656103/crates/transcode/src/lib.rs#L250
There was a problem hiding this comment.
BalanceVariant::from still needs some tidying up.
For some inspiration, have a look at formatBalance that polkadot.js uses. It does so in a fairly concise manner. See e.g. calcSi
Closes #673
Example of denomination of balances when running a call on substrate contracts node:
Update
Balances can also be inputed in a denominated format (i.e.
500MDOTfor 500 x 10^6 x 10^<tokenDecimals>DOT).The token symbol must match the one specified in the running local chain. If the chain config does not have a token symbol and/or decimals.
UNITis used as a default symbol and 12 decimals are used for denominationThis includes:
--valueforcallandinstantiatecommands--storage_deposit_limitfor any commandIncludes fixes addressed in #751