mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Allow 11 characters in symbol for RPC (#10670)
* Add error in RPC for zero length symbols * Increase RPC symbol length allowed to 11 * Add RPC tests for new symbol length checks
This commit is contained in:
parent
8fc2c3272a
commit
94fc420584
@ -793,9 +793,14 @@ export default class PreferencesController {
|
|||||||
if (typeof symbol !== 'string') {
|
if (typeof symbol !== 'string') {
|
||||||
throw ethErrors.rpc.invalidParams(`Invalid symbol: not a string.`);
|
throw ethErrors.rpc.invalidParams(`Invalid symbol: not a string.`);
|
||||||
}
|
}
|
||||||
if (!(symbol.length < 7)) {
|
if (!(symbol.length > 0)) {
|
||||||
throw ethErrors.rpc.invalidParams(
|
throw ethErrors.rpc.invalidParams(
|
||||||
`Invalid symbol "${symbol}": longer than 6 characters.`,
|
`Invalid symbol "${symbol}": shorter than a character.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!(symbol.length < 12)) {
|
||||||
|
throw ethErrors.rpc.invalidParams(
|
||||||
|
`Invalid symbol "${symbol}": longer than 11 characters.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const numDecimals = parseInt(decimals, 10);
|
const numDecimals = parseInt(decimals, 10);
|
||||||
|
@ -539,6 +539,14 @@ describe('preferences controller', function () {
|
|||||||
decimals: 0,
|
decimals: 0,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
assert.doesNotThrow(() =>
|
||||||
|
validate({
|
||||||
|
address: '0xd26114cd6EE289AccF82350c8d8487fedB8A0C07',
|
||||||
|
symbol: 'ABCDEFGHIJK',
|
||||||
|
decimals: 0,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => validate({ symbol: 'ABC', decimals: 0 }),
|
() => validate({ symbol: 'ABC', decimals: 0 }),
|
||||||
'missing address should fail',
|
'missing address should fail',
|
||||||
@ -563,10 +571,19 @@ describe('preferences controller', function () {
|
|||||||
() =>
|
() =>
|
||||||
validate({
|
validate({
|
||||||
address: '0xd26114cd6EE289AccF82350c8d8487fedB8A0C07',
|
address: '0xd26114cd6EE289AccF82350c8d8487fedB8A0C07',
|
||||||
symbol: 'ABCDEFGHI',
|
symbol: 'ABCDEFGHIJKLM',
|
||||||
decimals: 0,
|
decimals: 0,
|
||||||
}),
|
}),
|
||||||
'invalid symbol should fail',
|
'long symbol should fail',
|
||||||
|
);
|
||||||
|
assert.throws(
|
||||||
|
() =>
|
||||||
|
validate({
|
||||||
|
address: '0xd26114cd6EE289AccF82350c8d8487fedB8A0C07',
|
||||||
|
symbol: '',
|
||||||
|
decimals: 0,
|
||||||
|
}),
|
||||||
|
'empty symbol should fail',
|
||||||
);
|
);
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() =>
|
() =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user