diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-13 22:09:04 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-13 22:09:04 +0800 |
commit | 61243b418e4d962cd8d8a1d7a49f04510b3c1c7f (patch) | |
tree | 76dc6976632f74dbf3434ce5780aec9ad33bde3f /packages/order-utils/src/exchange_transfer_simulator.ts | |
parent | fe75660e88ed0c37c4f3d461a644bd9305bf6183 (diff) | |
download | dexon-0x-contracts-61243b418e4d962cd8d8a1d7a49f04510b3c1c7f.tar dexon-0x-contracts-61243b418e4d962cd8d8a1d7a49f04510b3c1c7f.tar.gz dexon-0x-contracts-61243b418e4d962cd8d8a1d7a49f04510b3c1c7f.tar.bz2 dexon-0x-contracts-61243b418e4d962cd8d8a1d7a49f04510b3c1c7f.tar.lz dexon-0x-contracts-61243b418e4d962cd8d8a1d7a49f04510b3c1c7f.tar.xz dexon-0x-contracts-61243b418e4d962cd8d8a1d7a49f04510b3c1c7f.tar.zst dexon-0x-contracts-61243b418e4d962cd8d8a1d7a49f04510b3c1c7f.zip |
Implement initial set of orderFill combinatorial tests
Diffstat (limited to 'packages/order-utils/src/exchange_transfer_simulator.ts')
-rw-r--r-- | packages/order-utils/src/exchange_transfer_simulator.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/packages/order-utils/src/exchange_transfer_simulator.ts b/packages/order-utils/src/exchange_transfer_simulator.ts index 32d53d6a2..cac4af243 100644 --- a/packages/order-utils/src/exchange_transfer_simulator.ts +++ b/packages/order-utils/src/exchange_transfer_simulator.ts @@ -1,7 +1,8 @@ -import { ExchangeContractErrs } from '@0xproject/types'; +import { AssetProxyId, ExchangeContractErrs } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { AbstractBalanceAndProxyAllowanceLazyStore } from './abstract/abstract_balance_and_proxy_allowance_lazy_store'; +import { assetProxyUtils } from './asset_proxy_utils'; import { constants } from './constants'; import { TradeSide, TransferType } from './types'; @@ -89,8 +90,13 @@ export class ExchangeTransferSimulator { userAddress: string, amountInBaseUnits: BigNumber, ): Promise<void> { + const assetProxyId = assetProxyUtils.decodeAssetDataId(assetData); + const isERC721Asset = assetProxyId === AssetProxyId.ERC721; const proxyAllowance = await this._store.getProxyAllowanceAsync(assetData, userAddress); - if (!proxyAllowance.eq(constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS)) { + // HACK: This code assumes that all tokens with an UNLIMITED_ALLOWANCE_IN_BASE_UNITS set, + // are UnlimitedAllowanceTokens. This is however not true, it just so happens that all + // DummyERC20Tokens we use in tests are. + if (!proxyAllowance.eq(constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS) && !isERC721Asset) { this._store.setProxyAllowance(assetData, userAddress, proxyAllowance.minus(amountInBaseUnits)); } } |