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

Minor tweak and test files #1356

Merged
merged 1 commit into from
Apr 21, 2023
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
19 changes: 19 additions & 0 deletions contrib/local/04-gov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good example 👍

set -o errexit -o nounset -o pipefail

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

echo "Compile with buildflag ''-X github.com/CosmWasm/wasmd/app.ProposalsEnabled=true' to enable gov"
sleep 1
echo "## Submit a CosmWasm gov proposal"
RESP=$(wasmd tx wasm submit-proposal store-instantiate "$DIR/../../x/wasm/keeper/testdata/reflect.wasm" \
'{}' --label="testing" \
--title "testing" --summary "Testing" --deposit "1000000000ustake" \
--admin $(wasmd keys show -a validator --keyring-backend=test) \
--amount 123ustake \
--keyring-backend=test \
--from validator --gas auto --gas-adjustment=1.5 -y --chain-id=testing --node=http://localhost:26657 -b sync -o json)
echo $RESP
sleep 6
wasmd q tx $(echo "$RESP"| jq -r '.txhash') -o json | jq

2 changes: 1 addition & 1 deletion contrib/local/setup_wasmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if ! wasmd keys show validator --keyring-backend=test; then
) | wasmd keys add validator --keyring-backend=test
fi
# hardcode the validator account for this instance
echo "$PASSWORD" | wasmd genesis add-genesis-account validator "1000000000$STAKE,1000000000$FEE" --keyring-backend=test
echo "$PASSWORD" | wasmd genesis add-genesis-account validator "1000000000000$STAKE,1000000000000$FEE" --keyring-backend=test
# (optionally) add a few more genesis accounts
for addr in "$@"; do
echo "$addr"
Expand Down
30 changes: 17 additions & 13 deletions x/wasm/client/cli/gov_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"github.com/CosmWasm/wasmd/x/wasm/types"
)

// DefaultGovAuthority is set to the gov module address.
// Extension point for chains to overwrite the default
var DefaultGovAuthority = sdk.AccAddress(address.Module("gov"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to have this! Also the code looks cleaner.


func SubmitProposalCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "submit-proposal",
Expand Down Expand Up @@ -64,7 +68,7 @@ func ProposalStoreCodeCmd() *cobra.Command {
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

src, err := parseStoreCodeArgs(args[0], authority, cmd.Flags())
Expand Down Expand Up @@ -154,7 +158,7 @@ func ProposalInstantiateContractCmd() *cobra.Command {
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

src, err := parseInstantiateArgs(args[0], args[1], clientCtx.Keyring, authority, cmd.Flags())
Expand Down Expand Up @@ -201,7 +205,7 @@ func ProposalInstantiateContract2Cmd() *cobra.Command {
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

src, err := parseInstantiateArgs(args[0], args[1], clientCtx.Keyring, authority, cmd.Flags())
Expand Down Expand Up @@ -250,7 +254,7 @@ func ProposalStoreAndInstantiateContractCmd() *cobra.Command {
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

src, err := parseStoreCodeArgs(args[0], authority, cmd.Flags())
Expand Down Expand Up @@ -375,7 +379,7 @@ func ProposalMigrateContractCmd() *cobra.Command {
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

src, err := parseMigrateContractArgs(args, authority)
Expand Down Expand Up @@ -417,7 +421,7 @@ func ProposalExecuteContractCmd() *cobra.Command {
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

contract := args[0]
Expand Down Expand Up @@ -474,7 +478,7 @@ func ProposalSudoContractCmd() *cobra.Command {
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

msg := types.MsgSudoContract{
Expand Down Expand Up @@ -517,7 +521,7 @@ func ProposalUpdateContractAdminCmd() *cobra.Command {
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

src := parseUpdateContractAdminArgs(args, authority)
Expand Down Expand Up @@ -556,7 +560,7 @@ func ProposalClearContractAdminCmd() *cobra.Command {
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

msg := types.MsgClearAdmin{
Expand Down Expand Up @@ -598,7 +602,7 @@ func ProposalPinCodesCmd() *cobra.Command {
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

codeIds, err := parsePinCodesArgs(args)
Expand Down Expand Up @@ -656,7 +660,7 @@ func ProposalUnpinCodesCmd() *cobra.Command {
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

codeIds, err := parsePinCodesArgs(args)
Expand Down Expand Up @@ -763,7 +767,7 @@ $ %s tx gov submit-proposal update-instantiate-config 1:nobody 2:everybody 3:%s1
}

if len(authority) == 0 {
authority = sdk.AccAddress(address.Module("gov")).String()
return errors.New("authority address is required")
}

updates, err := parseAccessConfigUpdates(args)
Expand Down Expand Up @@ -803,7 +807,7 @@ func addCommonProposalFlags(cmd *cobra.Command) {
cmd.Flags().String(cli.FlagTitle, "", "Title of proposal")
cmd.Flags().String(cli.FlagSummary, "", "Summary of proposal")
cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal")
cmd.Flags().String(flagAuthority, "", "The address of the governance account.")
cmd.Flags().String(flagAuthority, DefaultGovAuthority.String(), "The address of the governance account. Default is the sdk gov module account")
}

func getProposalInfo(cmd *cobra.Command) (client.Context, string, string, sdk.Coins, error) {
Expand Down