-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Support proper encoding/decoding of TX metadata #1159
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
Changes from all commits
26ca7b1
c33f52c
ab68fa6
24cf723
3d7d169
8768206
d7914eb
eb23dd3
482298b
1c3165d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,7 @@ type AllegraBlock struct { | |
| BlockHeader *AllegraBlockHeader | ||
| TransactionBodies []AllegraTransactionBody | ||
| TransactionWitnessSets []shelley.ShelleyTransactionWitnessSet | ||
| TransactionMetadataSet map[uint]*cbor.LazyValue | ||
| TransactionMetadataSet common.TransactionMetadataSet | ||
| } | ||
|
|
||
| func (b *AllegraBlock) UnmarshalCBOR(cborData []byte) error { | ||
|
|
@@ -239,7 +239,7 @@ type AllegraTransaction struct { | |
| hash *common.Blake2b256 | ||
| Body AllegraTransactionBody | ||
| WitnessSet shelley.ShelleyTransactionWitnessSet | ||
| TxMetadata *cbor.LazyValue | ||
| TxMetadata common.TransactionMetadatum | ||
| } | ||
|
|
||
| func (t *AllegraTransaction) UnmarshalCBOR(cborData []byte) error { | ||
|
|
@@ -349,7 +349,7 @@ func (t AllegraTransaction) Donation() uint64 { | |
| return t.Body.Donation() | ||
| } | ||
|
|
||
| func (t AllegraTransaction) Metadata() *cbor.LazyValue { | ||
| func (t AllegraTransaction) Metadata() common.TransactionMetadatum { | ||
| return t.TxMetadata | ||
| } | ||
|
|
||
|
|
@@ -411,7 +411,7 @@ func (t *AllegraTransaction) Cbor() []byte { | |
| cbor.RawMessage(t.WitnessSet.Cbor()), | ||
| } | ||
| if t.TxMetadata != nil { | ||
| tmpObj = append(tmpObj, cbor.RawMessage(t.TxMetadata.Cbor())) | ||
| tmpObj = append(tmpObj, t.TxMetadata) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt for AI agents |
||
| } else { | ||
| tmpObj = append(tmpObj, nil) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,7 @@ type AlonzoBlock struct { | |
| BlockHeader *AlonzoBlockHeader | ||
| TransactionBodies []AlonzoTransactionBody | ||
| TransactionWitnessSets []AlonzoTransactionWitnessSet | ||
| TransactionMetadataSet map[uint]*cbor.LazyValue | ||
| TransactionMetadataSet common.TransactionMetadataSet | ||
| InvalidTransactions []uint | ||
| } | ||
|
|
||
|
|
@@ -86,7 +86,7 @@ func (b *AlonzoBlock) MarshalCBOR() ([]byte, error) { | |
| BlockHeader *AlonzoBlockHeader | ||
| TransactionBodies []AlonzoTransactionBody | ||
| TransactionWitnessSets []AlonzoTransactionWitnessSet | ||
| TransactionMetadataSet map[uint]*cbor.LazyValue | ||
| TransactionMetadataSet common.TransactionMetadataSet | ||
| InvalidTransactions cbor.IndefLengthList | ||
| } | ||
|
|
||
|
|
@@ -633,7 +633,7 @@ type AlonzoTransaction struct { | |
| Body AlonzoTransactionBody | ||
| WitnessSet AlonzoTransactionWitnessSet | ||
| TxIsValid bool | ||
| TxMetadata *cbor.LazyValue | ||
| TxMetadata common.TransactionMetadatum | ||
| } | ||
|
|
||
| func (t *AlonzoTransaction) UnmarshalCBOR(cborData []byte) error { | ||
|
|
@@ -747,7 +747,7 @@ func (t AlonzoTransaction) Donation() uint64 { | |
| return t.Body.Donation() | ||
| } | ||
|
|
||
| func (t AlonzoTransaction) Metadata() *cbor.LazyValue { | ||
| func (t AlonzoTransaction) Metadata() common.TransactionMetadatum { | ||
| return t.TxMetadata | ||
| } | ||
|
|
||
|
|
@@ -807,7 +807,7 @@ func (t *AlonzoTransaction) Cbor() []byte { | |
| t.TxIsValid, | ||
| } | ||
| if t.TxMetadata != nil { | ||
| tmpObj = append(tmpObj, cbor.RawMessage(t.TxMetadata.Cbor())) | ||
| tmpObj = append(tmpObj, t.TxMetadata) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt for AI agents |
||
| } else { | ||
| tmpObj = append(tmpObj, nil) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,7 +142,7 @@ type ByronTransaction struct { | |
| hash *common.Blake2b256 | ||
| TxInputs []ByronTransactionInput | ||
| TxOutputs []ByronTransactionOutput | ||
| Attributes *cbor.LazyValue | ||
| Attributes cbor.RawMessage | ||
| } | ||
|
|
||
| func (t *ByronTransaction) UnmarshalCBOR(cborData []byte) error { | ||
|
|
@@ -275,8 +275,8 @@ func (t *ByronTransaction) Donation() uint64 { | |
| return 0 | ||
| } | ||
|
|
||
| func (t *ByronTransaction) Metadata() *cbor.LazyValue { | ||
| return t.Attributes | ||
| func (t *ByronTransaction) Metadata() common.TransactionMetadatum { | ||
| return nil | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is definitely not correct. This probably needs its own Byron-specific type, since it'll be different from things afterwards. |
||
| } | ||
|
|
||
| func (t *ByronTransaction) LeiosHash() common.Blake2b256 { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Metadata is appended as a raw struct, so the generated transaction CBOR will encode Go struct fields instead of the Cardano metadata representation.
Prompt for AI agents