From f9cc7e09067aff4cdb88ffcda7feb7f43035f15a Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 13 Jun 2024 16:54:41 +0200 Subject: [PATCH 1/4] refactor(cmd)!: deprecate `ignite node`command --- changelog.md | 1 + go.mod | 2 +- ignite/cmd/cmd.go | 5 +- ignite/cmd/node.go | 80 ----- ignite/cmd/node_query.go | 76 ----- ignite/cmd/node_query_bank.go | 14 - ignite/cmd/node_query_bank_balances.go | 59 ---- ignite/cmd/node_query_tx.go | 45 --- ignite/cmd/node_tx.go | 75 ----- ignite/cmd/node_tx_bank.go | 14 - ignite/cmd/node_tx_bank_send.go | 78 ----- integration/node/cmd_query_bank_test.go | 288 ------------------ integration/node/cmd_query_tx_test.go | 96 ------ integration/node/cmd_tx_bank_send_test.go | 339 ---------------------- 14 files changed, 6 insertions(+), 1166 deletions(-) delete mode 100644 ignite/cmd/node.go delete mode 100644 ignite/cmd/node_query.go delete mode 100644 ignite/cmd/node_query_bank.go delete mode 100644 ignite/cmd/node_query_bank_balances.go delete mode 100644 ignite/cmd/node_query_tx.go delete mode 100644 ignite/cmd/node_tx.go delete mode 100644 ignite/cmd/node_tx_bank.go delete mode 100644 ignite/cmd/node_tx_bank_send.go delete mode 100644 integration/node/cmd_query_bank_test.go delete mode 100644 integration/node/cmd_query_tx_test.go delete mode 100644 integration/node/cmd_tx_bank_send_test.go diff --git a/changelog.md b/changelog.md index a1755b5c5a..734b2f5cd1 100644 --- a/changelog.md +++ b/changelog.md @@ -41,6 +41,7 @@ - [#4167](https://github.com/ignite/cli/pull/4167) Scaffold `int64` instead of `int32` when a field type is `int` - [#4168](https://github.com/ignite/cli/pull/4168) Bump IBC to `v8.3.1` - [#4178](https://github.com/ignite/cli/pull/4178) Bump cosmos-sdk to `v0.50.7` +- []() Deprecate `ignite node` for `ignite connect` app ### Fixes diff --git a/go.mod b/go.mod index 4b91d19df2..9a0008354c 100644 --- a/go.mod +++ b/go.mod @@ -47,6 +47,7 @@ require ( github.com/goccy/go-yaml v1.11.3 github.com/golangci/golangci-lint v1.57.2 github.com/google/go-github/v48 v48.2.0 + github.com/google/go-querystring v1.1.0 github.com/gorilla/mux v1.8.1 github.com/hashicorp/go-hclog v1.6.3 github.com/hashicorp/go-plugin v1.6.0 @@ -270,7 +271,6 @@ require ( github.com/google/go-cmp v0.6.0 // indirect github.com/google/go-containerregistry v0.19.1 // indirect github.com/google/go-dap v0.11.0 // indirect - github.com/google/go-querystring v1.1.0 // indirect github.com/google/pprof v0.0.0-20240509144519-723abb6459b7 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gordonklaus/ineffassign v0.1.0 // indirect diff --git a/ignite/cmd/cmd.go b/ignite/cmd/cmd.go index 034af6cb3a..847d6bf565 100644 --- a/ignite/cmd/cmd.go +++ b/ignite/cmd/cmd.go @@ -84,7 +84,6 @@ To get started, create a blockchain: NewScaffold(), NewChain(), NewGenerate(), - NewNode(), NewAccount(), NewDocs(), NewVersion(), @@ -239,6 +238,10 @@ func deprecated() []*cobra.Command { Use: "faucet", Deprecated: "use `ignite chain faucet` instead.", }, + { + Use: "node", + Deprecated: "use ignite connect app instead (ignite app install -g github.com/ignite/apps/connect).", + }, } } diff --git a/ignite/cmd/node.go b/ignite/cmd/node.go deleted file mode 100644 index 0e07a001e0..0000000000 --- a/ignite/cmd/node.go +++ /dev/null @@ -1,80 +0,0 @@ -package ignitecmd - -import ( - "github.com/spf13/cobra" - - "github.com/ignite/cli/v29/ignite/pkg/cosmosaccount" - "github.com/ignite/cli/v29/ignite/pkg/cosmosclient" - "github.com/ignite/cli/v29/ignite/pkg/xurl" -) - -const ( - flagNode = "node" - cosmosRPCAddress = "https://rpc.cosmos.directory:443/cosmoshub" -) - -func NewNode() *cobra.Command { - c := &cobra.Command{ - Use: "node [command]", - Short: "Make requests to a live blockchain node", - Args: cobra.ExactArgs(1), - } - - c.PersistentFlags().String(flagNode, cosmosRPCAddress, ": to tendermint rpc interface for this chain") - - c.AddCommand( - NewNodeQuery(), - NewNodeTx(), - ) - - return c -} - -func newNodeCosmosClient(cmd *cobra.Command) (cosmosclient.Client, error) { - var ( - home = getHome(cmd) - prefix = getAddressPrefix(cmd) - node = getNode(cmd) - keyringBackend = getKeyringBackend(cmd) - keyringDir = getKeyringDir(cmd) - gas = getGas(cmd) - gasPrices = getGasPrices(cmd) - gasAdjustment = getGasAdjustment(cmd) - fees = getFees(cmd) - generateOnly = getGenerateOnly(cmd) - ) - if keyringBackend == "" { - // Makes cosmosclient usable for commands that doesn't expose the keyring - // backend flag (cosmosclient.New returns an error if it's empty). - keyringBackend = cosmosaccount.KeyringTest - } - - options := []cosmosclient.Option{ - cosmosclient.WithAddressPrefix(prefix), - cosmosclient.WithHome(home), - cosmosclient.WithKeyringBackend(keyringBackend), - cosmosclient.WithKeyringDir(keyringDir), - cosmosclient.WithNodeAddress(xurl.HTTPEnsurePort(node)), - cosmosclient.WithGenerateOnly(generateOnly), - } - - if gas != "" { - options = append(options, cosmosclient.WithGas(gas)) - } - if gasPrices != "" { - options = append(options, cosmosclient.WithGasPrices(gasPrices)) - } - if gasAdjustment != 0 { - options = append(options, cosmosclient.WithGasAdjustment(gasAdjustment)) - } - if fees != "" { - options = append(options, cosmosclient.WithFees(fees)) - } - - return cosmosclient.New(cmd.Context(), options...) -} - -func getNode(cmd *cobra.Command) (node string) { - node, _ = cmd.Flags().GetString(flagNode) - return -} diff --git a/ignite/cmd/node_query.go b/ignite/cmd/node_query.go deleted file mode 100644 index e1c033cefc..0000000000 --- a/ignite/cmd/node_query.go +++ /dev/null @@ -1,76 +0,0 @@ -package ignitecmd - -import ( - "fmt" - - "github.com/spf13/cobra" - flag "github.com/spf13/pflag" - - "github.com/cosmos/cosmos-sdk/types/query" - - "github.com/ignite/cli/v29/ignite/pkg/errors" -) - -const ( - flagPage = "page" - flagLimit = "limit" - flagPageKey = "page-key" - flagOffset = "offset" - flagCountTotal = "count-total" - flagReverse = "reverse" -) - -func NewNodeQuery() *cobra.Command { - c := &cobra.Command{ - Use: "query", - Short: "Querying subcommands", - Aliases: []string{"q"}, - } - - c.AddCommand( - NewNodeQueryBank(), - NewNodeQueryTx(), - ) - - return c -} - -func flagSetPagination(query string) *flag.FlagSet { - fs := flag.NewFlagSet("", flag.ContinueOnError) - - fs.Uint64(flagPage, 1, fmt.Sprintf("pagination page of %s to query for. This sets offset to a multiple of limit", query)) - fs.String(flagPageKey, "", fmt.Sprintf("pagination page-key of %s to query for", query)) - fs.Uint64(flagOffset, 0, fmt.Sprintf("pagination offset of %s to query for", query)) - fs.Uint64(flagLimit, 100, fmt.Sprintf("pagination limit of %s to query for", query)) - fs.Bool(flagCountTotal, false, fmt.Sprintf("count total number of records in %s to query for", query)) - fs.Bool(flagReverse, false, "results are sorted in descending order") - - return fs -} - -func getPagination(cmd *cobra.Command) (*query.PageRequest, error) { - var ( - pageKey, _ = cmd.Flags().GetString(flagPageKey) - offset, _ = cmd.Flags().GetUint64(flagOffset) - limit, _ = cmd.Flags().GetUint64(flagLimit) - countTotal, _ = cmd.Flags().GetBool(flagCountTotal) - page, _ = cmd.Flags().GetUint64(flagPage) - reverse, _ = cmd.Flags().GetBool(flagReverse) - ) - - if page > 1 && offset > 0 { - return nil, errors.New("page and offset cannot be used together") - } - - if page > 1 { - offset = (page - 1) * limit - } - - return &query.PageRequest{ - Key: []byte(pageKey), - Offset: offset, - Limit: limit, - CountTotal: countTotal, - Reverse: reverse, - }, nil -} diff --git a/ignite/cmd/node_query_bank.go b/ignite/cmd/node_query_bank.go deleted file mode 100644 index 9ebf9cc287..0000000000 --- a/ignite/cmd/node_query_bank.go +++ /dev/null @@ -1,14 +0,0 @@ -package ignitecmd - -import "github.com/spf13/cobra" - -func NewNodeQueryBank() *cobra.Command { - c := &cobra.Command{ - Use: "bank", - Short: "Querying commands for the bank module", - } - - c.AddCommand(NewNodeQueryBankBalances()) - - return c -} diff --git a/ignite/cmd/node_query_bank_balances.go b/ignite/cmd/node_query_bank_balances.go deleted file mode 100644 index 2b25fbca10..0000000000 --- a/ignite/cmd/node_query_bank_balances.go +++ /dev/null @@ -1,59 +0,0 @@ -package ignitecmd - -import ( - "github.com/spf13/cobra" - - "github.com/ignite/cli/v29/ignite/pkg/cliui" -) - -func NewNodeQueryBankBalances() *cobra.Command { - c := &cobra.Command{ - Use: "balances [from_account_or_address]", - Short: "Query for account balances by account name or address", - RunE: nodeQueryBankBalancesHandler, - Args: cobra.ExactArgs(1), - } - - c.Flags().AddFlagSet(flagSetHome()) - c.Flags().AddFlagSet(flagSetAccountPrefixes()) - c.Flags().AddFlagSet(flagSetKeyringBackend()) - c.Flags().AddFlagSet(flagSetKeyringDir()) - c.Flags().AddFlagSet(flagSetPagination("all balances")) - - return c -} - -func nodeQueryBankBalancesHandler(cmd *cobra.Command, args []string) error { - session := cliui.New(cliui.StartSpinnerWithText(statusQuerying)) - defer session.End() - - inputAccount := args[0] - - client, err := newNodeCosmosClient(cmd) - if err != nil { - return err - } - - // inputAccount can be an account of the keyring or a raw address - address, err := client.Address(inputAccount) - if err != nil { - address = inputAccount - } - - pagination, err := getPagination(cmd) - if err != nil { - return err - } - - balances, err := client.BankBalances(cmd.Context(), address, pagination) - if err != nil { - return err - } - - var rows [][]string - for _, b := range balances { - rows = append(rows, []string{b.Amount.String(), b.Denom}) - } - - return session.PrintTable([]string{"Amount", "Denom"}, rows...) -} diff --git a/ignite/cmd/node_query_tx.go b/ignite/cmd/node_query_tx.go deleted file mode 100644 index 8d47cb4946..0000000000 --- a/ignite/cmd/node_query_tx.go +++ /dev/null @@ -1,45 +0,0 @@ -package ignitecmd - -import ( - "encoding/hex" - "encoding/json" - - "github.com/spf13/cobra" - - "github.com/ignite/cli/v29/ignite/pkg/cliui" -) - -func NewNodeQueryTx() *cobra.Command { - c := &cobra.Command{ - Use: "tx [hash]", - Short: "Query for transaction by hash", - RunE: nodeQueryTxHandler, - Args: cobra.ExactArgs(1), - } - return c -} - -func nodeQueryTxHandler(cmd *cobra.Command, args []string) error { - session := cliui.New(cliui.StartSpinnerWithText(statusQuerying)) - defer session.End() - - bz, err := hex.DecodeString(args[0]) - if err != nil { - return err - } - client, err := newNodeCosmosClient(cmd) - if err != nil { - return err - } - - resp, err := client.RPC.Tx(cmd.Context(), bz, false) - if err != nil { - return err - } - bz, err = json.MarshalIndent(resp, "", " ") - if err != nil { - return err - } - - return session.Println(string(bz)) -} diff --git a/ignite/cmd/node_tx.go b/ignite/cmd/node_tx.go deleted file mode 100644 index 883aae251f..0000000000 --- a/ignite/cmd/node_tx.go +++ /dev/null @@ -1,75 +0,0 @@ -package ignitecmd - -import ( - "fmt" - - "github.com/spf13/cobra" - flag "github.com/spf13/pflag" -) - -const ( - flagGenerateOnly = "generate-only" - - gasFlagAuto = "auto" - flagGasPrices = "gas-prices" - flagAdjustment = "gas-adjustment" - flagGas = "gas" - flagFees = "fees" -) - -func NewNodeTx() *cobra.Command { - c := &cobra.Command{ - Use: "tx", - Short: "Transactions subcommands", - } - c.PersistentFlags().AddFlagSet(flagSetHome()) - c.PersistentFlags().AddFlagSet(flagSetKeyringBackend()) - c.PersistentFlags().AddFlagSet(flagSetAccountPrefixes()) - c.PersistentFlags().AddFlagSet(flagSetKeyringDir()) - c.PersistentFlags().AddFlagSet(flagSetGenerateOnly()) - c.PersistentFlags().AddFlagSet(flagSetGasFlags()) - c.PersistentFlags().String(flagFees, "", "fees to pay along with transaction; eg: 10uatom") - - c.AddCommand(NewNodeTxBank()) - - return c -} - -func flagSetGenerateOnly() *flag.FlagSet { - fs := flag.NewFlagSet("", flag.ContinueOnError) - fs.Bool(flagGenerateOnly, false, "build an unsigned transaction and write it to STDOUT") - return fs -} - -func getGenerateOnly(cmd *cobra.Command) bool { - generateOnly, _ := cmd.Flags().GetBool(flagGenerateOnly) - return generateOnly -} - -func flagSetGasFlags() *flag.FlagSet { - fs := flag.NewFlagSet("", flag.ContinueOnError) - fs.String(flagGasPrices, "", "gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)") - fs.String(flagGas, gasFlagAuto, fmt.Sprintf("gas limit to set per-transaction; set to %q to calculate sufficient gas automatically", gasFlagAuto)) - fs.Float64(flagAdjustment, 0, "gas adjustment to set per-transaction") - return fs -} - -func getGasPrices(cmd *cobra.Command) string { - gasPrices, _ := cmd.Flags().GetString(flagGasPrices) - return gasPrices -} - -func getGasAdjustment(cmd *cobra.Command) float64 { - gasAdjustment, _ := cmd.Flags().GetFloat64(flagAdjustment) - return gasAdjustment -} - -func getGas(cmd *cobra.Command) string { - gas, _ := cmd.Flags().GetString(flagGas) - return gas -} - -func getFees(cmd *cobra.Command) string { - fees, _ := cmd.Flags().GetString(flagFees) - return fees -} diff --git a/ignite/cmd/node_tx_bank.go b/ignite/cmd/node_tx_bank.go deleted file mode 100644 index 9c541a5b36..0000000000 --- a/ignite/cmd/node_tx_bank.go +++ /dev/null @@ -1,14 +0,0 @@ -package ignitecmd - -import "github.com/spf13/cobra" - -func NewNodeTxBank() *cobra.Command { - c := &cobra.Command{ - Use: "bank", - Short: "Bank transaction subcommands", - } - - c.AddCommand(NewNodeTxBankSend()) - - return c -} diff --git a/ignite/cmd/node_tx_bank_send.go b/ignite/cmd/node_tx_bank_send.go deleted file mode 100644 index ed8ca47579..0000000000 --- a/ignite/cmd/node_tx_bank_send.go +++ /dev/null @@ -1,78 +0,0 @@ -package ignitecmd - -import ( - "github.com/spf13/cobra" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/ignite/cli/v29/ignite/pkg/cliui" -) - -func NewNodeTxBankSend() *cobra.Command { - c := &cobra.Command{ - Use: "send [from_account_or_address] [to_account_or_address] [amount]", - Short: "Send funds from one account to another.", - RunE: nodeTxBankSendHandler, - Args: cobra.ExactArgs(3), - } - - return c -} - -func nodeTxBankSendHandler(cmd *cobra.Command, args []string) error { - session := cliui.New() - defer session.End() - - var ( - fromAccountInput = args[0] - toAccountInput = args[1] - amount = args[2] - generateOnly = getGenerateOnly(cmd) - ) - - client, err := newNodeCosmosClient(cmd) - if err != nil { - return err - } - - // fromAccountInput must be an account of the keyring - fromAccount, err := client.Account(fromAccountInput) - if err != nil { - return err - } - - // toAccountInput can be an account of the keyring or a raw address - toAddress, err := client.Address(toAccountInput) - if err != nil { - toAddress = toAccountInput - } - - coins, err := sdk.ParseCoinsNormalized(amount) - if err != nil { - return err - } - - tx, err := client.BankSendTx(cmd.Context(), fromAccount, toAddress, coins) - if err != nil { - return err - } - - if generateOnly { - json, err := tx.EncodeJSON() - if err != nil { - return err - } - - return session.Println(string(json)) - } - - session.StartSpinner("Sending transaction...") - resp, err := tx.Broadcast(cmd.Context()) - if err != nil { - return err - } - - session.Printf("Transaction broadcast successful! (hash = %s)\n", resp.TxHash) - session.Printf("%s sent from %s to %s\n", amount, fromAccountInput, toAccountInput) - return nil -} diff --git a/integration/node/cmd_query_bank_test.go b/integration/node/cmd_query_bank_test.go deleted file mode 100644 index b72c45ae5e..0000000000 --- a/integration/node/cmd_query_bank_test.go +++ /dev/null @@ -1,288 +0,0 @@ -package node_test - -import ( - "bytes" - "context" - "path/filepath" - "strings" - "testing" - - "github.com/cosmos/cosmos-sdk/crypto/keyring" - sdktypes "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - chainconfig "github.com/ignite/cli/v29/ignite/config/chain" - "github.com/ignite/cli/v29/ignite/config/chain/base" - "github.com/ignite/cli/v29/ignite/pkg/cliui/entrywriter" - "github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step" - "github.com/ignite/cli/v29/ignite/pkg/cosmosaccount" - "github.com/ignite/cli/v29/ignite/pkg/cosmosclient" - "github.com/ignite/cli/v29/ignite/pkg/randstr" - "github.com/ignite/cli/v29/ignite/pkg/xurl" - "github.com/ignite/cli/v29/ignite/pkg/xyaml" - envtest "github.com/ignite/cli/v29/integration" -) - -const ( - keyringTestDirName = "keyring-test" - testPrefix = "testpref" -) - -func assertBankBalanceOutput(t *testing.T, output string, balances string) { - var table [][]string - coins, err := sdktypes.ParseCoinsNormalized(balances) - require.NoError(t, err, "wrong balances %s", balances) - for _, c := range coins { - table = append(table, []string{c.Amount.String(), c.Denom}) - } - var expectedBalances strings.Builder - _ = entrywriter.MustWrite(&expectedBalances, []string{"Amount", "Denom"}, table...) - assert.Contains(t, output, expectedBalances.String()) -} - -func TestNodeQueryBankBalances(t *testing.T) { - var ( - appname = randstr.Runes(10) - alice = "alice" - - env = envtest.New(t) - app = env.Scaffold(appname, "--address-prefix", testPrefix) - home = env.AppHome(appname) - servers = app.RandomizeServerPorts() - - accKeyringDir = t.TempDir() - ) - - node, err := xurl.HTTP(servers.RPC) - require.NoError(t, err) - - ca, err := cosmosaccount.New( - cosmosaccount.WithHome(filepath.Join(home, keyringTestDirName)), - cosmosaccount.WithKeyringBackend(cosmosaccount.KeyringTest), - ) - require.NoError(t, err) - - aliceAccount, aliceMnemonic, err := ca.Create(alice) - require.NoError(t, err) - - app.EditConfig(func(c *chainconfig.Config) { - c.Accounts = []base.Account{ - { - Name: alice, - Mnemonic: aliceMnemonic, - Coins: []string{"5600atoken", "1200btoken", "100000000stake"}, - }, - } - c.Faucet = base.Faucet{} - c.Validators[0].Client = xyaml.Map{ - "keyring-backend": keyring.BackendTest, - } - }) - - env.Must(env.Exec("import alice", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "account", - "import", - alice, - "--keyring-dir", accKeyringDir, - "--non-interactive", - "--secret", aliceMnemonic, - ), - )), - )) - - var ( - ctx, cancel = context.WithTimeout(env.Ctx(), envtest.ServeTimeout) - isBackendAliveErr error - ) - - // do not fail the test in a goroutine, it has to be done in the main. - go func() { - defer cancel() - - if isBackendAliveErr = env.IsAppServed(ctx, servers.API); isBackendAliveErr != nil { - return - } - - client, err := cosmosclient.New(context.Background(), - cosmosclient.WithAddressPrefix(testPrefix), - cosmosclient.WithNodeAddress(node), - ) - require.NoError(t, err) - waitForNextBlock(env, client) - - b := &bytes.Buffer{} - - env.Exec("query bank balances by account name", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "query", - "bank", - "balances", - "alice", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - ), - )), - envtest.ExecStdout(b), - ) - - if env.HasFailed() { - return - } - - assertBankBalanceOutput(t, b.String(), "5600atoken,1200btoken") - - b.Reset() - - aliceAddr, err := aliceAccount.Address(testPrefix) - require.NoError(t, err) - - env.Exec("query bank balances by address", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "query", - "bank", - "balances", - aliceAddr, - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - ), - )), - envtest.ExecStdout(b), - ) - - if env.HasFailed() { - return - } - - assertBankBalanceOutput(t, b.String(), "5600atoken,1200btoken") - - b.Reset() - env.Exec("query bank balances with pagination -page 1", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "query", - "bank", - "balances", - "alice", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - "--limit", "1", - "--page", "1", - ), - )), - envtest.ExecStdout(b), - ) - - if env.HasFailed() { - return - } - - assertBankBalanceOutput(t, b.String(), "5600atoken") - assert.NotContains(t, b.String(), "btoken") - - b.Reset() - env.Exec("query bank balances with pagination -page 2", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "query", - "bank", - "balances", - "alice", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - "--limit", "1", - "--page", "2", - ), - )), - envtest.ExecStdout(b), - ) - - if env.HasFailed() { - return - } - - assertBankBalanceOutput(t, b.String(), "1200btoken") - assert.NotContains(t, b.String(), "atoken") - - b.Reset() - env.Exec("query bank balances fail with non-existent account name", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "query", - "bank", - "balances", - "nonexistentaccount", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - ), - )), - envtest.ExecShouldError(), - ) - - if env.HasFailed() { - return - } - - env.Exec("query bank balances fail with non-existent address", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "query", - "bank", - "balances", - testPrefix+"1gspvt8qsk8cryrsxnqt452cjczjm5ejdgla24e", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - ), - )), - envtest.ExecShouldError(), - ) - - if env.HasFailed() { - return - } - - env.Exec("query bank balances should fail with a wrong prefix", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "query", - "bank", - "balances", - "alice", - "--node", node, - "--keyring-dir", accKeyringDir, - // the default prefix will fail this test, which is on purpose. - ), - )), - envtest.ExecShouldError(), - ) - }() - - env.Must(app.Serve("should serve", envtest.ExecCtx(ctx))) - - require.NoError(t, isBackendAliveErr, "app cannot get online in time") -} diff --git a/integration/node/cmd_query_tx_test.go b/integration/node/cmd_query_tx_test.go deleted file mode 100644 index 8dc2b00389..0000000000 --- a/integration/node/cmd_query_tx_test.go +++ /dev/null @@ -1,96 +0,0 @@ -package node_test - -import ( - "bytes" - "context" - "regexp" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step" - "github.com/ignite/cli/v29/ignite/pkg/cosmosclient" - "github.com/ignite/cli/v29/ignite/pkg/randstr" - "github.com/ignite/cli/v29/ignite/pkg/xurl" - envtest "github.com/ignite/cli/v29/integration" -) - -func TestNodeQueryTx(t *testing.T) { - var ( - appname = randstr.Runes(10) - // alice = "alice" - // bob = "bob" - - env = envtest.New(t) - app = env.Scaffold(appname) - home = env.AppHome(appname) - servers = app.RandomizeServerPorts() - - // accKeyringDir = t.TempDir() - ) - - node, err := xurl.HTTP(servers.RPC) - require.NoError(t, err) - - var ( - ctx, cancel = context.WithTimeout(env.Ctx(), envtest.ServeTimeout) - isBackendAliveErr error - ) - - go func() { - defer cancel() - - if isBackendAliveErr = env.IsAppServed(ctx, servers.API); isBackendAliveErr != nil { - return - } - client, err := cosmosclient.New(context.Background(), - cosmosclient.WithAddressPrefix(testPrefix), - cosmosclient.WithNodeAddress(node), - ) - require.NoError(t, err) - waitForNextBlock(env, client) - - b := &bytes.Buffer{} - env.Exec("send 100token from alice to bob", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "tx", - "bank", - "send", - "alice", - "bob", - "100token", - "--node", node, - "--keyring-dir", home, - ), - step.Stdout(b), - )), - ) - require.False(t, env.HasFailed(), b.String()) - - // Parse tx hash from output - res := regexp.MustCompile(`\(hash = (\w+)\)`).FindAllStringSubmatch(b.String(), -1) - require.Len(t, res[0], 2, "can't extract hash from command output") - hash := res[0][1] - waitForNextBlock(env, client) - - env.Must(env.Exec("query tx", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "query", - "tx", - hash, - "--node", node, - ), - )), - )) - }() - - env.Must(app.Serve("should serve", envtest.ExecCtx(ctx))) - - require.NoError(t, isBackendAliveErr, "app cannot get online in time") -} diff --git a/integration/node/cmd_tx_bank_send_test.go b/integration/node/cmd_tx_bank_send_test.go deleted file mode 100644 index 6c8a63ff05..0000000000 --- a/integration/node/cmd_tx_bank_send_test.go +++ /dev/null @@ -1,339 +0,0 @@ -package node_test - -import ( - "bytes" - "context" - "fmt" - "path/filepath" - "testing" - "time" - - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/stretchr/testify/require" - - chainconfig "github.com/ignite/cli/v29/ignite/config/chain" - "github.com/ignite/cli/v29/ignite/config/chain/base" - "github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step" - "github.com/ignite/cli/v29/ignite/pkg/cosmosaccount" - "github.com/ignite/cli/v29/ignite/pkg/cosmosclient" - "github.com/ignite/cli/v29/ignite/pkg/randstr" - "github.com/ignite/cli/v29/ignite/pkg/xurl" - "github.com/ignite/cli/v29/ignite/pkg/xyaml" - envtest "github.com/ignite/cli/v29/integration" -) - -func waitForNextBlock(env envtest.Env, client cosmosclient.Client) { - ctx, cancel := context.WithTimeout(env.Ctx(), time.Second*10) - defer cancel() - require.NoError(env.T(), client.WaitForNextBlock(ctx)) -} - -func TestNodeTxBankSend(t *testing.T) { - var ( - appname = randstr.Runes(10) - alice = "alice" - bob = "bob" - - env = envtest.New(t) - app = env.Scaffold(appname, "--address-prefix", testPrefix) - home = env.AppHome(appname) - servers = app.RandomizeServerPorts() - - accKeyringDir = t.TempDir() - ) - - node, err := xurl.HTTP(servers.RPC) - require.NoError(t, err) - - ca, err := cosmosaccount.New( - cosmosaccount.WithHome(filepath.Join(home, keyringTestDirName)), - cosmosaccount.WithKeyringBackend(cosmosaccount.KeyringTest), - ) - require.NoError(t, err) - - aliceAccount, aliceMnemonic, err := ca.Create(alice) - require.NoError(t, err) - - bobAccount, bobMnemonic, err := ca.Create(bob) - require.NoError(t, err) - - app.EditConfig(func(c *chainconfig.Config) { - c.Accounts = []base.Account{ - { - Name: alice, - Mnemonic: aliceMnemonic, - Coins: []string{"2000token", "100000000stake"}, - }, - { - Name: bob, - Mnemonic: bobMnemonic, - Coins: []string{"10000token", "100000000stake"}, - }, - } - c.Faucet = base.Faucet{} - c.Validators[0].Client = xyaml.Map{ - "keyring-backend": keyring.BackendTest, - } - }) - env.Must(env.Exec("import alice", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "account", - "import", - "alice", - "--keyring-dir", accKeyringDir, - "--non-interactive", - "--secret", aliceMnemonic, - ), - )), - )) - - env.Must(env.Exec("import bob", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "account", - "import", - "bob", - "--keyring-dir", accKeyringDir, - "--non-interactive", - "--secret", bobMnemonic, - ), - )), - )) - - var ( - ctx, cancel = context.WithTimeout(env.Ctx(), envtest.ServeTimeout) - isBackendAliveErr error - ) - - go func() { - defer cancel() - - if isBackendAliveErr = env.IsAppServed(ctx, servers.API); isBackendAliveErr != nil { - return - } - client, err := cosmosclient.New(context.Background(), - cosmosclient.WithAddressPrefix(testPrefix), - cosmosclient.WithNodeAddress(node), - ) - require.NoError(t, err) - waitForNextBlock(env, client) - - env.Exec("send 100token from alice to bob", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "tx", - "bank", - "send", - "alice", - "bob", - "100token", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - ), - )), - ) - - if env.HasFailed() { - return - } - - bobAddr, err := bobAccount.Address(testPrefix) - require.NoError(t, err) - aliceAddr, err := aliceAccount.Address(testPrefix) - require.NoError(t, err) - - env.Exec("send 2stake from bob to alice using addresses", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "tx", - "bank", - "send", - bobAddr, - aliceAddr, - "2stake", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - ), - )), - ) - - if env.HasFailed() { - return - } - - env.Exec("send 5token from alice to bob using a combination of address and account", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "tx", - "bank", - "send", - "alice", - bobAddr, - "5token", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - ), - )), - ) - - if env.HasFailed() { - return - } - - b := &bytes.Buffer{} - env.Exec("query bank balances for alice", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "query", - "bank", - "balances", - "alice", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - ), - )), - envtest.ExecStdout(b), - ) - - assertBankBalanceOutput(t, b.String(), "2stake,1895token") - - if env.HasFailed() { - return - } - - b.Reset() - env.Exec("query bank balances for bob", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "query", - "bank", - "balances", - "bob", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - ), - )), - envtest.ExecStdout(b), - ) - - assertBankBalanceOutput(t, b.String(), "99999998stake,10105token") - - // check generated tx - b.Reset() - env.Exec("generate unsigned tx", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "tx", - "bank", - "send", - "alice", - "bob", - "5token", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - "--generate-only", - ), - )), - envtest.ExecStdout(b), - ) - - require.Contains(t, b.String(), - fmt.Sprintf(`"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"%s","to_address":"%s","amount":[{"denom":"token","amount":"5"}]}]`, - aliceAddr, bobAddr), - ) - require.Contains(t, b.String(), `"signatures":[]`) - - // test with gas - env.Exec("send 100token from bob to alice with gas flags", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "tx", - "bank", - "send", - "bob", - "alice", - "100token", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - "--gas", "200000", - "--gas-prices", "1stake", - "--gas-adjustment", "1.8", - ), - )), - ) - - // not enough minerals - env.Exec("send 100token from alice to bob with too little gas", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "tx", - "bank", - "send", - "alice", - "bob", - "100token", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - "--gas", "2", - "--gas-prices", "1stake", - ), - )), - envtest.ExecShouldError(), - ) - - b.Reset() - env.Exec("generate bank send tx with gas flags", - step.NewSteps(step.New( - step.Exec( - envtest.IgniteApp, - "node", - "tx", - "bank", - "send", - "alice", - "bob", - "100token", - "--node", node, - "--keyring-dir", accKeyringDir, - "--address-prefix", testPrefix, - "--gas", "2000034", - "--gas-prices", "0.089stake", - "--generate-only", - ), - )), - envtest.ExecStdout(b), - ) - require.Contains(t, b.String(), `"fee":{"amount":[{"denom":"stake","amount":"178004"}],"gas_limit":"2000034"`) - }() - - env.Must(app.Serve("should serve", envtest.ExecCtx(ctx))) - - require.NoError(t, isBackendAliveErr, "app cannot get online in time") -} From a353d046eb77097140655e6cb78618ef2b0fd4cd Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 13 Jun 2024 16:56:46 +0200 Subject: [PATCH 2/4] changelog --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 734b2f5cd1..ddecd1e5c8 100644 --- a/changelog.md +++ b/changelog.md @@ -41,7 +41,7 @@ - [#4167](https://github.com/ignite/cli/pull/4167) Scaffold `int64` instead of `int32` when a field type is `int` - [#4168](https://github.com/ignite/cli/pull/4168) Bump IBC to `v8.3.1` - [#4178](https://github.com/ignite/cli/pull/4178) Bump cosmos-sdk to `v0.50.7` -- []() Deprecate `ignite node` for `ignite connect` app +- [#4189](https://github.com/ignite/cli/pull/4189) Deprecate `ignite node` for `ignite connect` app ### Fixes From eacaed4d19328e6ac3b0718415fc767e5399600f Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 13 Jun 2024 17:02:15 +0200 Subject: [PATCH 3/4] updates --- ignite/cmd/cmd.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ignite/cmd/cmd.go b/ignite/cmd/cmd.go index 847d6bf565..73d1b76cd9 100644 --- a/ignite/cmd/cmd.go +++ b/ignite/cmd/cmd.go @@ -147,11 +147,6 @@ func flagSetHome() *flag.FlagSet { return fs } -func getHome(cmd *cobra.Command) (home string) { - home, _ = cmd.Flags().GetString(flagHome) - return -} - func flagSetConfig() *flag.FlagSet { fs := flag.NewFlagSet("", flag.ContinueOnError) fs.StringP(flagConfig, "c", "", "path to Ignite config file (default: ./config.yml)") From b44b334159ddabf292653aea9d5034b8ff30bfd7 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 13 Jun 2024 17:28:53 +0200 Subject: [PATCH 4/4] update ignite account note --- ignite/cmd/account.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ignite/cmd/account.go b/ignite/cmd/account.go index f83f7fc820..a8598ed7e4 100644 --- a/ignite/cmd/account.go +++ b/ignite/cmd/account.go @@ -25,7 +25,7 @@ func NewAccount() *cobra.Command { Short: "Create, delete, and show Ignite accounts", Long: `Commands for managing Ignite accounts. An Ignite account is a private/public keypair stored in a keyring. Currently Ignite accounts are used when interacting -with Ignite relayer commands and when using "ignite network" commands. +with Ignite Apps (namely ignite relayer, ignite network and ignite connect). Note: Ignite account commands are not for managing your chain's keys and accounts. Use you chain's binary to manage accounts from "config.yml". For example, if your