Skip to content

Commit 10c6823

Browse files
Nana-ECnatanasow
andauthored
Align log with execution apis (0.4) (#364)
CHerry-pick #337 to release/0.4 Update log response integers to be hexadecimals Signed-off-by: Nikolay Atanasow <[email protected]> Signed-off-by: Nana-EC <[email protected]> Co-authored-by: Nikolay Atanasow <[email protected]>
1 parent 4dbcdea commit 10c6823

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

packages/relay/src/lib/eth.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -825,13 +825,13 @@ export class EthImpl implements Eth {
825825
return new Log({
826826
address: log.address,
827827
blockHash: EthImpl.toHash32(receiptResponse.block_hash),
828-
blockNumber: receiptResponse.block_number,
828+
blockNumber: EthImpl.numberTo0x(receiptResponse.block_number),
829829
data: log.data,
830-
logIndex: log.index,
830+
logIndex: EthImpl.numberTo0x(log.index),
831831
removed: false,
832832
topics: log.topics,
833833
transactionHash: EthImpl.toHash32(receiptResponse.hash),
834-
transactionIndex: receiptResponse.transaction_index
834+
transactionIndex: EthImpl.numberTo0x(receiptResponse.transaction_index)
835835
});
836836
});
837837

@@ -1151,13 +1151,13 @@ export class EthImpl implements Eth {
11511151
logs[logIndex] = new Log({
11521152
address: log.address,
11531153
blockHash: EthImpl.toHash32(detail.block_hash),
1154-
blockNumber: detail.block_number,
1154+
blockNumber: EthImpl.numberTo0x(detail.block_number),
11551155
data: log.data,
1156-
logIndex: logIndex,
1156+
logIndex: EthImpl.numberTo0x(logIndex),
11571157
removed: false,
11581158
topics: log.topics,
11591159
transactionHash: EthImpl.toHash32(detail.hash),
1160-
transactionIndex: detail.transaction_index
1160+
transactionIndex: EthImpl.numberTo0x(detail.transaction_index)
11611161
});
11621162
}
11631163
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -979,15 +979,15 @@ describe('Eth calls using MirrorNode', async function () {
979979
expect(res.address).to.eq(log.address);
980980
expect(res.blockHash).to.eq(EthImpl.toHash32(tx.block_hash));
981981
expect(res.blockHash.length).to.eq(66);
982-
expect(res.blockNumber).to.eq(tx.block_number);
982+
expect(res.blockNumber).to.eq(EthImpl.numberTo0x(tx.block_number));
983983
expect(res.data).to.eq(log.data);
984-
expect(res.logIndex).to.eq(blockLogIndexOffset + Number(log.index));
984+
expect(res.logIndex).to.eq(EthImpl.numberTo0x(blockLogIndexOffset + Number(log.index)));
985985
expect(res.removed).to.eq(false);
986986
expect(res.topics).to.exist;
987987
expect(res.topics).to.deep.eq(log.topics);
988988
expect(res.transactionHash).to.eq(tx.hash);
989989
expect(res.transactionHash.length).to.eq(66);
990-
expect(res.transactionIndex).to.eq(tx.transaction_index);
990+
expect(res.transactionIndex).to.eq(EthImpl.numberTo0x(tx.transaction_index));
991991
};
992992

993993
const expectLogData1 = (res) => {
@@ -1411,15 +1411,15 @@ describe('Eth', async function () {
14111411
"logs": [{
14121412
"address": "0x0000000000000000000000000000000000001389",
14131413
"blockHash": "0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042",
1414-
"blockNumber": 17,
1414+
"blockNumber": "0x11",
14151415
"data": "0x0123",
1416-
"logIndex": 0,
1416+
"logIndex": "0x0",
14171417
"removed": false,
14181418
"topics": [
14191419
"0x97c1fc0a6ed5551bc831571325e9bdb365d06803100dc20648640ba24ce69750"
14201420
],
14211421
"transactionHash": "0x4a563af33c4871b51a8b108aa2fe1dd5280a30dfb7236170ae5e5e7957eb6392",
1422-
"transactionIndex": 1
1422+
"transactionIndex": "0x1"
14231423
}],
14241424
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
14251425
"status": "0x1",

packages/server/tests/acceptance/rpc.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe('RPC Server Acceptance Tests', function () {
131131
expect(logs[i]).to.have.property('logIndex');
132132

133133
// verify logIndex represents index in block across transactions
134-
expect(logs[i].logIndex).to.equal(Number(i));
134+
expect(logs[i].logIndex).to.equal(ethers.utils.hexValue(Number(i)));
135135

136136
const key = `${logs[i].transactionHash}---${logs[i].logIndex}`;
137137
txIndexLogIndexMapping.push(key);
@@ -156,7 +156,7 @@ describe('RPC Server Acceptance Tests', function () {
156156

157157
const log4BlockInt = parseInt(log4Block.blockNumber);
158158
for (let i in logs) {
159-
expect(logs[i].blockNumber).to.be.greaterThanOrEqual(log4BlockInt);
159+
expect(parseInt(logs[i].blockNumber, 16)).to.be.greaterThanOrEqual(log4BlockInt);
160160
}
161161
});
162162

@@ -168,7 +168,7 @@ describe('RPC Server Acceptance Tests', function () {
168168

169169
const log0BlockInt = parseInt(log0Block.blockNumber);
170170
for (let i in logs) {
171-
expect(logs[i].blockNumber).to.be.lessThanOrEqual(log0BlockInt);
171+
expect(parseInt(logs[i].blockNumber, 16)).to.be.lessThanOrEqual(log0BlockInt);
172172
}
173173
});
174174

@@ -182,8 +182,8 @@ describe('RPC Server Acceptance Tests', function () {
182182
const log0BlockInt = parseInt(log0Block.blockNumber);
183183
const log4BlockInt = parseInt(log4Block.blockNumber);
184184
for (let i in logs) {
185-
expect(logs[i].blockNumber).to.be.greaterThanOrEqual(log0BlockInt);
186-
expect(logs[i].blockNumber).to.be.lessThanOrEqual(log4BlockInt);
185+
expect(parseInt(logs[i].blockNumber, 16)).to.be.greaterThanOrEqual(log0BlockInt);
186+
expect(parseInt(logs[i].blockNumber, 16)).to.be.lessThanOrEqual(log4BlockInt);
187187
}
188188
});
189189

0 commit comments

Comments
 (0)