Skip to content

Commit

Permalink
fix: fetch block from header
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Nov 12, 2024
1 parent dbf13c0 commit 95ff74c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/actions/public/watchBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,18 @@ export function watchBlocks<

const { unsubscribe: unsubscribe_ } = await transport.subscribe({
params: ['newHeads'],
onData(data: any) {
async onData(data: any) {
if (!active) return
const format =
client.chain?.formatters?.block?.format || formatBlock
const block = format(data.result)
onBlock(block, prevBlock as any)
const block = (await getAction(
client,
getBlock,
'getBlock',
)({
blockNumber: data.blockNumber,
includeTransactions,
}).catch(() => {})) as GetBlockReturnType<chain>
if (!active) return
onBlock(block as any, prevBlock as any)
emitFetched = false
prevBlock = block
},
Expand Down

0 comments on commit 95ff74c

Please sign in to comment.