Skip to content

Commit

Permalink
Merge PR: make sure GetFrom returns sender address (#1722)
Browse files Browse the repository at this point in the history
Co-authored-by: xiangjianmeng <[email protected]>
  • Loading branch information
yann-sjtu and xiangjianmeng authored Mar 23, 2022
1 parent 5398649 commit 17998a9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion x/evm/types/msg_evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ func (tx *MsgEthereumTx) SetFrom(addr string) {
tx.From = addr
}

// GetFrom returns sender address of MsgEthereumTx if signature is valid, or returns "".
func (tx *MsgEthereumTx) GetFrom() string {
// firstVerifySig will do nothing if tx.Base.GetFrom != "".
_ = tx.firstVerifySig(tx.ChainID())
return tx.BaseTx.GetFrom()
}

func (msg *MsgEthereumTx) GetNonce() uint64 {
return msg.Data.AccountNonce
}
Expand Down Expand Up @@ -251,7 +258,7 @@ func (msg *MsgEthereumTx) Sign(chainID *big.Int, priv *ecdsa.PrivateKey) error {
}

func (msg *MsgEthereumTx) firstVerifySig(chainID *big.Int) error {
if msg.GetFrom() != "" {
if msg.BaseTx.GetFrom() != "" {
return nil
}

Expand Down

0 comments on commit 17998a9

Please sign in to comment.