Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Conversation

@sorpaas
Copy link
Contributor

@sorpaas sorpaas commented Mar 16, 2021

This adds a usable_balance_for function to the Currency trait. In situations like EVM, we care about the actually transferrable balance, which currently can't be fetched via the Currency trait. With this function we can do usable_balance_for(account_id, WithdrawReasons::TRANSFER).

@github-actions github-actions bot added the A0-please_review Pull request needs code review. label Mar 16, 2021
@sorpaas sorpaas added A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). B3-apinoteworthy C1-low PR touches the given topic and has a low impact on builders. and removed A0-please_review Pull request needs code review. labels Mar 16, 2021
@sorpaas
Copy link
Contributor Author

sorpaas commented Mar 16, 2021

^ It shouldn't need any Polkadot PR. The CI error looks like something else unrelated.

@gavofyork
Copy link
Member

under what circumstance is this needed?

@sorpaas
Copy link
Contributor Author

sorpaas commented Mar 16, 2021

@gavofyork pallet-evm needs something like this. Right now, the EVM would return the account balance as free_balance. This, however, breaks the usual EVM assumption that if a balance is available, then it can be used in TRANSFER. By changing the returned balance to used_balance_for(TRANSFER) this issue can be then fixed.

@JoshOrndorff
Copy link
Contributor

Is there any intention to merge this? If so the Moonbeam team is willing to brush the dust off of it. If this won't be merged we can begin looking for other solutions to polkadot-evm/frontier#291

@gui1117
Copy link
Contributor

gui1117 commented Apr 13, 2021

now that https://crates.parity.io/frame_support/traits/tokens/fungible/trait.Inspect.html#tymethod.reducible_balance exists I think this is no longer required no ?

Also this doesn't take into account the providers restriction. so people could expect to be able to withdraw the total amount where it is actually not possible.
Related paritytech/polkadot-sdk#335

@sorpaas
Copy link
Contributor Author

sorpaas commented May 7, 2021

@thiolliere Yeah I think you're right. This can be closed now!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). C1-low PR touches the given topic and has a low impact on builders.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants