Skip to content

Commit

Permalink
fix parsing integers
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tron committed Aug 6, 2024
1 parent 2e03550 commit 3c474e8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/api/converters.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package api

import (
"encoding/hex"
"encoding/json"
"fmt"
"math/big"
Expand Down Expand Up @@ -179,12 +178,11 @@ func stringToTVMStackRecord(s string) (tlb.VmStackValue, error) {
return tlb.TlbStructToVmCellSlice(account.ID.ToMsgAddress())
}
if strings.HasPrefix(s, "0x") {
b, err := hex.DecodeString(s[2:])
if err != nil {
return tlb.VmStackValue{}, err
}
i := big.Int{}
i.SetBytes(b)
_, ok := i.SetString(s[2:], 16)
if !ok {
return tlb.VmStackValue{}, fmt.Errorf("invalid hex %v", s)
}
return tlb.VmStackValue{SumType: "VmStkInt", VmStkInt: tlb.Int257(i)}, nil
}
isDigit := true
Expand Down

0 comments on commit 3c474e8

Please sign in to comment.