How do I get the lamports sent in each transaction and why are there multiple transaction accounts on each message? This is the code I have, but 'parsed' is typed as any in the SDK
const getTransactionSummary = (
fromAddress: ParsedMessageAccount,
transaction: ParsedTransactionWithMeta
) => {
const {
blockTime,
transaction: { message },
} = transaction;
const parsedLamports = message.instructions
.filter(isParsedInstruction)
.map(({ parsed }) => parsed.info.lamports);
return {
address: fromAddress.pubkey.toBase58(),
time: blockTime ? new Date(blockTime * 1000).toISOString() : null,
amount: parsedLamports.reduce(add, 0),
meta: transaction.meta?.err ?? null,
};
};```