Skip to content

Commit

Permalink
Fix watchAsset symbol validation (#9960)
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks authored Nov 30, 2020
1 parent 429847a commit cb44cff
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/scripts/controllers/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,14 +800,16 @@ export default class PreferencesController {
* doesn't fulfill requirements
*
*/
_validateERC20AssetParams(opts) {
const { rawAddress, symbol, decimals } = opts
_validateERC20AssetParams({ rawAddress, symbol, decimals } = {}) {
if (!rawAddress || !symbol || typeof decimals === 'undefined') {
throw new Error(
`Cannot suggest token without address, symbol, and decimals`,
)
}
if (!(symbol.length < 7)) {
if (typeof symbol !== 'string') {
throw new Error(`Invalid symbol: not a string`)
}
if (symbol.length > 6) {
throw new Error(`Invalid symbol ${symbol} more than six characters`)
}
const numDecimals = parseInt(decimals, 10)
Expand Down

0 comments on commit cb44cff

Please sign in to comment.