Skip to content

Commit e4d1ad8

Browse files
authored
feat: TX current treasury value attribute (#641)
This adds a method for retrieving the current treasury value attribute from a TX Fixes #626
1 parent 86c47ea commit e4d1ad8

File tree

9 files changed

+44
-5
lines changed

9 files changed

+44
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ This is not an exhaustive list of existing and planned features, but it covers t
134134
- [X] Reference inputs
135135
- [X] Voting procedures
136136
- [X] Proposal procedures
137-
- [ ] Current treasury value
137+
- [X] Current treasury value
138138
- [ ] Donation
139139
- [ ] Testing
140140
- [X] Test framework for mocking Ouroboros conversations

ledger/allegra.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ func (t AllegraTransaction) ProposalProcedures() []ProposalProcedure {
210210
return t.Body.ProposalProcedures()
211211
}
212212

213+
func (t AllegraTransaction) CurrentTreasuryValue() int64 {
214+
return t.Body.CurrentTreasuryValue()
215+
}
216+
213217
func (t AllegraTransaction) Metadata() *cbor.LazyValue {
214218
return t.TxMetadata
215219
}

ledger/alonzo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ func (t AlonzoTransaction) ProposalProcedures() []ProposalProcedure {
324324
return t.Body.ProposalProcedures()
325325
}
326326

327+
func (t AlonzoTransaction) CurrentTreasuryValue() int64 {
328+
return t.Body.CurrentTreasuryValue()
329+
}
330+
327331
func (t AlonzoTransaction) Metadata() *cbor.LazyValue {
328332
return t.TxMetadata
329333
}

ledger/babbage.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,10 @@ func (t BabbageTransaction) ProposalProcedures() []ProposalProcedure {
492492
return t.Body.ProposalProcedures()
493493
}
494494

495+
func (t BabbageTransaction) CurrentTreasuryValue() int64 {
496+
return t.Body.CurrentTreasuryValue()
497+
}
498+
495499
func (t BabbageTransaction) Metadata() *cbor.LazyValue {
496500
return t.TxMetadata
497501
}

ledger/byron.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ func (t *ByronTransaction) ProposalProcedures() []ProposalProcedure {
235235
return nil
236236
}
237237

238+
func (t *ByronTransaction) CurrentTreasuryValue() int64 {
239+
// No current treasury value in Byron
240+
return 0
241+
}
242+
238243
func (t *ByronTransaction) Metadata() *cbor.LazyValue {
239244
return t.Attributes
240245
}

ledger/conway.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ func (h *ConwayBlockHeader) Era() Era {
121121

122122
type ConwayTransactionBody struct {
123123
BabbageTransactionBody
124-
TxVotingProcedures VotingProcedures `cbor:"19,keyasint,omitempty"`
125-
TxProposalProcedures []ProposalProcedure `cbor:"20,keyasint,omitempty"`
126-
CurrentTreasuryValue int64 `cbor:"21,keyasint,omitempty"`
127-
Donation uint64 `cbor:"22,keyasint,omitempty"`
124+
TxVotingProcedures VotingProcedures `cbor:"19,keyasint,omitempty"`
125+
TxProposalProcedures []ProposalProcedure `cbor:"20,keyasint,omitempty"`
126+
TxCurrentTreasuryValue int64 `cbor:"21,keyasint,omitempty"`
127+
Donation uint64 `cbor:"22,keyasint,omitempty"`
128128
}
129129

130130
func (b *ConwayTransactionBody) UnmarshalCBOR(cborData []byte) error {
@@ -139,6 +139,10 @@ func (b *ConwayTransactionBody) ProposalProcedures() []ProposalProcedure {
139139
return b.TxProposalProcedures
140140
}
141141

142+
func (b *ConwayTransactionBody) CurrentTreasuryValue() int64 {
143+
return b.TxCurrentTreasuryValue
144+
}
145+
142146
// VotingProcedures is a convenience type to avoid needing to duplicate the full type definition everywhere
143147
type VotingProcedures map[*Voter]map[*GovActionId]VotingProcedure
144148

@@ -397,6 +401,10 @@ func (t ConwayTransaction) ProposalProcedures() []ProposalProcedure {
397401
return t.Body.ProposalProcedures()
398402
}
399403

404+
func (t ConwayTransaction) CurrentTreasuryValue() int64 {
405+
return t.Body.CurrentTreasuryValue()
406+
}
407+
400408
func (t ConwayTransaction) Metadata() *cbor.LazyValue {
401409
return t.TxMetadata
402410
}

ledger/mary.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ func (t MaryTransaction) ProposalProcedures() []ProposalProcedure {
227227
return t.Body.ProposalProcedures()
228228
}
229229

230+
func (t MaryTransaction) CurrentTreasuryValue() int64 {
231+
return t.Body.CurrentTreasuryValue()
232+
}
233+
230234
func (t MaryTransaction) Metadata() *cbor.LazyValue {
231235
return t.TxMetadata
232236
}

ledger/shelley.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ func (b *ShelleyTransactionBody) ProposalProcedures() []ProposalProcedure {
278278
return nil
279279
}
280280

281+
func (b *ShelleyTransactionBody) CurrentTreasuryValue() int64 {
282+
// No current treasury value in Shelley
283+
return 0
284+
}
285+
281286
func (b *ShelleyTransactionBody) Utxorpc() *utxorpc.Tx {
282287
var txi []*utxorpc.TxInput
283288
var txo []*utxorpc.TxOutput
@@ -464,6 +469,10 @@ func (t ShelleyTransaction) ProposalProcedures() []ProposalProcedure {
464469
return t.Body.ProposalProcedures()
465470
}
466471

472+
func (t ShelleyTransaction) CurrentTreasuryValue() int64 {
473+
return t.Body.CurrentTreasuryValue()
474+
}
475+
467476
func (t ShelleyTransaction) Metadata() *cbor.LazyValue {
468477
return t.TxMetadata
469478
}

ledger/tx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ type TransactionBody interface {
5353
ScriptDataHash() *Blake2b256
5454
VotingProcedures() VotingProcedures
5555
ProposalProcedures() []ProposalProcedure
56+
CurrentTreasuryValue() int64
5657
Utxorpc() *utxorpc.Tx
5758
}
5859

0 commit comments

Comments
 (0)