-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Release / Debug build generated json-rpc calls are different #2501
Comments
Does this error also occur if you don't use the callback? const web3 = new Web3(`https://ropsten.infura.io/${Config.INFURA_API_KEY}`);
return web3.eth.getBalance(walletAddress).then((weiBalance) => {
return (weiBalance / Math.pow(10, 18));
}); |
Yes, tried it, and it occurs again. Somehow, the call gets weirdly nested after method key in release builds:
|
I've tested it with the version beta.48 of Web3.js in a NodeJS environment and in the browser without an error thrown. This looks like a problem of react-native especially because it's nesting the JSON-RPC payload object in a weird way. Could you create an example GitHub repository for me? Code: const web3 = new Web3('http://localhost:8545');
web3.eth.getBalance('0xdf09cba4cbd5902d83d4fa4e3f5e7dbfc7bd0bDD').then((weiBalance) => {
console.log((weiBalance / Math.pow(10, 18)));
}); Request:
Response:
|
@nivida I've included console.log/error statements in web3-providers/dist/web3-providers.umd.js before every sendPayload statement, here is what i've found: In Debug build, i get this, and everything works as intended:
In Release build. i strangely get this:
I'm using
in my start file, for react native web3 compatibility. I'll try to upload a reproducible repo as well. |
Description
I'm trying to make simple web3 calls in React Native with web3.js, but generated json-rpc calls are different between release / debug builds - IOS/Xcode.
Expected behavior
should return balance.
In Debug build, there is no problem.
Actual behavior
In Release build, it fails with
Node error: {"code":-32600,"message":"invalid json request"}
i've inspected that in my release build the json -rpc request becomes like this:
{"jsonrpc":"2.0","id":1,"method":{"jsonrpc":"2.0","id":0,"method":"eth_getBalance","params":["0xe1f42aa9aec952f61c5d929dd0b33690faaef976","latest"]}}
whereas in debug build the json-rpc request is like this:
{"jsonrpc":"2.0","id":0,"method":"eth_getBalance","params":["0xe1f42aa9aec952f61c5d929dd0b33690faaef976","latest"]}
how can the request get nested in the release build, this i don't understand...
Versions
Release build json-rpc call made by simulator/device, captured by Charles proxy.
The text was updated successfully, but these errors were encountered: