Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Apr 10, 2024
1 parent 5455f70 commit ba7fdc4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/v2/autocli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"strings"
"time"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
Expand Down Expand Up @@ -205,8 +206,13 @@ func encoder(encoder aminojson.Encoder) aminojson.Encoder {
}

amount := msg.Get(amountField).String()
if len(amount) >= math.LegacyPrecision {
if len(amount) > math.LegacyPrecision {
amount = amount[:len(amount)-math.LegacyPrecision] + "." + amount[len(amount)-math.LegacyPrecision:]
} else if len(amount) == math.LegacyPrecision {
amount = "0." + amount
} else {
decimalPlace := len(amount) - math.LegacyPrecision
amount = "0." + strings.Repeat("0", -decimalPlace) + amount
}

amountDec, err := math.LegacyNewDecFromStr(amount)
Expand Down

0 comments on commit ba7fdc4

Please sign in to comment.