Skip to content

Commit

Permalink
feat: change app.go to v2 and add AppWiring feature (#3553)
Browse files Browse the repository at this point in the history
* build buf pkg

* fix go.mod

* comment xbug pkg and bump buf versions

* generate proto from buf and remove protoc and plugins

* add proto ts and api generation

* add changelog

* fix proto and template path

* fix wrong template for ts generation

* fix api out path

* fix ts out path and remove unused log

* fix go.mod ident and sort

* remove unused method

* fix lint

* fix wrong lint comment

* remove unused tools

* fix doctor for tools pkg

* add missing tool dependency

* add missing import

* add global protoanalysis.NewCache to buf structure

* fix proto module name

* update go.mod

* Update ignite/pkg/cosmosgen/generate_go.go method name

Co-authored-by: Jerónimo Albi <[email protected]>

* Update ignite/pkg/buf/buf.go remove unused ctx

Co-authored-by: Jerónimo Albi <[email protected]>

* fix wrong method call

* fix deep tools

* fix ignite doctor

* fix buf.gen files

* fix proto gen files

* remove 3thrparty  mod

* thr modules openapi

* add xos copy commands

* fix wrong proto tmp path

* remove unused method

* update tools for the doctor command

* unhlanded error

* check if the buf files exists

* remove unused ctx

* fix changelog merge

* fix unit tests and make more dynamic

* add support for new app.go v2

* remove chain warnings from logs

* use custom buffer instead bytes.buffer

* Update changelog

Co-authored-by: İlker G. Öztürk <[email protected]>

* inject custom module

* fix ts script generation and remove pulsar buf files

* remove params from module and bump sdk and ibc

* app.go v2

* add changelog

* add pulsar protobuf support

* fix changelog

* fix changelog

* add msg update params

* update change log

* add custom parameters

* remove upgrade handlers

* remove the keeper as a pointer

* add custom parameters default keys

* add pulsar module config to appconfig and fix import not exist for module v1

* add missing placeholder and remove unused replacer parameter

* remove unused placeholders

* remove unused placeholders

* add missing imports for IBC modules

* add ibc to app.go

* fix changelog

* fix ibc templates for appwiring

* inject ibc keepers

* remove warning

* ADD IBC TO GOV ROUTE KEEPER

* fix ibckeeper injection

* fix testutil for ibc module

* update goversion

* update lint version

* fix goversion

* downgrade lint version

* add pulsar to the tools file

* fix tests for app.go implementations

* fix doctor command

* update lint

* use sdkerrors codes

* use deprecated sdkerrors

* add migration for scaffold and generate commands

* fix pre handler

* fix rance condition

* fix wrong app path for tools migrations

* rollback lint version

* fix lint

* rollback draft changes

* fix ineffassign lint

* fix wrong path

* fix deprecated rand seed

* remove unused code

* assert simulation app name

* decrease the size of the test chain name

* fix setup msg server keeper

* fix wrong keeper name

* exclude module.proto from go proto generation

* fix wrong keeper arg pointer

* fix missing sdk import

* fix wrong imports

* fix missing import

* move buf pkg to cosmosbuf

* fix doctor tools test

* fix dependencie bank perm

* add default expected keepers

* create generate proto-pulsar commands

* bump ibc-go

* remove unused module

* replace cosmossdk.io/simapp/params to github.com/cosmos/cosmos-sdk/types/module/testutil

* remove unused workaround

* fix relative path for appPath

* use default rand

* rollback checkBufFiles method

* set params for testutil

* use short name for integrastion test modules

* change slashing keep interface to avoid conflict with the staking keeper

* fix tx module name for intagration tests

* remove some typos

* update buf version

* exclude module.proto file to generate ts

* refactor: validate SDK version and deprecate `sdkerrors.Wrap` (#3602)

* feat: change scaffold commands to validate supported SDK version

Validation was added to pre run handler to avoid applying buff or other
migrations when the app is using an older SDK version.

* refactor: fix deprecated `sdkerrors.Wrap` calls in app templates

* fix: correct app path in scaffold pre run handler

* fix: correct app template imports for SDK errors

* fix: correct `errorsmod.Wrapf` error wrapping argument

* test: increased integration test timeout to 20m

---------

Co-authored-by: Jerónimo Albi <[email protected]>
Co-authored-by: İlker G. Öztürk <[email protected]>
Co-authored-by: Danilo Pantani <[email protected]>
Co-authored-by: Pantani <Pantani>
  • Loading branch information
4 people committed Aug 17, 2023
1 parent 0891ffe commit 7d54608
Show file tree
Hide file tree
Showing 146 changed files with 3,612 additions and 1,925 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gen-docs-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: '1.20'

- name: Generate CLI Docs
run: ./scripts/gen-cli-docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: '1.20'

- name: Run make format
run: make format
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: '1.20'

- name: Checkout
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- uses: actions/setup-go@v4
if: env.GIT_DIFF
with:
go-version: 1.19
go-version: '1.20'
- name: Run Integration Tests
if: env.GIT_DIFF
run: GOSUMDB=off go test -v -timeout 120m ./integration/${{ matrix.test-path }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: actions/setup-go@v4
if: env.GIT_DIFF
with:
go-version: 1.19
go-version: '1.20'
cache: true
cache-dependency-path: go.sum

Expand Down
2 changes: 1 addition & 1 deletion .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM gitpod/workspace-full

# Go
ENV GO_VERSION=1.19.3
ENV GO_VERSION=1.20.5
ENV GOPATH=$HOME/go-packages
ENV GOROOT=$HOME/go
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## prep the base image.
#
FROM golang:1.19 as base
FROM golang:1.20 as base

RUN apt update && \
apt-get install -y \
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
### Features

- [#3476](https://github.com/ignite/cli/pull/3476) Use `buf.build` binary to code generate from proto files
- [#3536](https://github.com/ignite/cli/pull/3536) Change app.go to v2 and add AppWiring feature

### Changes

- [#3559](https://github.com/ignite/cli/pull/3559) Bump network plugin version to `v0.1.1`

### Changes

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/03-clients/01-go-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ To import dependencies for your package, you can add the following code to the
```text title="blogclient/go.mod"
module blogclient
go 1.19
go 1.20
require (
blog v0.0.0-00010101000000-000000000000
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/03-clients/03-vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ properly interact with a Cosmos chain. The address prefix is used to identify
the chain that the app is connected to, and must match the prefix used by the
chain.

By default, Ignite creates a chain with the the `cosmos` prefix. If you have
By default, Ignite creates a chain with the `cosmos` prefix. If you have
created your chain with `ignite scaffold chain ... --adddress-prefix foo` or
manually changed the prefix in the source code of the chain, you need to set the
prefix in the Vue app.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/04-network/02-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ anyone can be a coordinator or a validator.

## Launching a chain on Ignite

Launching with the CLI can be as simple as a few short commands with the the CLI using `ignite network` command
Launching with the CLI can be as simple as a few short commands with the CLI using `ignite network` command
namespace.

> **NOTE:** `ignite n` can also be used as a shortcut for `ignite network`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ In the newly scaffolded `x/blog/keeper/msg_server_create_comment.go` file, you c
You need to do the following things:

* Create a variable of type `Comment` with title and body from the message
* Check if the the comment posted for the respective blog id exists and comment is not older than 100 blocks
* Check if the comment posted for the respective blog id exists and comment is not older than 100 blocks
* Append this `Comment` to the store

```go
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (k msgServer) RevealSolution(goCtx context.Context, msg *types.MsgRevealSol
// convert the hash to a string
var solutionScavengerHashString = hex.EncodeToString(solutionScavengerHash[:])

// try getting a commit using the the hash of solution and address
// try getting a commit using the hash of solution and address
_, isFound := k.GetCommit(ctx, solutionScavengerHashString)

// return an error if a commit doesn't exist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To launch a Cosmos blockchain you need someone to be a coordinator and others to

## Launching a chain on Ignite

Launching with the CLI can be as simple as a few short commands with the the CLI using `ignite network` command namespace.
Launching with the CLI can be as simple as a few short commands with the CLI using `ignite network` command namespace.

> **NOTE:** `ignite n` can also be used as a shortcut for `ignite network`.
Expand Down
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-v0.26.1/03-clients/03-vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ properly interact with a Cosmos chain. The address prefix is used to identify
the chain that the app is connected to, and must match the prefix used by the
chain.

By default, Ignite creates a chain with the the `cosmos` prefix. If you have
By default, Ignite creates a chain with the `cosmos` prefix. If you have
created your chain with `ignite scaffold chain ... --adddress-prefix foo` or
manually changed the prefix in the source code of the chain, you need to set the
prefix in the Vue app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ anyone can be a coordinator or a validator.

## Launching a chain on Ignite

Launching with the CLI can be as simple as a few short commands with the the CLI using `ignite network` command
Launching with the CLI can be as simple as a few short commands with the CLI using `ignite network` command
namespace.

> **NOTE:** `ignite n` can also be used as a shortcut for `ignite network`.
Expand Down
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-v0.27.1/03-clients/03-vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ properly interact with a Cosmos chain. The address prefix is used to identify
the chain that the app is connected to, and must match the prefix used by the
chain.

By default, Ignite creates a chain with the the `cosmos` prefix. If you have
By default, Ignite creates a chain with the `cosmos` prefix. If you have
created your chain with `ignite scaffold chain ... --adddress-prefix foo` or
manually changed the prefix in the source code of the chain, you need to set the
prefix in the Vue app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ anyone can be a coordinator or a validator.

## Launching a chain on Ignite

Launching with the CLI can be as simple as a few short commands with the the CLI using `ignite network` command
Launching with the CLI can be as simple as a few short commands with the CLI using `ignite network` command
namespace.

> **NOTE:** `ignite n` can also be used as a shortcut for `ignite network`.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ignite/cli

go 1.19
go 1.20

require (
cosmossdk.io/math v1.0.1
Expand Down
1 change: 1 addition & 0 deletions ignite/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ meant to be edited by hand.
flagSetPath(c)
flagSetClearCache(c)
c.AddCommand(NewGenerateGo())
c.AddCommand(NewGeneratePulsar())
c.AddCommand(NewGenerateTSClient())
c.AddCommand(NewGenerateVuex())
c.AddCommand(NewGenerateComposables())
Expand Down
47 changes: 47 additions & 0 deletions ignite/cmd/generate_pulsar.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package ignitecmd

import (
"github.com/spf13/cobra"

"github.com/ignite/cli/ignite/pkg/cliui"
"github.com/ignite/cli/ignite/pkg/cliui/icons"
"github.com/ignite/cli/ignite/services/chain"
)

func NewGeneratePulsar() *cobra.Command {
c := &cobra.Command{
Use: "proto-pulsar",
Short: "Compile protocol buffer files to Go pulsar source code required by Cosmos SDK",
RunE: generatePulsarHandler,
}

c.Flags().AddFlagSet(flagSetYes())

return c
}

func generatePulsarHandler(cmd *cobra.Command, _ []string) error {
session := cliui.New(cliui.StartSpinnerWithText(statusGenerating))
defer session.End()

c, err := newChainWithHomeFlags(
cmd,
chain.WithOutputer(session),
chain.CollectEvents(session.EventBus()),
chain.CheckCosmosSDKVersion(),
)
if err != nil {
return err
}

cacheStorage, err := newCache(cmd)
if err != nil {
return err
}

if err := c.Generate(cmd.Context(), cacheStorage, chain.GeneratePulsar()); err != nil {
return err
}

return session.Println(icons.OK, "Generated Go pulsar code")
}
11 changes: 11 additions & 0 deletions ignite/cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
flag "github.com/spf13/pflag"

"github.com/ignite/cli/ignite/pkg/cliui"
"github.com/ignite/cli/ignite/pkg/cosmosver"
"github.com/ignite/cli/ignite/pkg/gomodulepath"
"github.com/ignite/cli/ignite/pkg/placeholder"
"github.com/ignite/cli/ignite/pkg/xgit"
"github.com/ignite/cli/ignite/services/scaffolder"
"github.com/ignite/cli/ignite/version"
)

// flags related to component scaffolding.
Expand Down Expand Up @@ -129,6 +131,15 @@ func migrationPreRunHandler(cmd *cobra.Command, args []string) error {
return err
}

ver, err := cosmosver.Detect(appPath)
if err != nil {
return err
}

if err := version.AssertSupportedCosmosSDKVersion(ver); err != nil {
return err
}

if err := toolsMigrationPreRunHandler(cmd, session, appPath); err != nil {
return err
}
Expand Down
12 changes: 12 additions & 0 deletions ignite/cmd/scaffold_chain.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ignitecmd

import (
"errors"

"github.com/spf13/cobra"

"github.com/ignite/cli/ignite/pkg/cliui"
Expand Down Expand Up @@ -77,6 +79,7 @@ about Cosmos SDK on https://docs.cosmos.network
c.Flags().AddFlagSet(flagSetAccountPrefixes())
c.Flags().StringP(flagPath, "p", "", "create a project in a specific path")
c.Flags().Bool(flagNoDefaultModule, false, "create a project without a default module")
c.Flags().StringSlice(flagParams, []string{}, "add default module parameters")
c.Flags().Bool(flagSkipGit, false, "skip Git repository initialization")

return c
Expand All @@ -94,6 +97,14 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error {
skipGit, _ = cmd.Flags().GetBool(flagSkipGit)
)

params, err := cmd.Flags().GetStringSlice(flagParams)
if err != nil {
return err
}
if noDefaultModule && len(params) > 0 {
return errors.New("params flag is only supported if the default module is enabled")
}

cacheStorage, err := newCache(cmd)
if err != nil {
return err
Expand All @@ -108,6 +119,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error {
addressPrefix,
noDefaultModule,
skipGit,
params,
)
if err != nil {
return err
Expand Down
56 changes: 0 additions & 56 deletions ignite/cmd/scaffold_mwasm.go

This file was deleted.

2 changes: 1 addition & 1 deletion ignite/config/plugins/testdata/localplugin/example/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/ignite/example

go 1.19
go 1.20
2 changes: 0 additions & 2 deletions ignite/pkg/availableport/availableport.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"math/rand"
"net"
"time"
)

// Find finds n number of unused ports.
Expand All @@ -16,7 +15,6 @@ func Find(n int) (ports []int, err error) {

for i := 0; i < n; i++ {
for {
rand.Seed(time.Now().UnixNano())
port := rand.Intn(max-min+1) + min

conn, err := net.Dial("tcp", fmt.Sprintf(":%d", port))
Expand Down
Loading

0 comments on commit 7d54608

Please sign in to comment.