Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix and refactor gex app #81

Merged
merged 20 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: actions/setup-go@v5
if: env.GIT_DIFF
with:
go-version: '1.21'
go-version: 'stable'

- name: Run Lint Tests
if: env.GIT_DIFF
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- uses: actions/setup-go@v5
if: env.GIT_DIFF
with:
go-version: '1.21'
go-version: 'stable'

- name: Run Unit Tests
if: env.GIT_DIFF
Expand Down
6 changes: 6 additions & 0 deletions explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Explorer App Changelog

## [`v0.3.0`](https://github.com/ignite/apps/releases/tag/explorer/v0.3.0)

* The Gex app was not working when we passed a custom RPC address.
Pantani marked this conversation as resolved.
Show resolved Hide resolved
* Add gex integration tests.
* Use `ignite/gex@v1.0.0` instead `cosmos/gex`.

## [`v0.2.0`](https://github.com/ignite/apps/releases/tag/explorer/v0.2.0)

* Update app to support gRPC.
Expand Down
14 changes: 12 additions & 2 deletions explorer/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package cmd

import "github.com/ignite/cli/v28/ignite/services/plugin"

const flagRPCAddress = "rpc-address"

// GetCommands returns the list of explorer app commands.
func GetCommands() []*plugin.Command {
return []*plugin.Command{
Expand All @@ -11,9 +13,17 @@ func GetCommands() []*plugin.Command {
Aliases: []string{"e"},
Commands: []*plugin.Command{
{
Use: "gex [rpc_url]",
Short: "Run gex",
Use: "gex",
Short: "Run gex explorer",
Aliases: []string{"g"},
Flags: []*plugin.Flag{
{
Name: flagRPCAddress,
Usage: "The chain RPC address",
DefaultValue: "http://localhost:26657",
Type: plugin.FlagTypeString,
},
},
},
},
},
Expand Down
44 changes: 12 additions & 32 deletions explorer/cmd/gex.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,29 @@ package cmd

import (
"context"
"net/url"
"os"

"github.com/ignite/cli/v28/ignite/pkg/errors"
"github.com/ignite/cli/v28/ignite/services/plugin"

"github.com/ignite/apps/explorer/gex"
"github.com/ignite/gex/pkg/xurl"
"github.com/ignite/gex/services/explorer"
)

const maxNumArgs = 1

// ExecuteGex executes explorer gex subcommand.
func ExecuteGex(ctx context.Context, cmd *plugin.ExecutedCommand) error {
argc := len(cmd.Args)
if argc > maxNumArgs {
return errors.Errorf("accepts at most %d arg(s), received %d", maxNumArgs, argc)
flags, err := cmd.NewFlags()
if err != nil {
return err
}

ssl := false
host := "localhost"
port := "26657"

if argc == 1 {
rpcURL, err := url.Parse(cmd.Args[0])
if err != nil {
return errors.Wrapf(err, "failed to parse RPC URL %s", cmd.Args[0])
}

ssl = rpcURL.Scheme == "https"
host = rpcURL.Hostname()
port = rpcURL.Port()
if port == "" {
if ssl {
port = "443"
} else {
port = "80"
}
}
rpcAddress, err := flags.GetString(flagRPCAddress)
if err != nil {
return errors.Errorf("could not get --%s flag: %s", flagRPCAddress, err)
}

g, err := gex.New()
hostURL, err := xurl.Parse(rpcAddress)
if err != nil {
return errors.Wrap(err, "failed to initialize Gex")
return err
}
return g.Run(ctx, os.Stdout, os.Stderr, host, port, ssl)

return explorer.Run(ctx, hostURL.String())
}
75 changes: 0 additions & 75 deletions explorer/gex/gex.go

This file was deleted.

34 changes: 18 additions & 16 deletions explorer/go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/ignite/apps/explorer

go 1.21.1
go 1.22.2
Pantani marked this conversation as resolved.
Show resolved Hide resolved

require (
github.com/hashicorp/go-plugin v1.6.0
github.com/ignite/cli/v28 v28.3.0
github.com/ignite/ignite-files/gex v0.0.1
github.com/ignite/gex v1.0.0
github.com/stretchr/testify v1.9.0
)

Expand All @@ -27,7 +27,7 @@ require (
github.com/DataDog/zstd v1.5.5 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymanbagabas/go-osc52 v1.2.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
Expand All @@ -54,6 +54,8 @@ require (
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.4.11 // indirect
github.com/cosmos/iavl v1.0.1 // indirect
github.com/cosmos/ibc-go/modules/capability v1.0.0 // indirect
github.com/cosmos/ibc-go/v8 v8.1.1 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
Expand All @@ -68,7 +70,7 @@ require (
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/emicklei/dot v1.6.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand Down Expand Up @@ -132,17 +134,18 @@ require (
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/microcosm-cc/bluemonday v1.0.23 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.1 // indirect
github.com/muesli/termenv v0.14.0 // indirect
github.com/mum4k/termdash v0.20.0 // indirect
github.com/nsf/termbox-go v1.1.1 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/onsi/gomega v1.28.1 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -151,9 +154,8 @@ require (
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.47.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/radovskyb/watcher v1.0.7 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/rs/zerolog v1.32.0 // indirect
Expand All @@ -180,15 +182,15 @@ require (
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.18.0 // indirect
golang.org/x/tools v0.19.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect
Expand Down
Loading
Loading