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

Bump proto #563

Merged
merged 12 commits into from
Jul 27, 2021
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

[Full Changelog](https://github.com/CosmWasm/wasmd/compare/v0.17.0...HEAD)

**Api Breaking:**

- Renamed InitMsg and MigrateMsg fields to Msg. This applies to protobuf Msg
and Proposals, as well as REST and CLI [\#563](https://github.com/CosmWasm/wasmd/pull/563)
- Move Proto version from `v1beta1` to `v1` for all cosmwasm.wasm.* types
[\#563](https://github.com/CosmWasm/wasmd/pull/563)

## [v0.17.0](https://github.com/CosmWasm/wasmd/tree/v0.17.0) (2021-05-26)

[Full Changelog](https://github.com/CosmWasm/wasmd/compare/v0.17.0...v0.16.0)
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ proto-swagger-gen:
@./scripts/protoc-swagger-gen.sh

proto-lint:
@$(DOCKER_BUF) check lint --error-format=json
@$(DOCKER_BUF) lint --error-format=json

proto-check-breaking:
@$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master
@$(DOCKER_BUF) breaking --against-input $(HTTPS_GIT)#branch=master

.PHONY: all install install-debug \
go-mod-cache draw-deps clean build format \
Expand Down
344 changes: 172 additions & 172 deletions docs/proto/proto-docs.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
syntax = "proto3";
package cosmwasm.wasm.v1beta1;
package cosmwasm.wasm.v1;

import "gogoproto/gogo.proto";
import "cosmwasm/wasm/v1beta1/types.proto";
import "cosmwasm/wasm/v1beta1/tx.proto";
import "cosmwasm/wasm/v1/types.proto";
import "cosmwasm/wasm/v1/tx.proto";

option go_package = "github.com/CosmWasm/wasmd/x/wasm/types";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package cosmwasm.wasm.v1beta1;
package cosmwasm.wasm.v1;

import "gogoproto/gogo.proto";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
syntax = "proto3";
package cosmwasm.wasm.v1beta1;
package cosmwasm.wasm.v1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmwasm/wasm/v1beta1/types.proto";
import "cosmwasm/wasm/v1/types.proto";

option go_package = "github.com/CosmWasm/wasmd/x/wasm/types";
option (gogoproto.goproto_stringer_all) = false;
Expand Down Expand Up @@ -44,8 +44,8 @@ message InstantiateContractProposal {
uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ];
// Label is optional metadata to be stored with a constract instance.
string label = 6;
// InitMsg json encoded message to be passed to the contract on instantiation
bytes init_msg = 7;
// Msg json encoded message to be passed to the contract on instantiation
bytes msg = 7;
// Funds coins that are transferred to the contract on instantiation
repeated cosmos.base.v1beta1.Coin funds = 8 [
(gogoproto.nullable) = false,
Expand All @@ -65,8 +65,8 @@ message MigrateContractProposal {
string contract = 4;
// CodeID references the new WASM code
uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ];
// MigrateMsg json encoded message to be passed to the contract on migration
bytes migrate_msg = 6;
// Msg json encoded message to be passed to the contract on migration
bytes msg = 6;
Copy link
Member

Choose a reason for hiding this comment

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

Nice changes. I was wondering: why is there no ExecuteContractProposal? Would this be useful?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm.. what would it do?

Migrate will override any other auth.

InstantiateProposal is useful if we want to instantiate a code ID which is governance restricted (you can set it so only governance can create new contracts, to avoid eg. everyone making cw20 tokens on a non-DeFi chain)

What would the Execute Proposal do?

All I can think of is to execute a message as an arbitrary account. Which is as powerful as "allow governance to forge a message from arbitrary user". You can make an issue to describe this idea if you think it would be useful and let's wait for Alex to discuss it.

}

// UpdateAdminProposal gov proposal content type to set an admin for a contract.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
syntax = "proto3";
package cosmwasm.wasm.v1beta1;
package cosmwasm.wasm.v1;

import "gogoproto/gogo.proto";
import "cosmwasm/wasm/v1beta1/types.proto";
import "cosmwasm/wasm/v1/types.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";

Expand All @@ -15,42 +15,42 @@ service Query {
// ContractInfo gets the contract meta data
rpc ContractInfo(QueryContractInfoRequest)
returns (QueryContractInfoResponse) {
option (google.api.http).get = "/wasm/v1beta1/contract/{address}";
option (google.api.http).get = "/wasm/v1/contract/{address}";
}
// ContractHistory gets the contract code history
rpc ContractHistory(QueryContractHistoryRequest)
returns (QueryContractHistoryResponse) {
option (google.api.http).get = "/wasm/v1beta1/contract/{address}/history";
option (google.api.http).get = "/wasm/v1/contract/{address}/history";
}
// ContractsByCode lists all smart contracts for a code id
rpc ContractsByCode(QueryContractsByCodeRequest)
returns (QueryContractsByCodeResponse) {
option (google.api.http).get = "/wasm/v1beta1/code/{code_id}/contracts";
option (google.api.http).get = "/wasm/v1/code/{code_id}/contracts";
}
// AllContractState gets all raw store data for a single contract
rpc AllContractState(QueryAllContractStateRequest)
returns (QueryAllContractStateResponse) {
option (google.api.http).get = "/wasm/v1beta1/contract/{address}/state";
option (google.api.http).get = "/wasm/v1/contract/{address}/state";
}
// RawContractState gets single key from the raw store data of a contract
rpc RawContractState(QueryRawContractStateRequest)
returns (QueryRawContractStateResponse) {
option (google.api.http).get =
"/wasm/v1beta1/contract/{address}/raw/{query_data}";
"/wasm/v1/contract/{address}/raw/{query_data}";
}
// SmartContractState get smart query result from the contract
rpc SmartContractState(QuerySmartContractStateRequest)
returns (QuerySmartContractStateResponse) {
option (google.api.http).get =
"/wasm/v1beta1/contract/{address}/smart/{query_data}";
"/wasm/v1/contract/{address}/smart/{query_data}";
}
// Code gets the binary code and metadata for a singe wasm code
rpc Code(QueryCodeRequest) returns (QueryCodeResponse) {
option (google.api.http).get = "/wasm/v1beta1/code/{code_id}";
option (google.api.http).get = "/wasm/v1/code/{code_id}";
}
// Codes gets the metadata for all stored wasm codes
rpc Codes(QueryCodesRequest) returns (QueryCodesResponse) {
option (google.api.http).get = "/wasm/v1beta1/code";
option (google.api.http).get = "/wasm/v1/code";
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
syntax = "proto3";
package cosmwasm.wasm.v1beta1;
package cosmwasm.wasm.v1;

import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "cosmwasm/wasm/v1beta1/types.proto";
import "cosmwasm/wasm/v1/types.proto";

option go_package = "github.com/CosmWasm/wasmd/x/wasm/types";
option (gogoproto.goproto_getters_all) = false;
Expand Down Expand Up @@ -57,8 +57,8 @@ message MsgInstantiateContract {
uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ];
// Label is optional metadata to be stored with a contract instance.
string label = 4;
// InitMsg json encoded message to be passed to the contract on instantiation
bytes init_msg = 5;
// Msg json encoded message to be passed to the contract on instantiation
bytes msg = 5;
// Funds coins that are transferred to the contract on instantiation
repeated cosmos.base.v1beta1.Coin funds = 6 [
(gogoproto.nullable) = false,
Expand Down Expand Up @@ -102,8 +102,8 @@ message MsgMigrateContract {
string contract = 2;
// CodeID references the new WASM code
uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ];
// MigrateMsg json encoded message to be passed to the contract on migration
bytes migrate_msg = 4;
// Msg json encoded message to be passed to the contract on migration
bytes msg = 4;
}

// MsgMigrateContractResponse returns contract migration result data.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package cosmwasm.wasm.v1beta1;
package cosmwasm.wasm.v1;

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
Expand Down
4 changes: 2 additions & 2 deletions x/wasm/client/cli/gov_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func ProposalInstantiateContractCmd() *cobra.Command {
Admin: src.Admin,
CodeID: src.CodeID,
Label: src.Label,
InitMsg: src.InitMsg,
Msg: src.Msg,
Funds: src.Funds,
}

Expand Down Expand Up @@ -212,7 +212,7 @@ func ProposalMigrateContractCmd() *cobra.Command {
Description: proposalDescr,
Contract: src.Contract,
CodeID: src.CodeID,
MigrateMsg: src.MigrateMsg,
Msg: src.Msg,
RunAs: runAs,
}

Expand Down
8 changes: 4 additions & 4 deletions x/wasm/client/cli/new_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ func parseMigrateContractArgs(args []string, cliCtx client.Context) (types.MsgMi
migrateMsg := args[2]

msg := types.MsgMigrateContract{
Sender: cliCtx.GetFromAddress().String(),
Contract: args[0],
CodeID: codeID,
MigrateMsg: []byte(migrateMsg),
Sender: cliCtx.GetFromAddress().String(),
Contract: args[0],
CodeID: codeID,
Msg: []byte(migrateMsg),
}
return msg, nil
}
Expand Down
12 changes: 6 additions & 6 deletions x/wasm/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ func parseInstantiateArgs(rawCodeID, initMsg string, sender sdk.AccAddress, flag

// build and sign the transaction, then broadcast to Tendermint
msg := types.MsgInstantiateContract{
Sender: sender.String(),
CodeID: codeID,
Label: label,
Funds: amount,
InitMsg: []byte(initMsg),
Admin: adminStr,
Sender: sender.String(),
CodeID: codeID,
Label: label,
Funds: amount,
Msg: []byte(initMsg),
Admin: adminStr,
}
return msg, nil
}
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/client/proposal_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestGovRestHandlers(t *testing.T) {
"admin": "cosmos100dejzacpanrldpjjwksjm62shqhyss44jf5xz",
"code_id": "1",
"label": "https://example.com/",
"init_msg": "my/builder:tag",
"msg": dict{"recipient": "cosmos100dejzacpanrldpjjwksjm62shqhyss44jf5xz"},
"funds": []dict{{"denom": "ustake", "amount": "100"}},
"deposit": []dict{{"denom": "ustake", "amount": "10"}},
"proposer": "cosmos1ve557a5g9yw2g2z57js3pdmcvd5my6g8ze20np",
Expand Down
20 changes: 10 additions & 10 deletions x/wasm/client/rest/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ type InstantiateProposalJsonReq struct {

RunAs string `json:"run_as" yaml:"run_as"`
// Admin is an optional address that can execute migrations
Admin string `json:"admin,omitempty" yaml:"admin"`
Code uint64 `json:"code_id" yaml:"code_id"`
Label string `json:"label" yaml:"label"`
InitMsg json.RawMessage `json:"init_msg" yaml:"init_msg"`
Funds sdk.Coins `json:"funds" yaml:"funds"`
Admin string `json:"admin,omitempty" yaml:"admin"`
Code uint64 `json:"code_id" yaml:"code_id"`
Label string `json:"label" yaml:"label"`
Msg json.RawMessage `json:"msg" yaml:"msg"`
Funds sdk.Coins `json:"funds" yaml:"funds"`
}

func (s InstantiateProposalJsonReq) Content() govtypes.Content {
Expand All @@ -92,7 +92,7 @@ func (s InstantiateProposalJsonReq) Content() govtypes.Content {
Admin: s.Admin,
CodeID: s.Code,
Label: s.Label,
InitMsg: s.InitMsg,
Msg: s.Msg,
Funds: s.Funds,
}
}
Expand Down Expand Up @@ -128,9 +128,9 @@ type MigrateProposalJsonReq struct {
Proposer string `json:"proposer" yaml:"proposer"`
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`

Contract string `json:"contract" yaml:"contract"`
Code uint64 `json:"code_id" yaml:"code_id"`
MigrateMsg json.RawMessage `json:"msg" yaml:"msg"`
Contract string `json:"contract" yaml:"contract"`
Code uint64 `json:"code_id" yaml:"code_id"`
Msg json.RawMessage `json:"msg" yaml:"msg"`
// RunAs is the role that is passed to the contract's environment
RunAs string `json:"run_as" yaml:"run_as"`
}
Expand All @@ -141,7 +141,7 @@ func (s MigrateProposalJsonReq) Content() govtypes.Content {
Description: s.Description,
Contract: s.Contract,
CodeID: s.Code,
MigrateMsg: s.MigrateMsg,
Msg: s.Msg,
RunAs: s.RunAs,
}
}
Expand Down
16 changes: 8 additions & 8 deletions x/wasm/client/rest/new_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ func registerNewTxRoutes(cliCtx client.Context, r *mux.Router) {
}

type migrateContractReq struct {
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Admin string `json:"admin,omitempty" yaml:"admin"`
CodeID uint64 `json:"code_id" yaml:"code_id"`
MigrateMsg []byte `json:"migrate_msg,omitempty" yaml:"migrate_msg"`
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Admin string `json:"admin,omitempty" yaml:"admin"`
CodeID uint64 `json:"code_id" yaml:"code_id"`
Msg []byte `json:"msg,omitempty" yaml:"msg"`
}

type updateContractAdministrateReq struct {
Expand Down Expand Up @@ -70,10 +70,10 @@ func migrateContractHandlerFn(cliCtx client.Context) http.HandlerFunc {
}

msg := &types.MsgMigrateContract{
Sender: req.BaseReq.From,
Contract: contractAddr,
CodeID: req.CodeID,
MigrateMsg: req.MigrateMsg,
Sender: req.BaseReq.From,
Contract: contractAddr,
CodeID: req.CodeID,
Msg: req.Msg,
}
if err := msg.ValidateBasic(); err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
Expand Down
14 changes: 7 additions & 7 deletions x/wasm/client/rest/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type instantiateContractReq struct {
Label string `json:"label" yaml:"label"`
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
Admin string `json:"admin,omitempty" yaml:"admin"`
InitMsg []byte `json:"init_msg" yaml:"init_msg"`
Msg []byte `json:"msg" yaml:"msg"`
}

type executeContractReq struct {
Expand Down Expand Up @@ -101,12 +101,12 @@ func instantiateContractHandlerFn(cliCtx client.Context) http.HandlerFunc {
}

msg := types.MsgInstantiateContract{
Sender: req.BaseReq.From,
CodeID: codeID,
Label: req.Label,
Funds: req.Deposit,
InitMsg: req.InitMsg,
Admin: req.Admin,
Sender: req.BaseReq.From,
CodeID: codeID,
Label: req.Label,
Funds: req.Deposit,
Msg: req.Msg,
Admin: req.Admin,
}

if err := msg.ValidateBasic(); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions x/wasm/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func TestInitGenesis(t *testing.T) {
require.NoError(t, err)

initCmd := MsgInstantiateContract{
Sender: creator.String(),
CodeID: firstCodeID,
InitMsg: initMsgBz,
Funds: deposit,
Sender: creator.String(),
CodeID: firstCodeID,
Msg: initMsgBz,
Funds: deposit,
}
res, err = h(data.ctx, &initCmd)
require.NoError(t, err)
Expand Down
14 changes: 7 additions & 7 deletions x/wasm/ibctesting/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ func (c *TestChain) StoreCode(byteCode []byte) types.MsgStoreCodeResponse {

func (c *TestChain) InstantiateContract(codeID uint64, initMsg []byte) sdk.AccAddress {
instantiateMsg := &types.MsgInstantiateContract{
Sender: c.SenderAccount.GetAddress().String(),
Admin: c.SenderAccount.GetAddress().String(),
CodeID: codeID,
Label: "ibc-test",
InitMsg: initMsg,
Funds: sdk.Coins{TestCoin},
Sender: c.SenderAccount.GetAddress().String(),
Admin: c.SenderAccount.GetAddress().String(),
CodeID: codeID,
Label: "ibc-test",
Msg: initMsg,
Funds: sdk.Coins{TestCoin},
}

r, err := c.SendMsgs(instantiateMsg)
Expand Down Expand Up @@ -104,7 +104,7 @@ func (c *TestChain) SmartQuery(contractAddr string, queryMsg interface{}, respon

// TODO: what is the query?
res := c.App.Query(abci.RequestQuery{
Path: "/cosmwasm.wasm.v1beta1.Query/SmartContractState",
Path: "/cosmwasm.wasm.v1.Query/SmartContractState",
Data: reqBin,
})

Expand Down
Loading