Skip to content
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

feat: add support for TX attribute: protocol parameters update #599

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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