Skip to content

Commit

Permalink
Fix reflecting issue for TransferContract after json unmarshaling (#81)
Browse files Browse the repository at this point in the history
* Fix reflecting issue for TransferContract after json unmarshaling

* Change type conversion from []interface{} to []string
  • Loading branch information
belovbelov authored Jul 14, 2023
1 parent faa109b commit 0a25b92
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,19 @@ func GetPaddedParam(param []Param) ([]byte, error) {
}

if (ty.Elem.T == eABI.IntTy || ty.Elem.T == eABI.UintTy) &&
ty.Elem.Size > 64 &&
reflect.TypeOf(v).Elem().Kind() == reflect.String {
ty.Elem.Size > 64 {
tmp := make([]*big.Int, 0)
for _, s := range v.([]string) {
tmpSlice, ok := v.([]string)
if !ok {
return nil, fmt.Errorf("unable to convert array of unints %+v", p)
}
for i := range tmpSlice {
var value *big.Int
// check for hex char
if strings.HasPrefix(s, "0x") {
value, _ = new(big.Int).SetString(s[2:], 16)
if strings.HasPrefix(tmpSlice[i], "0x") {
value, _ = new(big.Int).SetString(tmpSlice[i][2:], 16)
} else {
value, _ = new(big.Int).SetString(s, 10)
value, _ = new(big.Int).SetString(tmpSlice[i], 10)
}
tmp = append(tmp, value)
}
Expand Down

0 comments on commit 0a25b92

Please sign in to comment.