Skip to content

Commit

Permalink
Add transactionhash to receipt logs
Browse files Browse the repository at this point in the history
Signed-off-by: Nana-EC <nana@swirldslabs.com>
  • Loading branch information
Nana-EC committed Jun 17, 2022
1 parent 75625e1 commit 30d12f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 11 additions & 4 deletions packages/relay/src/lib/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,24 +698,31 @@ export class EthImpl implements Eth {
receiptResponse.created_contract_ids.length > 0
? EthImpl.prepend0x(ContractId.fromString(receiptResponse.created_contract_ids[0]).toSolidityAddress())
: undefined;
const answer = {


// support stricter go-eth client which requires the transaction hash property on logs
const logs = receiptResponse.logs.map(log => ({ ...log, transactionHash: receiptResponse.hash}));

const receipt = {
blockHash: receiptResponse.block_hash.substring(0, 66),
blockNumber: EthImpl.numberTo0x(receiptResponse.block_number),
from: receiptResponse.from,
to: receiptResponse.to,
cumulativeGasUsed: EthImpl.numberTo0x(receiptResponse.block_gas_used),
gasUsed: EthImpl.numberTo0x(receiptResponse.gas_used),
contractAddress: createdContract,
logs: receiptResponse.logs,
logs: logs,
logsBloom: receiptResponse.bloom,
transactionHash: receiptResponse.hash,
transactionIndex: EthImpl.numberTo0x(receiptResponse.transaction_index),
effectiveGasPrice: EthImpl.numberTo0x(Number.parseInt(effectiveGas) * 10_000_000_000),
root: receiptResponse.root,
status: receiptResponse.status,
};
this.logger.trace(`receipt for ${hash} found in block ${answer.blockNumber}`);
return answer;


this.logger.trace(`receipt for ${hash} found in block ${receipt.blockNumber}`);
return receipt;
}
}

Expand Down
5 changes: 3 additions & 2 deletions packages/relay/tests/lib/eth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,8 @@ describe('Eth', async function () {
"contract_id": "0.0.5001",
"data": "0x0123",
"index": 0,
"topics": ["0x97c1fc0a6ed5551bc831571325e9bdb365d06803100dc20648640ba24ce69750"]
"topics": ["0x97c1fc0a6ed5551bc831571325e9bdb365d06803100dc20648640ba24ce69750"],
"transactionHash": "0x4a563af33c4871b51a8b108aa2fe1dd5280a30dfb7236170ae5e5e7957eb6392"
}],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": "0x1",
Expand Down Expand Up @@ -1224,7 +1225,7 @@ describe('Eth', async function () {
expect(receipt).to.be.null;
});

it('executes correctly', async function () {
it('valid receipt on match', async function () {
// mirror node request mocks
mock.onGet(`contracts/results/${defaultTxHash}`).reply(200, defaultDetailedContractResultByHash);
const receipt = await ethImpl.getTransactionReceipt(defaultTxHash);
Expand Down

0 comments on commit 30d12f6

Please # to comment.