[Internal] Add check and fix id field (#5904)

* Add check for existence of id field.

* Fix id field if it differs from address.

* Fix a few tokens with casing differences.

Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com>
This commit is contained in:
Adam R 2021-03-12 19:01:29 +01:00 committed by GitHub
parent cb2dc1a5ab
commit a957795c20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 26 additions and 14 deletions

View File

@ -10,5 +10,5 @@
"symbol": "BFC",
"decimals": 18,
"status": "active",
"id": "0x0c7d5ae016f806603cb1782bea29ac69471cab9c"
"id": "0x0c7D5ae016f806603CB1782bEa29AC69471CAb9c"
}

View File

@ -14,5 +14,5 @@
"symbol": "CGG",
"decimals": 18,
"status": "active",
"id": "0x1fe24f25b1cf609b9c4e7e12d802e3640dfa5e43"
"id": "0x1fE24F25b1Cf609B9c4e7E12D802e3640dFA5e43"
}

View File

@ -7,5 +7,5 @@
"symbol": "WSCRT",
"decimals": 6,
"status": "active",
"id": "0x2b89bf8ba858cd2fcee1fada378d5cd6936968be"
"id": "0x2B89bF8ba858cd2FCee1faDa378D5cd6936968Be"
}

View File

@ -7,5 +7,5 @@
"description": "Wootrade is a layer one trading infrastructure complete with deep liquidity, frontend trading GUI, and the ability to integrate into any exchange, trading desk, wallet, dApp, or other trading-related platform.",
"explorer": "https://etherscan.io/token/0x4691937a7508860f876c9c0a2a617e7d9e945d4b",
"status": "active",
"id": "0x4691937a7508860f876c9c0a2a617e7d9e945d4b"
"id": "0x4691937a7508860F876c9c0a2a617E7d9E945D4B"
}

View File

@ -7,5 +7,5 @@
"website": "http://shadows.link/",
"explorer": "https://etherscan.io/token/0x661ab0ed68000491d98c796146bcf28c20d7c559",
"status": "active",
"id": "0x661ab0ed68000491d98c796146bcf28c20d7c559"
"id": "0x661Ab0Ed68000491d98C796146bcF28c20d7c559"
}

View File

@ -7,5 +7,5 @@
"symbol": "LOTTO",
"decimals": 18,
"status": "active",
"id": "0xb0dfd28d3cf7a5897c694904ace292539242f858"
"id": "0xb0dFd28d3CF7A5897C694904Ace292539242f858"
}

View File

@ -7,5 +7,5 @@
"description": "Worlds first and only blockchain-based freelancer platform on the Binance Chain network, working with fully decentralized and smart contracts.",
"explorer": "https://bscscan.com/token/0x851f7a700c5d67db59612b871338a85526752c25",
"status": "active",
"id": "0x851f7a700c5d67db59612b871338a85526752c25"
"id": "0x851F7a700c5d67DB59612b871338a85526752c25"
}

View File

@ -7,5 +7,5 @@
"symbol": "OXT",
"decimals": 18,
"status": "active",
"id": "0xad6172123e1bd3b4ce0b01ef92fdd63e83590b99"
"id": "0xAd6172123E1Bd3B4ce0B01ef92fDD63E83590b99"
}

View File

@ -25,5 +25,5 @@
"symbol": "EGG",
"decimals": 18,
"status": "active",
"id": "0xf952fc3ca7325cc27d15885d37117676d25bfda6"
"id": "0xF952Fc3ca7325Cc27D15885d37117676d25BfdA6"
}

View File

@ -29,16 +29,14 @@ function isAssetInfoValid(info: unknown, path: string, address: string, chain: s
typeof info['type'] === "string" && info['type'] !== "" &&
typeof info['symbol'] === "string" && info['symbol'] !== "" &&
typeof info['decimals'] === "number" && //(info['description'] === "-" || info['decimals'] !== 0) &&
typeof info['status'] === "string" && info['status'] !== ""
typeof info['status'] === "string" && info['status'] !== "" &&
typeof info['id'] === "string" && info['id'] !== ""
;
if (!isKeys1CorrectType) {
return [`Check keys1 '${info['name']}' '${info['type']}' '${info['symbol']}' '${info['decimals']}' '${info['id']}' ${path}`, "", fixedInfo];
return [`Field missing or invalid; name '${info['name']}' type '${info['type']}' symbol '${info['symbol']}' decimals '${info['decimals']}' id '${info['id']}' ${path}`, "", fixedInfo];
}
// type
if (typeof info['type'] !== "string") {
return [`Incorrect type for type '${info['type']}' '${chain}' '${path}`, "", fixedInfo];
}
if (chainFromAssetType(info['type'].toUpperCase()) !== chain ) {
return [`Incorrect value for type '${info['type']}' '${chain}' '${path}`, "", fixedInfo];
}
@ -52,6 +50,20 @@ function isAssetInfoValid(info: unknown, path: string, address: string, chain: s
fixedInfo['type'] = info['type'].toUpperCase();
}
// id, should match address
if (info['id'] != address) {
if (checkOnly) {
if (info['id'].toUpperCase() != address.toUpperCase()) {
return [`Incorrect value for id '${info['id']}' '${chain}' '${path}`, "", fixedInfo];
}
// is is correct value, but casing is wrong
return ["", `Wrong casing for id '${info['id']}' '${chain}' '${path}`, fixedInfo];
}
// fix
if (!fixedInfo) { fixedInfo = info; }
fixedInfo['id'] = address;
}
const isKeys2CorrectType =
typeof info['description'] === "string" && info['description'] !== "" &&
// website should be set (exception description='-' marks empty infos)