web3 / web3.js

Collection of comprehensive TypeScript libraries for Interaction with the Ethereum JSON RPC API and utility functions.
https://web3js.org/
Other
19.21k stars 4.92k forks source link

Invalid type for block transactions #7090

Closed sharifzadesina closed 2 months ago

sharifzadesina commented 3 months ago

Expected behavior

The eth.getBlock().transactions should either return empty array in case of empty block, or include undefined as part of its return type.

Actual behavior

import { Web3 } from "web3";

const web3 = new Web3('https://sepolia.infura.io/v3/xxxxxx');

const block = await web3.eth.getBlock(6058307, true);

console.log(block.transactions); // this is undefined!

Steps to reproduce the behavior

  1. use web3.eth.getBlock on an empty block.

Logs

Doesn't matter.

Environment

Doesn't matter.

SantiagoDevRel commented 3 months ago

Hi @sharifzadesina thanks for submitting this, you are right, the taem will work on it soon! thanks

luu-alex commented 2 months ago

Created a PR for this, thanks

luu-alex commented 2 months ago

merged. will be available next release