Skip to content

Commit

Permalink
refactor: get signers from msg v2
Browse files Browse the repository at this point in the history
  • Loading branch information
dudong2 committed Jan 15, 2024
1 parent d2d56aa commit a99c931
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
25 changes: 17 additions & 8 deletions x/evm/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func GetSignersFromMsgEthereumTxV2(msg protov2.Message) ([][]byte, error) {
func GetMsgEthereumTxFromMsgV2(msg protov2.Message) (MsgEthereumTx, error) {
msgv2, ok := msg.(*evmapi.MsgEthereumTx)
if !ok {
return MsgEthereumTx{}, nil
return MsgEthereumTx{}, fmt.Errorf("invalid x/evm/MsgEthereumTx msg v2: %v", msg)
}

var dataAny *codectypes.Any
Expand Down Expand Up @@ -520,13 +520,9 @@ func GetMsgEthereumTxFromMsgV2(msg protov2.Message) (MsgEthereumTx, error) {
}

func GetSignersFromMsgUpdateParamsV2(msg protov2.Message) ([][]byte, error) {
msgv2, ok := msg.(*evmapi.MsgUpdateParams)
if !ok {
return nil, nil
}

msgv1 := MsgUpdateParams{
Authority: msgv2.Authority,
msgv1, err := GetMsgUpdateParamsFromMsgV2(msg)
if err != nil {
return nil, err
}

signers := [][]byte{}
Expand All @@ -536,3 +532,16 @@ func GetSignersFromMsgUpdateParamsV2(msg protov2.Message) ([][]byte, error) {

return signers, nil
}

func GetMsgUpdateParamsFromMsgV2(msg protov2.Message) (MsgUpdateParams, error) {
msgv2, ok := msg.(*evmapi.MsgUpdateParams)
if !ok {
return MsgUpdateParams{}, fmt.Errorf("invalid x/evm/MsgUpdateParams msg v2: %v", msg)
}

msgv1 := MsgUpdateParams{
Authority: msgv2.Authority,
}

return msgv1, nil
}
25 changes: 18 additions & 7 deletions x/feemarket/types/msg.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package types

import (
"fmt"

protov2 "google.golang.org/protobuf/proto"

errorsmod "cosmossdk.io/errors"
Expand Down Expand Up @@ -31,13 +33,9 @@ func (m MsgUpdateParams) GetSignBytes() []byte {
}

func GetSignersFromMsgUpdateParamsV2(msg protov2.Message) ([][]byte, error) {
msgv2, ok := msg.(*feemarketapi.MsgUpdateParams)
if !ok {
return nil, nil
}

msgv1 := MsgUpdateParams{
Authority: msgv2.Authority,
msgv1, err := GetMsgUpdateParamsFromMsgV2(msg)
if err != nil {
return nil, err
}

signers := [][]byte{}
Expand All @@ -47,3 +45,16 @@ func GetSignersFromMsgUpdateParamsV2(msg protov2.Message) ([][]byte, error) {

return signers, nil
}

func GetMsgUpdateParamsFromMsgV2(msg protov2.Message) (MsgUpdateParams, error) {
msgv2, ok := msg.(*feemarketapi.MsgUpdateParams)
if !ok {
return MsgUpdateParams{}, fmt.Errorf("invalid x/feemarket/MsgUpdateParams msg v2: %v", msg)
}

msgv1 := MsgUpdateParams{
Authority: msgv2.Authority,
}

return msgv1, nil
}

0 comments on commit a99c931

Please sign in to comment.