diff --git a/cmd/nolusd/genwasm.go b/cmd/nolusd/genwasm.go index c0cf4302..16ab9ec4 100644 --- a/cmd/nolusd/genwasm.go +++ b/cmd/nolusd/genwasm.go @@ -8,7 +8,7 @@ import ( func addGenesisWasmMsgCmd(defaultNodeHome string) *cobra.Command { txCmd := &cobra.Command{ - Use: "add-wasm-message", + Use: "add-wasm-genesis-message", Short: "Wasm genesis subcommands", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, diff --git a/cmd/nolusd/root.go b/cmd/nolusd/root.go index b1b266fa..cb466ccb 100644 --- a/cmd/nolusd/root.go +++ b/cmd/nolusd/root.go @@ -11,12 +11,12 @@ import ( "cosmossdk.io/store/snapshots" snapshottypes "cosmossdk.io/store/snapshots/types" storetypes "cosmossdk.io/store/types" + confixcmd "cosmossdk.io/tools/confix/cmd" "github.com/CosmWasm/wasmd/x/wasm" tmcfg "github.com/cometbft/cometbft/config" tmcli "github.com/cometbft/cometbft/libs/cli" - tmtypes "github.com/cometbft/cometbft/types" db "github.com/cosmos/cosmos-db" @@ -27,9 +27,11 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/rpc" + "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/cosmos/cosmos-sdk/types/module" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -38,6 +40,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/genutil" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/spf13/cast" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -135,6 +138,18 @@ func NewRootCmd( rootOptions := newRootOptions() encodingConfig := app.MakeEncodingConfig(moduleBasics) + tempApp := app.New( + log.NewNopLogger(), + db.NewMemDB(), + nil, + true, + nil, + tempDir(), + 0, + encodingConfig, + simtestutil.NewAppOptionsWithFlagHome(tempDir()), + ) + initClientCtx := client.Context{}. WithCodec(encodingConfig.Marshaler). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). @@ -180,6 +195,17 @@ func NewRootCmd( moduleBasics, rootOptions, ) + + // add keyring to autocli opts + autoCliOpts := tempApp.AutoCliOpts() + initClientCtx, _ = config.ReadDefaultValuesFromDefaultClientConfig(initClientCtx) + autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring) + autoCliOpts.ClientCtx = initClientCtx + + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { + panic(err) + } + overwriteFlagDefaults(rootCmd, map[string]string{ flags.FlagChainID: defaultChainID, flags.FlagKeyringBackend: "test", @@ -214,8 +240,7 @@ func initRootCmd( addGenesisWasmMsgCmd(defaultNodeHome), tmcli.NewCompletionCmd(rootCmd, true), debug.Cmd(), - // TODO: cmd/nolusd/config.go - // ConfigCmd(), + confixcmd.ConfigCommand(), // TODO: test and decide if we need those two new pruning/snapshot commands // pruning.Cmd(newApp, simapp.DefaultNodeHome), @@ -292,15 +317,17 @@ func txCommand(moduleBasics module.BasicManager) *cobra.Command { authcmd.GetSignCommand(), authcmd.GetSignBatchCommand(), authcmd.GetMultiSignCommand(), + authcmd.GetMultiSignBatchCmd(), authcmd.GetValidateSignaturesCommand(), flags.LineBreak, authcmd.GetBroadcastCommand(), authcmd.GetEncodeCommand(), authcmd.GetDecodeCommand(), + authcmd.GetSimulateCmd(), ) // TODO: autocli - moduleBasics.AddTxCommands(cmd) + // moduleBasics.AddTxCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd @@ -372,7 +399,7 @@ func (a appCreator) newApp( chainID := cast.ToString(appOpts.Get(flags.FlagChainID)) if chainID == "" { // fallback to genesis chain-id - appGenesis, err := tmtypes.GenesisDocFromFile(filepath.Join(homePath, "config", "genesis.json")) + appGenesis, err := genutiltypes.AppGenesisFromFile(filepath.Join(homePath, "config", "genesis.json")) if err != nil { panic(err) } @@ -500,3 +527,13 @@ lru_size = 0` return customAppTemplate, customAppConfig } + +var tempDir = func() string { + dir, err := os.MkdirTemp("", "nolusd") + if err != nil { + panic("failed to create temp dir: " + err.Error()) + } + defer os.RemoveAll(dir) + + return dir +} diff --git a/go.mod b/go.mod index 8be6241b..b8be3c21 100644 --- a/go.mod +++ b/go.mod @@ -29,8 +29,10 @@ require ( cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.0.2 + cosmossdk.io/tools/confix v0.1.1 cosmossdk.io/x/evidence v0.1.0 cosmossdk.io/x/feegrant v0.1.0 + cosmossdk.io/x/tx v0.13.0 cosmossdk.io/x/upgrade v0.1.1 github.com/cosmos/cosmos-db v1.0.0 github.com/cosmos/cosmos-proto v1.0.0-beta.4 @@ -51,7 +53,6 @@ require ( cosmossdk.io/collections v0.4.0 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect cosmossdk.io/x/circuit v0.1.0 // indirect - cosmossdk.io/x/tx v0.13.0 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.2 // indirect @@ -83,6 +84,8 @@ require ( github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/interchain-security/v5 v5.0.0-alpha1 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect + github.com/creachadair/atomicfile v0.3.1 // indirect + github.com/creachadair/tomledit v0.0.24 // indirect github.com/danieljoos/wincred v1.2.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect diff --git a/go.sum b/go.sum index a42e4f59..42099ad5 100644 --- a/go.sum +++ b/go.sum @@ -202,6 +202,8 @@ cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/store v1.0.2 h1:lSg5BTvJBHUDwswNNyeh4K/CbqiHER73VU4nDNb8uk0= cosmossdk.io/store v1.0.2/go.mod h1:EFtENTqVTuWwitGW1VwaBct+yDagk7oG/axBMPH+FXs= +cosmossdk.io/tools/confix v0.1.1 h1:aexyRv9+y15veH3Qw16lxQwo+ki7r2I+g0yNTEFEQM8= +cosmossdk.io/tools/confix v0.1.1/go.mod h1:nQVvP1tHsGXS83PonPVWJtSbddIqyjEw99L4M3rPJyQ= cosmossdk.io/x/circuit v0.1.0 h1:IAej8aRYeuOMritczqTlljbUVHq1E85CpBqaCTwYgXs= cosmossdk.io/x/circuit v0.1.0/go.mod h1:YDzblVE8+E+urPYQq5kq5foRY/IzhXovSYXb4nwd39w= cosmossdk.io/x/evidence v0.1.0 h1:J6OEyDl1rbykksdGynzPKG5R/zm6TacwW2fbLTW4nCk= @@ -382,6 +384,10 @@ github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5X github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creachadair/atomicfile v0.3.1 h1:yQORkHjSYySh/tv5th1dkKcn02NEW5JleB84sjt+W4Q= +github.com/creachadair/atomicfile v0.3.1/go.mod h1:mwfrkRxFKwpNAflYZzytbSwxvbK6fdGRRlp0KEQc0qU= +github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6QKQDhQ= +github.com/creachadair/tomledit v0.0.24/go.mod h1:9qHbShRWQzSCcn617cMzg4eab1vbLCOjOshAWSzWr8U= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE= diff --git a/scripts/init-local-network.sh b/scripts/init-local-network.sh index a50ef6e7..edfb333d 100755 --- a/scripts/init-local-network.sh +++ b/scripts/init-local-network.sh @@ -326,9 +326,9 @@ while [[ $# -gt 0 ]]; do done __config_client() { - run_cmd "$USER_DIR" config chain-id "$CHAIN_ID" - run_cmd "$USER_DIR" config keyring-backend "test" - run_cmd "$USER_DIR" config node "tcp://${NOLUS_NETWORK_ADDR}:$(first_node_rpc_port)" + run_cmd "$USER_DIR" config set client chain-id "$CHAIN_ID" + run_cmd "$USER_DIR" config set client keyring-backend "test" + run_cmd "$USER_DIR" config set client node "tcp://${NOLUS_NETWORK_ADDR}:$(first_node_rpc_port)" } verify_dir_exist "$WASM_SCRIPT_PATH" "WASM sripts path" diff --git a/scripts/internal/genesis.sh b/scripts/internal/genesis.sh index 33a16be6..7c9b2848 100644 --- a/scripts/internal/genesis.sh +++ b/scripts/internal/genesis.sh @@ -141,8 +141,8 @@ __generate_proto_genesis_no_wasm() { local -a wasm_allowed_addresses=("$admin_contract_addr" "$store_code_privileged_addr") run_cmd "$genesis_home_dir" init genesis_manager --chain-id "$chain_id" - run_cmd "$genesis_home_dir" config keyring-backend test - run_cmd "$genesis_home_dir" config chain-id "$chain_id" + run_cmd "$genesis_home_dir" config set client keyring-backend test + run_cmd "$genesis_home_dir" config set client chain-id "$chain_id" __set_token_denominations "$genesis_file" "$native_currency" __set_tax_recipient "$genesis_file" "$treasury_addr" @@ -230,8 +230,9 @@ __set_gov_parameters() { < "$genesis_file" \ jq '.app_state["gov"]["deposit_params"]["max_deposit_period"]="'"$max_deposit_period"'"' \ - | jq '.app_state["gov"]["params"]["voting_period"]="'"$voting_period"'"' \ - | jq '.app_state["gov"]["voting_params"]["voting_period"]="'"$voting_period"'"' > "$genesis_tmp_file" + | jq '.app_state["gov"]["params"]["voting_period"]="'"$gov_voting_period"'"' \ + | jq '.app_state["gov"]["params"]["expedited_voting_period"]="'"$voting_period"'"' \ + | jq '.app_state["gov"]["voting_params"]["voting_period"]="'"$gov_voting_period"'"' > "$genesis_tmp_file" mv "$genesis_tmp_file" "$genesis_file" } diff --git a/scripts/internal/validators-manager.sh b/scripts/internal/validators-manager.sh index 65e124a6..ce63f4e1 100644 --- a/scripts/internal/validators-manager.sh +++ b/scripts/internal/validators-manager.sh @@ -12,8 +12,8 @@ init_val_mngr_sh() { val_mngr_home_dir="$1" val_mngr_chain_id="$2" - run_cmd "$val_mngr_home_dir" config chain-id "$val_mngr_chain_id" - run_cmd "$val_mngr_home_dir" config keyring-backend test + run_cmd "$val_mngr_home_dir" config set client chain-id "$val_mngr_chain_id" + run_cmd "$val_mngr_home_dir" config set client keyring-backend test } # outputs the generated create validator transaction to the standard output diff --git a/x/tax/keeper/custom_tx_fee_checker_test.go b/x/tax/keeper/custom_tx_fee_checker_test.go index 0042b81c..f79a7326 100644 --- a/x/tax/keeper/custom_tx_fee_checker_test.go +++ b/x/tax/keeper/custom_tx_fee_checker_test.go @@ -5,10 +5,6 @@ import ( "testing" "cosmossdk.io/math" -<<<<<<< HEAD -======= - ->>>>>>> d6418d5 (wip: fix some unit-tests) keepertest "github.com/Nolus-Protocol/nolus-core/testutil/keeper" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -140,13 +136,8 @@ func TestCustomTxFeeCheckerSuccessfulInNLS(t *testing.T) { } // Fail to pay fees in unsupported denom. -<<<<<<< HEAD func TestCustomTxFeeCheckerFailWhenUnsupportedDenom(t *testing.T) { taxKeeper, ctx, _ := keepertest.TaxKeeper(t, true, sdk.DecCoins{sdk.NewDecCoin("unls", sdk.NewInt(1))}) -======= -func TestCustomTxFeeCheckerSuccessfulInUnsupportedDenom(t *testing.T) { - taxKeeper, ctx, _ := keepertest.TaxKeeper(t, true, sdk.DecCoins{sdk.NewDecCoin("unls", math.NewInt(1))}) ->>>>>>> d6418d5 (wip: fix some unit-tests) // create a new CustomTxFeeChecker feeTx := keepertest.MockFeeTx{ Msgs: []sdk.Msg{},