From 7c7085c9328ce41c97469dc50232737814a7b95f Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 20 Dec 2018 14:45:06 -0800 Subject: feature(contract-wrappers): add support for Trust Wallet signature denial errors when trying to sense signature denial from a provider --- packages/contract-wrappers/src/utils/constants.ts | 3 ++- packages/contract-wrappers/src/utils/decorators.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'packages/contract-wrappers/src') diff --git a/packages/contract-wrappers/src/utils/constants.ts b/packages/contract-wrappers/src/utils/constants.ts index c587ba526..94afdc112 100644 --- a/packages/contract-wrappers/src/utils/constants.ts +++ b/packages/contract-wrappers/src/utils/constants.ts @@ -14,5 +14,6 @@ export const constants = { ZERO_AMOUNT: new BigNumber(0), ONE_AMOUNT: new BigNumber(1), ETHER_TOKEN_DECIMALS: 18, - USER_DENIED_SIGNATURE_PATTERN: 'User denied transaction signature', + METAMASK_USER_DENIED_SIGNATURE_PATTERN: 'User denied transaction signature', + TRUST_WALLET_USER_DENIED_SIGNATURE_PATTERN: 'cancelled', }; diff --git a/packages/contract-wrappers/src/utils/decorators.ts b/packages/contract-wrappers/src/utils/decorators.ts index a4207ae4c..3acfa3a88 100644 --- a/packages/contract-wrappers/src/utils/decorators.ts +++ b/packages/contract-wrappers/src/utils/decorators.ts @@ -30,7 +30,10 @@ const schemaErrorTransformer = (error: Error) => { }; const signatureRequestErrorTransformer = (error: Error) => { - if (_.includes(error.message, constants.USER_DENIED_SIGNATURE_PATTERN)) { + if ( + _.includes(error.message, constants.METAMASK_USER_DENIED_SIGNATURE_PATTERN) || + _.includes(error.message, constants.TRUST_WALLET_USER_DENIED_SIGNATURE_PATTERN) + ) { const errMsg = ContractWrappersError.SignatureRequestDenied; return new Error(errMsg); } -- cgit v1.2.3 From 0fba0b1a1bbe1192802ebcf4b88437b94d6a1c18 Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Wed, 2 Jan 2019 14:08:21 -0800 Subject: feat: Add balance and allowance checks for MultiAssetProxy --- .../asset_balance_and_proxy_allowance_fetcher.ts | 132 ++++++++++++++------- 1 file changed, 87 insertions(+), 45 deletions(-) (limited to 'packages/contract-wrappers/src') diff --git a/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts b/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts index d10cffe57..376004f52 100644 --- a/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts +++ b/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts @@ -1,8 +1,9 @@ // tslint:disable:no-unnecessary-type-assertion import { AbstractBalanceAndProxyAllowanceFetcher, assetDataUtils } from '@0x/order-utils'; -import { AssetProxyId, ERC20AssetData, ERC721AssetData } from '@0x/types'; +import { AssetProxyId, ERC20AssetData, ERC721AssetData, MultiAssetData } from '@0x/types'; import { BigNumber } from '@0x/utils'; import { BlockParamLiteral } from 'ethereum-types'; +import * as _ from 'lodash'; import { ERC20TokenWrapper } from '../contract_wrappers/erc20_token_wrapper'; import { ERC721TokenWrapper } from '../contract_wrappers/erc721_token_wrapper'; @@ -18,60 +19,101 @@ export class AssetBalanceAndProxyAllowanceFetcher implements AbstractBalanceAndP } public async getBalanceAsync(assetData: string, userAddress: string): Promise { const decodedAssetData = assetDataUtils.decodeAssetDataOrThrow(assetData); - if (decodedAssetData.assetProxyId === AssetProxyId.ERC20) { - const decodedERC20AssetData = decodedAssetData as ERC20AssetData; - const balance = await this._erc20Token.getBalanceAsync(decodedERC20AssetData.tokenAddress, userAddress, { - defaultBlock: this._stateLayer, - }); - return balance; - } else { - const decodedERC721AssetData = decodedAssetData as ERC721AssetData; - const tokenOwner = await this._erc721Token.getOwnerOfAsync( - decodedERC721AssetData.tokenAddress, - decodedERC721AssetData.tokenId, - { + let balance: BigNumber | undefined; + switch (decodedAssetData.assetProxyId) { + case AssetProxyId.ERC20: + const decodedERC20AssetData = decodedAssetData as ERC20AssetData; + balance = await this._erc20Token.getBalanceAsync(decodedERC20AssetData.tokenAddress, userAddress, { defaultBlock: this._stateLayer, - }, - ); - const balance = tokenOwner === userAddress ? new BigNumber(1) : new BigNumber(0); - return balance; + }); + break; + case AssetProxyId.ERC721: + const decodedERC721AssetData = decodedAssetData as ERC721AssetData; + const tokenOwner = await this._erc721Token.getOwnerOfAsync( + decodedERC721AssetData.tokenAddress, + decodedERC721AssetData.tokenId, + { + defaultBlock: this._stateLayer, + }, + ); + balance = tokenOwner === userAddress ? new BigNumber(1) : new BigNumber(0); + break; + case AssetProxyId.MultiAsset: + // The `balance` for MultiAssetData is the total units of the entire `assetData` that are held by the `userAddress`. + for (const [ + index, + nestedAssetDataElement, + ] of (decodedAssetData as MultiAssetData).nestedAssetData.entries()) { + const nestedAmountElement = (decodedAssetData as MultiAssetData).amounts[index]; + const nestedAssetBalance = (await this.getBalanceAsync( + nestedAssetDataElement, + userAddress, + )).dividedToIntegerBy(nestedAmountElement); + if (_.isUndefined(balance) || nestedAssetBalance.lessThan(balance)) { + balance = nestedAssetBalance; + } + } + break; + default: + throw new Error(`Proxy with id ${decodedAssetData.assetProxyId} not supported`); } + return balance as BigNumber; } public async getProxyAllowanceAsync(assetData: string, userAddress: string): Promise { const decodedAssetData = assetDataUtils.decodeAssetDataOrThrow(assetData); - if (decodedAssetData.assetProxyId === AssetProxyId.ERC20) { - const decodedERC20AssetData = decodedAssetData as ERC20AssetData; - const proxyAllowance = await this._erc20Token.getProxyAllowanceAsync( - decodedERC20AssetData.tokenAddress, - userAddress, - { - defaultBlock: this._stateLayer, - }, - ); - return proxyAllowance; - } else { - const decodedERC721AssetData = decodedAssetData as ERC721AssetData; - - const isApprovedForAll = await this._erc721Token.isProxyApprovedForAllAsync( - decodedERC721AssetData.tokenAddress, - userAddress, - { - defaultBlock: this._stateLayer, - }, - ); - if (isApprovedForAll) { - return new BigNumber(this._erc20Token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); - } else { - const isApproved = await this._erc721Token.isProxyApprovedAsync( + let proxyAllowance: BigNumber | undefined; + switch (decodedAssetData.assetProxyId) { + case AssetProxyId.ERC20: + const decodedERC20AssetData = decodedAssetData as ERC20AssetData; + proxyAllowance = await this._erc20Token.getProxyAllowanceAsync( + decodedERC20AssetData.tokenAddress, + userAddress, + { + defaultBlock: this._stateLayer, + }, + ); + break; + case AssetProxyId.ERC721: + const decodedERC721AssetData = decodedAssetData as ERC721AssetData; + const isApprovedForAll = await this._erc721Token.isProxyApprovedForAllAsync( decodedERC721AssetData.tokenAddress, - decodedERC721AssetData.tokenId, + userAddress, { defaultBlock: this._stateLayer, }, ); - const proxyAllowance = isApproved ? new BigNumber(1) : new BigNumber(0); - return proxyAllowance; - } + if (isApprovedForAll) { + return new BigNumber(this._erc20Token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); + } else { + const isApproved = await this._erc721Token.isProxyApprovedAsync( + decodedERC721AssetData.tokenAddress, + decodedERC721AssetData.tokenId, + { + defaultBlock: this._stateLayer, + }, + ); + proxyAllowance = isApproved ? new BigNumber(1) : new BigNumber(0); + } + break; + case AssetProxyId.MultiAsset: + // The `proxyAllowance` for MultiAssetData is the total units of the entire `assetData` that the proxies have been approved to spend by the `userAddress`. + for (const [ + index, + nestedAssetDataElement, + ] of (decodedAssetData as MultiAssetData).nestedAssetData.entries()) { + const nestedAmountElement = (decodedAssetData as MultiAssetData).amounts[index]; + const nestedAssetAllowance = (await this.getProxyAllowanceAsync( + nestedAssetDataElement, + userAddress, + )).dividedToIntegerBy(nestedAmountElement); + if (_.isUndefined(proxyAllowance) || nestedAssetAllowance.lessThan(proxyAllowance)) { + proxyAllowance = nestedAssetAllowance; + } + } + break; + default: + throw new Error(`Proxy with id ${decodedAssetData.assetProxyId} not supported`); } + return proxyAllowance as BigNumber; } } -- cgit v1.2.3 From 24564b986daa703f66e54f85abf4782d99a40f94 Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Fri, 4 Jan 2019 14:31:25 -0800 Subject: Minimize unnecessary type assertions --- .../asset_balance_and_proxy_allowance_fetcher.ts | 132 ++++++++------------- 1 file changed, 52 insertions(+), 80 deletions(-) (limited to 'packages/contract-wrappers/src') diff --git a/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts b/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts index 376004f52..1ff130a48 100644 --- a/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts +++ b/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts @@ -1,6 +1,4 @@ -// tslint:disable:no-unnecessary-type-assertion import { AbstractBalanceAndProxyAllowanceFetcher, assetDataUtils } from '@0x/order-utils'; -import { AssetProxyId, ERC20AssetData, ERC721AssetData, MultiAssetData } from '@0x/types'; import { BigNumber } from '@0x/utils'; import { BlockParamLiteral } from 'ethereum-types'; import * as _ from 'lodash'; @@ -20,99 +18,73 @@ export class AssetBalanceAndProxyAllowanceFetcher implements AbstractBalanceAndP public async getBalanceAsync(assetData: string, userAddress: string): Promise { const decodedAssetData = assetDataUtils.decodeAssetDataOrThrow(assetData); let balance: BigNumber | undefined; - switch (decodedAssetData.assetProxyId) { - case AssetProxyId.ERC20: - const decodedERC20AssetData = decodedAssetData as ERC20AssetData; - balance = await this._erc20Token.getBalanceAsync(decodedERC20AssetData.tokenAddress, userAddress, { + if (assetDataUtils.isERC20AssetData(decodedAssetData)) { + balance = await this._erc20Token.getBalanceAsync(decodedAssetData.tokenAddress, userAddress, { + defaultBlock: this._stateLayer, + }); + } else if (assetDataUtils.isERC721AssetData(decodedAssetData)) { + const tokenOwner = await this._erc721Token.getOwnerOfAsync( + decodedAssetData.tokenAddress, + decodedAssetData.tokenId, + { defaultBlock: this._stateLayer, - }); - break; - case AssetProxyId.ERC721: - const decodedERC721AssetData = decodedAssetData as ERC721AssetData; - const tokenOwner = await this._erc721Token.getOwnerOfAsync( - decodedERC721AssetData.tokenAddress, - decodedERC721AssetData.tokenId, - { - defaultBlock: this._stateLayer, - }, - ); - balance = tokenOwner === userAddress ? new BigNumber(1) : new BigNumber(0); - break; - case AssetProxyId.MultiAsset: - // The `balance` for MultiAssetData is the total units of the entire `assetData` that are held by the `userAddress`. - for (const [ - index, + }, + ); + balance = tokenOwner === userAddress ? new BigNumber(1) : new BigNumber(0); + } else if (assetDataUtils.isMultiAssetData(decodedAssetData)) { + // The `balance` for MultiAssetData is the total units of the entire `assetData` that are held by the `userAddress`. + for (const [index, nestedAssetDataElement] of decodedAssetData.nestedAssetData.entries()) { + const nestedAmountElement = decodedAssetData.amounts[index]; + const nestedAssetBalance = (await this.getBalanceAsync( nestedAssetDataElement, - ] of (decodedAssetData as MultiAssetData).nestedAssetData.entries()) { - const nestedAmountElement = (decodedAssetData as MultiAssetData).amounts[index]; - const nestedAssetBalance = (await this.getBalanceAsync( - nestedAssetDataElement, - userAddress, - )).dividedToIntegerBy(nestedAmountElement); - if (_.isUndefined(balance) || nestedAssetBalance.lessThan(balance)) { - balance = nestedAssetBalance; - } + userAddress, + )).dividedToIntegerBy(nestedAmountElement); + if (_.isUndefined(balance) || nestedAssetBalance.lessThan(balance)) { + balance = nestedAssetBalance; } - break; - default: - throw new Error(`Proxy with id ${decodedAssetData.assetProxyId} not supported`); + } } return balance as BigNumber; } public async getProxyAllowanceAsync(assetData: string, userAddress: string): Promise { const decodedAssetData = assetDataUtils.decodeAssetDataOrThrow(assetData); let proxyAllowance: BigNumber | undefined; - switch (decodedAssetData.assetProxyId) { - case AssetProxyId.ERC20: - const decodedERC20AssetData = decodedAssetData as ERC20AssetData; - proxyAllowance = await this._erc20Token.getProxyAllowanceAsync( - decodedERC20AssetData.tokenAddress, - userAddress, - { - defaultBlock: this._stateLayer, - }, - ); - break; - case AssetProxyId.ERC721: - const decodedERC721AssetData = decodedAssetData as ERC721AssetData; - const isApprovedForAll = await this._erc721Token.isProxyApprovedForAllAsync( - decodedERC721AssetData.tokenAddress, - userAddress, + if (assetDataUtils.isERC20AssetData(decodedAssetData)) { + proxyAllowance = await this._erc20Token.getProxyAllowanceAsync(decodedAssetData.tokenAddress, userAddress, { + defaultBlock: this._stateLayer, + }); + } else if (assetDataUtils.isERC721AssetData(decodedAssetData)) { + const isApprovedForAll = await this._erc721Token.isProxyApprovedForAllAsync( + decodedAssetData.tokenAddress, + userAddress, + { + defaultBlock: this._stateLayer, + }, + ); + if (isApprovedForAll) { + return new BigNumber(this._erc20Token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); + } else { + const isApproved = await this._erc721Token.isProxyApprovedAsync( + decodedAssetData.tokenAddress, + decodedAssetData.tokenId, { defaultBlock: this._stateLayer, }, ); - if (isApprovedForAll) { - return new BigNumber(this._erc20Token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); - } else { - const isApproved = await this._erc721Token.isProxyApprovedAsync( - decodedERC721AssetData.tokenAddress, - decodedERC721AssetData.tokenId, - { - defaultBlock: this._stateLayer, - }, - ); - proxyAllowance = isApproved ? new BigNumber(1) : new BigNumber(0); - } - break; - case AssetProxyId.MultiAsset: - // The `proxyAllowance` for MultiAssetData is the total units of the entire `assetData` that the proxies have been approved to spend by the `userAddress`. - for (const [ - index, + proxyAllowance = isApproved ? new BigNumber(1) : new BigNumber(0); + } + } else if (assetDataUtils.isMultiAssetData(decodedAssetData)) { + // The `proxyAllowance` for MultiAssetData is the total units of the entire `assetData` that the proxies have been approved to spend by the `userAddress`. + for (const [index, nestedAssetDataElement] of decodedAssetData.nestedAssetData.entries()) { + const nestedAmountElement = decodedAssetData.amounts[index]; + const nestedAssetAllowance = (await this.getProxyAllowanceAsync( nestedAssetDataElement, - ] of (decodedAssetData as MultiAssetData).nestedAssetData.entries()) { - const nestedAmountElement = (decodedAssetData as MultiAssetData).amounts[index]; - const nestedAssetAllowance = (await this.getProxyAllowanceAsync( - nestedAssetDataElement, - userAddress, - )).dividedToIntegerBy(nestedAmountElement); - if (_.isUndefined(proxyAllowance) || nestedAssetAllowance.lessThan(proxyAllowance)) { - proxyAllowance = nestedAssetAllowance; - } + userAddress, + )).dividedToIntegerBy(nestedAmountElement); + if (_.isUndefined(proxyAllowance) || nestedAssetAllowance.lessThan(proxyAllowance)) { + proxyAllowance = nestedAssetAllowance; } - break; - default: - throw new Error(`Proxy with id ${decodedAssetData.assetProxyId} not supported`); + } } return proxyAllowance as BigNumber; } -- cgit v1.2.3 From 43b648e7dc1ea49aff3ab1e6883aa6e069fae72f Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Thu, 20 Dec 2018 15:39:19 -0800 Subject: Dutch wrapper --- .../contract-wrappers/src/contract_wrappers.ts | 10 ++ .../src/contract_wrappers/dutch_auction_wrapper.ts | 151 +++++++++++++++++++++ packages/contract-wrappers/src/index.ts | 1 + 3 files changed, 162 insertions(+) create mode 100644 packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts (limited to 'packages/contract-wrappers/src') diff --git a/packages/contract-wrappers/src/contract_wrappers.ts b/packages/contract-wrappers/src/contract_wrappers.ts index 0c535bd5c..396505866 100644 --- a/packages/contract-wrappers/src/contract_wrappers.ts +++ b/packages/contract-wrappers/src/contract_wrappers.ts @@ -20,6 +20,7 @@ import { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper'; import { ExchangeWrapper } from './contract_wrappers/exchange_wrapper'; import { ForwarderWrapper } from './contract_wrappers/forwarder_wrapper'; import { OrderValidatorWrapper } from './contract_wrappers/order_validator_wrapper'; +import { DutchAuctionWrapper } from './contract_wrappers/dutch_auction_wrapper'; import { ContractWrappersConfigSchema } from './schemas/contract_wrappers_config_schema'; import { ContractWrappersConfig } from './types'; import { assert } from './utils/assert'; @@ -65,6 +66,10 @@ export class ContractWrappers { * An instance of the OrderValidatorWrapper class containing methods for interacting with any OrderValidator smart contract. */ public orderValidator: OrderValidatorWrapper; + /** + * An instance of the DutchAuctionWrapper class containing methods for interacting with any DutchAuction smart contract. + */ + public dutchAuction: DutchAuctionWrapper; private readonly _web3Wrapper: Web3Wrapper; /** @@ -141,6 +146,11 @@ export class ContractWrappers { config.networkId, contractAddresses.orderValidator, ); + this.dutchAuction = new DutchAuctionWrapper( + this._web3Wrapper, + config.networkId, + contractAddresses.orderValidator, + ); } /** * Unsubscribes from all subscriptions for all contracts. diff --git a/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts new file mode 100644 index 000000000..500e7a63d --- /dev/null +++ b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts @@ -0,0 +1,151 @@ +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 } from '@0x/utils'; +import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; +import * as _ from 'lodash'; +import ethAbi = require('ethereumjs-abi'); +import { schemas } from '@0x/json-schemas'; +import { assert } from '../utils/assert'; +import ethUtil = require('ethereumjs-util'); + +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'; + +export class DutchAuctionWrapper extends ContractWrapper { + public abi: ContractAbi = DutchAuction.compilerOutput.abi; + public address: string; + private _dutchAuctionContractIfExists?: DutchAuctionContract; + /** + * Instantiate DutchAuctionWrapper + * @param web3Wrapper Web3Wrapper instance to use. + * @param networkId Desired networkId. + * @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, + ) { + super(web3Wrapper, networkId); + this.address = address; + } + /** + * Matches the buy and sell orders at an amount given the following: the current block time, the auction + * start time and the auction begin amount. The sell order is a an order at the lowest amount + * at the end of the auction. Excess from the match is transferred to the seller. + * Over time the price moves from beginAmount to endAmount given the current block.timestamp. + * @param buyOrder The Buyer's order. This order is for the current expected price of the auction. + * @param sellOrder The Seller's order. This order is for the lowest amount (at the end of the auction). + * @param from Address the transaction is being sent from. + * @return Transaction receipt with decoded logs. + */ + public async matchOrdersAsync( + buyOrder: SignedOrder, + sellOrder: SignedOrder, + takerAddress: string, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, + ): Promise { + // type assertions + assert.doesConformToSchema('buyOrder', buyOrder, schemas.signedOrderSchema); + assert.doesConformToSchema('sellOrder', sellOrder, schemas.signedOrderSchema); + await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); + assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]); + const normalizedTakerAddress = takerAddress.toLowerCase(); + // other assertions + if ( + sellOrder.makerAssetData !== buyOrder.takerAssetData || + sellOrder.takerAssetData !== buyOrder.makerAssetData + ) { + throw new Error(ExchangeWrapperError.AssetDataMismatch); + } + // get contract + const dutchAuctionInstance = await this._getDutchAuctionContractAsync(); + // validate transaction + if (orderTransactionOpts.shouldValidate) { + await dutchAuctionInstance.matchOrders.callAsync( + buyOrder, + sellOrder, + buyOrder.signature, + sellOrder.signature, + { + from: normalizedTakerAddress, + gas: orderTransactionOpts.gasLimit, + gasPrice: orderTransactionOpts.gasPrice, + nonce: orderTransactionOpts.nonce, + }, + ); + } + // send transaction + const txHash = await dutchAuctionInstance.matchOrders.sendTransactionAsync( + buyOrder, + sellOrder, + buyOrder.signature, + sellOrder.signature, + { + from: normalizedTakerAddress, + gas: orderTransactionOpts.gasLimit, + gasPrice: orderTransactionOpts.gasPrice, + nonce: orderTransactionOpts.nonce, + }, + ); + return txHash; + } + /** + * Calculates the Auction Details for the given order + * @param sellOrder The Seller's order. This order is for the lowest amount (at the end of the auction). + * @return The dutch auction details. + */ + public async getAuctionDetailsAsync(sellOrder: SignedOrder): Promise { + // type assertions + assert.doesConformToSchema('sellOrder', sellOrder, schemas.signedOrderSchema); + // get contract + const dutchAuctionInstance = await this._getDutchAuctionContractAsync(); + // call contract + const afterAuctionDetails = await dutchAuctionInstance.getAuctionDetails.callAsync(sellOrder); + return afterAuctionDetails; + } + private async _getDutchAuctionContractAsync(): Promise { + if (!_.isUndefined(this._dutchAuctionContractIfExists)) { + return this._dutchAuctionContractIfExists; + } + const contractInstance = new DutchAuctionContract( + this.abi, + this.address, + this._web3Wrapper.getProvider(), + this._web3Wrapper.getContractDefaults(), + ); + this._dutchAuctionContractIfExists = contractInstance; + return this._dutchAuctionContractIfExists; + } + /** + * 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 { + const assetDataBuffer = ethUtil.toBuffer(assetData); + const abiEncodedAuctionData = (ethAbi as any).rawEncode( + ['uint256', 'uint256'], + [beginTimeSeconds.toString(), beginAmount.toString()], + ); + const abiEncodedAuctionDataBuffer = ethUtil.toBuffer(abiEncodedAuctionData); + const dutchAuctionDataBuffer = Buffer.concat([assetDataBuffer, abiEncodedAuctionDataBuffer]); + const dutchAuctionData = ethUtil.bufferToHex(dutchAuctionDataBuffer); + return dutchAuctionData; + }; +} diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts index d66ff5c9c..5c64dbbc6 100644 --- a/packages/contract-wrappers/src/index.ts +++ b/packages/contract-wrappers/src/index.ts @@ -34,6 +34,7 @@ export { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper'; export { ERC721ProxyWrapper } from './contract_wrappers/erc721_proxy_wrapper'; export { ForwarderWrapper } from './contract_wrappers/forwarder_wrapper'; export { OrderValidatorWrapper } from './contract_wrappers/order_validator_wrapper'; +export { DutchAuctionWrapper } from './contract_wrappers/dutch_auction_wrapper'; export { TransactionEncoder } from './utils/transaction_encoder'; -- cgit v1.2.3 From 5da748a062043b46133a2dbce248a756bbefce12 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Thu, 20 Dec 2018 19:40:16 -0800 Subject: Progress on dutch auction wrapper. Need to add auction data decoding to it. --- .../contract-wrappers/src/contract_wrappers.ts | 2 +- .../src/contract_wrappers/dutch_auction_wrapper.ts | 74 +++++++++++++++++++++- 2 files changed, 73 insertions(+), 3 deletions(-) (limited to 'packages/contract-wrappers/src') diff --git a/packages/contract-wrappers/src/contract_wrappers.ts b/packages/contract-wrappers/src/contract_wrappers.ts index 396505866..3728d58d3 100644 --- a/packages/contract-wrappers/src/contract_wrappers.ts +++ b/packages/contract-wrappers/src/contract_wrappers.ts @@ -149,7 +149,7 @@ export class ContractWrappers { this.dutchAuction = new DutchAuctionWrapper( this._web3Wrapper, config.networkId, - contractAddresses.orderValidator, + contractAddresses.dutchAuction, ); } /** 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 500e7a63d..fee543c3b 100644 --- a/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts @@ -21,9 +21,13 @@ import { OrderTransactionOpts } from '../types'; import { ContractWrapper } from './contract_wrapper'; import { ExchangeWrapperError } from '../types'; +import { orderFactory } from '@0x/order-utils/lib/src/order_factory'; +import { constants } from 'zlib'; + export class DutchAuctionWrapper extends ContractWrapper { public abi: ContractAbi = DutchAuction.compilerOutput.abi; public address: string; + private _exchangeAddress: string; private _dutchAuctionContractIfExists?: DutchAuctionContract; /** * Instantiate DutchAuctionWrapper @@ -35,10 +39,12 @@ export class DutchAuctionWrapper extends ContractWrapper { constructor( web3Wrapper: Web3Wrapper, networkId: number, - address: string, + address?: string, + exchangeAddress?: string, ) { super(web3Wrapper, networkId); - this.address = address; + 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 @@ -110,6 +116,8 @@ 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); @@ -128,6 +136,66 @@ export class DutchAuctionWrapper extends ContractWrapper { this._dutchAuctionContractIfExists = contractInstance; return this._dutchAuctionContractIfExists; } + + public async createSignedSellOrderAsync( + auctionBeginTimeSections: BigNumber, + auctionBeginAmount: BigNumber, + auctionEndAmount: BigNumber, + acutionEndTime: BigNumber, + makerAssetData: string, + takerAssetData: string, + makerAddress: string, + takerAddress: string, + takerFillableAmount: BigNumber, + senderAddress?: string, + makerFee?: BigNumber, + takerFee?: BigNumber, + feeRecipientAddress?: string, + ): Promise { + console.log(`asdasd`); + const makerAssetAmount = auctionEndAmount; + const makerAssetDataWithAuctionDetails = DutchAuctionWrapper.encodeDutchAuctionAssetData(makerAssetData, auctionBeginTimeSections, auctionBeginAmount); + const signedOrder = await orderFactory.createSignedOrderAsync( + this._web3Wrapper.getProvider(), + makerAddress, + makerAssetAmount, + makerAssetDataWithAuctionDetails, + takerFillableAmount, + takerAssetData, + this._exchangeAddress, + { + takerAddress, + senderAddress, + makerFee, + takerFee, + feeRecipientAddress, + expirationTimeSeconds: acutionEndTime, + }, + ); + //console.log(signedOrder); + return signedOrder; + } + + public async createSignedBuyOrderAsync(sellOrder: SignedOrder, buyerAddress: string, senderAddress?: string, makerFee?: BigNumber, takerFee?: BigNumber, feeRecipientAddress?: string): Promise { + const signedOrder = await orderFactory.createSignedOrderAsync( + this._web3Wrapper.getProvider(), + buyerAddress, + sellOrder.takerAssetAmount.times(2), // change this to decode value from auction @TODO -- add decode above for this. + sellOrder.takerAssetData, + sellOrder.makerAssetAmount, + sellOrder.makerAssetData, + sellOrder.exchangeAddress, + { + senderAddress, + makerFee, + takerFee, + feeRecipientAddress, + expirationTimeSeconds: sellOrder.expirationTimeSeconds, + }, + ); + // console.log(signedOrder); + return signedOrder; + } /** * 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 @@ -138,6 +206,7 @@ export class DutchAuctionWrapper extends ContractWrapper { * @return The hex encoded assetData string. */ public static encodeDutchAuctionAssetData(assetData: string, beginTimeSeconds: BigNumber, beginAmount: BigNumber): string { + // console.log(`yoooo`, assetData); const assetDataBuffer = ethUtil.toBuffer(assetData); const abiEncodedAuctionData = (ethAbi as any).rawEncode( ['uint256', 'uint256'], @@ -145,6 +214,7 @@ 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; }; -- cgit v1.2.3 From 7203ca90cf9bff2f7accf5fe2ee7da5764d0dac3 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Fri, 21 Dec 2018 16:11:59 -0800 Subject: all dutchie wrapper tests passing --- .../src/contract_wrappers/dutch_auction_wrapper.ts | 94 +++++++--------------- 1 file changed, 30 insertions(+), 64 deletions(-) (limited to 'packages/contract-wrappers/src') 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 fee543c3b..5896617fc 100644 --- a/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts @@ -7,7 +7,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 } from '@0x/utils'; +import { BigNumber, abiUtils } from '@0x/utils'; import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; import ethAbi = require('ethereumjs-abi'); @@ -21,8 +21,7 @@ import { OrderTransactionOpts } from '../types'; import { ContractWrapper } from './contract_wrapper'; import { ExchangeWrapperError } from '../types'; -import { orderFactory } from '@0x/order-utils/lib/src/order_factory'; -import { constants } from 'zlib'; +import { assetDataUtils, AssetData } from '@0x/order-utils'; export class DutchAuctionWrapper extends ContractWrapper { public abi: ContractAbi = DutchAuction.compilerOutput.abi; @@ -74,6 +73,10 @@ export class DutchAuctionWrapper extends ContractWrapper { 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'; } // get contract const dutchAuctionInstance = await this._getDutchAuctionContractAsync(); @@ -136,66 +139,6 @@ export class DutchAuctionWrapper extends ContractWrapper { this._dutchAuctionContractIfExists = contractInstance; return this._dutchAuctionContractIfExists; } - - public async createSignedSellOrderAsync( - auctionBeginTimeSections: BigNumber, - auctionBeginAmount: BigNumber, - auctionEndAmount: BigNumber, - acutionEndTime: BigNumber, - makerAssetData: string, - takerAssetData: string, - makerAddress: string, - takerAddress: string, - takerFillableAmount: BigNumber, - senderAddress?: string, - makerFee?: BigNumber, - takerFee?: BigNumber, - feeRecipientAddress?: string, - ): Promise { - console.log(`asdasd`); - const makerAssetAmount = auctionEndAmount; - const makerAssetDataWithAuctionDetails = DutchAuctionWrapper.encodeDutchAuctionAssetData(makerAssetData, auctionBeginTimeSections, auctionBeginAmount); - const signedOrder = await orderFactory.createSignedOrderAsync( - this._web3Wrapper.getProvider(), - makerAddress, - makerAssetAmount, - makerAssetDataWithAuctionDetails, - takerFillableAmount, - takerAssetData, - this._exchangeAddress, - { - takerAddress, - senderAddress, - makerFee, - takerFee, - feeRecipientAddress, - expirationTimeSeconds: acutionEndTime, - }, - ); - //console.log(signedOrder); - return signedOrder; - } - - public async createSignedBuyOrderAsync(sellOrder: SignedOrder, buyerAddress: string, senderAddress?: string, makerFee?: BigNumber, takerFee?: BigNumber, feeRecipientAddress?: string): Promise { - const signedOrder = await orderFactory.createSignedOrderAsync( - this._web3Wrapper.getProvider(), - buyerAddress, - sellOrder.takerAssetAmount.times(2), // change this to decode value from auction @TODO -- add decode above for this. - sellOrder.takerAssetData, - sellOrder.makerAssetAmount, - sellOrder.makerAssetData, - sellOrder.exchangeAddress, - { - senderAddress, - makerFee, - takerFee, - feeRecipientAddress, - expirationTimeSeconds: sellOrder.expirationTimeSeconds, - }, - ); - // console.log(signedOrder); - return signedOrder; - } /** * 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 @@ -206,7 +149,6 @@ export class DutchAuctionWrapper extends ContractWrapper { * @return The hex encoded assetData string. */ public static encodeDutchAuctionAssetData(assetData: string, beginTimeSeconds: BigNumber, beginAmount: BigNumber): string { - // console.log(`yoooo`, assetData); const assetDataBuffer = ethUtil.toBuffer(assetData); const abiEncodedAuctionData = (ethAbi as any).rawEncode( ['uint256', 'uint256'], @@ -218,4 +160,28 @@ export class DutchAuctionWrapper extends ContractWrapper { 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 + * 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 + */ + public static decodeDutchAuctionData(dutchAuctionData: string): [AssetData, BigNumber, BigNumber] { + const dutchAuctionDataBuffer = ethUtil.toBuffer(dutchAuctionData); + // Decode asset data + const assetDataBuffer = dutchAuctionDataBuffer.slice(0, dutchAuctionDataBuffer.byteLength - 64); + const assetDataHex = ethUtil.bufferToHex(assetDataBuffer); + const assetData = assetDataUtils.decodeAssetDataOrThrow(assetDataHex); + // Decode auction details + const dutchAuctionDetailsBuffer = dutchAuctionDataBuffer.slice(dutchAuctionDataBuffer.byteLength - 64); + const [beginTimeSecondsAsBN, beginAmountAsBN] = ethAbi.rawDecode( + ['uint256', 'uint256'], + dutchAuctionDetailsBuffer + ); + const beginTimeSeconds = new BigNumber(`0x${beginTimeSecondsAsBN.toString()}`); + const beginAmount = new BigNumber(`0x${beginAmountAsBN.toString()}`); + console.log(beginAmount); + return [assetData, beginTimeSeconds, beginAmount]; + }; } -- cgit v1.2.3 From 0432212a346aa761c54b5a9159a7e61e0c2f9b9a Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Fri, 21 Dec 2018 16:40:07 -0800 Subject: dutch wrapper tests working --- .../src/contract_wrappers/dutch_auction_wrapper.ts | 24 +++++++++------------- packages/contract-wrappers/src/types.ts | 12 +++++++++++ 2 files changed, 22 insertions(+), 14 deletions(-) (limited to 'packages/contract-wrappers/src') 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; +} -- cgit v1.2.3 From b249a50d8f0054328a901525af6316133ed64023 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Fri, 21 Dec 2018 16:40:11 -0800 Subject: ran prettier --- .../src/contract_wrappers/dutch_auction_wrapper.ts | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'packages/contract-wrappers/src') 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, }; - }; + } } -- cgit v1.2.3 From cb1bfa0f9790706bf9ce08aad0bf8fd9e2621ce9 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Fri, 21 Dec 2018 17:04:17 -0800 Subject: ran prettier + added changelog entry for contract wrappers --- .../src/contract_wrappers/dutch_auction_wrapper.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'packages/contract-wrappers/src') 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 -- cgit v1.2.3 From d6467d707fdc1797eba4a445e805ccadc1f47872 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Fri, 21 Dec 2018 22:23:21 -0800 Subject: Removed redundant assignment --- .../contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/contract-wrappers/src') 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 bb1e89555..f243d55d9 100644 --- a/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts @@ -32,7 +32,7 @@ export class DutchAuctionWrapper extends ContractWrapper { */ constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string) { super(web3Wrapper, networkId); - this.address = this.address = _.isUndefined(address) + this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).dutchAuction : address; } -- cgit v1.2.3 From c6ab380685098dbf3a0a6ee5fae137e816839c2d Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Sat, 22 Dec 2018 12:56:52 -0800 Subject: Ran prettier & linter --- .../contract-wrappers/src/contract_wrappers.ts | 2 +- .../src/contract_wrappers/dutch_auction_wrapper.ts | 135 +++++++++++---------- 2 files changed, 70 insertions(+), 67 deletions(-) (limited to 'packages/contract-wrappers/src') diff --git a/packages/contract-wrappers/src/contract_wrappers.ts b/packages/contract-wrappers/src/contract_wrappers.ts index 3728d58d3..4e594593e 100644 --- a/packages/contract-wrappers/src/contract_wrappers.ts +++ b/packages/contract-wrappers/src/contract_wrappers.ts @@ -12,6 +12,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import { Provider } from 'ethereum-types'; import * as _ from 'lodash'; +import { DutchAuctionWrapper } from './contract_wrappers/dutch_auction_wrapper'; import { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper'; import { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper'; import { ERC721ProxyWrapper } from './contract_wrappers/erc721_proxy_wrapper'; @@ -20,7 +21,6 @@ import { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper'; import { ExchangeWrapper } from './contract_wrappers/exchange_wrapper'; import { ForwarderWrapper } from './contract_wrappers/forwarder_wrapper'; import { OrderValidatorWrapper } from './contract_wrappers/order_validator_wrapper'; -import { DutchAuctionWrapper } from './contract_wrappers/dutch_auction_wrapper'; import { ContractWrappersConfigSchema } from './schemas/contract_wrappers_config_schema'; import { ContractWrappersConfig } from './types'; import { assert } from './utils/assert'; 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 f243d55d9..cb0c10187 100644 --- a/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts @@ -1,28 +1,84 @@ import { DutchAuctionContract } from '@0x/abi-gen-wrappers'; import { DutchAuction } from '@0x/contract-artifacts'; -import { _getDefaultContractAddresses } from '../utils/contract_addresses'; +import { schemas } from '@0x/json-schemas'; +import { assetDataUtils } from '@0x/order-utils'; import { DutchAuctionDetails, SignedOrder } from '@0x/types'; -import { ContractAbi } from 'ethereum-types'; -import { Web3Wrapper } from '@0x/web3-wrapper'; import { BigNumber } from '@0x/utils'; +import { Web3Wrapper } from '@0x/web3-wrapper'; +import { ContractAbi } from 'ethereum-types'; +import * as ethAbi from 'ethereumjs-abi'; +import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; -import ethAbi = require('ethereumjs-abi'); -import { schemas } from '@0x/json-schemas'; -import { assert } from '../utils/assert'; -import ethUtil = require('ethereumjs-util'); 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 { DutchAuctionWrapperError, DutchAuctionData } from '../types'; +import { DutchAuctionData, DutchAuctionWrapperError, OrderTransactionOpts } from '../types'; +import { assert } from '../utils/assert'; +import { _getDefaultContractAddresses } from '../utils/contract_addresses'; -import { assetDataUtils } from '@0x/order-utils'; +import { ContractWrapper } from './contract_wrapper'; export class DutchAuctionWrapper extends ContractWrapper { public abi: ContractAbi = DutchAuction.compilerOutput.abi; public address: string; private _dutchAuctionContractIfExists?: DutchAuctionContract; + /** + * 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 { + const assetDataBuffer = ethUtil.toBuffer(assetData); + const abiEncodedAuctionData = (ethAbi as any).rawEncode( + ['uint256', 'uint256'], + [beginTimeSeconds.toString(), beginAmount.toString()], + ); + const abiEncodedAuctionDataBuffer = ethUtil.toBuffer(abiEncodedAuctionData); + 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 + * 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 An object containing the auction asset, auction begin time and auction begin amount. + */ + public static decodeDutchAuctionData(dutchAuctionData: string): DutchAuctionData { + const dutchAuctionDataBuffer = ethUtil.toBuffer(dutchAuctionData); + // Decode asset data + const dutchAuctionDataLengthInBytes = 64; + const assetDataBuffer = dutchAuctionDataBuffer.slice( + 0, + dutchAuctionDataBuffer.byteLength - dutchAuctionDataLengthInBytes, + ); + const assetDataHex = ethUtil.bufferToHex(assetDataBuffer); + const assetData = assetDataUtils.decodeAssetDataOrThrow(assetDataHex); + // Decode auction details + const dutchAuctionDetailsBuffer = dutchAuctionDataBuffer.slice( + dutchAuctionDataBuffer.byteLength - dutchAuctionDataLengthInBytes, + ); + const [beginTimeSecondsAsBN, beginAmountAsBN] = ethAbi.rawDecode( + ['uint256', 'uint256'], + dutchAuctionDetailsBuffer, + ); + const beginTimeSeconds = new BigNumber(`0x${beginTimeSecondsAsBN.toString()}`); + const beginAmount = new BigNumber(`0x${beginAmountAsBN.toString()}`); + return { + assetData, + beginTimeSeconds, + beginAmount, + }; + } /** * Instantiate DutchAuctionWrapper * @param web3Wrapper Web3Wrapper instance to use. @@ -30,11 +86,9 @@ 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) { + public constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string) { super(web3Wrapper, networkId); - this.address = _.isUndefined(address) - ? _getDefaultContractAddresses(networkId).dutchAuction - : address; + this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).dutchAuction : address; } /** * Matches the buy and sell orders at an amount given the following: the current block time, the auction @@ -124,55 +178,4 @@ export class DutchAuctionWrapper extends ContractWrapper { this._dutchAuctionContractIfExists = contractInstance; return this._dutchAuctionContractIfExists; } - /** - * 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 { - const assetDataBuffer = ethUtil.toBuffer(assetData); - const abiEncodedAuctionData = (ethAbi as any).rawEncode( - ['uint256', 'uint256'], - [beginTimeSeconds.toString(), beginAmount.toString()], - ); - const abiEncodedAuctionDataBuffer = ethUtil.toBuffer(abiEncodedAuctionData); - 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 - * 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 An object containing the auction asset, auction begin time and auction begin amount. - */ - public static decodeDutchAuctionData(dutchAuctionData: string): DutchAuctionData { - const dutchAuctionDataBuffer = ethUtil.toBuffer(dutchAuctionData); - // Decode asset data - const assetDataBuffer = dutchAuctionDataBuffer.slice(0, dutchAuctionDataBuffer.byteLength - 64); - const assetDataHex = ethUtil.bufferToHex(assetDataBuffer); - const assetData = assetDataUtils.decodeAssetDataOrThrow(assetDataHex); - // Decode auction details - const dutchAuctionDetailsBuffer = dutchAuctionDataBuffer.slice(dutchAuctionDataBuffer.byteLength - 64); - const [beginTimeSecondsAsBN, beginAmountAsBN] = ethAbi.rawDecode( - ['uint256', 'uint256'], - dutchAuctionDetailsBuffer, - ); - const beginTimeSeconds = new BigNumber(`0x${beginTimeSecondsAsBN.toString()}`); - const beginAmount = new BigNumber(`0x${beginAmountAsBN.toString()}`); - return { - assetData, - beginTimeSeconds, - beginAmount, - }; - } } -- cgit v1.2.3 From 61a33688264d31be063cd11260d9f37f3774975b Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Sat, 22 Dec 2018 13:11:14 -0800 Subject: `afterAuctionDetails` -> `auctionDetails` --- .../contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/contract-wrappers/src') 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 cb0c10187..f9eb3c771 100644 --- a/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts @@ -162,8 +162,8 @@ export class DutchAuctionWrapper extends ContractWrapper { // get contract const dutchAuctionInstance = await this._getDutchAuctionContractAsync(); // call contract - const afterAuctionDetails = await dutchAuctionInstance.getAuctionDetails.callAsync(sellOrder); - return afterAuctionDetails; + const auctionDetails = await dutchAuctionInstance.getAuctionDetails.callAsync(sellOrder); + return auctionDetails; } private async _getDutchAuctionContractAsync(): Promise { if (!_.isUndefined(this._dutchAuctionContractIfExists)) { -- cgit v1.2.3 From 77a2ca1ddc9a7dd444822ca3cb38b3679dbd4085 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Sat, 22 Dec 2018 13:54:57 -0800 Subject: Minor documentation updates to dutch auction wrapper --- .../src/contract_wrappers/dutch_auction_wrapper.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'packages/contract-wrappers/src') 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 f9eb3c771..c1aceff47 100644 --- a/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/dutch_auction_wrapper.ts @@ -47,9 +47,9 @@ export class DutchAuctionWrapper extends ContractWrapper { 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 decodes 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. + * dutch auction. * @param dutchAuctionData Hex encoded assetData string for the asset being auctioned. * @return An object containing the auction asset, auction begin time and auction begin amount. */ @@ -95,10 +95,11 @@ export class DutchAuctionWrapper extends ContractWrapper { * start time and the auction begin amount. The sell order is a an order at the lowest amount * at the end of the auction. Excess from the match is transferred to the seller. * Over time the price moves from beginAmount to endAmount given the current block.timestamp. - * @param buyOrder The Buyer's order. This order is for the current expected price of the auction. - * @param sellOrder The Seller's order. This order is for the lowest amount (at the end of the auction). - * @param from Address the transaction is being sent from. - * @return Transaction receipt with decoded logs. + * @param buyOrder The Buyer's order. This order is for the current expected price of the auction. + * @param sellOrder The Seller's order. This order is for the lowest amount (at the end of the auction). + * @param takerAddress The user Ethereum address who would like to fill this order. Must be available via the supplied + * Provider provided at instantiation. + * @return Transaction hash. */ public async matchOrdersAsync( buyOrder: SignedOrder, @@ -152,7 +153,7 @@ export class DutchAuctionWrapper extends ContractWrapper { return txHash; } /** - * Calculates the Auction Details for the given order + * Fetches the Auction Details for the given order * @param sellOrder The Seller's order. This order is for the lowest amount (at the end of the auction). * @return The dutch auction details. */ -- cgit v1.2.3 From edb989fbf381201752309a1e2aa5dcf6837b67d0 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Sun, 23 Dec 2018 16:04:09 -0800 Subject: export dutch auction wrapper types from 0x.js --- packages/contract-wrappers/src/index.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages/contract-wrappers/src') diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts index 5c64dbbc6..cf0ec405f 100644 --- a/packages/contract-wrappers/src/index.ts +++ b/packages/contract-wrappers/src/index.ts @@ -55,6 +55,7 @@ export { OrderAndTraderInfo, TraderInfo, ValidateOrderFillableOpts, + DutchAuctionData, } from './types'; export { Order, SignedOrder, AssetProxyId } from '@0x/types'; -- cgit v1.2.3 From d0a0673694f26a2e9f8e562d335a34cdc1e9c8b2 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Sun, 23 Dec 2018 17:14:34 -0800 Subject: Doc generation working for changes by dutch auction wrapper --- packages/contract-wrappers/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/contract-wrappers/src') diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts index cf0ec405f..bf9c27018 100644 --- a/packages/contract-wrappers/src/index.ts +++ b/packages/contract-wrappers/src/index.ts @@ -58,7 +58,7 @@ export { DutchAuctionData, } from './types'; -export { Order, SignedOrder, AssetProxyId } from '@0x/types'; +export { AssetData, DutchAuctionDetails, ERC20AssetData, ERC721AssetData, Order, SignedOrder, AssetProxyId } from '@0x/types'; export { BlockParamLiteral, -- cgit v1.2.3 From e39ae0350b744227bca73001c90101f0b8613193 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Sun, 23 Dec 2018 17:29:12 -0800 Subject: Ran prettier --- packages/contract-wrappers/src/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'packages/contract-wrappers/src') diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts index bf9c27018..853194d6f 100644 --- a/packages/contract-wrappers/src/index.ts +++ b/packages/contract-wrappers/src/index.ts @@ -58,7 +58,15 @@ export { DutchAuctionData, } from './types'; -export { AssetData, DutchAuctionDetails, ERC20AssetData, ERC721AssetData, Order, SignedOrder, AssetProxyId } from '@0x/types'; +export { + AssetData, + DutchAuctionDetails, + ERC20AssetData, + ERC721AssetData, + Order, + SignedOrder, + AssetProxyId, +} from '@0x/types'; export { BlockParamLiteral, -- cgit v1.2.3 From 04db7f0fae02ef29795d0f65deb71e64b5552233 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Mon, 7 Jan 2019 13:08:44 -0800 Subject: Fixed merge conflict from development --- packages/contract-wrappers/src/index.ts | 5 ++++- packages/contract-wrappers/src/types.ts | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'packages/contract-wrappers/src') diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts index 853194d6f..69bbe3c91 100644 --- a/packages/contract-wrappers/src/index.ts +++ b/packages/contract-wrappers/src/index.ts @@ -60,9 +60,12 @@ export { export { AssetData, - DutchAuctionDetails, ERC20AssetData, ERC721AssetData, + SingleAssetData, + MultiAssetData, + MultiAssetDataWithRecursiveDecoding, + DutchAuctionDetails, Order, SignedOrder, AssetProxyId, diff --git a/packages/contract-wrappers/src/types.ts b/packages/contract-wrappers/src/types.ts index f23587c20..945ca88cd 100644 --- a/packages/contract-wrappers/src/types.ts +++ b/packages/contract-wrappers/src/types.ts @@ -9,13 +9,11 @@ import { WETH9Events, } from '@0x/abi-gen-wrappers'; import { ContractAddresses } from '@0x/contract-addresses'; -import { OrderState, SignedOrder } from '@0x/types'; +import { AssetData, OrderState, SignedOrder } from '@0x/types'; 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', } -- cgit v1.2.3