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

FallbackProvider: If only one provider is used, it is not possible to get the block number #3745

Closed
samuelexferri opened this issue Feb 7, 2023 · 0 comments
Assignees
Labels
investigate Under investigation and may be a bug.

Comments

@samuelexferri
Copy link

Ethers Version

6.0.2

Search Terms

FallbackProvider

Describe the Problem

I am using ethers v6.0.2 and when I use a FallbackProvider with only one JsonRpcProvider in the provider array I get an error.

I'm working on a fix!

Code Snippet

providersArray.push({
  provider: new ethers.JsonRpcProvider(providerUrls[i], network, {
    polling: true,
    staticNetwork: network,
  }),
  stallTimeout: 10000,
  weight: 3,
  priority: 1,
});

const provider = new ethers.FallbackProvider(providersArray, network); // Default Quorum is 2, so must have at least > 2 weight

provider.getBlockNumber().then((blockNumber) => {
  console.log(`Block Number: ${blockNumber}`);
});

Contract ABI

No response

Errors

Error:
 TypeError: invalid numeric value (argument="value", value=null, code=INVALID_ARGUMENT, version=6.0.2)
    at makeError (file:///Users/user/project/node_modules/ethers/lib.esm/utils/errors.js:109:21)
    at assert (file:///Users/user/project/node_modules/ethers/lib.esm/utils/errors.js:132:15)
    at assertArgument (file:///Users/user/project/node_modules/ethers/lib.esm/utils/errors.js:143:5)
    at getNumber (file:///Users/user/project/node_modules/ethers/lib.esm/utils/maths.js:139:5)
    at #checkQuorum (file:///Users/user/project/node_modules/ethers/lib.esm/providers/provider-fallback.js:385:46)
    at #waitForQuorum (file:///Users/user/project/node_modules/ethers/lib.esm/providers/provider-fallback.js:456:46)
    at #waitForQuorum (file:///Users/user/project/node_modules/ethers/lib.esm/providers/provider-fallback.js:477:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async FallbackProvider._perform (file:///Users/user/project/node_modules/ethers/lib.esm/providers/provider-fallback.js:509:24)
    at async #perform (file:///Users/user/project/node_modules/ethers/lib.esm/providers/abstract-provider.js:207:16) {
  code: 'INVALID_ARGUMENT',
  argument: 'value',
  value: undefined
}

Environment

No response

Environment (Other)

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug.
Projects
None yet
Development

No branches or pull requests

2 participants