Skip to content

Commit

Permalink
use simplified item IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
uiii committed Nov 14, 2023
1 parent 2a31cee commit 083bb06
Show file tree
Hide file tree
Showing 41 changed files with 573 additions and 250 deletions.
2 changes: 1 addition & 1 deletion src/components/DataViewerValueParsed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { css } from "@emotion/react";
import { DecodedArg } from "../model/decodedMetadata";
import { noCase } from "../utils/string";

import { AccountAddress } from "./AccountAddress";
import { AccountAddress } from "./account/AccountAddress";
import { Network } from "../model/network";

// found in https://github.com/polkadot-js/apps/blob/59c2badf87c29fd8cb5b7dfcc045c3ce451a54bc/packages/react-params/src/Param/findComponent.ts#L51
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { useMemo } from "react";
import { Tooltip } from "@mui/material";
import { css } from "@emotion/react";

import { Network } from "../model/network";
import { encodeAddress } from "../utils/address";
import { shortenHash } from "../utils/shortenHash";
import { Network } from "../../model/network";
import { encodeAddress } from "../../utils/address";
import { shortenHash } from "../../utils/shortenHash";

import CopyToClipboardButton, { CopyToClipboardButtonProps } from "../CopyToClipboardButton";
import { Link } from "../Link";

import { Link } from "./Link";
import { AccountAvatar } from "./AccountAvatar";
import CopyToClipboardButton, { CopyToClipboardButtonProps } from "./CopyToClipboardButton";

const accountAddressStyle = css`
display: flex;
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/components/account/AccountBalancesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import { UsdRates } from "../../model/usdRates";

import { compareProps } from "../../utils/compare";

import { AccountAddress } from "../AccountAddress";
import { Currency } from "../Currency";
import { ErrorMessage } from "../ErrorMessage";
import { ItemsTable, ItemsTableAttribute } from "../ItemsTable";

import { AccountAddress } from "./AccountAddress";

const networkStyle = css`
display: flex;
align-items: center;
Expand Down
3 changes: 2 additions & 1 deletion src/components/balances/BalancesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Resource } from "../../model/resource";
import { UsdRates } from "../../model/usdRates";
import { decodeAddress } from "../../utils/address";

import { AccountAddress } from "../AccountAddress";
import { AccountAddress } from "../account/AccountAddress";

import { Currency } from "../Currency";
import { ItemsTable, ItemsTableAttribute } from "../ItemsTable";
import { Link } from "../Link";
Expand Down
3 changes: 2 additions & 1 deletion src/components/blocks/BlockInfoTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { Network } from "../../model/network";
import { Resource } from "../../model/resource";
import { encodeAddress } from "../../utils/address";

import { AccountAddress } from "../AccountAddress";
import { AccountAddress } from "../account/AccountAddress";

import { InfoTable, InfoTableAttribute } from "../InfoTable";
import { Link } from "../Link";
import { NetworkBadge } from "../NetworkBadge";
Expand Down
21 changes: 21 additions & 0 deletions src/components/blocks/BlockLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Network } from "../../model/network";
import { simplifyBlockId } from "../../services/blocksService";

import { Link } from "../Link";

export interface BlockLinkProps {
network: Network;
id: string;
}

export const BlockLink = (props: BlockLinkProps) => {
const {network, id} = props;

const simplifiedId = simplifyBlockId(id);

return (
<Link to={`/${network.name}/block/${simplifiedId}`}>
{simplifiedId}
</Link>
);
};
15 changes: 6 additions & 9 deletions src/components/blocks/BlocksTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { Block } from "../../model/block";
import { Network } from "../../model/network";
import { PaginatedResource } from "../../model/paginatedResource";

import { AccountAddress } from "../AccountAddress";
import { AccountAddress } from "../account/AccountAddress";

import { ItemsTable, ItemsTableAttribute } from "../ItemsTable";
import { Link } from "../Link";
import { Time } from "../Time";

import { BlockLink } from "./BlockLink";

