From 7f257e258f5d5dedc9bc1edbd38180cc872bc2a0 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Fri, 2 Feb 2018 14:44:29 -0800 Subject: Change the InjectedWeb3Subprovider to accept Web3.Provider --- packages/subproviders/src/subproviders/injected_web3.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'packages/subproviders/src') diff --git a/packages/subproviders/src/subproviders/injected_web3.ts b/packages/subproviders/src/subproviders/injected_web3.ts index bd29acb22..238ba89f8 100644 --- a/packages/subproviders/src/subproviders/injected_web3.ts +++ b/packages/subproviders/src/subproviders/injected_web3.ts @@ -1,17 +1,16 @@ import * as _ from 'lodash'; import Web3 = require('web3'); -import Web3ProviderEngine = require('web3-provider-engine'); /* * This class implements the web3-provider-engine subprovider interface and forwards * requests involving user accounts (getAccounts, sendTransaction, etc...) to the injected - * web3 instance in their browser. + * MetamaskInpageProvider instance in their browser. * Source: https://github.com/MetaMask/provider-engine/blob/master/subproviders/subprovider.js */ export class InjectedWeb3Subprovider { private _injectedWeb3: Web3; - constructor(injectedWeb3: Web3) { - this._injectedWeb3 = injectedWeb3; + constructor(subprovider: Web3.Provider) { + this._injectedWeb3 = new Web3(subprovider); } public handleRequest( payload: Web3.JSONRPCRequestPayload, @@ -43,7 +42,7 @@ export class InjectedWeb3Subprovider { } // Required to implement this method despite not needing it for this subprovider // tslint:disable-next-line:prefer-function-over-method - public setEngine(engine: Web3ProviderEngine) { + public setEngine(engine: any) { // noop } } -- cgit v1.2.3 From 882816d60958f0e7d1b1aa06dc214ebdcfc53e2a Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Mon, 5 Feb 2018 13:46:59 -0800 Subject: Justify the any usage --- packages/subproviders/src/subproviders/injected_web3.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packages/subproviders/src') diff --git a/packages/subproviders/src/subproviders/injected_web3.ts b/packages/subproviders/src/subproviders/injected_web3.ts index 238ba89f8..a74a6c4b2 100644 --- a/packages/subproviders/src/subproviders/injected_web3.ts +++ b/packages/subproviders/src/subproviders/injected_web3.ts @@ -4,7 +4,7 @@ import Web3 = require('web3'); /* * This class implements the web3-provider-engine subprovider interface and forwards * requests involving user accounts (getAccounts, sendTransaction, etc...) to the injected - * MetamaskInpageProvider instance in their browser. + * provider instance in their browser. * Source: https://github.com/MetaMask/provider-engine/blob/master/subproviders/subprovider.js */ export class InjectedWeb3Subprovider { @@ -41,6 +41,7 @@ export class InjectedWeb3Subprovider { } } // Required to implement this method despite not needing it for this subprovider + // This type is Web3ProviderEngine, but there is no need to import this for a noop. // tslint:disable-next-line:prefer-function-over-method public setEngine(engine: any) { // noop -- cgit v1.2.3 From cf171d28c70c49541a30534d2593a623dd126f24 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Mon, 5 Feb 2018 17:20:45 -0800 Subject: Reword comment on any --- packages/subproviders/src/subproviders/injected_web3.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packages/subproviders/src') diff --git a/packages/subproviders/src/subproviders/injected_web3.ts b/packages/subproviders/src/subproviders/injected_web3.ts index a74a6c4b2..0d70180c4 100644 --- a/packages/subproviders/src/subproviders/injected_web3.ts +++ b/packages/subproviders/src/subproviders/injected_web3.ts @@ -41,7 +41,8 @@ export class InjectedWeb3Subprovider { } } // Required to implement this method despite not needing it for this subprovider - // This type is Web3ProviderEngine, but there is no need to import this for a noop. + // The engine argument type should be Web3ProviderEngine, but we've decided to keep it as type any + // to remove the provider engine depdency given this method is a noop // tslint:disable-next-line:prefer-function-over-method public setEngine(engine: any) { // noop -- cgit v1.2.3