|
1 |
| -// Copyright 2024 Blink Labs Software |
| 1 | +// Copyright 2025 Blink Labs Software |
2 | 2 | //
|
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
4 | 4 | // you may not use this file except in compliance with the License.
|
@@ -303,21 +303,54 @@ func (o AlonzoTransactionOutput) Utxorpc() *utxorpc.TxOutput {
|
303 | 303 |
|
304 | 304 | type AlonzoRedeemer struct {
|
305 | 305 | cbor.StructAsArray
|
306 |
| - Tag uint8 |
| 306 | + Tag common.RedeemerTag |
307 | 307 | Index uint32
|
308 |
| - Data cbor.RawMessage |
| 308 | + Data cbor.LazyValue |
309 | 309 | ExUnits common.RedeemerExUnits
|
310 | 310 | }
|
311 | 311 |
|
| 312 | +type AlonzoRedeemers []AlonzoRedeemer |
| 313 | + |
| 314 | +func (r AlonzoRedeemers) Indexes(tag common.RedeemerTag) []uint { |
| 315 | + ret := []uint{} |
| 316 | + for _, redeemer := range r { |
| 317 | + if redeemer.Tag == tag { |
| 318 | + ret = append(ret, uint(redeemer.Index)) |
| 319 | + } |
| 320 | + } |
| 321 | + return ret |
| 322 | +} |
| 323 | + |
| 324 | +func (r AlonzoRedeemers) Value(index uint, tag common.RedeemerTag) (cbor.LazyValue, common.RedeemerExUnits) { |
| 325 | + for _, redeemer := range r { |
| 326 | + if redeemer.Tag == tag && uint(redeemer.Index) == index { |
| 327 | + return redeemer.Data, redeemer.ExUnits |
| 328 | + } |
| 329 | + } |
| 330 | + return cbor.LazyValue{}, common.RedeemerExUnits{} |
| 331 | +} |
| 332 | + |
312 | 333 | type AlonzoTransactionWitnessSet struct {
|
313 | 334 | shelley.ShelleyTransactionWitnessSet
|
314 |
| - PlutusV1Scripts [][]byte `cbor:"3,keyasint,omitempty"` |
315 |
| - PlutusData []cbor.Value `cbor:"4,keyasint,omitempty"` |
316 |
| - Redeemers []AlonzoRedeemer `cbor:"5,keyasint,omitempty"` |
| 335 | + WsPlutusV1Scripts [][]byte `cbor:"3,keyasint,omitempty"` |
| 336 | + WsPlutusData []cbor.Value `cbor:"4,keyasint,omitempty"` |
| 337 | + WsRedeemers AlonzoRedeemers `cbor:"5,keyasint,omitempty"` |
| 338 | +} |
| 339 | + |
| 340 | +func (w *AlonzoTransactionWitnessSet) UnmarshalCBOR(cborData []byte) error { |
| 341 | + return w.UnmarshalCbor(cborData, w) |
| 342 | +} |
| 343 | + |
| 344 | +func (w AlonzoTransactionWitnessSet) PlutusV1Scripts() [][]byte { |
| 345 | + return w.WsPlutusV1Scripts |
317 | 346 | }
|
318 | 347 |
|
319 |
| -func (t *AlonzoTransactionWitnessSet) UnmarshalCBOR(cborData []byte) error { |
320 |
| - return t.UnmarshalCbor(cborData, t) |
| 348 | +func (w AlonzoTransactionWitnessSet) PlutusData() []cbor.Value { |
| 349 | + return w.WsPlutusData |
| 350 | +} |
| 351 | + |
| 352 | +func (w AlonzoTransactionWitnessSet) Redeemers() common.TransactionWitnessRedeemers { |
| 353 | + return w.WsRedeemers |
321 | 354 | }
|
322 | 355 |
|
323 | 356 | type AlonzoTransaction struct {
|
@@ -452,6 +485,10 @@ func (t AlonzoTransaction) Produced() []common.Utxo {
|
452 | 485 | }
|
453 | 486 | }
|
454 | 487 |
|
| 488 | +func (t AlonzoTransaction) Witnesses() common.TransactionWitnessSet { |
| 489 | + return t.WitnessSet |
| 490 | +} |
| 491 | + |
455 | 492 | func (t *AlonzoTransaction) Cbor() []byte {
|
456 | 493 | // Return stored CBOR if we have any
|
457 | 494 | cborData := t.DecodeStoreCbor.Cbor()
|
|
0 commit comments