Skip to content

Commit

Permalink
wip: update message signer
Browse files Browse the repository at this point in the history
  • Loading branch information
boodyvo committed Oct 31, 2024
1 parent 59969b9 commit 9e57cd0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
33 changes: 21 additions & 12 deletions x/evm/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func (msg MsgEthereumTx) Type() string { return TypeMsgEthereumTx }
// ValidateBasic implements the sdk.Msg interface. It performs basic validation
// checks of a Transaction. If returns an error if validation fails.
func (msg MsgEthereumTx) ValidateBasic() error {
fmt.Println("MsgEthereumTx.ValidateBasic")
if msg.From != "" {
if err := types.ValidateAddress(msg.From); err != nil {
return errorsmod.Wrap(err, "invalid from address")
Expand Down Expand Up @@ -286,18 +287,25 @@ func GetSigners(msg protov2.Message) ([][]byte, error) {
fmt.Println("Eth message data", msg.ProtoReflect().Descriptor().Fields().ByName("data"))
fmt.Println("Eth message value of ", protoreflect.ValueOfMessage(msg.ProtoReflect()))

//data, err := UnpackTxData(data.Bytes())
//if err != nil {
// return nil, err
//}
//
//sender, err := msg.GetSender(data.GetChainID())
//if err != nil {
// return nil, err
//}
//
//signer := sdk.AccAddress(sender.Bytes())
//return [][]byte{signer}, nil
value := protoreflect.ValueOfMessage(msg.ProtoReflect())
var msgEthereumTx *MsgEthereumTx
err := msgEthereumTx.Unmarshal(value.Bytes())
if err != nil {
return nil, err
}

data, err := UnpackTxData(msgEthereumTx.Data)
if err != nil {
return nil, err
}

sender, err := msgEthereumTx.GetSender(data.GetChainID())
if err != nil {
return nil, err
}

signer := sdk.AccAddress(sender.Bytes())
return [][]byte{signer}, nil

Check warning on line 308 in x/evm/types/msg.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

unreachable-code: unreachable code after this statement (revive)

return nil, nil
}
Expand Down Expand Up @@ -465,6 +473,7 @@ func (m MsgUpdateParams) GetSigners() []sdk.AccAddress {

// ValidateBasic does a sanity check of the provided data
func (m *MsgUpdateParams) ValidateBasic() error {
fmt.Println("MsgUpdateParams.ValidateBasic")
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
return errorsmod.Wrap(err, "invalid authority address")
}
Expand Down
2 changes: 2 additions & 0 deletions x/feemarket/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
errorsmod "cosmossdk.io/errors"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand All @@ -15,6 +16,7 @@ func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress {

// ValidateBasic does a sanity check of the provided data
func (m *MsgUpdateParams) ValidateBasic() error {
fmt.Println("MsgUpdateParams.ValidateBasic")
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
return errorsmod.Wrap(err, "invalid authority address")
}
Expand Down

0 comments on commit 9e57cd0

Please sign in to comment.