From c64d5d54ba6d9667e360a0180a9ea14a666f61a6 Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Fri, 8 Jan 2021 15:06:51 +0100 Subject: [PATCH] Refactor to grpc message server --- doc/proto.md | 105 ++- x/wasm/alias.go | 61 +- x/wasm/genesis_test.go | 12 +- x/wasm/handler.go | 223 +---- x/wasm/internal/keeper/msg_server.go | 185 ++++ x/wasm/internal/types/codec.go | 3 + x/wasm/internal/types/tx.pb.go | 1303 +++++++++++++++++++++++++- x/wasm/internal/types/tx.proto | 140 ++- x/wasm/module.go | 5 +- x/wasm/module_test.go | 30 +- 10 files changed, 1750 insertions(+), 317 deletions(-) create mode 100644 x/wasm/internal/keeper/msg_server.go diff --git a/doc/proto.md b/doc/proto.md index 7cce573d..571fe8d6 100644 --- a/doc/proto.md +++ b/doc/proto.md @@ -41,11 +41,19 @@ - [x/wasm/internal/types/tx.proto](#x/wasm/internal/types/tx.proto) - [MsgClearAdmin](#cosmwasm.wasm.v1beta1.MsgClearAdmin) + - [MsgClearAdminResponse](#cosmwasm.wasm.v1beta1.MsgClearAdminResponse) - [MsgExecuteContract](#cosmwasm.wasm.v1beta1.MsgExecuteContract) + - [MsgExecuteContractResponse](#cosmwasm.wasm.v1beta1.MsgExecuteContractResponse) - [MsgInstantiateContract](#cosmwasm.wasm.v1beta1.MsgInstantiateContract) + - [MsgInstantiateContractResponse](#cosmwasm.wasm.v1beta1.MsgInstantiateContractResponse) - [MsgMigrateContract](#cosmwasm.wasm.v1beta1.MsgMigrateContract) + - [MsgMigrateContractResponse](#cosmwasm.wasm.v1beta1.MsgMigrateContractResponse) - [MsgStoreCode](#cosmwasm.wasm.v1beta1.MsgStoreCode) + - [MsgStoreCodeResponse](#cosmwasm.wasm.v1beta1.MsgStoreCodeResponse) - [MsgUpdateAdmin](#cosmwasm.wasm.v1beta1.MsgUpdateAdmin) + - [MsgUpdateAdminResponse](#cosmwasm.wasm.v1beta1.MsgUpdateAdminResponse) + + - [Msg](#cosmwasm.wasm.v1beta1.Msg) - [x/wasm/internal/types/types.proto](#x/wasm/internal/types/types.proto) - [AbsoluteTxPosition](#cosmwasm.wasm.v1beta1.AbsoluteTxPosition) @@ -623,6 +631,16 @@ MsgClearAdmin removes any admin stored for a smart contract + + +### MsgClearAdminResponse +MsgClearAdminResponse returns empty data + + + + + + ### MsgExecuteContract @@ -641,6 +659,21 @@ MsgExecuteContract submits the given message data to a smart contract + + +### MsgExecuteContractResponse +MsgExecuteContractResponse returns execution result data. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| data | [bytes](#bytes) | | Data contains base64-encoded bytes to returned from the contract | + + + + + + ### MsgInstantiateContract @@ -661,6 +694,21 @@ MsgInstantiateContract create a new smart contract instance for the given code i + + +### MsgInstantiateContractResponse +MsgInstantiateContractResponse return instantiation result data + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| address | [string](#string) | | Address is the address of the new contract instance. | + + + + + + ### MsgMigrateContract @@ -679,6 +727,21 @@ MsgMigrateContract runs a code upgrade/ downgrade for a smart contract + + +### MsgMigrateContractResponse +MsgMigrateContractResponse returns contract migration result data. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| data | [bytes](#bytes) | | Data contains base64-encoded bytes returned from the wasm contract. | + + + + + + ### MsgStoreCode @@ -698,6 +761,21 @@ MsgStoreCode submit Wasm code to the system + + +### MsgStoreCodeResponse +MsgStoreCodeResponse returns store result data. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| code_id | [string](#string) | | CodeID is the reference to the stored WASM code | + + + + + + ### MsgUpdateAdmin @@ -714,7 +792,15 @@ MsgUpdateAdmin sets a new admin for a smart contract - + + + +### MsgUpdateAdminResponse +MsgUpdateAdminResponse returns empty data + + + + @@ -723,6 +809,23 @@ MsgUpdateAdmin sets a new admin for a smart contract + + +### Msg +Msg defines the wasm Msg service. + +| Method Name | Request Type | Response Type | Description | +| ----------- | ------------ | ------------- | ------------| +| StoreCode | [MsgStoreCode](#cosmwasm.wasm.v1beta1.MsgStoreCode) | [MsgStoreCodeResponse](#cosmwasm.wasm.v1beta1.MsgStoreCodeResponse) | StoreCode to submit Wasm code to the system | +| InstantiateContract | [MsgInstantiateContract](#cosmwasm.wasm.v1beta1.MsgInstantiateContract) | [MsgInstantiateContractResponse](#cosmwasm.wasm.v1beta1.MsgInstantiateContractResponse) | Instantiate creates a new smart contract instance for the given code id. | +| ExecuteContract | [MsgExecuteContract](#cosmwasm.wasm.v1beta1.MsgExecuteContract) | [MsgExecuteContractResponse](#cosmwasm.wasm.v1beta1.MsgExecuteContractResponse) | Execute submits the given message data to a smart contract | +| MigrateContract | [MsgMigrateContract](#cosmwasm.wasm.v1beta1.MsgMigrateContract) | [MsgMigrateContractResponse](#cosmwasm.wasm.v1beta1.MsgMigrateContractResponse) | Migrate runs a code upgrade/ downgrade for a smart contract | +| UpdateAdmin | [MsgUpdateAdmin](#cosmwasm.wasm.v1beta1.MsgUpdateAdmin) | [MsgUpdateAdminResponse](#cosmwasm.wasm.v1beta1.MsgUpdateAdminResponse) | UpdateAdmin sets a new admin for a smart contract | +| ClearAdmin | [MsgClearAdmin](#cosmwasm.wasm.v1beta1.MsgClearAdmin) | [MsgClearAdminResponse](#cosmwasm.wasm.v1beta1.MsgClearAdminResponse) | ClearAdmin removes any admin stored for a smart contract | + + + +

Top

diff --git a/x/wasm/alias.go b/x/wasm/alias.go index c52a70cf..bd22f274 100644 --- a/x/wasm/alias.go +++ b/x/wasm/alias.go @@ -100,31 +100,38 @@ var ( ) type ( - ProposalType = types.ProposalType - GenesisState = types.GenesisState - Code = types.Code - Contract = types.Contract - MsgStoreCode = types.MsgStoreCode - MsgInstantiateContract = types.MsgInstantiateContract - MsgExecuteContract = types.MsgExecuteContract - MsgMigrateContract = types.MsgMigrateContract - MsgUpdateAdmin = types.MsgUpdateAdmin - MsgClearAdmin = types.MsgClearAdmin - Model = types.Model - CodeInfo = types.CodeInfo - ContractInfo = types.ContractInfo - CreatedAt = types.AbsoluteTxPosition - Config = types.WasmConfig - ContractInfoWithAddress = types.ContractInfoWithAddress - CodeInfoResponse = types.CodeInfoResponse - MessageHandler = keeper.MessageHandler - BankEncoder = keeper.BankEncoder - CustomEncoder = keeper.CustomEncoder - StakingEncoder = keeper.StakingEncoder - WasmEncoder = keeper.WasmEncoder - MessageEncoders = keeper.MessageEncoders - Keeper = keeper.Keeper - QueryHandler = keeper.QueryHandler - CustomQuerier = keeper.CustomQuerier - QueryPlugins = keeper.QueryPlugins + ProposalType = types.ProposalType + GenesisState = types.GenesisState + Code = types.Code + Contract = types.Contract + MsgStoreCode = types.MsgStoreCode + MsgStoreCodeResponse = types.MsgStoreCodeResponse + MsgInstantiateContract = types.MsgInstantiateContract + MsgInstantiateContractResponse = types.MsgInstantiateContractResponse + MsgExecuteContract = types.MsgExecuteContract + MsgExecuteContractResponse = types.MsgExecuteContractResponse + MsgMigrateContract = types.MsgMigrateContract + MsgMigrateContractResponse = types.MsgMigrateContractResponse + MsgUpdateAdmin = types.MsgUpdateAdmin + MsgUpdateAdminResponse = types.MsgUpdateAdminResponse + MsgClearAdmin = types.MsgClearAdmin + MsgClearAdminResponse = types.MsgClearAdminResponse + MsgServer = types.MsgServer + Model = types.Model + CodeInfo = types.CodeInfo + ContractInfo = types.ContractInfo + CreatedAt = types.AbsoluteTxPosition + Config = types.WasmConfig + ContractInfoWithAddress = types.ContractInfoWithAddress + CodeInfoResponse = types.CodeInfoResponse + MessageHandler = keeper.MessageHandler + BankEncoder = keeper.BankEncoder + CustomEncoder = keeper.CustomEncoder + StakingEncoder = keeper.StakingEncoder + WasmEncoder = keeper.WasmEncoder + MessageEncoders = keeper.MessageEncoders + Keeper = keeper.Keeper + QueryHandler = keeper.QueryHandler + CustomQuerier = keeper.CustomQuerier + QueryPlugins = keeper.QueryPlugins ) diff --git a/x/wasm/genesis_test.go b/x/wasm/genesis_test.go index 8bb6f9cd..e40d50b8 100644 --- a/x/wasm/genesis_test.go +++ b/x/wasm/genesis_test.go @@ -30,7 +30,10 @@ func TestInitGenesis(t *testing.T) { res, err := h(data.ctx, &msg) require.NoError(t, err) - require.Equal(t, res.Data, []byte("1")) + + var pStoreResp MsgStoreCodeResponse + require.NoError(t, pStoreResp.Unmarshal(res.Data)) + require.Equal(t, pStoreResp.CodeID, "1") _, _, bob := keyPubAddr() initMsg := initMsg{ @@ -48,7 +51,9 @@ func TestInitGenesis(t *testing.T) { } res, err = h(data.ctx, &initCmd) require.NoError(t, err) - contractBech32Addr := string(res.Data) + var pInstResp MsgInstantiateContractResponse + require.NoError(t, pInstResp.Unmarshal(res.Data)) + contractBech32Addr := pInstResp.Address execCmd := MsgExecuteContract{ Sender: fred.String(), @@ -58,6 +63,9 @@ func TestInitGenesis(t *testing.T) { } res, err = h(data.ctx, &execCmd) require.NoError(t, err) + var pExecResp MsgExecuteContractResponse + require.NoError(t, pExecResp.Unmarshal(res.Data)) + require.NotEmpty(t, pExecResp.Data) // ensure all contract state is as after init assertCodeList(t, q, data.ctx, 1) diff --git a/x/wasm/handler.go b/x/wasm/handler.go index 67f38277..4ef66bcd 100644 --- a/x/wasm/handler.go +++ b/x/wasm/handler.go @@ -2,215 +2,70 @@ package wasm import ( "fmt" - + "github.com/CosmWasm/wasmd/x/wasm/internal/keeper" "github.com/CosmWasm/wasmd/x/wasm/internal/types" + "github.com/gogo/protobuf/proto" + abci "github.com/tendermint/tendermint/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - abci "github.com/tendermint/tendermint/abci/types" ) // NewHandler returns a handler for "bank" type messages. func NewHandler(k *Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) + var ( + res proto.Message + err error + ) switch msg := msg.(type) { case *MsgStoreCode: - return handleStoreCode(ctx, k, msg) + res, err = msgServer.StoreCode(sdk.WrapSDKContext(ctx), msg) case *MsgInstantiateContract: - return handleInstantiate(ctx, k, msg) + res, err = msgServer.InstantiateContract(sdk.WrapSDKContext(ctx), msg) case *MsgExecuteContract: - return handleExecute(ctx, k, msg) + res, err = msgServer.ExecuteContract(sdk.WrapSDKContext(ctx), msg) case *MsgMigrateContract: - return handleMigration(ctx, k, msg) + res, err = msgServer.MigrateContract(sdk.WrapSDKContext(ctx), msg) case *MsgUpdateAdmin: - return handleUpdateContractAdmin(ctx, k, msg) + res, err = msgServer.UpdateAdmin(sdk.WrapSDKContext(ctx), msg) case *MsgClearAdmin: - return handleClearContractAdmin(ctx, k, msg) + res, err = msgServer.ClearAdmin(sdk.WrapSDKContext(ctx), msg) default: errMsg := fmt.Sprintf("unrecognized wasm message type: %T", msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) } + + ctx = ctx.WithEventManager(filterMessageEvents(ctx)) + return sdk.WrapServiceResult(ctx, res, err) } } -// filterMessageEvents returns the same events with all of type == EventTypeMessage removed. +// filterMessageEvents returns the same events with all of type == EventTypeMessage removed except +// for wasm message types. // this is so only our top-level message event comes through -func filteredMessageEvents(manager *sdk.EventManager) []abci.Event { - events := manager.ABCIEvents() - res := make([]abci.Event, 0, len(events)) - for _, e := range events { - if e.Type != sdk.EventTypeMessage { - res = append(res, e) +func filterMessageEvents(ctx sdk.Context) *sdk.EventManager { + m := sdk.NewEventManager() + for _, e := range ctx.EventManager().Events() { + if e.Type == sdk.EventTypeMessage && + !hasWasmModuleAttribute(e.Attributes) { + continue + } + m.EmitEvent(e) + } + return m +} + +func hasWasmModuleAttribute(attrs []abci.EventAttribute) bool { + for _, a := range attrs { + if sdk.AttributeKeyModule == string(a.Key) && + types.ModuleName == string(a.Value) { + return true } } - return res -} - -func handleStoreCode(ctx sdk.Context, k *Keeper, msg *MsgStoreCode) (*sdk.Result, error) { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - return nil, sdkerrors.Wrap(err, "sender") - } - codeID, err := k.Create(ctx, senderAddr, msg.WASMByteCode, msg.Source, msg.Builder, msg.InstantiatePermission) - if err != nil { - return nil, err - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), - sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), - sdk.NewAttribute(types.AttributeKeyCodeID, fmt.Sprintf("%d", codeID)), - ), - }) - - return &sdk.Result{ - Data: []byte(fmt.Sprintf("%d", codeID)), - Events: ctx.EventManager().ABCIEvents(), - }, nil -} - -func handleInstantiate(ctx sdk.Context, k *Keeper, msg *MsgInstantiateContract) (*sdk.Result, error) { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - return nil, sdkerrors.Wrap(err, "sender") - } - var adminAddr sdk.AccAddress - if msg.Admin != "" { - if adminAddr, err = sdk.AccAddressFromBech32(msg.Admin); err != nil { - return nil, sdkerrors.Wrap(err, "admin") - } - } - - contractAddr, err := k.Instantiate(ctx, msg.CodeID, senderAddr, adminAddr, msg.InitMsg, msg.Label, msg.InitFunds) - if err != nil { - return nil, err - } - - events := filteredMessageEvents(ctx.EventManager()) - custom := sdk.Events{sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), - sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), - sdk.NewAttribute(types.AttributeKeyCodeID, fmt.Sprintf("%d", msg.CodeID)), - sdk.NewAttribute(types.AttributeKeyContract, contractAddr.String()), - )} - events = append(events, custom.ToABCIEvents()...) - - return &sdk.Result{ - Data: []byte(contractAddr.String()), - Events: events, - }, nil -} - -func handleExecute(ctx sdk.Context, k *Keeper, msg *MsgExecuteContract) (*sdk.Result, error) { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - return nil, sdkerrors.Wrap(err, "sender") - } - contractAddr, err := sdk.AccAddressFromBech32(msg.Contract) - if err != nil { - return nil, sdkerrors.Wrap(err, "contract") - } - - res, err := k.Execute(ctx, contractAddr, senderAddr, msg.Msg, msg.SentFunds) - if err != nil { - return nil, err - } - - events := filteredMessageEvents(ctx.EventManager()) - custom := sdk.Events{sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), - sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), - sdk.NewAttribute(types.AttributeKeyContract, msg.Contract), - ), - } - events = append(events, custom.ToABCIEvents()...) - - res.Events = events - return res, nil -} - -func handleMigration(ctx sdk.Context, k *Keeper, msg *MsgMigrateContract) (*sdk.Result, error) { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - return nil, sdkerrors.Wrap(err, "sender") - } - contractAddr, err := sdk.AccAddressFromBech32(msg.Contract) - if err != nil { - return nil, sdkerrors.Wrap(err, "contract") - } - - res, err := k.Migrate(ctx, contractAddr, senderAddr, msg.CodeID, msg.MigrateMsg) - if err != nil { - return nil, err - } - - events := filteredMessageEvents(ctx.EventManager()) - custom := sdk.Events{sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), - sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), - sdk.NewAttribute(types.AttributeKeyContract, msg.Contract), - )} - events = append(events, custom.ToABCIEvents()...) - res.Events = events - return res, nil -} - -func handleUpdateContractAdmin(ctx sdk.Context, k *Keeper, msg *MsgUpdateAdmin) (*sdk.Result, error) { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - return nil, sdkerrors.Wrap(err, "sender") - } - contractAddr, err := sdk.AccAddressFromBech32(msg.Contract) - if err != nil { - return nil, sdkerrors.Wrap(err, "contract") - } - newAdminAddr, err := sdk.AccAddressFromBech32(msg.NewAdmin) - if err != nil { - return nil, sdkerrors.Wrap(err, "new admin") - } - - if err := k.UpdateContractAdmin(ctx, contractAddr, senderAddr, newAdminAddr); err != nil { - return nil, err - } - events := ctx.EventManager().Events() - ourEvent := sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), - sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), - sdk.NewAttribute(types.AttributeKeyContract, msg.Contract), - ) - return &sdk.Result{ - Events: append(events, ourEvent).ToABCIEvents(), - }, nil -} - -func handleClearContractAdmin(ctx sdk.Context, k *Keeper, msg *MsgClearAdmin) (*sdk.Result, error) { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - return nil, sdkerrors.Wrap(err, "sender") - } - contractAddr, err := sdk.AccAddressFromBech32(msg.Contract) - if err != nil { - return nil, sdkerrors.Wrap(err, "contract") - } - - if err := k.ClearContractAdmin(ctx, contractAddr, senderAddr); err != nil { - return nil, err - } - events := ctx.EventManager().Events() - ourEvent := sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), - sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), - sdk.NewAttribute(types.AttributeKeyContract, msg.Contract), - ) - return &sdk.Result{ - Events: append(events, ourEvent).ToABCIEvents(), - }, nil + return false } diff --git a/x/wasm/internal/keeper/msg_server.go b/x/wasm/internal/keeper/msg_server.go new file mode 100644 index 00000000..8c33cf6f --- /dev/null +++ b/x/wasm/internal/keeper/msg_server.go @@ -0,0 +1,185 @@ +package keeper + +import ( + "context" + "fmt" + "github.com/CosmWasm/wasmd/x/wasm/internal/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var _ types.MsgServer = msgServer{} + +type msgServer struct { + keeper *Keeper +} + +func NewMsgServerImpl(k *Keeper) types.MsgServer { + return &msgServer{keeper: k} +} + +func (m msgServer) StoreCode(goCtx context.Context, msg *types.MsgStoreCode) (*types.MsgStoreCodeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, sdkerrors.Wrap(err, "sender") + } + codeID, err := m.keeper.Create(ctx, senderAddr, msg.WASMByteCode, msg.Source, msg.Builder, msg.InstantiatePermission) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), + sdk.NewAttribute(types.AttributeKeyCodeID, fmt.Sprintf("%d", codeID)), + )) + + return &types.MsgStoreCodeResponse{ + CodeID: fmt.Sprintf("%d", codeID), + }, nil +} + +func (m msgServer) InstantiateContract(goCtx context.Context, msg *types.MsgInstantiateContract) (*types.MsgInstantiateContractResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, sdkerrors.Wrap(err, "sender") + } + var adminAddr sdk.AccAddress + if msg.Admin != "" { + if adminAddr, err = sdk.AccAddressFromBech32(msg.Admin); err != nil { + return nil, sdkerrors.Wrap(err, "admin") + } + } + + contractAddr, err := m.keeper.Instantiate(ctx, msg.CodeID, senderAddr, adminAddr, msg.InitMsg, msg.Label, msg.InitFunds) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), + sdk.NewAttribute(types.AttributeKeyCodeID, fmt.Sprintf("%d", msg.CodeID)), + sdk.NewAttribute(types.AttributeKeyContract, contractAddr.String()), + )) + + return &types.MsgInstantiateContractResponse{ + Address: contractAddr.String(), + }, nil +} + +func (m msgServer) ExecuteContract(goCtx context.Context, msg *types.MsgExecuteContract) (*types.MsgExecuteContractResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, sdkerrors.Wrap(err, "sender") + } + contractAddr, err := sdk.AccAddressFromBech32(msg.Contract) + if err != nil { + return nil, sdkerrors.Wrap(err, "contract") + } + + res, err := m.keeper.Execute(ctx, contractAddr, senderAddr, msg.Msg, msg.SentFunds) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), + sdk.NewAttribute(types.AttributeKeyContract, msg.Contract), + )) + + return &types.MsgExecuteContractResponse{ + Data: res.Data, + }, nil + +} + +func (m msgServer) MigrateContract(goCtx context.Context, msg *types.MsgMigrateContract) (*types.MsgMigrateContractResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, sdkerrors.Wrap(err, "sender") + } + contractAddr, err := sdk.AccAddressFromBech32(msg.Contract) + if err != nil { + return nil, sdkerrors.Wrap(err, "contract") + } + + res, err := m.keeper.Migrate(ctx, contractAddr, senderAddr, msg.CodeID, msg.MigrateMsg) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), + sdk.NewAttribute(types.AttributeKeyContract, msg.Contract), + )) + + return &types.MsgMigrateContractResponse{ + Data: res.Data, + }, nil +} + +func (m msgServer) UpdateAdmin(goCtx context.Context, msg *types.MsgUpdateAdmin) (*types.MsgUpdateAdminResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, sdkerrors.Wrap(err, "sender") + } + contractAddr, err := sdk.AccAddressFromBech32(msg.Contract) + if err != nil { + return nil, sdkerrors.Wrap(err, "contract") + } + newAdminAddr, err := sdk.AccAddressFromBech32(msg.NewAdmin) + if err != nil { + return nil, sdkerrors.Wrap(err, "new admin") + } + + if err := m.keeper.UpdateContractAdmin(ctx, contractAddr, senderAddr, newAdminAddr); err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), + sdk.NewAttribute(types.AttributeKeyContract, msg.Contract), + )) + + return &types.MsgUpdateAdminResponse{}, nil +} + +func (m msgServer) ClearAdmin(goCtx context.Context, msg *types.MsgClearAdmin) (*types.MsgClearAdminResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, sdkerrors.Wrap(err, "sender") + } + contractAddr, err := sdk.AccAddressFromBech32(msg.Contract) + if err != nil { + return nil, sdkerrors.Wrap(err, "contract") + } + + if err := m.keeper.ClearContractAdmin(ctx, contractAddr, senderAddr); err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent(sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeKeySigner, msg.Sender), + sdk.NewAttribute(types.AttributeKeyContract, msg.Contract), + )) + + return &types.MsgClearAdminResponse{}, nil +} diff --git a/x/wasm/internal/types/codec.go b/x/wasm/internal/types/codec.go index 0015caf5..c8b3aef2 100644 --- a/x/wasm/internal/types/codec.go +++ b/x/wasm/internal/types/codec.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -42,6 +43,8 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &UpdateAdminProposal{}, &ClearAdminProposal{}, ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } var ( diff --git a/x/wasm/internal/types/tx.pb.go b/x/wasm/internal/types/tx.pb.go index eaa87112..2a9eea18 100644 --- a/x/wasm/internal/types/tx.pb.go +++ b/x/wasm/internal/types/tx.pb.go @@ -4,12 +4,17 @@ package types import ( + context "context" encoding_json "encoding/json" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" io "io" math "math" math_bits "math/bits" @@ -73,6 +78,45 @@ func (m *MsgStoreCode) XXX_DiscardUnknown() { var xxx_messageInfo_MsgStoreCode proto.InternalMessageInfo +// MsgStoreCodeResponse returns store result data. +type MsgStoreCodeResponse struct { + // CodeID is the reference to the stored WASM code + CodeID string `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` +} + +func (m *MsgStoreCodeResponse) Reset() { *m = MsgStoreCodeResponse{} } +func (m *MsgStoreCodeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgStoreCodeResponse) ProtoMessage() {} +func (*MsgStoreCodeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5129e02f2349864e, []int{1} +} +func (m *MsgStoreCodeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgStoreCodeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgStoreCodeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgStoreCodeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgStoreCodeResponse.Merge(m, src) +} +func (m *MsgStoreCodeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgStoreCodeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgStoreCodeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgStoreCodeResponse proto.InternalMessageInfo + // MsgInstantiateContract create a new smart contract instance for the given code id. type MsgInstantiateContract struct { // Sender is the that actor that signed the messages @@ -93,7 +137,7 @@ func (m *MsgInstantiateContract) Reset() { *m = MsgInstantiateContract{} func (m *MsgInstantiateContract) String() string { return proto.CompactTextString(m) } func (*MsgInstantiateContract) ProtoMessage() {} func (*MsgInstantiateContract) Descriptor() ([]byte, []int) { - return fileDescriptor_5129e02f2349864e, []int{1} + return fileDescriptor_5129e02f2349864e, []int{2} } func (m *MsgInstantiateContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -122,6 +166,45 @@ func (m *MsgInstantiateContract) XXX_DiscardUnknown() { var xxx_messageInfo_MsgInstantiateContract proto.InternalMessageInfo +// MsgInstantiateContractResponse return instantiation result data +type MsgInstantiateContractResponse struct { + // Address is the address of the new contract instance. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *MsgInstantiateContractResponse) Reset() { *m = MsgInstantiateContractResponse{} } +func (m *MsgInstantiateContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgInstantiateContractResponse) ProtoMessage() {} +func (*MsgInstantiateContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5129e02f2349864e, []int{3} +} +func (m *MsgInstantiateContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgInstantiateContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgInstantiateContractResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgInstantiateContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgInstantiateContractResponse.Merge(m, src) +} +func (m *MsgInstantiateContractResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgInstantiateContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgInstantiateContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgInstantiateContractResponse proto.InternalMessageInfo + // MsgExecuteContract submits the given message data to a smart contract type MsgExecuteContract struct { // Sender is the that actor that signed the messages @@ -138,7 +221,7 @@ func (m *MsgExecuteContract) Reset() { *m = MsgExecuteContract{} } func (m *MsgExecuteContract) String() string { return proto.CompactTextString(m) } func (*MsgExecuteContract) ProtoMessage() {} func (*MsgExecuteContract) Descriptor() ([]byte, []int) { - return fileDescriptor_5129e02f2349864e, []int{2} + return fileDescriptor_5129e02f2349864e, []int{4} } func (m *MsgExecuteContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -167,6 +250,45 @@ func (m *MsgExecuteContract) XXX_DiscardUnknown() { var xxx_messageInfo_MsgExecuteContract proto.InternalMessageInfo +// MsgExecuteContractResponse returns execution result data. +type MsgExecuteContractResponse struct { + // Data contains base64-encoded bytes to returned from the contract + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *MsgExecuteContractResponse) Reset() { *m = MsgExecuteContractResponse{} } +func (m *MsgExecuteContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgExecuteContractResponse) ProtoMessage() {} +func (*MsgExecuteContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5129e02f2349864e, []int{5} +} +func (m *MsgExecuteContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecuteContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecuteContractResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgExecuteContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecuteContractResponse.Merge(m, src) +} +func (m *MsgExecuteContractResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgExecuteContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecuteContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecuteContractResponse proto.InternalMessageInfo + // MsgMigrateContract runs a code upgrade/ downgrade for a smart contract type MsgMigrateContract struct { // Sender is the that actor that signed the messages @@ -183,7 +305,7 @@ func (m *MsgMigrateContract) Reset() { *m = MsgMigrateContract{} } func (m *MsgMigrateContract) String() string { return proto.CompactTextString(m) } func (*MsgMigrateContract) ProtoMessage() {} func (*MsgMigrateContract) Descriptor() ([]byte, []int) { - return fileDescriptor_5129e02f2349864e, []int{3} + return fileDescriptor_5129e02f2349864e, []int{6} } func (m *MsgMigrateContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -212,6 +334,45 @@ func (m *MsgMigrateContract) XXX_DiscardUnknown() { var xxx_messageInfo_MsgMigrateContract proto.InternalMessageInfo +// MsgMigrateContractResponse returns contract migration result data. +type MsgMigrateContractResponse struct { + // Data contains base64-encoded bytes returned from the wasm contract. + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *MsgMigrateContractResponse) Reset() { *m = MsgMigrateContractResponse{} } +func (m *MsgMigrateContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMigrateContractResponse) ProtoMessage() {} +func (*MsgMigrateContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5129e02f2349864e, []int{7} +} +func (m *MsgMigrateContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMigrateContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMigrateContractResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgMigrateContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMigrateContractResponse.Merge(m, src) +} +func (m *MsgMigrateContractResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMigrateContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMigrateContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMigrateContractResponse proto.InternalMessageInfo + // MsgUpdateAdmin sets a new admin for a smart contract type MsgUpdateAdmin struct { // Sender is the that actor that signed the messages @@ -226,7 +387,7 @@ func (m *MsgUpdateAdmin) Reset() { *m = MsgUpdateAdmin{} } func (m *MsgUpdateAdmin) String() string { return proto.CompactTextString(m) } func (*MsgUpdateAdmin) ProtoMessage() {} func (*MsgUpdateAdmin) Descriptor() ([]byte, []int) { - return fileDescriptor_5129e02f2349864e, []int{4} + return fileDescriptor_5129e02f2349864e, []int{8} } func (m *MsgUpdateAdmin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -255,6 +416,43 @@ func (m *MsgUpdateAdmin) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateAdmin proto.InternalMessageInfo +// MsgUpdateAdminResponse returns empty data +type MsgUpdateAdminResponse struct { +} + +func (m *MsgUpdateAdminResponse) Reset() { *m = MsgUpdateAdminResponse{} } +func (m *MsgUpdateAdminResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateAdminResponse) ProtoMessage() {} +func (*MsgUpdateAdminResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5129e02f2349864e, []int{9} +} +func (m *MsgUpdateAdminResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateAdminResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateAdminResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateAdminResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateAdminResponse.Merge(m, src) +} +func (m *MsgUpdateAdminResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateAdminResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateAdminResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateAdminResponse proto.InternalMessageInfo + // MsgClearAdmin removes any admin stored for a smart contract type MsgClearAdmin struct { // Sender is the that actor that signed the messages @@ -267,7 +465,7 @@ func (m *MsgClearAdmin) Reset() { *m = MsgClearAdmin{} } func (m *MsgClearAdmin) String() string { return proto.CompactTextString(m) } func (*MsgClearAdmin) ProtoMessage() {} func (*MsgClearAdmin) Descriptor() ([]byte, []int) { - return fileDescriptor_5129e02f2349864e, []int{5} + return fileDescriptor_5129e02f2349864e, []int{10} } func (m *MsgClearAdmin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -296,59 +494,386 @@ func (m *MsgClearAdmin) XXX_DiscardUnknown() { var xxx_messageInfo_MsgClearAdmin proto.InternalMessageInfo +// MsgClearAdminResponse returns empty data +type MsgClearAdminResponse struct { +} + +func (m *MsgClearAdminResponse) Reset() { *m = MsgClearAdminResponse{} } +func (m *MsgClearAdminResponse) String() string { return proto.CompactTextString(m) } +func (*MsgClearAdminResponse) ProtoMessage() {} +func (*MsgClearAdminResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5129e02f2349864e, []int{11} +} +func (m *MsgClearAdminResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgClearAdminResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgClearAdminResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgClearAdminResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgClearAdminResponse.Merge(m, src) +} +func (m *MsgClearAdminResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgClearAdminResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgClearAdminResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgClearAdminResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgStoreCode)(nil), "cosmwasm.wasm.v1beta1.MsgStoreCode") + proto.RegisterType((*MsgStoreCodeResponse)(nil), "cosmwasm.wasm.v1beta1.MsgStoreCodeResponse") proto.RegisterType((*MsgInstantiateContract)(nil), "cosmwasm.wasm.v1beta1.MsgInstantiateContract") + proto.RegisterType((*MsgInstantiateContractResponse)(nil), "cosmwasm.wasm.v1beta1.MsgInstantiateContractResponse") proto.RegisterType((*MsgExecuteContract)(nil), "cosmwasm.wasm.v1beta1.MsgExecuteContract") + proto.RegisterType((*MsgExecuteContractResponse)(nil), "cosmwasm.wasm.v1beta1.MsgExecuteContractResponse") proto.RegisterType((*MsgMigrateContract)(nil), "cosmwasm.wasm.v1beta1.MsgMigrateContract") + proto.RegisterType((*MsgMigrateContractResponse)(nil), "cosmwasm.wasm.v1beta1.MsgMigrateContractResponse") proto.RegisterType((*MsgUpdateAdmin)(nil), "cosmwasm.wasm.v1beta1.MsgUpdateAdmin") + proto.RegisterType((*MsgUpdateAdminResponse)(nil), "cosmwasm.wasm.v1beta1.MsgUpdateAdminResponse") proto.RegisterType((*MsgClearAdmin)(nil), "cosmwasm.wasm.v1beta1.MsgClearAdmin") + proto.RegisterType((*MsgClearAdminResponse)(nil), "cosmwasm.wasm.v1beta1.MsgClearAdminResponse") } func init() { proto.RegisterFile("x/wasm/internal/types/tx.proto", fileDescriptor_5129e02f2349864e) } var fileDescriptor_5129e02f2349864e = []byte{ - // 632 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x86, 0xe3, 0xa6, 0x4d, 0x9b, 0x6d, 0xa8, 0x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x6c, 0x1b, 0x57, - 0x63, 0xdb, 0xf8, 0x36, 0xb6, 0x8d, 0x0f, 0xd7, 0x76, 0xe5, 0xea, 0xda, 0xae, 0x7c, 0xb9, 0xb6, - 0x2b, 0xa7, 0x7b, 0x33, 0x27, 0xe5, 0x0b, 0xc8, 0x4e, 0xd4, 0x1d, 0xa5, 0x3e, 0xe5, 0xd4, 0x1d, - 0x96, 0xef, 0x9b, 0x37, 0x56, 0x5c, 0xd3, 0x97, 0xd5, 0xe3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, - 0x7b, 0xfd, 0xe7, 0x34, 0x3e, 0x05, 0x00, 0x00, + // 818 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcd, 0x6e, 0xeb, 0x44, + 0x14, 0x8e, 0x6f, 0xfe, 0x9a, 0x93, 0x70, 0x41, 0xa6, 0x2d, 0xc6, 0x20, 0x27, 0xf8, 0x82, 0x14, + 0x04, 0xb5, 0xdb, 0x22, 0x40, 0x02, 0xb1, 0x68, 0x02, 0x48, 0x5d, 0x18, 0x21, 0x5f, 0xa1, 0x2b, + 0x55, 0x42, 0x61, 0x62, 0x4f, 0xcd, 0x94, 0x78, 0x26, 0xf2, 0x4c, 0x48, 0x2a, 0xde, 0x80, 0x15, + 0x4f, 0xc1, 0x02, 0xf1, 0x20, 0x5d, 0x76, 0xc9, 0x2a, 0x40, 0xca, 0x92, 0x27, 0x60, 0x85, 0xc6, + 0x76, 0x5c, 0x37, 0xc4, 0x91, 0x11, 0x62, 0x63, 0xcf, 0x19, 0x7f, 0xe7, 0xfb, 0x7c, 0x3e, 0x9d, + 0x33, 0x1a, 0x30, 0x16, 0xf6, 0x1c, 0xf1, 0xd0, 0x26, 0x54, 0xe0, 0x88, 0xa2, 0x89, 0x2d, 0xae, + 0xa7, 0x98, 0xdb, 0x62, 0x61, 0x4d, 0x23, 0x26, 0x98, 0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03, 0x4a, 0x7f, + 0xab, 0x04, 0x28, 0x73, 0xf5, 0x3b, 0x78, 0x71, 0xdb, 0xe1, 0x74, 0x54, 0xcc, 0xb1, 0x05, 0xae, + 0xbf, 0xfb, 0xaf, 0xe0, 0x99, 0x38, 0x83, 0xe7, 0x37, 0x87, 0xf6, 0xcd, 0x62, 0xa6, 0x0d, 0xa8, + 0x7e, 0x52, 0x1a, 0x9a, 0x17, 0xdc, 0x1c, 0x86, 0x1d, 0x82, 0x1b, 0xd0, 0x5d, 0x82, 0x45, 0x4d, + 0xeb, 0x41, 0x3b, 0xdf, 0x9d, 0x6f, 0x14, 0x33, 0xe4, 0x60, 0xfa, 0x51, 0x29, 0x58, 0x26, 0xf2, + 0x15, 0x40, 0xae, 0x0b, 0x5f, 0x2f, 0x4e, 0xbe, 0x47, 0xe9, 0x6f, 0x97, 0x41, 0xad, 0x15, 0x06, + 0x9f, 0xdd, 0xfc, 0x6e, 0x54, 0x6e, 0x56, 0x86, 0x72, 0xbb, 0x32, 0x94, 0xdf, 0x56, 0x86, 0xf2, + 0xc3, 0x9d, 0x51, 0xb9, 0xbd, 0x33, 0x2a, 0xbf, 0xdc, 0x19, 0x95, 0x8b, 0xe3, 0xdc, 0x69, 0x36, + 0x64, 0x3c, 0x7c, 0x26, 0x2f, 0x10, 0x92, 0xd5, 0xb7, 0x17, 0xe9, 0xfb, 0xe1, 0x75, 0x62, 0xdc, + 0x88, 0x6f, 0x12, 0xef, 0xfc, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x01, 0xf3, 0xf7, 0xcc, 0xdb, 0x08, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // StoreCode to submit Wasm code to the system + StoreCode(ctx context.Context, in *MsgStoreCode, opts ...grpc.CallOption) (*MsgStoreCodeResponse, error) + // Instantiate creates a new smart contract instance for the given code id. + InstantiateContract(ctx context.Context, in *MsgInstantiateContract, opts ...grpc.CallOption) (*MsgInstantiateContractResponse, error) + // Execute submits the given message data to a smart contract + ExecuteContract(ctx context.Context, in *MsgExecuteContract, opts ...grpc.CallOption) (*MsgExecuteContractResponse, error) + // Migrate runs a code upgrade/ downgrade for a smart contract + MigrateContract(ctx context.Context, in *MsgMigrateContract, opts ...grpc.CallOption) (*MsgMigrateContractResponse, error) + // UpdateAdmin sets a new admin for a smart contract + UpdateAdmin(ctx context.Context, in *MsgUpdateAdmin, opts ...grpc.CallOption) (*MsgUpdateAdminResponse, error) + // ClearAdmin removes any admin stored for a smart contract + ClearAdmin(ctx context.Context, in *MsgClearAdmin, opts ...grpc.CallOption) (*MsgClearAdminResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) StoreCode(ctx context.Context, in *MsgStoreCode, opts ...grpc.CallOption) (*MsgStoreCodeResponse, error) { + out := new(MsgStoreCodeResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1beta1.Msg/StoreCode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) InstantiateContract(ctx context.Context, in *MsgInstantiateContract, opts ...grpc.CallOption) (*MsgInstantiateContractResponse, error) { + out := new(MsgInstantiateContractResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1beta1.Msg/InstantiateContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ExecuteContract(ctx context.Context, in *MsgExecuteContract, opts ...grpc.CallOption) (*MsgExecuteContractResponse, error) { + out := new(MsgExecuteContractResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1beta1.Msg/ExecuteContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) MigrateContract(ctx context.Context, in *MsgMigrateContract, opts ...grpc.CallOption) (*MsgMigrateContractResponse, error) { + out := new(MsgMigrateContractResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1beta1.Msg/MigrateContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateAdmin(ctx context.Context, in *MsgUpdateAdmin, opts ...grpc.CallOption) (*MsgUpdateAdminResponse, error) { + out := new(MsgUpdateAdminResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1beta1.Msg/UpdateAdmin", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ClearAdmin(ctx context.Context, in *MsgClearAdmin, opts ...grpc.CallOption) (*MsgClearAdminResponse, error) { + out := new(MsgClearAdminResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1beta1.Msg/ClearAdmin", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // StoreCode to submit Wasm code to the system + StoreCode(context.Context, *MsgStoreCode) (*MsgStoreCodeResponse, error) + // Instantiate creates a new smart contract instance for the given code id. + InstantiateContract(context.Context, *MsgInstantiateContract) (*MsgInstantiateContractResponse, error) + // Execute submits the given message data to a smart contract + ExecuteContract(context.Context, *MsgExecuteContract) (*MsgExecuteContractResponse, error) + // Migrate runs a code upgrade/ downgrade for a smart contract + MigrateContract(context.Context, *MsgMigrateContract) (*MsgMigrateContractResponse, error) + // UpdateAdmin sets a new admin for a smart contract + UpdateAdmin(context.Context, *MsgUpdateAdmin) (*MsgUpdateAdminResponse, error) + // ClearAdmin removes any admin stored for a smart contract + ClearAdmin(context.Context, *MsgClearAdmin) (*MsgClearAdminResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) StoreCode(ctx context.Context, req *MsgStoreCode) (*MsgStoreCodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StoreCode not implemented") +} +func (*UnimplementedMsgServer) InstantiateContract(ctx context.Context, req *MsgInstantiateContract) (*MsgInstantiateContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method InstantiateContract not implemented") +} +func (*UnimplementedMsgServer) ExecuteContract(ctx context.Context, req *MsgExecuteContract) (*MsgExecuteContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExecuteContract not implemented") +} +func (*UnimplementedMsgServer) MigrateContract(ctx context.Context, req *MsgMigrateContract) (*MsgMigrateContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MigrateContract not implemented") +} +func (*UnimplementedMsgServer) UpdateAdmin(ctx context.Context, req *MsgUpdateAdmin) (*MsgUpdateAdminResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateAdmin not implemented") +} +func (*UnimplementedMsgServer) ClearAdmin(ctx context.Context, req *MsgClearAdmin) (*MsgClearAdminResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClearAdmin not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_StoreCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgStoreCode) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).StoreCode(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1beta1.Msg/StoreCode", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).StoreCode(ctx, req.(*MsgStoreCode)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_InstantiateContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgInstantiateContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).InstantiateContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1beta1.Msg/InstantiateContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).InstantiateContract(ctx, req.(*MsgInstantiateContract)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ExecuteContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExecuteContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ExecuteContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1beta1.Msg/ExecuteContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ExecuteContract(ctx, req.(*MsgExecuteContract)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_MigrateContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMigrateContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).MigrateContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1beta1.Msg/MigrateContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).MigrateContract(ctx, req.(*MsgMigrateContract)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateAdmin) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateAdmin(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1beta1.Msg/UpdateAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateAdmin(ctx, req.(*MsgUpdateAdmin)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ClearAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgClearAdmin) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ClearAdmin(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1beta1.Msg/ClearAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ClearAdmin(ctx, req.(*MsgClearAdmin)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmwasm.wasm.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "StoreCode", + Handler: _Msg_StoreCode_Handler, + }, + { + MethodName: "InstantiateContract", + Handler: _Msg_InstantiateContract_Handler, + }, + { + MethodName: "ExecuteContract", + Handler: _Msg_ExecuteContract_Handler, + }, + { + MethodName: "MigrateContract", + Handler: _Msg_MigrateContract_Handler, + }, + { + MethodName: "UpdateAdmin", + Handler: _Msg_UpdateAdmin_Handler, + }, + { + MethodName: "ClearAdmin", + Handler: _Msg_ClearAdmin_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "x/wasm/internal/types/tx.proto", } func (m *MsgStoreCode) Marshal() (dAtA []byte, err error) { @@ -414,6 +939,36 @@ func (m *MsgStoreCode) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgStoreCodeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgStoreCodeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgStoreCodeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CodeID) > 0 { + i -= len(m.CodeID) + copy(dAtA[i:], m.CodeID) + i = encodeVarintTx(dAtA, i, uint64(len(m.CodeID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgInstantiateContract) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -484,6 +1039,36 @@ func (m *MsgInstantiateContract) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgInstantiateContractResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgInstantiateContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgInstantiateContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgExecuteContract) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -542,6 +1127,36 @@ func (m *MsgExecuteContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgExecuteContractResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgExecuteContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecuteContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgMigrateContract) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -591,6 +1206,36 @@ func (m *MsgMigrateContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgMigrateContractResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgMigrateContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMigrateContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgUpdateAdmin) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -635,6 +1280,29 @@ func (m *MsgUpdateAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgUpdateAdminResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateAdminResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgClearAdmin) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -672,6 +1340,29 @@ func (m *MsgClearAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgClearAdminResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgClearAdminResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgClearAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -712,6 +1403,19 @@ func (m *MsgStoreCode) Size() (n int) { return n } +func (m *MsgStoreCodeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CodeID) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func (m *MsgInstantiateContract) Size() (n int) { if m == nil { return 0 @@ -746,6 +1450,19 @@ func (m *MsgInstantiateContract) Size() (n int) { return n } +func (m *MsgInstantiateContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func (m *MsgExecuteContract) Size() (n int) { if m == nil { return 0 @@ -773,6 +1490,19 @@ func (m *MsgExecuteContract) Size() (n int) { return n } +func (m *MsgExecuteContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func (m *MsgMigrateContract) Size() (n int) { if m == nil { return 0 @@ -797,6 +1527,19 @@ func (m *MsgMigrateContract) Size() (n int) { return n } +func (m *MsgMigrateContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func (m *MsgUpdateAdmin) Size() (n int) { if m == nil { return 0 @@ -818,6 +1561,15 @@ func (m *MsgUpdateAdmin) Size() (n int) { return n } +func (m *MsgUpdateAdminResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgClearAdmin) Size() (n int) { if m == nil { return 0 @@ -835,6 +1587,15 @@ func (m *MsgClearAdmin) Size() (n int) { return n } +func (m *MsgClearAdminResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1060,6 +1821,91 @@ func (m *MsgStoreCode) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgStoreCodeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgStoreCodeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgStoreCodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgInstantiateContract) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1296,6 +2142,91 @@ func (m *MsgInstantiateContract) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgInstantiateContractResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgInstantiateContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgInstantiateContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgExecuteContract) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1481,6 +2412,93 @@ func (m *MsgExecuteContract) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgExecuteContractResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgExecuteContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgMigrateContract) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1651,6 +2669,93 @@ func (m *MsgMigrateContract) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgMigrateContractResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgMigrateContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMigrateContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgUpdateAdmin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1800,6 +2905,59 @@ func (m *MsgUpdateAdmin) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateAdminResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgClearAdmin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1917,6 +3075,59 @@ func (m *MsgClearAdmin) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgClearAdminResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgClearAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClearAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/wasm/internal/types/tx.proto b/x/wasm/internal/types/tx.proto index e5884286..dbfc5448 100644 --- a/x/wasm/internal/types/tx.proto +++ b/x/wasm/internal/types/tx.proto @@ -2,83 +2,125 @@ syntax = "proto3"; package cosmwasm.wasm.v1beta1; -import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; import "x/wasm/internal/types/types.proto"; option go_package = "github.com/CosmWasm/wasmd/x/wasmd/internal/types"; option (gogoproto.goproto_getters_all) = false; +// Msg defines the wasm Msg service. +service Msg { + // StoreCode to submit Wasm code to the system + rpc StoreCode(MsgStoreCode) returns (MsgStoreCodeResponse); + // Instantiate creates a new smart contract instance for the given code id. + rpc InstantiateContract(MsgInstantiateContract) returns (MsgInstantiateContractResponse); + // Execute submits the given message data to a smart contract + rpc ExecuteContract(MsgExecuteContract) returns (MsgExecuteContractResponse); + // Migrate runs a code upgrade/ downgrade for a smart contract + rpc MigrateContract(MsgMigrateContract) returns (MsgMigrateContractResponse); + // UpdateAdmin sets a new admin for a smart contract + rpc UpdateAdmin(MsgUpdateAdmin) returns (MsgUpdateAdminResponse); + // ClearAdmin removes any admin stored for a smart contract + rpc ClearAdmin(MsgClearAdmin) returns (MsgClearAdminResponse); +} // MsgStoreCode submit Wasm code to the system message MsgStoreCode { - // Sender is the that actor that signed the messages - string sender = 1; - // WASMByteCode can be raw or gzip compressed - bytes wasm_byte_code = 2 [(gogoproto.customname) = "WASMByteCode"]; - // Source is a valid absolute HTTPS URI to the contract's source code, optional - string source = 3; - // Builder is a valid docker image name with tag, optional - string builder = 4; - // InstantiatePermission access control to apply on contract creation, optional - AccessConfig instantiate_permission = 5; + // Sender is the that actor that signed the messages + string sender = 1; + // WASMByteCode can be raw or gzip compressed + bytes wasm_byte_code = 2 [(gogoproto.customname) = "WASMByteCode"]; + // Source is a valid absolute HTTPS URI to the contract's source code, optional + string source = 3; + // Builder is a valid docker image name with tag, optional + string builder = 4; + // InstantiatePermission access control to apply on contract creation, optional + AccessConfig instantiate_permission = 5; +} +// MsgStoreCodeResponse returns store result data. +message MsgStoreCodeResponse{ + // CodeID is the reference to the stored WASM code + string code_id = 1 [(gogoproto.customname) = "CodeID"]; } // MsgInstantiateContract create a new smart contract instance for the given code id. message MsgInstantiateContract { - // Sender is the that actor that signed the messages - string sender = 1; - // Admin is an optional address that can execute migrations - string admin = 2; - // CodeID is the reference to the stored WASM code - 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 [(gogoproto.casttype) = "encoding/json.RawMessage"]; - // InitFunds coins that are transferred to the contract on instantiation - repeated cosmos.base.v1beta1.Coin init_funds = 6 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + // Sender is the that actor that signed the messages + string sender = 1; + // Admin is an optional address that can execute migrations + string admin = 2; + // CodeID is the reference to the stored WASM code + 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 [(gogoproto.casttype) = "encoding/json.RawMessage"]; + // InitFunds coins that are transferred to the contract on instantiation + repeated cosmos.base.v1beta1.Coin init_funds = 6 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} +// MsgInstantiateContractResponse return instantiation result data +message MsgInstantiateContractResponse { + // Address is the bech32 address of the new contract instance. + string address = 1; } // MsgExecuteContract submits the given message data to a smart contract message MsgExecuteContract { - // Sender is the that actor that signed the messages - string sender = 1; - // Contract is the address of the smart contract - string contract = 2; - // Msg json encoded message to be passed to the contract - bytes msg = 3 [(gogoproto.casttype) = "encoding/json.RawMessage"]; - // SentFunds coins that are transferred to the contract on execution - repeated cosmos.base.v1beta1.Coin sent_funds = 5 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + // Sender is the that actor that signed the messages + string sender = 1; + // Contract is the address of the smart contract + string contract = 2; + // Msg json encoded message to be passed to the contract + bytes msg = 3 [(gogoproto.casttype) = "encoding/json.RawMessage"]; + // SentFunds coins that are transferred to the contract on execution + repeated cosmos.base.v1beta1.Coin sent_funds = 5 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// MsgExecuteContractResponse returns execution result data. +message MsgExecuteContractResponse { + // Data contains base64-encoded bytes to returned from the contract + bytes data = 1; } // MsgMigrateContract runs a code upgrade/ downgrade for a smart contract message MsgMigrateContract { - // Sender is the that actor that signed the messages - string sender = 1; - // Contract is the address of the smart contract - 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 [(gogoproto.casttype) = "encoding/json.RawMessage"]; + // Sender is the that actor that signed the messages + string sender = 1; + // Contract is the address of the smart contract + 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 [(gogoproto.casttype) = "encoding/json.RawMessage"]; +} + +// MsgMigrateContractResponse returns contract migration result data. +message MsgMigrateContractResponse { + // Data contains base64-encoded bytes returned from the wasm contract. + bytes data = 1; } // MsgUpdateAdmin sets a new admin for a smart contract message MsgUpdateAdmin { - // Sender is the that actor that signed the messages - string sender = 1; - // NewAdmin address to be set - string new_admin = 2; - // Contract is the address of the smart contract - string contract = 3; + // Sender is the that actor that signed the messages + string sender = 1; + // NewAdmin address to be set + string new_admin = 2; + // Contract is the address of the smart contract + string contract = 3; } +// MsgUpdateAdminResponse returns empty data +message MsgUpdateAdminResponse{} // MsgClearAdmin removes any admin stored for a smart contract message MsgClearAdmin { - // Sender is the that actor that signed the messages - string sender = 1; - // Contract is the address of the smart contract - string contract = 3; + // Sender is the that actor that signed the messages + string sender = 1; + // Contract is the address of the smart contract + string contract = 3; } + +// MsgClearAdminResponse returns empty data +message MsgClearAdminResponse{} diff --git a/x/wasm/module.go b/x/wasm/module.go index 5a4aee15..1d45ae51 100644 --- a/x/wasm/module.go +++ b/x/wasm/module.go @@ -107,8 +107,9 @@ func NewAppModule(keeper *Keeper, validatorSetSource keeper.ValidatorSetSource) } } -func (am AppModule) RegisterServices(configurator module.Configurator) { - types.RegisterQueryServer(configurator.QueryServer(), NewQuerier(am.keeper)) +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), NewQuerier(am.keeper)) } func (am AppModule) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier { diff --git a/x/wasm/module_test.go b/x/wasm/module_test.go index 68fbe56f..f60aa429 100644 --- a/x/wasm/module_test.go +++ b/x/wasm/module_test.go @@ -154,7 +154,9 @@ func TestHandleInstantiate(t *testing.T) { } res, err := h(data.ctx, msg) require.NoError(t, err) - require.Equal(t, res.Data, []byte("1")) + var pStoreResp MsgStoreCodeResponse + require.NoError(t, pStoreResp.Unmarshal(res.Data)) + require.Equal(t, pStoreResp.CodeID, "1") _, _, bob := keyPubAddr() _, _, fred := keyPubAddr() @@ -175,7 +177,10 @@ func TestHandleInstantiate(t *testing.T) { } res, err = h(data.ctx, &initCmd) require.NoError(t, err) - contractBech32Addr := string(res.Data) + var pInstResp MsgInstantiateContractResponse + require.NoError(t, pInstResp.Unmarshal(res.Data)) + contractBech32Addr := pInstResp.Address + require.Equal(t, "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5", contractBech32Addr) // this should be standard x/wasm init event, nothing from contract require.Equal(t, 2, len(res.Events), prettyEvents(res.Events)) @@ -213,7 +218,9 @@ func TestHandleExecute(t *testing.T) { } res, err := h(data.ctx, msg) require.NoError(t, err) - require.Equal(t, res.Data, []byte("1")) + var pStoreResp MsgStoreCodeResponse + require.NoError(t, pStoreResp.Unmarshal(res.Data)) + require.Equal(t, pStoreResp.CodeID, "1") _, _, bob := keyPubAddr() initMsg := initMsg{ @@ -231,7 +238,10 @@ func TestHandleExecute(t *testing.T) { } res, err = h(data.ctx, &initCmd) require.NoError(t, err) - contractBech32Addr := string(res.Data) + var pInstResp MsgInstantiateContractResponse + require.NoError(t, pInstResp.Unmarshal(res.Data)) + contractBech32Addr := pInstResp.Address + require.Equal(t, "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5", contractBech32Addr) // this should be standard x/wasm init event, plus a bank send event (2), with no custom contract events require.Equal(t, 3, len(res.Events), prettyEvents(res.Events)) @@ -265,6 +275,10 @@ func TestHandleExecute(t *testing.T) { } res, err = h(data.ctx, &execCmd) require.NoError(t, err) + var pExecResp MsgExecuteContractResponse + require.NoError(t, pExecResp.Unmarshal(res.Data)) + require.NotEmpty(t, pExecResp.Data) + // this should be standard x/wasm init event, plus 2 bank send event, plus a special event from the contract require.Equal(t, 4, len(res.Events), prettyEvents(res.Events)) @@ -327,7 +341,6 @@ func TestHandleExecuteEscrow(t *testing.T) { } res, err := h(data.ctx, msg) require.NoError(t, err) - require.Equal(t, res.Data, []byte("1")) _, _, bob := keyPubAddr() initMsg := map[string]interface{}{ @@ -345,7 +358,9 @@ func TestHandleExecuteEscrow(t *testing.T) { } res, err = h(data.ctx, &initCmd) require.NoError(t, err) - contractBech32Addr := string(res.Data) + var pInstResp MsgInstantiateContractResponse + require.NoError(t, pInstResp.Unmarshal(res.Data)) + contractBech32Addr := pInstResp.Address require.Equal(t, "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5", contractBech32Addr) handleMsg := map[string]interface{}{ @@ -362,6 +377,9 @@ func TestHandleExecuteEscrow(t *testing.T) { } res, err = h(data.ctx, &execCmd) require.NoError(t, err) + var pExecResp MsgExecuteContractResponse + require.NoError(t, pExecResp.Unmarshal(res.Data)) + require.NotEmpty(t, pExecResp.Data) // ensure bob now exists and got both payments released bobAcct := data.acctKeeper.GetAccount(data.ctx, bob)