Skip to content

Commit 4ffacfe

Browse files
authored
feat: TX asset mint attribute (#631)
This adds a method for retrieving any asset mints from a TX Fixes #336
1 parent 205b6fa commit 4ffacfe

File tree

8 files changed

+41
-2
lines changed

8 files changed

+41
-2
lines changed

ledger/allegra.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ func (t AllegraTransaction) RequiredSigners() []Blake2b224 {
182182
return t.Body.RequiredSigners()
183183
}
184184

185+
func (t AllegraTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
186+
return t.Body.AssetMint()
187+
}
188+
185189
func (t AllegraTransaction) VotingProcedures() VotingProcedures {
186190
return t.Body.VotingProcedures()
187191
}

ledger/alonzo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ func (t AlonzoTransaction) RequiredSigners() []Blake2b224 {
296296
return t.Body.RequiredSigners()
297297
}
298298

299+
func (t AlonzoTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
300+
return t.Body.AssetMint()
301+
}
302+
299303
func (t AlonzoTransaction) VotingProcedures() VotingProcedures {
300304
return t.Body.VotingProcedures()
301305
}

ledger/babbage.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,10 @@ func (t BabbageTransaction) RequiredSigners() []Blake2b224 {
472472
return t.Body.RequiredSigners()
473473
}
474474

475+
func (t BabbageTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
476+
return t.Body.AssetMint()
477+
}
478+
475479
func (t BabbageTransaction) ProposalProcedures() []ProposalProcedure {
476480
return t.Body.ProposalProcedures()
477481
}

ledger/byron.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ func (t *ByronTransaction) RequiredSigners() []Blake2b224 {
205205
return nil
206206
}
207207

208+
func (t *ByronTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
209+
// No asset mints in Byron
210+
return nil
211+
}
212+
208213
func (t *ByronTransaction) VotingProcedures() VotingProcedures {
209214
// No voting procedures in Byron
210215
return nil

ledger/conway.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ func (t ConwayTransaction) RequiredSigners() []Blake2b224 {
373373
return t.Body.RequiredSigners()
374374
}
375375

376+
func (t ConwayTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
377+
return t.Body.AssetMint()
378+
}
379+
376380
func (t ConwayTransaction) VotingProcedures() VotingProcedures {
377381
return t.Body.VotingProcedures()
378382
}

ledger/mary.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ type MaryTransactionBody struct {
120120
ProtocolParamUpdates map[Blake2b224]MaryProtocolParameterUpdate
121121
Epoch uint64
122122
} `cbor:"6,keyasint,omitempty"`
123-
TxOutputs []MaryTransactionOutput `cbor:"1,keyasint,omitempty"`
124-
Mint MultiAsset[MultiAssetTypeMint] `cbor:"9,keyasint,omitempty"`
123+
TxOutputs []MaryTransactionOutput `cbor:"1,keyasint,omitempty"`
124+
TxMint *MultiAsset[MultiAssetTypeMint] `cbor:"9,keyasint,omitempty"`
125125
}
126126

127127
func (b *MaryTransactionBody) UnmarshalCBOR(cborData []byte) error {
@@ -137,6 +137,10 @@ func (b *MaryTransactionBody) Outputs() []TransactionOutput {
137137
return ret
138138
}
139139

140+
func (b *MaryTransactionBody) AssetMint() *MultiAsset[MultiAssetTypeMint] {
141+
return b.TxMint
142+
}
143+
140144
type MaryTransaction struct {
141145
cbor.StructAsArray
142146
cbor.DecodeStoreCbor
@@ -199,6 +203,10 @@ func (t MaryTransaction) RequiredSigners() []Blake2b224 {
199203
return t.Body.RequiredSigners()
200204
}
201205

206+
func (t MaryTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
207+
return t.Body.AssetMint()
208+
}
209+
202210
func (t MaryTransaction) VotingProcedures() VotingProcedures {
203211
return t.Body.VotingProcedures()
204212
}

ledger/shelley.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ func (b *ShelleyTransactionBody) RequiredSigners() []Blake2b224 {
249249
return nil
250250
}
251251

252+
func (b *ShelleyTransactionBody) AssetMint() *MultiAsset[MultiAssetTypeMint] {
253+
// No asset minting in Shelley
254+
return nil
255+
}
256+
252257
func (t *ShelleyTransactionBody) VotingProcedures() VotingProcedures {
253258
// No voting procedures in Shelley
254259
return nil
@@ -421,6 +426,10 @@ func (t ShelleyTransaction) RequiredSigners() []Blake2b224 {
421426
return t.Body.RequiredSigners()
422427
}
423428

429+
func (t ShelleyTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
430+
return t.Body.AssetMint()
431+
}
432+
424433
func (t ShelleyTransaction) VotingProcedures() VotingProcedures {
425434
return t.Body.VotingProcedures()
426435
}

ledger/tx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type TransactionBody interface {
4747
Certificates() []Certificate
4848
Withdrawals() map[*Address]uint64
4949
RequiredSigners() []Blake2b224
50+
AssetMint() *MultiAsset[MultiAssetTypeMint]
5051
VotingProcedures() VotingProcedures
5152
ProposalProcedures() []ProposalProcedure
5253
Utxorpc() *utxorpc.Tx

0 commit comments

Comments
 (0)