aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-12-22 08:40:07 +0800
committerGreg Hysen <greg.hysen@gmail.com>2019-01-08 07:50:48 +0800
commit0432212a346aa761c54b5a9159a7e61e0c2f9b9a (patch)
treed713c31d0a4820cc462846030754f6fd96ec4cdc /packages/contract-wrappers/src
parent7203ca90cf9bff2f7accf5fe2ee7da5764d0dac3 (diff)
downloaddexon-0x-contracts-0432212a346aa761c54b5a9159a7e61e0c2f9b9a.tar.gz
dexon-0x-contracts-0432212a346aa761c54b5a9159a7e61e0c2f9b9a.tar.zst
dexon-0x-contracts-0432212a346aa761c54b5a9159a7e61e0c2f9b9a.zip
dutch wrapper tests working
Diffstat (limited to 'packages/contract-wrappers/src')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts24
-rw-r--r--packages/contract-wrappers/src/types.ts12
2 files changed, 22 insertions, 14 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts
index 5896617fc..dea759962 100644
--- a/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts
@@ -19,9 +19,9 @@ import { orderTxOptsSchema } from '../schemas/order_tx_opts_schema';
import { txOptsSchema } from '../schemas/tx_opts_schema';
import { OrderTransactionOpts } from '../types';
import { ContractWrapper } from './contract_wrapper';
-import { ExchangeWrapperError } from '../types';
+import { DutchAuctionWrapperError, DutchAuctionData } from '../types';
-import { assetDataUtils, AssetData } from '@0x/order-utils';
+import { assetDataUtils } from '@0x/order-utils';
export class DutchAuctionWrapper extends ContractWrapper {
public abi: ContractAbi = DutchAuction.compilerOutput.abi;
@@ -72,11 +72,7 @@ export class DutchAuctionWrapper extends ContractWrapper {
sellOrder.makerAssetData !== buyOrder.takerAssetData ||
sellOrder.takerAssetData !== buyOrder.makerAssetData
) {
- throw new Error(ExchangeWrapperError.AssetDataMismatch);
- } else {
- // Smart contracts assigns the asset data from the left order to the right one so we can save gas on reducing the size of call data
- //rightSignedOrder.makerAssetData = '0x';
- // rightSignedOrder.takerAssetData = '0x';
+ throw new Error(DutchAuctionWrapperError.AssetDataMismatch);
}
// get contract
const dutchAuctionInstance = await this._getDutchAuctionContractAsync();
@@ -119,8 +115,6 @@ export class DutchAuctionWrapper extends ContractWrapper {
// type assertions
assert.doesConformToSchema('sellOrder', sellOrder, schemas.signedOrderSchema);
// get contract
- console.log(sellOrder);
- console.log(await this._getDutchAuctionContractAsync());
const dutchAuctionInstance = await this._getDutchAuctionContractAsync();
// call contract
const afterAuctionDetails = await dutchAuctionInstance.getAuctionDetails.callAsync(sellOrder);
@@ -156,7 +150,6 @@ export class DutchAuctionWrapper extends ContractWrapper {
);
const abiEncodedAuctionDataBuffer = ethUtil.toBuffer(abiEncodedAuctionData);
const dutchAuctionDataBuffer = Buffer.concat([assetDataBuffer, abiEncodedAuctionDataBuffer]);
- // console.log(`GREFG --- `, abiEncodedAuctionData);
const dutchAuctionData = ethUtil.bufferToHex(dutchAuctionDataBuffer);
return dutchAuctionData;
};
@@ -165,9 +158,9 @@ export class DutchAuctionWrapper extends ContractWrapper {
* encoded assetData string, containing information both about the asset being traded and the
* dutch auction; which is usable in the makerAssetData or takerAssetData fields in a 0x order.
* @param dutchAuctionData Hex encoded assetData string for the asset being auctioned.
- * @return
+ * @return An object containing the auction asset, auction begin time and auction begin amount.
*/
- public static decodeDutchAuctionData(dutchAuctionData: string): [AssetData, BigNumber, BigNumber] {
+ public static decodeDutchAuctionData(dutchAuctionData: string): DutchAuctionData {
const dutchAuctionDataBuffer = ethUtil.toBuffer(dutchAuctionData);
// Decode asset data
const assetDataBuffer = dutchAuctionDataBuffer.slice(0, dutchAuctionDataBuffer.byteLength - 64);
@@ -181,7 +174,10 @@ export class DutchAuctionWrapper extends ContractWrapper {
);
const beginTimeSeconds = new BigNumber(`0x${beginTimeSecondsAsBN.toString()}`);
const beginAmount = new BigNumber(`0x${beginAmountAsBN.toString()}`);
- console.log(beginAmount);
- return [assetData, beginTimeSeconds, beginAmount];
+ return {
+ assetData,
+ beginTimeSeconds,
+ beginAmount
+ };
};
}
diff --git a/packages/contract-wrappers/src/types.ts b/packages/contract-wrappers/src/types.ts
index 14d4649ae..f23587c20 100644
--- a/packages/contract-wrappers/src/types.ts
+++ b/packages/contract-wrappers/src/types.ts
@@ -14,6 +14,8 @@ import { BigNumber } from '@0x/utils';
import { BlockParam, ContractEventArg, DecodedLogArgs, LogEntryEvent, LogWithDecodedArgs } from 'ethereum-types';
+import { AssetData } from '@0x/order-utils';
+
export enum ExchangeWrapperError {
AssetDataMismatch = 'ASSET_DATA_MISMATCH',
}
@@ -206,3 +208,13 @@ export interface BalanceAndAllowance {
balance: BigNumber;
allowance: BigNumber;
}
+
+export enum DutchAuctionWrapperError {
+ AssetDataMismatch = 'ASSET_DATA_MISMATCH',
+}
+
+export interface DutchAuctionData {
+ assetData: AssetData;
+ beginTimeSeconds: BigNumber;
+ beginAmount: BigNumber;
+}