-
Notifications
You must be signed in to change notification settings - Fork 213
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
Simplify multi-asset value conversions. #4125
Simplify multi-asset value conversions. #4125
Conversation
In particular, we simplify expressions of the following form: - `fromCardanoValue . Cardano.fromMaryValue` The above expression peforms the following two-step conversion: - From a ledger MA value (nested map) to a cardano-api MA value (flat map) - From a cardano-api MA value (flat map) to a wallet MA value (nested map) The `toWalletTokenBundle` function performs this conversion in a single step.
In particular, we simplify expressions of the following form: - `fromCardanoValue . Cardano.fromMaryValue` The above expression peforms the following two-step conversion: - From a ledger MA value (nested map) to a cardano-api MA value (flat map) - From a cardano-api MA value (flat map) to a wallet MA value (nested map) The `toWalletTokenBundle` function performs this conversion in a single step.
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.
👍
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.
This may risk entangling the wallet and cardano-balance-tx
more, but it may be worth it as it is better 🤔
I was thinking it could make things easier, as the dependency set of this particular conversion has been reduced in the following way: - {cardano-wallet-primitive, cardano-ledger, cardano-api}
+ {cardano-wallet-primitive, cardano-ledger} In other words, if we have a ledger value, or a primitive value, we'd no longer need to go via the equivalent OTOH, much of the |
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.
On second thought I really don't think there's a meaningful drawback with this in particular, but happy to discuss tomorrow anyway. My concern would be where Compatibility.Ledger
would live now / in the future and who'd depend on it.
Issue
None. Noticed while browsing the code.
Summary
This PR makes the following simplification in several places:
The original expression performs a two-step conversion of multi-asset (MA) values:
cardano-ledger
MA value (nested map) to acardano-api
MA value (flat map)cardano-api
MA value (flat map) to acardano-wallet
MA value (nested map)The
toWalletTokenBundle
function performs this conversion in a single step, and doesn't require the creation of an intermediatecardano-api
MA value.