rpc: extract msg from cosmos tx (#163)

Closes #162
This commit is contained in:
yihuang 2021-06-22 15:49:25 +08:00 committed by GitHub
parent b5ea5bf6b9
commit 95bd7563d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
@ -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)
@ -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)