diff options
author | Fabio Berger <me@fabioberger.com> | 2018-07-18 22:43:25 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-07-18 22:43:25 +0800 |
commit | 29d5034260b2e3b4b670d856463ed34377bff3ac (patch) | |
tree | 358b3cce6e4b2c4ea4f4c816668635e2aff758f0 /packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts | |
parent | f99232095b3effea261b5b24bc01db4f96c416f6 (diff) | |
parent | 00d1622b3f087943e750f1b3f6ee6ceab7e80285 (diff) | |
download | dexon-sol-tools-29d5034260b2e3b4b670d856463ed34377bff3ac.tar dexon-sol-tools-29d5034260b2e3b4b670d856463ed34377bff3ac.tar.gz dexon-sol-tools-29d5034260b2e3b4b670d856463ed34377bff3ac.tar.bz2 dexon-sol-tools-29d5034260b2e3b4b670d856463ed34377bff3ac.tar.lz dexon-sol-tools-29d5034260b2e3b4b670d856463ed34377bff3ac.tar.xz dexon-sol-tools-29d5034260b2e3b4b670d856463ed34377bff3ac.tar.zst dexon-sol-tools-29d5034260b2e3b4b670d856463ed34377bff3ac.zip |
merge v2-prototype
Diffstat (limited to 'packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts')
-rw-r--r-- | packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts b/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts index 6d5a02adf..5a2c1d7ff 100644 --- a/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts +++ b/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts @@ -1,8 +1,10 @@ +import { AssetProxyId } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import { AbstractBalanceAndProxyAllowanceFetcher } from '../abstract/abstract_balance_and_proxy_allowance_fetcher'; import { AbstractBalanceAndProxyAllowanceLazyStore } from '../abstract/abstract_balance_and_proxy_allowance_lazy_store'; +import { assetDataUtils } from '../asset_data_utils'; /** * Copy on read store for balances/proxyAllowances of tokens/accounts @@ -74,6 +76,20 @@ export class BalanceAndProxyAllowanceLazyStore implements AbstractBalanceAndProx } } } + public deleteAllERC721ProxyAllowance(tokenAddress: string, userAddress: string): void { + for (const assetData in this._proxyAllowance) { + if (this._proxyAllowance.hasOwnProperty(assetData)) { + const decodedAssetData = assetDataUtils.decodeAssetDataOrThrow(assetData); + if ( + decodedAssetData.assetProxyId === AssetProxyId.ERC721 && + decodedAssetData.tokenAddress === tokenAddress && + !_.isUndefined(this._proxyAllowance[assetData][userAddress]) + ) { + delete this._proxyAllowance[assetData][userAddress]; + } + } + } + } public deleteAll(): void { this._balance = {}; this._proxyAllowance = {}; |