diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-12-22 08:40:11 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2019-01-08 07:50:48 +0800 |
commit | b249a50d8f0054328a901525af6316133ed64023 (patch) | |
tree | 05cd417eb5aa1cda6f4f5592f71fa03ee9482d41 /packages/contract-wrappers | |
parent | 0432212a346aa761c54b5a9159a7e61e0c2f9b9a (diff) | |
download | dexon-sol-tools-b249a50d8f0054328a901525af6316133ed64023.tar dexon-sol-tools-b249a50d8f0054328a901525af6316133ed64023.tar.gz dexon-sol-tools-b249a50d8f0054328a901525af6316133ed64023.tar.bz2 dexon-sol-tools-b249a50d8f0054328a901525af6316133ed64023.tar.lz dexon-sol-tools-b249a50d8f0054328a901525af6316133ed64023.tar.xz dexon-sol-tools-b249a50d8f0054328a901525af6316133ed64023.tar.zst dexon-sol-tools-b249a50d8f0054328a901525af6316133ed64023.zip |
ran prettier
Diffstat (limited to 'packages/contract-wrappers')
-rw-r--r-- | packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts | 33 | ||||
-rw-r--r-- | packages/contract-wrappers/test/dutch_auction_wrapper_test.ts | 39 |
2 files changed, 35 insertions, 37 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 dea759962..b7cdff670 100644 --- a/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts @@ -1,14 +1,10 @@ -import { artifacts as protocolArtifacts } from '@0x/contracts-protocol'; import { DutchAuctionContract } from '@0x/abi-gen-wrappers'; 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 { DutchAuctionDetails, SignedOrder } from '@0x/types'; import { ContractAbi } from 'ethereum-types'; import { Web3Wrapper } from '@0x/web3-wrapper'; import { BigNumber, abiUtils } from '@0x/utils'; -import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; import ethAbi = require('ethereumjs-abi'); 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 * default to the known address corresponding to the networkId. */ - constructor( - web3Wrapper: Web3Wrapper, - networkId: number, - address?: string, - exchangeAddress?: string, - ) { + constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string, exchangeAddress?: string) { super(web3Wrapper, networkId); - this.address = this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).dutchAuction : address; - this._exchangeAddress = _.isUndefined(exchangeAddress) ? _getDefaultContractAddresses(networkId).exchange : exchangeAddress; + this.address = this.address = _.isUndefined(address) + ? _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 @@ -142,7 +137,11 @@ export class DutchAuctionWrapper extends ContractWrapper { * @param beginAmount Starting amount being sold in the dutch auction. * @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 abiEncodedAuctionData = (ethAbi as any).rawEncode( ['uint256', 'uint256'], @@ -152,7 +151,7 @@ export class DutchAuctionWrapper extends ContractWrapper { const dutchAuctionDataBuffer = Buffer.concat([assetDataBuffer, abiEncodedAuctionDataBuffer]); const dutchAuctionData = ethUtil.bufferToHex(dutchAuctionDataBuffer); return dutchAuctionData; - }; + } /** * 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 @@ -170,14 +169,14 @@ export class DutchAuctionWrapper extends ContractWrapper { const dutchAuctionDetailsBuffer = dutchAuctionDataBuffer.slice(dutchAuctionDataBuffer.byteLength - 64); const [beginTimeSecondsAsBN, beginAmountAsBN] = ethAbi.rawDecode( ['uint256', 'uint256'], - dutchAuctionDetailsBuffer + dutchAuctionDetailsBuffer, ); const beginTimeSeconds = new BigNumber(`0x${beginTimeSecondsAsBN.toString()}`); const beginAmount = new BigNumber(`0x${beginAmountAsBN.toString()}`); return { assetData, beginTimeSeconds, - beginAmount + beginAmount, }; - }; + } } diff --git a/packages/contract-wrappers/test/dutch_auction_wrapper_test.ts b/packages/contract-wrappers/test/dutch_auction_wrapper_test.ts index 697554dd1..fa5ef41fd 100644 --- a/packages/contract-wrappers/test/dutch_auction_wrapper_test.ts +++ b/packages/contract-wrappers/test/dutch_auction_wrapper_test.ts @@ -15,9 +15,7 @@ import { provider, web3Wrapper } from './utils/web3_wrapper'; import { getLatestBlockTimestampAsync } from '@0x/contracts-test-utils'; import { DutchAuctionUtils } from './utils/dutch_auction_utils'; -import { - expectTransactionFailedAsync, -} from '@0x/contracts-test-utils'; +import { expectTransactionFailedAsync } from '@0x/contracts-test-utils'; chaiSetup.configure(); const expect = chai.expect; @@ -25,7 +23,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); // tslint:disable:custom-no-magic-numbers 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; let contractWrappers: ContractWrappers; let exchangeContractAddress: string; @@ -69,7 +67,12 @@ describe.only('DutchAuctionWrapper', () => { auctionEndTimeSeconds = new BigNumber(currentBlockTimestamp + tenMinutesInSeconds); // create auction orders 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( auctionBeginTimeSeconds, auctionBeginAmount, @@ -81,10 +84,7 @@ describe.only('DutchAuctionWrapper', () => { constants.NULL_ADDRESS, auctionEndAmount, ); - buyOrder = await dutchAuctionUtils.createSignedBuyOrderAsync( - sellOrder, - takerAddress, - ); + buyOrder = await dutchAuctionUtils.createSignedBuyOrderAsync(sellOrder, takerAddress); }); after(async () => { await blockchainLifecycle.revertAsync(); @@ -105,15 +105,10 @@ describe.only('DutchAuctionWrapper', () => { const badSellOrder = buyOrder; const badBuyOrder = sellOrder; return expectTransactionFailedAsync( - contractWrappers.dutchAuction.matchOrdersAsync( - badBuyOrder, - badSellOrder, - takerAddress, - { - shouldValidate: true, - }, - ), - RevertReason.InvalidAssetData + contractWrappers.dutchAuction.matchOrdersAsync(badBuyOrder, badSellOrder, takerAddress, { + shouldValidate: true, + }), + RevertReason.InvalidAssetData, ); }); }); @@ -123,9 +118,13 @@ describe.only('DutchAuctionWrapper', () => { // get auction details const auctionDetails = await contractWrappers.dutchAuction.getAuctionDetailsAsync(sellOrder); // 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.endTimeSeconds, 'auctionDetails.endTimeSeconds').to.be.bignumber.equal(auctionEndTimeSeconds); + expect(auctionDetails.endTimeSeconds, 'auctionDetails.endTimeSeconds').to.be.bignumber.equal( + auctionEndTimeSeconds, + ); }); }); }); |