diff options
Diffstat (limited to 'packages/contracts/util/order.ts')
-rw-r--r-- | packages/contracts/util/order.ts | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/packages/contracts/util/order.ts b/packages/contracts/util/order.ts index e202d485b..57bb2bcbf 100644 --- a/packages/contracts/util/order.ts +++ b/packages/contracts/util/order.ts @@ -1,19 +1,17 @@ -import { BigNumber, promisify } from '@0xproject/utils'; +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; import ethUtil = require('ethereumjs-util'); import * as _ from 'lodash'; -import Web3 = require('web3'); import { crypto } from './crypto'; import { OrderParams } from './types'; -// In order to benefit from type-safety, we re-assign the global web3 instance injected by Truffle -// with type `any` to a variable of type `Web3`. -const web3: Web3 = (global as any).web3; - export class Order { public params: OrderParams; - constructor(params: OrderParams) { + private _web3Wrapper: Web3Wrapper; + constructor(web3Wrapper: Web3Wrapper, params: OrderParams) { this.params = params; + this._web3Wrapper = web3Wrapper; } public isValidSignature() { const { v, r, s } = this.params; @@ -32,7 +30,7 @@ export class Order { } public async signAsync() { const orderHash = this._getOrderHash(); - const signature = await promisify<string>(web3.eth.sign)(this.params.maker, orderHash); + const signature = await this._web3Wrapper.signTransactionAsync(this.params.maker, orderHash); const { v, r, s } = ethUtil.fromRpcSig(signature); this.params = _.assign(this.params, { orderHashHex: orderHash, |