ran prettier
This commit is contained in:
parent
0432212a34
commit
b249a50d8f
@ -70,7 +70,11 @@ export class DutchAuctionTestWrapper {
|
|||||||
* @param beginAmount Starting amount being sold in the dutch auction.
|
* @param beginAmount Starting amount being sold in the dutch auction.
|
||||||
* @return The hex encoded assetData string.
|
* @return The hex encoded assetData string.
|
||||||
*/
|
*/
|
||||||
public static encodeDutchAuctionAssetData(assetData: string, beginTimeSeconds: BigNumber, beginAmount: BigNumber): string {
|
public static encodeDutchAuctionAssetData(
|
||||||
|
assetData: string,
|
||||||
|
beginTimeSeconds: BigNumber,
|
||||||
|
beginAmount: BigNumber,
|
||||||
|
): string {
|
||||||
return DutchAuctionWrapper.encodeDutchAuctionAssetData(assetData, beginTimeSeconds, beginAmount);
|
return DutchAuctionWrapper.encodeDutchAuctionAssetData(assetData, beginTimeSeconds, beginAmount);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
import { artifacts as protocolArtifacts } from '@0x/contracts-protocol';
|
|
||||||
import { DutchAuctionContract } from '@0x/abi-gen-wrappers';
|
import { DutchAuctionContract } from '@0x/abi-gen-wrappers';
|
||||||
import { DutchAuction } from '@0x/contract-artifacts';
|
import { DutchAuction } from '@0x/contract-artifacts';
|
||||||
import { LogDecoder } from '@0x/contracts-test-utils';
|
|
||||||
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
|
|
||||||
import { _getDefaultContractAddresses } from '../utils/contract_addresses';
|
import { _getDefaultContractAddresses } from '../utils/contract_addresses';
|
||||||
import { DutchAuctionDetails, SignedOrder } from '@0x/types';
|
import { DutchAuctionDetails, SignedOrder } from '@0x/types';
|
||||||
import { ContractAbi } from 'ethereum-types';
|
import { ContractAbi } from 'ethereum-types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { BigNumber, abiUtils } from '@0x/utils';
|
import { BigNumber, abiUtils } from '@0x/utils';
|
||||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import ethAbi = require('ethereumjs-abi');
|
import ethAbi = require('ethereumjs-abi');
|
||||||
import { schemas } from '@0x/json-schemas';
|
import { schemas } from '@0x/json-schemas';
|
||||||
@ -35,15 +31,14 @@ export class DutchAuctionWrapper extends ContractWrapper {
|
|||||||
* @param address The address of the Dutch Auction contract. If undefined, will
|
* @param address The address of the Dutch Auction contract. If undefined, will
|
||||||
* default to the known address corresponding to the networkId.
|
* default to the known address corresponding to the networkId.
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string, exchangeAddress?: string) {
|
||||||
web3Wrapper: Web3Wrapper,
|
|
||||||
networkId: number,
|
|
||||||
address?: string,
|
|
||||||
exchangeAddress?: string,
|
|
||||||
) {
|
|
||||||
super(web3Wrapper, networkId);
|
super(web3Wrapper, networkId);
|
||||||
this.address = this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).dutchAuction : address;
|
this.address = this.address = _.isUndefined(address)
|
||||||
this._exchangeAddress = _.isUndefined(exchangeAddress) ? _getDefaultContractAddresses(networkId).exchange : exchangeAddress;
|
? _getDefaultContractAddresses(networkId).dutchAuction
|
||||||
|
: address;
|
||||||
|
this._exchangeAddress = _.isUndefined(exchangeAddress)
|
||||||
|
? _getDefaultContractAddresses(networkId).exchange
|
||||||
|
: exchangeAddress;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Matches the buy and sell orders at an amount given the following: the current block time, the auction
|
* Matches the buy and sell orders at an amount given the following: the current block time, the auction
|
||||||
@ -142,7 +137,11 @@ export class DutchAuctionWrapper extends ContractWrapper {
|
|||||||
* @param beginAmount Starting amount being sold in the dutch auction.
|
* @param beginAmount Starting amount being sold in the dutch auction.
|
||||||
* @return The hex encoded assetData string.
|
* @return The hex encoded assetData string.
|
||||||
*/
|
*/
|
||||||
public static encodeDutchAuctionAssetData(assetData: string, beginTimeSeconds: BigNumber, beginAmount: BigNumber): string {
|
public static encodeDutchAuctionAssetData(
|
||||||
|
assetData: string,
|
||||||
|
beginTimeSeconds: BigNumber,
|
||||||
|
beginAmount: BigNumber,
|
||||||
|
): string {
|
||||||
const assetDataBuffer = ethUtil.toBuffer(assetData);
|
const assetDataBuffer = ethUtil.toBuffer(assetData);
|
||||||
const abiEncodedAuctionData = (ethAbi as any).rawEncode(
|
const abiEncodedAuctionData = (ethAbi as any).rawEncode(
|
||||||
['uint256', 'uint256'],
|
['uint256', 'uint256'],
|
||||||
@ -152,7 +151,7 @@ export class DutchAuctionWrapper extends ContractWrapper {
|
|||||||
const dutchAuctionDataBuffer = Buffer.concat([assetDataBuffer, abiEncodedAuctionDataBuffer]);
|
const dutchAuctionDataBuffer = Buffer.concat([assetDataBuffer, abiEncodedAuctionDataBuffer]);
|
||||||
const dutchAuctionData = ethUtil.bufferToHex(dutchAuctionDataBuffer);
|
const dutchAuctionData = ethUtil.bufferToHex(dutchAuctionDataBuffer);
|
||||||
return dutchAuctionData;
|
return dutchAuctionData;
|
||||||
};
|
}
|
||||||
/**
|
/**
|
||||||
* Dutch auction details are encoded with the asset data for a 0x order. This function produces a hex
|
* Dutch auction details are encoded with the asset data for a 0x order. This function produces a hex
|
||||||
* encoded assetData string, containing information both about the asset being traded and the
|
* encoded assetData string, containing information both about the asset being traded and the
|
||||||
@ -170,14 +169,14 @@ export class DutchAuctionWrapper extends ContractWrapper {
|
|||||||
const dutchAuctionDetailsBuffer = dutchAuctionDataBuffer.slice(dutchAuctionDataBuffer.byteLength - 64);
|
const dutchAuctionDetailsBuffer = dutchAuctionDataBuffer.slice(dutchAuctionDataBuffer.byteLength - 64);
|
||||||
const [beginTimeSecondsAsBN, beginAmountAsBN] = ethAbi.rawDecode(
|
const [beginTimeSecondsAsBN, beginAmountAsBN] = ethAbi.rawDecode(
|
||||||
['uint256', 'uint256'],
|
['uint256', 'uint256'],
|
||||||
dutchAuctionDetailsBuffer
|
dutchAuctionDetailsBuffer,
|
||||||
);
|
);
|
||||||
const beginTimeSeconds = new BigNumber(`0x${beginTimeSecondsAsBN.toString()}`);
|
const beginTimeSeconds = new BigNumber(`0x${beginTimeSecondsAsBN.toString()}`);
|
||||||
const beginAmount = new BigNumber(`0x${beginAmountAsBN.toString()}`);
|
const beginAmount = new BigNumber(`0x${beginAmountAsBN.toString()}`);
|
||||||
return {
|
return {
|
||||||
assetData,
|
assetData,
|
||||||
beginTimeSeconds,
|
beginTimeSeconds,
|
||||||
beginAmount
|
beginAmount,
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,7 @@ import { provider, web3Wrapper } from './utils/web3_wrapper';
|
|||||||
import { getLatestBlockTimestampAsync } from '@0x/contracts-test-utils';
|
import { getLatestBlockTimestampAsync } from '@0x/contracts-test-utils';
|
||||||
import { DutchAuctionUtils } from './utils/dutch_auction_utils';
|
import { DutchAuctionUtils } from './utils/dutch_auction_utils';
|
||||||
|
|
||||||
import {
|
import { expectTransactionFailedAsync } from '@0x/contracts-test-utils';
|
||||||
expectTransactionFailedAsync,
|
|
||||||
} from '@0x/contracts-test-utils';
|
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
@ -25,7 +23,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
|||||||
|
|
||||||
// tslint:disable:custom-no-magic-numbers
|
// tslint:disable:custom-no-magic-numbers
|
||||||
describe.only('DutchAuctionWrapper', () => {
|
describe.only('DutchAuctionWrapper', () => {
|
||||||
const fillableAmount = new BigNumber(2);//Web3Wrapper.toBaseUnitAmount(new BigNumber(50), 18);
|
const fillableAmount = new BigNumber(2); //Web3Wrapper.toBaseUnitAmount(new BigNumber(50), 18);
|
||||||
const tenMinutesInSeconds = 10 * 60;
|
const tenMinutesInSeconds = 10 * 60;
|
||||||
let contractWrappers: ContractWrappers;
|
let contractWrappers: ContractWrappers;
|
||||||
let exchangeContractAddress: string;
|
let exchangeContractAddress: string;
|
||||||
@ -69,7 +67,12 @@ describe.only('DutchAuctionWrapper', () => {
|
|||||||
auctionEndTimeSeconds = new BigNumber(currentBlockTimestamp + tenMinutesInSeconds);
|
auctionEndTimeSeconds = new BigNumber(currentBlockTimestamp + tenMinutesInSeconds);
|
||||||
// create auction orders
|
// create auction orders
|
||||||
const coinbase = userAddresses[0];
|
const coinbase = userAddresses[0];
|
||||||
const dutchAuctionUtils = new DutchAuctionUtils(web3Wrapper, coinbase, exchangeContractAddress, contractWrappers.erc20Proxy.address);
|
const dutchAuctionUtils = new DutchAuctionUtils(
|
||||||
|
web3Wrapper,
|
||||||
|
coinbase,
|
||||||
|
exchangeContractAddress,
|
||||||
|
contractWrappers.erc20Proxy.address,
|
||||||
|
);
|
||||||
sellOrder = await dutchAuctionUtils.createSignedSellOrderAsync(
|
sellOrder = await dutchAuctionUtils.createSignedSellOrderAsync(
|
||||||
auctionBeginTimeSeconds,
|
auctionBeginTimeSeconds,
|
||||||
auctionBeginAmount,
|
auctionBeginAmount,
|
||||||
@ -81,10 +84,7 @@ describe.only('DutchAuctionWrapper', () => {
|
|||||||
constants.NULL_ADDRESS,
|
constants.NULL_ADDRESS,
|
||||||
auctionEndAmount,
|
auctionEndAmount,
|
||||||
);
|
);
|
||||||
buyOrder = await dutchAuctionUtils.createSignedBuyOrderAsync(
|
buyOrder = await dutchAuctionUtils.createSignedBuyOrderAsync(sellOrder, takerAddress);
|
||||||
sellOrder,
|
|
||||||
takerAddress,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await blockchainLifecycle.revertAsync();
|
await blockchainLifecycle.revertAsync();
|
||||||
@ -105,15 +105,10 @@ describe.only('DutchAuctionWrapper', () => {
|
|||||||
const badSellOrder = buyOrder;
|
const badSellOrder = buyOrder;
|
||||||
const badBuyOrder = sellOrder;
|
const badBuyOrder = sellOrder;
|
||||||
return expectTransactionFailedAsync(
|
return expectTransactionFailedAsync(
|
||||||
contractWrappers.dutchAuction.matchOrdersAsync(
|
contractWrappers.dutchAuction.matchOrdersAsync(badBuyOrder, badSellOrder, takerAddress, {
|
||||||
badBuyOrder,
|
shouldValidate: true,
|
||||||
badSellOrder,
|
}),
|
||||||
takerAddress,
|
RevertReason.InvalidAssetData,
|
||||||
{
|
|
||||||
shouldValidate: true,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
RevertReason.InvalidAssetData
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -123,9 +118,13 @@ describe.only('DutchAuctionWrapper', () => {
|
|||||||
// get auction details
|
// get auction details
|
||||||
const auctionDetails = await contractWrappers.dutchAuction.getAuctionDetailsAsync(sellOrder);
|
const auctionDetails = await contractWrappers.dutchAuction.getAuctionDetailsAsync(sellOrder);
|
||||||
// run some basic sanity checks on the return value
|
// run some basic sanity checks on the return value
|
||||||
expect(auctionDetails.beginTimeSeconds, 'auctionDetails.beginTimeSeconds').to.be.bignumber.equal(auctionBeginTimeSeconds);
|
expect(auctionDetails.beginTimeSeconds, 'auctionDetails.beginTimeSeconds').to.be.bignumber.equal(
|
||||||
|
auctionBeginTimeSeconds,
|
||||||
|
);
|
||||||
expect(auctionDetails.beginAmount, 'auctionDetails.beginAmount').to.be.bignumber.equal(auctionBeginAmount);
|
expect(auctionDetails.beginAmount, 'auctionDetails.beginAmount').to.be.bignumber.equal(auctionBeginAmount);
|
||||||
expect(auctionDetails.endTimeSeconds, 'auctionDetails.endTimeSeconds').to.be.bignumber.equal(auctionEndTimeSeconds);
|
expect(auctionDetails.endTimeSeconds, 'auctionDetails.endTimeSeconds').to.be.bignumber.equal(
|
||||||
|
auctionEndTimeSeconds,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user