Skip to content

Commit 10a31cd

Browse files
Fix fee calculation to always round up (#155)
1 parent 2aee34a commit 10a31cd

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

pkg/lumera/modules/tx/impl.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tx
33
import (
44
"context"
55
"fmt"
6+
"math"
67
"strconv"
78

89
"github.com/LumeraProtocol/supernode/v2/pkg/logtrace"
@@ -225,14 +226,14 @@ func (m *module) CalculateFee(gasAmount uint64, config *TxConfig) string {
225226
denom = DefaultFeeDenom
226227
}
227228

228-
feeAmount := gasPriceF * float64(gasAmount)
229+
// Calculate fee and always round up to meet chain minimums
230+
feeFloat := gasPriceF * float64(gasAmount)
231+
feeInt := uint64(math.Ceil(feeFloat))
229232

230233
// Ensure we have at least 1 unit of fee to meet minimal requirements
231-
if feeAmount < 1 {
232-
feeAmount = 1
233-
}
234+
feeInt = max(feeInt, 1)
234235

235-
return fmt.Sprintf("%.0f%s", feeAmount, denom)
236+
return fmt.Sprintf("%d%s", feeInt, denom)
236237
}
237238

238239
// ProcessTransaction handles the complete flow: simulate, build, sign, and broadcast

0 commit comments

Comments
 (0)