Merge pull request 'fixed big int reader' (#140) from tron-146 into main
Some checks failed
ci/woodpecker/push/fx_oracle Pipeline is pending
ci/woodpecker/push/ledger Pipeline is pending
ci/woodpecker/push/mntx_gateway Pipeline is pending
ci/woodpecker/push/nats Pipeline is pending
ci/woodpecker/push/notification Pipeline is pending
ci/woodpecker/push/payments_orchestrator Pipeline is pending
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline failed
ci/woodpecker/push/frontend Pipeline failed
ci/woodpecker/push/chain_gateway Pipeline was successful
Some checks failed
ci/woodpecker/push/fx_oracle Pipeline is pending
ci/woodpecker/push/ledger Pipeline is pending
ci/woodpecker/push/mntx_gateway Pipeline is pending
ci/woodpecker/push/nats Pipeline is pending
ci/woodpecker/push/notification Pipeline is pending
ci/woodpecker/push/payments_orchestrator Pipeline is pending
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline failed
ci/woodpecker/push/frontend Pipeline failed
ci/woodpecker/push/chain_gateway Pipeline was successful
Reviewed-on: #140
This commit was merged in pull request #140.
This commit is contained in:
@@ -199,11 +199,17 @@ 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, merrors.Internal("decimals call failed: " + err.Error())
|
||||
}
|
||||
val, err := hexutil.DecodeUint64(hexResp)
|
||||
val, err := hexutil.DecodeBig(hexResp)
|
||||
if err != nil {
|
||||
return 0, merrors.Internal("decimals decode failed: " + err.Error())
|
||||
}
|
||||
return uint8(val), nil
|
||||
if val == nil {
|
||||
return 0, merrors.Internal("decimals decode failed: empty response")
|
||||
}
|
||||
if val.BitLen() > 8 {
|
||||
return 0, merrors.Internal("decimals decode failed: value out of range")
|
||||
}
|
||||
return uint8(val.Uint64()), nil
|
||||
}
|
||||
|
||||
func toBaseUnits(amount string, decimals uint8) (*big.Int, error) {
|
||||
|
||||
@@ -104,11 +104,17 @@ func readDecimals(ctx context.Context, client *rpc.Client, token string) (uint8,
|
||||
if err := client.CallContext(ctx, &hexResp, "eth_call", call, "latest"); err != nil {
|
||||
return 0, merrors.Internal("decimals call failed: " + err.Error())
|
||||
}
|
||||
val, err := hexutil.DecodeUint64(hexResp)
|
||||
val, err := hexutil.DecodeBig(hexResp)
|
||||
if err != nil {
|
||||
return 0, merrors.Internal("decimals decode failed: " + err.Error())
|
||||
}
|
||||
return uint8(val), nil
|
||||
if val == nil {
|
||||
return 0, merrors.Internal("decimals decode failed: empty response")
|
||||
}
|
||||
if val.BitLen() > 8 {
|
||||
return 0, merrors.Internal("decimals decode failed: value out of range")
|
||||
}
|
||||
return uint8(val.Uint64()), nil
|
||||
}
|
||||
|
||||
func readBalanceOf(ctx context.Context, client *rpc.Client, token string, wallet string) (*big.Int, error) {
|
||||
|
||||
@@ -315,11 +315,17 @@ 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.DecodeUint64(hexResp)
|
||||
val, err := hexutil.DecodeBig(hexResp)
|
||||
if err != nil {
|
||||
return 0, executorInternal("decimals decode failed", err)
|
||||
}
|
||||
return uint8(val), nil
|
||||
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
|
||||
}
|
||||
|
||||
func toBaseUnits(amount string, decimals uint8) (*big.Int, error) {
|
||||
|
||||
Reference in New Issue
Block a user