-
Notifications
You must be signed in to change notification settings - Fork 25
Implement writeTxFileTextEnvelope and writeTxFileTextEnvelopeCanonical for SignedTx
#1033
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
base: master
Are you sure you want to change the base?
Implement writeTxFileTextEnvelope and writeTxFileTextEnvelopeCanonical for SignedTx
#1033
Conversation
00d933e to
292cdc0
Compare
292cdc0 to
fee95da
Compare
palas
left a comment
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.
Just a few comments. Make sure the potential incompatibility issue is not a problem, and the rest are only suggestions
| serialiseToRawBytes (SignedTx tx) = | ||
| Ledger.serialize' (Ledger.eraProtVerHigh @(LedgerEra era)) tx | ||
| deserialiseFromRawBytes _ = | ||
| bimap wrapError SignedTx | ||
| . Ledger.decodeFullAnnotator | ||
| (Ledger.eraProtVerHigh @(LedgerEra era)) | ||
| "SignedTx" | ||
| Ledger.decCBOR | ||
| . fromStrict | ||
| where | ||
| wrapError | ||
| :: Ledger.DecoderError -> SerialiseAsRawBytesError | ||
| wrapError = SerialiseAsRawBytesError . displayException |
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 think this can probably be implemented in terms of SerialiseAsCBOR now, or the other way around, because they are almost identical code except for the error handling
| . fromStrict | ||
|
|
||
| instance (L.EraTx (LedgerEra era), HasTypeProxy era) => HasTextEnvelope (SignedTx era) where | ||
| textEnvelopeType _ = "Tx" |
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 break compatibility with the old API text envelope type:
| instance IsShelleyBasedEra era => HasTextEnvelope (Tx era) where |
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.
Also, do you have in mind how will deserialising work without knowing the era? I guess because we have only two eras is not too problematic, but we may need two separate functions (one for each era).
| either | ||
| ( \err -> | ||
| error $ | ||
| "writeTxFileTextEnvelopeCanonical: Impossible - deserialisation of just serialised bytes failed " | ||
| <> show err | ||
| ) | ||
| id | ||
| . canonicaliseCborBs | ||
| $ teRawCBOR te |
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.
Changelog
Context
Additional context for the PR goes here. If the PR fixes a particular issue please provide a link to the issue.
How to trust this PR
Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.
Checklist