diff --git a/PENDING.md b/PENDING.md index a8f278ebb469..4720ec774c1a 100644 --- a/PENDING.md +++ b/PENDING.md @@ -80,6 +80,7 @@ BUG FIXES * SDK - \#2733 [x/gov, x/mock/simulation] Fix governance simulation, update x/gov import/export + - \#2854 [x/bank] Remove unused bank.MsgIssue, prevent possible panic * Tendermint * [\#2797](https://github.com/tendermint/tendermint/pull/2797) AddressBook requires addresses to have IDs; Do not crap out immediately after sending pex addrs in seed mode diff --git a/x/bank/codec.go b/x/bank/codec.go index bcc2cbddaa65..2195e4853a0e 100644 --- a/x/bank/codec.go +++ b/x/bank/codec.go @@ -7,7 +7,6 @@ import ( // Register concrete types on codec codec func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgSend{}, "cosmos-sdk/Send", nil) - cdc.RegisterConcrete(MsgIssue{}, "cosmos-sdk/Issue", nil) } var msgCdc = codec.New() diff --git a/x/bank/handler.go b/x/bank/handler.go index e02043d7b4f1..ea3ee4398c43 100644 --- a/x/bank/handler.go +++ b/x/bank/handler.go @@ -10,8 +10,6 @@ func NewHandler(k Keeper) sdk.Handler { switch msg := msg.(type) { case MsgSend: return handleMsgSend(ctx, k, msg) - case MsgIssue: - return handleMsgIssue(ctx, k, msg) default: errMsg := "Unrecognized bank Msg type: %s" + msg.Type() return sdk.ErrUnknownRequest(errMsg).Result() @@ -32,8 +30,3 @@ func handleMsgSend(ctx sdk.Context, k Keeper, msg MsgSend) sdk.Result { Tags: tags, } } - -// Handle MsgIssue. -func handleMsgIssue(ctx sdk.Context, k Keeper, msg MsgIssue) sdk.Result { - panic("not implemented yet") -} diff --git a/x/bank/msgs.go b/x/bank/msgs.go index a1c346a88d80..1af7acfe73dd 100644 --- a/x/bank/msgs.go +++ b/x/bank/msgs.go @@ -86,65 +86,6 @@ func (msg MsgSend) GetSigners() []sdk.AccAddress { return addrs } -//---------------------------------------- -// MsgIssue - -// MsgIssue - high level transaction of the coin module -type MsgIssue struct { - Banker sdk.AccAddress `json:"banker"` - Outputs []Output `json:"outputs"` -} - -var _ sdk.Msg = MsgIssue{} - -// NewMsgIssue - construct arbitrary multi-in, multi-out send msg. -func NewMsgIssue(banker sdk.AccAddress, out []Output) MsgIssue { - return MsgIssue{Banker: banker, Outputs: out} -} - -// Implements Msg. -// nolint -func (msg MsgIssue) Route() string { return "bank" } // TODO: "bank/issue" -func (msg MsgIssue) Type() string { return "issue" } - -// Implements Msg. -func (msg MsgIssue) ValidateBasic() sdk.Error { - // XXX - if len(msg.Outputs) == 0 { - return ErrNoOutputs(DefaultCodespace).TraceSDK("") - } - for _, out := range msg.Outputs { - if err := out.ValidateBasic(); err != nil { - return err.TraceSDK("") - } - } - return nil -} - -// Implements Msg. -func (msg MsgIssue) GetSignBytes() []byte { - var outputs []json.RawMessage - for _, output := range msg.Outputs { - outputs = append(outputs, output.GetSignBytes()) - } - b, err := msgCdc.MarshalJSON(struct { - Banker sdk.AccAddress `json:"banker"` - Outputs []json.RawMessage `json:"outputs"` - }{ - Banker: msg.Banker, - Outputs: outputs, - }) - if err != nil { - panic(err) - } - return sdk.MustSortJSON(b) -} - -// Implements Msg. -func (msg MsgIssue) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{msg.Banker} -} - //---------------------------------------- // Input diff --git a/x/bank/msgs_test.go b/x/bank/msgs_test.go index 157cc9b5b95b..14e9a4c7094a 100644 --- a/x/bank/msgs_test.go +++ b/x/bank/msgs_test.go @@ -223,48 +223,3 @@ func TestMsgSendSigners(t *testing.T) { require.Equal(t, signers, tx.Signers()) } */ - -// ---------------------------------------- -// MsgIssue Tests - -func TestNewMsgIssue(t *testing.T) { - // TODO -} - -func TestMsgIssueRoute(t *testing.T) { - // Construct an MsgIssue - addr := sdk.AccAddress([]byte("loan-from-bank")) - coins := sdk.Coins{sdk.NewInt64Coin("atom", 10)} - var msg = MsgIssue{ - Banker: sdk.AccAddress([]byte("input")), - Outputs: []Output{NewOutput(addr, coins)}, - } - - // TODO some failures for bad result - require.Equal(t, msg.Route(), "bank") -} - -func TestMsgIssueValidation(t *testing.T) { - // TODO -} - -func TestMsgIssueGetSignBytes(t *testing.T) { - addr := sdk.AccAddress([]byte("loan-from-bank")) - coins := sdk.Coins{sdk.NewInt64Coin("atom", 10)} - var msg = MsgIssue{ - Banker: sdk.AccAddress([]byte("input")), - Outputs: []Output{NewOutput(addr, coins)}, - } - res := msg.GetSignBytes() - - expected := `{"banker":"cosmos1d9h8qat57ljhcm","outputs":[{"address":"cosmos1d3hkzm3dveex7mfdvfsku6cjngpcj","coins":[{"amount":"10","denom":"atom"}]}]}` - require.Equal(t, expected, string(res)) -} - -func TestMsgIssueGetSigners(t *testing.T) { - var msg = MsgIssue{ - Banker: sdk.AccAddress([]byte("onlyone")), - } - res := msg.GetSigners() - require.Equal(t, fmt.Sprintf("%v", res), "[6F6E6C796F6E65]") -} diff --git a/x/ibc/ibc_test.go b/x/ibc/ibc_test.go index 6cd89fded4ea..94c3c7a2ecb2 100644 --- a/x/ibc/ibc_test.go +++ b/x/ibc/ibc_test.go @@ -44,7 +44,6 @@ func makeCodec() *codec.Codec { // Register Msgs cdc.RegisterInterface((*sdk.Msg)(nil), nil) cdc.RegisterConcrete(bank.MsgSend{}, "test/ibc/Send", nil) - cdc.RegisterConcrete(bank.MsgIssue{}, "test/ibc/Issue", nil) cdc.RegisterConcrete(IBCTransferMsg{}, "test/ibc/IBCTransferMsg", nil) cdc.RegisterConcrete(IBCReceiveMsg{}, "test/ibc/IBCReceiveMsg", nil) diff --git a/x/stake/keeper/test_common.go b/x/stake/keeper/test_common.go index af7e688f3215..65445cbb1fa3 100644 --- a/x/stake/keeper/test_common.go +++ b/x/stake/keeper/test_common.go @@ -60,7 +60,6 @@ func MakeTestCodec() *codec.Codec { // Register Msgs cdc.RegisterInterface((*sdk.Msg)(nil), nil) cdc.RegisterConcrete(bank.MsgSend{}, "test/stake/Send", nil) - cdc.RegisterConcrete(bank.MsgIssue{}, "test/stake/Issue", nil) cdc.RegisterConcrete(types.MsgCreateValidator{}, "test/stake/CreateValidator", nil) cdc.RegisterConcrete(types.MsgEditValidator{}, "test/stake/EditValidator", nil) cdc.RegisterConcrete(types.MsgBeginUnbonding{}, "test/stake/BeginUnbonding", nil)