Skip to content

Commit

Permalink
revise router
Browse files Browse the repository at this point in the history
  • Loading branch information
keefertaylor committed Dec 12, 2023
1 parent 4613a4e commit ab54f70
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
32 changes: 32 additions & 0 deletions file/config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package file

import (
"fmt"
"os"

"github.com/tessellated-io/pickaxe/config"

Check failure on line 7 in file/config.go

View workflow job for this annotation

GitHub Actions / build router

missing go.sum entry for module providing package github.com/tessellated-io/pickaxe/config (imported by github.com/tessellated-io/router/file); to add:
"github.com/tessellated-io/pickaxe/log"

Check failure on line 8 in file/config.go

View workflow job for this annotation

GitHub Actions / build router

missing go.sum entry for module providing package github.com/tessellated-io/pickaxe/log (imported by github.com/tessellated-io/router/file); to add:
"gopkg.in/yaml.v2"
)

Expand Down Expand Up @@ -30,3 +33,32 @@ func parseConfig(filename string) (*Config, error) {

return config, nil
}

// Write an example config file.
func InitializeConfigFile(filename string, configurationDirectory string, logger *log.Logger) error {
networks := []NetworkConfig{
NetworkConfig{
ChainID: "cosmoshub-4",
GrpcEndpoint: "tcp://cosmos.rpc.directory",
},
NetworkConfig{
ChainID: "osmosis-1",
GrpcEndpoint: "tcp://osmosis.rpc.directory",
},
}

routerConfig := Config{
Networks: networks,
}

// Create folder if needed
config.CreateDirectoryIfNeeded(configurationDirectory, logger)

routerConfigFile := fmt.Sprintf("%s/%s", configurationDirectory, filename)
header := "This is a file to route chain IDs to RPC endpoints\n"
err := config.WriteYamlWithComments(routerConfig, header, routerConfigFile, logger)
if err != nil {
return err
}
return nil
}
9 changes: 8 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ module github.com/tessellated-io/router
go 1.20

require (
github.com/tessellated-io/pickaxe v1.0.11
github.com/tessellated-io/pickaxe v1.0.14
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/rs/zerolog v1.29.1 // indirect
golang.org/x/sys v0.10.0 // indirect
)
21 changes: 19 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc=
github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/tessellated-io/pickaxe v1.0.11 h1:gaQVdYh+DMSE1tXA44JCunwmQnXeplblp2HQFowiNaE=
github.com/tessellated-io/pickaxe v1.0.11/go.mod h1:wO7zNwLt2PbwH5C9j+p/KM+4I6K4zXY7rrq1567CPJE=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
Expand Down

0 comments on commit ab54f70

Please sign in to comment.