diff options
Merge branch 'master' of github.com:MetaMask/metamask-extension into filter-leak-fix
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/lib/inpage-provider.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js index b2515bfb8..da75c4be2 100644 --- a/app/scripts/lib/inpage-provider.js +++ b/app/scripts/lib/inpage-provider.js @@ -38,14 +38,22 @@ function MetamaskInpageProvider (connectionStream) { streamMiddleware.stream, (err) => logStreamDisconnectWarning('MetaMask RpcProvider', err) ) + // handle sendAsync requests via dapp-side rpc engine - const engine = new RpcEngine() - engine.push(createIdRemapMiddleware()) - engine.push(streamMiddleware) + const rpcEngine = new RpcEngine() + rpcEngine.push(createIdRemapMiddleware()) + rpcEngine.push(streamMiddleware) + self.rpcEngine = rpcEngine +} - self.sendAsync = engine.handle.bind(engine) +// handle sendAsync requests via asyncProvider +// also remap ids inbound and outbound +MetamaskInpageProvider.prototype.sendAsync = function (payload, cb) { + const self = this + self.rpcEngine.handle(payload, cb) } + MetamaskInpageProvider.prototype.send = function (payload) { const self = this @@ -91,10 +99,6 @@ MetamaskInpageProvider.prototype.send = function (payload) { } } -MetamaskInpageProvider.prototype.sendAsync = function () { - throw new Error('MetamaskInpageProvider - sendAsync not overwritten') -} - MetamaskInpageProvider.prototype.isConnected = function () { return true } |