1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix watchAsset symbol validation (#9960)

This commit is contained in:
Erik Marks 2020-11-30 12:59:01 -08:00 committed by GitHub
parent 429847a686
commit cb44cff168
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -800,14 +800,16 @@ export default class PreferencesController {
* doesn't fulfill requirements * doesn't fulfill requirements
* *
*/ */
_validateERC20AssetParams(opts) { _validateERC20AssetParams({ rawAddress, symbol, decimals } = {}) {
const { rawAddress, symbol, decimals } = opts
if (!rawAddress || !symbol || typeof decimals === 'undefined') { if (!rawAddress || !symbol || typeof decimals === 'undefined') {
throw new Error( throw new Error(
`Cannot suggest token without address, symbol, and decimals`, `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`) throw new Error(`Invalid symbol ${symbol} more than six characters`)
} }
const numDecimals = parseInt(decimals, 10) const numDecimals = parseInt(decimals, 10)