Skip to content

Commit d2262ee

Browse files
authored
Use evm_address of recently deployed contracts to populate the transaction receipt result (#766)
* Edit getTransactionReceipt Signed-off-by: nikolay <[email protected]> * Fix code smell Signed-off-by: nikolay <[email protected]> Signed-off-by: nikolay <[email protected]>
1 parent 2a97070 commit d2262ee

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

packages/relay/src/lib/eth.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020

2121
import { Eth } from '../index';
22-
import { ContractId, Hbar, EthereumTransaction } from '@hashgraph/sdk';
22+
import { Hbar, EthereumTransaction } from '@hashgraph/sdk';
2323
import { BigNumber } from '@hashgraph/sdk/lib/Transfer';
2424
import { Logger } from 'pino';
2525
import { Block, Transaction, Log } from './model';
@@ -1033,12 +1033,6 @@ export class EthImpl implements Eth {
10331033
? receiptResponse.gas_price
10341034
: receiptResponse.max_fee_per_gas;
10351035

1036-
let createdContract;
1037-
if (receiptResponse.created_contract_ids.length) {
1038-
const contract = await this.mirrorNodeClient.getContract(receiptResponse.created_contract_ids[0]);
1039-
createdContract = contract?.evm_address ?? EthImpl.prepend0x(ContractId.fromString(receiptResponse.created_contract_ids[0]).toSolidityAddress());
1040-
}
1041-
10421036
// support stricter go-eth client which requires the transaction hash property on logs
10431037
const logs = receiptResponse.logs.map(log => {
10441038
return new Log({
@@ -1061,7 +1055,7 @@ export class EthImpl implements Eth {
10611055
to: receiptResponse.to,
10621056
cumulativeGasUsed: EthImpl.numberTo0x(receiptResponse.block_gas_used),
10631057
gasUsed: EthImpl.nanOrNumberTo0x(receiptResponse.gas_used),
1064-
contractAddress: createdContract,
1058+
contractAddress: receiptResponse.address,
10651059
logs: logs,
10661060
logsBloom: receiptResponse.bloom === EthImpl.emptyHex ? EthImpl.emptyBloom : receiptResponse.bloom,
10671061
transactionHash: EthImpl.toHash32(receiptResponse.hash),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2530,6 +2530,7 @@ describe('Eth', async function () {
25302530
};
25312531

25322532
const defaultDetailedContractResultByHash = {
2533+
"address": "0xd8db0b1dbf8ba6721ef5256ad5fe07d72d1d04b9",
25332534
"amount": 2000000000,
25342535
"bloom":
25352536
"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
@@ -2611,7 +2612,7 @@ describe('Eth', async function () {
26112612
"status": "0x1",
26122613
"transactionHash": "0x4a563af33c4871b51a8b108aa2fe1dd5280a30dfb7236170ae5e5e7957eb6392",
26132614
"transactionIndex": "0x1",
2614-
"contractAddress": "0x0000000000000000000000000000000000001b59",
2615+
"contractAddress": "0xd8db0b1dbf8ba6721ef5256ad5fe07d72d1d04b9",
26152616
"root": undefined
26162617
};
26172618

0 commit comments

Comments
 (0)