Open ifavo opened 4 days ago
The logIndex in the transaction conversion can only be as big as the first clause number of events. I don't have an example transaction to show this situation but from the code it seems there is a bug in the conversion
logIndex
This issue relates to this part: https://github.com/vechain/vechain-sdk-js/blob/10787514e01b3b8bfb7bd3256e47ad27401382c3/packages/network/src/provider/utils/formatter/transactions/formatter.ts#L149-L171
When looking at these two lines:
const n = receipt.outputs.length > 0 ? receipt.outputs[0].events.length : 0; const filledLogIndexes = new Array<number>(n)
The list of potential indexes is equal to the number of events in the first clause output.
No response
Given this imaginary transaction:
Then:
n
0
filledLogIndexes
logIndexes[0]
A different approach & solution can be:
const logs: TransactionReceiptLogsRPC[] = []; let logIndex = logIndexOffset; receipt.outputs.forEach((output) => { output.events.forEach((event, index) => { logs.push({ blockHash: receipt.meta.blockID, blockNumber: Quantity.of(receipt.meta.blockNumber), transactionHash: receipt.meta.txID as string, address: event.address, topics: event.topics.map((topic) => topic), data: event.data, removed: false, transactionIndex: Quantity.of(transactionIndex), // convert to hex on-demand logIndex: Quantity.of(logIndex) }); // increase logIndex after each event logIndex++ }); });
![DESCRIPTION](LINK.png)
Description
The
logIndex
in the transaction conversion can only be as big as the first clause number of events. I don't have an example transaction to show this situation but from the code it seems there is a bug in the conversionThis issue relates to this part: https://github.com/vechain/vechain-sdk-js/blob/10787514e01b3b8bfb7bd3256e47ad27401382c3/packages/network/src/provider/utils/formatter/transactions/formatter.ts#L149-L171
When looking at these two lines:
The list of potential indexes is equal to the number of events in the first clause output.
Reproduction URL
No response
Reproduction steps
Given this imaginary transaction:
Then:
n
will0
filledLogIndexes
will be of size0
logIndexes[0]
is undefinedA different approach & solution can be:
Screenshots
Logs
No response
OS
No response