mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
returning error in watchAsset
This commit is contained in:
parent
6fa889abcb
commit
3a3732eb24
@ -87,11 +87,15 @@ class PreferencesController {
|
|||||||
const { type, options } = req.params
|
const { type, options } = req.params
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'ERC20':
|
case 'ERC20':
|
||||||
res.result = await this._handleWatchAssetERC20(options)
|
const result = await this._handleWatchAssetERC20(options)
|
||||||
end()
|
if (result instanceof Error) {
|
||||||
|
end(result)
|
||||||
|
} else {
|
||||||
|
res.result = result
|
||||||
|
end()
|
||||||
|
}
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
// TODO return promise for not handled assets
|
|
||||||
end(new Error(`Asset of type ${type} not supported`))
|
end(new Error(`Asset of type ${type} not supported`))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -507,7 +511,11 @@ class PreferencesController {
|
|||||||
async _handleWatchAssetERC20 (options) {
|
async _handleWatchAssetERC20 (options) {
|
||||||
const { address, symbol, decimals, imageUrl } = options
|
const { address, symbol, decimals, imageUrl } = options
|
||||||
const rawAddress = address
|
const rawAddress = address
|
||||||
this._validateERC20AssetParams({ rawAddress, symbol, decimals })
|
try {
|
||||||
|
this._validateERC20AssetParams({ rawAddress, symbol, decimals })
|
||||||
|
} catch (err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
const tokenOpts = { rawAddress, decimals, symbol, imageUrl }
|
const tokenOpts = { rawAddress, decimals, symbol, imageUrl }
|
||||||
this.addSuggestedERC20Asset(tokenOpts)
|
this.addSuggestedERC20Asset(tokenOpts)
|
||||||
return this.showWatchAssetUi().then(() => {
|
return this.showWatchAssetUi().then(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user