vechain / vechain-sdk-js

The official JavaScript SDK for VeChain.
19 stars 6 forks source link

🐛 [BUG] - RPC `eth_getBlockByNumber` and `eth_getBlockByHash` do not respect the `hydrated` flag #1014

Open ifavo opened 6 days ago

ifavo commented 6 days ago

Description

The RPC docs on https://ethereum.github.io/execution-apis/api-documentation/ state that the second parameter for eth_getBlockByNumber and eth_getBlockByHash is a boolean flag that indicates if transaction results will be hydrated.

Currently the SDK returns hydrated transaction details at all times.

Reproduction URL

https://www.val.town/v/ifavo/amberOtter

Reproduction steps

import { ThorClient, VeChainProvider } from "@vechain/sdk-network";

const thorClient = ThorClient.fromUrl("https://mainnet.vechain.org");
const provider = new VeChainProvider(thorClient);

const txIdsOnly = await provider.request({
  method: "eth_getBlockByHash",
  params: ["0x012031cb1199629027c010e8c259664edb3f9d0d78b78a4ebc089dc78f604e78", false],
});

console.log("This should be Ids only:", txIdsOnly.transactions)

const hydrated = await provider.request({
  method: "eth_getBlockByHash",
  params: ["0x012031cb1199629027c010e8c259664edb3f9d0d78b78a4ebc089dc78f604e78", true],
});

console.log("This should be transaction objects:", hydrated.transactions)

Screenshots

![DESCRIPTION](LINK.png)

Logs

No response

OS

No response