Skip to content
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
11 changes: 5 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@ linters:
- gocritic
- godot
- gofumpt
- revive
- gosimple
- govet
- grouper
- ineffassign
- misspell
- nakedret
- nolintlint
- staticcheck
- reassign
- revive
- staticcheck
- stylecheck
- thelper
- typecheck
- unconvert
- tenv
- thelper
- unused
- unparam
- misspell
- unused
- usetesting

linters-settings:
forbidigo:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ lint:
@for dir in $$(find $$(pwd -P) -mindepth 1 -maxdepth 4 -type d); do \
if [ -e "$$dir/go.mod" ]; then \
echo "Running golangci-lint in $$dir"; \
cd "$$dir" && golangci-lint run; \
cd "$$dir" && golangci-lint run --fix; \
fi \
done

Expand Down
16 changes: 8 additions & 8 deletions appregistry/strcase/strcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ import (
)

// ToKebab converts a string to kebab case (lowercase with hyphens).
// Example: "camelCase" -> "camel-case"
// Example: "camelCase" -> "camel-case".
func ToKebab(s string) string {
return strcase.ToKebab(s)
}

// ToSnake converts a string to snake case (lowercase with underscores).
// Example: "camelCase" -> "camel_case"
// Example: "camelCase" -> "camel_case".
func ToSnake(s string) string {
return strcase.ToSnake(s)
}

// ToLower converts a string to all lowercase.
// Example: "HELLO" -> "hello"
// Example: "HELLO" -> "hello".
func ToLower(s string) string {
return strings.ToLower(s)
}

// ToUpper converts a string to all uppercase.
// Example: "hello" -> "HELLO"
// Example: "hello" -> "HELLO".
func ToUpper(s string) string {
return strings.ToUpper(s)
}

