Skip to content

Commit

Permalink
x/interchainstaking/keeper: comment about isNumericString choices
Browse files Browse the repository at this point in the history
Adds a comment for future selves, about the choice of strconv.ParseInt
inside isNumericString and showing that its limits won't be exceeded.

Updates PR quicksilver-zone#1319
  • Loading branch information
odeke-em committed Mar 22, 2024
1 parent 60e77b3 commit ee9f9da
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit ee9f9da

Please sign in to comment.