+
{renderContent()}
);
@@ -45,16 +45,73 @@ function TransactionModal() {
function TransactionDetails({ selected }: { selected: Selected }) {
const { blocks } = useBlocks();
const block = blocks[selected.slot];
- if (!block) return
{"block not found"};
+ if (!block)
+ return
{"Transaction block not found"};
if (!block.transactions) {
- return
loading;
+ return (
+
+
+ Loading
+
+ );
}
- const tx = block.transactions[selected.signature];
- if (!tx) return
{"sig not found"};
+ const details = block.transactions[selected.signature];
+ if (!details)
+ return
{"Transaction not found"};
- return
{JSON.stringify(tx)}
;
+ if (details.transfers.length === 0)
+ return
{"No transfers"};
+
+ let i = 0;
+ return (
+ <>
+ {details.transfers.map(transfer => {
+ return (
+
+ {i > 1 ?
: null}
+
+
+
+
+
+
From
+
+
+ {transfer.fromPubkey.toBase58()}
+
+
+
+
+
+
+
+
To
+
+
+ {transfer.toPubkey.toBase58()}
+
+
+
+
+
+
+
+
Amount (SOL)
+
+
+ {`◎${(1.0 * transfer.lamports) / LAMPORTS_PER_SOL}`}
+
+
+
+
+
+
+ );
+ })}
+ >
+ );
}
export default TransactionModal;
diff --git a/explorer/src/providers/blocks.tsx b/explorer/src/providers/blocks.tsx
index 3462909b70..711b3d08cd 100644
--- a/explorer/src/providers/blocks.tsx
+++ b/explorer/src/providers/blocks.tsx
@@ -1,6 +1,12 @@
import React from "react";
import bs58 from "bs58";
-import { Connection, Transaction } from "@solana/web3.js";
+import {
+ Connection,
+ Transaction,
+ TransferParams,
+ SystemProgram,
+ SystemInstruction
+} from "@solana/web3.js";
import { useCluster, ClusterStatus } from "./cluster";
import { useTransactions } from "./transactions";
@@ -10,7 +16,12 @@ export enum Status {
Success
}
-type Transactions = { [signature: string]: Transaction };
+export interface TransactionDetails {
+ transaction: Transaction;
+ transfers: Array
;
+}
+
+type Transactions = { [signature: string]: TransactionDetails };
export interface Block {
status: Status;
transactions?: Transactions;
@@ -155,8 +166,26 @@ async function fetchBlock(dispatch: Dispatch, slot: number, url: string) {
block.transactions.forEach(({ transaction }) => {
const signature = transaction.signature;
if (signature) {
+ const transferInstructions = transaction.instructions
+ .filter(ix => ix.programId.equals(SystemProgram.programId))
+ .filter(
+ ix => SystemInstruction.decodeInstructionType(ix) === "Transfer"
+ );
+
+ let transfers: TransferParams[] = [];
+ transferInstructions.forEach(ix => {
+ try {
+ transfers.push(SystemInstruction.decodeTransfer(ix));
+ } catch (err) {
+ console.log(ix, err);
+ }
+ });
+
const sig = bs58.encode(signature);
- transactions[sig] = transaction;
+ transactions[sig] = {
+ transaction,
+ transfers
+ };
}
});
status = Status.Success;