prettier
This commit is contained in:
parent
feebb45e9d
commit
cfa2a90dae
@ -21,7 +21,6 @@ import { swapQuoteConsumerUtils } from '../utils/swap_quote_consumer_utils';
|
|||||||
import { utils } from '../utils/utils';
|
import { utils } from '../utils/utils';
|
||||||
|
|
||||||
export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumer<ExchangeMarketBuySmartContractParams> {
|
export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumer<ExchangeMarketBuySmartContractParams> {
|
||||||
|
|
||||||
public readonly provider: ZeroExProvider;
|
public readonly provider: ZeroExProvider;
|
||||||
public readonly networkId: number;
|
public readonly networkId: number;
|
||||||
|
|
||||||
@ -39,16 +38,15 @@ export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumer<ExchangeMark
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getCalldataOrThrowAsync(quote: SwapQuote, opts: Partial<SwapQuoteGetOutputOpts>): Promise<CalldataInfo> {
|
public async getCalldataOrThrowAsync(
|
||||||
|
quote: SwapQuote,
|
||||||
|
opts: Partial<SwapQuoteGetOutputOpts>,
|
||||||
|
): Promise<CalldataInfo> {
|
||||||
assert.isValidSwapQuote('quote', quote);
|
assert.isValidSwapQuote('quote', quote);
|
||||||
|
|
||||||
const { params, to, ethAmount, methodAbi } = await this.getSmartContractParamsOrThrowAsync(quote, opts);
|
const { params, to, ethAmount, methodAbi } = await this.getSmartContractParamsOrThrowAsync(quote, opts);
|
||||||
const abiEncoder = new AbiEncoder.Method(methodAbi);
|
const abiEncoder = new AbiEncoder.Method(methodAbi);
|
||||||
const args = [
|
const args = [params.orders, params.makerAssetFillAmount, params.signatures];
|
||||||
params.orders,
|
|
||||||
params.makerAssetFillAmount,
|
|
||||||
params.signatures,
|
|
||||||
];
|
|
||||||
const calldataHexString = abiEncoder.encode(args);
|
const calldataHexString = abiEncoder.encode(args);
|
||||||
return {
|
return {
|
||||||
calldataHexString,
|
calldataHexString,
|
||||||
@ -58,7 +56,10 @@ export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumer<ExchangeMark
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getSmartContractParamsOrThrowAsync(quote: SwapQuote, opts: Partial<SwapQuoteGetOutputOpts>): Promise<SmartContractParamsInfo<ExchangeMarketBuySmartContractParams>> {
|
public async getSmartContractParamsOrThrowAsync(
|
||||||
|
quote: SwapQuote,
|
||||||
|
opts: Partial<SwapQuoteGetOutputOpts>,
|
||||||
|
): Promise<SmartContractParamsInfo<ExchangeMarketBuySmartContractParams>> {
|
||||||
assert.isValidSwapQuote('quote', quote);
|
assert.isValidSwapQuote('quote', quote);
|
||||||
|
|
||||||
const { orders, makerAssetFillAmount } = quote;
|
const { orders, makerAssetFillAmount } = quote;
|
||||||
@ -66,9 +67,9 @@ export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumer<ExchangeMark
|
|||||||
const signatures = _.map(orders, o => o.signature);
|
const signatures = _.map(orders, o => o.signature);
|
||||||
|
|
||||||
const params: ExchangeMarketBuySmartContractParams = {
|
const params: ExchangeMarketBuySmartContractParams = {
|
||||||
orders,
|
orders,
|
||||||
signatures,
|
signatures,
|
||||||
makerAssetFillAmount,
|
makerAssetFillAmount,
|
||||||
};
|
};
|
||||||
|
|
||||||
const methodAbi = utils.getMethodAbiFromContractAbi(
|
const methodAbi = utils.getMethodAbiFromContractAbi(
|
||||||
@ -83,7 +84,10 @@ export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumer<ExchangeMark
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async executeSwapQuoteOrThrowAsync(quote: SwapQuote, opts: Partial<SwapQuoteExecutionOpts>): Promise<string> {
|
public async executeSwapQuoteOrThrowAsync(
|
||||||
|
quote: SwapQuote,
|
||||||
|
opts: Partial<SwapQuoteExecutionOpts>,
|
||||||
|
): Promise<string> {
|
||||||
assert.isValidSwapQuote('quote', quote);
|
assert.isValidSwapQuote('quote', quote);
|
||||||
|
|
||||||
const { takerAddress, gasLimit, gasPrice } = opts;
|
const { takerAddress, gasLimit, gasPrice } = opts;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { SupportedProvider, Web3Wrapper } from '@0x/web3-wrapper';
|
import { SupportedProvider, Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import {
|
import { SwapQuoteConsumerError, SwapQuoteExecutionOpts } from '../types';
|
||||||
SwapQuoteConsumerError,
|
|
||||||
SwapQuoteExecutionOpts,
|
|
||||||
} from '../types';
|
|
||||||
|
|
||||||
export const swapQuoteConsumerUtils = {
|
export const swapQuoteConsumerUtils = {
|
||||||
async getTakerAddressOrThrowAsync(provider: SupportedProvider, opts: Partial<SwapQuoteExecutionOpts>): Promise<string> {
|
async getTakerAddressOrThrowAsync(
|
||||||
|
provider: SupportedProvider,
|
||||||
|
opts: Partial<SwapQuoteExecutionOpts>,
|
||||||
|
): Promise<string> {
|
||||||
if (opts.takerAddress !== undefined) {
|
if (opts.takerAddress !== undefined) {
|
||||||
return opts.takerAddress;
|
return opts.takerAddress;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user