diff options
author | Jacob Evans <jacob@dekz.net> | 2018-10-02 15:32:28 +0800 |
---|---|---|
committer | Jacob Evans <jacob@dekz.net> | 2018-10-05 10:00:41 +0800 |
commit | 07926ded6ef194969ffe26e3879d6e86a0eb9c50 (patch) | |
tree | 9603fa9942cdf1c364fe794e037013351416fc73 /packages/website | |
parent | adcfaa2e80389f69e196b602955cee858a1eb40f (diff) | |
download | dexon-0x-contracts-07926ded6ef194969ffe26e3879d6e86a0eb9c50.tar dexon-0x-contracts-07926ded6ef194969ffe26e3879d6e86a0eb9c50.tar.gz dexon-0x-contracts-07926ded6ef194969ffe26e3879d6e86a0eb9c50.tar.bz2 dexon-0x-contracts-07926ded6ef194969ffe26e3879d6e86a0eb9c50.tar.lz dexon-0x-contracts-07926ded6ef194969ffe26e3879d6e86a0eb9c50.tar.xz dexon-0x-contracts-07926ded6ef194969ffe26e3879d6e86a0eb9c50.tar.zst dexon-0x-contracts-07926ded6ef194969ffe26e3879d6e86a0eb9c50.zip |
Introduce Metamask Subprovider.
MM has a number of inconsistencies with other providers when implementing the JSON RPC interface. This subprovider wraps those nuances so they do not leak into the rest of our code
Diffstat (limited to 'packages/website')
-rw-r--r-- | packages/website/ts/blockchain.ts | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index c420bbf3a..652f2eb1d 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -9,14 +9,14 @@ import { ExchangeFillEventArgs, IndexedFilterValues, } from '@0xproject/contract-wrappers'; -import { assetDataUtils, orderHashUtils, signatureUtils, SignerType } from '@0xproject/order-utils'; +import { assetDataUtils, orderHashUtils, signatureUtils } from '@0xproject/order-utils'; import { EtherscanLinkSuffixes, utils as sharedUtils } from '@0xproject/react-shared'; import { ledgerEthereumBrowserClientFactoryAsync, LedgerSubprovider, + MetamaskSubprovider, RedundantSubprovider, RPCSubprovider, - SignerSubprovider, Web3ProviderEngine, } from '@0xproject/subproviders'; import { SignedOrder, Token as ZeroExToken } from '@0xproject/types'; @@ -161,7 +161,7 @@ export class Blockchain { // We catch all requests involving a users account and send it to the injectedWeb3 // instance. All other requests go to the public hosted node. const provider = new Web3ProviderEngine(); - provider.addProvider(new SignerSubprovider(injectedWeb3.currentProvider)); + provider.addProvider(new MetamaskSubprovider(injectedWeb3.currentProvider)); provider.addProvider(new FilterSubprovider()); const rpcSubproviders = _.map(publicNodeUrlsIfExistsForNetworkId, publicNodeUrl => { return new RPCSubprovider(publicNodeUrl); @@ -432,21 +432,7 @@ export class Blockchain { } this._showFlashMessageIfLedger(); const provider = this._contractWrappers.getProvider(); - const isLedgerSigner = !_.isUndefined(this._ledgerSubprovider); - const injectedProvider = Blockchain._getInjectedWeb3().currentProvider; - const isMetaMaskSigner = utils.getProviderType(injectedProvider) === Providers.Metamask; - let signerType = SignerType.Default; - if (isLedgerSigner) { - signerType = SignerType.Ledger; - } else if (isMetaMaskSigner) { - signerType = SignerType.Metamask; - } - const ecSignatureString = await signatureUtils.ecSignOrderHashAsync( - provider, - orderHash, - makerAddress, - signerType, - ); + const ecSignatureString = await signatureUtils.ecSignHashAsync(provider, orderHash, makerAddress); this._dispatcher.updateSignature(ecSignatureString); return ecSignatureString; } |