Skip to content

Commit

Permalink
feat: add support for TX attribute: protocol parameters update (#599)
Browse files Browse the repository at this point in the history
Signed-off-by: Ales Verbic <verbotenj@blinklabs.io>
  • Loading branch information
verbotenj committed Apr 29, 2024
1 parent 77a9387 commit cdfeb4b
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ledger/allegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ func (t AllegraTransaction) IsValid() bool {
return true
}

func (t *AllegraTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
updateMap := make(map[Blake2b224]any)
for k, v := range t.Body.Update.ProtocolParamUpdates {
updateMap[k] = v
}
return updateMap
}

func (t *AllegraTransaction) Cbor() []byte {
// Return stored CBOR if we have any
cborData := t.DecodeStoreCbor.Cbor()
Expand Down
8 changes: 8 additions & 0 deletions ledger/alonzo.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ func (t AlonzoTransaction) IsValid() bool {
return t.IsTxValid
}

func (t *AlonzoTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
updateMap := make(map[Blake2b224]any)
for k, v := range t.Body.Update.ProtocolParamUpdates {
updateMap[k] = v
}
return updateMap
}

func (t *AlonzoTransaction) Cbor() []byte {
// Return stored CBOR if we have any
cborData := t.DecodeStoreCbor.Cbor()
Expand Down
8 changes: 8 additions & 0 deletions ledger/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,14 @@ func (t BabbageTransaction) IsValid() bool {
return t.IsTxValid
}

func (t *BabbageTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
updateMap := make(map[Blake2b224]any)
for k, v := range t.Body.Update.ProtocolParamUpdates {
updateMap[k] = v
}
return updateMap
}

func (t *BabbageTransaction) Cbor() []byte {
// Return stored CBOR if we have any
cborData := t.DecodeStoreCbor.Cbor()
Expand Down
9 changes: 9 additions & 0 deletions ledger/byron.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ func (t *ByronTransaction) Utxorpc() *utxorpc.Tx {
return &utxorpc.Tx{}
}

func (t *ByronTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
// TODO: Implement this add missing Body TransactionBody
updateMap := make(map[Blake2b224]any)
// for k, v := range t.Body.Update.ProtocolParamUpdates {
// updateMap[k] = v
// }
return updateMap
}

type ByronTransactionInput struct {
cbor.StructAsArray
TxId Blake2b256
Expand Down
8 changes: 8 additions & 0 deletions ledger/conway.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ func (t ConwayTransaction) IsValid() bool {
return t.IsTxValid
}

func (t *ConwayTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
updateMap := make(map[Blake2b224]any)
for k, v := range t.Body.Update.ProtocolParamUpdates {
updateMap[k] = v
}
return updateMap
}

func (t *ConwayTransaction) Cbor() []byte {
// Return stored CBOR if we have any
cborData := t.DecodeStoreCbor.Cbor()
Expand Down
8 changes: 8 additions & 0 deletions ledger/mary.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ func (t MaryTransaction) IsValid() bool {
return true
}

func (t *MaryTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
updateMap := make(map[Blake2b224]any)
for k, v := range t.Body.Update.ProtocolParamUpdates {
updateMap[k] = v
}
return updateMap
}

func (t *MaryTransaction) Cbor() []byte {
// Return stored CBOR if we have any
cborData := t.DecodeStoreCbor.Cbor()
Expand Down
8 changes: 8 additions & 0 deletions ledger/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ func (t ShelleyTransaction) Utxorpc() *utxorpc.Tx {
return t.Body.Utxorpc()
}

func (t *ShelleyTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
updateMap := make(map[Blake2b224]any)
for k, v := range t.Body.Update.ProtocolParamUpdates {
updateMap[k] = v
}
return updateMap
}

func (t *ShelleyTransaction) Cbor() []byte {
// Return stored CBOR if we have any
cborData := t.DecodeStoreCbor.Cbor()
Expand Down
1 change: 1 addition & 0 deletions ledger/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Transaction interface {
TransactionBody
Metadata() *cbor.Value
IsValid() bool
ProtocolParametersUpdate() map[Blake2b224]any
}

type TransactionBody interface {
Expand Down

0 comments on commit cdfeb4b

Please sign in to comment.