Skip to content

Commit

Permalink
Use ierrors.Chain
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Mar 20, 2024
1 parent a3d2d56 commit 0b5258b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ func TotalManaIn(manaDecayProvider *iotago.ManaDecayProvider, storageScoreStruct
}
totalIn, err = safemath.SafeAdd(totalIn, manaStored)
if err != nil {
return 0, ierrors.WithMessagef(iotago.ErrManaOverflow, "%w", err)
return 0, ierrors.Chain(iotago.ErrManaOverflow, err)
}
manaPotential, err := iotago.PotentialMana(manaDecayProvider, storageScoreStructure, input, outputID.CreationSlot(), txCreationSlot)
if err != nil {
return 0, ierrors.Wrapf(err, "input %s potential mana calculation failed", outputID)
}
totalIn, err = safemath.SafeAdd(totalIn, manaPotential)
if err != nil {
return 0, ierrors.WithMessagef(iotago.ErrManaOverflow, "%w", err)
return 0, ierrors.Chain(iotago.ErrManaOverflow, err)
}
}

Expand All @@ -98,7 +98,7 @@ func TotalManaIn(manaDecayProvider *iotago.ManaDecayProvider, storageScoreStruct
var err error
totalIn, err = safemath.SafeAdd(totalIn, reward)
if err != nil {
return 0, ierrors.WithMessagef(iotago.ErrManaOverflow, "%w", err)
return 0, ierrors.Chain(iotago.ErrManaOverflow, err)
}
}

Expand All @@ -112,13 +112,13 @@ func TotalManaOut(outputs iotago.Outputs[iotago.TxEssenceOutput], allotments iot
for _, output := range outputs {
totalOut, err = safemath.SafeAdd(totalOut, output.StoredMana())
if err != nil {
return 0, ierrors.WithMessagef(iotago.ErrManaOverflow, "%w", err)
return 0, ierrors.Chain(iotago.ErrManaOverflow, err)
}
}
for _, allotment := range allotments {
totalOut, err = safemath.SafeAdd(totalOut, allotment.Mana)
if err != nil {
return 0, ierrors.WithMessagef(iotago.ErrManaOverflow, "%w", err)
return 0, ierrors.Chain(iotago.ErrManaOverflow, err)
}
}

Expand Down Expand Up @@ -622,7 +622,7 @@ func unlockAddress(ownerAddr iotago.Address, unlock iotago.Unlock, inputIndex ui
}

if err := unlockedAddrsSet.MultiUnlock(owner, uBlock, essenceMsgToSign, inputIndex); err != nil {
return ierrors.WithMessagef(iotago.ErrMultiAddressUnlockInvalid, "%w", err)
return ierrors.Chain(iotago.ErrMultiAddressUnlockInvalid, err)
}

default:
Expand Down Expand Up @@ -701,7 +701,7 @@ func ExecFuncBalancedMana() ExecFunc {
} else if manaIn > manaOut {
// less mana on output side than on input side => check if mana burning is allowed
if vmParams.WorkingSet.Tx.Capabilities.CannotBurnMana() {
return ierrors.WithMessagef(iotago.ErrInputOutputManaMismatch, "%w", iotago.ErrTxCapabilitiesManaBurningNotAllowed)
return ierrors.Chain(iotago.ErrInputOutputManaMismatch, iotago.ErrTxCapabilitiesManaBurningNotAllowed)
}
}

Expand Down Expand Up @@ -832,7 +832,7 @@ func ExecFuncBalancedNativeTokens() ExecFunc {

vmParams.WorkingSet.OutNativeTokens, err = vmParams.WorkingSet.Tx.Outputs.NativeTokenSum()
if err != nil {
return ierrors.WithMessagef(iotago.ErrNativeTokenSetInvalid, "%w", err)
return ierrors.Chain(iotago.ErrNativeTokenSetInvalid, err)
}

// check invariants for when token foundry is absent
Expand Down

0 comments on commit 0b5258b

Please sign in to comment.