Skip to content

Commit 68b23ac

Browse files
Change v field in eth_getTransactionByHash and eth_getBlockByHash to be zeroHex instead of null (#917)
* Change null to 0x Signed-off-by: Major <[email protected]> Signed-off-by: Major <[email protected]> * Added test for 0x0 value when v is null Signed-off-by: Major <[email protected]> --------- Signed-off-by: Major <[email protected]> Signed-off-by: Major <[email protected]>
1 parent 541c06e commit 68b23ac

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/relay/src/lib/eth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ export class EthImpl implements Eth {
11011101
to: contractResult.to?.substring(0, 42),
11021102
transactionIndex: EthImpl.numberTo0x(contractResult.transaction_index),
11031103
type: EthImpl.nullableNumberTo0x(contractResult.type),
1104-
v: EthImpl.nullableNumberTo0x(contractResult.v),
1104+
v: EthImpl.nanOrNumberTo0x(contractResult.v),
11051105
value: EthImpl.nanOrNumberTo0x(contractResult.amount),
11061106
});
11071107
}
@@ -1382,7 +1382,7 @@ export class EthImpl implements Eth {
13821382
to: contractResultDetails.to.substring(0, 42),
13831383
transactionIndex: EthImpl.numberTo0x(contractResultDetails.transaction_index),
13841384
type: EthImpl.nullableNumberTo0x(contractResultDetails.type),
1385-
v: EthImpl.nullableNumberTo0x(contractResultDetails.v),
1385+
v: EthImpl.nanOrNumberTo0x(contractResultDetails.v),
13861386
value: EthImpl.nanOrNumberTo0x(contractResultDetails.amount),
13871387
});
13881388
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,6 +3320,24 @@ describe('Eth', async function () {
33203320
expect(result.value).to.eq('0x0');
33213321
});
33223322

3323+
it('handles transactions with v as null', async function () {
3324+
// mirror node request mocks
3325+
const detailedResultsWithNullNullableValues = {
3326+
...defaultDetailedContractResultByHash,
3327+
v: null
3328+
};
3329+
3330+
restMock.onGet(`contracts/results/${defaultTxHash}`).reply(200, detailedResultsWithNullNullableValues);
3331+
restMock.onGet(`accounts/${defaultFromLongZeroAddress}`).reply(200, {
3332+
evm_address: `${defaultTransaction.from}`
3333+
});
3334+
const result = await ethImpl.getTransactionByHash(defaultTxHash);
3335+
if (result == null) return;
3336+
3337+
expect(result).to.exist;
3338+
expect(result.v).to.eq('0x0');
3339+
});
3340+
33233341
it('returns reverted transactions', async function () {
33243342
restMock.onGet(`contracts/results/${defaultTxHash}`).reply(200, defaultDetailedContractResultByHashReverted);
33253343
restMock.onGet(`accounts/${defaultFromLongZeroAddress}`).reply(200, {

0 commit comments

Comments
 (0)