diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-07 20:41:30 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-07 20:41:30 +0800 |
commit | 568e4d33f29db2f5c0195585438e18ab4b2aea18 (patch) | |
tree | 4f2372dc040f4354d51cfb2229391cfd7c033264 /packages/contracts/util/exchange_wrapper.ts | |
parent | fd004032cb23998184a78ac4a0a486ef1bd04c25 (diff) | |
download | dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.gz dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.bz2 dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.lz dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.xz dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.zst dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.zip |
Use Order and SignedOrder type from 0x.js
Diffstat (limited to 'packages/contracts/util/exchange_wrapper.ts')
-rw-r--r-- | packages/contracts/util/exchange_wrapper.ts | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/packages/contracts/util/exchange_wrapper.ts b/packages/contracts/util/exchange_wrapper.ts index ff263246f..03d04629d 100644 --- a/packages/contracts/util/exchange_wrapper.ts +++ b/packages/contracts/util/exchange_wrapper.ts @@ -1,4 +1,4 @@ -import { TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js'; +import { SignedOrder, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import * as Web3 from 'web3'; @@ -6,7 +6,7 @@ import * as Web3 from 'web3'; import { ExchangeContract } from '../src/contract_wrappers/generated/exchange'; import { formatters } from './formatters'; -import { SignedOrder } from './signed_order'; +import { signedOrderUtils } from './signed_order_utils'; export class ExchangeWrapper { private _exchange: ExchangeContract; @@ -24,7 +24,11 @@ export class ExchangeWrapper { } = {}, ): Promise<TransactionReceiptWithDecodedLogs> { const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance; - const params = signedOrder.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount); + const params = signedOrderUtils.createFill( + signedOrder, + shouldThrowOnInsufficientBalanceOrAllowance, + opts.fillTakerTokenAmount, + ); const txHash = await this._exchange.fillOrder.sendTransactionAsync( params.orderAddresses, params.orderValues, @@ -45,7 +49,7 @@ export class ExchangeWrapper { from: string, opts: { cancelTakerTokenAmount?: BigNumber } = {}, ): Promise<TransactionReceiptWithDecodedLogs> { - const params = signedOrder.createCancel(opts.cancelTakerTokenAmount); + const params = signedOrderUtils.createCancel(signedOrder, opts.cancelTakerTokenAmount); const txHash = await this._exchange.cancelOrder.sendTransactionAsync( params.orderAddresses, params.orderValues, @@ -63,7 +67,11 @@ export class ExchangeWrapper { opts: { fillTakerTokenAmount?: BigNumber } = {}, ): Promise<TransactionReceiptWithDecodedLogs> { const shouldThrowOnInsufficientBalanceOrAllowance = true; - const params = signedOrder.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount); + const params = signedOrderUtils.createFill( + signedOrder, + shouldThrowOnInsufficientBalanceOrAllowance, + opts.fillTakerTokenAmount, + ); const txHash = await this._exchange.fillOrKillOrder.sendTransactionAsync( params.orderAddresses, params.orderValues, @@ -177,17 +185,17 @@ export class ExchangeWrapper { } public async getOrderHashAsync(signedOrder: SignedOrder): Promise<string> { const shouldThrowOnInsufficientBalanceOrAllowance = false; - const params = signedOrder.createFill(shouldThrowOnInsufficientBalanceOrAllowance); + const params = signedOrderUtils.getOrderAddressesAndValues(signedOrder); const orderHash = await this._exchange.getOrderHash(params.orderAddresses, params.orderValues); return orderHash; } public async isValidSignatureAsync(signedOrder: SignedOrder): Promise<boolean> { const isValidSignature = await this._exchange.isValidSignature( - signedOrder.params.maker, - signedOrder.getOrderHashHex(), - signedOrder.params.v, - signedOrder.params.r, - signedOrder.params.s, + signedOrder.maker, + ZeroEx.getOrderHashHex(signedOrder), + signedOrder.ecSignature.v, + signedOrder.ecSignature.r, + signedOrder.ecSignature.s, ); return isValidSignature; } |