-
Notifications
You must be signed in to change notification settings - Fork 25
Make 1-1 relationship of witness and policy ID in TxMintValue instead of 1-* #776
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
Make 1-1 relationship of witness and policy ID in TxMintValue instead of 1-* #776
Conversation
14c56ca
to
38cd583
Compare
f4ca29b
to
7e341b2
Compare
ee0da17
to
109a495
Compare
… of 1-* * Remove exports: `parseValue`, `ParserValueRole` * Add new type `PolicyAssets` representing minted assets within a single PolicyId * Add `mkTxMintValue` helper function
109a495
to
ed64a00
Compare
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.
One comment
Mary.scaledMinDeposit (toMaryValue v) | ||
|
||
-- | Map of non-ADA assets with their quantity, for a single policy | ||
newtype PolicyAssets = PolicyAssets (Map AssetName Quantity) |
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.
Almost everywhere PolicyAssets
is used in a Map
i.e Map PolicyId PolicyAssets
. Why not make this type:
newtype PolicyAssets = PolicyAssets (Map PolicyId (Map AssetName Quantity))
?
And if we're doing that, we can just use the ledger type directly newtype MultiAsset = MultiAsset (Map PolicyID (Map AssetName Integer))
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.
I agree. But the main purpose of this type is to use it in TxMintValue
where we have one witness per policy ID. So we need some type aggregating assets and quantities. You can't do it in a nice way if you have a type Map PolicyId (Map AssetName Quantity)
- you'd have to keep two maps (one with quantities and the otehr with witnesses) and make sure they're in sync... cumbersome and error prone.
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.
An alternative would be to just use Map AssetName Quantity
there, but it's annoying to handle: you'd need to write operations like merging or negating by hand. So this newtype
provides MonoFunctor
and Semigroup
instances making those operations easier.
Changelog
Context
Fixes:
Previous related changes to
TxMintValue
:TxMintValue
#663Used in:
Checklist