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

fix: notification detail network fee broke application #25315

Merged

Conversation

Prithpal-Sooriya
Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Jun 14, 2024

Description

Yeah, due to some type assertions (evil), we did not receive a correct value expected. Due to this we ended up performing a .split on an undefined... then crash.

This adds some safer logic and also fixes the area that call the function with the wrong inputs.

A separate PR will be ready that fixes these bad type assertions.

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Create a MATIC send/receive notification
  2. Open details
  3. See crash

Screenshots/Recordings

image

Before

After

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.

@Prithpal-Sooriya Prithpal-Sooriya requested a review from a team as a code owner June 14, 2024 10:52
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.

@@ -27,7 +27,7 @@ export const NotificationDetailBlockExplorerButton = ({

const chainIdHex = decimalToHex(chainId);
const { nativeBlockExplorerUrl } = getNetworkDetailsByChainId(
`0x${chainId}` as keyof typeof CHAIN_IDS,
`0x${chainIdHex}` as keyof typeof CHAIN_IDS,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function was not using correct input.

I blame the type assertions - will fix and remove these type assertions in a future PR.

Comment on lines +304 to +305
NETWORK_TO_NAME_MAP[chainId as keyof typeof NETWORK_TO_NAME_MAP] ?? '';
const nativeCurrencyName = fullNativeCurrencyName.split(' ')[0] ?? '';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Safeguards to prevent the .split issue.

I do want us to revisit this function in a future PR to make sure all other mappers are safe too.


// If rpc is found, return its URL. Otherwise, return a default URL based on the chainId.
if (rpc) {
return rpc.rpcUrl;
}
// Fallback RPC URLs based on the chainId
switch (chainId) {
case 'MAINNET':
case CHAIN_IDS.MAINNET:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same issue! Above we gave a bad/false type of keyof typeof CHAIN_IDS which is the keys. We actually want to test against the values/hex numbers of the chains.

@Prithpal-Sooriya Prithpal-Sooriya added the team-notifications Notifications team label Jun 14, 2024
Copy link
Contributor

@matteoscurati matteoscurati left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 16.66667% with 10 lines in your changes missing coverage. Please review.

Project coverage is 65.70%. Comparing base (b7d7a34) to head (bf75bbd).

Files Patch % Lines
ui/helpers/utils/notification.util.ts 16.67% 10 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #25315   +/-   ##
========================================
  Coverage    65.69%   65.70%           
========================================
  Files         1377     1377           
  Lines        54624    54622    -2     
  Branches     14314    14316    +2     
========================================
+ Hits         35884    35885    +1     
+ Misses       18740    18737    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Prithpal-Sooriya
Copy link
Contributor Author

I will add code coverage in a followup PR that tidies up types and functions.
This is mainly for the v12 branch

@metamaskbot
Copy link
Collaborator

Builds ready [bf75bbd]
Page Load Metrics (46 ± 3 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint62897684
domContentLoaded9141021
load39614673
domInteractive9131021
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 94 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@Prithpal-Sooriya Prithpal-Sooriya merged commit 0d32814 into develop Jun 14, 2024
99 of 100 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the NOTIFY-751-qa-gas-network-fee-keeps-failing branch June 14, 2024 11:26
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2024
@metamaskbot metamaskbot added the release-12.1.0 Issue or pull request that will be included in release 12.1.0 label Jun 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.1.0 Issue or pull request that will be included in release 12.1.0 team-notifications Notifications team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants