Allow 'none' as value for explorer standard

This commit is contained in:
ligi 2021-10-10 17:39:21 +02:00
parent 67af6867fd
commit 341ae07c03
No known key found for this signature in database
GPG Key ID: 8E81894010ABF23D
4 changed files with 38 additions and 4 deletions

View File

@ -191,8 +191,8 @@ fun checkChain(chainFile: File, connectRPC: Boolean) {
throw(ExplorerInvalidUrl())
}
if (explorer["standard"] != "EIP3091") {
throw(ExplorerStandardMustBeEIP3091())
if (explorer["standard"] != "EIP3091" && explorer["standard"] != "none") {
throw(ExplorerStandardMustBeEIP3091OrNone())
}
}
}

View File

@ -15,7 +15,7 @@ class UnsupportedNamespace(): Exception("So far only the EIP155 namespace is sup
class ExplorersMustBeArray: Exception("explorers must be an array")
class ExplorerMustHaveName: Exception("Explorer must have name")
class ExplorerInvalidUrl: Exception("Explorer have url starting with https://")
class ExplorerStandardMustBeEIP3091: Exception("explorer standard must be EIP3091 - currently the only one supported")
class ExplorerStandardMustBeEIP3091OrNone: Exception("explorer standard must be 'none' or 'EIP3091'")
class ParentHasInvalidType(type: String?): Exception("Parent has invalid type $type - only L2 or shard allowed")
class ParentMustBeObject: Exception("parent must be an object")
class ParentMustHaveChainAndType: Exception("parent must have fields 'chain' and 'type'")

View File

@ -28,6 +28,14 @@ class TheChainChecker {
checkChain(file, false)
}
@Test
fun shouldPassForValidChainWithExplorersNoStandard() {
val file = getFile("valid/withexplorer/eip155-2.json")
checkChain(file, false)
}
@Test
fun shouldPassForValidChainWithParent() {
val file = getFile("valid/withparent/eip155-2.json")
@ -186,7 +194,7 @@ class TheChainChecker {
checkChain(getFile("invalid/explorersnotarray/eip155-1.json"), false)
}
@Test(expected = ExplorerStandardMustBeEIP3091::class)
@Test(expected = ExplorerStandardMustBeEIP3091OrNone::class)
fun shouldFailOnWrongExplorerStandard() {
checkChain(getFile("invalid/wrongexplorerstandard/eip155-1.json"), false)
}

View File

@ -0,0 +1,26 @@
{
"name": "Ethereum Mainnet",
"shortName": "eth",
"chain": "ETH",
"network": "mainnet",
"chainId": 2,
"networkId": 2,
"rpc": [
"https://mainnet.infura.io/v3/${INFURA_API_KEY}",
"https://api.mycryptoapi.com/eth"
],
"faucets": [],
"infoURL": "https://ethereum.org",
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"explorers": [
{
"name": "some",
"url": "https://etherscan.io",
"standard": "none"
}
]
}