Open edzillion opened 5 years ago
Seems like it's an issue connecting to ganache: Failed to connect to /127.0.0.1:8545
utilities.pad = (input) => {
console.log('input call', JSON.stringify(input))
if (input.startsWith('0x')) {
input call {"line":259178,"column":36,"sourceURL":"http://192.168.178.27:19001/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false&assetPlugin=E%3A%5Cdev%5Ccircles%5Ccircles-mobile%5Cnode_modules%5Cexpo%5Ctools%5ChashAssetFiles.js","statusCode":0,"responseText":"Failed to connect to /127.0.0.1:8545"}
It seems to be something to do with the provider not working right (I removed the RPC_URL
to use the default url)
export const customHttpProvider = new ethers.providers.JsonRpcProvider()
When I try to run a simple method on the provider it fails:
const latestBlock = await provider.getBlockNumber()
const accounts = await provider.listAccounts()
Both respond with Error: invalid response - 0
If I put that in a try catch block I get a big list of random warnings with some mention of the RPC toward the top:
Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See https://github.com/facebook/react-native/issues/12981 for more info. (Saw setTimeout with duration 120000ms)
- node_modules\expo\build\environment\logging.js:25:23 in warn
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:248:8 in setTimeout
- node_modules\ethers\dist\ethers.min.js:1:283646 in <unknown>
- node_modules\ethers\dist\shims.js:1:5963 in <unknown>
- node_modules\ethers\dist\shims.js:1:6022 in R
- node_modules\ethers\dist\ethers.min.js:1:283585 in fetchJson
- node_modules\ethers\dist\ethers.min.js:1:206210 in send
- node_modules\ethers\dist\ethers.min.js:1:206018 in listAccounts
* lib\utilities\metatx-client\index.js:46:25 in _accounts$
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:271:30 in invoke
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:135:28 in invoke
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:170:17 in <unknown>
- node_modules\ethers\dist\shims.js:1:5963 in <unknown>
- node_modules\ethers\dist\shims.js:1:6022 in R
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:169:27 in callInvokeWithMethodAndArg
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:192:38 in enqueue
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:216:8 in async
* null:null in _accounts
* lib\utilities\metatx-client\index.js:16:19 in MetaTx
* lib\utilities\blockchain.js:32:42 in <unknown>
- node_modules\metro\src\lib\polyfills\require.js:292:12 in loadModuleImplementation
* lib\sagas\AuthSaga.js:4:0 in <unknown>
- node_modules\metro\src\lib\polyfills\require.js:292:12 in loadModuleImplementation
* lib\sagas\index.js:3:0 in <unknown>
- node_modules\metro\src\lib\polyfills\require.js:292:12 in loadModuleImplementation
* lib\store\index.js:3:0 in <unknown>
- node_modules\metro\src\lib\polyfills\require.js:292:12 in loadModuleImplementation
* App.js:6:0 in <unknown>
- node_modules\metro\src\lib\polyfills\require.js:292:12 in loadModuleImplementation
- node_modules\expo\AppEntry.js:2:0 in <unknown>
- node_modules\metro\src\lib\polyfills\require.js:292:12 in loadModuleImplementation
- node_modules\metro\src\lib\polyfills\require.js:179:45 in guardedLoadModule
* null:null in global code
The provider object itself has the _lastBlockNumber
set to -2:
{"ready":{"":17,"_subscribers":[{"":18,"_subscribers":[]},null,null],"_onerror":null},"_lastBlockNumber":-2,"_balances":{},"_events":[],"_pollingInterval":4000,"_emitted":{"block":-2},"_fastQueryDate":0,"connection":{"url":"http://localhost:8545"}}
If I connect to ganache using a cli the listAccounts()
call works fine.
also the provider
object looks different:
JsonRpcProvider {
ready:
Promise {
<pending>,
domain:
Domain {
domain: null,
_events: [Object],
_eventsCount: 3,
_maxListeners: undefined,
members: [] } },
_lastBlockNumber: -2,
_balances: {},
_events: [],
_pollingInterval: 4000,
_emitted: { block: -2 },
_fastQueryDate: 0,
connection: { url: 'http://localhost:8545' } }
It seems for the provider to work, that the ready
promise needs to resolve to something like this:
{ chainId: 5777, name: 'unknown' }, domain: [...]
I am guessing this promise is not resolving; if I try
await provider.ready
It never returns.
Ok so it seems like no matter what I use as the RPC_URL
I still get the same object returned (with lots more subscribers), so I am pretty sure it never establishes a proper connection.
export const customHttpProvider = new ethers.providers.JsonRpcProvider('1.1.1.1')
provider {"ready":{"":49,"_subscribers":[{"":50,"_subscribers":[]},null,null],"_onerror":null},"_lastBlockNumber":-2,"_balances":{},"_events":[],"_pollingInterval":4000,"_emitted":{"block":-2},"_fastQueryDate":0,"connection":{"url":"1.1.1.1"}}
Other things I have tried:
--host 0.0.0.0
and connecting with new ethers.providers.JsonRpcProvider('http://0.0.0.0:8545')
no change
Don't install metatx-client as a package yet its not ready
Don't install metatx-client as a package yet its not ready
I am using it from the submodule lib\utilities\metatx-client