Skip to content

Commit

Permalink
fix: always truncate transaction addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
williamluke4 committed Nov 15, 2023
1 parent cf44bb9 commit 717d7db
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/components/address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import { truncateEthAddress } from "~/utils/dmr-helpers";
interface IAddressProps {
address?: string;
className?: string;
shrink?: boolean;
truncate?: boolean;
forceTruncate?: boolean;
}

function Address(props: IAddressProps) {
const md = useBreakpoint("lg");
const address =
md.isBelowLg && props.shrink
( md.isBelowLg && props.truncate || props.forceTruncate)
? truncateEthAddress(props.address)
: props.address;
return (
Expand Down
8 changes: 6 additions & 2 deletions src/components/tables/transactions-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ export function TransactionsTable({
{
accessorKey: "sender_address",
header: "Sender",
cell: (info) => <Address address={info.getValue<string>()} shrink />,
cell: (info) => (
<Address address={info.getValue<string>()} truncate />
),
},
{
accessorKey: "recipient_address",
header: "Recipient",
cell: (info) => <Address address={info.getValue<string>()} shrink />,
cell: (info) => (
<Address address={info.getValue<string>()} truncate />
),
},
{
accessorKey: "tx_value",
Expand Down
2 changes: 1 addition & 1 deletion src/components/transactions/transaction-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const TransactionListItem = (props: TransactionProps) => {
</Avatar>
<div className="flex-1 flex-col">
<div className="flex">
<Address shrink address={address} />
<Address forceTruncate address={address} />
{props.tx.success ? null : (
<span className="ml-3 text-xs rounded-full text-white px-2 py-1 bg-red-500">
FAILED
Expand Down
4 changes: 2 additions & 2 deletions src/components/users/tables/staff-users-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function StaffUsersTable() {
accessorKey: "interface_identifier",
cell: (info) =>
isAddress(info.getValue<string>()) ? (
<Address address={info.getValue<string>()} shrink />
<Address address={info.getValue<string>()} truncate />
) : (
info.getValue<string>()
),
Expand Down Expand Up @@ -128,7 +128,7 @@ export function StaffUsersTable() {
accessorKey: "blockchain_address",
cell: (info) =>
isAddress(info.getValue<string>()) ? (
<Address address={info.getValue<string>()} shrink />
<Address address={info.getValue<string>()} truncate />
) : (
info.getValue<string>()
),
Expand Down

1 comment on commit 717d7db

@vercel
Copy link

@vercel vercel bot commented on 717d7db Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.