Skip to content

Commit

Permalink
Apply review suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrm50 committed Sep 28, 2023
1 parent 4df60a3 commit be58d07
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion components/dashboard/explorer_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func getTransaction(c echo.Context) error {

iotaTX, isTX := block.SignedTransaction()
if !isTX {
return ierrors.Errorf("payload is not a transaction: %s", output.BlockID().ToHex())
return ierrors.Errorf("payload is not a signed transaction: %s", output.BlockID().ToHex())
}

return httpserver.JSONResponse(c, http.StatusOK, NewTransaction(iotaTX))
Expand Down
38 changes: 19 additions & 19 deletions components/dashboard/jsonresponse.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ func NewOutputID(outputID iotago.OutputID) *OutputID {

// endregion ///////////////////////////////////////////////////////////////////////////////////////////////////////////

// region SignedTransaction //////////////////////////////////////////////////////////////////////////////////////////////////
// region Transaction //////////////////////////////////////////////////////////////////////////////////////////////////

// Transaction represents the JSON model of a ledgerstate.SignedTransaction.
// Transaction represents the JSON model of a iotago.SignedTransaction.
type Transaction struct {
TransactionID string `json:"txId"`
NetworkID iotago.NetworkID `json:"networkId"`
Expand All @@ -128,20 +128,20 @@ type Transaction struct {
Payload []byte `json:"payload"`
}

// NewTransaction returns a Transaction from the given ledgerstate.SignedTransaction.
func NewTransaction(iotaTx *iotago.SignedTransaction) *Transaction {
txID, err := iotaTx.ID()
// NewTransaction returns a Transaction from the given iotago.SignedTransaction.
func NewTransaction(signedTx *iotago.SignedTransaction) *Transaction {
txID, err := signedTx.ID()
if err != nil {
return nil
}

inputs := make([]*Input, len(iotaTx.Transaction.Inputs))
for i, input := range iotaTx.Transaction.Inputs {
inputs := make([]*Input, len(signedTx.Transaction.Inputs))
for i, input := range signedTx.Transaction.Inputs {
inputs[i] = NewInput(input)
}

outputs := make([]*Output, len(iotaTx.Transaction.Outputs))
for i, output := range iotaTx.Transaction.Outputs {
outputs := make([]*Output, len(signedTx.Transaction.Outputs))
for i, output := range signedTx.Transaction.Outputs {
outputs[i] = NewOutput(output)
outputs[i].OutputID = &OutputID{
Hex: iotago.OutputIDFromTransactionIDAndIndex(txID, uint16(i)).ToHex(),
Expand All @@ -150,19 +150,19 @@ func NewTransaction(iotaTx *iotago.SignedTransaction) *Transaction {
}
}

unlockBlocks := make([]*UnlockBlock, len(iotaTx.Unlocks))
for i, unlockBlock := range iotaTx.Unlocks {
unlockBlocks := make([]*UnlockBlock, len(signedTx.Unlocks))
for i, unlockBlock := range signedTx.Unlocks {
unlockBlocks[i] = NewUnlockBlock(unlockBlock)
}

dataPayload := make([]byte, 0)
if iotaTx.Transaction.Payload != nil {
dataPayload, _ = deps.Protocol.CurrentAPI().Encode(iotaTx.Transaction.Payload)
if signedTx.Transaction.Payload != nil {
dataPayload, _ = deps.Protocol.CurrentAPI().Encode(signedTx.Transaction.Payload)
}

return &Transaction{
NetworkID: iotaTx.Transaction.NetworkID,
CreationSlot: iotaTx.Transaction.CreationSlot,
NetworkID: signedTx.Transaction.NetworkID,
CreationSlot: signedTx.Transaction.CreationSlot,
Inputs: inputs,
Outputs: outputs,
Unlocks: unlockBlocks,
Expand All @@ -174,15 +174,15 @@ func NewTransaction(iotaTx *iotago.SignedTransaction) *Transaction {

// region Input ////////////////////////////////////////////////////////////////////////////////////////////////////////

// Input represents the JSON model of a ledgerstate.Input.
// Input represents the JSON model of a iotago.Input.
type Input struct {
Type string `json:"type"`
ReferencedOutputID *OutputID `json:"referencedOutputID,omitempty"`
// the referenced output object, omit if not specified
Output *Output `json:"output,omitempty"`
}

// NewInput returns an Input from the given ledgerstate.Input.
// NewInput returns an Input from the given iotago.Input.
func NewInput(input iotago.Input) *Input {
utxoInput, isUtxoInput := input.(*iotago.UTXOInput)
if !isUtxoInput {
Expand All @@ -199,14 +199,14 @@ func NewInput(input iotago.Input) *Input {

// region UnlockBlock //////////////////////////////////////////////////////////////////////////////////////////////////

// UnlockBlock represents the JSON model of a ledgerstate.UnlockBlock.
// UnlockBlock represents the JSON model of a iotago.UnlockBlock.
type UnlockBlock struct {
Type string `json:"type"`
SignatureType iotago.SignatureType `json:"signatureType,omitempty"`
Signature json.RawMessage `json:"signature,omitempty"`
}

// NewUnlockBlock returns an UnlockBlock from the given ledgerstate.UnlockBlock.
// NewUnlockBlock returns an UnlockBlock from the given UnlockBlock.
func NewUnlockBlock(unlockBlock iotago.Unlock) *UnlockBlock {
result := &UnlockBlock{
Type: unlockBlock.Type().String(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

type TestConflict = *Conflict[iotago.TransactionID, iotago.OutputID, vote.MockedRank]

//var NewTestConflict = NewConflict[iotago.SignedTransactionID, iotago.OutputID, vote.MockedRank]
//var NewTestConflict = NewConflict[iotago.TransactionID, iotago.OutputID, vote.MockedRank]

func NewTestConflict(id iotago.TransactionID, parentConflicts ds.Set[*Conflict[iotago.TransactionID, iotago.OutputID, vote.MockedRank]], conflictSets ds.Set[*ConflictSet[iotago.TransactionID, iotago.OutputID, vote.MockedRank]], initialWeight *weight.Weight, pendingTasksCounter *syncutils.Counter, acceptanceThresholdProvider func() int64) *Conflict[iotago.TransactionID, iotago.OutputID, vote.MockedRank] {
conflict := NewConflict[iotago.TransactionID, iotago.OutputID, vote.MockedRank](id, initialWeight, pendingTasksCounter, acceptanceThresholdProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func newTestFramework(t *testing.T) *tests.Framework {
)
}

// transactionID creates a (made up) SignedTransactionID from the given alias.
// transactionID creates a (made up) TransactionID from the given alias.
func transactionID(alias string) iotago.TransactionID {
result := iotago.TransactionIDFromData(TestTransactionCreationSlot, []byte(alias))
result.RegisterAlias(alias)
Expand Down
2 changes: 1 addition & 1 deletion pkg/protocol/engine/mempool/conflictdag/tests/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Framework struct {
// Assert provides a set of assertions that can be used to verify the state of the ConflictDAG.
Assert *Assertions

// ConflictID is a function that is used to translate a string alias into a (deterministic) iotago.SignedTransactionID.
// ConflictID is a function that is used to translate a string alias into a (deterministic) iotago.TransactionID.
ConflictID func(string) iotago.TransactionID

// ResourceID is a function that is used to translate a string alias into a (deterministic) iotago.OutputID.
Expand Down
2 changes: 1 addition & 1 deletion pkg/protocol/engine/mempool/tests/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (t *Transaction) ContextInputs() (iotago.TransactionContextInputs, error) {
}

func (t *Transaction) String() string {
return "SignedTransaction(" + t.id.String() + ")"
return "Transaction(" + t.id.String() + ")"
}

var _ mempool.Transaction = new(Transaction)
2 changes: 1 addition & 1 deletion pkg/protocol/engine/mempool/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

type Transaction interface {
// ID returns the identifier of the Transaction.
ID() (iotago.SignedTransactionID, error)
ID() (iotago.TransactionID, error)

// Inputs returns the inputs of the Transaction.
Inputs() ([]*iotago.UTXOInput, error)
Expand Down
4 changes: 2 additions & 2 deletions pkg/testsuite/transactions_framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (t *TransactionFramework) SignedTransaction(alias string) *iotago.SignedTra
return transaction
}

func (t *TransactionFramework) SignedTransactionID(alias string) iotago.TransactionID {
func (t *TransactionFramework) SignedTransactionID(alias string) iotago.SignedTransactionID {
return lo.PanicOnErr(t.SignedTransaction(alias).ID())
}

Expand Down Expand Up @@ -502,7 +502,7 @@ func WithAccountNativeTokens(nativeTokens iotago.NativeTokens) options.Option[bu
}
}

// SignedTransaction options
// TransactionBuilder options

func WithInputs(inputs utxoledger.Outputs) options.Option[builder.TransactionBuilder] {
return func(txBuilder *builder.TransactionBuilder) {
Expand Down
8 changes: 4 additions & 4 deletions tools/evil-spammer/wallet/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (o *Options) checkInputsAndOutputs() error {
return nil
}

// WithInputs returns an Option that is used to provide the Inputs of the SignedTransaction.
// WithInputs returns an Option that is used to provide the Inputs of the Transaction.
func WithInputs(inputs interface{}) Option {
return func(options *Options) {
switch in := inputs.(type) {
Expand All @@ -135,7 +135,7 @@ func WithInputs(inputs interface{}) Option {
}
}

// WithOutput returns an Option that is used to define a non-colored Output for the SignedTransaction in the Block.
// WithOutput returns an Option that is used to define a non-colored Output for the Transaction in the Block.
func WithOutput(output *OutputOption) Option {
return func(options *Options) {
if output.amount == 0 || output.address == nil {
Expand All @@ -162,7 +162,7 @@ func WithOutput(output *OutputOption) Option {
}
}

// WithOutputs returns an Option that is used to define a non-colored Outputs for the SignedTransaction in the Block.
// WithOutputs returns an Option that is used to define a non-colored Outputs for the Transaction in the Block.
func WithOutputs(outputs []*OutputOption) Option {
return func(options *Options) {
for _, output := range outputs {
Expand Down Expand Up @@ -248,7 +248,7 @@ func NewFaucetRequestOptions(options ...FaucetRequestOption) *FaucetRequestOptio
// FaucetRequestOption is an option for faucet request.
type FaucetRequestOption func(*FaucetRequestOptions)

// WithOutputAlias returns an Option that is used to provide the Output of the SignedTransaction.
// WithOutputAlias returns an Option that is used to provide the Output of the Transaction.
func WithOutputAlias(aliasName string) FaucetRequestOption {
return func(options *FaucetRequestOptions) {
options.outputAliasName = aliasName
Expand Down

0 comments on commit be58d07

Please sign in to comment.