// ToUpperCamel converts a string into upper camel case with spaces preserved between logical words.
// It only modifies the first rune of each word, keeping the rest intact (case-preserving).
// Example: "hello-world" -> "Hello World"
// Example: "snAke_caSe" -> "SnAke CaSe"
// Example: "hello-world" -> "Hello World".
// Example: "snAke_caSe" -> "SnAke CaSe".
func ToUpperCamel(s string) string {
s = strings.TrimSpace(s)
s = strings.ReplaceAll(s, "-", " ")
Expand All @@ -53,8 +53,8 @@ func ToUpperCamel(s string) string {

// ToLowerCamel converts a string into lower camel case with spaces between words.
// All characters are converted to lowercase. Hyphens and underscores are replaced with spaces.
// Example: "Hello-World" -> "hello world"
// Example: "UPPER_CASE" -> "upper case"
// Example: "Hello-World" -> "hello world".
// Example: "UPPER_CASE" -> "upper case".
func ToLowerCamel(s string) string {
s = strings.TrimSpace(s)
s = strings.ReplaceAll(s, "-", " ")
Expand Down
2 changes: 1 addition & 1 deletion connect/chains/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
var (
configName = "connect.yaml"

// ErrConfigNotFound is returned when the config file is not found
// ErrConfigNotFound is returned when the config file is not found.
ErrConfigNotFound = fmt.Errorf("config file not found")
)

Expand Down
6 changes: 3 additions & 3 deletions connect/chains/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func NewChainRegistry() *ChainRegistry {
}
}

// FetchChains fetches the list of chains from the cosmos.directory API
// Note, the output chainregistry.Chain doesn't contain the full list of fields
// FetchChains fetches the list of chains from the cosmos.directory API.
// Note, the output chainregistry.Chain doesn't contain the full list of fields.
func (r *ChainRegistry) FetchChains() error {
client := &http.Client{
Timeout: 5 * time.Second,
Expand Down Expand Up @@ -73,7 +73,7 @@ func (r *ChainRegistry) FetchChains() error {
return nil
}

// EnrichChain fetches the full chain information from the cosmos.directory API
// EnrichChain fetches the full chain information from the cosmos.directory API.
func EnrichChain(chain *chainregistry.Chain) error {
baseURL := fmt.Sprintf("%s/%s", cosmosDirectoryAPIURL, chain.ChainName)

Expand Down
16 changes: 9 additions & 7 deletions connect/cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package cmd

import (
"context"
"errors"
"fmt"
"strings"

authv1betav1 "cosmossdk.io/api/cosmos/auth/v1beta1"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"google.golang.org/grpc"

"github.com/ignite/cli/v29/ignite/pkg/chainregistry"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/services/plugin"

"github.com/ignite/apps/connect/chains"
Expand All @@ -28,7 +29,7 @@ type addCmdModel struct {
}

func newAddCmdModel(chain chainregistry.Chain) *addCmdModel {
s := spinner.NewModel()
s := spinner.New()
s.Spinner = spinner.Dot

c := &chain
Expand Down Expand Up @@ -119,18 +120,18 @@ func (m *addCmdModel) View() string {
end = totalSize
}

out := "\033[K" // clear current line before printing
out := outLine
out += "Select endpoint:\n"
for i, item := range items[start:end] {
out += "\033[K" // clear current line before printing
out += outLine
if i == m.selectedIndex {
out += "\033[32m✓ \033[1m" + item + "\033[0m\n"
} else {
out += fmt.Sprintf(" %s\n", item)
}
}

out += "\033[K" // clear current line before printing
out += outLine
out += "(press 'n'/'right' for next, 'p'/'left' for prev, 'enter' to add chain, 'q'/'ctrl+c' to quit)\n"

return out
Expand Down Expand Up @@ -204,7 +205,8 @@ func initChain(ctx context.Context, chain chainregistry.Chain, endpoint string)
return err
}

fmt.Printf("%s is ready to Connect!\n", strings.Title(chain.ChainName)) //nolintlint:staticcheck // strings.Title has a better API.
c := cases.Title(language.English, cases.NoLower)
fmt.Printf("%s is ready to Connect!\n", c.String(chain.ChainName))
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion connect/cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func AppHandler(ctx context.Context, name string, cfg *chains.ChainConfig, args
ValidatorAddressCodec: addresscodec.NewBech32Codec(fmt.Sprintf("%svaloper", cfg.Bech32Prefix)),
ConsensusAddressCodec: addresscodec.NewBech32Codec(fmt.Sprintf("%svalcons", cfg.Bech32Prefix)),
},
GetClientConn: func(command *cobra.Command) (grpc.ClientConnInterface, error) {
GetClientConn: func(*cobra.Command) (grpc.ClientConnInterface, error) {
return conn.Connect()
},
AddQueryConnFlags: func(command *cobra.Command) {
Expand Down
2 changes: 2 additions & 0 deletions connect/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/ignite/cli/v29/ignite/services/plugin"
)

const outLine = "\033[K" // current line before printing

// GetCommands returns the list of app commands.
func GetCommands(availableChains []string) []*plugin.Command {
cmd := []*plugin.Command{
Expand Down
24 changes: 12 additions & 12 deletions connect/cmd/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

const pageSize = 10

// model holds the state of the UI
// model holds the state of the UI.
type discoverCmdModel struct {
spinner spinner.Model
fetching bool
Expand All @@ -28,7 +28,7 @@ type discoverCmdModel struct {
chainRegistry *chains.ChainRegistry
}

// Messages
// Messages.
type fetchDoneMsg struct {
reg *chains.ChainRegistry
}
Expand All @@ -37,12 +37,12 @@ type fetchErrMsg struct {
err error
}

// Init initialize Bubble Tea program
// Init initialize Bubble Tea program.
func (m *discoverCmdModel) Init() tea.Cmd {
return tea.Batch(fetchChainsCmd)
}

// fetchChainsCmd fetch the chains in the background
// fetchChainsCmd fetch the chains in the background.
func fetchChainsCmd() tea.Msg {
cr := chains.NewChainRegistry()
if err := cr.FetchChains(); err != nil {
Expand All @@ -51,7 +51,7 @@ func fetchChainsCmd() tea.Msg {
return fetchDoneMsg{cr}
}

// Update handles messages and updates the model accordingly
// Update handles messages and updates the model accordingly.
func (m *discoverCmdModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
var totalSize int
Expand Down Expand Up @@ -114,7 +114,7 @@ func (m *discoverCmdModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, cmd
}

// View returns the UI as a string
// View returns the UI as a string.
func (m *discoverCmdModel) View() string {
if m.fetching && m.err == nil {
return fmt.Sprintf("%s Discovering chains... (press 'q' to quit)\n", m.spinner.View())
Expand All @@ -139,7 +139,7 @@ func (m *discoverCmdModel) View() string {
end = totalSize
}

out := "\033[K" // clear current line before printing
out := outLine
out += fmt.Sprintf("Fetched %d chains. Showing %d-%d:\n", totalSize, start+1, end)

// ANSI escape codes for highlighting
Expand All @@ -149,7 +149,7 @@ func (m *discoverCmdModel) View() string {
for i, k := range chainsNames[start:end] {
chain := m.chainRegistry.Chains[k]

out += "\033[K" // clear current line before printing
out += outLine

// Check if the input corresponds to this line number
if i == m.selectedIndex {
Expand All @@ -159,13 +159,13 @@ func (m *discoverCmdModel) View() string {
}
}

out += "\033[K" // clear current line before printing
out += outLine
out += "(press 'n'/'right' for next, 'p'/'left' for prev, 'enter' to init chain, 'q'/'ctrl+c' to quit)\n"
return out
}

func DiscoverHandler(ctx context.Context, cmd *plugin.ExecutedCommand) error {
s := spinner.NewModel()
func DiscoverHandler(context.Context, *plugin.ExecutedCommand) error {
s := spinner.New()
s.Spinner = spinner.Dot
model := &discoverCmdModel{
spinner: s,
Expand All @@ -177,7 +177,7 @@ func DiscoverHandler(ctx context.Context, cmd *plugin.ExecutedCommand) error {
return err
}

// if the user selected a chain, execute the add command
// if the user selected a chain, execute the add command.
if len(model.selectedChain.ChainName) > 0 {
selectedChain := model.chainRegistry.Chains[model.selectedChain.ChainName]

Expand Down
4 changes: 2 additions & 2 deletions connect/cmd/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package cmd

import (
"context"
"errors"
"fmt"
"os"
"path"

"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/services/plugin"

"github.com/ignite/apps/connect/chains"
)

func RemoveHandler(ctx context.Context, cmd *plugin.ExecutedCommand) error {
func RemoveHandler(_ context.Context, cmd *plugin.ExecutedCommand) error {
if len(cmd.Args) < 1 {
return errors.New("usage: connect remove <chain>")
}
Expand Down
2 changes: 1 addition & 1 deletion connect/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package cmd

import (
"context"
"errors"
"fmt"
"runtime/debug"
"strings"

"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/services/plugin"
)

Expand Down
5 changes: 3 additions & 2 deletions evm/cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"context"
"path/filepath"

"github.com/ignite/apps/evm/template"
"github.com/ignite/cli/v29/ignite/pkg/cliui"
"github.com/ignite/cli/v29/ignite/pkg/cosmosver"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/pkg/gocmd"
"github.com/ignite/cli/v29/ignite/pkg/xgenny"
"github.com/ignite/cli/v29/ignite/services/chain"
"github.com/ignite/cli/v29/ignite/services/plugin"

"github.com/ignite/apps/evm/template"
)

const (
Expand All @@ -20,7 +21,7 @@ const (
flagPath = "path"
)

// AddHandler implements the EVM integration command
// AddHandler implements the EVM integration command.
func AddHandler(ctx context.Context, cmd *plugin.ExecutedCommand) error {
flags := plugin.Flags(cmd.Flags)

Expand Down
2 changes: 1 addition & 1 deletion evm/template/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewEVMGenerator(chain *chain.Chain) (*genny.Generator, error) {

g.RunFn(commandsModify(appPath, binaryName))
g.RunFn(rootModify(appPath, binaryName))
g.RunFn(appModify(appPath, binaryName))
g.RunFn(appModify(appPath))
g.RunFn(appConfigModify(appPath))
g.RunFn(ibcModify(appPath))

Expand Down
2 changes: 1 addition & 1 deletion evm/template/generator_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// appModify modifies the application app.go to use EVM.
func appModify(appPath, binaryName string) genny.RunFn {
func appModify(appPath string) genny.RunFn {
return func(r *genny.Runner) error {
appGoPath := filepath.Join(appPath, module.PathAppGo)
f, err := r.Disk.Find(appGoPath)
Expand Down
2 changes: 1 addition & 1 deletion evolve/cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package cmd

import (
"context"
"errors"
"path/filepath"

"github.com/ignite/cli/v29/ignite/pkg/cliui"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/pkg/xgenny"
"github.com/ignite/cli/v29/ignite/services/chain"
"github.com/ignite/cli/v29/ignite/services/plugin"
Expand Down
3 changes: 2 additions & 1 deletion evolve/template/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/gobuffalo/genny/v2"

"github.com/ignite/cli/v29/ignite/pkg/cosmosver"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/pkg/placeholder"
Expand Down Expand Up @@ -46,7 +47,7 @@ func commandsStartModify(appPath, binaryName string, version cosmosver.Version)
content = replaceLegacyAddCommands(content)

// modify the add commands arguments using xast.
content, err = xast.ModifyCaller(content, ServerAddCommandsWithStartCmdOptions, func(args []string) ([]string, error) {
content, err = xast.ModifyCaller(content, ServerAddCommandsWithStartCmdOptions, func([]string) ([]string, error) {
return []string{
"rootCmd",
"app.DefaultNodeHome",
Expand Down
Loading
Loading