-
Notifications
You must be signed in to change notification settings - Fork 217
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
Support of mint/burn of assets in decode transaction #3025
Support of mint/burn of assets in decode transaction #3025
Conversation
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.
Two comments so far:
-
So far, we've used the terminology "burned" rather than "burnt", both in our API types and in our internal algorithms. I think it would be good to be consistent and continue to use "burned" everywhere, rather than having a mixture of the two.
-
There are two fields in
ApiDecodedTransaction
:assets_minted
andassets_burned
that have the same typeApiMintedBurnedAssets
. Given that minted and burned assets are separated in this way, I think it's okay to say thatApiMintedBurnedAssets
can only contain positive values. Indeed, this provides a nicer mapping to our internal types, which do not allow negative values. What do you think?
specifications/api/swagger.yaml
Outdated
@@ -941,6 +941,19 @@ x-assetMint: &assetMint | |||
Positive values mean creation and negative values mean | |||
destruction. | |||
|
|||
x-assetMintedBurnt: &assetMintedBurnt |
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.
Suggestion: use "burned", rather than "burnt".
Elsewhere, we have used the "burned" terminology; it's probably good to be consistent.
x-assetMintedBurnt: &assetMintedBurnt | |
x-assetMintedBurned: &assetMintedBurned |
specifications/api/swagger.yaml
Outdated
@@ -2381,6 +2394,16 @@ components: | |||
description: | | |||
Withdrawals that could be external or belong to the wallet. | |||
|
|||
ApiMintedBurntAssets: &ApiMintedBurntAssets |
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.
ApiMintedBurntAssets: &ApiMintedBurntAssets | |
ApiMintedBurnedAssets: &ApiMintedBurnedAssets |
specifications/api/swagger.yaml
Outdated
@@ -2381,6 +2394,16 @@ components: | |||
description: | | |||
Withdrawals that could be external or belong to the wallet. | |||
|
|||
ApiMintedBurntAssets: &ApiMintedBurntAssets | |||
description: | | |||
Assets minted (created) or burnt (destroyed) |
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.
Assets minted (created) or burnt (destroyed) | |
Assets minted (created) or burned (destroyed) |
specifications/api/swagger.yaml
Outdated
assets_minted: *ApiMintedBurntAssets | ||
assets_burnt: *ApiMintedBurntAssets |
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'm wondering why are there two of these fields, when both of these fields are ApiMintedBurnedAssets
?
Shouldn't it be something like:
assets_minted: *ApiMintedAssets
assets_burned: *ApiBurnedAssets
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.
adopted
specifications/api/swagger.yaml
Outdated
Assets minted (created) or burnt (destroyed) | ||
This amount contributes to the total transaction value. | ||
Positive values denote creation of assets and negative values | ||
denote the reverse. |
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.
Given that you have two fields of this type, I think it would be okay to only allow positive values here.
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.
revised this fragments
thanks @jonathanknowles for looking at this. First of all, let's address only minting/burning in this PR, and certs in separate PR. When it comes to positive values for both minting/burning I think it is ok to have this like that. We can change this during adding minting/burning support in wallet soon, though. Right now it is the least invasive to have this with decomposition into minting and burning using positive values. |
3572145
to
e9cffcc
Compare
specifications/api/swagger.yaml
Outdated
|
||
ApiBurnedAssets: &ApiBurnedAssets | ||
description: | | ||
Assets burned (destroyed) |
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.
Assets burned (destroyed) | |
Assets burned (destroyed). |
specifications/api/swagger.yaml
Outdated
ApiMintedAssets: &ApiMintedAssets | ||
description: | | ||
Assets minted (created). | ||
This amount contributes to the total transaction value. |
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 amount contributes to the total transaction value. | |
The act of minting assets provides value to a transaction. |
specifications/api/swagger.yaml
Outdated
ApiBurnedAssets: &ApiBurnedAssets | ||
description: | | ||
Assets burned (destroyed) | ||
This amount contributes to the total transaction value. |
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 amount contributes to the total transaction value. | |
The act of burning assets consumes value from a transaction. |
(unsafeFromHex $ T.encodeUtf8 cborHexWithBurning) | ||
|
||
let (Right txBodyBurn) = Cardano.deserialiseFromTextEnvelope (Cardano.AsTxBody Cardano.AsAlonzoEra) textEnvelopeBurn | ||
let cborHexBurn = T.decodeUtf8 $ hex $ Cardano.serialiseToCBOR (Cardano.makeSignedTransaction [] txBodyBurn) |
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.
(line length limit)
let cborHexBurn = T.decodeUtf8 $ hex $ Cardano.serialiseToCBOR (Cardano.makeSignedTransaction [] txBodyBurn) | |
let cborHexBurn = T.decodeUtf8 | |
$ hex | |
$ Cardano.serialiseToCBOR | |
$ Cardano.makeSignedTransaction [] txBodyBurn |
"" | ||
(unsafeFromHex $ T.encodeUtf8 cborHexWithBurning) | ||
|
||
let (Right txBodyBurn) = Cardano.deserialiseFromTextEnvelope (Cardano.AsTxBody Cardano.AsAlonzoEra) textEnvelopeBurn |
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.
(line length limit)
let (Right txBodyBurn) = Cardano.deserialiseFromTextEnvelope (Cardano.AsTxBody Cardano.AsAlonzoEra) textEnvelopeBurn | |
let Right txBodyBurn = Cardano.deserialiseFromTextEnvelope | |
(Cardano.AsTxBody Cardano.AsAlonzoEra) | |
textEnvelopeBurn |
(unsafeFromHex $ T.encodeUtf8 cborHexWithMinting) | ||
|
||
let (Right txBodyMint) = Cardano.deserialiseFromTextEnvelope (Cardano.AsTxBody Cardano.AsAlonzoEra) textEnvelopeMint | ||
let cborHexMint = T.decodeUtf8 $ hex $ Cardano.serialiseToCBOR (Cardano.makeSignedTransaction [] txBodyMint) |
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.
(line length limit)
let cborHexMint = T.decodeUtf8 $ hex $ Cardano.serialiseToCBOR (Cardano.makeSignedTransaction [] txBodyMint) | |
let cborHexMint = T.decodeUtf8 | |
$ hex | |
$ Cardano.serialiseToCBOR | |
$ Cardano.makeSignedTransaction [] txBodyMint |
"" | ||
(unsafeFromHex $ T.encodeUtf8 cborHexWithMinting) | ||
|
||
let (Right txBodyMint) = Cardano.deserialiseFromTextEnvelope (Cardano.AsTxBody Cardano.AsAlonzoEra) textEnvelopeMint |
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.
(line length limit)
let (Right txBodyMint) = Cardano.deserialiseFromTextEnvelope (Cardano.AsTxBody Cardano.AsAlonzoEra) textEnvelopeMint | |
let Right txBodyMint = Cardano.deserialiseFromTextEnvelope | |
(Cardano.AsTxBody Cardano.AsAlonzoEra) | |
textEnvelopeMint |
let tokens = TokenMap.fromNestedList | ||
[(tokenPolicyId, NE.fromList [(UnsafeTokenName "HappyCoin", TokenQuantity 50000)])] |
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.
Suggestion: use TokenMap.singleton
here:
let tokens = TokenMap.fromNestedList | |
[(tokenPolicyId, NE.fromList [(UnsafeTokenName "HappyCoin", TokenQuantity 50000)])] | |
let tokens = TokenMap.singleton | |
(AssetId tokenPolicyId (UnsafeTokenName "HappyCoin")) | |
(TokenQuantity 50_000) |
(Link.decodeTransaction @'Shelley wa) Default decodeMintPayload | ||
verify rTx | ||
[ expectResponseCode HTTP.status202 | ||
, expectField (#fee . #getQuantity) (`shouldBe` 202725) |
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.
Suggestion: use NumericUnderscores
for extra clarity.
, expectField (#fee . #getQuantity) (`shouldBe` 202725) | |
, expectField (#fee . #getQuantity) (`shouldBe` 202_725) |
(Link.decodeTransaction @'Shelley wa) Default decodeBurnPayload | ||
verify rTx' | ||
[ expectResponseCode HTTP.status202 | ||
, expectField (#fee . #getQuantity) (`shouldBe` 202725) |
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.
Suggestion: use NumericUnderscores
for extra clarity.
, expectField (#fee . #getQuantity) (`shouldBe` 202725) | |
, expectField (#fee . #getQuantity) (`shouldBe` 202_725) |
bors r+ |
Build succeeded: |
I will add supports for certs with integration tests in next PR
Comments
Issue Number