aboutsummaryrefslogtreecommitdiffstats
path: root/src/web3_wrapper.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-13 09:50:42 +0800
committerGitHub <noreply@github.com>2017-11-13 09:50:42 +0800
commitb0be323e899ea7be42b6c695b4fd6d526070b213 (patch)
tree86042b06c407b388e39be690d9a40db218f82675 /src/web3_wrapper.ts
parent1392a855bb17981f7680548a23062842fb6dc4e0 (diff)
parenta22661670f105a2bf527aca0e803689e0302ed17 (diff)
downloaddexon-sol-tools-b0be323e899ea7be42b6c695b4fd6d526070b213.tar
dexon-sol-tools-b0be323e899ea7be42b6c695b4fd6d526070b213.tar.gz
dexon-sol-tools-b0be323e899ea7be42b6c695b4fd6d526070b213.tar.bz2
dexon-sol-tools-b0be323e899ea7be42b6c695b4fd6d526070b213.tar.lz
dexon-sol-tools-b0be323e899ea7be42b6c695b4fd6d526070b213.tar.xz
dexon-sol-tools-b0be323e899ea7be42b6c695b4fd6d526070b213.tar.zst
dexon-sol-tools-b0be323e899ea7be42b6c695b4fd6d526070b213.zip
Merge pull request #205 from 0xProject/orderWatcher
Order watcher
Diffstat (limited to 'src/web3_wrapper.ts')
-rw-r--r--src/web3_wrapper.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts
index 3b1e4477b..d03c102b2 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) {
@@ -94,6 +100,10 @@ export class Web3Wrapper {
const signData = await promisify(this.web3.eth.sign)(address, message);
return signData;
}
+ public async getBlockNumberAsync(): Promise<number> {
+ const blockNumber = await promisify(this.web3.eth.getBlockNumber)();
+ return blockNumber;
+ }
public async getBlockAsync(blockParam: string|Web3.BlockParam): Promise<Web3.BlockWithoutTransactionData> {
const block = await promisify(this.web3.eth.getBlock)(blockParam);
return block;