Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Adapt TxParametersDetail to display a future safeNonce #2982

Merged
merged 12 commits into from
Nov 15, 2021

Conversation

DiogoSoaress
Copy link
Member

@DiogoSoaress DiogoSoaress commented Nov 10, 2021

What it solves

Resolves #2904

How this PR fixes it

When the user edits the transaction params and sets a safeNonce greater than the current nonce

How to test it

On creating transaction "Review" step, edit the safeNonce to be greater than the current one.
Then:

  • the gas estimate area is replaced with error copy
  • the advanced menu has been expanded
  • the offending nonce is highlighted red.
  • updated warning copy

Screenshots

Screen Shot 2021-11-12 at 14 46 51

@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

github-actions bot commented Nov 10, 2021

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 2 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@github-actions
Copy link

@coveralls
Copy link

coveralls commented Nov 10, 2021

Pull Request Test Coverage Report for Build 1462197080

  • 15 of 17 (88.24%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 31.68%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/routes/safe/components/Transactions/helpers/TxParametersDetail/index.tsx 9 11 81.82%
Totals Coverage Status
Change from base Build 1453880886: 0.1%
Covered Lines: 2985
Relevant Lines: 8383

💛 - Coveralls

@github-actions
Copy link

github-actions bot commented Nov 10, 2021

E2E Tests Passed
Check the results here: https://github.com/gnosis/safe-react-e2e-tests/actions/runs/1462223974

@DiogoSoaress DiogoSoaress marked this pull request as ready for review November 11, 2021 18:19
@DiogoSoaress DiogoSoaress marked this pull request as draft November 11, 2021 18:26
@DiogoSoaress DiogoSoaress marked this pull request as ready for review November 11, 2021 18:45
@DiogoSoaress DiogoSoaress marked this pull request as draft November 12, 2021 06:42
@DiogoSoaress DiogoSoaress marked this pull request as ready for review November 12, 2021 13:47
Copy link
Member

@iamacook iamacook left a comment

Choose a reason for hiding this comment

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

Looking good. I have a few questions and found a few places you can improve

isCreation,
isExecution,
isOffChainSignature,
safeNonce,
Copy link
Member

Choose a reason for hiding this comment

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

Assign a default value here and then you won't need to use a fallback on line 26.

{transactionsToGo}
</Text>
{` transaction${
transactionsToGo > 1 ? 's' : ''
Copy link
Member

Choose a reason for hiding this comment

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

Nice perfectionism 😉

@@ -4,7 +4,7 @@ import { getNetworkInfo } from 'src/config'
import { TransactionFailText } from 'src/components/TransactionFailText'
import { Text } from '@gnosis.pm/safe-react-components'

type TransactionFailTextProps = {
export type TransactionFailTextProps = {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how we approach exporting types. I would use my Parameters<typeof TransactionFees>[0] trick instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you are right. Works like a charm 👌

txEstimationExecutionStatus={txEstimationExecutionStatus}
/>
</div>
<ReviewInfoText
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove the class here?

txEstimationExecutionStatus={txEstimationExecutionStatus}
/>
</Block>
<ReviewInfoText
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove the and class here?

const threshold = useSelector(currentSafeThreshold) || 1
const defaultParameterStatus = isOffChainSignature && threshold > 1 ? 'ETH_HIDDEN' : 'ENABLED'

const { safeNonce } = txParameters
Copy link
Member

Choose a reason for hiding this comment

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

Assign a default here and you will not have to use a fallback?

const threshold = useSelector(currentSafeThreshold) || 1
const defaultParameterStatus = isOffChainSignature && threshold > 1 ? 'ETH_HIDDEN' : 'ENABLED'

const { safeNonce } = txParameters
const isSafeNonceFuture = parseInt(safeNonce || '', 10) > nonce
const [isAccordionExpanded, setIsAccordionExpanded] = useState(isSafeNonceFuture)
Copy link
Member

Choose a reason for hiding this comment

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

You should strictly type this.

if (!isTransactionExecution && !isTransactionCreation && isOffChainSignature) {
return null
}

const onChangeExpand = () => {
setIsAccordionExpanded(!isAccordionExpanded)
Copy link
Member

Choose a reason for hiding this comment

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

Here it should be fine, but you should normally use the previous state value by means of a callback.

const transactionsToGo = parseInt(safeNonce || '', 10) - nonce

return (
<ReviewInfoTextWrapper data-testid={testId}>
Copy link
Member

Choose a reason for hiding this comment

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

You're missing the styling that seems to have been applied everywhere else here.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we are talking about the

padding: ${sm} ${lg}

That's why I've passed that styling to the to the ReviewInfoTextWrapper styled component.

Thats why I also removed some of the wrapping elements/classes across the Modals as they were repeating this same css property but dispersed across the codebase.

Copy link
Member

Choose a reason for hiding this comment

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

No, I mean in reference to all of my other comments regarding classes.

@@ -154,12 +153,13 @@ export const RemoveGuardModal = ({ onClose, guardAddress }: RemoveGuardModalProp
isOffChainSignature={isOffChainSignature}
/>
</Block>
<Row className={cn(classes.modalDescription, classes.gasCostsContainer)}>
<TransactionFees
<Row className={classes.modalDescription}>
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove the <Row> and class here?

@DiogoSoaress
Copy link
Member Author

I check the and components before removing them. They basically wrap the children prop inside a div. I also verified that I was not getting rid of any particular styling before removing the gasCostsContainer class in the elements.
From my testing the modals are rendered like before but please let me know if it was unnecessary.
The aim was to unify the same wrapping style for the <ReviewInfoText /> inside that component.

@iamacook
Copy link
Member

I check the and components before removing them. They basically wrap the children prop inside a div. I also verified that I was not getting rid of any particular styling before removing the gasCostsContainer class in the elements. From my testing the modals are rendered like before but please let me know if it was unnecessary. The aim was to unify the same wrapping style for the <ReviewInfoText /> inside that component.

Some were <div>s but there were also <Block>s and <Rows>s. Were all of the gasCostsContainers the same stylistically?

@DiogoSoaress
Copy link
Member Author

Yes, all the gasCostsContainers were applying the same styles: background and padding. All referring to the same Modal section.
I think it is way more manageable now and this section should have a unified look

@francovenica
Copy link
Contributor

Works fine, a small detail:
The snapshot in the original issue 2904 has also the text in red
image

@DiogoSoaress
Copy link
Member Author

@francovenica I've fixed it! I also made sure that the Advanced Options section is extended when we enter the Review step with a suggested safe nonce in the future (before it was only opening after you edit).

@francovenica
Copy link
Contributor

Looks good to me.
I like the idea of displaying the advanced options if they have to change the nonce.

@DiogoSoaress DiogoSoaress merged commit 434fa9f into dev Nov 15, 2021
@DiogoSoaress DiogoSoaress deleted the safenonce-out-of-order-warning branch November 15, 2021 12:58
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ask user confirmation when using a safeNonce out of order
4 participants