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

chore: move ProtocolParametersUpdate() to TransactionBody interface #658

Merged
merged 1 commit into from
Jun 12, 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
16 changes: 10 additions & 6 deletions ledger/allegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ func (b *AllegraTransactionBody) ValidityIntervalStart() uint64 {
return b.TxValidityIntervalStart
}

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

type AllegraTransaction struct {
cbor.StructAsArray
cbor.DecodeStoreCbor
Expand Down Expand Up @@ -238,12 +246,8 @@ func (t AllegraTransaction) Produced() []TransactionOutput {
return t.Outputs()
}

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) ProtocolParametersUpdate() map[Blake2b224]any {
return t.Body.ProtocolParametersUpdate()
}

func (t *AllegraTransaction) Cbor() []byte {
Expand Down
20 changes: 12 additions & 8 deletions ledger/alonzo.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ func (b *AlonzoTransactionBody) Outputs() []TransactionOutput {
return ret
}

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

func (b *AlonzoTransactionBody) Collateral() []TransactionInput {
ret := []TransactionInput{}
for _, collateral := range b.TxCollateral {
Expand Down Expand Up @@ -289,6 +297,10 @@ func (t AlonzoTransaction) ValidityIntervalStart() uint64 {
return t.Body.ValidityIntervalStart()
}

func (t AlonzoTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
return t.Body.ProtocolParametersUpdate()
}

func (t AlonzoTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}
Expand Down Expand Up @@ -370,14 +382,6 @@ func (t AlonzoTransaction) Produced() []TransactionOutput {
}
}

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
20 changes: 12 additions & 8 deletions ledger/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ func (b *BabbageTransactionBody) Outputs() []TransactionOutput {
return ret
}

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

func (b *BabbageTransactionBody) ReferenceInputs() []TransactionInput {
ret := []TransactionInput{}
for _, input := range b.TxReferenceInputs {
Expand Down Expand Up @@ -455,6 +463,10 @@ func (t BabbageTransaction) ValidityIntervalStart() uint64 {
return t.Body.ValidityIntervalStart()
}

func (t BabbageTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
return t.Body.ProtocolParametersUpdate()
}

func (t BabbageTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}
Expand Down Expand Up @@ -538,14 +550,6 @@ func (t BabbageTransaction) Produced() []TransactionOutput {
}
}

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
20 changes: 12 additions & 8 deletions ledger/conway.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ func (b *ConwayTransactionBody) UnmarshalCBOR(cborData []byte) error {
return b.UnmarshalCbor(cborData, b)
}

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

func (b *ConwayTransactionBody) VotingProcedures() VotingProcedures {
return b.TxVotingProcedures
}
Expand Down Expand Up @@ -357,6 +365,10 @@ func (t ConwayTransaction) ValidityIntervalStart() uint64 {
return t.Body.ValidityIntervalStart()
}

func (t ConwayTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
return t.Body.ProtocolParametersUpdate()
}

func (t ConwayTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}
Expand Down Expand Up @@ -440,14 +452,6 @@ func (t ConwayTransaction) Produced() []TransactionOutput {
}
}

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
20 changes: 12 additions & 8 deletions ledger/mary.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ func (b *MaryTransactionBody) Outputs() []TransactionOutput {
return ret
}

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

func (b *MaryTransactionBody) AssetMint() *MultiAsset[MultiAssetTypeMint] {
return b.TxMint
}
Expand Down Expand Up @@ -179,6 +187,10 @@ func (t MaryTransaction) ValidityIntervalStart() uint64 {
return t.Body.ValidityIntervalStart()
}

func (t MaryTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
return t.Body.ProtocolParametersUpdate()
}

func (t MaryTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}
Expand Down Expand Up @@ -251,14 +263,6 @@ func (t MaryTransaction) Produced() []TransactionOutput {
return t.Outputs()
}

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
14 changes: 9 additions & 5 deletions ledger/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ func (b *ShelleyTransactionBody) ValidityIntervalStart() uint64 {
return 0
}

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

func (b *ShelleyTransactionBody) ReferenceInputs() []TransactionInput {
return []TransactionInput{}
}
Expand Down Expand Up @@ -503,11 +511,7 @@ func (t ShelleyTransaction) Utxorpc() *utxorpc.Tx {
}

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
return t.Body.ProtocolParametersUpdate()
}

func (t *ShelleyTransaction) Cbor() []byte {
Expand Down
2 changes: 1 addition & 1 deletion ledger/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type Transaction interface {
IsValid() bool
Consumed() []TransactionInput
Produced() []TransactionOutput
ProtocolParametersUpdate() map[Blake2b224]any
}

type TransactionBody interface {
Expand All @@ -40,6 +39,7 @@ type TransactionBody interface {
Inputs() []TransactionInput
Outputs() []TransactionOutput
TTL() uint64
ProtocolParametersUpdate() map[Blake2b224]any
ValidityIntervalStart() uint64
ReferenceInputs() []TransactionInput
Collateral() []TransactionInput
Expand Down