diff --git a/x/babylon/contract/in_message.go b/x/babylon/contract/in_message.go index 2905d40..d7df60b 100644 --- a/x/babylon/contract/in_message.go +++ b/x/babylon/contract/in_message.go @@ -1,11 +1,18 @@ package contract -// CustomMsg is a message sent from a smart contract to the Babylon module -// TODO: implement -type CustomMsg struct { - Test *TestMsg `json:"test,omitempty"` -} +import ( + wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types" +) -type TestMsg struct { - Placeholder string `json:"placeholder,omitempty"` -} +// CustomMsg is a message sent from a smart contract to the Babylon module +type ( + CustomMsg struct { + MintRewards *MintRewardsMsg `json:"mint_rewards,omitempty"` + } + // MintRewardsMsg mints the specified number of block rewards, + // and sends them to the specified recipient (typically, the staking contract) + MintRewardsMsg struct { + Amount wasmvmtypes.Coin `json:"amount"` + Recipient string `json:"recipient"` + } +) diff --git a/x/babylon/keeper/handler_plugin.go b/x/babylon/keeper/handler_plugin.go index a7c655f..5a6534d 100644 --- a/x/babylon/keeper/handler_plugin.go +++ b/x/babylon/keeper/handler_plugin.go @@ -55,7 +55,7 @@ func (h CustomMsgHandler) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddre if err := json.Unmarshal(msg.Custom, &customMsg); err != nil { return nil, nil, nil, sdkerrors.ErrJSONUnmarshal.Wrap("custom message") } - if customMsg.Test == nil { + if customMsg.MintRewards == nil { // not our message type return nil, nil, nil, wasmtypes.ErrUnknownMsg } @@ -64,10 +64,10 @@ func (h CustomMsgHandler) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddre return nil, nil, nil, sdkerrors.ErrUnauthorized.Wrapf("contract has no permission for Babylon operations") } - return h.handleTestMsg(ctx, contractAddr, customMsg.Test) + return h.handleMintRewardsMsg(ctx, contractAddr, customMsg.MintRewards) } -func (h CustomMsgHandler) handleTestMsg(ctx sdk.Context, actor sdk.AccAddress, testMsg *contract.TestMsg) ([]sdk.Event, [][]byte, [][]*codectypes.Any, error) { +func (h CustomMsgHandler) handleMintRewardsMsg(ctx sdk.Context, actor sdk.AccAddress, mintRewardsMsg *contract.MintRewardsMsg) ([]sdk.Event, [][]byte, [][]*codectypes.Any, error) { return []sdk.Event{}, nil, nil, nil }