Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1815 from 0xProject/bug/dutchAuctionDecode
Browse files Browse the repository at this point in the history
Incorrect decode in DutchAuctionWrapper
  • Loading branch information
dekz authored May 15, 2019
2 parents 418d033 + b4b34e4 commit c7f474a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
9 changes: 9 additions & 0 deletions packages/contract-wrappers/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "9.1.3",
"changes": [
{
"note": "Fix decoding bug in `DutchAuctionWrapper.decodeDutchAuctionData`",
"pr": 1815
}
]
},
{
"version": "9.1.2",
"changes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export class DutchAuctionWrapper extends ContractWrapper {
['uint256', 'uint256'],
dutchAuctionDetailsBuffer,
);
const beginTimeSeconds = new BigNumber(`0x${beginTimeSecondsAsBN.toString()}`);
const beginAmount = new BigNumber(`0x${beginAmountAsBN.toString()}`);
const beginTimeSeconds = new BigNumber(beginTimeSecondsAsBN.toString());
const beginAmount = new BigNumber(beginAmountAsBN.toString());
return {
assetData,
beginTimeSeconds,
Expand Down
19 changes: 17 additions & 2 deletions packages/contract-wrappers/test/dutch_auction_wrapper_test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { expectTransactionFailedAsync, getLatestBlockTimestampAsync } from '@0x/contracts-test-utils';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { RevertReason, SignedOrder } from '@0x/types';
import { ERC20AssetData, RevertReason, SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import 'mocha';

import { ContractWrappers } from '../src';
import { ContractWrappers, DutchAuctionWrapper } from '../src';

import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
Expand Down Expand Up @@ -91,6 +91,21 @@ describe('DutchAuctionWrapper', () => {
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
describe('.decodeDutchAuctionAssetData', () => {
it('decodes to the encoded values', async () => {
const encodedAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
makerTokenAssetData,
auctionBeginTimeSeconds,
makerAssetAmount,
);
const decodedAssetData = DutchAuctionWrapper.decodeDutchAuctionData(encodedAssetData);
// tslint:disable-next-line:no-unnecessary-type-assertion
const erc20AssetData = decodedAssetData.assetData as ERC20AssetData;
expect(erc20AssetData.tokenAddress).to.eq(makerTokenAddress);
expect(decodedAssetData.beginAmount).to.be.bignumber.eq(makerAssetAmount);
expect(decodedAssetData.beginTimeSeconds).to.be.bignumber.eq(auctionBeginTimeSeconds);
});
});
describe('#matchOrdersAsync', () => {
it('should match two orders', async () => {
const txHash = await contractWrappers.dutchAuction.matchOrdersAsync(buyOrder, sellOrder, takerAddress);
Expand Down

0 comments on commit c7f474a

Please sign in to comment.