Skip to content

Commit

Permalink
Fix wrap order in output files
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGackstatter committed Mar 8, 2024
1 parent e43ba29 commit b35652f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func OutputsSyntacticalDepositAmount(protoParams ProtocolParameters, storageScor
var err error
sum, err = safemath.SafeAdd(sum, amount)
if err != nil {
return ierrors.WithMessagef(ErrOutputsSumExceedsTotalSupply, "%w: output %d", err, index)
return ierrors.Join(ErrOutputsSumExceedsTotalSupply, ierrors.WithMessagef(err, "output %d", index))
}
if sum > protoParams.TokenSupply() {
return ierrors.WithMessagef(ErrOutputsSumExceedsTotalSupply, "output %d", index)
Expand Down Expand Up @@ -422,7 +422,7 @@ func OutputsSyntacticalStoredMana(maxManaValue Mana) ElementValidationFunc[Outpu
var err error
sum, err = safemath.SafeAdd(sum, storedMana)
if err != nil {
return ierrors.WithMessagef(ErrMaxManaExceeded, "%w: stored mana sum calculation failed at output %d", err, index)
return ierrors.Join(ierrors.Wrapf(ErrMaxManaExceeded, "stored mana sum calculation failed at output %d", index), err)
}

if sum > maxManaValue {
Expand Down Expand Up @@ -694,7 +694,7 @@ func OutputsSyntacticalImplicitAccountCreationAddress() ElementValidationFunc[Ou
return ierrors.WithMessagef(ErrImplicitAccountCreationAddressInInvalidOutput, "output %d", index)
}
default:
panic("unrecognized output type")
panic("all known output types should be handled above")
}

return nil
Expand Down Expand Up @@ -743,7 +743,7 @@ func OutputsSyntacticalUnlockConditionLexicalOrderAndUniqueness() ElementValidat
}
}
default:
panic("unrecognized output type")
panic("all known output types should be handled above")
}

return nil
Expand Down Expand Up @@ -812,7 +812,7 @@ func OutputsSyntacticalFeaturesLexicalOrderAndUniqueness() ElementValidationFunc
// This output does not have features.
return nil
default:
panic("unrecognized output type")
panic("all known output types should be handled above")
}

return nil
Expand Down Expand Up @@ -900,16 +900,16 @@ func OutputsSyntacticalCommitmentInput(hasCommitmentInput bool) ElementValidatio
return func(index int, output Output) error {
hasStakingFeature := output.FeatureSet().Staking() != nil
if hasStakingFeature && !hasCommitmentInput {
return ierrors.Wrapf(ErrStakingCommitmentInputMissing, "output %d", index)
return ierrors.WithMessagef(ErrStakingCommitmentInputMissing, "output %d", index)
}

hasBlockIssuerFeature := output.FeatureSet().BlockIssuer() != nil
if hasBlockIssuerFeature && !hasCommitmentInput {
return ierrors.Wrapf(ErrBlockIssuerCommitmentInputMissing, "output %d", index)
return ierrors.WithMessagef(ErrBlockIssuerCommitmentInputMissing, "output %d", index)
}

if output.Type() == OutputDelegation && !hasCommitmentInput {
return ierrors.Wrapf(ErrDelegationCommitmentInputMissing, "output %d", index)
return ierrors.WithMessagef(ErrDelegationCommitmentInputMissing, "output %d", index)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions output_anchor.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ func (a *AnchorOutput) Owner(nextState OwnerTransitionDependentOutput) (Address,
}
otherAnchorOutput, isAnchorOutput := nextState.(*AnchorOutput)
if !isAnchorOutput {
return nil, ierrors.Wrapf(ErrOwnerTransitionDependentOutputNextInvalid, "expected AnchorOutput but got %s for owner computation", nextState.Type())
return nil, ierrors.WithMessagef(ErrOwnerTransitionDependentOutputNextInvalid, "expected AnchorOutput but got %s for owner computation", nextState.Type())
}
switch {
case a.StateIndex == otherAnchorOutput.StateIndex:
return a.GovernorAddress(), nil
case a.StateIndex+1 == otherAnchorOutput.StateIndex:
return a.StateController(), nil
default:
return nil, ierrors.Wrap(ErrOwnerTransitionDependentOutputNextInvalid, "can not compute right owner for anchor output as state index delta is invalid")
return nil, ierrors.WithMessage(ErrOwnerTransitionDependentOutputNextInvalid, "can not compute right owner for anchor output as state index delta is invalid")
}
}

Expand Down
8 changes: 4 additions & 4 deletions output_id_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type OutputIDProof struct {

func OutputIDProofFromTransaction(tx *Transaction, outputIndex uint16) (*OutputIDProof, error) {
if tx.API == nil {
return nil, ierrors.New("API not set")
panic("API on transaction not set")
}

transactionCommitment, err := tx.TransactionCommitment()
Expand All @@ -32,7 +32,7 @@ func OutputIDProofFromTransaction(tx *Transaction, outputIndex uint16) (*OutputI

func NewOutputIDProof(api API, txCommitment Identifier, txCreationSlot SlotIndex, outputs TxEssenceOutputs, outputIndex uint16) (*OutputIDProof, error) {
if int(outputIndex) >= len(outputs) {
return nil, ierrors.Errorf("index %d out of bounds len=%d", outputIndex, len(outputs))
return nil, ierrors.Errorf("index %d out of bounds for outputs slice of len %d", outputIndex, len(outputs))
}

//nolint:nosnakecase // false positive
Expand Down Expand Up @@ -72,7 +72,7 @@ func (p *OutputIDProof) SetDeserializationContext(ctx context.Context) {

func (p *OutputIDProof) OutputID(output Output) (OutputID, error) {
if p.API == nil {
return EmptyOutputID, ierrors.New("API not set")
panic("API on OutputIDProof not set")
}

//nolint:nosnakecase // false positive
Expand All @@ -85,7 +85,7 @@ func (p *OutputIDProof) OutputID(output Output) (OutputID, error) {

// The proof does not contain a hash of the output
if !contains {
return EmptyOutputID, ierrors.Errorf("proof does not contain the given output")
return EmptyOutputID, ierrors.New("proof does not contain the given output")
}

// Hash the proof to get the root
Expand Down

0 comments on commit b35652f

Please sign in to comment.