remove duplicate query in receipts (#273)

* logs tests

* updates

* String()

* remove extra query, add comments

* test fixes

* lint

* lint
This commit is contained in:
Federico Kunze
2020-05-02 21:56:18 -04:00
committed by GitHub
parent 86cd39defb
commit 26d4e968e0
7 changed files with 234 additions and 59 deletions
+20 -23
View File
@@ -301,7 +301,7 @@ func (e *PublicEthAPI) SendTransaction(args params.SendTxArgs) (common.Hash, err
return common.Hash{}, err
}
// Broadcast transaction
// Broadcast transaction in sync mode (default)
res, err := e.cliCtx.BroadcastTx(txBytes)
// If error is encountered on the node, the broadcast will not return an error
if err != nil {
@@ -698,14 +698,6 @@ func (e *PublicEthAPI) GetTransactionReceipt(hash common.Hash) (map[string]inter
status = hexutil.Uint(0)
}
res, _, err := e.cliCtx.Query(fmt.Sprintf("custom/%s/%s/%s", types.ModuleName, evm.QueryTxLogs, hash.Hex()))
if err != nil {
return nil, err
}
var logs types.QueryETHLogs
e.cliCtx.Codec.MustUnmarshalJSON(res, &logs)
txData := tx.TxResult.GetData()
data, err := types.DecodeResultData(txData)
@@ -714,22 +706,27 @@ func (e *PublicEthAPI) GetTransactionReceipt(hash common.Hash) (map[string]inter
}
receipt := map[string]interface{}{
"blockHash": blockHash,
"blockNumber": hexutil.Uint64(tx.Height),
"transactionHash": hash,
"transactionIndex": hexutil.Uint64(tx.Index),
"from": from,
"to": ethTx.To(),
"gasUsed": hexutil.Uint64(tx.TxResult.GasUsed),
"cumulativeGasUsed": nil, // ignore until needed
"contractAddress": nil,
"logs": logs.Logs,
"logsBloom": data.Bloom,
// Consensus fields: These fields are defined by the Yellow Paper
"status": status,
}
"cumulativeGasUsed": nil, // ignore until needed
"logsBloom": data.Bloom,
"logs": data.Logs,
if data.Address != (common.Address{}) {
receipt["contractAddress"] = data.Address
// Implementation fields: These fields are added by geth when processing a transaction.
// They are stored in the chain database.
"transactionHash": hash,
"contractAddress": data.ContractAddress,
"gasUsed": hexutil.Uint64(tx.TxResult.GasUsed),
// Inclusion information: These fields provide information about the inclusion of the
// transaction corresponding to this receipt.
"blockHash": blockHash,
"blockNumber": hexutil.Uint64(tx.Height),
"transactionIndex": hexutil.Uint64(tx.Index),
// sender and receiver (contract or EOA) addreses
"from": from,
"to": ethTx.To(),
}
return receipt, nil