From 2afb06de13098a1f7d72f4ed250da47d034144d7 Mon Sep 17 00:00:00 2001 From: David Sun Date: Fri, 21 Jun 2019 10:17:36 -0700 Subject: [PATCH] refactored forwarder to utilize utils --- .../forwarder_swap_quote_consumer.ts | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/packages/asset-buyer/src/quote_consumers/forwarder_swap_quote_consumer.ts b/packages/asset-buyer/src/quote_consumers/forwarder_swap_quote_consumer.ts index f179164e0b..fc540c7214 100644 --- a/packages/asset-buyer/src/quote_consumers/forwarder_swap_quote_consumer.ts +++ b/packages/asset-buyer/src/quote_consumers/forwarder_swap_quote_consumer.ts @@ -19,6 +19,7 @@ import { import { affiliateFeeUtils } from '../utils/affiliate_fee_utils'; import { assert } from '../utils/assert'; import { assetDataUtils } from '../utils/asset_data_utils'; +import { SwapQuoteConsumerUtils } from '../utils/swap_quote_consumer_utils'; import { utils } from '../utils/utils'; export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumer { @@ -164,7 +165,7 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumer): Promise { - if (opts.takerAddress !== undefined) { - return opts.takerAddress; - } else { - const web3Wrapper = new Web3Wrapper(this.provider); - const availableAddresses = await web3Wrapper.getAvailableAddressesAsync(); - const firstAvailableAddress = _.head(availableAddresses); - if (firstAvailableAddress !== undefined) { - return firstAvailableAddress; - } else { - throw new Error(SwapQuoteConsumerError.NoAddressAvailable); - } - } - } - - /** - * Get the assetData that represents the WETH token. - * Will throw if WETH does not exist for the current network. - */ private _getEtherTokenAssetDataOrThrow(): string { return assetDataUtils.getEtherTokenAssetData(this._contractWrappers); }