Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
nortonandreev committed Feb 4, 2025
1 parent cb6c984 commit 6d08836
Show file tree
Hide file tree
Showing 28 changed files with 870 additions and 55 deletions.
4 changes: 4 additions & 0 deletions explorer/src/lib/chain-info/__tests__/transformBlock.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ describe("transformBlock", () => {
blockheight: 495868,
date: new Date(blockData.transactions[0].blockTimestamp * 1000),
feepaid: 290866,
from: undefined,
gaslimit: 500000000,
gasprice: 1,
gasspent: 290866,
memo: blockData.transactions[0].tx.memo,
method: "transfer",
success: true,
to: undefined,
txerror: "",
txid: "3a3f6f90a1012ae751b4448bcb8e98def0ba2b18170239bd69fcf8e2e37f0602",
txtype: "Moonlight",
Expand All @@ -46,12 +48,14 @@ describe("transformBlock", () => {
blockheight: 495868,
date: new Date(blockData.transactions[1].blockTimestamp * 1000),
feepaid: 289852,
from: undefined,
gaslimit: 500000000,
gasprice: 1,
gasspent: 289852,
memo: blockData.transactions[1].tx.memo,
method: "transfer",
success: true,
to: undefined,
txerror: "",
txid: "07bfabea1d94c16f2dc3697fa642f6cecea6e81bf76b9644efbb6e2723b76d00",
txtype: "Phoenix",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ describe("transformTransaction", () => {
blockheight: 487166,
date: new Date(txData.blockTimestamp * 1000),
feepaid: 290766,
from: undefined,
gaslimit: 500000000,
gasprice: 1,
gasspent: 290766,
memo: gqlTransaction.tx.tx.memo,
method: "transfer",
success: true,
to: undefined,
txerror: "",
txid: "4877687c2dbf154248d3ddee9ba0d81e3431f39056f82a46819da041d4ac0e04",
txtype: "Moonlight",
Expand Down
2 changes: 2 additions & 0 deletions explorer/src/lib/chain-info/chain-info.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type SearchResult = {
};

type Transaction = {
from: string | undefined;
to: string | undefined;
blockhash: string;
blockheight: number;
date: Date;
Expand Down
2 changes: 2 additions & 0 deletions explorer/src/lib/chain-info/transformTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ const transformTransaction = (tx) => ({
blockheight: tx.blockHeight,
date: unixTsToDate(tx.blockTimestamp),
feepaid: tx.gasSpent * tx.tx.gasPrice,
from: undefined,
gaslimit: tx.tx.gasLimit,
gasprice: tx.tx.gasPrice,
gasspent: tx.gasSpent,
memo: tx.tx.memo ?? "",
method: tx.tx.isDeploy ? "deploy" : tx.tx.callData?.fnName ?? "transfer",
success: tx.err === null,
to: undefined,
txerror: tx.err ?? "",
txid: tx.id,
txtype: tx.tx.txType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports[`Blocks Card > should disable the \`Show More\` button if there is no mo
class="data-card__content"
>
<div
class="table-container blocks-table blocks-card__table"
class="table-container blocks-table data-card__table"
>
<table
class="table"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ exports[`Navbar > renders the Navbar component 1`] = `
>
Provisioners
</a>
<a
class="dusk-anchor dusk-anchor--off-surface dusk-nav-list__link"
href="/some-base-path/tokens"
>
Tokens
</a>
</nav>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports[`Provisioners Card > should disable the \`Show More\` button if there is
class="data-card__content"
>
<div
class="table-container provisioners-table provisioners-card__table"
class="table-container provisioners-table data-card__table"
>
<table
class="table"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ exports[`Transactions Card > should disable the \`Show More\` button if there is
class="data-card__content"
>
<div
class="table-container transactions-table transactions-card__table"
class="table-container transactions-table"
>
<table
class="table"
Expand Down
4 changes: 0 additions & 4 deletions explorer/src/lib/components/blocks-card/BlocksCard.css

This file was deleted.

2 changes: 0 additions & 2 deletions explorer/src/lib/components/blocks-card/BlocksCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<script>
import { BlocksList, BlocksTable, DataCard } from "$lib/components";
import "./BlocksCard.css";
/** @type {Block[] | null}*/
export let blocks;
Expand Down
4 changes: 4 additions & 0 deletions explorer/src/lib/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export { default as TransactionDetails } from "./transaction-details/Transaction
export { default as TransactionsList } from "./transactions-list/TransactionsList.svelte";
export { default as TransactionsTable } from "./transactions-table/TransactionsTable.svelte";
export { default as TokensTable } from "./tokens-table/TokensTable.svelte";
export { default as TokenOverview } from "./token-overview/TokenOverview.svelte";
export { default as TokenDetailItem } from "./token-detail-item/TokenDetailItem.svelte";
export { default as TokenDetailsTable } from "./token-details-table/TokenDetailsTable.svelte";
export { default as TokenListDetails } from "./token-list-details/TokenListDetails.svelte";
export { default as TokenTransactionsList } from "./token-transactions-list/TokenTransactionsList.svelte";
export { default as TransactionType } from "./transaction-type/TransactionType.svelte";
export { default as TransactionStatus } from "./transaction-status/TransactionStatus.svelte";
export { default as WorldMap } from "./world-map/WorldMap.svelte";
24 changes: 24 additions & 0 deletions explorer/src/lib/components/token-detail-item/TokenDetailItem.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.token-overview-panel__details-item {
flex: 1;
display: flex;
flex-direction: column;
justify-content: flex-start;
min-width: max-content;
margin: 0 1rem;
}

@media (min-width: 1024px) {
.token-overview-panel__details-item:not(:last-child) {
border-right: 1px solid var(--taupe-grey);
}
}

.token-overview-panel__details-item-title {
font-size: 1.125rem;
font-weight: 500;
margin-bottom: 0.3125rem;
}

.token-overview-panel__details-item-subtitle {
font-size: 0.875rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script>
import "./TokenDetailItem.css";
export let title;
export let subtitle;
</script>

<div class="token-overview-panel__details-item">
<p class="token-overview-panel__details-item-title">{title}</p>
<p class="token-overview-panel__details-item-subtitle">{subtitle}</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<svelte:options immutable={true} />

<script>
import {
Table,
TableBody,
TableCell,
TableHead,
TableRow,
} from "$lib/components/table";
import { TransactionStatus, TransactionType } from "$lib/components";
import { makeClassName, middleEllipsis } from "$lib/dusk/string";
/** @type {string | undefined} */
export let className = undefined;
/** @type {Transaction[]} */
export let data;
/** @type {boolean} */
export let displayTooltips = false;
const HASH_CHARS_LENGTH = 10;
$: classes = makeClassName(["tokens-table", className]);
</script>

<Table className={classes}>
<TableHead>
<TableRow>
<TableCell type="th">From</TableCell>
<TableCell type="th">To</TableCell>
<TableCell type="th">ID</TableCell>
<TableCell type="th">Fee (Dusk)</TableCell>
<TableCell type="th">Status</TableCell>
<TableCell type="th">Type</TableCell>
</TableRow>
</TableHead>
<TableBody>
{#each data as transaction (transaction)}
<TableRow>
<TableCell
>{middleEllipsis(
transaction.from ? transaction.from : "",
HASH_CHARS_LENGTH
)}</TableCell
>
<TableCell
>{middleEllipsis(
transaction.to ? transaction.to : "",
HASH_CHARS_LENGTH
)}</TableCell
>
<TableCell
>{middleEllipsis(transaction.txid, HASH_CHARS_LENGTH)}</TableCell
>
<TableCell>{transaction.gasprice}</TableCell>
<TableCell>
<TransactionStatus
errorMessage={transaction.txerror}
showErrorTooltip={false}
/>
</TableCell>
<TableCell>
<TransactionType data={transaction} {displayTooltips} />
</TableCell>
</TableRow>
{/each}
</TableBody>
</Table>
56 changes: 56 additions & 0 deletions explorer/src/lib/components/token-overview/TokenOverview.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.token-overview-panel {
display: flex;
padding: 1rem 1.375rem;
flex-direction: column;
row-gap: 0.75rem;
border-radius: 1.5rem;
background-color: var(--surface-color);
width: 100%;
text-transform: uppercase;
position: relative;
margin-bottom: 1.25rem;
}

.token-overview-panel__header {
display: flex;
gap: 1.25rem;
flex-direction: column;
align-items: flex-start;
}

@media (min-width: 992px) {
.token-overview-panel__header {
flex-direction: row;
align-items: center;
}
}

.token-overview-panel__token-name {
font-weight: 500;
font-size: 1.125em;
margin-bottom: 0.3125rem;
}

.token-overview-panel__token-address-subheader {
font-size: 1.125em;
color: var(--text-color-secondary);
}

.token-overview-panel__token-address {
font-weight: 500;
}

.token-overview-panel__separator {
border: none;
border-top: 1px solid var(--taupe-grey);
margin: 0.5rem 0;
}

.token-overview-panel__details {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
gap: 1rem;
width: 100%;
}
41 changes: 41 additions & 0 deletions explorer/src/lib/components/token-overview/TokenOverview.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<script>
import { Icon } from "$lib/dusk/components";
import { TokenDetailItem } from "$lib/components";
import { calculateAdaptiveCharCount, middleEllipsis } from "$lib/dusk/string";
import "./TokenOverview.css";
export let data;
export let iconPath;
export let screenWidth;
</script>

<section class="token-overview-panel">
<div class="token-overview-panel__header">
<Icon path={iconPath} size="large" />
<div>
<h2 class="token-overview-panel__token-name">{data.token}</h2>
<p class="token-overview-panel__token-address-subheader">
Address:
<b class="token-overview-panel__token-address">
{middleEllipsis(
data.contractId,
calculateAdaptiveCharCount(screenWidth, 320, 1024, 4, 30)
)}
</b>
</p>
</div>
</div>
<hr class="token-overview-panel__separator" />
<div class="token-overview-panel__details">
<TokenDetailItem
title="{data.totalCurrentSupply} {data.ticker}"
subtitle="Current Total Supply"
/>
<TokenDetailItem
title={data.maxCirculatingSupply}
subtitle="Max Circulating Supply"
/>
<TokenDetailItem title="${data.price}" subtitle="Price" />
</div>
</section>
Loading

0 comments on commit 6d08836

Please sign in to comment.