diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-10-05 06:51:04 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-10-16 04:36:59 +0800 |
commit | 3da032fb24a7b3d27fd388ce4fbc6bd194971201 (patch) | |
tree | f7fa75f6b63d53d94cf4b69f2f3b3fa958d68cdd /packages | |
parent | d0b37fcab563b854fcec59818b83a80c659d090c (diff) | |
download | dexon-0x-contracts-3da032fb24a7b3d27fd388ce4fbc6bd194971201.tar.gz dexon-0x-contracts-3da032fb24a7b3d27fd388ce4fbc6bd194971201.tar.zst dexon-0x-contracts-3da032fb24a7b3d27fd388ce4fbc6bd194971201.zip |
update asset-buyer to use new artifacts and abi-gen wrappers packages
Diffstat (limited to 'packages')
-rw-r--r-- | packages/asset-buyer/package.json | 8 | ||||
-rw-r--r-- | packages/asset-buyer/src/asset_buyer.ts | 15 | ||||
-rw-r--r-- | packages/asset-buyer/src/utils/asset_data_utils.ts | 20 |
3 files changed, 19 insertions, 24 deletions
diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json index 291342169..1aeb048e4 100644 --- a/packages/asset-buyer/package.json +++ b/packages/asset-buyer/package.json @@ -8,7 +8,8 @@ "main": "lib/src/index.js", "types": "lib/src/index.d.ts", "scripts": { - "watch_without_deps": "tsc -w", + "build": "yarn tsc -b", + "build:ci": "yarn build", "lint": "tslint --project .", "test": "yarn run_mocha", "rebuild_and_test": "run-s clean build test", @@ -16,10 +17,7 @@ "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", "test:circleci": "yarn test:coverage", "run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit", - "clean": "shx rm -rf lib test_temp scripts", - "build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", - "build:ci": "yarn build", - "manual:postpublish": "yarn build; node ./scripts/postpublish.js" + "clean": "shx rm -rf lib test_temp" }, "config": { "postpublish": { diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 50343efde..5863ce5d5 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -109,6 +109,17 @@ export class AssetBuyer { this.expiryBufferSeconds = expiryBufferSeconds; this._contractWrappers = new ContractWrappers(this.provider, { networkId, + // TODO(albrow): Load in real contract addresses here. + contractAddresses: { + erc20Proxy: '', + erc721Proxy: '', + zrxToken: '', + etherToken: '', + exchange: '', + assetProxyOwner: '', + forwarder: '', + orderValidator: '', + }, }); } /** @@ -283,13 +294,13 @@ export class AssetBuyer { * Will throw if WETH does not exist for the current network. */ private _getEtherTokenAssetDataOrThrow(): string { - return assetDataUtils.getEtherTokenAssetDataOrThrow(this._contractWrappers); + return assetDataUtils.getEtherTokenAssetData(this._contractWrappers); } /** * Get the assetData that represents the ZRX token. * Will throw if ZRX does not exist for the current network. */ private _getZrxTokenAssetDataOrThrow(): string { - return assetDataUtils.getZrxTokenAssetDataOrThrow(this._contractWrappers); + return this._contractWrappers.exchange.getZRXAssetData(); } } diff --git a/packages/asset-buyer/src/utils/asset_data_utils.ts b/packages/asset-buyer/src/utils/asset_data_utils.ts index d05ff2504..f54462a23 100644 --- a/packages/asset-buyer/src/utils/asset_data_utils.ts +++ b/packages/asset-buyer/src/utils/asset_data_utils.ts @@ -2,25 +2,11 @@ import { ContractWrappers } from '@0xproject/contract-wrappers'; import { assetDataUtils as sharedAssetDataUtils } from '@0xproject/order-utils'; import * as _ from 'lodash'; -import { AssetBuyerError } from '../types'; - export const assetDataUtils = { ...sharedAssetDataUtils, - getEtherTokenAssetDataOrThrow(contractWrappers: ContractWrappers): string { - const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists(); - if (_.isUndefined(etherTokenAddressIfExists)) { - throw new Error(AssetBuyerError.NoEtherTokenContractFound); - } - const etherTokenAssetData = sharedAssetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists); + getEtherTokenAssetData(contractWrappers: ContractWrappers): string { + const etherTokenAddress = contractWrappers.forwarder.etherTokenAddress; + const etherTokenAssetData = sharedAssetDataUtils.encodeERC20AssetData(etherTokenAddress); return etherTokenAssetData; }, - getZrxTokenAssetDataOrThrow(contractWrappers: ContractWrappers): string { - let zrxTokenAssetData: string; - try { - zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData(); - } catch (err) { - throw new Error(AssetBuyerError.NoZrxTokenContractFound); - } - return zrxTokenAssetData; - }, }; |