Skip to content

Commit

Permalink
got rid of Get on Msg interface
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnya97 authored and cwgoes committed Apr 30, 2018
1 parent b79ab07 commit af0e71f
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 74 deletions.
10 changes: 4 additions & 6 deletions examples/democoin/x/cool/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ func NewMsgSetTrend(sender sdk.Address, cool string) MsgSetTrend {
var _ sdk.Msg = MsgSetTrend{}

// nolint
func (msg MsgSetTrend) Type() string { return "cool" }
func (msg MsgSetTrend) Get(key interface{}) (value interface{}) { return nil }
func (msg MsgSetTrend) GetSigners() []sdk.Address { return []sdk.Address{msg.Sender} }
func (msg MsgSetTrend) Type() string { return "cool" }
func (msg MsgSetTrend) GetSigners() []sdk.Address { return []sdk.Address{msg.Sender} }
func (msg MsgSetTrend) String() string {
return fmt.Sprintf("MsgSetTrend{Sender: %v, Cool: %v}", msg.Sender, msg.Cool)
}
Expand Down Expand Up @@ -83,9 +82,8 @@ func NewMsgQuiz(sender sdk.Address, coolerthancool string) MsgQuiz {
var _ sdk.Msg = MsgQuiz{}

// nolint
func (msg MsgQuiz) Type() string { return "cool" }
func (msg MsgQuiz) Get(key interface{}) (value interface{}) { return nil }
func (msg MsgQuiz) GetSigners() []sdk.Address { return []sdk.Address{msg.Sender} }
func (msg MsgQuiz) Type() string { return "cool" }
func (msg MsgQuiz) GetSigners() []sdk.Address { return []sdk.Address{msg.Sender} }
func (msg MsgQuiz) String() string {
return fmt.Sprintf("MsgQuiz{Sender: %v, CoolAnswer: %v}", msg.Sender, msg.CoolAnswer)
}
Expand Down
5 changes: 2 additions & 3 deletions examples/democoin/x/pow/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ func NewMsgMine(sender sdk.Address, difficulty uint64, count uint64, nonce uint6
}

// nolint
func (msg MsgMine) Type() string { return "pow" }
func (msg MsgMine) Get(key interface{}) (value interface{}) { return nil }
func (msg MsgMine) GetSigners() []sdk.Address { return []sdk.Address{msg.Sender} }
func (msg MsgMine) Type() string { return "pow" }
func (msg MsgMine) GetSigners() []sdk.Address { return []sdk.Address{msg.Sender} }
func (msg MsgMine) String() string {
return fmt.Sprintf("MsgMine{Sender: %v, Difficulty: %d, Count: %d, Nonce: %d, Proof: %s}", msg.Sender, msg.Difficulty, msg.Count, msg.Nonce, msg.Proof)
}
Expand Down
7 changes: 0 additions & 7 deletions examples/democoin/x/pow/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ func TestMsgMineString(t *testing.T) {
assert.Equal(t, res, "MsgMine{Sender: 73656E646572, Difficulty: 0, Count: 0, Nonce: 0, Proof: abc}")
}

func TestMsgMineGet(t *testing.T) {
addr := sdk.Address([]byte("sender"))
msg := MsgMine{addr, 0, 0, 0, []byte("")}
res := msg.Get(nil)
assert.Nil(t, res)
}

func TestMsgMineGetSignBytes(t *testing.T) {
addr := sdk.Address([]byte("sender"))
msg := MsgMine{addr, 1, 1, 1, []byte("abc")}
Expand Down
7 changes: 3 additions & 4 deletions examples/democoin/x/simplestake/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ func NewMsgUnbond(addr sdk.Address) MsgUnbond {
}

//nolint
func (msg MsgUnbond) Type() string { return moduleName } //TODO update "stake/declarecandidacy"
func (msg MsgUnbond) Get(key interface{}) (value interface{}) { return nil }
func (msg MsgUnbond) GetSigners() []sdk.Address { return []sdk.Address{msg.Address} }
func (msg MsgUnbond) ValidateBasic() sdk.Error { return nil }
func (msg MsgUnbond) Type() string { return moduleName } //TODO update "stake/declarecandidacy"
func (msg MsgUnbond) GetSigners() []sdk.Address { return []sdk.Address{msg.Address} }
func (msg MsgUnbond) ValidateBasic() sdk.Error { return nil }

// get unbond message sign bytes
func (msg MsgUnbond) GetSignBytes() []byte {
Expand Down
3 changes: 0 additions & 3 deletions types/tx_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ type Msg interface {
// Must be alphanumeric or empty.
Type() string

// Get some property of the Msg.
Get(key interface{}) (value interface{})

// Get the canonical byte representation of the Msg.
GetSignBytes() []byte

Expand Down
1 change: 0 additions & 1 deletion x/auth/baseaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func NewBaseAccountWithAddress(addr sdk.Address) BaseAccount {
}
}

// Implements sdk.Account.
func (acc BaseAccount) Get(key interface{}) (value interface{}, err error) {
panic("not implemented yet")
}
Expand Down
10 changes: 0 additions & 10 deletions x/bank/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ func (msg MsgSend) ValidateBasic() sdk.Error {
return nil
}

// Implements Msg.
func (msg MsgSend) Get(key interface{}) (value interface{}) {
return nil
}

// Implements Msg.
func (msg MsgSend) GetSignBytes() []byte {
b, err := json.Marshal(msg) // XXX: ensure some canonical form
Expand Down Expand Up @@ -107,11 +102,6 @@ func (msg MsgIssue) ValidateBasic() sdk.Error {
return nil
}

// Implements Msg.
func (msg MsgIssue) Get(key interface{}) (value interface{}) {
return nil
}

// Implements Msg.
func (msg MsgIssue) GetSignBytes() []byte {
b, err := json.Marshal(msg) // XXX: ensure some canonical form
Expand Down
23 changes: 0 additions & 23 deletions x/bank/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,6 @@ func TestMsgSendValidation(t *testing.T) {
}
}

func TestMsgSendGet(t *testing.T) {
addr1 := sdk.Address([]byte("input"))
addr2 := sdk.Address([]byte("output"))
coins := sdk.Coins{{"atom", 10}}
var msg = MsgSend{
Inputs: []Input{NewInput(addr1, coins)},
Outputs: []Output{NewOutput(addr2, coins)},
}
res := msg.Get(nil)
assert.Nil(t, res)
}

func TestMsgSendGetSignBytes(t *testing.T) {
addr1 := sdk.Address([]byte("input"))
addr2 := sdk.Address([]byte("output"))
Expand Down Expand Up @@ -259,17 +247,6 @@ func TestMsgIssueValidation(t *testing.T) {
// TODO
}

func TestMsgIssueGet(t *testing.T) {
addr := sdk.Address([]byte("loan-from-bank"))
coins := sdk.Coins{{"atom", 10}}
var msg = MsgIssue{
Banker: sdk.Address([]byte("input")),
Outputs: []Output{NewOutput(addr, coins)},
}
res := msg.Get(nil)
assert.Nil(t, res)
}

func TestMsgIssueGetSignBytes(t *testing.T) {
addr := sdk.Address([]byte("loan-from-bank"))
coins := sdk.Coins{{"atom", 10}}
Expand Down
8 changes: 3 additions & 5 deletions x/ibc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ type IBCTransferMsg struct {
}

// nolint
func (msg IBCTransferMsg) Type() string { return "ibc" }
func (msg IBCTransferMsg) Get(key interface{}) interface{} { return nil }
func (msg IBCTransferMsg) Type() string { return "ibc" }

// x/bank/tx.go MsgSend.GetSigners()
func (msg IBCTransferMsg) GetSigners() []sdk.Address { return []sdk.Address{msg.SrcAddr} }
Expand Down Expand Up @@ -87,9 +86,8 @@ type IBCReceiveMsg struct {
}

// nolint
func (msg IBCReceiveMsg) Type() string { return "ibc" }
func (msg IBCReceiveMsg) Get(key interface{}) interface{} { return nil }
func (msg IBCReceiveMsg) ValidateBasic() sdk.Error { return msg.IBCPacket.ValidateBasic() }
func (msg IBCReceiveMsg) Type() string { return "ibc" }
func (msg IBCReceiveMsg) ValidateBasic() sdk.Error { return msg.IBCPacket.ValidateBasic() }

// x/bank/tx.go MsgSend.GetSigners()
func (msg IBCReceiveMsg) GetSigners() []sdk.Address { return []sdk.Address{msg.Relayer} }
Expand Down
20 changes: 8 additions & 12 deletions x/stake/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ func NewMsgDeclareCandidacy(candidateAddr sdk.Address, pubkey crypto.PubKey,
}

//nolint
func (msg MsgDeclareCandidacy) Type() string { return MsgType } //TODO update "stake/declarecandidacy"
func (msg MsgDeclareCandidacy) Get(key interface{}) (value interface{}) { return nil }
func (msg MsgDeclareCandidacy) GetSigners() []sdk.Address { return []sdk.Address{msg.CandidateAddr} }
func (msg MsgDeclareCandidacy) Type() string { return MsgType } //TODO update "stake/declarecandidacy"
func (msg MsgDeclareCandidacy) GetSigners() []sdk.Address { return []sdk.Address{msg.CandidateAddr} }

// get the bytes for the message signer to sign on
func (msg MsgDeclareCandidacy) GetSignBytes() []byte {
Expand Down Expand Up @@ -87,9 +86,8 @@ func NewMsgEditCandidacy(candidateAddr sdk.Address, description Description) Msg
}

//nolint
func (msg MsgEditCandidacy) Type() string { return MsgType } //TODO update "stake/msgeditcandidacy"
func (msg MsgEditCandidacy) Get(key interface{}) (value interface{}) { return nil }
func (msg MsgEditCandidacy) GetSigners() []sdk.Address { return []sdk.Address{msg.CandidateAddr} }
func (msg MsgEditCandidacy) Type() string { return MsgType } //TODO update "stake/msgeditcandidacy"
func (msg MsgEditCandidacy) GetSigners() []sdk.Address { return []sdk.Address{msg.CandidateAddr} }

// get the bytes for the message signer to sign on
func (msg MsgEditCandidacy) GetSignBytes() []byte {
Expand Down Expand Up @@ -130,9 +128,8 @@ func NewMsgDelegate(delegatorAddr, candidateAddr sdk.Address, bond sdk.Coin) Msg
}

//nolint
func (msg MsgDelegate) Type() string { return MsgType } //TODO update "stake/msgeditcandidacy"
func (msg MsgDelegate) Get(key interface{}) (value interface{}) { return nil }
func (msg MsgDelegate) GetSigners() []sdk.Address { return []sdk.Address{msg.DelegatorAddr} }
func (msg MsgDelegate) Type() string { return MsgType } //TODO update "stake/msgeditcandidacy"
func (msg MsgDelegate) GetSigners() []sdk.Address { return []sdk.Address{msg.DelegatorAddr} }

// get the bytes for the message signer to sign on
func (msg MsgDelegate) GetSignBytes() []byte {
Expand Down Expand Up @@ -178,9 +175,8 @@ func NewMsgUnbond(delegatorAddr, candidateAddr sdk.Address, shares string) MsgUn
}

//nolint
func (msg MsgUnbond) Type() string { return MsgType } //TODO update "stake/msgeditcandidacy"
func (msg MsgUnbond) Get(key interface{}) (value interface{}) { return nil }
func (msg MsgUnbond) GetSigners() []sdk.Address { return []sdk.Address{msg.DelegatorAddr} }
func (msg MsgUnbond) Type() string { return MsgType } //TODO update "stake/msgeditcandidacy"
func (msg MsgUnbond) GetSigners() []sdk.Address { return []sdk.Address{msg.DelegatorAddr} }

// get the bytes for the message signer to sign on
func (msg MsgUnbond) GetSignBytes() []byte {
Expand Down

0 comments on commit af0e71f

Please sign in to comment.