-
Notifications
You must be signed in to change notification settings - Fork 576
feat: add memo to transaction history #829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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> | ||
|
|
@@ -73,7 +73,7 @@ export function TransactionHistoryCard({ address }: { address: string }) { | |
| </td> | ||
| </> | ||
| )} | ||
|
|
||
| <td>{signatureInfo.memo ? <MemoField memo={signatureInfo.memo} /> : '---'}</td> | ||
| <td> | ||
| <span className={`badge bg-${statusClass}-soft`}>{statusText}</span> | ||
| </td> | ||
|
|
@@ -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> | ||
|
|
@@ -131,3 +132,33 @@ function TransactionRawDataDownloadField({ signature }: { signature: string }) { | |
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function MemoField({ memo }: { memo: string }) { | ||
| const [showTooltip, setShowTooltip] = React.useState(false); | ||
| const truncateLength = 25; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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}> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
| ); | ||
| } | ||
There was a problem hiding this comment.
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