Use service Msgs in CLI tx commands (#8512)
* Use service Msgs in CLI tx commands * Update comment * Gracefully support amino signing * CLI to use svc msg * Fix lint * Use fq method name in events * Update tests * Fix quering events * Add docs * Fix test build * Fix events * Fix search for events * Handle old andd new event quering * Use merge events * Better encCfg * Add page in search * Fix tests * Update test and comments * Update x/auth/legacy/legacytx/stdsign.go Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com> * Fix conflict for weighted vote * Make CopyTx actually run * Fix CopyTx * Fix test * Add changelog entry * Remove useless code * Add msgs tests * Remove testing proto Msg via CLI * Fix lint * Fix test * Implement GetSignBytes on ServiceMsg * Fix %T Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
atheeshp
mergify[bot]
parent
b4820fe491
commit
73e38e4009
+14
-2
@@ -1,6 +1,8 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -18,7 +20,7 @@ type MsgRequest interface {
|
||||
}
|
||||
|
||||
// ServiceMsg is the struct into which an Any whose typeUrl matches a service
|
||||
// method format (ex. `/cosmos.gov.Msg/SubmitProposal`) unpacks.
|
||||
// method format (ex. `/cosmos.gov.v1beta1.Msg/SubmitProposal`) unpacks.
|
||||
type ServiceMsg struct {
|
||||
// MethodName is the fully-qualified service method name.
|
||||
MethodName string
|
||||
@@ -44,7 +46,17 @@ func (msg ServiceMsg) ValidateBasic() error {
|
||||
|
||||
// GetSignBytes implements Msg.GetSignBytes method.
|
||||
func (msg ServiceMsg) GetSignBytes() []byte {
|
||||
panic("ServiceMsg does not have a GetSignBytes method")
|
||||
// Here, we're gracefully supporting Amino JSON for service
|
||||
// Msgs.
|
||||
// ref: https://github.com/cosmos/cosmos-sdk/issues/8346
|
||||
// If `msg` is a service Msg, then we cast its `Request` to a sdk.Msg
|
||||
// and call GetSignBytes on the `Request`.
|
||||
msgRequest, ok := msg.Request.(Msg)
|
||||
if !ok {
|
||||
panic(fmt.Errorf("cannot convert ServiceMsg request to sdk.Msg, got %T", msgRequest))
|
||||
}
|
||||
|
||||
return msgRequest.GetSignBytes()
|
||||
}
|
||||
|
||||
// GetSigners implements Msg.GetSigners method.
|
||||
|
||||
Reference in New Issue
Block a user