forked from binaryholdings/tenderseed
-
Notifications
You must be signed in to change notification settings - Fork 16
/
registry.go
54 lines (43 loc) · 920 Bytes
/
registry.go
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
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
// getchains() gets the list of chains from the chain registry
func GetChains() Chains {
resp, err := http.Get("https://cosmos-chain.directory/chains")
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
}
var chains Chains
err = json.Unmarshal([]byte(body), &chains)
if err != nil {
fmt.Println(err)
}
return chains
}
// getchain() gets one chain's records from the chain registry
func GetChain(chainid string) Chain {
resp, err := http.Get("https://cosmos-chain.directory/chains/" + chainid)
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
}
var chain Chain
err = json.Unmarshal([]byte(body), &chain)
if err != nil {
fmt.Println(err)
}
return chain
}