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

Fix: conditions to display "Execute transaction" #3257

Merged
merged 28 commits into from
Jan 14, 2022

Conversation

DiogoSoaress
Copy link
Member

@DiogoSoaress DiogoSoaress commented Jan 6, 2022

What it solves

Resolves #2942

How this PR fixes it

Extracted to a new hook useCanTxExecute the logic to check if a tx can execute.
Display the "Execute transaction" checkbox based on with this logic.

The variables were renamed as:

  • canTxExecute: for hook return
  • shouldExecute: for checkbox state
  • willExecute: for instances where the above two are combined

How to test it

In a single owner Safe, "Execute transaction" checkbox shall display when creating a transaction and

  • There is no tx in the next queue and the tx nonce is equal to the safe nonce

In a multi owner Safe, "Execute transaction" checkbox shall display when:

  • Approving transaction and the number of confirmations meets the Safe threshold

Screenshots

Screen Shot 2022-01-10 at 10 29 12

@github-actions
Copy link

github-actions bot commented Jan 6, 2022

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

github-actions bot commented Jan 6, 2022

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

github-actions bot commented Jan 6, 2022

Deployment links

🟠 Safe Rinkeby Safe Mainnet 🟣 Safe Polygon 🟡 Safe BSC Safe Arbitrum 🟢 Safe xDai

@coveralls
Copy link

coveralls commented Jan 6, 2022

Pull Request Test Coverage Report for Build 1693532428

  • 47 of 141 (33.33%) changed or added relevant lines in 22 files are covered.
  • 6 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.05%) to 32.493%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/routes/safe/components/Settings/UpdateSafeModal/index.tsx 0 1 0.0%
src/routes/safe/components/Transactions/TxList/modals/RejectTxModal.tsx 0 1 0.0%
src/logic/hooks/useGetRecommendedNonce.tsx 13 16 81.25%
src/routes/safe/components/Balances/SendModal/screens/ContractInteraction/ReviewCustomTx/index.tsx 0 3 0.0%
src/routes/safe/components/Transactions/TxList/modals/ApproveTxModal.tsx 0 3 0.0%
src/routes/safe/components/Apps/components/ConfirmTxModal/ReviewConfirm.tsx 4 8 50.0%
src/routes/safe/components/Apps/components/SignMessageModal/ReviewMessage.tsx 2 6 33.33%
src/routes/safe/components/Settings/Advanced/RemoveGuardModal.tsx 2 6 33.33%
src/logic/hooks/useEstimateTransactionGas.tsx 0 5 0.0%
src/routes/safe/components/Settings/Advanced/RemoveModuleModal.tsx 0 6 0.0%
Files with Coverage Reduction New Missed Lines %
src/logic/hooks/useEstimateTransactionGas.tsx 1 15.69%
src/logic/safe/transactions/gas.ts 1 17.31%
src/routes/safe/components/Balances/SendModal/screens/ContractInteraction/ReviewCustomTx/index.tsx 1 0%
src/routes/safe/components/Balances/SendModal/screens/ReviewCollectible/index.tsx 1 0%
src/routes/safe/components/Balances/SendModal/screens/ContractInteraction/Review/index.tsx 2 0%
Totals Coverage Status
Change from base Build 1692167562: 0.05%
Covered Lines: 3163
Relevant Lines: 8685

💛 - Coveralls

@github-actions
Copy link

github-actions bot commented Jan 6, 2022

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

Failed tests:

  • ❌ Safe Apps List Safe Apps List
  • ❌ Read-only transaction creation and review Read-only transaction creation and review

src/logic/hooks/useCanTxExecute.tsx Outdated Show resolved Hide resolved
}

