Skip to content

Commit

Permalink
feat: TX required signers attribute (#630)
Browse files Browse the repository at this point in the history
This adds a method to retrieve the required signers for a TX

Fixes #339
  • Loading branch information
agaffney authored May 15, 2024
1 parent bf20614 commit 205b6fa
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ledger/allegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ func (t AllegraTransaction) Withdrawals() map[*Address]uint64 {
return t.Body.Withdrawals()
}

func (t AllegraTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

func (t AllegraTransaction) VotingProcedures() VotingProcedures {
return t.Body.VotingProcedures()
}
Expand Down
16 changes: 12 additions & 4 deletions ledger/alonzo.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ type AlonzoTransactionBody struct {
ProtocolParamUpdates map[Blake2b224]AlonzoProtocolParameterUpdate
Epoch uint64
} `cbor:"6,keyasint,omitempty"`
ScriptDataHash Blake2b256 `cbor:"11,keyasint,omitempty"`
TxCollateral []ShelleyTransactionInput `cbor:"13,keyasint,omitempty"`
RequiredSigners []Blake2b224 `cbor:"14,keyasint,omitempty"`
NetworkId uint8 `cbor:"15,keyasint,omitempty"`
ScriptDataHash Blake2b256 `cbor:"11,keyasint,omitempty"`
TxCollateral []ShelleyTransactionInput `cbor:"13,keyasint,omitempty"`
TxRequiredSigners []Blake2b224 `cbor:"14,keyasint,omitempty"`
NetworkId uint8 `cbor:"15,keyasint,omitempty"`
}

func (b *AlonzoTransactionBody) UnmarshalCBOR(cborData []byte) error {
Expand All @@ -155,6 +155,10 @@ func (b *AlonzoTransactionBody) Collateral() []TransactionInput {
return ret
}

func (b *AlonzoTransactionBody) RequiredSigners() []Blake2b224 {
return b.TxRequiredSigners[:]
}

type AlonzoTransactionOutput struct {
cbor.StructAsArray
cbor.DecodeStoreCbor
Expand Down Expand Up @@ -288,6 +292,10 @@ func (t AlonzoTransaction) Withdrawals() map[*Address]uint64 {
return t.Body.Withdrawals()
}

func (t AlonzoTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

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 @@ -468,6 +468,10 @@ func (t BabbageTransaction) VotingProcedures() VotingProcedures {
return t.Body.VotingProcedures()
}

func (t BabbageTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

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 @@ -200,6 +200,11 @@ func (t *ByronTransaction) Withdrawals() map[*Address]uint64 {
return nil
}

func (t *ByronTransaction) RequiredSigners() []Blake2b224 {
// No required signers 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 @@ -369,6 +369,10 @@ func (t ConwayTransaction) Withdrawals() map[*Address]uint64 {
return t.Body.Withdrawals()
}

func (t ConwayTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

func (t ConwayTransaction) VotingProcedures() VotingProcedures {
return t.Body.VotingProcedures()
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/mary.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ func (t MaryTransaction) Withdrawals() map[*Address]uint64 {
return t.Body.Withdrawals()
}

func (t MaryTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

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 @@ -244,6 +244,11 @@ func (b *ShelleyTransactionBody) Withdrawals() map[*Address]uint64 {
return b.TxWithdrawals
}

func (b *ShelleyTransactionBody) RequiredSigners() []Blake2b224 {
// No required signers in Shelley
return nil
}

func (t *ShelleyTransactionBody) VotingProcedures() VotingProcedures {
// No voting procedures in Shelley
return nil
Expand Down Expand Up @@ -412,6 +417,10 @@ func (t ShelleyTransaction) Withdrawals() map[*Address]uint64 {
return t.Body.Withdrawals()
}

func (t ShelleyTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}

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 @@ -46,6 +46,7 @@ type TransactionBody interface {
TotalCollateral() uint64
Certificates() []Certificate
Withdrawals() map[*Address]uint64
RequiredSigners() []Blake2b224
VotingProcedures() VotingProcedures
ProposalProcedures() []ProposalProcedure
Utxorpc() *utxorpc.Tx
Expand Down

0 comments on commit 205b6fa

Please sign in to comment.