got rid of Get on Msg interface

This commit is contained in:
Sunny Aggarwal
2018-05-01 00:15:15 +02:00
committed by Christopher Goes
parent b79ab072e7
commit af0e71fa0d
10 changed files with 20 additions and 74 deletions
+4 -6
View File
@@ -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)
}
@@ -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)
}
+2 -3
View File
@@ -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)
}
-7
View File
@@ -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")}
+3 -4
View File
@@ -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 {
-3
View File
@@ -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
-1
View File
@@ -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")
}
-10
View File
@@ -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
@@ -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
-23
View File
@@ -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"))
@@ -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}}
+3 -5
View File
@@ -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} }
@@ -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} }
+8 -12
View File
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {