-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.
500MDOT
for 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.
UNIT
is used as a default symbol and 12 decimals are used for denominationThis includes:
--value
forcall
andinstantiate
commands--storage_deposit_limit
for any commandIncludes fixes addressed in #751