Skip to content
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

feat: SOL-80 transaction details #29323

Merged
merged 47 commits into from
Feb 4, 2025
Merged

feat: SOL-80 transaction details #29323

merged 47 commits into from
Feb 4, 2025

Conversation

zone-live
Copy link
Contributor

@zone-live zone-live commented Dec 18, 2024

Description

This PR adds the new transaction details modal for the non-evm networks, BTC and SOL.

Screenshot 2024-12-18 at 14 42 18

Screen.Recording.2024-12-17.at.12.27.40.mov

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/SOL-80

Manual testing steps

Testing this is a bit extensive, but if you still want to give it a go these are the steps:

  1. Checkout this branch and run yarn
  2. Update the file shared/lib/accounts/solana-wallet-snap.ts with:
    export const SOLANA_WALLET_SNAP_ID: SnapId = 'local:http://localhost:8080' as SnapId;
  3. Update the filtering code in MultichainTransactionsController under node modules to return transactions for devnet, currently only returns for mainnet. It's under node_modules/@metamask/multichain-transactions-controller/dist/MultichainTransactionsController.mjs and node_modules/@metamask/multichain-transactions-controller/dist/MultichainTransactionsController.cjs with:
MultichainNetwork.SolanaDevnet
instead of
MultichainNetwork.Solana

  1. Run the extension with yarn start:flask
  2. Run the Snap: https://github.com/MetaMask/snap-solana-wallet
    • Clone it
    • Run yarn
    • Run yarn start
  3. Go to http://localhost:3000/
  4. Install the Snap
  5. In the extension, go to the Settings > Experimental > Enable Solana account
  6. Create a Solana account from the account-list menu
  7. Fund the new Solana account with some SOL, use a faucet like https://faucet.solana.com/
  8. the initial Tx with funds from the faucet will display in the activity tab
  9. Click in it and you will see the Tx details modal
  10. Thats it! 🎉

Screenshots/Recordings

Before

Didn't exist.

After

Screenshot 2024-12-18 at 14 42 18

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Dec 18, 2024
@metamaskbot metamaskbot removed the INVALID-PR-TEMPLATE PR's body doesn't match template label Dec 18, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [d6d7a16]
Page Load Metrics (1613 ± 64 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14291925161413464
domContentLoaded14211869158812661
load14291918161313464
domInteractive2299472311
backgroundConnect883292210
firstReactRender1574362411
getState55013136
initialActions00000
loadScripts10051404114511455
setupStore85816178
uiStartup16022107183313967
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@zone-live zone-live requested a review from a team as a code owner January 29, 2025 17:32
@zone-live
Copy link
Contributor Author

Screenshot 2025-01-29 at 15 42 04

@metamaskbot
Copy link
Collaborator

Builds ready [3403374]
Page Load Metrics (1800 ± 93 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint28222981734389187
domContentLoaded15352285176419594
load15442291180019493
domInteractive2692442211
backgroundConnect1090392914
firstReactRender1699432713
getState56416157
initialActions00000
loadScripts11131723130417584
setupStore991332613
uiStartup177026372107277133
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

aganglada
aganglada previously approved these changes Jan 30, 2025
aganglada
aganglada previously approved these changes Jan 30, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [6996ee1]
Page Load Metrics (1539 ± 44 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1382176815388641
domContentLoaded1377170815218139
load1381177115399144
domInteractive2394392110
backgroundConnect86621188
firstReactRender1468292010
getState4479126
initialActions01000
loadScripts972128711037536
setupStore757222210
uiStartup1553196417349545
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [684e9b6]
Page Load Metrics (1819 ± 62 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint37720881615512246
domContentLoaded15432076179913464
load15982090181912862
domInteractive2699472713
backgroundConnect96026188
firstReactRender16103432613
getState46316188
initialActions0442105
loadScripts11141578131811555
setupStore75815147
uiStartup177629642127245117
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Contributor

@ccharly ccharly left a comment

Choose a reason for hiding this comment

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

LGTM (I will update the URL handling in another PR, as mentionned in some comments).

I've only tested the storybook part, but the video shows everything and the storybook displays properly.

* @param chainId - Network chain ID
* @returns Full URL to transaction in block explorer, or empty string if no explorer URL
*/
export const getTransactionUrl = (txId: string, chainId: string): string => {
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed internally, I think this kind of logic will not scale well in the future.

I have prepared another PR that will use format-strings instead to build block explorer URLs:

I'll make the changes to support transactions once we have merged this PR!

* @param chainId - Network chain ID
* @returns Full URL to address in block explorer, or empty string if no explorer URL
*/
export const getAddressUrl = (address: string, chainId: string): string => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.


// It's typical for Solana timestamps to use seconds, while JS Dates and most EVM chains use milliseconds.
// Hence we needed to use the conversion `timestamp < 1e12 ? timestamp * 1000 : timestamp` for it to work.
const timestampMs = timestamp < 1e12 ? timestamp * 1000 : timestamp;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since timestamps must be UNIX timestamp, they should be using "seconds" already, so I think we should just use timestamp * 1000.

However, since only the Solana Snap implements this for now, I'll keep it as is and we will revisit this later once we have stabilized everything!

it('shows transaction ID in shortened format', () => {
renderComponent();
const txId = mockTransaction.id;
const shortenedTxId = screen.getByText(shortenAddress(txId));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: But this should have been shortenTransactionId here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add in an other PR

@zone-live zone-live added this pull request to the merge queue Feb 4, 2025
Merged via the queue into main with commit 86334eb Feb 4, 2025
71 checks passed
@zone-live zone-live deleted the SOL-80-transaction-details branch February 4, 2025 12:40
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2025
@metamaskbot metamaskbot added the release-12.13.0 Issue or pull request that will be included in release 12.13.0 label Feb 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.13.0 Issue or pull request that will be included in release 12.13.0 team-sol PRs from the Solana snap team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants