Colm3na / polkastats-backend-v3

polkastats.io backend repository
Apache License 2.0
17 stars 15 forks source link

Store block logs #189

Closed mariopino closed 4 years ago

mariopino commented 4 years ago

Is your feature request related to a problem? Please describe.

Import logs from block, example code:

// Block 89988
const { block } = await api.rpc.chain.getBlock("0xdf759b27b3ad24dcb1712bfc7461c053e46df6b59c08739040a216f81a592c7b");
block.header.digest.logs.forEach((log, index) => {
  const { type } = log;
  const [ [ engine, data ] ] = Object.values(log.toJSON());
  console.log(JSON.stringify({
    block: block.header.number,
    index,
    type,
    engine,
    data
  }, null, 2));
})

Describe the solution you'd like

Describe alternatives you've considered

Additional context

mariopino commented 4 years ago

Done