diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-10-11 09:27:06 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-10-11 09:28:12 +0800 |
commit | 19f61906d3075391efb32c17c99c2cba1f7a3858 (patch) | |
tree | 5341adb545f8cbc883f3e569adf99b58a8b03de1 /packages/instant/src/util/provider.ts | |
parent | a5a033c359a1a00a144ae0655080b4e6d0e43c88 (diff) | |
download | dexon-sol-tools-19f61906d3075391efb32c17c99c2cba1f7a3858.tar dexon-sol-tools-19f61906d3075391efb32c17c99c2cba1f7a3858.tar.gz dexon-sol-tools-19f61906d3075391efb32c17c99c2cba1f7a3858.tar.bz2 dexon-sol-tools-19f61906d3075391efb32c17c99c2cba1f7a3858.tar.lz dexon-sol-tools-19f61906d3075391efb32c17c99c2cba1f7a3858.tar.xz dexon-sol-tools-19f61906d3075391efb32c17c99c2cba1f7a3858.tar.zst dexon-sol-tools-19f61906d3075391efb32c17c99c2cba1f7a3858.zip |
feat: Move over features from zrx-buyer
Diffstat (limited to 'packages/instant/src/util/provider.ts')
-rw-r--r-- | packages/instant/src/util/provider.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/instant/src/util/provider.ts b/packages/instant/src/util/provider.ts new file mode 100644 index 000000000..49705fd11 --- /dev/null +++ b/packages/instant/src/util/provider.ts @@ -0,0 +1,12 @@ +import { Provider } from 'ethereum-types'; + +export const getProvider = (): Provider => { + const injectedWeb3 = (window as any).web3 || undefined; + try { + // Use MetaMask/Mist provider + return injectedWeb3.currentProvider; + } catch (err) { + // Throws when user doesn't have MetaMask/Mist running + throw new Error(`No injected web3 found: ${err}`); + } +}; |