aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-27 03:43:44 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-27 03:43:44 +0800
commit9512978de9aee1953930d4f16a105ec5ef7f048e (patch)
tree64758b2ed21ad734f23c8d764b17d2f48abcb716 /packages/instant/src/util
parentffecba21f4e9dcda961a3e8432e70e6605174de5 (diff)
downloaddexon-sol-tools-9512978de9aee1953930d4f16a105ec5ef7f048e.tar
dexon-sol-tools-9512978de9aee1953930d4f16a105ec5ef7f048e.tar.gz
dexon-sol-tools-9512978de9aee1953930d4f16a105ec5ef7f048e.tar.bz2
dexon-sol-tools-9512978de9aee1953930d4f16a105ec5ef7f048e.tar.lz
dexon-sol-tools-9512978de9aee1953930d4f16a105ec5ef7f048e.tar.xz
dexon-sol-tools-9512978de9aee1953930d4f16a105ec5ef7f048e.tar.zst
dexon-sol-tools-9512978de9aee1953930d4f16a105ec5ef7f048e.zip
feat(instant): Show message if user doesn't have enough ETH
Diffstat (limited to 'packages/instant/src/util')
-rw-r--r--packages/instant/src/util/address.ts6
-rw-r--r--packages/instant/src/util/error.ts5
2 files changed, 10 insertions, 1 deletions
diff --git a/packages/instant/src/util/address.ts b/packages/instant/src/util/address.ts
new file mode 100644
index 000000000..97ed30a00
--- /dev/null
+++ b/packages/instant/src/util/address.ts
@@ -0,0 +1,6 @@
+import { web3Wrapper } from '../util/web3_wrapper';
+
+export const getBestAddress = async (): Promise<string> => {
+ const addresses = await web3Wrapper.getAvailableAddressesAsync();
+ return addresses[0];
+};
diff --git a/packages/instant/src/util/error.ts b/packages/instant/src/util/error.ts
index 64c1f4885..5db0c66d2 100644
--- a/packages/instant/src/util/error.ts
+++ b/packages/instant/src/util/error.ts
@@ -2,7 +2,7 @@ import { AssetBuyerError } from '@0x/asset-buyer';
import { Dispatch } from 'redux';
import { Action, actions } from '../redux/actions';
-import { Asset } from '../types';
+import { Asset, ZeroExInstantError } from '../types';
import { assetUtils } from './asset';
@@ -49,6 +49,9 @@ const humanReadableMessageForError = (error: Error, asset?: Asset): string | und
if (error.message === AssetBuyerError.SignatureRequestDenied) {
return 'You denied this transaction';
}
+ if (error.message === ZeroExInstantError.InsufficientBalance) {
+ return "You don't have enough ETH";
+ }
return undefined;
};