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

feat: TX current treasury value attribute #641

Merged
merged 1 commit into from
May 20, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions ledger/allegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/alonzo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions ledger/byron.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 12 additions & 4 deletions ledger/conway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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

Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/mary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
9 changes: 9 additions & 0 deletions ledger/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions ledger/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type TransactionBody interface {
ScriptDataHash() *Blake2b256
VotingProcedures() VotingProcedures
ProposalProcedures() []ProposalProcedure
CurrentTreasuryValue() int64
Utxorpc() *utxorpc.Tx
}

Expand Down