Merge pull request #70 from ethereum-lists/verify-script

Add verify script
This commit is contained in:
Pedro Gomes 2019-06-17 18:10:56 +02:00 committed by GitHub
commit 108129d5a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 1892 additions and 90 deletions

4
.gitignore vendored
View File

@ -1,4 +1,6 @@
_site
.sass-cache
.jekyll-metadata
.DS_Store
.DS_Store
.env
node_modules

View File

@ -2,7 +2,10 @@
"name": "Ethereum Mainnet",
"chain": "ETH",
"network": "mainnet",
"rpc": ["https://mainnet.infura.io/v3/${INFURA_API_KEY}", "https://api.mycryptoapi.com/eth"],
"rpc": [
"https://mainnet.infura.io/v3/${INFURA_API_KEY}",
"https://api.mycryptoapi.com/eth"
],
"faucets": [],
"nativeCurrency": {
"name": "Ether",

View File

@ -2,7 +2,9 @@
"name": "xDAI Chain",
"chain": "XDAI",
"network": "mainnet",
"rpc": ["https://dai.poa.network"],
"rpc": [
"https://dai.poa.network"
],
"faucets": [],
"nativeCurrency": {
"name": "xDAI",
@ -12,5 +14,5 @@
"infoURL": "https://forum.poa.network/c/xdai-chain",
"shortName": "xdai",
"chainId": 100,
"networkId": 1
"networkId": 100
}

View File

@ -2,7 +2,9 @@
"name": "EtherInc",
"chain": "ETI",
"network": "mainnet",
"rpc": ["https://api.einc.io/jsonrpc/mainnet"],
"rpc": [
"https://api.einc.io/jsonrpc/mainnet"
],
"faucets": [],
"nativeCurrency": {
"name": "EtherInc Ether",

View File

@ -2,8 +2,12 @@
"name": "ThunderCore Mainnet",
"chain": "TT",
"network": "mainnet",
"rpc": ["https://mainnet-rpc.thundercore.com"],
"faucets": ["https://faucet.thundercore.com"],
"rpc": [
"https://mainnet-rpc.thundercore.com"
],
"faucets": [
"https://faucet.thundercore.com"
],
"nativeCurrency": {
"name": "ThunderCore Mainnet Ether",
"symbol": "TT",

View File

@ -2,7 +2,9 @@
"name": "Metadium Mainnet",
"chain": "META",
"network": "mainnet",
"rpc": ["https://api.metadium.com/prod"],
"rpc": [
"https://api.metadium.com/prod"
],
"faucets": [],
"nativeCurrency": {
"name": "Metadium Mainnet Ether",

View File

@ -2,7 +2,10 @@
"name": "IPOS Network",
"chain": "IPOS",
"network": "mainnet",
"rpc": ["https://rpc.iposlab.com", "https://rpc2.iposlab.com"],
"rpc": [
"https://rpc.iposlab.com",
"https://rpc2.iposlab.com"
],
"faucets": [],
"nativeCurrency": {
"name": "IPOS Network Ether",

View File

@ -2,7 +2,9 @@
"name": "Metadium Testnet",
"chain": "META",
"network": "testnet",
"rpc": ["https://api.metadium.com/dev"],
"rpc": [
"https://api.metadium.com/dev"
],
"faucets": [],
"nativeCurrency": {
"name": "Metadium Testnet Ether",

View File

@ -2,7 +2,9 @@
"name": "Ether-1",
"chain": "ETHO",
"network": "mainnet",
"rpc": ["https://rpc.ether1.org"],
"rpc": [
"https://rpc.ether1.org"
],
"faucets": [],
"nativeCurrency": {
"name": "Ether-1 Ether",

View File

@ -2,7 +2,9 @@
"name": "PepChain Churchill",
"chain": "PEP",
"network": "testnet",
"rpc": ["https://churchill-rpc.pepchain.io"],
"rpc": [
"https://churchill-rpc.pepchain.io"
],
"faucets": [],
"nativeCurrency": {
"name": "PepChain Churchill Ether",

View File

@ -1,16 +1,20 @@
{
"name": "Lightstreams Testnet",
"chain": "PHT",
"network": "sirius",
"rpc": ["https://node.sirius.lightstreams.io"],
"faucets": ["https://discuss.lightstreams.network/t/request-test-tokens"],
"nativeCurrency": {
"name": "Lightstreams PHT",
"symbol": "PHT",
"decimals": 18
},
"infoURL": "https://explorer.sirius.lightstreams.io",
"shortName": "tpht",
"chainId": 162,
"networkId": 162
"name": "Lightstreams Testnet",
"chain": "PHT",
"network": "sirius",
"rpc": [
"https://node.sirius.lightstreams.io"
],
"faucets": [
"https://discuss.lightstreams.network/t/request-test-tokens"
],
"nativeCurrency": {
"name": "Lightstreams PHT",
"symbol": "PHT",
"decimals": 18
},
"infoURL": "https://explorer.sirius.lightstreams.io",
"shortName": "tpht",
"chainId": 162,
"networkId": 162
}

View File

@ -2,7 +2,9 @@
"name": "Atheios",
"chain": "ATH",
"network": "mainnet",
"rpc": ["https://wallet.atheios.com:8797"],
"rpc": [
"https://wallet.atheios.com:8797"
],
"faucets": [],
"nativeCurrency": {
"name": "Atheios Ether",

View File

@ -1,16 +1,18 @@
{
"name": "Lightstreams Mainnet",
"chain": "PHT",
"network": "mainnet",
"rpc": ["https://node.mainnet.lightstreams.io"],
"faucets": [],
"nativeCurrency": {
"name": "Lightstreams PHT",
"symbol": "PHT",
"decimals": 18
},
"infoURL": "https://explorer.lightstreams.io",
"shortName": "pht",
"chainId": 163,
"networkId": 163
"name": "Lightstreams Mainnet",
"chain": "PHT",
"network": "mainnet",
"rpc": [
"https://node.mainnet.lightstreams.io"
],
"faucets": [],
"nativeCurrency": {
"name": "Lightstreams PHT",
"symbol": "PHT",
"decimals": 18
},
"infoURL": "https://explorer.lightstreams.io",
"shortName": "pht",
"chainId": 163,
"networkId": 163
}

View File

@ -2,8 +2,12 @@
"name": "ThunderCore Testnet",
"chain": "TST",
"network": "testnet",
"rpc": ["https://testnet-rpc.thundercore.com"],
"faucets": ["https://faucet-testnet.thundercore.com"],
"rpc": [
"https://testnet-rpc.thundercore.com"
],
"faucets": [
"https://faucet-testnet.thundercore.com"
],
"nativeCurrency": {
"name": "ThunderCore Testnet Ether",
"symbol": "TST",

View File

@ -2,7 +2,9 @@
"name": "IOLite",
"chain": "ILT",
"network": "mainnet",
"rpc": ["https://net.iolite.io"],
"rpc": [
"https://net.iolite.io"
],
"faucets": [],
"nativeCurrency": {
"name": "IOLite Ether",

View File

@ -2,7 +2,9 @@
"name": "Teslafunds",
"chain": "TSF",
"network": "mainnet",
"rpc": ["https://tsfapi.europool.me"],
"rpc": [
"https://tsfapi.europool.me"
],
"faucets": [],
"nativeCurrency": {
"name": "Teslafunds Ether",

View File

@ -2,7 +2,9 @@
"name": "EtherGem",
"chain": "EGEM",
"network": "mainnet",
"rpc": ["https://jsonrpc.egem.io/custom"],
"rpc": [
"https://jsonrpc.egem.io/custom"
],
"faucets": [],
"nativeCurrency": {
"name": "EtherGem Ether",

View File

@ -2,7 +2,9 @@
"name": "Expanse Network",
"chain": "EXP",
"network": "mainnet",
"rpc": ["https://node.expanse.tech"],
"rpc": [
"https://node.expanse.tech"
],
"faucets": [],
"nativeCurrency": {
"name": "Expanse Network Ether",

View File

@ -2,7 +2,9 @@
"name": "Akaroma",
"chain": "AKA",
"network": "mainnet",
"rpc": ["https://remote.akroma.io"],
"rpc": [
"https://remote.akroma.io"
],
"faucets": [],
"nativeCurrency": {
"name": "Akaroma Ether",

View File

@ -2,7 +2,9 @@
"name": "Webchain",
"chain": "WEB",
"network": "mainnet",
"rpc": ["https://node1.webchain.network"],
"rpc": [
"https://node1.webchain.network"
],
"faucets": [],
"nativeCurrency": {
"name": "Webchain Ether",

View File

@ -2,7 +2,9 @@
"name": "ARTIS sigma1",
"chain": "ARTIS",
"network": "sigma1",
"rpc": ["https://rpc.sigma1.artis.network"],
"rpc": [
"https://rpc.sigma1.artis.network"
],
"faucets": [],
"nativeCurrency": {
"name": "ARTIS sigma1 Ether",

View File

@ -2,7 +2,9 @@
"name": "ARTIS tau1",
"chain": "ARTIS",
"network": "tau1",
"rpc": ["https://rpc.tau1.artis.network"],
"rpc": [
"https://rpc.tau1.artis.network"
],
"faucets": [],
"nativeCurrency": {
"name": "ARTIS tau1 Ether",

View File

@ -2,7 +2,9 @@
"name": "High Performance Blockchain",
"chain": "HPB",
"network": "mainnet",
"rpc": ["https://node.hpb.blue"],
"rpc": [
"https://node.hpb.blue"
],
"faucets": [],
"nativeCurrency": {
"name": "High Performance Blockchain Ether",

View File

@ -2,7 +2,9 @@
"name": "Auxilium Network Mainnet",
"chain": "AUX",
"network": "mainnet",
"rpc": ["https://rpc.auxilium.global"],
"rpc": [
"https://rpc.auxilium.global"
],
"faucets": [],
"nativeCurrency": {
"name": "Auxilium coin",
@ -13,4 +15,4 @@
"shortName": "aux",
"chainId": 28945486,
"networkId": 28945486
}
}

View File

@ -2,8 +2,12 @@
"name": "Ethereum Testnet Ropsten",
"chain": "ETH",
"network": "ropsten",
"rpc": ["https://ropsten.infura.io/v3/${INFURA_API_KEY}"],
"faucets": ["https://faucet.ropsten.be?${ADDRESS}"],
"rpc": [
"https://ropsten.infura.io/v3/${INFURA_API_KEY}"
],
"faucets": [
"https://faucet.ropsten.be?${ADDRESS}"
],
"nativeCurrency": {
"name": "Ropsten Ether",
"symbol": "ROP",

View File

@ -2,7 +2,10 @@
"name": "RSK Mainnet",
"chain": "RSK",
"network": "mainnet",
"rpc": ["https://public-node.rsk.co", "https://mycrypto.rsk.co"],
"rpc": [
"https://public-node.rsk.co",
"https://mycrypto.rsk.co"
],
"faucets": [],
"nativeCurrency": {
"name": "RSK Mainnet Ether",
@ -12,5 +15,5 @@
"infoURL": "https://rsk.co",
"shortName": "rsk",
"chainId": 30,
"networkId": 775
"networkId": 30
}

View File

@ -2,8 +2,13 @@
"name": "RSK Testnet",
"chain": "RSK",
"network": "testnet",
"rpc": ["https://public-node.testnet.rsk.co", "https://mycrypto.testnet.rsk.co"],
"faucets": ["https://faucet.testnet.rsk.co"],
"rpc": [
"https://public-node.testnet.rsk.co",
"https://mycrypto.testnet.rsk.co"
],
"faucets": [
"https://faucet.testnet.rsk.co"
],
"nativeCurrency": {
"name": "RSK Testnet Ether",
"symbol": "TRSK",
@ -12,5 +17,5 @@
"infoURL": "https://rsk.co",
"shortName": "trsk",
"chainId": 31,
"networkId": 8052
"networkId": 31
}

View File

@ -2,7 +2,9 @@
"name": "Ethersocial Network",
"chain": "ESN",
"network": "mainnet",
"rpc": ["https://api.esn.gonspool.com"],
"rpc": [
"https://api.esn.gonspool.com"
],
"faucets": [],
"nativeCurrency": {
"name": "Ethersocial Network Ether",

View File

@ -2,7 +2,9 @@
"name": "Pirl",
"chain": "PIRL",
"network": "mainnet",
"rpc": ["https://wallrpc.pirl.io"],
"rpc": [
"https://wallrpc.pirl.io"
],
"faucets": [],
"nativeCurrency": {
"name": "Pirl Ether",

View File

@ -2,8 +2,12 @@
"name": "Lisinski",
"chain": "CRO",
"network": "mainnet",
"rpc": ["https://rpc-bitfalls1.lisinski.online"],
"faucets": ["https://pipa.lisinski.online"],
"rpc": [
"https://rpc-bitfalls1.lisinski.online"
],
"faucets": [
"https://pipa.lisinski.online"
],
"nativeCurrency": {
"name": "Lisinski Ether",
"symbol": "LISINSKI",

View File

@ -2,8 +2,12 @@
"name": "Ethereum Testnet Rinkeby",
"chain": "ETH",
"network": "rinkeby",
"rpc": ["https://rinkeby.infura.io/v3/${INFURA_API_KEY}"],
"faucets": ["https://faucet.rinkeby.io"],
"rpc": [
"https://rinkeby.infura.io/v3/${INFURA_API_KEY}"
],
"faucets": [
"https://faucet.rinkeby.io"
],
"nativeCurrency": {
"name": "Rinkeby Ether",
"symbol": "RIN",

View File

@ -2,8 +2,13 @@
"name": "Ethereum Testnet Kovan",
"chain": "ETH",
"network": "kovan",
"rpc": ["https://kovan.infura.io/v3/${INFURA_API_KEY}"],
"faucets": ["https://faucet.kovan.network", "https://gitter.im/kovan-testnet/faucet"],
"rpc": [
"https://kovan.infura.io/v3/${INFURA_API_KEY}"
],
"faucets": [
"https://faucet.kovan.network",
"https://gitter.im/kovan-testnet/faucet"
],
"nativeCurrency": {
"name": "Kovan Ether",
"symbol": "KOV",

View File

@ -2,8 +2,15 @@
"name": "Ethereum Testnet Görli",
"chain": "ETH",
"network": "goerli",
"rpc": ["https://rpc.goerli.mudit.blog/", "https://rpc.slock.it/goerli ", "https://goerli.prylabs.net/"],
"faucets": ["https://goerli-faucet.slock.it/?address=${ADDRESS}", "https://faucet.goerli.mudit.blog"],
"rpc": [
"https://rpc.goerli.mudit.blog/",
"https://rpc.slock.it/goerli ",
"https://goerli.prylabs.net/"
],
"faucets": [
"https://goerli-faucet.slock.it/?address=${ADDRESS}",
"https://faucet.goerli.mudit.blog"
],
"nativeCurrency": {
"name": "Görli Ether",
"symbol": "GOR",

View File

@ -2,7 +2,9 @@
"name": "GoChain",
"chain": "GO",
"network": "mainnet",
"rpc": ["https://rpc.gochain.io"],
"rpc": [
"https://rpc.gochain.io"
],
"faucets": [],
"nativeCurrency": {
"name": "GoChain Ether",

View File

@ -2,7 +2,9 @@
"name": "Ethereum Classic Mainnet",
"chain": "ETC",
"network": "mainnet",
"rpc": ["https://ethereumclassic.network"],
"rpc": [
"https://ethereumclassic.network"
],
"faucets": [],
"nativeCurrency": {
"name": "Ethereum Classic Ether",

View File

@ -2,8 +2,13 @@
"name": "Aquachain",
"chain": "AQUA",
"network": "mainnet",
"rpc": ["https://c.onical.org", "https://tx.aquacha.in/api"],
"faucets": ["https://aquacha.in/faucet"],
"rpc": [
"https://c.onical.org",
"https://tx.aquacha.in/api"
],
"faucets": [
"https://aquacha.in/faucet"
],
"nativeCurrency": {
"name": "Aquachain Ether",
"symbol": "AQUA",

View File

@ -2,7 +2,9 @@
"name": "Ellaism",
"chain": "ELLA",
"network": "mainnet",
"rpc": ["https://jsonrpc.ellaism.org"],
"rpc": [
"https://jsonrpc.ellaism.org"
],
"faucets": [],
"nativeCurrency": {
"name": "Ellaism Ether",
@ -12,5 +14,5 @@
"infoURL": "https://ellaism.org",
"shortName": "ella",
"chainId": 64,
"networkId": 1
"networkId": 64
}

View File

@ -2,7 +2,9 @@
"name": "Mix",
"chain": "MIX",
"network": "mainnet",
"rpc": ["https://rpc2.mix-blockchain.org:8647"],
"rpc": [
"https://rpc2.mix-blockchain.org:8647"
],
"faucets": [],
"nativeCurrency": {
"name": "Mix Ether",
@ -12,5 +14,5 @@
"infoURL": "https://mix-blockchain.org",
"shortName": "mix",
"chainId": 76,
"networkId": 1
"networkId": 76
}

View File

@ -2,8 +2,12 @@
"name": "POA Network Sokol",
"chain": "POA",
"network": "sokol",
"rpc": ["https://sokol.poa.network"],
"faucets": ["https://faucet-sokol.herokuapp.com"],
"rpc": [
"https://sokol.poa.network"
],
"faucets": [
"https://faucet-sokol.herokuapp.com"
],
"nativeCurrency": {
"name": "POA Sokol Ether",
"symbol": "POA",
@ -12,5 +16,5 @@
"infoURL": "https://poa.network",
"shortName": "poa",
"chainId": 77,
"networkId": 1
"networkId": 77
}

View File

@ -2,7 +2,9 @@
"name": "Musicoin",
"chain": "MUSIC",
"network": "mainnet",
"rpc": ["https://mewapi.musicoin.tw"],
"rpc": [
"https://mewapi.musicoin.tw"
],
"faucets": [],
"nativeCurrency": {
"name": "Musicoin",

View File

@ -2,7 +2,9 @@
"name": "Ubiq Network Mainnet",
"chain": "UBQ",
"network": "mainnet",
"rpc": ["https://pyrus2.ubiqscan.io"],
"rpc": [
"https://pyrus2.ubiqscan.io"
],
"faucets": [],
"nativeCurrency": {
"name": "Ubiq Ether",

View File

@ -2,7 +2,9 @@
"name": "Callisto Mainnet",
"chain": "CLO",
"network": "mainnet",
"rpc": ["https://clo-geth.0xinfra.com"],
"rpc": [
"https://clo-geth.0xinfra.com"
],
"faucets": [],
"nativeCurrency": {
"name": "Callisto Mainnet Ether",

View File

@ -2,7 +2,9 @@
"name": "TomoChain",
"chain": "TOMO",
"network": "mainnet",
"rpc": ["https://core.tomocoin.io"],
"rpc": [
"https://core.tomocoin.io"
],
"faucets": [],
"nativeCurrency": {
"name": "TomoChain Ether",

View File

@ -2,8 +2,13 @@
"name": "Nepal Blockchain Network",
"chain": "YETI",
"network": "mainnet",
"rpc": ["https://api.nepalblockchain.dev", "https://api.nepalblockchain.network"],
"faucets": ["https://faucet.nepalblockchain.network"],
"rpc": [
"https://api.nepalblockchain.dev",
"https://api.nepalblockchain.network"
],
"faucets": [
"https://faucet.nepalblockchain.network"
],
"nativeCurrency": {
"name": "Nepal Blockchain Network Ether",
"symbol": "YETI",

View File

@ -2,7 +2,9 @@
"name": "POA Network Core",
"chain": "POA",
"network": "core",
"rpc": ["https://core.poa.network"],
"rpc": [
"https://core.poa.network"
],
"faucets": [],
"nativeCurrency": {
"name": "POA Network Core Ether",
@ -12,5 +14,5 @@
"infoURL": "https://poa.network",
"shortName": "skl",
"chainId": 99,
"networkId": 2
"networkId": 99
}

3
script/.eslintrc Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "standard"
}

158
script/index.js Normal file
View File

@ -0,0 +1,158 @@
const fs = require('fs')
const path = require('path')
const axios = require('axios')
const BigNumber = require('bignumber.js')
require('dotenv').config()
const ROOT_DIRECTORY = path.join(__dirname, '../')
const CHAINS_DIRECTORY = path.join(ROOT_DIRECTORY, './_data/chains')
const NET_VERSION_REQ = {
id: 1,
jsonrpc: '2.0',
method: 'net_version',
params: []
}
const CHAIN_ID_REQ = {
id: 1,
jsonrpc: '2.0',
method: 'eth_chainId',
params: []
}
function formatRpcUrl (rpcUrl) {
return rpcUrl.replace(
'${INFURA_API_KEY}', // eslint-disable-line
process.env.INFURA_PROJECT_ID
)
}
async function writeJson (filePath, json) {
// console.log('Overwriting', filePath)
return new Promise((resolve, reject) => {
const data = JSON.stringify(json, null, 2)
fs.writeFile(filePath, data, (err, res) => {
if (err) {
reject(err)
}
resolve(res)
})
})
}
async function rpcRequest (rpcUrl, body) {
const response = await axios.post(rpcUrl, body, {
timeout: 20000, // 20 secs
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
})
if (!response && !response.data) {
throw new Error('No Response Body')
}
if (response.data.error && response.data.error.message) {
throw new Error(response.data.error.message)
}
return response.data.result
}
function toNumber (value) {
const BN = new BigNumber(value)
let result = null
if (!BN.isNaN()) {
result = BN.toNumber()
}
return result
}
async function getNetworkId (rpcUrl) {
try {
rpcUrl = formatRpcUrl(rpcUrl)
const result = await rpcRequest(rpcUrl, NET_VERSION_REQ)
const networkId = toNumber(result)
return networkId
} catch (error) {
return null
}
}
async function getChainId (rpcUrl) {
try {
rpcUrl = formatRpcUrl(rpcUrl)
const result = await rpcRequest(rpcUrl, CHAIN_ID_REQ)
const chainId = toNumber(result)
return chainId
} catch (error) {
return null
}
}
async function queryMulti (urls, apiCall) {
let result = null
let results = await Promise.all(
urls.map(async url => {
try {
return await apiCall(url)
} catch (error) {
return null
}
})
)
if (results && results.length) {
results = results.filter(x => !!x)
result = results[0] || null
}
return result
}
async function verifyJson (json) {
if (json.rpc && json.rpc.length) {
const chainId = await queryMulti(json.rpc, getChainId)
if (chainId) {
json.chainId = chainId
}
const networkId = await queryMulti(json.rpc, getNetworkId)
if (networkId) {
json.networkId = networkId
}
}
return json
}
fs.readdir(CHAINS_DIRECTORY, function (err, files) {
if (err) {
console.error('Could not list the directory.', err)
process.exit(1)
}
files.forEach(function (file, index) {
const filePath = path.join(CHAINS_DIRECTORY, file)
fs.stat(filePath, async function (error, stat) {
if (error) {
console.error('Error stating file.', error)
return
}
const ext = path.extname(file)
if (stat.isFile() && ext === '.json') {
let json = require(filePath)
const fileName = file.replace(ext, '')
if (toNumber(fileName)) {
json.chainId = toNumber(fileName)
}
json = await verifyJson(json)
console.log(
`${json.chain.toUpperCase()} chainId=${json.chainId} networId=${
json.networkId
}`
)
await writeJson(filePath, json)
}
})
})
})

1492
script/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

25
script/package.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "script",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.0",
"bignumber.js": "^9.0.0",
"dotenv": "^8.0.0"
},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0"
}
}