Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot unmarshal hex number with leading zero digits into Go struct field #59

Open
sfurionix opened this issue Jul 15, 2021 · 0 comments

Comments

@sfurionix
Copy link

sfurionix commented Jul 15, 2021

Example response from Eth: Client RPC error response [uri] / [method] eth_estimateGas [error code] -32602 [error message] invalid argument 0: json: cannot unmarshal hex number with leading zero digits into Go struct field CallArgs.value of type *hexutil.Big
Method EthQ::hexValUnpadded() must return a string without leading zeros. For example, 0.2 ether (200000000000000000 wei) should be converted to 0x2c68af0bb140000 instead of 0x02c68af0bb140000.

Suggesting changes:

--- src/DataType/EthQ.php
+++ src/DataType/EthQ.php
@@ -282,7 +282,7 @@ class EthQ extends EthD
      */
     public function hexValUnpadded()
     {
-        return '0x' . $this->value->toHex($this->value->is_negative);
+        return '0x' . ltrim($this->value->toHex($this->value->is_negative), '0');
     }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant