Open mdtanrikulu opened 5 years ago
We should add support for the latest versions of web3.
Doesn't work with web3@1.0.0-beta52.
Ps: we can't use ganache-core or ganache-cli as provider with web3js because ganache-core has not yet been ported (to web3 > beta37). So if you upgrade, the unit tests will not work.
Doesn't work with web3@1.0.0-beta55 Tried with different web3 versions but all give this error.
UnhandledPromiseRejectionWarning: Error: Node error: {"code":-32600,"message":"invalid json request"}
@mdtanrikulu Could you describe more clearly how you resolve this?
@OliveIT web@1.0.0-beta37 and below are ok. Be sure to use the right syntax in package.json, not the one with '^...'. If you need to only resolve name, you should use web3js or ethers. If you need reverse, ethers is the only way to do it with a recent web3js version.
There is a feature ticket: https://github.com/ethereum/web3.js/issues/2683
How are you initializing ensjs? You can now pass a provider object as the first argument, which should remove any dependency on a specific version.
I'm using infura in my tests:
new ENS(new Web3.providers.HttpProvider(`https://mainnet.infura.io/v3/${token}`))
I have this error:
(node:7284) UnhandledPromiseRejectionWarning: Error: Node error: {"code":-32600,"message":"invalid json request"}
at Function.validate (/home/ellis/Documents/Perso/Sources/fireblock/backend_express/node_modules/web3-providers/dist/web3-providers.cjs.js:111:18)
at HttpProvider._callee$ (/home/ellis/Documents/Perso/Sources/fireblock/backend_express/node_modules/web3-providers/dist/web3-providers.cjs.js:706:61)
at tryCatch (/home/ellis/Documents/Perso/Sources/fireblock/backend_express/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/home/ellis/Documents/Perso/Sources/fireblock/backend_express/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.(anonymous function) [as next] (/home/ellis/Documents/Perso/Sources/fireblock/backend_express/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/home/ellis/Documents/Perso/Sources/fireblock/backend_express/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/home/ellis/Documents/Perso/Sources/fireblock/backend_express/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at process.internalTickCallback (internal/process/next_tick.js:77:7)
@ellis2323 That traceback doesn't tell us a lot because it doesn't include the call site. Are you able to narrow down what call is causing it?
I will recheck in few hours. Please wait my confirmation.
A simple unit test with web3 beta52. It was something like that:
const ENS = require('ethereum-ens')
const Web3 = require('web3')
let provider = new Web3.providers.HttpProvider(`https://mainnet.infura.io/v3/${token}`)
const ens = new ENS(provider);
let address = await ens.resolver('ellis2323.eth').addr()
Looks like this is more of Infura not responding to older version of web3.js.
Here is the sample code.
const Web3 = require('web3')
const Web3Legacy = require('web3legacy')
console.log('web3 version', (new Web3()).version)
console.log('web3 legacy version', (new Web3Legacy()).version)
// Do "export INFURA_PROJECT_ID=YOURPROJECTID" on your terminal
const projectid = process.env.INFURA_PROJECT_ID
const endpoint = 'https://mainnet.infura.io/v3/' + projectid
const provider = new Web3.providers.HttpProvider(endpoint)
const web3 = new Web3(provider)
const web3legacy = new Web3Legacy(provider)
async function call(){
console.log('latest web3')
console.log('blocknumber', await web3.eth.getBlockNumber())
console.log('lagacy web3')
console.log('blocknumber', await web3legacy.eth.getBlockNumber())
}
call()
The above script shows the same error message
web3 version 1.0.0-beta.55
web3 legacy version 1.0.0-beta.37
latest web3
blocknumber 7732404
lagacy web3
(node:57809) UnhandledPromiseRejectionWarning: Error: Node error: {"code":-32600,"message":"invalid json request"}
at Function.validate (/Users/makoto/work/ens/tmp/ethereum-ens-versions/node_modules/web3-providers/dist/web3-providers.cjs.js:114:18)
at HttpProvider._callee$ (/Users/makoto/work/ens/tmp/ethereum-ens-versions/node_modules/web3-providers/dist/web3-providers.cjs.js:710:61)
at tryCatch (/Users/makoto/work/ens/tmp/ethereum-ens-versions/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/Users/makoto/work/ens/tmp/ethereum-ens-versions/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.(anonymous function) [as next] (/Users/makoto/work/ens/tmp/ethereum-ens-versions/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/Users/makoto/work/ens/tmp/ethereum-ens-versions/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/Users/makoto/work/ens/tmp/ethereum-ens-versions/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
(node:57809) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:57809) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I am quite sure that this started happening recently as it did not happen back in March when I last tried..
I will raise the issue into Infura and will see what they say. If they won't support old version of web3, then we may have to upgrade web3 we use to the latest (which I tried but struggled a bit.
I use infura for other calls without problem. It must be related to their code with ens functions. But thanks @makoto great identification.
It looks like there might be some strange dependency issues that are causing this. It definitely is sending invalid json. more details on our infura community thread: https://community.infura.io/t/web3-js-1-0-0-beta-37-call-raises-code-32600-message-invalid-json-request/583/3?u=egalano
Could we release a new version not pinned to web3@1.0.0.beta.37
now that web3@1.2.0
is out (essentially a LTS version of beta.37
)?
Any chance we can get it switched over to web3@1.2.0
it seems like it should be drop in replacement as it is just a version name change?
Bumping this for support of Web3 1.x
Hello! It would be better If you mention about compatible version range of Web3.js in the readme or in release page for each release.
The latest version of Web3.js doesn't work with the library at all.
With a quick test, I would say, from
web3@1.0.0-beta27
toweb3@1.0.0-beta37
is fine with the latest one.web3@1.0.0-beta27
and below gives;core.addProviders is not a function
errorweb3@1.0.0-beta38 - 39
has a babel module issueCannot find module '@babel/runtime/helpers/classCallCheck'
web3@1.0.0-beta40
and above has;(node:91462) UnhandledPromiseRejectionWarning: Error: Node error: {"code":-32600,"message":"invalid json request"}