Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/interchainstaking/keeper: comment about isNumericString choices #1322

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion x/interchainstaking/keeper/ibc_packet_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,14 @@ func (*Keeper) prepareRewardsDistributionMsgs(zone types.Zone, rewards sdkmath.I
}

func isNumericString(in string) bool {
_, err := strconv.Atoi(in)
// It is okay to use strconv.ParseInt to test if a value is numeric
// because the total supply of QCK is:
// 400_000_000 (400 million) qck aka 400_000_000_000_000 uqck
// and to parse numeric values, say in the smallest unit of uqck
// MaxInt64: (1<<63)-1 = 9_223_372_036_854_775_807 uqck aka
// 9_223_372_036_854.775 (9.223 Trillion) qck
// so the function is appropriate as its range won't be exceeded.
_, err := strconv.ParseInt(in, 10, 64)
return err == nil
}

Expand Down