aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-12-22 09:04:17 +0800
committerGreg Hysen <greg.hysen@gmail.com>2019-01-08 07:50:48 +0800
commitcb1bfa0f9790706bf9ce08aad0bf8fd9e2621ce9 (patch)
treefd063745d6e40e21ff7c85a3063ecafb93d98062
parentb249a50d8f0054328a901525af6316133ed64023 (diff)
downloaddexon-sol-tools-cb1bfa0f9790706bf9ce08aad0bf8fd9e2621ce9.tar
dexon-sol-tools-cb1bfa0f9790706bf9ce08aad0bf8fd9e2621ce9.tar.gz
dexon-sol-tools-cb1bfa0f9790706bf9ce08aad0bf8fd9e2621ce9.tar.bz2
dexon-sol-tools-cb1bfa0f9790706bf9ce08aad0bf8fd9e2621ce9.tar.lz
dexon-sol-tools-cb1bfa0f9790706bf9ce08aad0bf8fd9e2621ce9.tar.xz
dexon-sol-tools-cb1bfa0f9790706bf9ce08aad0bf8fd9e2621ce9.tar.zst
dexon-sol-tools-cb1bfa0f9790706bf9ce08aad0bf8fd9e2621ce9.zip
ran prettier + added changelog entry for contract wrappers
-rw-r--r--contracts/extensions/package.json1
-rw-r--r--contracts/extensions/test/extensions/dutch_auction.ts14
-rw-r--r--contracts/extensions/test/utils/dutch_auction_test_wrapper.ts18
-rw-r--r--packages/contract-wrappers/CHANGELOG.json10
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts8
5 files changed, 20 insertions, 31 deletions
diff --git a/contracts/extensions/package.json b/contracts/extensions/package.json
index 069b5d2d5..ad45073dc 100644
--- a/contracts/extensions/package.json
+++ b/contracts/extensions/package.json
@@ -45,6 +45,7 @@
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
"devDependencies": {
"@0x/abi-gen": "^1.0.19",
+ "@0x/contract-wrappers": "^4.2.0",
"@0x/contracts-test-utils": "^1.0.2",
"@0x/dev-utils": "^1.0.21",
"@0x/sol-compiler": "^1.1.16",
diff --git a/contracts/extensions/test/extensions/dutch_auction.ts b/contracts/extensions/test/extensions/dutch_auction.ts
index cd5816810..22b3caa16 100644
--- a/contracts/extensions/test/extensions/dutch_auction.ts
+++ b/contracts/extensions/test/extensions/dutch_auction.ts
@@ -1,3 +1,4 @@
+import { DutchAuctionWrapper } from '@0x/contract-wrappers';
import {
artifacts as protocolArtifacts,
ERC20Wrapper,
@@ -33,7 +34,6 @@ import * as _ from 'lodash';
import { DutchAuctionContract } from '../../generated-wrappers/dutch_auction';
import { artifacts } from '../../src/artifacts';
-
import { DutchAuctionTestWrapper } from '../utils/dutch_auction_test_wrapper';
chaiSetup.configure();
@@ -164,7 +164,7 @@ describe(ContractName.DutchAuction, () => {
feeRecipientAddress,
// taker address or sender address should be set to the ducth auction contract
takerAddress: dutchAuctionContract.address,
- makerAssetData: DutchAuctionTestWrapper.encodeDutchAuctionAssetData(
+ makerAssetData: DutchAuctionWrapper.encodeDutchAuctionAssetData(
assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
auctionBeginTimeSeconds,
auctionBeginAmount,
@@ -206,7 +206,7 @@ describe(ContractName.DutchAuction, () => {
describe('matchOrders', () => {
it('should be worth the begin price at the begining of the auction', async () => {
auctionBeginTimeSeconds = new BigNumber(currentBlockTimestamp + 2);
- const makerAssetData = DutchAuctionTestWrapper.encodeDutchAuctionAssetData(
+ const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
defaultERC20MakerAssetData,
auctionBeginTimeSeconds,
auctionBeginAmount,
@@ -220,7 +220,7 @@ describe(ContractName.DutchAuction, () => {
it('should be be worth the end price at the end of the auction', async () => {
auctionBeginTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds * 2);
auctionEndTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds);
- const makerAssetData = DutchAuctionTestWrapper.encodeDutchAuctionAssetData(
+ const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
defaultERC20MakerAssetData,
auctionBeginTimeSeconds,
auctionBeginAmount,
@@ -286,7 +286,7 @@ describe(ContractName.DutchAuction, () => {
it('should revert when auction expires', async () => {
auctionBeginTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds * 2);
auctionEndTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds);
- const makerAssetData = DutchAuctionTestWrapper.encodeDutchAuctionAssetData(
+ const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
defaultERC20MakerAssetData,
auctionBeginTimeSeconds,
auctionBeginAmount,
@@ -320,7 +320,7 @@ describe(ContractName.DutchAuction, () => {
});
it('begin time is less than end time', async () => {
auctionBeginTimeSeconds = new BigNumber(auctionEndTimeSeconds).plus(tenMinutesInSeconds);
- const makerAssetData = DutchAuctionTestWrapper.encodeDutchAuctionAssetData(
+ const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
defaultERC20MakerAssetData,
auctionBeginTimeSeconds,
auctionBeginAmount,
@@ -348,7 +348,7 @@ describe(ContractName.DutchAuction, () => {
it('should match orders when ERC721', async () => {
const makerAssetId = erc721MakerAssetIds[0];
const erc721MakerAssetData = assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId);
- const makerAssetData = DutchAuctionTestWrapper.encodeDutchAuctionAssetData(
+ const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
erc721MakerAssetData,
auctionBeginTimeSeconds,
auctionBeginAmount,
diff --git a/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts
index ae8f53aa5..4dc83a5e7 100644
--- a/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts
+++ b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts
@@ -5,11 +5,9 @@ import { DutchAuctionDetails, SignedOrder } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
-import { BigNumber } from '@0x/utils';
import { DutchAuctionContract } from '../../generated-wrappers/dutch_auction';
import { artifacts } from '../../src/artifacts';
-import { DutchAuctionWrapper } from '@0x/contract-wrappers';
export class DutchAuctionTestWrapper {
private readonly _dutchAuctionContract: DutchAuctionContract;
@@ -61,20 +59,4 @@ export class DutchAuctionTestWrapper {
const afterAuctionDetails = await this._dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
return afterAuctionDetails;
}
- /**
- * 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
- * dutch auction; which is usable in the makerAssetData or takerAssetData fields in a 0x order.
- * @param assetData Hex encoded assetData string for the asset being auctioned.
- * @param beginTimeSeconds Begin time of the dutch auction.
- * @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 {
- return DutchAuctionWrapper.encodeDutchAuctionAssetData(assetData, beginTimeSeconds, beginAmount);
- }
}
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json
index 581fbdee1..dadba6190 100644
--- a/packages/contract-wrappers/CHANGELOG.json
+++ b/packages/contract-wrappers/CHANGELOG.json
@@ -3,6 +3,16 @@
"version": "4.2.0",
"changes": [
{
+ "note":
+ "Added Dutch Auction wrapper",
+ "pr": 1465
+ }
+ ]
+ },
+ {
+ "version": "4.1.4",
+ "changes": [
+ {
"note": "Add support for Trust Wallet signature denial error"
},
{
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 b7cdff670..bb1e89555 100644
--- a/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts
@@ -4,7 +4,7 @@ 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 { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import ethAbi = require('ethereumjs-abi');
import { schemas } from '@0x/json-schemas';
@@ -22,7 +22,6 @@ import { assetDataUtils } from '@0x/order-utils';
export class DutchAuctionWrapper extends ContractWrapper {
public abi: ContractAbi = DutchAuction.compilerOutput.abi;
public address: string;
- private _exchangeAddress: string;
private _dutchAuctionContractIfExists?: DutchAuctionContract;
/**
* Instantiate DutchAuctionWrapper
@@ -31,14 +30,11 @@ 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) {
super(web3Wrapper, networkId);
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