diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-02-08 02:27:22 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-02-08 02:27:22 +0800 |
commit | f3c6cce4559d096a2f3babfc7af670d078a6f0dd (patch) | |
tree | 580c59d474d52affc57593d25eb1d0acd480d4b0 /packages/contracts/util/exchange_wrapper.ts | |
parent | d9b1d31e7310f7f554f1740f93e4ccd5b5db90f5 (diff) | |
parent | a26e77074fdf5ea7a754a7a676ebd752668d3c82 (diff) | |
download | dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.gz dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.bz2 dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.lz dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.xz dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.zst dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.zip |
Merge branch 'development' into feature/testnet-faucets/queue-by-network
* development: (24 commits)
Fix Remco's github name in CODEOWNERS
Fix ABI error message
Stop using definite assignment assertion cause prettier doesn't handle that
Special-case ZRXToken snake case conversion
Fix linter errors
Generate contract wrappers on pre-build
Add missing async
Remove noImplicitThis
Tslint disable no-consecutive-blank-lines in generated files
Change compiled sources in contracts
Change utils
Change tests
Add base_contract.ts
Remove generated files
.gitignore gemerated files
Change the list of generated wrappers
Change contract templates
Add indices for index parameters so that their names don't collide
Use abi-gen for events in 0x.js
Fix artifacts path
...
Diffstat (limited to 'packages/contracts/util/exchange_wrapper.ts')
-rw-r--r-- | packages/contracts/util/exchange_wrapper.ts | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/packages/contracts/util/exchange_wrapper.ts b/packages/contracts/util/exchange_wrapper.ts index 7a07239f5..b749cd72e 100644 --- a/packages/contracts/util/exchange_wrapper.ts +++ b/packages/contracts/util/exchange_wrapper.ts @@ -3,14 +3,16 @@ import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import * as Web3 from 'web3'; +import { ExchangeContract } from '../src/contract_wrappers/generated/exchange'; + import { formatters } from './formatters'; import { Order } from './order'; export class ExchangeWrapper { - private _exchange: Web3.ContractInstance; + private _exchange: ExchangeContract; private _zeroEx: ZeroEx; - constructor(exchangeContractInstance: Web3.ContractInstance, zeroEx: ZeroEx) { - this._exchange = exchangeContractInstance; + constructor(exchangeContract: ExchangeContract, zeroEx: ZeroEx) { + this._exchange = exchangeContract; this._zeroEx = zeroEx; } public async fillOrderAsync( @@ -23,14 +25,14 @@ export class ExchangeWrapper { ): Promise<TransactionReceiptWithDecodedLogs> { const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance; const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount); - const txHash = await this._exchange.fillOrder( + const txHash = await this._exchange.fillOrder.sendTransactionAsync( params.orderAddresses, params.orderValues, params.fillTakerTokenAmount, params.shouldThrowOnInsufficientBalanceOrAllowance, - params.v, - params.r, - params.s, + params.v as number, + params.r as string, + params.s as string, { from }, ); const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash); @@ -44,7 +46,7 @@ export class ExchangeWrapper { opts: { cancelTakerTokenAmount?: BigNumber } = {}, ): Promise<TransactionReceiptWithDecodedLogs> { const params = order.createCancel(opts.cancelTakerTokenAmount); - const txHash = await this._exchange.cancelOrder( + const txHash = await this._exchange.cancelOrder.sendTransactionAsync( params.orderAddresses, params.orderValues, params.cancelTakerTokenAmount, @@ -62,13 +64,13 @@ export class ExchangeWrapper { ): Promise<TransactionReceiptWithDecodedLogs> { const shouldThrowOnInsufficientBalanceOrAllowance = true; const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount); - const txHash = await this._exchange.fillOrKillOrder( + const txHash = await this._exchange.fillOrKillOrder.sendTransactionAsync( params.orderAddresses, params.orderValues, params.fillTakerTokenAmount, - params.v, - params.r, - params.s, + params.v as number, + params.r as string, + params.s as string, { from }, ); const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash); @@ -90,7 +92,7 @@ export class ExchangeWrapper { shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmounts, ); - const txHash = await this._exchange.batchFillOrders( + const txHash = await this._exchange.batchFillOrders.sendTransactionAsync( params.orderAddresses, params.orderValues, params.fillTakerTokenAmounts, @@ -116,7 +118,7 @@ export class ExchangeWrapper { shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmounts, ); - const txHash = await this._exchange.batchFillOrKillOrders( + const txHash = await this._exchange.batchFillOrKillOrders.sendTransactionAsync( params.orderAddresses, params.orderValues, params.fillTakerTokenAmounts, @@ -141,7 +143,7 @@ export class ExchangeWrapper { shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount, ); - const txHash = await this._exchange.fillOrdersUpTo( + const txHash = await this._exchange.fillOrdersUpTo.sendTransactionAsync( params.orderAddresses, params.orderValues, params.fillTakerTokenAmount, @@ -162,7 +164,7 @@ export class ExchangeWrapper { opts: { cancelTakerTokenAmounts?: BigNumber[] } = {}, ): Promise<TransactionReceiptWithDecodedLogs> { const params = formatters.createBatchCancel(orders, opts.cancelTakerTokenAmounts); - const txHash = await this._exchange.batchCancelOrders( + const txHash = await this._exchange.batchCancelOrders.sendTransactionAsync( params.orderAddresses, params.orderValues, params.cancelTakerTokenAmounts, @@ -182,10 +184,10 @@ export class ExchangeWrapper { public async isValidSignatureAsync(order: Order): Promise<boolean> { const isValidSignature = await this._exchange.isValidSignature( order.params.maker, - order.params.orderHashHex, - order.params.v, - order.params.r, - order.params.s, + order.params.orderHashHex as string, + order.params.v as number, + order.params.r as string, + order.params.s as string, ); return isValidSignature; } |