@@ -3,6 +3,7 @@ package config
3
3
import (
4
4
"context"
5
5
"encoding/json"
6
+ "errors"
6
7
"os"
7
8
"strings"
8
9
@@ -18,6 +19,8 @@ import (
18
19
19
20
const ibcPathSuffix = ".json"
20
21
22
+ var ErrGitHubClient = errors .New ("GitHub client not provided" )
23
+
21
24
type Account struct {
22
25
Address string `yaml:"address"`
23
26
Denom string `yaml:"denom"`
@@ -35,10 +38,11 @@ type Config struct {
35
38
Accounts []Account `yaml:"accounts"`
36
39
RPCs []RPC `yaml:"rpc"`
37
40
GitHub struct {
38
- Org string `yaml:"org"`
39
- Repo string `yaml:"repo"`
40
- IBCDir string `yaml:"dir"`
41
- Token string `env:"GITHUB_TOKEN"`
41
+ Org string `yaml:"org"`
42
+ Repo string `yaml:"repo"`
43
+ IBCDir string `yaml:"dir"`
44
+ TestnetsIBCDir string `yaml:"testnetsDir"`
45
+ Token string `env:"GITHUB_TOKEN"`
42
46
} `yaml:"github"`
43
47
}
44
48
@@ -74,8 +78,6 @@ func (c *Config) GetRPCsMap() *map[string]RPC {
74
78
}
75
79
76
80
func (c * Config ) IBCPaths () ([]* relayer.IBCdata , error ) {
77
- ctx := context .Background ()
78
-
79
81
client := github .NewClient (nil )
80
82
81
83
if c .GitHub .Token != "" {
@@ -84,7 +86,32 @@ func (c *Config) IBCPaths() ([]*relayer.IBCdata, error) {
84
86
client = github .NewClient (nil ).WithAuthToken (c .GitHub .Token )
85
87
}
86
88
87
- _ , ibcDir , _ , err := client .Repositories .GetContents (ctx , c .GitHub .Org , c .GitHub .Repo , c .GitHub .IBCDir , nil )
89
+ paths , err := c .getPaths (c .GitHub .IBCDir , client )
90
+ if err != nil {
91
+ return nil , err
92
+ }
93
+
94
+ testnetsPaths := []* relayer.IBCdata {}
95
+ if c .GitHub .TestnetsIBCDir != "" {
96
+ testnetsPaths , err = c .getPaths (c .GitHub .TestnetsIBCDir , client )
97
+ if err != nil {
98
+ return nil , err
99
+ }
100
+ }
101
+
102
+ paths = append (paths , testnetsPaths ... )
103
+
104
+ return paths , nil
105
+ }
106
+
107
+ func (c * Config ) getPaths (dir string , client * github.Client ) ([]* relayer.IBCdata , error ) {
108
+ if client == nil {
109
+ return nil , ErrGitHubClient
110
+ }
111
+
112
+ ctx := context .Background ()
113
+
114
+ _ , ibcDir , _ , err := client .Repositories .GetContents (ctx , c .GitHub .Org , c .GitHub .Repo , dir , nil )
88
115
if err != nil {
89
116
return nil , err
90
117
}
0 commit comments