-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.js
69 lines (61 loc) · 2.05 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { assets, chains } from 'chain-registry'
import fetch from 'node-fetch'
import fs from 'fs'
var finalData = []
async function getLcd(chain) {
let finder = chains.find(
({chain_name}) => chain_name === chain
)
let finalLcd = ''
if (typeof finder !== 'undefined' && typeof finder.apis !== 'undefined') {
for (const lcds of finder.apis.rest) {
try {
const response = await fetch(lcds.address + '/node_info')
if (response.status == 200) {
finalLcd = lcds.address
break
}
} catch (err) {
console.error(err)
}
}
}
return finalLcd
}
async function getRpc(chain) {
let finder = chains.find(
({chain_name}) => chain_name === chain
)
let finalRpc = ''
if (typeof finder !== 'undefined' && typeof finder.apis !== 'undefined') {
for (const rpcs of finder.apis.rpc) {
try {
const response = await fetch(rpcs.address)
if (response.status == 200) {
finalRpc = rpcs.address
break
}
} catch (err) {
console.error(err)
}
}
}
return finalRpc
}
var content = ''
var datetime = new Date();
content += `Last update: ` + datetime + `
`
var chainsToCheck = ['cosmoshub', 'bitcanna', 'osmosis', 'desmos', 'chihuahua', 'juno', 'stargaze', 'akash', 'axelar', 'kichain', 'kujira', 'meme', 'passage', 'persistence', 'secretnetwork', 'gravitybridge', 'emoney', 'dig', 'bitsong', 'cheqd']
chainsToCheck.forEach(async function(item) {
const assetList = assets.find(({chain_name}) => chain_name === item)
var lcd = await getLcd(item)
var rpc = await getRpc(item)
content += `### <img alt="`+item+`" src="`+assetList.assets[0].logo_URIs.png+`" width="30" height="30"> ` + item + `
`
content += `  LCD :green_circle: ` + lcd + `
`
content += `  RPC :green_circle: ` + rpc + `
`
fs.writeFileSync("README.md", content)
})