Reduce character set names can use (#1924)

context #1912
This commit is contained in:
ligi 2022-11-23 03:25:51 +01:00 committed by GitHub
parent d8071dab68
commit 2898285b5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 36 additions and 17 deletions

View File

@ -1,5 +1,5 @@
{
"name": "Calypso NFT Hub | SKALE",
"name": "Calypso NFT Hub (SKALE)",
"title": "Calypso NFT Hub Mainnet",
"chain": "honorable-steel-rasalhague",
"rpc": ["https://mainnet.skalenodes.com/v1/honorable-steel-rasalhague"],

View File

@ -1,5 +1,5 @@
{
"name": "Optimism Bedrock: Goerli Alpha Testnet",
"name": "Optimism Bedrock (Goerli Alpha Testnet)",
"chain": "ETH",
"rpc": [
"https://alpha-1-replica-0.bedrock-goerli.optimism.io",

View File

@ -1,5 +1,5 @@
{
"name": "Filecoin Mainnet",
"name": "Filecoin - Mainnet",
"chain": "FIL",
"status": "incubating",
"rpc": ["https://api.node.glif.io/rpc/v0"],

View File

@ -1,5 +1,5 @@
{
"name": "Filecoin Buildernet",
"name": "Filecoin - Buildernet",
"chain": "FIL",
"status": "incubating",
"rpc": [],

View File

@ -1,5 +1,5 @@
{
"name": "Filecoin Wallaby testnet",
"name": "Filecoin - Wallaby testnet",
"chain": "FIL",
"status": "incubating",
"rpc": ["https://wallaby.node.glif.io/rpc/v0"],

View File

@ -1,5 +1,5 @@
{
"name": "Filecoin Calibration testnet",
"name": "Filecoin - Calibration testnet",
"chain": "FIL",
"status": "incubating",
"rpc": ["https://api.calibration.node.glif.io/rpc/v0"],

View File

@ -1,5 +1,5 @@
{
"name": "Filecoin Butterfly testnet",
"name": "Filecoin - Butterfly testnet",
"chain": "FIL",
"status": "incubating",
"rpc": [],

View File

@ -1,5 +1,5 @@
{
"name": "Filecoin Local testnet",
"name": "Filecoin - Local testnet",
"chain": "FIL",
"status": "incubating",
"rpc": [],

View File

@ -1,5 +1,5 @@
{
"name": "Calypso NFT Hub | SKALE Testnet",
"name": "Calypso NFT Hub (SKALE Testnet)",
"title": "Calypso NFT Hub Testnet",
"chain": "staging-utter-unripe-menkar",
"rpc": ["https://staging-v3.skalenodes.com/v1/staging-utter-unripe-menkar"],

View File

@ -6,7 +6,7 @@
"https://docs.crab.network/dvm/wallets/dvm-metamask#apply-for-the-test-token"
],
"nativeCurrency": {
"name": "Pangolin Network Native Token",
"name": "Pangolin Network Native Token",
"symbol": "PRING",
"decimals": 18
},

View File

@ -4,7 +4,7 @@
"rpc": ["https://pangoro-rpc.darwinia.network"],
"faucets": [],
"nativeCurrency": {
"name": "Pangoro Network Native Token",
"name": "Pangoro Network Native Token",
"symbol": "ORING",
"decimals": 18
},

View File

@ -257,6 +257,7 @@ fun checkChain(chainFile: File, connectRPC: Boolean, verbose: Boolean = false) {
}
}
val nameRegex = Regex("^[a-zA-Z0-9\\-\\.\\(\\) ]+$")
jsonObject["nativeCurrency"]?.let {
if (it !is JsonObject) {
throw NativeCurrencyMustBeObject()
@ -275,9 +276,23 @@ fun checkChain(chainFile: File, connectRPC: Boolean, verbose: Boolean = false) {
if (it["decimals"] !is Int) {
throw NativeCurrencyDecimalMustBeInt()
}
if (it["name"] !is String) {
val currencyName = it["name"]
if (currencyName !is String) {
throw NativeCurrencyNameMustBeString()
}
if (!nameRegex.matches(currencyName)) {
throw IllegalName("currencyName", currencyName)
}
}
val chainName = jsonObject["name"]
if (chainName !is String) {
throw ChainNameMustBeString()
}
if (!nameRegex.matches(chainName)) {
throw IllegalName("chain name", chainName)
}
jsonObject["explorers"]?.let {

View File

@ -40,4 +40,8 @@ class NativeCurrencyCanOnlyHaveSymbolNameAndDecimals: Exception("Native currency
class NativeCurrencyDecimalMustBeInt: Exception("Native currency decimals must be int")
class NativeCurrencyNameMustBeString: Exception("Native currency name must be string")
class ChainNameMustBeString: Exception("Name must be string")
class IllegalName(type: String,name: String): Exception("Invalid $type: $name")
class UnreferencedIcon(fileName: String, iconsDownloadPath: File): Exception("Found file $fileName in $iconsDownloadPath that is not referenced")

View File

@ -9,7 +9,7 @@
"https://api.mycryptoapi.com/eth"
],
"nativeCurrency": {
"name": "Görli Ether",
"name": "Goerli Ether",
"symbol": "GOR",
"decimals": 18
},

View File

@ -1,5 +1,5 @@
{
"name": "Ethereum Testnet Görli",
"name": "Ethereum Testnet Goerli",
"chain": "ETH",
"rpc": [
"https://rpc.goerli.mudit.blog/",
@ -11,7 +11,7 @@
"https://faucet.goerli.mudit.blog"
],
"nativeCurrency": {
"name": "Görli Ether",
"name": "Goerli Ether",
"symbol": "GOR",
"decimals": 18
},

View File

@ -1,5 +1,5 @@
{
"name": "Ethereum Testnet Görli",
"name": "Ethereum Testnet Goerli",
"chain": "ETH",
"rpc": [
"https://rpc.goerli.mudit.blog/",
@ -11,7 +11,7 @@
"https://faucet.goerli.mudit.blog"
],
"nativeCurrency": {
"name": "Görli Ether",
"name": "Goerli Ether",
"symbol": "GOR",
"decimals": 18
},