aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban MIno <efmino@uc.cl>2018-08-22 00:12:45 +0800
committerEsteban MIno <efmino@uc.cl>2018-08-22 00:12:45 +0800
commit3a3732eb2471c83722d41f2389f34c8759b5e2cb (patch)
tree2123a6351132a54050166864e1cc490433fe13a8
parent6fa889abcb2e907073e227379e1fc930d22bfe2d (diff)
downloadtangerine-wallet-browser-3a3732eb2471c83722d41f2389f34c8759b5e2cb.tar
tangerine-wallet-browser-3a3732eb2471c83722d41f2389f34c8759b5e2cb.tar.gz
tangerine-wallet-browser-3a3732eb2471c83722d41f2389f34c8759b5e2cb.tar.bz2
tangerine-wallet-browser-3a3732eb2471c83722d41f2389f34c8759b5e2cb.tar.lz
tangerine-wallet-browser-3a3732eb2471c83722d41f2389f34c8759b5e2cb.tar.xz
tangerine-wallet-browser-3a3732eb2471c83722d41f2389f34c8759b5e2cb.tar.zst
tangerine-wallet-browser-3a3732eb2471c83722d41f2389f34c8759b5e2cb.zip
returning error in watchAsset
-rw-r--r--app/scripts/controllers/preferences.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index 04a9f2e75..a03abbf79 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -87,11 +87,15 @@ class PreferencesController {
const { type, options } = req.params
switch (type) {
case 'ERC20':
- res.result = await this._handleWatchAssetERC20(options)
- end()
+ const result = await this._handleWatchAssetERC20(options)
+ if (result instanceof Error) {
+ end(result)
+ } else {
+ res.result = result
+ end()
+ }
break
default:
- // TODO return promise for not handled assets
end(new Error(`Asset of type ${type} not supported`))
}
} else {
@@ -507,7 +511,11 @@ class PreferencesController {
async _handleWatchAssetERC20 (options) {
const { address, symbol, decimals, imageUrl } = options
const rawAddress = address
- this._validateERC20AssetParams({ rawAddress, symbol, decimals })
+ try {
+ this._validateERC20AssetParams({ rawAddress, symbol, decimals })
+ } catch (err) {
+ return err
+ }
const tokenOpts = { rawAddress, decimals, symbol, imageUrl }
this.addSuggestedERC20Asset(tokenOpts)
return this.showWatchAssetUi().then(() => {