Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions app/components/account/history/TransactionHistoryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function TransactionHistoryCard({ address }: { address: string }) {

const hasTimestamps = transactionRows.some(element => element.blockTime);
const detailsList: React.ReactNode[] = transactionRows.map(
({ slot, signature, blockTime, statusClass, statusText }) => {
({ slot, signature, blockTime, statusClass, statusText, signatureInfo }) => {
return (
<tr key={signature}>
<td>
Expand All @@ -73,7 +73,7 @@ export function TransactionHistoryCard({ address }: { address: string }) {
</td>
</>
)}

<td>{signatureInfo.memo ? <MemoField memo={signatureInfo.memo} /> : '---'}</td>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: the memo is grey to match the other columns, but --- is white. I suppose it is better to use the same styles

<td>
<span className={`badge bg-${statusClass}-soft`}>{statusText}</span>
</td>
Expand Down Expand Up @@ -101,6 +101,7 @@ export function TransactionHistoryCard({ address }: { address: string }) {
<th className="text-muted w-1">Timestamp</th>
</>
)}
<th className="text-muted">Memo</th>
<th className="text-muted">Result</th>
<th className="text-muted">Raw Data</th>
</tr>
Expand Down Expand Up @@ -131,3 +132,33 @@ function TransactionRawDataDownloadField({ signature }: { signature: string }) {
</div>
);
}

function MemoField({ memo }: { memo: string }) {
const [showTooltip, setShowTooltip] = React.useState(false);
const truncateLength = 25;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we have this at the props with 25 as the default value?

// Remove memo length like "[15] " from the memo for display (handles all occurrences)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the newer master, we have a rule to explicitly state the reason for regexps. That line would fail after merging.

I propose something like:

// eslint-disable-next-line no-restricted-syntax -- Solana RPC prepends `[length] ` to memo strings in getSignaturesForAddress responses; strip for display 

const cleanMemo = memo.replace(/\[\d+\]\s*/g, '').trim();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we really need to replace all the occurrences in the Memo? What if this [N] format is selected by anyone for verification, for example

const isTruncated = cleanMemo.length > truncateLength;
const displayText = isTruncated ? `${cleanMemo.slice(0, truncateLength)}...` : cleanMemo;

return (
<div
className="popover-container"
onMouseOver={() => isTruncated && setShowTooltip(true)}
onMouseOut={() => setShowTooltip(false)}
style={{ cursor: isTruncated ? 'pointer' : 'default' }}
>
<Copyable text={cleanMemo}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thought: Why not to allow copying the original memo?

<span className="text-muted">{displayText}</span>
</Copyable>
{showTooltip && (
<div className="popover bs-popover-top show" style={{ maxWidth: '20rem' }}>
<div className="arrow" />
<div className="popover-body" style={{ wordBreak: 'break-word' }}>
{cleanMemo}
</div>
</div>
)}
</div>
);
}
1 change: 1 addition & 0 deletions app/scss/dashkit/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ $container-max-widths: (
md: 720px,
lg: 960px,
xl: 1140px,
xxl: 1400px,
) !default;
/* beautify ignore:end */

Expand Down