Rename BalanceAndAllowanceFetchers to BalanceAndProxyAllowanceFetchers
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
export abstract class BalanceAndAllowanceFetcher {
|
||||
export abstract class BalanceAndProxyAllowanceFetcher {
|
||||
public abstract async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber>;
|
||||
public abstract async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber>;
|
||||
}
|
@@ -13,7 +13,7 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import { SimpleBalanceAndAllowanceFetcher } from '../fetchers/simple_balance_and_allowance_fetcher';
|
||||
import { SimpleBalanceAndProxyAllowanceFetcher } from '../fetchers/simple_balance_and_proxy_allowance_fetcher';
|
||||
import { SimpleOrderFilledCancelledFetcher } from '../fetchers/simple_order_filled_cancelled_fetcher';
|
||||
import {
|
||||
BlockRange,
|
||||
@@ -881,12 +881,12 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* @param signedOrder The signedOrder
|
||||
*/
|
||||
public async getOrderStateAsync(signedOrder: SignedOrder): Promise<OrderState> {
|
||||
const balanceAndProxyAllowanceLazyStore = new SimpleBalanceAndAllowanceFetcher(
|
||||
const simpleBalanceAndProxyAllowanceFetcher = new SimpleBalanceAndProxyAllowanceFetcher(
|
||||
this._tokenWrapper,
|
||||
BlockParamLiteral.Latest,
|
||||
);
|
||||
const orderFilledCancelledLazyStore = new SimpleOrderFilledCancelledFetcher(this);
|
||||
const orderStateUtils = new OrderStateUtils(balanceAndProxyAllowanceLazyStore, orderFilledCancelledLazyStore);
|
||||
const simpleOrderFilledCancelledFetcher = new SimpleOrderFilledCancelledFetcher(this);
|
||||
const orderStateUtils = new OrderStateUtils(simpleBalanceAndProxyAllowanceFetcher, simpleOrderFilledCancelledFetcher);
|
||||
return orderStateUtils.getOrderStateAsync(signedOrder);
|
||||
}
|
||||
/**
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
import {BalanceAndAllowanceFetcher} from '../abstract/balance_and_allowance_fetcher';
|
||||
import {BalanceAndProxyAllowanceFetcher} from '../abstract/balance_and_proxy_allowance_fetcher';
|
||||
import {TokenWrapper} from '../contract_wrappers/token_wrapper';
|
||||
|
||||
export class SimpleBalanceAndAllowanceFetcher implements BalanceAndAllowanceFetcher {
|
||||
export class SimpleBalanceAndProxyAllowanceFetcher implements BalanceAndProxyAllowanceFetcher {
|
||||
private _token: TokenWrapper;
|
||||
private _defaultBlock: BlockParamLiteral;
|
||||
constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) {
|
@@ -3,12 +3,12 @@ import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { TokenWrapper } from '../contract_wrappers/token_wrapper';
|
||||
import { BalanceAndAllowanceFetcher } from '../abstract/balance_and_allowance_fetcher';
|
||||
import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher';
|
||||
|
||||
/**
|
||||
* Copy on read store for balances/proxyAllowances of tokens/accounts
|
||||
*/
|
||||
export class BalanceAndProxyAllowanceLazyStore implements BalanceAndAllowanceFetcher {
|
||||
export class BalanceAndProxyAllowanceLazyStore implements BalanceAndProxyAllowanceFetcher {
|
||||
private _token: TokenWrapper;
|
||||
private _defaultBlock: BlockParamLiteral;
|
||||
private _balance: {
|
||||
|
@@ -4,7 +4,7 @@ import * as _ from 'lodash';
|
||||
|
||||
import { ZeroEx } from '../0x';
|
||||
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
|
||||
import { BalanceAndAllowanceFetcher } from '../abstract/balance_and_allowance_fetcher';
|
||||
import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher';
|
||||
import { OrderFilledCancelledFetcher } from '../abstract/order_filled_cancelled_fetcher';
|
||||
import { RemainingFillableCalculator } from '../order_watcher/remaining_fillable_calculator';
|
||||
import { ExchangeContractErrs, OrderRelevantState, OrderState, OrderStateInvalid, OrderStateValid } from '../types';
|
||||
@@ -12,7 +12,7 @@ import { ExchangeContractErrs, OrderRelevantState, OrderState, OrderStateInvalid
|
||||
const ACCEPTABLE_RELATIVE_ROUNDING_ERROR = 0.0001;
|
||||
|
||||
export class OrderStateUtils {
|
||||
private _balanceAndAllowanceFetcher: BalanceAndAllowanceFetcher;
|
||||
private _balanceAndProxyAllowanceFetcher: BalanceAndProxyAllowanceFetcher;
|
||||
private _orderFilledCancelledFetcher: OrderFilledCancelledFetcher;
|
||||
private static _validateIfOrderIsValid(signedOrder: SignedOrder, orderRelevantState: OrderRelevantState): void {
|
||||
const unavailableTakerTokenAmount = orderRelevantState.cancelledTakerTokenAmount.add(
|
||||
@@ -49,10 +49,10 @@ export class OrderStateUtils {
|
||||
}
|
||||
}
|
||||
constructor(
|
||||
balanceAndProxyAllowanceFetcher: BalanceAndAllowanceFetcher,
|
||||
balanceAndProxyAllowanceFetcher: BalanceAndProxyAllowanceFetcher,
|
||||
orderFilledCancelledFetcher: OrderFilledCancelledFetcher,
|
||||
) {
|
||||
this._balanceAndAllowanceFetcher = balanceAndProxyAllowanceFetcher;
|
||||
this._balanceAndProxyAllowanceFetcher = balanceAndProxyAllowanceFetcher;
|
||||
this._orderFilledCancelledFetcher = orderFilledCancelledFetcher;
|
||||
}
|
||||
public async getOrderStateAsync(signedOrder: SignedOrder): Promise<OrderState> {
|
||||
@@ -83,19 +83,19 @@ export class OrderStateUtils {
|
||||
const exchange = (this._orderFilledCancelledFetcher as any)._exchange as ExchangeWrapper;
|
||||
const zrxTokenAddress = exchange.getZRXTokenAddress();
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
const makerBalance = await this._balanceAndAllowanceFetcher.getBalanceAsync(
|
||||
const makerBalance = await this._balanceAndProxyAllowanceFetcher.getBalanceAsync(
|
||||
signedOrder.makerTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
const makerProxyAllowance = await this._balanceAndAllowanceFetcher.getProxyAllowanceAsync(
|
||||
const makerProxyAllowance = await this._balanceAndProxyAllowanceFetcher.getProxyAllowanceAsync(
|
||||
signedOrder.makerTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
const makerFeeBalance = await this._balanceAndAllowanceFetcher.getBalanceAsync(
|
||||
const makerFeeBalance = await this._balanceAndProxyAllowanceFetcher.getBalanceAsync(
|
||||
zrxTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
const makerFeeProxyAllowance = await this._balanceAndAllowanceFetcher.getProxyAllowanceAsync(
|
||||
const makerFeeProxyAllowance = await this._balanceAndProxyAllowanceFetcher.getProxyAllowanceAsync(
|
||||
zrxTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
|
Reference in New Issue
Block a user