// Review default values
const useCanTxExecute: UseCanTxExecuteType = (preApprovingOwner = '', txConfirmations = 0) => {
Copy link
Member

Choose a reason for hiding this comment

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

Make sure to test this. I am pretty sure we have react-hooks-testing-library installed.

const [canTxExecute, setCanTxExecute] = useState(false)
const nextQueuedTx = useSelector(nextTransactions)
const hasQueueNextTx = nextQueuedTx && Object.keys(nextQueuedTx).length > 0
const { threshold = 1 } = useSelector(currentSafe)
Copy link
Member

Choose a reason for hiding this comment

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

Why would the threshold be undefined?

src/logic/hooks/useCanTxExecute.tsx Outdated Show resolved Hide resolved
src/logic/hooks/useCanTxExecute.tsx Outdated Show resolved Hide resolved
@DiogoSoaress DiogoSoaress marked this pull request as ready for review January 10, 2022 09:30
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, but why do you now have a mix-match of isExecution and canExecute since my last review?

src/logic/hooks/useCanTxExecute.tsx Outdated Show resolved Hide resolved
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.

All looks good but I still find the variable names confusing as it is not consistent. There is a mix match between: canExecute, canTxExecute and isExecution for what you return from useCanTxExecute(). I would name them all canTxExecute as that mirrors the name of the hook.

I think shouldExecute is a good choice for when the execution relies not only on what is returned from useCanTxExecute() but also something else.

  const canTxExecute = useCanTxExecute()
  const shouldExecute = otherFlag && canTxExecute

For clarification: canExecute is used for showing/hiding or enabling/disabling the confirm/reject buttons and isExecution is used extensively in process/createTransaction.

const { threshold } = useSelector(currentSafe)

const safeAddress = extractSafeAddress()
const recommendedNonce = useGetRecommendedNonce(safeAddress) // to be changed. should be txNonce
Copy link
Member

Choose a reason for hiding this comment

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

Can you now remove this comment?

Copy link
Member

@usame-algan usame-algan left a comment

Choose a reason for hiding this comment

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

🚀

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.

LGTM! 🚀

@francovenica
Copy link
Contributor

Issues:

1 - Gas limit is not being calculated for tx with higher nonce. Even tho gas limit is not needed for tx that will not be executed right away, the problem is that if the user decides to change the nonce to the current one he will submit the tx with a gas limit of 0. Currently in dev the gas limit is calculated for all tx, even those with a higher nonce than the current one
image

2 - Switching from future nonce to current nonce and back causes the warning message of "tx might fail" error message to popUp.
Create a tx and leave it in queue
Start the creation of a new tx, it will have current nonce + 1, so it cannot be executed
Edit that nonce to be the current one, the execute button shows up just fine
Edit it once again to be current + 1.
Now a message of "tx might fail" will show up and won't go away
01-12-2022_x(3929)

3 - The confirm icon was replaced with the execute one:
Create a tx in a safe of 3 out of x owners and see the tx
image

This is the Icon that should show there:
image

txEstimationExecutionStatus,
}: TransactionFailTextProps): React.ReactElement | null => {
const { currentVersion: safeVersion = '' } = useSelector(currentSafe)
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 not default the Safe version otherwise it won't calculate the possibility of off chain signing correctly. You should get it from the Safe instance.

@github-actions
Copy link

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

@DiogoSoaress
Copy link
Member Author

Issues:

1 - Gas limit is not being calculated for tx with higher nonce. Even tho gas limit is not needed for tx that will not be executed right away, the problem is that if the user decides to change the nonce to the current one he will submit the tx with a gas limit of 0. Currently in dev the gas limit is calculated for all tx, even those with a higher nonce than the current one image

2 - Switching from future nonce to current nonce and back causes the warning message of "tx might fail" error message to popUp. Create a tx and leave it in queue Start the creation of a new tx, it will have current nonce + 1, so it cannot be executed Edit that nonce to be the current one, the execute button shows up just fine Edit it once again to be current + 1. Now a message of "tx might fail" will show up and won't go away 01-12-2022_x(3929)

3 - The confirm icon was replaced with the execute one: Create a tx in a safe of 3 out of x owners and see the tx image

This is the Icon that should show there: image

@francovenica I've tackled points 1. and 2. the point 3. is fixed in other PR #3283

Please give it another round 🙏

@francovenica
Copy link
Contributor

I have a estrange behavior with a tx I want to sign, the tx is ready for execution, but it triggers a multisig first and then the proper execution modal.
This is the safe, you can try to execute the tx with a non-owner now, and you should see the same behavior
https://pr3257--safereact.review-safe.gnosisdev.com/app/rin:0xFfDC1BcdeC18b1196e7FA04246295DE3A17972Ac/transactions/queue

Gif:
01-13-2022_x(3945)

@DiogoSoaress
Copy link
Member Author

Hey Franco, I am having the same behaviour in DEV and I think we should address it asap. However if it is not related with this issue I suggest it shouldn't block this ticket unless it impedes QAing properly. Let me know

@iamacook
Copy link
Member

I have a estrange behavior with a tx I want to sign, the tx is ready for execution, but it triggers a multisig first and then the proper execution modal.

This seems like quite a major bug that's worthwhile tackling this sprint (as another issue ofc), no?

@francovenica
Copy link
Contributor

Ok, since the issue is in dev we can ignore the issue at least for this PR.

The issues reported were fixed. The gas is estimated for tx creation and playing around with the nonce is not causing the issue with the warning message
Also the icon is now fixed here, so probably the fix was merged, so that's a plus.

@DiogoSoaress DiogoSoaress merged commit 42c2ee6 into dev Jan 14, 2022
@DiogoSoaress DiogoSoaress deleted the hide-execute-checkbox-conditions branch January 14, 2022 16:14
@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2022
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.

Single owner tx execution checkbox shows up when there are tx in queue already
5 participants