hex parser + test
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/shopspring/decimal"
|
||||
@@ -315,17 +314,11 @@ func erc20Decimals(ctx context.Context, client *rpc.Client, token common.Address
|
||||
if err := client.CallContext(ctx, &hexResp, "eth_call", call, "latest"); err != nil {
|
||||
return 0, executorInternal("decimals call failed", err)
|
||||
}
|
||||
val, err := hexutil.DecodeBig(hexResp)
|
||||
val, err := shared.DecodeHexUint8(hexResp)
|
||||
if err != nil {
|
||||
return 0, executorInternal("decimals decode failed", err)
|
||||
}
|
||||
if val == nil {
|
||||
return 0, executorInternal("decimals decode failed", errors.New("empty response"))
|
||||
}
|
||||
if val.BitLen() > 8 {
|
||||
return 0, executorInternal("decimals decode failed", errors.New("value out of range"))
|
||||
}
|
||||
return uint8(val.Uint64()), nil
|
||||
return val, nil
|
||||
}
|
||||
|
||||
func toBaseUnits(amount string, decimals uint8) (*big.Int, error) {
|
||||
|
||||
Reference in New Issue
Block a user