export type BlocksTableProps = {
network: Network;
blocks: PaginatedResource<Block>,
Expand Down Expand Up @@ -40,17 +42,12 @@ function ExtrinsicsTable(props: BlocksTableProps) {
<BlocksTableAttribute
label="Height"
render={(block) =>
<Link to={`/${network.name}/block/${block.id}`}>
{block.height}
</Link>
<BlockLink network={network} id={block.id} />
}
/>
<BlocksTableAttribute
label="Spec version"
render={(block) =>
<>{block.specVersion}</>

}
render={(block) => block.specVersion}
/>
{showValidator &&
<BlocksTableAttribute
Expand Down
20 changes: 9 additions & 11 deletions src/components/calls/CallInfoTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ import { Resource } from "../../model/resource";

import { encodeAddress } from "../../utils/address";

import { AccountAddress } from "../AccountAddress";
import { AccountAddress } from "../account/AccountAddress";
import { BlockLink } from "../blocks/BlockLink";
import { ExtrinsicLink } from "../extrinsics/ExtrinsicLink";

import { ButtonLink } from "../ButtonLink";
import { DataViewer } from "../DataViewer";
import { InfoTable, InfoTableAttribute } from "../InfoTable";
import { Link } from "../Link";
import { NetworkBadge } from "../NetworkBadge";
import { Time } from "../Time";

import { CallLink } from "./CallLink";

export type CallInfoTableProps = {
network: Network;
call: Resource<Call>;
Expand Down Expand Up @@ -56,27 +60,21 @@ export const CallInfoTable = (props: CallInfoTableProps) => {
<CallInfoTableAttribute
label="Block"
render={(data) =>
<Link to={`/${network.name}/block/${data.blockId}`}>
{data.blockHeight}
</Link>
<BlockLink network={network} id={data.blockId} />
}
copyToClipboard={(data) => data.blockId}
/>
<CallInfoTableAttribute
label="Extrinsic"
render={(data) =>
<Link to={`/${network.name}/extrinsic/${data.extrinsicId}`}>
{data.extrinsicId}
</Link>
<ExtrinsicLink network={network} id={data.extrinsicId} />
}
copyToClipboard={(data) => data.extrinsicId}
/>
<CallInfoTableAttribute
label="Parent call"
render={(data) => data.parentId &&
<Link to={`/${network.name}/call/${data.parentId}`}>
{data.parentId}
</Link>
<CallLink network={network} id={data.parentId} />
}
copyToClipboard={(data) => data.parentId}
hide={(data) => !data.parentId}
Expand Down
21 changes: 21 additions & 0 deletions src/components/calls/CallLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Network } from "../../model/network";
import { simplifyCallId } from "../../services/callsService";

import { Link } from "../Link";

export interface CallLinkProps {
network: Network;
id: string;
}

export const CallLink = (props: CallLinkProps) => {
const {network, id} = props;

const simplifiedId = simplifyCallId(id);

return (
<Link to={`/${network.name}/call/${simplifiedId}`}>
{simplifiedId}
</Link>
);
};
15 changes: 7 additions & 8 deletions src/components/calls/CallsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { Call } from "../../model/call";
import { Network } from "../../model/network";
import { PaginatedResource } from "../../model/paginatedResource";

import { AccountAddress } from "../AccountAddress";
import { AccountAddress } from "../account/AccountAddress";
import { ExtrinsicLink } from "../extrinsics/ExtrinsicLink";

import { ButtonLink } from "../ButtonLink";
import { ItemsTable, ItemsTableAttribute } from "../ItemsTable";
import { Link } from "../Link";

import { CallLink } from "./CallLink";

export type CallsTableProps = {
network: Network;
Expand Down Expand Up @@ -33,9 +36,7 @@ export const CallsTable = (props: CallsTableProps) => {
<CallsTableAttribute
label="ID"
render={(call) =>
<Link to={`/${network.name}/call/${call.id}`}>
{call.id}
</Link>
<CallLink network={network} id={call.id} />
}
/>
<CallsTableAttribute
Expand Down Expand Up @@ -66,9 +67,7 @@ export const CallsTable = (props: CallsTableProps) => {
<CallsTableAttribute
label="Extrinsic"
render={(call) =>
<Link to={`/${network.name}/extrinsic/${call.extrinsicId}`}>
{call.extrinsicId}
</Link>
<ExtrinsicLink network={network} id={call.extrinsicId} />
}
/>
</ItemsTable>
Expand Down
23 changes: 7 additions & 16 deletions src/components/events/EventInfoTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { Event } from "../../model/event";
import { Network } from "../../model/network";
import { Resource } from "../../model/resource";

import { BlockLink } from "../blocks/BlockLink";
import { CallLink } from "../calls/CallLink";
import { ExtrinsicLink } from "../extrinsics/ExtrinsicLink";

import { ButtonLink } from "../ButtonLink";
import { DataViewer } from "../DataViewer";
import { InfoTable, InfoTableAttribute } from "../InfoTable";
import { Link } from "../Link";
import { NetworkBadge } from "../NetworkBadge";
import { Time } from "../Time";

Expand Down Expand Up @@ -48,33 +51,21 @@ export const EventInfoTable = (props: EventInfoTableProps) => {
<EventInfoTableAttribute
label="Block"
render={(data) =>
<Link
to={`/${network.name}/block/${data.blockId}`}
>
{data.blockHeight}
</Link>
<BlockLink network={network} id={data.blockId} />
}
copyToClipboard={(data) => data.blockHeight.toString()}
/>
<EventInfoTableAttribute
label="Extrinsic"
render={(data) => data.extrinsicId &&
<Link
to={`/${network.name}/extrinsic/${data.extrinsicId}`}
>
{data.extrinsicId}
</Link>
<ExtrinsicLink network={network} id={data.extrinsicId} />
}
copyToClipboard={(data) => data.extrinsicId}
/>
<EventInfoTableAttribute
label="Call"
render={(data) => data.callId &&
<Link
to={`/${network.name}/call/${data.callId}`}
>
{data.callId}
</Link>
<CallLink network={network} id={data.callId} />
}
copyToClipboard={(data) => data.callId}
/>
Expand Down
21 changes: 21 additions & 0 deletions src/components/events/EventLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Network } from "../../model/network";
import { simplifyEventId } from "../../services/eventsService";

import { Link } from "../Link";

export interface EventLinkProps {
network: Network;
id: string;
}

export const EventLink = (props: EventLinkProps) => {
const {network, id} = props;

const simplifiedId = simplifyEventId(id);

return (
<Link to={`/${network.name}/event/${simplifiedId}`}>
{simplifiedId}
</Link>
);
};
13 changes: 6 additions & 7 deletions src/components/events/EventsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import { Event } from "../../model/event";
import { Network } from "../../model/network";
import { PaginatedResource } from "../../model/paginatedResource";

import { ExtrinsicLink } from "../extrinsics/ExtrinsicLink";

import { ButtonLink } from "../ButtonLink";
import { DataViewer } from "../DataViewer";
import { ItemsTable, ItemsTableAttribute } from "../ItemsTable";
import { Link } from "../Link";

import { EventLink } from "./EventLink";

const parametersColCss = (showExtrinsic?: boolean) => css`
width: ${showExtrinsic ? "40%" : "60%"};
Expand Down Expand Up @@ -40,9 +43,7 @@ function EventsTable(props: EventsTableProps) {
<EventsItemsTableAttribute
label="ID"
render={(event) => (
<Link to={`/${network.name}/event/${event.id}`}>
{event.id}
</Link>
<EventLink network={network} id={event.id} />
)}
/>
<EventsItemsTableAttribute
Expand All @@ -61,9 +62,7 @@ function EventsTable(props: EventsTableProps) {
<EventsItemsTableAttribute
label="Extrinsic"
render={(event) => event.extrinsicId && (
<Link to={`/${network.name}/extrinsic/${event.extrinsicId}`}>
{event.extrinsicId}
</Link>
<ExtrinsicLink network={event.network} id={event.extrinsicId} />
)}
/>
)}
Expand Down
9 changes: 4 additions & 5 deletions src/components/extrinsics/ExtrinsicInfoTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import { Resource } from "../../model/resource";

import { encodeAddress } from "../../utils/address";

import { AccountAddress } from "../AccountAddress";
import { AccountAddress } from "../account/AccountAddress";
import { BlockLink } from "../blocks/BlockLink";

import { ButtonLink } from "../ButtonLink";
import { DataViewer } from "../DataViewer";
import { InfoTable, InfoTableAttribute } from "../InfoTable";
import { Link } from "../Link";
import { NetworkBadge } from "../NetworkBadge";
import { Time } from "../Time";

Expand Down Expand Up @@ -62,9 +63,7 @@ export const ExtrinsicInfoTable = (props: ExtrinsicInfoTableProps) => {
<ExtrinsicInfoTableAttribute
label="Block"
render={(data) =>
<Link to={`/${network.name}/block/${data.blockId}`}>
{data.blockHeight}
</Link>
<BlockLink network={network} id={data.blockId} />
}
copyToClipboard={(data) => data.blockHeight.toString()}
/>
Expand Down
21 changes: 21 additions & 0 deletions src/components/extrinsics/ExtrinsicLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Network } from "../../model/network";
import { simplifyExtrinsicId } from "../../services/extrinsicsService";

import { Link } from "../Link";

export interface ExtrinsicLinkProps {
network: Network;
id: string;
}

export const ExtrinsicLink = (props: ExtrinsicLinkProps) => {
const {network, id} = props;

const simplifiedId = simplifyExtrinsicId(id);

return (
<Link to={`/${network.name}/extrinsic/${simplifiedId}`}>
{simplifiedId}
</Link>
);
};
Loading

0 comments on commit 083bb06

Please sign in to comment.