Explorer Account page revamp: Balances, Summary and Assets - #1245
Conversation
adfe2d8 to
0384079
Compare
| @@ -28,3 +28,6 @@ VITE_DATA_URL=https://data.xrpl.org/v1/network | |||
| # Whether to use ws instead of wss (boolean) | |||
| # Only used locally (the deployed Explorer requires wss) | |||
| VITE_INSECURE_WS=0 | |||
|
|
|||
| # LOS Endpoint URL | |||
| VITE_LOS_URL=https://los.dev.ripplex.io | |||
There was a problem hiding this comment.
nit: could we update the example to the prod url just in the rare case that someone tries to use it?
There was a problem hiding this comment.
For testing purpose, I think dev endpoint should be sufficient. In general, it's not a good idea to expose prod endpoint even though we have DDoS protection in place.
| cursor: default; | ||
|
|
||
| .clock-icon { | ||
| width: px; |
There was a problem hiding this comment.
nit: looks like there is a missing px value
| const fetchAccountHeldIOUs = async ( | ||
| rippledSocket: any, | ||
| accountId: string, | ||
| ): Promise<IOU[]> => { | ||
| let balancesResponse | ||
| try { | ||
| balancesResponse = await getBalances(rippledSocket, accountId) | ||
| } catch (error) { | ||
| log.error( | ||
| `Error calling 'gatewayBalances' for account ${accountId}: ${JSON.stringify(error)}`, | ||
| ) | ||
| return [] | ||
| } |
There was a problem hiding this comment.
I've seen these types of functions saved in the rippled folder in this repo. I don't feel strongly here but might be worth adding this there and importing for consistency
There was a problem hiding this comment.
getBalances is defined in rippled/. Here, we have a special use case of finding held IOUs from the response of getBalances. I don't think it's generic enough, unlike getBalances, to be in rippled/`
| for (const issuer of uniqueIssuers) { | ||
| try { | ||
| // eslint-disable-next-line no-await-in-loop | ||
| const accountInfo = await getAccountInfo(rippledSocket, issuer, false) | ||
|
|
||
| const transferFee = formatTransferFee(accountInfo?.TransferRate, 'IOU') | ||
|
|
There was a problem hiding this comment.
could some sort of parallelism here save time? not sure how long this process takes currently from a UI experience
There was a problem hiding this comment.
Based on my tests, parallel requests quickly get throttled by Clio. It’s fine to make these calls sequentially here: we display the Held IOU table with other fields almost immediately, then fetch the transfer fee and frozen status one by one, updating the columns as the data arrives. From the user’s perspective, the table shows up immediately, so the experience isn’t blocked.
| account={token.issuer} | ||
| shortAccount={shortenAccount(token.issuer)} |
There was a problem hiding this comment.
nit: passing both of these in seems redundant?
There was a problem hiding this comment.
It's not redundant since the caller of <Account /> can pass in a short version of account, e.g., rK2Y8ng...ZkyFm or an issuer name like Ripple as shortAccount. I will rename shortAccount to displayText since issuer name like Ripple is definitely not a short account.
| <td> | ||
| <FutureDataIcon /> | ||
| </td> |
There was a problem hiding this comment.
how come we are unable to provide the usd prices right now?
There was a problem hiding this comment.
Unlike IOU, MPT isn't being traded on the ledger at the moment. We need to have MPT DEX in mainnet so that MPT can be traded. Only after that will we have an MPT price in XRP and USD.
| log.error( | ||
| `Error fetching offers for NFT ${nft.nftId}: ${JSON.stringify(error)}`, | ||
| ) |
There was a problem hiding this comment.
should we add retry mechanisms here? or would a page reload be sufficient
There was a problem hiding this comment.
Based on my tests, we don't need a retry for now since I have tested some accounts with large number of tokens and I don't see any throttle. I plan to add retry as a follow-up.
| export const formatUsdBalance = (balance: number, lang: string): string => { | ||
| if (balance === 0) { | ||
| return '--' | ||
| } | ||
|
|
||
| let options | ||
| if (balance >= 1) { | ||
| options = USD_CURRENCY_OPTIONS | ||
| } else if (balance >= 0.0001) { | ||
| options = USD_SMALL_BALANCE_CURRENCY_OPTIONS | ||
| } else { | ||
| options = USD_EXTRA_SMALL_BALANCE_CURRENCY_OPTIONS | ||
| } |
There was a problem hiding this comment.
I do believe there are exisitng utils in this repo to display amounts, were you able to try those / is this logic significantly different?
There was a problem hiding this comment.
You’re right — we already have localizeNumber, and the functions in this file use it under the hood. However, I’ve added some custom logic, after discussed with Julian, to control how many decimals we display for different prices and balances. We can also update the Token and Token Ranking pages to use these functions for consistency.
Here’s the custom logic:
Token balance:
- If the balance is greater than
999, keep 2 decimals (e.g.,100,001.94) - If the balance is less than or equal to
999, keep 2 to 4 decimals, (e.g.,151.194)
USD price or balance:
- If the value is greater than
1, keep at most 2 decimals (e.g.,$1.02). - If the value is between
0.0001and1, keep 2–4 decimals (e.g.,$0.004,$0.02). - If the value is less than
0.0001, keep up to 10 decimals (e.g.,$0.00004).
achowdhry-ripple
left a comment
There was a problem hiding this comment.
Great job with this, was a large change and looks very clean! Mainly small questions and nits, and main concern is over the large number of api calls and the lack of parallelism/retries. Not a big issue though, seems like it works great overall but I would be curious to understand more there.
… `index.tsx` component
…eact Testing Library
b182c1c to
60db069
Compare
achowdhry-ripple
left a comment
There was a problem hiding this comment.
thanks for addressing the comments, lgtm!
…ogressively add non-LP tokens starting with 03 after confirming they aren’t LP tokens.
88cef2b to
e9debef
Compare
…USD after a `03` token is added to the table
High Level Overview of Change
Refactoring the Explorer Account page
Context of Change
The current XRPL Explorer Account page provides functional access to raw ledger data and transaction history, but lacks the clarity, structure, and usability expected by both casual users and developers. Key information—such as account properties, AMM participation, trustlines, and assets held/issued—is presented in a fragmented way, making it difficult to interpret an account's status, asset relationships, and overall activity at a glance.
This is a revamp of the Explorer Account page to deliver a more organized, performant, and informative experience.
Type of Change
Codebase Modernization
Before / After
Before - Account Information and XRP Balance
After - Account Information and XRP Balance
Before - Account Assets
After - Account Assets
Test Plan