Skip to content

Commit

Permalink
feat:add Mary protocol parameters support
Browse files Browse the repository at this point in the history
Signed-off-by: Ales Verbic <[email protected]>
  • Loading branch information
verbotenj committed Apr 18, 2024
1 parent 0b2aa02 commit 997486d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
23 changes: 21 additions & 2 deletions ledger/mary.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type MaryBlock struct {
cbor.DecodeStoreCbor
Header *MaryBlockHeader
TransactionBodies []MaryTransactionBody
TransactionWitnessSets []ShelleyTransactionWitnessSet
TransactionWitnessSets []MaryTransactionWitnessSet
TransactionMetadataSet map[uint]*cbor.Value
}

Expand Down Expand Up @@ -115,6 +115,11 @@ func (h *MaryBlockHeader) Era() Era {

type MaryTransactionBody struct {
AllegraTransactionBody
Update struct {
cbor.StructAsArray
ProtocolParamUpdates map[Blake2b224]MaryProtocolParameterUpdate
Epoch uint64
} `cbor:"6,keyasint,omitempty"`
TxOutputs []MaryTransactionOutput `cbor:"1,keyasint,omitempty"`
Mint MultiAsset[MultiAssetTypeMint] `cbor:"9,keyasint,omitempty"`
}
Expand All @@ -136,10 +141,16 @@ type MaryTransaction struct {
cbor.StructAsArray
cbor.DecodeStoreCbor
Body MaryTransactionBody
WitnessSet ShelleyTransactionWitnessSet
WitnessSet MaryTransactionWitnessSet
TxMetadata *cbor.Value
}

type MaryTransactionWitnessSet struct {
ShelleyTransactionWitnessSet
Script []interface{} `cbor:"4,keyasint,omitempty"`
PlutusScripts []interface{} `cbor:"5,keyasint,omitempty"`
}

func (t MaryTransaction) Hash() string {
return t.Body.Hash()
}
Expand Down Expand Up @@ -275,6 +286,14 @@ func (v *MaryTransactionOutputValue) MarshalCBOR() ([]byte, error) {
}
}

type MaryProtocolParameters struct {
AllegraProtocolParameters
}

type MaryProtocolParameterUpdate struct {
AllegraProtocolParameterUpdate
}

func NewMaryBlockFromCbor(data []byte) (*MaryBlock, error) {
var maryBlock MaryBlock
if _, err := cbor.Decode(data, &maryBlock); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions protocol/localstatequery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error)
return nil, err
}
return result[0], nil
case ledger.EraIdMary:
result := []ledger.MaryProtocolParameters{}
if err := c.runQuery(query, &result); err != nil {
return nil, err
}
return result[0], nil
case ledger.EraIdAllegra:
result := []ledger.AllegraProtocolParameters{}
if err := c.runQuery(query, &result); err != nil {
Expand Down

0 comments on commit 997486d

Please sign in to comment.