Skip to content

Commit 8479372

Browse files
authored
Add transactionhash to receipt logs (#235)
go-eth client seems to be stricter than other clients and requires the transaction hash in logs - Add `transactionHash` in logs - Updated `eth.spec.ts` Signed-off-by: Nana-EC <[email protected]>
1 parent b01b0a8 commit 8479372

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

packages/relay/src/lib/eth.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,24 +698,31 @@ export class EthImpl implements Eth {
698698
receiptResponse.created_contract_ids.length > 0
699699
? EthImpl.prepend0x(ContractId.fromString(receiptResponse.created_contract_ids[0]).toSolidityAddress())
700700
: undefined;
701-
const answer = {
701+
702+
703+
// support stricter go-eth client which requires the transaction hash property on logs
704+
const logs = receiptResponse.logs.map(log => ({ ...log, transactionHash: receiptResponse.hash}));
705+
706+
const receipt = {
702707
blockHash: receiptResponse.block_hash.substring(0, 66),
703708
blockNumber: EthImpl.numberTo0x(receiptResponse.block_number),
704709
from: receiptResponse.from,
705710
to: receiptResponse.to,
706711
cumulativeGasUsed: EthImpl.numberTo0x(receiptResponse.block_gas_used),
707712
gasUsed: EthImpl.numberTo0x(receiptResponse.gas_used),
708713
contractAddress: createdContract,
709-
logs: receiptResponse.logs,
714+
logs: logs,
710715
logsBloom: receiptResponse.bloom,
711716
transactionHash: receiptResponse.hash,
712717
transactionIndex: EthImpl.numberTo0x(receiptResponse.transaction_index),
713718
effectiveGasPrice: EthImpl.numberTo0x(Number.parseInt(effectiveGas) * 10_000_000_000),
714719
root: receiptResponse.root,
715720
status: receiptResponse.status,
716721
};
717-
this.logger.trace(`receipt for ${hash} found in block ${answer.blockNumber}`);
718-
return answer;
722+
723+
724+
this.logger.trace(`receipt for ${hash} found in block ${receipt.blockNumber}`);
725+
return receipt;
719726
}
720727
}
721728

packages/relay/tests/lib/eth.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,8 @@ describe('Eth', async function () {
10661066
"contract_id": "0.0.5001",
10671067
"data": "0x0123",
10681068
"index": 0,
1069-
"topics": ["0x97c1fc0a6ed5551bc831571325e9bdb365d06803100dc20648640ba24ce69750"]
1069+
"topics": ["0x97c1fc0a6ed5551bc831571325e9bdb365d06803100dc20648640ba24ce69750"],
1070+
"transactionHash": "0x4a563af33c4871b51a8b108aa2fe1dd5280a30dfb7236170ae5e5e7957eb6392"
10701071
}],
10711072
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
10721073
"status": "0x1",
@@ -1224,7 +1225,7 @@ describe('Eth', async function () {
12241225
expect(receipt).to.be.null;
12251226
});
12261227

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

0 commit comments

Comments
 (0)