Skip to content

Commit 67fefc2

Browse files
committed
Enhance LockTokens method by trimming denom from msg.Amount before parsing to uint64, ensuring correct amount handling. This change improves input validation and prevents potential parsing errors.
1 parent 4b8e776 commit 67fefc2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

x/evmbridge/keeper/msg_server_lock_tokens.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"strconv"
7+
"strings"
78
"time"
89

910
"github.com/airchains-network/junction/x/evmbridge/types"
@@ -62,7 +63,9 @@ func (k msgServer) LockTokens(goCtx context.Context, msg *types.MsgLockTokens) (
6263
blockHeight := sdkCtx.BlockHeight()
6364
blockTime := sdkCtx.BlockTime()
6465

65-
amountUint64, err := strconv.ParseUint(msg.Amount, 10, 64)
66+
// before passing msg.Amount we need to remove the denom value from it since it is going to be 1000uamf or something like this
67+
trimmedAmount := strings.TrimSuffix(msg.Amount, "uamf")
68+
amountUint64, err := strconv.ParseUint(trimmedAmount, 10, 64)
6669
if err != nil {
6770
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid amount: %s", err))
6871
}

0 commit comments

Comments
 (0)