Skip to content

Commit cdfeb4b

Browse files
authored
feat: add support for TX attribute: protocol parameters update (#599)
Signed-off-by: Ales Verbic <[email protected]>
1 parent 77a9387 commit cdfeb4b

File tree

8 files changed

+58
-0
lines changed

8 files changed

+58
-0
lines changed

ledger/allegra.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ func (t AllegraTransaction) IsValid() bool {
170170
return true
171171
}
172172

173+
func (t *AllegraTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
174+
updateMap := make(map[Blake2b224]any)
175+
for k, v := range t.Body.Update.ProtocolParamUpdates {
176+
updateMap[k] = v
177+
}
178+
return updateMap
179+
}
180+
173181
func (t *AllegraTransaction) Cbor() []byte {
174182
// Return stored CBOR if we have any
175183
cborData := t.DecodeStoreCbor.Cbor()

ledger/alonzo.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,14 @@ func (t AlonzoTransaction) IsValid() bool {
268268
return t.IsTxValid
269269
}
270270

271+
func (t *AlonzoTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
272+
updateMap := make(map[Blake2b224]any)
273+
for k, v := range t.Body.Update.ProtocolParamUpdates {
274+
updateMap[k] = v
275+
}
276+
return updateMap
277+
}
278+
271279
func (t *AlonzoTransaction) Cbor() []byte {
272280
// Return stored CBOR if we have any
273281
cborData := t.DecodeStoreCbor.Cbor()

ledger/babbage.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,14 @@ func (t BabbageTransaction) IsValid() bool {
438438
return t.IsTxValid
439439
}
440440

441+
func (t *BabbageTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
442+
updateMap := make(map[Blake2b224]any)
443+
for k, v := range t.Body.Update.ProtocolParamUpdates {
444+
updateMap[k] = v
445+
}
446+
return updateMap
447+
}
448+
441449
func (t *BabbageTransaction) Cbor() []byte {
442450
// Return stored CBOR if we have any
443451
cborData := t.DecodeStoreCbor.Cbor()

ledger/byron.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@ func (t *ByronTransaction) Utxorpc() *utxorpc.Tx {
187187
return &utxorpc.Tx{}
188188
}
189189

190+
func (t *ByronTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
191+
// TODO: Implement this add missing Body TransactionBody
192+
updateMap := make(map[Blake2b224]any)
193+
// for k, v := range t.Body.Update.ProtocolParamUpdates {
194+
// updateMap[k] = v
195+
// }
196+
return updateMap
197+
}
198+
190199
type ByronTransactionInput struct {
191200
cbor.StructAsArray
192201
TxId Blake2b256

ledger/conway.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ func (t ConwayTransaction) IsValid() bool {
172172
return t.IsTxValid
173173
}
174174

175+
func (t *ConwayTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
176+
updateMap := make(map[Blake2b224]any)
177+
for k, v := range t.Body.Update.ProtocolParamUpdates {
178+
updateMap[k] = v
179+
}
180+
return updateMap
181+
}
182+
175183
func (t *ConwayTransaction) Cbor() []byte {
176184
// Return stored CBOR if we have any
177185
cborData := t.DecodeStoreCbor.Cbor()

ledger/mary.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ func (t MaryTransaction) IsValid() bool {
183183
return true
184184
}
185185

186+
func (t *MaryTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
187+
updateMap := make(map[Blake2b224]any)
188+
for k, v := range t.Body.Update.ProtocolParamUpdates {
189+
updateMap[k] = v
190+
}
191+
return updateMap
192+
}
193+
186194
func (t *MaryTransaction) Cbor() []byte {
187195
// Return stored CBOR if we have any
188196
cborData := t.DecodeStoreCbor.Cbor()

ledger/shelley.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,14 @@ func (t ShelleyTransaction) Utxorpc() *utxorpc.Tx {
371371
return t.Body.Utxorpc()
372372
}
373373

374+
func (t *ShelleyTransaction) ProtocolParametersUpdate() map[Blake2b224]any {
375+
updateMap := make(map[Blake2b224]any)
376+
for k, v := range t.Body.Update.ProtocolParamUpdates {
377+
updateMap[k] = v
378+
}
379+
return updateMap
380+
}
381+
374382
func (t *ShelleyTransaction) Cbor() []byte {
375383
// Return stored CBOR if we have any
376384
cborData := t.DecodeStoreCbor.Cbor()

ledger/tx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Transaction interface {
2828
TransactionBody
2929
Metadata() *cbor.Value
3030
IsValid() bool
31+
ProtocolParametersUpdate() map[Blake2b224]any
3132
}
3233

3334
type TransactionBody interface {

0 commit comments

Comments
 (0)