aboutsummaryrefslogtreecommitdiffstats
path: root/contracts
diff options
context:
space:
mode:
Diffstat (limited to 'contracts')
-rw-r--r--contracts/protocol/test/utils/exchange_wrapper.ts15
-rw-r--r--contracts/protocol/test/utils/fill_order_combinatorial_utils.ts6
-rw-r--r--contracts/protocol/test/utils/types.ts8
3 files changed, 24 insertions, 5 deletions
diff --git a/contracts/protocol/test/utils/exchange_wrapper.ts b/contracts/protocol/test/utils/exchange_wrapper.ts
index cb6dce901..437882b41 100644
--- a/contracts/protocol/test/utils/exchange_wrapper.ts
+++ b/contracts/protocol/test/utils/exchange_wrapper.ts
@@ -8,13 +8,16 @@ import {
} from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { SignedOrder } from '@0x/types';
-import { BigNumber } from '@0x/utils';
+import { AbiEncoder, BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
-import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
+import { MethodAbi, Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
+import * as _ from 'lodash';
import { ExchangeContract } from '../../generated-wrappers/exchange';
import { artifacts } from '../../src/artifacts';
+import { AbiDecodedFillOrderData } from './types';
+
export class ExchangeWrapper {
private readonly _exchange: ExchangeContract;
private readonly _web3Wrapper: Web3Wrapper;
@@ -275,6 +278,14 @@ export class ExchangeWrapper {
);
return data;
}
+ public abiDecodeFillOrder(data: string): AbiDecodedFillOrderData {
+ // Lookup fillOrder ABI in exchange abi
+ const fillOrderAbi = _.find(this._exchange.abi, { name: 'fillOrder' }) as MethodAbi;
+ // Decode input data
+ const abiEncoder = new AbiEncoder.Method(fillOrderAbi);
+ const decodedData = abiEncoder.decode(data) as AbiDecodedFillOrderData;
+ return decodedData;
+ }
public getExchangeAddress(): string {
return this._exchange.address;
}
diff --git a/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts b/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts
index 5d0ea07a8..2fd33bebd 100644
--- a/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts
+++ b/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts
@@ -613,13 +613,13 @@ export class FillOrderCombinatorialUtils {
takerAssetFillAmount: BigNumber,
): Promise<void> {
const params = orderUtils.createFill(signedOrder, takerAssetFillAmount);
- const expectedAbiEncodedData = this.exchangeWrapper.abiEncodeFillOrder(signedOrder, { takerAssetFillAmount });
- const libsAbiEncodedData = await this.testLibsContract.publicAbiEncodeFillOrder.callAsync(
+ const abiDataEncodedByContract = await this.testLibsContract.publicAbiEncodeFillOrder.callAsync(
params.order,
params.takerAssetFillAmount,
params.signature,
);
- expect(libsAbiEncodedData).to.be.equal(expectedAbiEncodedData, 'ABIEncodedFillOrderData');
+ const paramsDecodedByClient = this.exchangeWrapper.abiDecodeFillOrder(abiDataEncodedByContract);
+ expect(paramsDecodedByClient).to.be.deep.equal(params, 'ABIEncodedFillOrderData');
}
private async _getTakerAssetFillAmountAsync(
signedOrder: SignedOrder,
diff --git a/contracts/protocol/test/utils/types.ts b/contracts/protocol/test/utils/types.ts
new file mode 100644
index 000000000..5f12635a7
--- /dev/null
+++ b/contracts/protocol/test/utils/types.ts
@@ -0,0 +1,8 @@
+import { SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
+
+export interface AbiDecodedFillOrderData {
+ order: SignedOrder;
+ takerAssetFillAmount: BigNumber;
+ signature: string;
+}