mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
cli/vm: use ParseInt to properly (and easily) check for int32
This commit is contained in:
parent
735db08f84
commit
4d2afa2624
1 changed files with 1 additions and 5 deletions
|
@ -10,7 +10,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -1026,13 +1025,10 @@ func getDumpArgs(c *cli.Context) (int32, []byte, error) {
|
||||||
)
|
)
|
||||||
h, err := flags.ParseAddress(hashOrID)
|
h, err := flags.ParseAddress(hashOrID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i, err := strconv.Atoi(hashOrID)
|
i, err := strconv.ParseInt(hashOrID, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, fmt.Errorf("failed to parse contract hash, address or ID: %w", err)
|
return 0, nil, fmt.Errorf("failed to parse contract hash, address or ID: %w", err)
|
||||||
}
|
}
|
||||||
if i > math.MaxInt32 {
|
|
||||||
return 0, nil, fmt.Errorf("contract ID exceeds max int32 value")
|
|
||||||
}
|
|
||||||
id = int32(i)
|
id = int32(i)
|
||||||
} else {
|
} else {
|
||||||
cs, err := ic.GetContract(h)
|
cs, err := ic.GetContract(h)
|
||||||
|
|
Loading…
Reference in a new issue