Skip to content

Commit 7d9c1e9

Browse files
authored
Merge pull request #14 from KyberNetwork/ft/safe_parse
feat: add safe parse big.Int
2 parents 50ce753 + ff2de9b commit 7d9c1e9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

parser.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package kutils
2+
3+
import (
4+
"math/big"
5+
)
6+
7+
const LimitLength = 200
8+
9+
func SafeParseBigInt(s string, base int) (*big.Int, bool) {
10+
if len(s) > LimitLength {
11+
return nil, false
12+
}
13+
return new(big.Int).SetString(s, base)
14+
}

0 commit comments

Comments
 (0)