Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
rpc: extract msg from cosmos tx (#163)
Browse files Browse the repository at this point in the history
Closes #162
  • Loading branch information
yihuang authored Jun 22, 2021
1 parent b5ea5bf commit 95bd756
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions ethereum/rpc/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,11 @@ func (e *PublicEthAPI) GetTransactionByHash(hash common.Hash) (*rpctypes.RPCTran
return nil, fmt.Errorf("failed to decode tx: %w", err)
}

msg, ok := tx.(*evmtypes.MsgEthereumTx)
if len(tx.GetMsgs()) != 1 {
e.logger.Debugln("invalid tx")
return nil, fmt.Errorf("invalid tx type: %T", tx)
}
msg, ok := tx.GetMsgs()[0].(*evmtypes.MsgEthereumTx)
if !ok {
e.logger.Debugln("invalid tx")
return nil, fmt.Errorf("invalid tx type: %T", tx)
Expand Down Expand Up @@ -763,7 +767,11 @@ func (e *PublicEthAPI) GetTransactionByBlockNumberAndIndex(blockNum rpctypes.Blo
return nil, fmt.Errorf("failed to decode tx: %w", err)
}

msg, ok := tx.(*evmtypes.MsgEthereumTx)
if len(tx.GetMsgs()) != 1 {
e.logger.Debugln("invalid tx")
return nil, fmt.Errorf("invalid tx type: %T", tx)
}
msg, ok := tx.GetMsgs()[0].(*evmtypes.MsgEthereumTx)
if !ok {
e.logger.Debugln("invalid tx")
return nil, fmt.Errorf("invalid tx type: %T", tx)
Expand Down Expand Up @@ -805,7 +813,11 @@ func (e *PublicEthAPI) GetTransactionReceipt(hash common.Hash) (map[string]inter
return nil, fmt.Errorf("failed to decode tx: %w", err)
}

msg, ok := tx.(*evmtypes.MsgEthereumTx)
if len(tx.GetMsgs()) != 1 {
e.logger.Debugln("invalid tx")
return nil, fmt.Errorf("invalid tx type: %T", tx)
}
msg, ok := tx.GetMsgs()[0].(*evmtypes.MsgEthereumTx)
if !ok {
e.logger.Debugln("invalid tx")
return nil, fmt.Errorf("invalid tx type: %T", tx)
Expand Down

0 comments on commit 95bd756

Please sign in to comment.