Skip to content

feat: add GetIgniteInfo gRPC API for apps #4659

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

Merged
merged 10 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all 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 buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ modules:
name: buf.build/ignitehq/cli
lint:
use:
- DEFAULT
- STANDARD
- FILE_LOWER_SNAKE_CASE
except:
- COMMENT_FIELD
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- [#4509](https://github.com/ignite/cli/pull/4509) Upgrade to Go 1.24. Running `ignite doctor` migrates the scaffolded `tools.go` to the tool directive in the go.mod
- [#4588](https://github.com/ignite/cli/pull/4588) Run `buf format after scaffold proto files.
- [#4603](https://github.com/ignite/cli/issues/4603) Add `GetIgniteInfo` gRPC API for apps.
- [#4657](https://github.com/ignite/cli/pull/4657) Upgrade to Cosmos SDK [v0.53.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.53.0).
- Add x/epochs module to default template (except for minimal template).
- Bump minimum compatible Cosmos SDK version to `v0.50.0`.
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ require (
golang.org/x/sync v0.13.0
golang.org/x/term v0.31.0
golang.org/x/text v0.24.0
golang.org/x/tools v0.31.0
google.golang.org/grpc v1.72.0
google.golang.org/protobuf v1.36.6
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -294,7 +295,7 @@ require (
github.com/jdx/go-netrc v1.0.0 // indirect
github.com/jgautheron/goconst v1.7.1 // indirect
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/jinzhu/copier v0.4.0 // indirect
github.com/jjti/go-spancheck v0.6.4 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down Expand Up @@ -439,7 +440,7 @@ require (
github.com/uudashr/gocognit v1.2.0 // indirect
github.com/uudashr/iface v1.3.1 // indirect
github.com/vbatts/tar-split v0.11.6 // indirect
github.com/vektra/mockery/v2 v2.46.0 // indirect
github.com/vektra/mockery/v2 v2.53.3 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xen0n/gosmopolitan v1.2.2 // indirect
github.com/yagipy/maintidx v1.0.0 // indirect
Expand Down Expand Up @@ -476,7 +477,6 @@ require (
golang.org/x/net v0.39.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/telemetry v0.0.0-20241106142447-58a1122356f5 // indirect
golang.org/x/tools v0.31.0 // indirect
golang.org/x/vuln v1.1.4 // indirect
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,8 @@ github.com/jhump/protoreflect/v2 v2.0.0-beta.2 h1:qZU+rEZUOYTz1Bnhi3xbwn+VxdXkLV
github.com/jhump/protoreflect/v2 v2.0.0-beta.2/go.mod h1:4tnOYkB/mq7QTyS3YKtVtNrJv4Psqout8HA1U+hZtgM=
github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs=
github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c=
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jjti/go-spancheck v0.6.4 h1:Tl7gQpYf4/TMU7AT84MN83/6PutY21Nb9fuQjFTpRRc=
github.com/jjti/go-spancheck v0.6.4/go.mod h1:yAEYdKJ2lRkDA8g7X+oKUHXOWVAXSBJRv04OhF+QUjk=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
Expand Down Expand Up @@ -1730,8 +1730,8 @@ github.com/uudashr/iface v1.3.1 h1:bA51vmVx1UIhiIsQFSNq6GZ6VPTk3WNMZgRiCe9R29U=
github.com/uudashr/iface v1.3.1/go.mod h1:4QvspiRd3JLPAEXBQ9AiZpLbJlrWWgRChOKDJEuQTdg=
github.com/vbatts/tar-split v0.11.6 h1:4SjTW5+PU11n6fZenf2IPoV8/tz3AaYHMWjf23envGs=
github.com/vbatts/tar-split v0.11.6/go.mod h1:dqKNtesIOr2j2Qv3W/cHjnvk9I8+G7oAkFDFN6TCBEI=
github.com/vektra/mockery/v2 v2.46.0 h1:DKIFj6hAPGwmOYiWfWzdsQtBgU8ozPXo3Bwbmf+Ku80=
github.com/vektra/mockery/v2 v2.46.0/go.mod h1:XNTE9RIu3deGAGQRVjP1VZxGpQNm0YedZx4oDs3prr8=
github.com/vektra/mockery/v2 v2.53.3 h1:yBU8XrzntcZdcNRRv+At0anXgSaFtgkyVUNm3f4an3U=
github.com/vektra/mockery/v2 v2.53.3/go.mod h1:hIFFb3CvzPdDJJiU7J4zLRblUMv7OuezWsHPmswriwo=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU=
Expand Down
10 changes: 6 additions & 4 deletions ignite/internal/plugin/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ func TestPluginExecute(t *testing.T) {
expectedError: "local app path \"/not/exists\" not found: stat /not/exists: no such file or directory",
},
{
name: "ok: plugin execute ok",
pluginPath: "testdata/execute_ok",
expectedOutput: "ok args=[arg1 arg2] chainid=id appPath=apppath configPath=configpath home=home rpcAddress=rpcPublicAddress\n",
name: "ok: plugin execute ok",
pluginPath: "testdata/execute_ok",
expectedOutput: `ok args=\[arg1 arg2\] chainid=id appPath=apppath configPath=configpath home=home rpcAddress=rpcPublicAddress
ok args=\[arg1 arg2\] cliVersion=.* goVersion=.* sdkVersion=.* bufVersion=.* buildDate=.* sourceHash=.* configVersion=.* os=.* arch=.* buildFromSource=.*
`,
},
{
name: "ok: plugin execute fail",
Expand Down Expand Up @@ -64,7 +66,7 @@ func TestPluginExecute(t *testing.T) {
return
}
require.NoError(t, err)
require.Equal(t, tt.expectedOutput, out)
require.Regexp(t, tt.expectedOutput, out)
})
}
}
24 changes: 19 additions & 5 deletions ignite/internal/plugin/testdata/execute_ok/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,44 @@ import (

type app struct{}

func (app) Manifest(ctx context.Context) (*plugin.Manifest, error) {
func (app) Manifest(context.Context) (*plugin.Manifest, error) {
return &plugin.Manifest{
Name: "execute_ok",
}, nil
}

func (app) Execute(ctx context.Context, cmd *plugin.ExecutedCommand, api plugin.ClientAPI) error {
c, _ := api.GetChainInfo(ctx)
c, err := api.GetChainInfo(ctx)
fmt.Printf(
"ok args=%s chainid=%s appPath=%s configPath=%s home=%s rpcAddress=%s\n",
cmd.Args, c.ChainId, c.AppPath, c.ConfigPath, c.Home, c.RpcAddress,
)
if err != nil {
return fmt.Errorf("failed to get chain info: %w", err)
}

i, err := api.GetIgniteInfo(ctx)
fmt.Printf(
"ok args=%s cliVersion=%s goVersion=%s sdkVersion=%s bufVersion=%s buildDate=%s "+
"sourceHash=%s configVersion=%s os=%s arch=%s buildFromSource=%t\n",
cmd.Args, i.CliVersion, i.GoVersion, i.SdkVersion, i.BufVersion, i.BuildDate, i.SourceHash, i.ConfigVersion,
i.Os, i.Arch, i.BuildFromSource,
)
if err != nil {
return fmt.Errorf("failed to get ignite info: %w", err)
}
return nil
}

func (app) ExecuteHookPre(ctx context.Context, h *plugin.ExecutedHook, api plugin.ClientAPI) error {
func (app) ExecuteHookPre(context.Context, *plugin.ExecutedHook, plugin.ClientAPI) error {
return nil
}

func (app) ExecuteHookPost(ctx context.Context, h *plugin.ExecutedHook, api plugin.ClientAPI) error {
func (app) ExecuteHookPost(context.Context, *plugin.ExecutedHook, plugin.ClientAPI) error {
return nil
}

func (app) ExecuteHookCleanUp(ctx context.Context, h *plugin.ExecutedHook, api plugin.ClientAPI) error {
func (app) ExecuteHookCleanUp(context.Context, *plugin.ExecutedHook, plugin.ClientAPI) error {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions ignite/pkg/cosmosclient/cosmosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ type FaucetClient interface {
Transfer(context.Context, cosmosfaucet.TransferRequest) (cosmosfaucet.TransferResponse, error)
}

// Gasometer allows to mock the tx.CalculateGas func.
// Gasometer allows mocking the tx.CalculateGas func.
//
//go:generate mockery --srcpkg . --name Gasometer --filename gasometer.go --with-expecter
type Gasometer interface {
CalculateGas(clientCtx gogogrpc.ClientConn, txf tx.Factory, msgs ...sdktypes.Msg) (*txtypes.SimulateResponse, uint64, error)
}

// Signer allows to mock the tx.Sign func.
// Signer allows mocking the tx.Sign func.
//
//go:generate mockery --srcpkg . --name Signer --filename signer.go --with-expecter
type Signer interface {
Expand Down
2 changes: 1 addition & 1 deletion ignite/pkg/cosmosclient/mocks/account_retriever.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ignite/pkg/cosmosclient/mocks/bank_query_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ignite/pkg/cosmosclient/mocks/faucet_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions ignite/pkg/cosmosclient/mocks/rpc_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ignite/pkg/cosmosclient/mocks/signer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ignite/pkg/cosmostxcollector/mocks/saver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ignite/pkg/cosmostxcollector/mocks/txs_collector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions ignite/services/plugin/client_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/version"
)

// ErrAppChainNotFound indicates that the plugin command is not running inside a blockchain app.
Expand Down Expand Up @@ -90,3 +91,23 @@ func (api clientAPI) getChain() (Chainer, error) {
}
return api.o.chain, nil
}

func (api clientAPI) GetIgniteInfo(ctx context.Context) (*IgniteInfo, error) {
info, err := version.GetInfo(ctx)
if err != nil {
return nil, err
}

return &IgniteInfo{
CliVersion: info.CLIVersion,
GoVersion: info.GoVersion,
SdkVersion: info.SDKVersion,
BufVersion: info.BufVersion,
BuildDate: info.BuildDate,
SourceHash: info.SourceHash,
ConfigVersion: info.ConfigVersion,
Os: info.OS,
Arch: info.Arch,
BuildFromSource: info.BuildFromSource,
}, nil
}
Loading