Skip to content

Commit

Permalink
feat: TX asset mint attribute
Browse files Browse the repository at this point in the history
This adds a method for retrieving any asset mints from a TX

Fixes #336
  • Loading branch information
agaffney committed May 15, 2024
1 parent 205b6fa commit db6c97d
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ledger/allegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ func (t AllegraTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

func (t AllegraTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
return t.Body.AssetMint()
}

func (t AllegraTransaction) VotingProcedures() VotingProcedures {
return t.Body.VotingProcedures()
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/alonzo.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ func (t AlonzoTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

func (t AlonzoTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
return t.Body.AssetMint()
}

func (t AlonzoTransaction) VotingProcedures() VotingProcedures {
return t.Body.VotingProcedures()
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ func (t BabbageTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

func (t BabbageTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
return t.Body.AssetMint()
}

func (t BabbageTransaction) ProposalProcedures() []ProposalProcedure {
return t.Body.ProposalProcedures()
}
Expand Down
5 changes: 5 additions & 0 deletions ledger/byron.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ func (t *ByronTransaction) RequiredSigners() []Blake2b224 {
return nil
}

func (t *ByronTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
// No asset mints in Byron
return nil
}

func (t *ByronTransaction) VotingProcedures() VotingProcedures {
// No voting procedures in Byron
return nil
Expand Down
4 changes: 4 additions & 0 deletions ledger/conway.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ func (t ConwayTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

func (t ConwayTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
return t.Body.AssetMint()
}

func (t ConwayTransaction) VotingProcedures() VotingProcedures {
return t.Body.VotingProcedures()
}
Expand Down
12 changes: 10 additions & 2 deletions ledger/mary.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ type MaryTransactionBody struct {
ProtocolParamUpdates map[Blake2b224]MaryProtocolParameterUpdate
Epoch uint64
} `cbor:"6,keyasint,omitempty"`
TxOutputs []MaryTransactionOutput `cbor:"1,keyasint,omitempty"`
Mint MultiAsset[MultiAssetTypeMint] `cbor:"9,keyasint,omitempty"`
TxOutputs []MaryTransactionOutput `cbor:"1,keyasint,omitempty"`
TxMint *MultiAsset[MultiAssetTypeMint] `cbor:"9,keyasint,omitempty"`
}

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

func (b *MaryTransactionBody) AssetMint() *MultiAsset[MultiAssetTypeMint] {
return b.TxMint
}

type MaryTransaction struct {
cbor.StructAsArray
cbor.DecodeStoreCbor
Expand Down Expand Up @@ -199,6 +203,10 @@ func (t MaryTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

func (t MaryTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
return t.Body.AssetMint()
}

func (t MaryTransaction) VotingProcedures() VotingProcedures {
return t.Body.VotingProcedures()
}
Expand Down
9 changes: 9 additions & 0 deletions ledger/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ func (b *ShelleyTransactionBody) RequiredSigners() []Blake2b224 {
return nil
}

func (b *ShelleyTransactionBody) AssetMint() *MultiAsset[MultiAssetTypeMint] {
// No asset minting in Shelley
return nil
}

func (t *ShelleyTransactionBody) VotingProcedures() VotingProcedures {
// No voting procedures in Shelley
return nil
Expand Down Expand Up @@ -421,6 +426,10 @@ func (t ShelleyTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

func (t ShelleyTransaction) AssetMint() *MultiAsset[MultiAssetTypeMint] {
return t.Body.AssetMint()
}

func (t ShelleyTransaction) VotingProcedures() VotingProcedures {
return t.Body.VotingProcedures()
}
Expand Down
1 change: 1 addition & 0 deletions ledger/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type TransactionBody interface {
Certificates() []Certificate
Withdrawals() map[*Address]uint64
RequiredSigners() []Blake2b224
AssetMint() *MultiAsset[MultiAssetTypeMint]
VotingProcedures() VotingProcedures
ProposalProcedures() []ProposalProcedure
Utxorpc() *utxorpc.Tx
Expand Down

0 comments on commit db6c97d

Please sign in to comment.