feat: add download button to account pages#883
feat: add download button to account pages#883askov wants to merge 16 commits intosolana-foundation:masterfrom
Conversation
|
@askov is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR adds a raw-data download button to token mint, token account, unknown account, and upgradeable program account pages. It replaces the legacy Bootstrap Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant AccountDownloadDropdown
participant useRawAccountData (SWR)
participant DownloadDropdown
participant Solana RPC
User->>AccountDownloadDropdown: mounts (space != 0)
Note over useRawAccountData (SWR): revalidateOnMount: false — no fetch yet
User->>DownloadDropdown: opens dropdown
DownloadDropdown->>AccountDownloadDropdown: onOpenChange(true)
AccountDownloadDropdown->>useRawAccountData (SWR): mutate()
useRawAccountData (SWR)->>Solana RPC: getAccountInfo(address)
Note over DownloadDropdown: shows "Loading hex/base58/base64…" (disabled)
Solana RPC-->>useRawAccountData (SWR): AccountInfo { data: Uint8Array }
useRawAccountData (SWR)-->>AccountDownloadDropdown: rawData = Uint8Array
AccountDownloadDropdown-->>DownloadDropdown: data=rawData, loading=false
Note over DownloadDropdown: shows "Download hex/base58/base64" (enabled)
User->>DownloadDropdown: clicks "Download hex"
DownloadDropdown->>DownloadDropdown: encodeBytes(data, "hex")
DownloadDropdown->>User: triggerDownloadText → .txt file
User->>AccountDownloadDropdown: clicks Refresh button
AccountDownloadDropdown->>useRawAccountData (SWR): mutate(rawAccountDataKey)
Note over useRawAccountData (SWR): invalidates cached raw data
Reviews (7): Last reviewed commit: "fix: overflowing card header buttons" | Re-trigger Greptile |
|
@greptile-apps review please |
|
@greptile-apps please review |
|
@greptile-apps review and update summary |
|
@greptile-apps review please |
|
|
||
| function handleDownload(data: ByteArray, encoding: EncodingFormat, filename: string) { | ||
| const encoded = encodeBytes(data, encoding); | ||
| triggerDownloadText(encoded, `${filename}_${encoding}.txt`); |
There was a problem hiding this comment.
Any of these might cause an unhandled exception. I think having a tooltip here is a good one
There was a problem hiding this comment.
I added a try-catch block, but honestly, I don’t think it makes much sense. This isn't an error we expect, it could be due to malformed data or browser quirks, I guess. There’s not much we can do about it-it's non-actionable.
Using a tooltip for an error is an even more over-engineered approach. A toast notification might make more sense, though. I don't know. Why do you believe there should be some UI feedback?
6307b5b to
38b1732
Compare
|
@greptile-apps review please |
app/tx/[signature]/page-client.tsx
Outdated
| )} | ||
| <span className="me-2"></span> | ||
| <DownloadableDropdown filename={signature} data={rawDetails?.data?.raw?.message.serialize() || null} /> | ||
| <DownloadDropdown filename={signature} data={rawDetails?.data?.raw?.message.serialize()} /> |
There was a problem hiding this comment.
Added (it wasn't there in the original implementation)
| import { AccountDownloadDropdown } from '../AccountDownloadDropdown'; | ||
|
|
||
| const mockMutate = vi.fn(); | ||
| const mockRawData: Buffer | null = null; |
There was a problem hiding this comment.
type should be Uint8Array | undefined
…down and add TODO for shared entity
…or DownloadDropdown
24cb619 to
f5f279b
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@greptile-apps review please |
Description
DropdownMenucomponent and migrate all existing download dropdowns to use it@entities/account,@features/account,app/shared/)Type of change
Screenshots
Testing
pnpm test:ci— new unit tests coveruseAccountsInfo,useRawAccountData, andAccountDownloadDropdownpnpm sb— new Storybook stories forDropdownMenuandDownloadDropdownrender correctlyRelated Issues
A part of HOO-356
Checklist
build:infoscript to update build information