Skip to content

Commit

Permalink
fix: unexpected primitive type bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
r3v4s committed May 10, 2023
1 parent b734f5e commit 89a4b4a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tm2/pkg/sdk/vm/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package vm
import (
"encoding/base64"
"fmt"
"math/big"
"strconv"

gno "github.com/gnolang/gno/gnovm/pkg/gnolang"
Expand Down Expand Up @@ -153,6 +154,18 @@ func convertArgToGno(arg string, argT gno.Type) (tv gno.TypedValue) {
}
tv.SetUint64(u64)
return
case gno.BigintType:
if arg[0] == '+' {
panic("numbers cannot start with +")
}
bi, ok := big.NewInt(0).SetString(arg, 10)
if !ok {
panic(fmt.Sprintf(
"error parsing bigint %v",
arg))
}
tv.SetBigInt(bi)
return
default:
panic(fmt.Sprintf("unexpected primitive type %s", bt.String()))
}
Expand Down

0 comments on commit 89a4b4a

Please sign in to comment.