Skip to content

Commit

Permalink
Robustify providerFromEngine callback type check (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks authored Mar 12, 2021
1 parent 3eb4f1a commit aa70ced
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/providerFromEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function providerFromEngine(engine: JsonRpcEngine): SafeEventEmitterProvider {
// handle both rpc send methods
provider.sendAsync = engine.handle.bind(engine);
provider.send = (req: JsonRpcRequest<string[]>, callback: VoidFunction) => {
if (!callback) {
throw new Error('Web3 Provider - must provider callback to "send" method');
if (typeof callback !== 'function') {
throw new Error('Must provide callback to "send" method.');
}
engine.handle(req, callback);
};
Expand Down

0 comments on commit aa70ced

Please sign in to comment.