Skip to content

Commit

Permalink
refactor: clean-up dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Mar 15, 2024
1 parent 85f5d97 commit 01a930a
Show file tree
Hide file tree
Showing 27 changed files with 805 additions and 316 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build:
## mocks: generate mocks
mocks:
@echo Generating mocks
@go install github.com/vektra/mockery/v2
@go install github.com/vektra/mockery/v2@latest
@go generate ./...

## format: Install and run goimports and gofumpt
Expand Down
5 changes: 3 additions & 2 deletions cmd/network.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"errors"
"fmt"
"path/filepath"

"github.com/ignite/cli/ignite/config"
Expand All @@ -10,7 +12,6 @@ import (
"github.com/ignite/cli/ignite/pkg/cosmosclient"
"github.com/ignite/cli/ignite/pkg/events"
"github.com/ignite/cli/ignite/pkg/gitpod"
"github.com/pkg/errors"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"

Expand Down Expand Up @@ -203,7 +204,7 @@ func (n NetworkBuilder) Network(options ...network.Option) (network.Network, err
if from != "" {
account, err = cosmos.AccountRegistry.GetByName(getFrom(n.cmd))
if err != nil {
return network.Network{}, errors.Wrap(err, "make sure that this account exists, use 'ignite account -h' to manage accounts")
return network.Network{}, fmt.Errorf("make sure that this account exists, use 'ignite account -h' to manage accounts: %w", err)
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/network_chain_join.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -10,7 +11,6 @@ import (
"github.com/ignite/cli/ignite/pkg/gitpod"
"github.com/ignite/cli/ignite/pkg/xchisel"
"github.com/manifoldco/promptui"
"github.com/pkg/errors"
"github.com/rdegges/go-ipify"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -164,7 +164,7 @@ func networkChainJoinHandler(cmd *cobra.Command, args []string) error {
// account balance set by user
amountCoins, err := sdk.ParseCoinsNormalized(amount)
if err != nil {
return errors.Wrap(err, "error parsing amount")
return fmt.Errorf("error parsing amount: %w", err)
}
joinOptions = append(joinOptions, network.WithAccountRequest(amountCoins))
default:
Expand Down Expand Up @@ -216,7 +216,7 @@ func askPublicAddress(cmd *cobra.Command, session *cliui.Session) (publicAddress
if gitpod.IsOnGitpod() {
publicAddress, err = gitpod.URLForPort(ctx, xchisel.DefaultServerPort)
if err != nil {
return "", errors.Wrap(err, "cannot read public Gitpod address of the node")
return "", fmt.Errorf("cannot read public Gitpod address of the node: %w", err)
}
return publicAddress, nil
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/network_chain_publish.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package cmd

import (
"errors"
"fmt"
"os"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ignite/cli/ignite/pkg/cliui"
"github.com/ignite/cli/ignite/pkg/cliui/icons"
"github.com/ignite/cli/ignite/pkg/xurl"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/tendermint/spn/pkg/chainid"
launchtypes "github.com/tendermint/spn/x/launch/types"
Expand Down Expand Up @@ -131,12 +131,12 @@ func networkChainPublishHandler(cmd *cobra.Command, args []string) error {
// parse the amount.
amountCoins, err := sdk.ParseCoinsNormalized(amount)
if err != nil {
return errors.Wrap(err, "error parsing amount")
return fmt.Errorf("error parsing amount: %w", err)
}

accountBalanceCoins, err := sdk.ParseCoinsNormalized(accountBalance)
if err != nil {
return errors.Wrap(err, "error parsing account balance")
return fmt.Errorf("error parsing account balance: %w", err)
}

source, err := xurl.MightHTTPS(args[0])
Expand Down Expand Up @@ -169,10 +169,10 @@ func networkChainPublishHandler(cmd *cobra.Command, args []string) error {
if chainID != "" {
chainName, _, err := chainid.ParseGenesisChainID(chainID)
if err != nil {
return errors.Wrapf(err, "invalid chain id: %s", chainID)
return fmt.Errorf("invalid chain id: %s: %w", chainID, err)
}
if err := chainid.CheckChainName(chainName); err != nil {
return errors.Wrapf(err, "invalid chain id name: %s", chainName)
return fmt.Errorf("invalid chain id name: %s: %w", chainName, err)
}
}

Expand Down
5 changes: 3 additions & 2 deletions cmd/network_request_approve.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cmd

import (
"fmt"

"github.com/ignite/cli/ignite/pkg/cliui"
"github.com/ignite/cli/ignite/pkg/cliui/icons"
"github.com/ignite/cli/ignite/pkg/numbers"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/ignite/cli-plugin-network/network"
Expand Down Expand Up @@ -92,7 +93,7 @@ func networkRequestApproveHandler(cmd *cobra.Command, args []string) error {
// if requests must be verified, we simulate the chain in a temporary directory with the requests
if !noVerification {
if err := verifyRequests(cmd.Context(), cacheStorage, nb, launchID, ids...); err != nil {
return errors.Wrap(err, "request(s) not valid")
return fmt.Errorf("request(s) not valid: %w", err)
}
session.Printf("%s Request(s) %s verified\n", icons.OK, numbers.List(ids, "#"))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/network_request_show.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package cmd

import (
"fmt"
"strconv"

"github.com/ignite/cli/ignite/pkg/cliui"
"github.com/ignite/cli/ignite/pkg/yaml"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/ignite/cli-plugin-network/network"
Expand Down Expand Up @@ -41,7 +41,7 @@ func networkRequestShowHandler(cmd *cobra.Command, args []string) error {
// parse request ID
requestID, err := strconv.ParseUint(args[1], 10, 64)
if err != nil {
return errors.Wrap(err, "error parsing requestID")
return fmt.Errorf("error parsing requestID: %w", err)
}

n, err := nb.Network()
Expand Down
4 changes: 2 additions & 2 deletions cmd/network_reward_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"bytes"
"errors"
"fmt"
"text/tabwriter"

Expand All @@ -13,7 +14,6 @@ import (
"github.com/ignite/cli/ignite/pkg/relayer"
relayerconf "github.com/ignite/cli/ignite/pkg/relayer/config"
"github.com/ignite/cli/ignite/pkg/xurl"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/ignite/cli-plugin-network/network"
Expand Down Expand Up @@ -63,7 +63,7 @@ func networkRewardRelease(cmd *cobra.Command, args []string) (err error) {
defer func() {
var accountErr *cosmosaccount.AccountDoesNotExistError
if errors.As(err, &accountErr) {
err = errors.Wrap(accountErr, `make sure to create or import your account through "ignite account" commands`)
err = fmt.Errorf(`make sure to create or import your account through "ignite account" commands: %w`, err)
}
}()

Expand Down

0 comments on commit 01a930a

Please sign in to comment.