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(ReviewTransaction): add new review component to SendConfirmation #6436

Merged
merged 31 commits into from
Jan 27, 2025

Conversation

sviderock
Copy link
Contributor

Description

This PR adds new ReviewTransaction component to the SendConfirmation.

Test plan

Fixed existing tests.

Related issues

Relates to RET-1295

Backwards compatibility

Yes

If a new NetworkId and/or Network are added in the future, the changes in this PR will:

  • Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.

Project coverage is 89.11%. Comparing base (f34cfbe) to head (7b12103).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/send/SendConfirmation.tsx 94.59% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #6436   +/-   ##
=======================================
  Coverage   89.11%   89.11%           
=======================================
  Files         733      731    -2     
  Lines       31907    31859   -48     
  Branches     6099     6082   -17     
=======================================
- Hits        28433    28391   -42     
+ Misses       3427     3422    -5     
+ Partials       47       46    -1     
Files with missing lines Coverage Δ
src/account/utils.ts 100.00% <100.00%> (ø)
src/components/Avatar.tsx 100.00% <100.00%> (ø)
src/recipients/recipient.ts 78.90% <100.00%> (ø)
src/send/SendConfirmation.tsx 94.44% <94.59%> (-1.39%) ⬇️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f34cfbe...7b12103. Read the comment docs.

@sviderock sviderock force-pushed the slava/add-new-review-to-send-flow branch from bcc174b to 6e3b7d9 Compare January 24, 2025 14:26
Base automatically changed from slava/add-total-value-to-review to main January 24, 2025 15:05
Copy link
Collaborator

@kathaypacific kathaypacific left a comment

Choose a reason for hiding this comment

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

looking great!

"bottom": "additive",
"left": "additive",
"right": "additive",
"bottom": "off",
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we remove the test that generates this snapshot? snapshot tests are particularly ineffective in a refactor like this

Copy link
Contributor Author

@sviderock sviderock Jan 27, 2025

Choose a reason for hiding this comment

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

Sure, I didn't know removal of snapshots are allowed! (assumed there was a reason for existing ones to be present considering that there are only a few of those)

Copy link
Contributor Author

@sviderock sviderock Jan 27, 2025

Choose a reason for hiding this comment

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

@kathaypacific further down the line, should I also remove snapshots if any other changes for other tasks involve updating snapshot? Or should that decision depend on the task/component?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes please remove any snapshots tests going forward that are not adding any value! ideally we want to replace all snapshot tests but sometimes you don't want to get bogged down with rewriting tests, so it depends on the task. but any suite where it looks like there's coverage over the main functionality already, please feel free to delete the snapshots tests

)

expect(queryByTestId('RecipientAddress')).toBeFalsy()
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we backfill on some tests about what is rendered? i know there are unit tests for the components that are used, but tests here would help to ensure that the components are used correctly

Copy link
Collaborator

Choose a reason for hiding this comment

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

(this doesn't have to be elaborate btw, but one test that asserts that a happy scenario is rendered might be helpful?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course! My understanding was that if the current tests were enough for the existing screen - they should be fine for the new one, considering that it is basically just a redesign. So I removed the tests that are now covered with the reusable component.
But I see the point as it totally makes sense to ensure that all of the old and new pieces are rendered correctly. Will do!

const walletAddress = useSelector(walletAddressSelector)
const feeCurrencies = useSelector((state) => feeCurrenciesSelector(state, tokenInfo!.networkId))

const dispatch = useDispatch()
const { maxFeeAmount, feeCurrency: feeTokenInfo } =
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we please double check whether we want to be showing the maxFeeAmount or the estimatedFeeAmount? this doesn't matter so much on most networks but when transacting on Ethereum, this could make a big difference. on the designs i see that we are using the approx symbol so i guess that we want to show estimatedFeeAmount...

Copy link
Contributor Author

@sviderock sviderock Jan 27, 2025

Choose a reason for hiding this comment

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

What's the best way for me to check this? Considering that this is the same value that was used for all this time I presumed that this was an intended way (as it wouldn't ever be the case that we estimated some X value and but it appeared to be bigger once the transaction was completed). Should I check it out with Kayla or Laura?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes perhaps this is a detail we can check separately, i can help to start a thread in figma. for context, we discussed this at length with swaps because we saw the max vs estimated gas fees differed by $20-60USD at times on Ethereum, of course this depends on the gas price and usd price of ETH on the day but this is why we decided to show estimated value rather than max for swaps (and show the max in the bottom sheet instead)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I'll pick it up from there and will re-post the final decision here for visibility!

token: formatValueToDisplay(tokenFeeAmount),
local: localFeeAmount ? formatValueToDisplay(localFeeAmount) : undefined,
}),
[localFeeAmount, tokenFeeAmount, feeTokenInfo]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
[localFeeAmount, tokenFeeAmount, feeTokenInfo]
[localFeeAmount, tokenFeeAmount]

i wonder if this variable is necessary given that we only use it in one place below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgot to remove after the last changes to this variable. Will remove!

@@ -174,124 +138,101 @@ function SendConfirmation(props: Props) {
tokenId,
usdAmount,
recipient,
fromModal,
// TODO remove fromModal from `sendPayment`
false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this break any existing flows? taking a quick look i think it affects how the navigation works after the transaction is finished, perhaps it is worth keeping this variable and renaming it instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I was looking at it I thought that once the modal is removed then we'll always redirect the user to the home page (cause now its a separate screen and not the overlay modal). But you're right, I misunderstood it. It's not as much related to whether its overlay or separate screen but more to the aspect of whether its a request from a DAPP that expects you to get back to it once you press back button instead of being redirected to the home screen (in this case bidali and it's also the only thing using this different redirect).

I will adjust the name of the screen in Screens and rename all the related arguments/variable.

Copy link
Contributor Author

@sviderock sviderock Jan 27, 2025

Choose a reason for hiding this comment

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

@kathaypacific I've reverted this change for this PR. It will not disrupt the existing flows anymore but the naming change will involve renaming all the occurrences of the screen name and fromModal argument which will add ~10 extra files changes + update of RootStateSchema so I would suggest committing renames in the follow-up PR, would you agree?

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh yes totally, makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kathaypacific here's the PR for the renaming!

: undefined
}
<ReviewTransaction
title="Review Send"
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this use translations?

{tokenInfo && (
<ReviewSummaryItem
testID="SendConfirmationToken"
label="Sending"
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this use translations?

<ReviewDetailsItem
testID="SendConfirmationNetwork"
label={t('transactionDetails.network')}
value={tokenInfo && NETWORK_NAMES[tokenInfo.networkId]}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
value={tokenInfo && NETWORK_NAMES[tokenInfo.networkId]}
value={NETWORK_NAMES[tokenInfo.networkId]}

Copy link
Collaborator

@kathaypacific kathaypacific left a comment

Choose a reason for hiding this comment

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

🚀✨

@sviderock sviderock added this pull request to the merge queue Jan 27, 2025
Merged via the queue into main with commit dcac9cf Jan 27, 2025
15 checks passed
@sviderock sviderock deleted the slava/add-new-review-to-send-flow branch January 27, 2025 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants