aboutsummaryrefslogtreecommitdiffstats
path: root/src/web3_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-10-30 17:34:26 +0800
committerFabio Berger <me@fabioberger.com>2017-10-31 00:49:16 +0800
commit7bf6e6188aad6f5ae3de4fe04074abed33c73c53 (patch)
treeb46532a85b2d0d7deb94467e71c9e5ca8864adfe /src/web3_wrapper.ts
parent26394813f4824590bac00da05ab1026aa360c77f (diff)
downloaddexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar
dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar.gz
dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar.bz2
dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar.lz
dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar.xz
dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar.zst
dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.zip
Move provider altering logic to Web3Wrapper
Diffstat (limited to 'src/web3_wrapper.ts')
-rw-r--r--src/web3_wrapper.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts
index 3b1e4477b..01d572654 100644
--- a/src/web3_wrapper.ts
+++ b/src/web3_wrapper.ts
@@ -10,10 +10,16 @@ export class Web3Wrapper {
private defaults: Partial<Web3.TxData>;
private networkIdIfExists?: number;
private jsonRpcRequestId: number;
- constructor(provider: Web3.Provider, defaults: Partial<Web3.TxData>) {
+ constructor(provider: Web3.Provider, defaults?: Partial<Web3.TxData>) {
+ if (_.isUndefined((provider as any).sendAsync)) {
+ // Web3@1.0 provider doesn't support synchronous http requests,
+ // so it only has an async `send` method, instead of a `send` and `sendAsync` in web3@0.x.x`
+ // We re-assign the send method so that Web3@1.0 providers work with 0x.js
+ (provider as any).sendAsync = (provider as any).send;
+ }
this.web3 = new Web3();
this.web3.setProvider(provider);
- this.defaults = defaults;
+ this.defaults = defaults || {};
this.jsonRpcRequestId = 0;
}
public setProvider(provider: Web3.Provider) {