You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
web3.eth.sendTransaction() supports both a synchronous mode and an async mode. If a callback is not provided, this will be a synchronous call, with a return value being the transaction hash. If a callback is present, it's async.
The default Web3.providers.HttpProvider supports both sync and async sends so if the above sendTransaction() is used with the default http provider, both work.
ethjs-provider-signer and ethjs-provider-http however only support the async version (sendAsync()). When used as a drop-in replacement for HttpProvider in the sync version, an error is generated:
var result = this.provider.send(payload);
^
TypeError: this.provider.send is not a function
Can the sync version of send(payload) be added to both ethjs-provider-signer and ethjs-provider-http to make it a full drop-in replacement for HttpProvider, esp. since ethjs-provider-signer is the recommended replacement for HookedWeb3Provider?
Efficiency aside, the sync version give people an option when async just can't cut it.
Steps to reproduce
const Web3 = require('web3');
const SignerProvider = require('ethjs-provider-signer');
const web3 = new Web3();
const signerProv = new SignerProvider(....);
const httpProv = new Web3.providers.HttpProvider("url");
web3.setProvider(httpProv);
let hash = web3.eth.sendTransaction({data: ..., from:...}); // works
web3.setProvider(signerProv);
hash = web3.eth.sendTransaction({data: ..., from: ...}); // does not work
Versions
Node/NPM: 7.7.1
Browser:
The text was updated successfully, but these errors were encountered:
@sharkfisher heyo, yes. We have a strict no-sync policy across all methods with ethjs. This is by choice. All methods are to be handled with proper callbacks or promises, so that errors are easier to handle.
ethjs-provider-signer/ethjs-provider-http
Issue Type
Description
web3.eth.sendTransaction() supports both a synchronous mode and an async mode. If a callback is not provided, this will be a synchronous call, with a return value being the transaction hash. If a callback is present, it's async.
The default Web3.providers.HttpProvider supports both sync and async sends so if the above sendTransaction() is used with the default http provider, both work.
ethjs-provider-signer and ethjs-provider-http however only support the async version (sendAsync()). When used as a drop-in replacement for HttpProvider in the sync version, an error is generated:
Can the sync version of send(payload) be added to both ethjs-provider-signer and ethjs-provider-http to make it a full drop-in replacement for HttpProvider, esp. since ethjs-provider-signer is the recommended replacement for HookedWeb3Provider?
Efficiency aside, the sync version give people an option when async just can't cut it.
Steps to reproduce
Versions
The text was updated successfully, but these errors were encountered: