Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.9.1 to cosmos stargate cli fixes #249

Merged
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
4 changes: 1 addition & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,8 @@ func NewWasmApp(
)

// Create IBC Keeper
// TODO: remove amino codec dependency once Tendermint version is upgraded with
// protobuf changes
app.ibcKeeper = ibckeeper.NewKeeper(
app.cdc, appCodec, keys[ibchost.StoreKey], app.stakingKeeper, scopedIBCKeeper,
appCodec, keys[ibchost.StoreKey], app.stakingKeeper, scopedIBCKeeper,
)

// Create Transfer Keepers
Expand Down
38 changes: 30 additions & 8 deletions app/encoding.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
package app

import (
"github.com/CosmWasm/wasmd/x/wasm"
"github.com/cosmos/cosmos-sdk/simapp"
simparams "github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
)

func MakeEncodingConfig() simparams.EncodingConfig {
encodingConfig := simapp.MakeEncodingConfig() // todo: this is the simapp !!!
wasm.RegisterCodec(encodingConfig.Amino)
wasm.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
// EncodingConfig specifies the concrete encoding types to use for a given app.
// This is provided for compatibility between protobuf and amino implementations.
type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Marshaler codec.Marshaler
TxConfig client.TxConfig
Amino *codec.Codec
}

func MakeEncodingConfig() EncodingConfig {
amino := codec.New()
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := codec.NewHybridCodec(amino, interfaceRegistry)
txGen := tx.NewTxConfig(codec.NewProtoCodec(interfaceRegistry), std.DefaultPublicKeyCodec{}, tx.DefaultSignModes)

std.RegisterCodec(amino)
std.RegisterInterfaces(interfaceRegistry)
ModuleBasics.RegisterCodec(amino)
ModuleBasics.RegisterInterfaces(interfaceRegistry)
return EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Marshaler: marshaler,
TxConfig: txGen,
Amino: amino,
}
}
18 changes: 14 additions & 4 deletions cmd/wasmcli/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"
"os"

Expand Down Expand Up @@ -43,7 +44,7 @@ func main() {
WithInput(os.Stdin).
WithAccountRetriever(authtypes.NewAccountRetriever(encodingConfig.Marshaler)).
WithBroadcastMode(flags.BroadcastBlock).
WithHomeDir(app.DefaultNodeHome)
WithHomeDir(app.DefaultCLIHome)
alpe marked this conversation as resolved.
Show resolved Hide resolved

rootCmd := &cobra.Command{
Use: "wasmcli",
Expand All @@ -70,10 +71,19 @@ func main() {
cli.NewCompletionCmd(rootCmd, true),
)

// Add flags and prefix all env exposed with WM
executor := cli.PrepareMainCmd(rootCmd, "WM", app.DefaultCLIHome)
// Create and set a client.Context on the command's Context. During the pre-run
// of the root command, a default initialized client.Context is provided to
// seed child command execution with values such as AccountRetriver, Keyring,
// and a Tendermint RPC. This requires the use of a pointer reference when
// getting and setting the client.Context. Ideally, we utilize
// https://github.com/spf13/cobra/pull/1118.
ctx := context.Background()
ctx = context.WithValue(ctx, client.ClientContextKey, &client.Context{})
ctx = context.WithValue(ctx, server.ServerContextKey, server.NewDefaultContext())

executor := cli.PrepareBaseCmd(rootCmd, "WM", app.DefaultCLIHome)
err := executor.ExecuteContext(ctx)

err := executor.Execute()
if err != nil {
fmt.Printf("Failed executing CLI command: %s, exiting...\n", err)
os.Exit(1)
Expand Down
15 changes: 13 additions & 2 deletions cmd/wasmd/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"encoding/json"
"io"
"os"
Expand Down Expand Up @@ -74,13 +75,23 @@ func main() {
debug.Cmd(),
)

server.AddCommands(rootCmd, newApp, exportAppStateAndTMValidators)
server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, exportAppStateAndTMValidators)

// Create and set a client.Context on the command's Context. During the pre-run
// of the root command, a default initialized client.Context is provided to
// seed child command execution with values such as AccountRetriver, Keyring,
// and a Tendermint RPC. This requires the use of a pointer reference when
// getting and setting the client.Context. Ideally, we utilize
// https://github.com/spf13/cobra/pull/1118.
ctx := context.Background()
ctx = context.WithValue(ctx, client.ClientContextKey, &client.Context{})
ctx = context.WithValue(ctx, server.ServerContextKey, server.NewDefaultContext())

// prepare and add flags
executor := cli.PrepareBaseCmd(rootCmd, "WM", app.DefaultNodeHome)
rootCmd.PersistentFlags().UintVar(&invCheckPeriod, flagInvCheckPeriod,
0, "Assert registered invariants every N blocks")
err := executor.Execute()
err := executor.ExecuteContext(ctx)
if err != nil {
panic(err)
}
Expand Down
11 changes: 0 additions & 11 deletions docker/run_all.sh

This file was deleted.

4 changes: 0 additions & 4 deletions docker/run_rest_server.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docker/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ for addr in "$@"; do
wasmd add-genesis-account "$addr" "1000000000$STAKE,1000000000$FEE"
done
# submit a genesis validator tx
(echo "$PASSWORD"; echo "$PASSWORD"; echo "$PASSWORD") | wasmd gentx --name validator --amount "250000000$STAKE"
(echo "$PASSWORD"; echo "$PASSWORD"; echo "$PASSWORD") | wasmd gentx validator --chain-id=testing --amount "250000000$STAKE"
alpe marked this conversation as resolved.
Show resolved Hide resolved
wasmd collect-gentxs
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.14
require (
// Note: update ENV GO_COSMWASM in Dockerfile when updating this
github.com/CosmWasm/go-cosmwasm v0.9.1
github.com/cosmos/cosmos-sdk v0.34.4-0.20200806092156-3076a8b12ec3
github.com/cosmos/cosmos-sdk v0.34.4-0.20200807102022-3322e269a184
github.com/dvsekhvalnov/jose2go v0.0.0-20180829124132-7f401d37b68a
github.com/gogo/protobuf v1.3.1
github.com/google/gofuzz v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/cosmos-sdk v0.34.4-0.20200806092156-3076a8b12ec3 h1:22rm9uHzeJtlGjVMRIqTUkRFapFU3nwN9xy8KLvLStg=
github.com/cosmos/cosmos-sdk v0.34.4-0.20200806092156-3076a8b12ec3/go.mod h1:7fv4+b5E8Iq9m0MKzR/v/QOLDKcpp+rBZW2JiNRtqMY=
github.com/cosmos/cosmos-sdk v0.34.4-0.20200807102022-3322e269a184 h1:Ogtqklf+8k2mdVl5JVwPVaBIk1Io9KyKdMzoxhq1cw8=
github.com/cosmos/cosmos-sdk v0.34.4-0.20200807102022-3322e269a184/go.mod h1:7fv4+b5E8Iq9m0MKzR/v/QOLDKcpp+rBZW2JiNRtqMY=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
Expand Down