Skip to content

Commit

Permalink
Merge branch 'main' into feat/plugin-system-improvements-versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
jeronimoalbi committed Oct 23, 2023
2 parents 9aaf758 + 5104114 commit e8cb887
Show file tree
Hide file tree
Showing 27 changed files with 158 additions and 73 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '**.md'
branches:
- main
- release/*

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
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 @@ -370,7 +370,7 @@ ignite
rootCmd := buildRootCmd(ctx)
tt.setup(t, ctx, pi)

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

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

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

if tt.expectedError != "" {
require.EqualError(p.Error, tt.expectedError)
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 @@ -156,10 +156,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 @@ -189,7 +191,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
1 change: 1 addition & 0 deletions ignite/pkg/cosmosanalysis/testdata/chain/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c=
github.com/cometbft/cometbft v0.37.1/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0=
github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down
6 changes: 3 additions & 3 deletions ignite/pkg/cosmosfaucet/http_faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type FaucetInfoResponse struct {
}

func (f Faucet) faucetInfoHandler(w http.ResponseWriter, _ *http.Request) {
xhttp.ResponseJSON(w, http.StatusOK, FaucetInfoResponse{
_ = xhttp.ResponseJSON(w, http.StatusOK, FaucetInfoResponse{
IsAFaucet: true,
ChainID: f.chainID,
})
Expand All @@ -94,11 +94,11 @@ func (f Faucet) coinsFromRequest(req TransferRequest) (sdk.Coins, error) {
}

func responseSuccess(w http.ResponseWriter) {
xhttp.ResponseJSON(w, http.StatusOK, TransferResponse{})
_ = xhttp.ResponseJSON(w, http.StatusOK, TransferResponse{})
}

func responseError(w http.ResponseWriter, code int, err error) {
xhttp.ResponseJSON(w, code, TransferResponse{
_ = xhttp.ResponseJSON(w, code, TransferResponse{
Error: err.Error(),
})
}
2 changes: 1 addition & 1 deletion ignite/pkg/cosmosfaucet/http_openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ type openAPIData struct {
}

func (f Faucet) openAPISpecHandler(w http.ResponseWriter, _ *http.Request) {
tmplOpenAPISpec.Execute(w, f.openAPIData)
_ = tmplOpenAPISpec.Execute(w, f.openAPIData)
}
2 changes: 1 addition & 1 deletion ignite/pkg/cosmostxcollector/adapter/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (a Adapter) Save(ctx context.Context, txs []cosmosclient.TX) error {
}

// Rollback won't have any effect if the transaction is committed before
defer sqlTx.Rollback()
defer sqlTx.Rollback() //nolint:errcheck

// Prepare insert statements to speed up "bulk" saving times
txStmt, err := sqlTx.PrepareContext(ctx, sqlInsertTX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ func TestQuery(t *testing.T) {
// Act
cr, err := adapter.Query(ctx, qry)
if cr.Next() {
cr.Scan(&rowValue)
err = cr.Scan(&rowValue)
require.NoError(t, err)
}

// Assert
Expand Down
2 changes: 1 addition & 1 deletion ignite/pkg/debugger/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func Start(ctx context.Context, binaryPath string, options ...Option) (err error
return fmt.Errorf("failed to run debug server: %w", err)
}

defer server.Stop()
defer server.Stop() //nolint:errcheck

// Wait until the context is done or the connected client disconnects
select {
Expand Down
24 changes: 16 additions & 8 deletions ignite/pkg/jsonfile/jsonfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,28 @@ func (f *JSONFile) Field(key string, param interface{}) error {
switch dataType {
case jsonparser.Boolean, jsonparser.Array, jsonparser.Number, jsonparser.Object:
err := json.Unmarshal(value, param)
if _, ok := err.(*json.UnmarshalTypeError); ok { //nolint:errorlint
var unmarshalTypeError *json.UnmarshalTypeError
if errors.As(err, &unmarshalTypeError) {
return ErrInvalidValueType
} else if err != nil {
return err
}
case jsonparser.String:
paramStr, ok := param.(*string)
if !ok {
return ErrInvalidValueType
}
*paramStr, err = jsonparser.ParseString(value)
result, err := jsonparser.ParseString(value)
if err != nil {
return err
}
paramStr, ok := param.(*string)
if ok {
*paramStr = result
break
}
var (
unmarshalTypeError *json.UnmarshalTypeError
syntaxTypeError *json.SyntaxError
)
if err := json.Unmarshal(value, param); errors.As(err, &unmarshalTypeError) ||
errors.As(err, &syntaxTypeError) {
return ErrInvalidValueType
}
case jsonparser.NotExist:
case jsonparser.Null:
case jsonparser.Unknown:
Expand Down
Loading

0 comments on commit e8cb887

Please sign in to comment.