Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

eth_getTransactionByBlockNumberAndIndex and eth_getTransactionByBlockHashAndIndex behave inconsistently #4435

Open
SamWilsn opened this issue Jun 7, 2023 · 0 comments
Labels

Comments

@SamWilsn
Copy link

SamWilsn commented Jun 7, 2023

Calling either eth_getTransactionByBlockNumberAndIndex or eth_getTransactionByBlockHashAndIndex through request has different behaviour when the block doesn't exist vs. the transaction is out of bounds.

For example:

const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
const { blockHash, transactionIndex } = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });

// Returns null:
const fakeHash = "0x0000000000000000000000000000000000000000000000000000000000000000";
await provider.request({ method: "eth_getTransactionByBlockHashAndIndex", params: [ fakeHash, transactionIndex] });

// Throws exception:
await provider.request({ method: "eth_getTransactionByBlockHashAndIndex", params: [ blockHash, transactionIndex + 1] });

The specific message is:

n.getTransactions()[w.Quantity.toNumber(...)] is undefined

Presumably these two error cases should behave similarly: both throw exceptions or both return null.

@github-project-automation github-project-automation bot moved this to Inbox in Ganache Jun 7, 2023
@davidmurdoch davidmurdoch moved this from Inbox to Backlog in Ganache Jun 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Status: Backlog
Development

No branches or pull requests

2 participants