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 13, 2023
2 parents 8524cc2 + 3c9f058 commit a9e35c9
Show file tree
Hide file tree
Showing 26 changed files with 201 additions and 175 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/md-link-checker-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"pattern": "^https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax"
},
{
"pattern": "^https://docs.starport.network"
"pattern": "^https://docs.ignite.com/"
},
{
"pattern": "^http://localhost"
Expand Down
2 changes: 1 addition & 1 deletion .gitpod/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ignite chain serve

## Install Ignite CLI locally

```
```sh
curl https://get.ignite.com/cli | bash
```

Expand Down
6 changes: 4 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@

### Changes

- [#3581](https://github.com/ignite/cli/pull/3581) Bump cometbft and cometbft-db in the template
- [#3621](https://github.com/ignite/cli/pull/3621) Change `pkg/availableport` to allow custom parameters in `Find` function and handle duplicated ports
- [#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
- [#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
- [#3656](https://github.com/ignite/cli/pull/3656) Disable Go toolchain download
- [#3662](https://github.com/ignite/cli/pull/3662) Refactor CLI "plugin" command to "app"
- [#3669](https://github.com/ignite/cli/pull/3669) Rename `plugins` config file to `igniteapps`
- [#3683](https://github.com/ignite/cli/pull/3683) Resolve `--dep auth` as `--dep account` in `scaffold module`

### Fixes

Expand Down Expand Up @@ -624,7 +626,7 @@ Our new name is **Ignite CLI**!
automatically take care of building proto files without a need of script in the app's source code.
- Integrated third-party proto-files used by Cosmos SDK modules into Ignite CLI
- Added ability to customize binary name with `build.binary` in `config.yml`
- Added ability to change path to home directory with ` .home` in `config.yml`
- Added ability to change path to home directory with `.home` in `config.yml`
- Added ability to add accounts by `address` with in `config.yml`
- Added faucet functionality available on port 4500 and configurable with `faucet` in `config.yml`
- Added `starport faucet [address] [coins]` command
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ require (
golang.org/x/exp v0.0.0-20230519143937-03e91628a987
golang.org/x/mod v0.12.0
golang.org/x/sync v0.2.0
golang.org/x/term v0.8.0
golang.org/x/text v0.9.0
golang.org/x/term v0.13.0
golang.org/x/text v0.13.0
golang.org/x/tools v0.9.1
golang.org/x/vuln v0.1.0
google.golang.org/grpc v1.55.0
Expand Down Expand Up @@ -402,10 +402,10 @@ require (
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/arch v0.1.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1419,8 +1419,8 @@ golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -1522,8 +1522,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -1647,8 +1647,8 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand All @@ -1659,8 +1659,8 @@ golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuX
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1672,8 +1672,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
2 changes: 1 addition & 1 deletion ignite/cmd/account_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ func accountCreateHandler(cmd *cobra.Command, args []string) error {
return fmt.Errorf("unable to create account: %w", err)
}

fmt.Printf("Account %q created, keep your mnemonic in a secret place:\n\n%s\n", name, mnemonic)
cmd.Printf("Account %q created, keep your mnemonic in a secret place:\n\n%s\n", name, mnemonic)
return nil
}
4 changes: 1 addition & 3 deletions ignite/cmd/account_delete.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package ignitecmd

import (
"fmt"

"github.com/spf13/cobra"

"github.com/ignite/cli/ignite/pkg/cosmosaccount"
Expand Down Expand Up @@ -34,6 +32,6 @@ func accountDeleteHandler(cmd *cobra.Command, args []string) error {
return err
}

fmt.Printf("Account %s deleted.\n", name)
cmd.Printf("Account %s deleted.\n", name)
return nil
}
2 changes: 1 addition & 1 deletion ignite/cmd/account_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ func accountExportHandler(cmd *cobra.Command, args []string) error {
return err
}

fmt.Printf("Account %q exported to file: %s\n", name, path)
cmd.Printf("Account %q exported to file: %s\n", name, path)
return nil
}
3 changes: 1 addition & 2 deletions ignite/cmd/account_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ignitecmd

import (
"errors"
"fmt"
"os"

"github.com/cosmos/go-bip39"
Expand Down Expand Up @@ -71,6 +70,6 @@ func accountImportHandler(cmd *cobra.Command, args []string) error {
return err
}

fmt.Printf("Account %q imported.\n", name)
cmd.Printf("Account %q imported.\n", name)
return nil
}
8 changes: 4 additions & 4 deletions ignite/cmd/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func linkPluginHook(rootCmd *cobra.Command, p *plugin.Plugin, hook *plugin.Hook)
ctx := cmd.Context()
err := p.Interface.ExecuteHookCleanUp(ctx, newExecutedHook(hook, cmd, args))

Check warning on line 224 in ignite/cmd/plugin.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/plugin.go#L223-L224

Added lines #L223 - L224 were not covered by tests
if err != nil {
fmt.Printf("app %q ExecuteHookCleanUp() error: %v", p.Path, err)
cmd.Printf("app %q ExecuteHookCleanUp() error: %v", p.Path, err)
}
}
return err
Expand All @@ -241,7 +241,7 @@ func linkPluginHook(rootCmd *cobra.Command, p *plugin.Plugin, hook *plugin.Hook)
defer func() {
err := p.Interface.ExecuteHookCleanUp(ctx, execHook)
if err != nil {
fmt.Printf("app %q ExecuteHookCleanUp() error: %v", p.Path, err)
cmd.Printf("app %q ExecuteHookCleanUp() error: %v", p.Path, err)
}
}()

Expand Down Expand Up @@ -404,7 +404,7 @@ If no path is specified all declared apps are updated.`,
if err != nil {
return err
}
fmt.Printf("All apps updated.\n")
cmd.Println("All apps updated.")
return nil
}
// find the plugin to update
Expand All @@ -414,7 +414,7 @@ If no path is specified all declared apps are updated.`,
if err != nil {
return err
}
fmt.Printf("App %q updated.\n", p.Path)
cmd.Printf("App %q updated.\n", p.Path)
return nil
}
}
Expand Down
10 changes: 10 additions & 0 deletions ignite/cmd/scaffold_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"regexp"
"strings"

"github.com/spf13/cobra"

Expand All @@ -15,6 +16,11 @@ import (
modulecreate "github.com/ignite/cli/ignite/templates/module/create"
)

// moduleNameKeeperAlias is a map of well known module names that have a different keeper name than the usual <module-name>Keeper.
var moduleNameKeeperAlias = map[string]string{
"auth": "account",
}

const (
flagDep = "dep"
flagIBC = "ibc"
Expand Down Expand Up @@ -170,6 +176,10 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error {
return fmt.Errorf("invalid module dependency name format '%s'", name)
}

if alias, ok := moduleNameKeeperAlias[strings.ToLower(name)]; ok {
name = alias
}

deps = append(deps, modulecreate.NewDependency(name))
}

Expand Down
4 changes: 1 addition & 3 deletions ignite/cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package ignitecmd

import (
"fmt"

"github.com/spf13/cobra"

"github.com/ignite/cli/ignite/version"
Expand All @@ -14,7 +12,7 @@ func NewVersion() *cobra.Command {
Use: "version",
Short: "Print the current build information",
Run: func(cmd *cobra.Command, _ []string) {
fmt.Println(version.Long(cmd.Context()))
cmd.Println(version.Long(cmd.Context()))
},
}
return c
Expand Down
2 changes: 1 addition & 1 deletion ignite/config/chain/base/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ type Faucet struct {
Host string `yaml:"host,omitempty"`

// Port number for faucet server to listen at.
Port int `yaml:"port,omitempty"`
Port uint `yaml:"port,omitempty"`
}

// Init overwrites sdk configurations with given values.
Expand Down
2 changes: 1 addition & 1 deletion ignite/config/chain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func FaucetHost(cfg *Config) string {
// We keep supporting Port option for backward compatibility
// TODO: drop this option in the future
host := cfg.Faucet.Host
if cfg.Faucet.Port != 0 {
if cfg.Faucet.Port != uint(0) {
host = fmt.Sprintf(":%d", cfg.Faucet.Port)
}

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 @@ -104,7 +104,7 @@ func generateCmd(cmd *cobra.Command, w io.Writer) error {
}

// here we change sub titles to bold styling. Otherwise, these titles will get
// printed in the right menu of docs.starport.network which is unpleasant because
// printed in the right menu of docs.ignite.com which is unpleasant because
// we only want to see a list of all available commands without the extra noise.
sc := bufio.NewScanner(b)
for sc.Scan() {
Expand Down
90 changes: 73 additions & 17 deletions ignite/pkg/availableport/availableport.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,85 @@ import (
"fmt"
"math/rand"
"net"
"time"
)

type availablePortOptions struct {
randomizer *rand.Rand
minPort uint
maxPort uint
}

type Options func(o *availablePortOptions)

func WithRandomizer(r *rand.Rand) Options {
return func(o *availablePortOptions) {
o.randomizer = r
}
}

func WithMaxPort(maxPort uint) Options {
return func(o *availablePortOptions) {
o.maxPort = maxPort
}
}

func WithMinPort(minPort uint) Options {
return func(o *availablePortOptions) {
o.minPort = minPort
}
}

// Find finds n number of unused ports.
// it is not guaranteed that these ports will not be allocated to
// another program in the time of calling Find().
func Find(n int) (ports []int, err error) {
min := 44000
max := 55000

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

conn, err := net.Dial("tcp", fmt.Sprintf(":%d", port))
// if there is an error, this might mean that no one is listening from this port
// which is what we need.
if err == nil {
conn.Close()
continue
}
ports = append(ports, port)
break
func Find(n uint, options ...Options) (ports []uint, err error) {
// Defining them before so we can set a value depending on the AvailablePortOptions
opts := availablePortOptions{
minPort: 44000,
maxPort: 55000,
randomizer: rand.New(rand.NewSource(time.Now().UnixNano())),
}

for _, apply := range options {
apply(&opts)
}
// If the number of ports required is bigger than the range, this stops it
if opts.maxPort < opts.minPort {
return nil, fmt.Errorf("invalid ports range: max < min (%d < %d)", opts.maxPort, opts.minPort)
}

// If the number of ports required is bigger than the range, this stops it
if n > (opts.maxPort - opts.minPort) {
return nil, fmt.Errorf("invalid amount of ports requested: limit is %d", opts.maxPort-opts.minPort)
}

// Marker to point if a port is already added in the list
registered := make(map[uint]bool)
for len(registered) < int(n) {
// Greater or equal to min and lower than max
totalPorts := opts.maxPort - opts.minPort + 1
randomPort := opts.randomizer.Intn(int(totalPorts))
port := uint(randomPort) + opts.minPort

conn, err := net.Dial("tcp", fmt.Sprintf(":%d", port))
// if there is an error, this might mean that no one is listening from this port
// which is what we need.
if err == nil {
conn.Close()
continue
}
if conn != nil {
defer conn.Close()
}

// if the port is already registered we skip it to the next one
// otherwise it's added to the ports list and pointed in our map
if registered[port] {
continue
}
ports = append(ports, port)
registered[port] = true
}
return ports, nil
}
Loading

0 comments on commit a9e35c9

Please sign in to comment.