diff options
author | Fred Carlsen <fred@sjelfull.no> | 2018-12-05 23:15:44 +0800 |
---|---|---|
committer | Fred Carlsen <fred@sjelfull.no> | 2018-12-05 23:15:44 +0800 |
commit | 00dbddc1aafd56c352e7a8905338d81e236b1fa1 (patch) | |
tree | c8462eb4e6882a39dec601b990f75761b4897ce8 /packages/instant/src/util/asset.ts | |
parent | b552c2bd0c5090629a96bc6b0e032cb85d9c52b3 (diff) | |
parent | b411e2250aed82b87d1cbebf5cf805d794ddbdb7 (diff) | |
download | dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar.gz dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar.bz2 dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar.lz dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar.xz dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar.zst dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.zip |
Merge remote-tracking branch 'upstream/development' into website
# Conflicts:
# packages/website/package.json
# packages/website/ts/style/colors.ts
Diffstat (limited to 'packages/instant/src/util/asset.ts')
-rw-r--r-- | packages/instant/src/util/asset.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/instant/src/util/asset.ts b/packages/instant/src/util/asset.ts index 40560d3eb..08f3642e3 100644 --- a/packages/instant/src/util/asset.ts +++ b/packages/instant/src/util/asset.ts @@ -1,3 +1,4 @@ +import { AssetBuyerError } from '@0x/asset-buyer'; import { AssetProxyId, ObjectMap } from '@0x/types'; import * as _ from 'lodash'; @@ -106,4 +107,20 @@ export const assetUtils = { ); return _.compact(erc20sOrUndefined); }, + assetBuyerErrorMessage: (asset: ERC20Asset, error: Error): string | undefined => { + if (error.message === AssetBuyerError.InsufficientAssetLiquidity) { + const assetName = assetUtils.bestNameForAsset(asset, 'of this asset'); + return `Not enough ${assetName} available`; + } else if (error.message === AssetBuyerError.InsufficientZrxLiquidity) { + return 'Not enough ZRX available'; + } else if ( + error.message === AssetBuyerError.StandardRelayerApiError || + error.message.startsWith(AssetBuyerError.AssetUnavailable) + ) { + const assetName = assetUtils.bestNameForAsset(asset, 'This asset'); + return `${assetName} is currently unavailable`; + } + + return undefined; + }, }; |