Enforce decimals=8 for BEP2 tokens (#12727)

Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com>
This commit is contained in:
Adam R 2021-08-12 09:50:33 +02:00 committed by GitHub
parent b71c7e27dd
commit 64b62f987e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,6 +112,14 @@ function isAssetInfoValid(info: unknown, path: string, address: string, chain: s
}
}
// extra checks on decimals
if (info['decimals'] > 30 || info['decimals'] < 0) {
return [`Incorrect value for decimals '${info['decimals']}' '${chain}' ${path}`, "", fixedInfo];
}
if (info['type'] === 'BEP2' && info['decimals'] != 8) {
return [`Incorrect value for decimals, BEP2 tokens have 8 decimals. '${info['decimals']}' '${chain}' ${path}`, "", fixedInfo];
}
// status
if (!isValidStatusValue(info['status'])) {
return [`Invalid value for status field, '${info['status']}'`, "", fixedInfo];