Skip to content

Commit 6a9766e

Browse files
authored
Fixed Null exception for transaction receipts (#1734)
Signed-off-by: Alfredo Gutierrez <[email protected]>
1 parent febb59e commit 6a9766e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/relay/src/lib/eth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,7 @@ export class EthImpl implements Eth {
18141814
effectiveGasPrice: nanOrNumberTo0x(Number.parseInt(effectiveGas) * 10_000_000_000),
18151815
root: receiptResponse.root,
18161816
status: receiptResponse.status,
1817-
type: numberTo0x(receiptResponse.type),
1817+
type: nullableNumberTo0x(receiptResponse.type),
18181818
};
18191819

18201820
if (receiptResponse.error_message) {

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5610,6 +5610,24 @@ describe('Eth', async function () {
56105610
expect(receipt.effectiveGasPrice).to.eq('0x0');
56115611
});
56125612

5613+
it('Handles null type', async function () {
5614+
const contractResult = {
5615+
...defaultDetailedContractResultByHash,
5616+
type: null,
5617+
};
5618+
5619+
const uniqueTxHash = '0x07cdd7b820375d10d73af57a6a3e84353645fdb1305ea58ff52daa53ec640533';
5620+
5621+
restMock.onGet(`contracts/results/${uniqueTxHash}`).reply(200, contractResult);
5622+
restMock.onGet(`contracts/${defaultDetailedContractResultByHash.created_contract_ids[0]}`).reply(404);
5623+
const receipt = await ethImpl.getTransactionReceipt(uniqueTxHash);
5624+
5625+
expect(receipt).to.exist;
5626+
if (receipt == null) return;
5627+
5628+
expect(receipt.type).to.be.null;
5629+
});
5630+
56135631
it('handles empty bloom', async function () {
56145632
const receiptWith0xBloom = {
56155633
...defaultDetailedContractResultByHash,

0 commit comments

Comments
 (0)