diff --git a/README.md b/README.md index e86d9abb..abef0a4e 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ This is not an exhaustive list of existing and planned features, but it covers t - [X] Reference inputs - [X] Voting procedures - [X] Proposal procedures - - [ ] Current treasury value + - [X] Current treasury value - [ ] Donation - [ ] Testing - [X] Test framework for mocking Ouroboros conversations diff --git a/ledger/allegra.go b/ledger/allegra.go index 69f93f5a..18e66b6b 100644 --- a/ledger/allegra.go +++ b/ledger/allegra.go @@ -210,6 +210,10 @@ func (t AllegraTransaction) ProposalProcedures() []ProposalProcedure { return t.Body.ProposalProcedures() } +func (t AllegraTransaction) CurrentTreasuryValue() int64 { + return t.Body.CurrentTreasuryValue() +} + func (t AllegraTransaction) Metadata() *cbor.LazyValue { return t.TxMetadata } diff --git a/ledger/alonzo.go b/ledger/alonzo.go index ad8ec194..6d769ce5 100644 --- a/ledger/alonzo.go +++ b/ledger/alonzo.go @@ -324,6 +324,10 @@ func (t AlonzoTransaction) ProposalProcedures() []ProposalProcedure { return t.Body.ProposalProcedures() } +func (t AlonzoTransaction) CurrentTreasuryValue() int64 { + return t.Body.CurrentTreasuryValue() +} + func (t AlonzoTransaction) Metadata() *cbor.LazyValue { return t.TxMetadata } diff --git a/ledger/babbage.go b/ledger/babbage.go index b599a550..d41c8dda 100644 --- a/ledger/babbage.go +++ b/ledger/babbage.go @@ -492,6 +492,10 @@ func (t BabbageTransaction) ProposalProcedures() []ProposalProcedure { return t.Body.ProposalProcedures() } +func (t BabbageTransaction) CurrentTreasuryValue() int64 { + return t.Body.CurrentTreasuryValue() +} + func (t BabbageTransaction) Metadata() *cbor.LazyValue { return t.TxMetadata } diff --git a/ledger/byron.go b/ledger/byron.go index 1590e37f..02fb0e3b 100644 --- a/ledger/byron.go +++ b/ledger/byron.go @@ -235,6 +235,11 @@ func (t *ByronTransaction) ProposalProcedures() []ProposalProcedure { return nil } +func (t *ByronTransaction) CurrentTreasuryValue() int64 { + // No current treasury value in Byron + return 0 +} + func (t *ByronTransaction) Metadata() *cbor.LazyValue { return t.Attributes } diff --git a/ledger/conway.go b/ledger/conway.go index 2700c817..a1dc6ef1 100644 --- a/ledger/conway.go +++ b/ledger/conway.go @@ -121,10 +121,10 @@ func (h *ConwayBlockHeader) Era() Era { type ConwayTransactionBody struct { BabbageTransactionBody - TxVotingProcedures VotingProcedures `cbor:"19,keyasint,omitempty"` - TxProposalProcedures []ProposalProcedure `cbor:"20,keyasint,omitempty"` - CurrentTreasuryValue int64 `cbor:"21,keyasint,omitempty"` - Donation uint64 `cbor:"22,keyasint,omitempty"` + TxVotingProcedures VotingProcedures `cbor:"19,keyasint,omitempty"` + TxProposalProcedures []ProposalProcedure `cbor:"20,keyasint,omitempty"` + TxCurrentTreasuryValue int64 `cbor:"21,keyasint,omitempty"` + Donation uint64 `cbor:"22,keyasint,omitempty"` } func (b *ConwayTransactionBody) UnmarshalCBOR(cborData []byte) error { @@ -139,6 +139,10 @@ func (b *ConwayTransactionBody) ProposalProcedures() []ProposalProcedure { return b.TxProposalProcedures } +func (b *ConwayTransactionBody) CurrentTreasuryValue() int64 { + return b.TxCurrentTreasuryValue +} + // VotingProcedures is a convenience type to avoid needing to duplicate the full type definition everywhere type VotingProcedures map[*Voter]map[*GovActionId]VotingProcedure @@ -397,6 +401,10 @@ func (t ConwayTransaction) ProposalProcedures() []ProposalProcedure { return t.Body.ProposalProcedures() } +func (t ConwayTransaction) CurrentTreasuryValue() int64 { + return t.Body.CurrentTreasuryValue() +} + func (t ConwayTransaction) Metadata() *cbor.LazyValue { return t.TxMetadata } diff --git a/ledger/mary.go b/ledger/mary.go index 04e83ead..d0aa4df5 100644 --- a/ledger/mary.go +++ b/ledger/mary.go @@ -227,6 +227,10 @@ func (t MaryTransaction) ProposalProcedures() []ProposalProcedure { return t.Body.ProposalProcedures() } +func (t MaryTransaction) CurrentTreasuryValue() int64 { + return t.Body.CurrentTreasuryValue() +} + func (t MaryTransaction) Metadata() *cbor.LazyValue { return t.TxMetadata } diff --git a/ledger/shelley.go b/ledger/shelley.go index c1b68286..cb67acd8 100644 --- a/ledger/shelley.go +++ b/ledger/shelley.go @@ -278,6 +278,11 @@ func (b *ShelleyTransactionBody) ProposalProcedures() []ProposalProcedure { return nil } +func (b *ShelleyTransactionBody) CurrentTreasuryValue() int64 { + // No current treasury value in Shelley + return 0 +} + func (b *ShelleyTransactionBody) Utxorpc() *utxorpc.Tx { var txi []*utxorpc.TxInput var txo []*utxorpc.TxOutput @@ -464,6 +469,10 @@ func (t ShelleyTransaction) ProposalProcedures() []ProposalProcedure { return t.Body.ProposalProcedures() } +func (t ShelleyTransaction) CurrentTreasuryValue() int64 { + return t.Body.CurrentTreasuryValue() +} + func (t ShelleyTransaction) Metadata() *cbor.LazyValue { return t.TxMetadata } diff --git a/ledger/tx.go b/ledger/tx.go index da76a3dd..9915b06d 100644 --- a/ledger/tx.go +++ b/ledger/tx.go @@ -53,6 +53,7 @@ type TransactionBody interface { ScriptDataHash() *Blake2b256 VotingProcedures() VotingProcedures ProposalProcedures() []ProposalProcedure + CurrentTreasuryValue() int64 Utxorpc() *utxorpc.Tx }