Skip to content

Commit

Permalink
Merge branch 'feat/sdk-v0.50' into julien/autocli
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Oct 19, 2023
2 parents 359a014 + 82355e8 commit 7441f20
Show file tree
Hide file tree
Showing 41 changed files with 285 additions and 133 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [#3559](https://github.com/ignite/cli/pull/3559) Bump network plugin version to `v0.1.1`
- [#3581](https://github.com/ignite/cli/pull/3581) Bump cometbft and cometbft-db in the template
- [#3522](https://github.com/ignite/cli/pull/3522) Remove indentation from `chain serve` output
- [#3346](https://github.com/ignite/cli/issues/3346) Improve scaffold query --help
- [#3601](https://github.com/ignite/cli/pull/3601) Update ts-relayer version to `0.10.0`
- [#3658](https://github.com/ignite/cli/pull/3658) Rename Marshaler to Codec in EncodingConfig
- [#3653](https://github.com/ignite/cli/pull/3653) Add "app" extension to plugin binaries
Expand All @@ -28,6 +29,7 @@

### Fixes

- [#3386](https://github.com/ignite/cli/issues/3386) Prevent scaffolding of default module called "ibc"
- [#3592](https://github.com/ignite/cli/pull/3592) Fix `pkg/protoanalysis` to support HTTP rule parameter arguments
- [#3598](https://github.com/ignite/cli/pull/3598) Fix consensus param keeper constructor key in `app.go`
- [#3610](https://github.com/ignite/cli/pull/3610) Fix overflow issue of cosmos faucet in `pkg/cosmosfaucet/transfer.go` and `pkg/cosmosfaucet/cosmosfaucet.go`
Expand Down
78 changes: 60 additions & 18 deletions docs/docs/08-references/01-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -3307,19 +3307,7 @@ array.coin. An example of using field types:

ignite scaffold list pool amount:coin tags:array.string height:int

Supported types:

| Type | Alias | Index | Code Type | Description |
|--------------|---------|-------|-----------|---------------------------------|
| string | - | yes | string | Text type |
| array.string | strings | no | []string | List of text type |
| bool | - | yes | bool | Boolean type |
| int | - | yes | int32 | Integer type |
| array.int | ints | no | []int32 | List of integers types |
| uint | - | yes | uint64 | Unsigned integer type |
| array.uint | uints | no | []uint64 | List of unsigned integers types |
| coin | - | no | sdk.Coin | Cosmos SDK coin type |
| array.coin | coins | no | sdk.Coins | List of Cosmos SDK coin types |
For detailed type information use ignite scaffold type --help

"Index" indicates whether the type can be used as an index in
"ignite scaffold map".
Expand Down Expand Up @@ -3398,7 +3386,7 @@ incrementing integer, whereas "map" values are indexed by a user-provided value

Let's use the same blog post example:

ignite scaffold map post title body
ignite scaffold map post title body:string

This command scaffolds a "Post" type and CRUD functionality to create, read,
updated, and delete posts. However, when creating a new post with your chain's
Expand Down Expand Up @@ -3427,6 +3415,8 @@ Since the behavior of "list" and "map" scaffolding is very similar, you can use
the "--no-message", "--module", "--signer" flags as well as the colon syntax for
custom types.

For detailed type information use ignite scaffold type --help


```
ignite scaffold map NAME [field]... [flags]
Expand Down Expand Up @@ -3480,6 +3470,8 @@ The command above will create a new message MsgAddPool with three fields: amount
(in tokens), denom (a string), and active (a boolean). The message will be added
to the "dex" module.

For detailed type information use ignite scaffold type --help

By default, the message is defined as a proto message in the
"proto/{app}/{module}/tx.proto" and registered in the "Msg" service. A CLI command to
create and broadcast a transaction with MsgAddPool is created in the module's
Expand All @@ -3503,7 +3495,7 @@ for details.


```
ignite scaffold message [name] [field1] [field2] ... [flags]
ignite scaffold message [name] [field1:type1] [field2:type2] ... [flags]
```

**Options**
Expand Down Expand Up @@ -3648,8 +3640,14 @@ ignite scaffold packet [packetName] [field1] [field2] ... --module [moduleName]

Query for fetching data from a blockchain

**Synopsis**

Query for fetching data from a blockchain.

For detailed type information use ignite scaffold type --help.

```
ignite scaffold query [name] [request_field1] [request_field2] ... [flags]
ignite scaffold query [name] [field1:type1] [field2:type2] ... [flags]
```

**Options**
Expand Down Expand Up @@ -3695,8 +3693,20 @@ ignite scaffold react [flags]

CRUD for data stored in a single location

**Synopsis**

CRUD for data stored in a single location.

For detailed type information use ignite scaffold type --help.

```
ignite scaffold single NAME [field:type]... [flags]
```

**Examples**

```
ignite scaffold single NAME [field]... [flags]
ignite scaffold single todo-single title:string done:bool
```

**Options**
Expand All @@ -3721,8 +3731,40 @@ ignite scaffold single NAME [field]... [flags]

Type definition

**Synopsis**

Type information

Currently supports:

| Type | Alias | Index | Code Type | Description |
|--------------|---------|-------|-----------|---------------------------------|
| string | - | yes | string | Text type |
| array.string | strings | no | []string | List of text type |
| bool | - | yes | bool | Boolean type |
| int | - | yes | int32 | Integer type |
| array.int | ints | no | []int32 | List of integers types |
| uint | - | yes | uint64 | Unsigned integer type |
| array.uint | uints | no | []uint64 | List of unsigned integers types |
| coin | - | no | sdk.Coin | Cosmos SDK coin type |
| array.coin | coins | no | sdk.Coins | List of Cosmos SDK coin types |

Field Usage:
- fieldName
- fieldName:fieldType

If no :fieldType, default (string) is used



```
ignite scaffold type NAME [field:type] ... [flags]
```

**Examples**

```
ignite scaffold type NAME [field]... [flags]
ignite scaffold type todo-item priority:int desc:string tags:array.string done:bool
```

**Options**
Expand Down
4 changes: 2 additions & 2 deletions ignite/cmd/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ ignite
rootCmd := buildRootCmd()
tt.setup(t, pi)

linkPlugins(rootCmd, []*plugin.Plugin{p})
_ = linkPlugins(rootCmd, []*plugin.Plugin{p})

if tt.expectedError != "" {
require.Error(p.Error)
Expand Down Expand Up @@ -540,7 +540,7 @@ func TestLinkPluginHooks(t *testing.T) {
rootCmd := buildRootCmd()
tt.setup(t, pi)

linkPlugins(rootCmd, []*plugin.Plugin{p})
_ = linkPlugins(rootCmd, []*plugin.Plugin{p})

if tt.expectedError != "" {
require.EqualError(p.Error, tt.expectedError)
Expand Down
22 changes: 22 additions & 0 deletions ignite/cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ const (
msgCommitPrompt = "Do you want to proceed without committing your saved changes"

statusScaffolding = "Scaffolding..."

supportFieldTypes = `
Currently supports:
| Type | Alias | Index | Code Type | Description |
|--------------|---------|-------|-----------|---------------------------------|
| string | - | yes | string | Text type |
| array.string | strings | no | []string | List of text type |
| bool | - | yes | bool | Boolean type |
| int | - | yes | int32 | Integer type |
| array.int | ints | no | []int32 | List of integers types |
| uint | - | yes | uint64 | Unsigned integer type |
| array.uint | uints | no | []uint64 | List of unsigned integers types |
| coin | - | no | sdk.Coin | Cosmos SDK coin type |
| array.coin | coins | no | sdk.Coins | List of Cosmos SDK coin types |
Field Usage:
- fieldName
- fieldName:fieldType
If no :fieldType, default (string) is used
`
)

// NewScaffold returns a command that groups scaffolding related sub commands.
Expand Down
14 changes: 1 addition & 13 deletions ignite/cmd/scaffold_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,7 @@ array.coin. An example of using field types:
ignite scaffold list pool amount:coin tags:array.string height:int
Supported types:
| Type | Alias | Index | Code Type | Description |
|--------------|---------|-------|-----------|---------------------------------|
| string | - | yes | string | Text type |
| array.string | strings | no | []string | List of text type |
| bool | - | yes | bool | Boolean type |
| int | - | yes | int32 | Integer type |
| array.int | ints | no | []int32 | List of integers types |
| uint | - | yes | uint64 | Unsigned integer type |
| array.uint | uints | no | []uint64 | List of unsigned integers types |
| coin | - | no | sdk.Coin | Cosmos SDK coin type |
| array.coin | coins | no | sdk.Coins | List of Cosmos SDK coin types |
For detailed type information use ignite scaffold type --help
"Index" indicates whether the type can be used as an index in
"ignite scaffold map".
Expand Down
4 changes: 3 additions & 1 deletion ignite/cmd/scaffold_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ incrementing integer, whereas "map" values are indexed by a user-provided value
Let's use the same blog post example:
ignite scaffold map post title body
ignite scaffold map post title body:string
This command scaffolds a "Post" type and CRUD functionality to create, read,
updated, and delete posts. However, when creating a new post with your chain's
Expand Down Expand Up @@ -54,6 +54,8 @@ product values that have the same category but are using different GUIDs.
Since the behavior of "list" and "map" scaffolding is very similar, you can use
the "--no-message", "--module", "--signer" flags as well as the colon syntax for
custom types.
For detailed type information use ignite scaffold type --help
`,
Args: cobra.MinimumNArgs(1),
PreRunE: migrationPreRunHandler,
Expand Down
4 changes: 3 additions & 1 deletion ignite/cmd/scaffold_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const flagSigner = "signer"
// NewScaffoldMessage returns the command to scaffold messages.
func NewScaffoldMessage() *cobra.Command {
c := &cobra.Command{
Use: "message [name] [field1] [field2] ...",
Use: "message [name] [field1:type1] [field2:type2] ...",
Short: "Message to perform state transition on the blockchain",
Long: `Message scaffolding is useful for quickly adding functionality to your
blockchain to handle specific Cosmos SDK messages.
Expand All @@ -38,6 +38,8 @@ The command above will create a new message MsgAddPool with three fields: amount
(in tokens), denom (a string), and active (a boolean). The message will be added
to the "dex" module.
For detailed type information use ignite scaffold type --help
By default, the message is defined as a proto message in the
"proto/{app}/{module}/tx.proto" and registered in the "Msg" service. A CLI command to
create and broadcast a transaction with MsgAddPool is created in the module's
Expand Down
7 changes: 5 additions & 2 deletions ignite/cmd/scaffold_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ const (
// NewScaffoldQuery command creates a new type command to scaffold queries.
func NewScaffoldQuery() *cobra.Command {
c := &cobra.Command{
Use: "query [name] [request_field1] [request_field2] ...",
Short: "Query for fetching data from a blockchain",
Use: "query [name] [field1:type1] [field2:type2] ...",
Short: "Query for fetching data from a blockchain",
Long: `Query for fetching data from a blockchain.
For detailed type information use ignite scaffold type --help.`,
Args: cobra.MinimumNArgs(1),
PreRunE: migrationPreRunHandler,
RunE: queryHandler,
Expand Down
8 changes: 6 additions & 2 deletions ignite/cmd/scaffold_single.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import (
// NewScaffoldSingle returns a new command to scaffold a singleton.
func NewScaffoldSingle() *cobra.Command {
c := &cobra.Command{
Use: "single NAME [field]...",
Short: "CRUD for data stored in a single location",
Use: "single NAME [field:type]...",
Short: "CRUD for data stored in a single location",
Long: `CRUD for data stored in a single location.
For detailed type information use ignite scaffold type --help.`,
Example: " ignite scaffold single todo-single title:string done:bool",
Args: cobra.MinimumNArgs(1),
PreRunE: migrationPreRunHandler,
RunE: scaffoldSingleHandler,
Expand Down
6 changes: 5 additions & 1 deletion ignite/cmd/scaffold_type.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ignitecmd

import (
"fmt"

"github.com/spf13/cobra"

"github.com/ignite/cli/ignite/services/scaffolder"
Expand All @@ -9,8 +11,10 @@ import (
// NewScaffoldType returns a new command to scaffold a type.
func NewScaffoldType() *cobra.Command {
c := &cobra.Command{
Use: "type NAME [field]...",
Use: "type NAME [field:type] ...",
Short: "Type definition",
Long: fmt.Sprintf("Type information\n%s\n", supportFieldTypes),
Example: " ignite scaffold type todo-item priority:int desc:string tags:array.string done:bool",
Args: cobra.MinimumNArgs(1),
PreRunE: migrationPreRunHandler,
RunE: scaffoldTypeHandler,
Expand Down
2 changes: 1 addition & 1 deletion ignite/internal/tools/gen-cli-docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func generateCmd(cmd *cobra.Command, w io.Writer) error {
continue
}

io.WriteString(w, "\n")
_, _ = io.WriteString(w, "\n")

if err := generateCmd(cmd, w); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions ignite/pkg/cliui/clispinner/clispinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *Spinner) SetCharset(charset []string) *Spinner {

// SetColor sets the prefix for spinner.
func (s *Spinner) SetColor(color string) *Spinner {
s.sp.Color(color)
_ = s.sp.Color(color)
return s
}

Expand All @@ -107,7 +107,7 @@ func (s *Spinner) Start() *Spinner {
func (s *Spinner) Stop() *Spinner {
s.sp.Stop()
s.sp.Prefix = ""
s.sp.Color(spinnerColor)
_ = s.sp.Color(spinnerColor)
s.sp.UpdateCharSet(charset)
s.sp.Stop()
return s
Expand Down
4 changes: 2 additions & 2 deletions ignite/pkg/cliui/view/errorview/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func (e Error) String() string {

w := wordwrap.NewWriter(80)
w.Breakpoints = []rune{' '}
w.Write([]byte(s))
w.Close()
_, _ = w.Write([]byte(s))
_ = w.Close()

return colors.Error(w.String())
}
4 changes: 2 additions & 2 deletions ignite/pkg/cmdrunner/cmdrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ type cmdSignal struct {
*exec.Cmd
}

func (e *cmdSignal) Signal(s os.Signal) { e.Cmd.Process.Signal(s) }
func (e *cmdSignal) Signal(s os.Signal) { _ = e.Cmd.Process.Signal(s) }

func (e *cmdSignal) Write([]byte) (n int, err error) { return 0, nil }

Expand All @@ -199,7 +199,7 @@ type cmdSignalWithWriter struct {
w io.WriteCloser
}

func (e *cmdSignalWithWriter) Signal(s os.Signal) { e.Cmd.Process.Signal(s) }
func (e *cmdSignalWithWriter) Signal(s os.Signal) { _ = e.Cmd.Process.Signal(s) }

func (e *cmdSignalWithWriter) Write(data []byte) (n int, err error) {
defer e.w.Close()
Expand Down
4 changes: 3 additions & 1 deletion ignite/pkg/cosmosanalysis/cosmosanalysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ func TestFindImplementationNotFound(t *testing.T) {

// No implementation
found, err := cosmosanalysis.FindImplementation(tmpDir1, expectedInterface)
require.NoError(t, err)
require.Len(t, found, 0)

// Partial implementation
found, err = cosmosanalysis.FindImplementation(tmpDir2, expectedInterface)
require.NoError(t, err)
require.Len(t, found, 0)
}

Expand Down Expand Up @@ -199,7 +201,7 @@ func TestFindAppFilePath(t *testing.T) {
appTestFilePath := filepath.Join(secondaryAppFolder, "my_own_app_test.go")
err = os.WriteFile(appTestFilePath, appTestFile, 0o644)
require.NoError(t, err)
pathFound, err = cosmosanalysis.FindAppFilePath(tmpDir)
_, err = cosmosanalysis.FindAppFilePath(tmpDir)
require.Error(t, err)
require.Contains(t, err.Error(), "cannot locate your app.go")

Expand Down
Loading

0 comments on commit 7441f20

Please sign in to comment.