Support slip44 and initial backfill (#76)

This commit is contained in:
ligi 2019-10-18 18:35:10 +09:00 committed by GitHub
parent 07b62b9258
commit b1c93db236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 27 additions and 14 deletions

View File

@ -15,5 +15,6 @@
"infoURL": "https://ethereum.org", "infoURL": "https://ethereum.org",
"shortName": "eth", "shortName": "eth",
"chainId": 1, "chainId": 1,
"networkId": 1 "networkId": 1,
"slip44": 60
} }

View File

@ -14,5 +14,6 @@
"infoURL": "https://forum.poa.network/c/xdai-chain", "infoURL": "https://forum.poa.network/c/xdai-chain",
"shortName": "xdai", "shortName": "xdai",
"chainId": 100, "chainId": 100,
"networkId": 100 "networkId": 100,
"slip44": 700
} }

View File

@ -14,5 +14,6 @@
"infoURL": "https://einc.io", "infoURL": "https://einc.io",
"shortName": "eti", "shortName": "eti",
"chainId": 101, "chainId": 101,
"networkId": 1 "networkId": 1,
"slip44": 464
} }

View File

@ -14,5 +14,6 @@
"infoURL": "https://metadium.com", "infoURL": "https://metadium.com",
"shortName": "meta", "shortName": "meta",
"chainId": 11, "chainId": 11,
"networkId": 11 "networkId": 11,
"slip44": 961
} }

View File

@ -14,5 +14,6 @@
"infoURL": "https://ether1.org", "infoURL": "https://ether1.org",
"shortName": "etho", "shortName": "etho",
"chainId": 1313114, "chainId": 1313114,
"networkId": 1313114 "networkId": 1313114,
"slip44": 1313114
} }

View File

@ -14,5 +14,6 @@
"infoURL": "https://atheios.com", "infoURL": "https://atheios.com",
"shortName": "ath", "shortName": "ath",
"chainId": 1620, "chainId": 1620,
"networkId": 11235813 "networkId": 11235813,
"slip44": 1620
} }

View File

@ -14,5 +14,6 @@
"infoURL": "https://egem.io", "infoURL": "https://egem.io",
"shortName": "egem", "shortName": "egem",
"chainId": 1987, "chainId": 1987,
"networkId": 1987 "networkId": 1987,
"slip44": 1987
} }

View File

@ -14,5 +14,6 @@
"infoURL": "https://expanse.tech", "infoURL": "https://expanse.tech",
"shortName": "exp", "shortName": "exp",
"chainId": 2, "chainId": 2,
"networkId": 1 "networkId": 1,
"slip44": 40
} }

View File

@ -14,5 +14,6 @@
"infoURL": "https://ethereumclassic.org", "infoURL": "https://ethereumclassic.org",
"shortName": "etc", "shortName": "etc",
"chainId": 61, "chainId": 61,
"networkId": 1 "networkId": 1,
"slip44": 61
} }

View File

@ -17,5 +17,6 @@
"infoURL": "https://aquachain.github.io", "infoURL": "https://aquachain.github.io",
"shortName": "aqua", "shortName": "aqua",
"chainId": 61717561, "chainId": 61717561,
"networkId": 61717561 "networkId": 61717561,
"slip44": 61717561
} }

View File

@ -6,7 +6,7 @@ import org.kethereum.rpc.HttpEthereumRPC
import java.io.File import java.io.File
import java.math.BigInteger import java.math.BigInteger
val all_fields = listOf( val mandatory_fields = listOf(
"name", "name",
"shortName", "shortName",
"chain", "chain",
@ -18,6 +18,9 @@ val all_fields = listOf(
"infoURL", "infoURL",
"nativeCurrency" "nativeCurrency"
) )
val optionalFields = listOf(
"slip44"
)
class FileNameMustMatchChainId : Exception("chainId must match the filename") class FileNameMustMatchChainId : Exception("chainId must match the filename")
class ExtensionMustBeJSON : Exception("filename extension must be json") class ExtensionMustBeJSON : Exception("filename extension must be json")
@ -41,12 +44,12 @@ fun checkChain(it: File, connectRPC: Boolean) {
getNumber(jsonObject, "networkId") getNumber(jsonObject, "networkId")
val extraFields = jsonObject.map.keys.subtract(all_fields) val extraFields = jsonObject.map.keys.subtract(mandatory_fields).subtract(optionalFields)
if (extraFields.isNotEmpty()) { if (extraFields.isNotEmpty()) {
throw ShouldHaveNoExtraFields(extraFields) throw ShouldHaveNoExtraFields(extraFields)
} }
val missingFields = all_fields.subtract(jsonObject.map.keys) val missingFields = mandatory_fields.subtract(jsonObject.map.keys)
if (missingFields.isNotEmpty()) { if (missingFields.isNotEmpty()) {
throw ShouldHaveNoMissingFields(missingFields) throw ShouldHaveNoMissingFields(missingFields)
} }