Integrate wasmcli into wasmd

This commit is contained in:
Alex Peters 2020-11-13 15:49:20 +01:00
parent 93761eac33
commit ca040da925
No known key found for this signature in database
GPG Key ID: 4E18CD9F98929E11
16 changed files with 118 additions and 237 deletions

1
.gitignore vendored
View File

@ -22,7 +22,6 @@ docs/node_modules
# Data - ideally these don't exist
baseapp/data/*
client/lcd/keys/*
cmd/wasmcli/statik/statik.go
mytestnet
# Testing

View File

@ -39,12 +39,9 @@ RUN LEDGER_ENABLED=false BUILD_TAGS=muslc make build-gaiaflex
FROM alpine:3.12
COPY --from=go-builder /code/build/wasmd /usr/bin/wasmd
COPY --from=go-builder /code/build/wasmcli /usr/bin/wasmcli
# testnet
COPY --from=go-builder /code/build/coral /usr/bin/coral
COPY --from=go-builder /code/build/corald /usr/bin/corald
COPY --from=go-builder /code/build/gaiaflex /usr/bin/gaiaflex
COPY --from=go-builder /code/build/gaiaflexd /usr/bin/gaiaflexd
COPY docker/* /opt/

View File

@ -54,7 +54,6 @@ build_tags_comma_sep := $(subst $(empty),$(comma),$(build_tags))
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=wasm \
-X github.com/cosmos/cosmos-sdk/version.AppName=wasmd \
-X github.com/CosmWasm/wasmd/cmd/wasmcli/version.ClientName=wasmcli \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
@ -67,10 +66,8 @@ ldflags := $(strip $(ldflags))
coral_ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=coral \
-X github.com/cosmos/cosmos-sdk/version.AppName=corald \
-X github.com/CosmWasm/wasmd/cmd/wasmcli/version.ClientName=coral \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/CosmWasm/wasmd/app.CLIDir=.coral \
-X github.com/CosmWasm/wasmd/app.NodeDir=.corald \
-X github.com/CosmWasm/wasmd/app.Bech32Prefix=coral \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
@ -82,11 +79,9 @@ coral_ldflags := $(strip $(coral_ldflags))
flex_ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=gaiaflex \
-X github.com/cosmos/cosmos-sdk/version.AppName=gaiaflexd \
-X github.com/CosmWasm/wasmd/cmd/wasmcli/version.ClientName=gaiaflex \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/CosmWasm/wasmd/app.ProposalsEnabled=true \
-X github.com/CosmWasm/wasmd/app.CLIDir=.gaiaflex \
-X github.com/CosmWasm/wasmd/app.NodeDir=.gaiaflexd \
-X github.com/CosmWasm/wasmd/app.Bech32Prefix=cosmos \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
@ -102,29 +97,23 @@ all: install lint test
build: go.sum
ifeq ($(OS),Windows_NT)
# wasmd nodes not supported on windows, maybe the cli?
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmcli.exe ./cmd/wasmcli
exit 1
else
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmd ./cmd/wasmd
go build -mod=readonly $(BUILD_FLAGS) -o build/wasmcli ./cmd/wasmcli
endif
build-coral: go.sum
ifeq ($(OS),Windows_NT)
# wasmd nodes not supported on windows, maybe the cli?
go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/coral.exe ./cmd/wasmcli
exit 1
else
go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/corald ./cmd/wasmd
go build -mod=readonly $(CORAL_BUILD_FLAGS) -o build/coral ./cmd/wasmcli
endif
build-gaiaflex: go.sum
ifeq ($(OS),Windows_NT)
# wasmd nodes not supported on windows, maybe the cli?
go build -mod=readonly $(FLEX_BUILD_FLAGS) -o build/gaiaflex.exe ./cmd/wasmcli
exit 1
else
go build -mod=readonly $(FLEX_BUILD_FLAGS) -o build/gaiaflexd ./cmd/wasmd
go build -mod=readonly $(FLEX_BUILD_FLAGS) -o build/gaiaflex ./cmd/wasmcli
endif
build-linux: go.sum
@ -139,7 +128,6 @@ endif
install: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/wasmd
go install -mod=readonly $(BUILD_FLAGS) ./cmd/wasmcli
########################################
### Tools & dependencies

View File

@ -97,7 +97,7 @@ docker run --rm -it \
--mount type=volume,source=wasmd_data,target=/root \
cosmwasm/wasmd:latest ./setup_wasmd.sh cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6
# This will start both wasmd and wasmcli rest-server, only wasmcli output is shown on the screen
# This will start both wasmd and rest-server, only rest-serve output is shown on the screen
docker run --rm -it -p 26657:26657 -p 26656:26656 -p 1317:1317 \
--mount type=volume,source=wasmd_data,target=/root \
cosmwasm/wasmd:latest ./run_all.sh
@ -126,7 +126,7 @@ sudo chown -R $(id -u):$(id -g) ./template
# bind to non-/root and pass an argument to run.sh to copy the template into /root
# we need wasmd_data volume mount not just for restart, but also to view logs
docker volume rm -f wasmd_data
docker run --rm -it -p 26657:26657 -p 26656:26656 -p 1317:1317 \
docker run --rm -it -p 26657:26657 -p 26656:26656 -p 9090:9090 \
--mount type=bind,source=$(pwd)/template,target=/template \
--mount type=volume,source=wasmd_data,target=/root \
cosmwasm/wasmd:latest ./run_all.sh /template
@ -150,7 +150,7 @@ to the configuration.
Available flags:
* `-X github.com/CosmWasm/wasmd/app.CLIDir=.coral` - set the config directory for the cli (default `~/.wasmcli`)
* `-X github.com/CosmWasm/wasmd/app.NodeDir=.corald` - set the config/data directory for the node (default `~/.wasmd`)
* `-X github.com/CosmWasm/wasmd/app.Bech32Prefix=coral` - set the bech32 prefix for all accounts (default `cosmos`)
* `-X github.com/CosmWasm/wasmd/app.ProposalsEnabled=true` - enable all x/wasm governance proposals (default `false`)

View File

@ -17,9 +17,9 @@ A list of ContractCodeHistoryEntries with following fields:
* 404 - for an unknown contract
### CLI
`wasmcli query wasm contract-history [bech32_address] to print all the code changes.`
`wasmd query wasm contract-history [bech32_address] to print all the code changes.`
Example:
`wasmcli query wasm contract-history cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c`
`wasmd query wasm contract-history cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c`
```json
[
{

View File

@ -95,7 +95,6 @@ const appName = "WasmApp"
// We pull these out so we can set them with LDFLAGS in the Makefile
var (
CLIDir = ".wasmcli"
NodeDir = ".wasmd"
Bech32Prefix = sdk.Bech32MainPrefix
@ -129,8 +128,6 @@ func GetEnabledProposals() []wasm.ProposalType {
// These are the ones we will want to use in the code, based on
// any overrides above
var (
// DefaultCLIHome default home directories for wasmcli
DefaultCLIHome = os.ExpandEnv("$HOME/") + CLIDir
// DefaultNodeHome default home directories for wasmd
DefaultNodeHome = os.ExpandEnv("$HOME/") + NodeDir

View File

@ -1,164 +0,0 @@
package main
import (
"context"
"fmt"
"os"
"github.com/CosmWasm/wasmd/app"
"github.com/cosmos/cosmos-sdk/client"
"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/server"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/libs/cli"
)
// ClientName is set via build process
const ClientName = "wasmcli"
func main() {
// Configure cobra to sort commands
cobra.EnableCommandSorting = false
// Read in the configuration file for the sdk
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub)
config.Seal()
// TODO: setup keybase, viper object, etc. to be passed into
// the below functions and eliminate global vars, like we do
// with the cdc
encodingConfig := app.MakeEncodingConfig()
initClientCtx := client.Context{}.
WithJSONMarshaler(encodingConfig.Marshaler).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).
WithInput(os.Stdin).
WithAccountRetriever(authtypes.AccountRetriever{}).
WithBroadcastMode(flags.BroadcastBlock).
WithHomeDir(app.DefaultCLIHome)
rootCmd := &cobra.Command{
Use: ClientName,
Short: "Command line interface for interacting with " + version.AppName,
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
return err
}
return server.InterceptConfigsPreRunHandler(cmd)
},
}
// Construct Root Command
rootCmd.AddCommand(
rpc.StatusCommand(),
queryCommand(),
txCommand(),
flags.LineBreak,
flags.LineBreak,
keys.Commands(app.DefaultNodeHome),
flags.LineBreak,
//version.Cmd,
cli.NewCompletionCmd(rootCmd, true),
)
// 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)
if err != nil {
fmt.Printf("Failed executing CLI command: %s, exiting...\n", err)
os.Exit(1)
}
}
func queryCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "query",
Aliases: []string{"q"},
Short: "Querying subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmd.AddCommand(
authcmd.GetAccountCmd(),
flags.LineBreak,
rpc.ValidatorCommand(),
rpc.BlockCommand(),
authcmd.QueryTxsByEventsCmd(),
authcmd.QueryTxCmd(),
flags.LineBreak,
)
app.ModuleBasics.AddQueryCommands(cmd)
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")
return cmd
}
func txCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "tx",
Short: "Transactions subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmd.AddCommand(
bankcmd.NewSendTxCmd(),
flags.LineBreak,
authcmd.GetSignCommand(),
authcmd.GetSignBatchCommand(),
authcmd.GetMultiSignCommand(),
authcmd.GetValidateSignaturesCommand(),
flags.LineBreak,
authcmd.GetBroadcastCommand(),
authcmd.GetEncodeCommand(),
authcmd.GetDecodeCommand(),
flags.LineBreak,
vestingcli.GetTxCmd(),
)
// add modules' tx commands
app.ModuleBasics.AddTxCommands(cmd)
// remove auth and bank commands as they're mounted under the root tx command
var cmdsToRemove []*cobra.Command
for _, cmd := range cmd.Commands() {
if cmd.Use == authtypes.ModuleName || cmd.Use == banktypes.ModuleName {
cmdsToRemove = append(cmdsToRemove, cmd)
}
}
cmd.RemoveCommand(cmdsToRemove...)
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")
return cmd
}

View File

@ -7,6 +7,9 @@ import (
"path/filepath"
"github.com/CosmWasm/wasmd/x/wasm"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
"github.com/spf13/cast"
"github.com/spf13/cobra"
tmcli "github.com/tendermint/tendermint/libs/cli"
@ -27,7 +30,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/auth/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
@ -50,7 +53,7 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) {
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).
WithInput(os.Stdin).
WithAccountRetriever(types.AccountRetriever{}).
WithAccountRetriever(authtypes.AccountRetriever{}).
WithBroadcastMode(flags.BroadcastBlock).
WithHomeDir(app.DefaultNodeHome)
@ -82,7 +85,7 @@ func Execute(rootCmd *cobra.Command) error {
srvCtx := server.NewDefaultContext()
ctx := context.Background()
ctx = context.WithValue(ctx, client.ClientContextKey, &client.Context{})
ctx = context.WithValue(ctx, server.ServerContextKey, server.NewDefaultContext())
ctx = context.WithValue(ctx, server.ServerContextKey, srvCtx)
rootCmd.PersistentFlags().String("log_level", srvCtx.Config.LogLevel, "The logging level in the format of <module>:<level>,...")
@ -110,6 +113,8 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig) {
// add keybase, auxiliary RPC, query, and tx child commands
rootCmd.AddCommand(
rpc.StatusCommand(),
queryCommand(),
txCommand(),
keys.Commands(app.DefaultNodeHome),
)
}
@ -119,6 +124,73 @@ func addModuleInitFlags(startCmd *cobra.Command) {
wasm.AddModuleInitFlags(startCmd)
}
func queryCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "query",
Aliases: []string{"q"},
Short: "Querying subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmd.AddCommand(
authcmd.GetAccountCmd(),
flags.LineBreak,
rpc.ValidatorCommand(),
rpc.BlockCommand(),
authcmd.QueryTxsByEventsCmd(),
authcmd.QueryTxCmd(),
flags.LineBreak,
)
app.ModuleBasics.AddQueryCommands(cmd)
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")
return cmd
}
func txCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "tx",
Short: "Transactions subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmd.AddCommand(
bankcmd.NewSendTxCmd(),
flags.LineBreak,
authcmd.GetSignCommand(),
authcmd.GetSignBatchCommand(),
authcmd.GetMultiSignCommand(),
authcmd.GetValidateSignaturesCommand(),
flags.LineBreak,
authcmd.GetBroadcastCommand(),
authcmd.GetEncodeCommand(),
authcmd.GetDecodeCommand(),
flags.LineBreak,
vestingcli.GetTxCmd(),
)
// add modules' tx commands
app.ModuleBasics.AddTxCommands(cmd)
// remove auth and bank commands as they're mounted under the root tx command
var cmdsToRemove []*cobra.Command
for _, cmd := range cmd.Commands() {
if cmd.Use == authtypes.ModuleName || cmd.Use == banktypes.ModuleName {
cmdsToRemove = append(cmdsToRemove, cmd)
}
}
cmd.RemoveCommand(cmdsToRemove...)
cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID")
return cmd
}
func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
var cache sdk.MultiStorePersistentCache

View File

@ -1,18 +1,18 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
BASE_ACCOUNT=$(wasmcli keys show validator -a)
wasmcli q account "$BASE_ACCOUNT" -o json | jq
BASE_ACCOUNT=$(wasmd keys show validator -a)
wasmd q account "$BASE_ACCOUNT" -o json | jq
echo "## Add new account"
wasmcli keys add fred
wasmd keys add fred
echo "## Check balance"
NEW_ACCOUNT=$(wasmcli keys show fred -a)
wasmcli q bank balances "$NEW_ACCOUNT" -o json || true
NEW_ACCOUNT=$(wasmd keys show fred -a)
wasmd q bank balances "$NEW_ACCOUNT" -o json || true
echo "## Transfer tokens"
wasmcli tx send validator "$NEW_ACCOUNT" 1ustake --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block | jq
wasmd tx send validator "$NEW_ACCOUNT" 1ustake --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block | jq
echo "## Check balance again"
wasmcli q bank balances "$NEW_ACCOUNT" -o json | jq
wasmd q bank balances "$NEW_ACCOUNT" -o json | jq

View File

@ -5,80 +5,80 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
echo "-----------------------"
echo "## Add new CosmWasm contract"
RESP=$(wasmcli tx wasm store "$DIR/../../x/wasm/internal/keeper/testdata/hackatom.wasm" \
RESP=$(wasmd tx wasm store "$DIR/../../x/wasm/internal/keeper/testdata/hackatom.wasm" \
--from validator --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block)
CODE_ID=$(echo "$RESP" | jq -r '.logs[0].events[0].attributes[-1].value')
echo "* Code id: $CODE_ID"
echo "* Download code"
TMPDIR=$(mktemp -t wasmcliXXXX)
wasmcli q wasm code "$CODE_ID" "$TMPDIR"
TMPDIR=$(mktemp -t wasmdXXXX)
wasmd q wasm code "$CODE_ID" "$TMPDIR"
rm -f "$TMPDIR"
echo "-----------------------"
echo "## List code"
wasmcli query wasm list-code --node=http://localhost:26657 --chain-id=testing | jq
wasmd query wasm list-code --node=http://localhost:26657 --chain-id=testing | jq
echo "-----------------------"
echo "## Create new contract instance"
INIT="{\"verifier\":\"$(wasmcli keys show validator -a)\", \"beneficiary\":\"$(wasmcli keys show fred -a)\"}"
wasmcli tx wasm instantiate "$CODE_ID" "$INIT" --admin=$(wasmcli keys show validator -a) \
INIT="{\"verifier\":\"$(wasmd keys show validator -a)\", \"beneficiary\":\"$(wasmd keys show fred -a)\"}"
wasmd tx wasm instantiate "$CODE_ID" "$INIT" --admin=$(wasmd keys show validator -a) \
--from validator --amount="100ustake" --label "local0.1.0" \
--gas 1000000 -y --chain-id=testing -b block | jq
CONTRACT=$(wasmcli query wasm list-contract-by-code "$CODE_ID" -o json | jq -r '.[0].address')
CONTRACT=$(wasmd query wasm list-contract-by-code "$CODE_ID" -o json | jq -r '.[0].address')
echo "* Contract address: $CONTRACT"
echo "### Query all"
RESP=$(wasmcli query wasm contract-state all "$CONTRACT" -o json)
RESP=$(wasmd query wasm contract-state all "$CONTRACT" -o json)
echo "$RESP"
echo "### Query smart"
wasmcli query wasm contract-state smart "$CONTRACT" '{"verifier":{}}' -o json | jq
wasmd query wasm contract-state smart "$CONTRACT" '{"verifier":{}}' -o json | jq
echo "### Query raw"
KEY=$(echo "$RESP" | jq -r ".[0].key")
wasmcli query wasm contract-state raw "$CONTRACT" "$KEY" -o json
wasmd query wasm contract-state raw "$CONTRACT" "$KEY" -o json
echo "-----------------------"
echo "## Execute contract $CONTRACT"
MSG='{"release":{}}'
wasmcli tx wasm execute "$CONTRACT" "$MSG" \
wasmd tx wasm execute "$CONTRACT" "$MSG" \
--from validator \
--gas 1000000 -y --chain-id=testing -b block | jq
echo "-----------------------"
echo "## Set new admin"
echo "### Query old admin: $(wasmcli q wasm contract $CONTRACT -o json | jq -r '.admin')"
echo "### Query old admin: $(wasmd q wasm contract $CONTRACT -o json | jq -r '.admin')"
echo "### Update contract"
wasmcli tx wasm set-contract-admin "$CONTRACT" $(wasmcli keys show fred -a) \
wasmd tx wasm set-contract-admin "$CONTRACT" $(wasmd keys show fred -a) \
--from validator -y --chain-id=testing -b block | jq
echo "### Query new admin: $(wasmcli q wasm contract $CONTRACT -o json | jq -r '.admin')"
echo "### Query new admin: $(wasmd q wasm contract $CONTRACT -o json | jq -r '.admin')"
echo "-----------------------"
echo "## Migrate contract"
echo "### Upload new code"
RESP=$(wasmcli tx wasm store "$DIR/../../x/wasm/internal/keeper/testdata/burner.wasm" \
RESP=$(wasmd tx wasm store "$DIR/../../x/wasm/internal/keeper/testdata/burner.wasm" \
--from validator --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b block)
BURNER_CODE_ID=$(echo "$RESP" | jq -r '.logs[0].events[0].attributes[-1].value')
echo "### Migrate to code id: $BURNER_CODE_ID"
DEST_ACCOUNT=$(wasmcli keys show fred -a)
wasmcli tx wasm migrate "$CONTRACT" "$BURNER_CODE_ID" "{\"payout\": \"$DEST_ACCOUNT\"}" --from fred \
DEST_ACCOUNT=$(wasmd keys show fred -a)
wasmd tx wasm migrate "$CONTRACT" "$BURNER_CODE_ID" "{\"payout\": \"$DEST_ACCOUNT\"}" --from fred \
--chain-id=testing -b block -y | jq
echo "### Query destination account: $BURNER_CODE_ID"
wasmcli q bank balances "$DEST_ACCOUNT" -o json | jq
wasmd q bank balances "$DEST_ACCOUNT" -o json | jq
echo "### Query contract meta data: $CONTRACT"
wasmcli q wasm contract "$CONTRACT" -o json | jq
wasmd q wasm contract "$CONTRACT" -o json | jq
echo "### Query contract meta history: $CONTRACT"
wasmcli q wasm contract-history "$CONTRACT" -o json | jq
wasmd q wasm contract-history "$CONTRACT" -o json | jq
echo "-----------------------"
echo "## Clear contract admin"
echo "### Query old admin: $(wasmcli q wasm contract $CONTRACT -o json | jq -r '.admin')"
echo "### Query old admin: $(wasmd q wasm contract $CONTRACT -o json | jq -r '.admin')"
echo "### Update contract"
wasmcli tx wasm clear-contract-admin "$CONTRACT" \
wasmd tx wasm clear-contract-admin "$CONTRACT" \
--from fred -y --chain-id=testing -b block | jq
echo "### Query new admin: $(wasmcli q wasm contract $CONTRACT -o json | jq -r '.admin')"
echo "### Query new admin: $(wasmd q wasm contract $CONTRACT -o json | jq -r '.admin')"

View File

@ -11,8 +11,8 @@ wasmd init --chain-id "$CHAIN_ID" "$MONIKER"
# staking/governance token is hardcoded in config, change this
## OSX requires: -i.
sed -i. "s/\"stake\"/\"$STAKE\"/" "$HOME"/.wasmd/config/genesis.json
if ! wasmcli keys show validator; then
(echo "$PASSWORD"; echo "$PASSWORD") | wasmcli keys add validator
if ! wasmd keys show validator; then
(echo "$PASSWORD"; echo "$PASSWORD") | wasmd keys add validator
fi
# hardcode the validator account for this instance
echo "$PASSWORD" | wasmd add-genesis-account validator "1000000000$STAKE,1000000000$FEE"

View File

@ -1,3 +0,0 @@
#!/bin/sh
tail -f /root/log/wasmd.log

View File

@ -1,4 +0,0 @@
#!/bin/sh
#set -euo pipefail
wasmcli rest-server --laddr tcp://0.0.0.0:1317 --trust-node --unsafe-cors

View File

@ -3,7 +3,6 @@
if test -n "$1"; then
# need -R not -r to copy hidden files
cp -R "$1/.wasmd" /root
cp -R "$1/.wasmcli" /root
fi
mkdir -p /root/log

View File

@ -10,8 +10,8 @@ MONIKER=${MONIKER:-node001}
wasmd init --chain-id "$CHAIN_ID" "$MONIKER"
# staking/governance token is hardcoded in config, change this
sed -i "s/\"stake\"/\"$STAKE\"/" "$HOME"/.wasmd/config/genesis.json
if ! wasmcli keys show validator; then
(echo "$PASSWORD"; echo "$PASSWORD") | wasmcli keys add validator
if ! wasmd keys show validator; then
(echo "$PASSWORD"; echo "$PASSWORD") | wasmd keys add validator
fi
# hardcode the validator account for this instance
echo "$PASSWORD" | wasmd add-genesis-account validator "1000000000$STAKE,1000000000$FEE"

View File

@ -76,7 +76,7 @@ As gov proposals bypass the existing authorzation policy they are diabled and re
## CLI
```shell script
wasmcli tx gov submit-proposal [command]
wasmd tx gov submit-proposal [command]
Available Commands:
wasm-store Submit a wasm binary proposal