Skip to content

Commit f0e23ff

Browse files
committed
Better naming for BalanceInAttFlowValidForFlowVault and fix logical condition
1 parent c644e3a commit f0e23ff

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

fvm/evm/emulator/emulator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func (proc *procedure) withdrawFrom(
417417
), nil
418418
}
419419

420-
if types.BalanceInAttFlowValidForFlowVault(call.Value) {
420+
if !types.AttoFlowBalanceValidForFlowVault(call.Value) {
421421
return types.NewInvalidResult(
422422
call.Transaction(),
423423
types.ErrWithdrawBalanceRounding,

fvm/evm/impl/impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ func newInternalEVMTypeWithdrawFunction(
654654
panic(types.ErrInvalidBalance)
655655
}
656656

657-
if types.BalanceInAttFlowValidForFlowVault(amountValue.BigInt) {
657+
if !types.AttoFlowBalanceValidForFlowVault(amountValue.BigInt) {
658658
panic(types.ErrWithdrawBalanceRounding)
659659
}
660660

fvm/evm/types/balance.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ func BalanceConversionToUFix64ProneToRoundingError(bal Balance) bool {
9494
return new(big.Int).Mod(bal, UFixToAttoConversionMultiplier).BitLen() != 0
9595
}
9696

97-
// BalanceInAttFlowValidForFlowVault returns true if the given balance,
97+
// AttoFlowBalanceValidForFlowVault returns true if the given balance,
9898
// represented as atto Flow, can be stored in a Flow Vault.
9999
//
100100
// Warning! The smallest unit of Flow token that a Flow Vault (Cadence)
101101
// can store, is 1e10^-8 .
102102
// That means the minimum balance, in atto Flow, that can be stored in a Flow Vault,
103103
// is 1e10^10 .
104-
func BalanceInAttFlowValidForFlowVault(bal *big.Int) bool {
105-
return bal.Cmp(UFixToAttoConversionMultiplier) < 0
104+
func AttoFlowBalanceValidForFlowVault(bal *big.Int) bool {
105+
return bal.Cmp(UFixToAttoConversionMultiplier) >= 0
106106
}
107107

108108
// Subtract balance 2 from balance 1 and returns the result as a new balance

0 commit comments

Comments
 (0)