Skip to content

Commit 3f47cef

Browse files
authored
chore: move ProtocolParametersUpdate() to TransactionBody interface (#658)
Fixes #603
1 parent abad687 commit 3f47cef

File tree

7 files changed

+68
-44
lines changed

7 files changed

+68
-44
lines changed

ledger/allegra.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ func (b *AllegraTransactionBody) ValidityIntervalStart() uint64 {
130130
return b.TxValidityIntervalStart
131131
}
132132

133+
func (b *AllegraTransactionBody) ProtocolParametersUpdate() map[Blake2b224]any {
134+
updateMap := make(map[Blake2b224]any)
135+
for k, v := range b.Update.ProtocolParamUpdates {
136+
updateMap[k] = v
137+
}
138+
return updateMap
139+
}
140+
133141
type AllegraTransaction struct {
134142
cbor.StructAsArray
135143
cbor.DecodeStoreCbor
@@ -238,12 +246,8 @@ func (t AllegraTransaction) Produced() []TransactionOutput {
238246
return t.Outputs()
239247
}
240248

241-
func (t *AllegraTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
242-
updateMap := make(map[Blake2b224]any)
243-
for k, v := range t.Body.Update.ProtocolParamUpdates {
244-
updateMap[k] = v
245-
}
246-
return updateMap
249+
func (t AllegraTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
250+
return t.Body.ProtocolParametersUpdate()
247251
}
248252

249253
func (t *AllegraTransaction) Cbor() []byte {

ledger/alonzo.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ func (b *AlonzoTransactionBody) Outputs() []TransactionOutput {
147147
return ret
148148
}
149149

150+
func (b *AlonzoTransactionBody) ProtocolParametersUpdate() map[Blake2b224]any {
151+
updateMap := make(map[Blake2b224]any)
152+
for k, v := range b.Update.ProtocolParamUpdates {
153+
updateMap[k] = v
154+
}
155+
return updateMap
156+
}
157+
150158
func (b *AlonzoTransactionBody) Collateral() []TransactionInput {
151159
ret := []TransactionInput{}
152160
for _, collateral := range b.TxCollateral {
@@ -289,6 +297,10 @@ func (t AlonzoTransaction) ValidityIntervalStart() uint64 {
289297
return t.Body.ValidityIntervalStart()
290298
}
291299

300+
func (t AlonzoTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
301+
return t.Body.ProtocolParametersUpdate()
302+
}
303+
292304
func (t AlonzoTransaction) ReferenceInputs() []TransactionInput {
293305
return t.Body.ReferenceInputs()
294306
}
@@ -370,14 +382,6 @@ func (t AlonzoTransaction) Produced() []TransactionOutput {
370382
}
371383
}
372384

373-
func (t *AlonzoTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
374-
updateMap := make(map[Blake2b224]any)
375-
for k, v := range t.Body.Update.ProtocolParamUpdates {
376-
updateMap[k] = v
377-
}
378-
return updateMap
379-
}
380-
381385
func (t *AlonzoTransaction) Cbor() []byte {
382386
// Return stored CBOR if we have any
383387
cborData := t.DecodeStoreCbor.Cbor()

ledger/babbage.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,14 @@ func (b *BabbageTransactionBody) Outputs() []TransactionOutput {
199199
return ret
200200
}
201201

202+
func (b *BabbageTransactionBody) ProtocolParametersUpdate() map[Blake2b224]any {
203+
updateMap := make(map[Blake2b224]any)
204+
for k, v := range b.Update.ProtocolParamUpdates {
205+
updateMap[k] = v
206+
}
207+
return updateMap
208+
}
209+
202210
func (b *BabbageTransactionBody) ReferenceInputs() []TransactionInput {
203211
ret := []TransactionInput{}
204212
for _, input := range b.TxReferenceInputs {
@@ -455,6 +463,10 @@ func (t BabbageTransaction) ValidityIntervalStart() uint64 {
455463
return t.Body.ValidityIntervalStart()
456464
}
457465

466+
func (t BabbageTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
467+
return t.Body.ProtocolParametersUpdate()
468+
}
469+
458470
func (t BabbageTransaction) ReferenceInputs() []TransactionInput {
459471
return t.Body.ReferenceInputs()
460472
}
@@ -538,14 +550,6 @@ func (t BabbageTransaction) Produced() []TransactionOutput {
538550
}
539551
}
540552

541-
func (t *BabbageTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
542-
updateMap := make(map[Blake2b224]any)
543-
for k, v := range t.Body.Update.ProtocolParamUpdates {
544-
updateMap[k] = v
545-
}
546-
return updateMap
547-
}
548-
549553
func (t *BabbageTransaction) Cbor() []byte {
550554
// Return stored CBOR if we have any
551555
cborData := t.DecodeStoreCbor.Cbor()

ledger/conway.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ func (b *ConwayTransactionBody) UnmarshalCBOR(cborData []byte) error {
131131
return b.UnmarshalCbor(cborData, b)
132132
}
133133

134+
func (b *ConwayTransactionBody) ProtocolParametersUpdate() map[Blake2b224]any {
135+
updateMap := make(map[Blake2b224]any)
136+
for k, v := range b.Update.ProtocolParamUpdates {
137+
updateMap[k] = v
138+
}
139+
return updateMap
140+
}
141+
134142
func (b *ConwayTransactionBody) VotingProcedures() VotingProcedures {
135143
return b.TxVotingProcedures
136144
}
@@ -357,6 +365,10 @@ func (t ConwayTransaction) ValidityIntervalStart() uint64 {
357365
return t.Body.ValidityIntervalStart()
358366
}
359367

368+
func (t ConwayTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
369+
return t.Body.ProtocolParametersUpdate()
370+
}
371+
360372
func (t ConwayTransaction) ReferenceInputs() []TransactionInput {
361373
return t.Body.ReferenceInputs()
362374
}
@@ -440,14 +452,6 @@ func (t ConwayTransaction) Produced() []TransactionOutput {
440452
}
441453
}
442454

443-
func (t *ConwayTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
444-
updateMap := make(map[Blake2b224]any)
445-
for k, v := range t.Body.Update.ProtocolParamUpdates {
446-
updateMap[k] = v
447-
}
448-
return updateMap
449-
}
450-
451455
func (t *ConwayTransaction) Cbor() []byte {
452456
// Return stored CBOR if we have any
453457
cborData := t.DecodeStoreCbor.Cbor()

ledger/mary.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ func (b *MaryTransactionBody) Outputs() []TransactionOutput {
137137
return ret
138138
}
139139

140+
func (b *MaryTransactionBody) ProtocolParametersUpdate() map[Blake2b224]any {
141+
updateMap := make(map[Blake2b224]any)
142+
for k, v := range b.Update.ProtocolParamUpdates {
143+
updateMap[k] = v
144+
}
145+
return updateMap
146+
}
147+
140148
func (b *MaryTransactionBody) AssetMint() *MultiAsset[MultiAssetTypeMint] {
141149
return b.TxMint
142150
}
@@ -179,6 +187,10 @@ func (t MaryTransaction) ValidityIntervalStart() uint64 {
179187
return t.Body.ValidityIntervalStart()
180188
}
181189

190+
func (t MaryTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
191+
return t.Body.ProtocolParametersUpdate()
192+
}
193+
182194
func (t MaryTransaction) ReferenceInputs() []TransactionInput {
183195
return t.Body.ReferenceInputs()
184196
}
@@ -251,14 +263,6 @@ func (t MaryTransaction) Produced() []TransactionOutput {
251263
return t.Outputs()
252264
}
253265

254-
func (t *MaryTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
255-
updateMap := make(map[Blake2b224]any)
256-
for k, v := range t.Body.Update.ProtocolParamUpdates {
257-
updateMap[k] = v
258-
}
259-
return updateMap
260-
}
261-
262266
func (t *MaryTransaction) Cbor() []byte {
263267
// Return stored CBOR if we have any
264268
cborData := t.DecodeStoreCbor.Cbor()

ledger/shelley.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ func (b *ShelleyTransactionBody) ValidityIntervalStart() uint64 {
218218
return 0
219219
}
220220

221+
func (b *ShelleyTransactionBody) ProtocolParametersUpdate() map[Blake2b224]any {
222+
updateMap := make(map[Blake2b224]any)
223+
for k, v := range b.Update.ProtocolParamUpdates {
224+
updateMap[k] = v
225+
}
226+
return updateMap
227+
}
228+
221229
func (b *ShelleyTransactionBody) ReferenceInputs() []TransactionInput {
222230
return []TransactionInput{}
223231
}
@@ -503,11 +511,7 @@ func (t ShelleyTransaction) Utxorpc() *utxorpc.Tx {
503511
}
504512

505513
func (t *ShelleyTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
506-
updateMap := make(map[Blake2b224]any)
507-
for k, v := range t.Body.Update.ProtocolParamUpdates {
508-
updateMap[k] = v
509-
}
510-
return updateMap
514+
return t.Body.ProtocolParametersUpdate()
511515
}
512516

513517
func (t *ShelleyTransaction) Cbor() []byte {

ledger/tx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type Transaction interface {
3030
IsValid() bool
3131
Consumed() []TransactionInput
3232
Produced() []TransactionOutput
33-
ProtocolParametersUpdate() map[Blake2b224]any
3433
}
3534

3635
type TransactionBody interface {
@@ -40,6 +39,7 @@ type TransactionBody interface {
4039
Inputs() []TransactionInput
4140
Outputs() []TransactionOutput
4241
TTL() uint64
42+
ProtocolParametersUpdate() map[Blake2b224]any
4343
ValidityIntervalStart() uint64
4444
ReferenceInputs() []TransactionInput
4545
Collateral() []TransactionInput

0 commit comments

Comments
 (0)