-
Notifications
You must be signed in to change notification settings - Fork 363
Fix: conditions to display "Execute transaction" #3257
Conversation
CLA Assistant Lite All Contributors have signed the CLA. |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
Deployment links
|
E2E Tests Failed Failed tests:
|
src/logic/hooks/useCanTxExecute.tsx
Outdated
} | ||
|
||
// Review default values | ||
const useCanTxExecute: UseCanTxExecuteType = (preApprovingOwner = '', txConfirmations = 0) => { |
There was a problem hiding this comment.
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.
src/logic/hooks/useCanTxExecute.tsx
Outdated
const [canTxExecute, setCanTxExecute] = useState(false) | ||
const nextQueuedTx = useSelector(nextTransactions) | ||
const hasQueueNextTx = nextQueuedTx && Object.keys(nextQueuedTx).length > 0 | ||
const { threshold = 1 } = useSelector(currentSafe) |
There was a problem hiding this comment.
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/routes/safe/components/Apps/components/ConfirmTxModal/ReviewConfirm.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Balances/SendModal/screens/ContractInteraction/Review/index.tsx
Outdated
Show resolved
Hide resolved
...utes/safe/components/Balances/SendModal/screens/ContractInteraction/ReviewCustomTx/index.tsx
Show resolved
Hide resolved
src/routes/safe/components/Balances/SendModal/screens/ReviewCollectible/index.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Balances/SendModal/screens/ReviewSendFundsTx/index.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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/routes/safe/components/Transactions/TxList/TxCollapsedActions.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
.
src/logic/hooks/useCanTxExecute.tsx
Outdated
const { threshold } = useSelector(currentSafe) | ||
|
||
const safeAddress = extractSafeAddress() | ||
const recommendedNonce = useGetRecommendedNonce(safeAddress) // to be changed. should be txNonce |
There was a problem hiding this comment.
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?
src/routes/safe/components/Apps/components/ConfirmTxModal/ReviewConfirm.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Apps/components/SignMessageModal/ReviewMessage.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Balances/SendModal/screens/ContractInteraction/Review/index.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Settings/Advanced/RemoveModuleModal.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Settings/SpendingLimit/NewLimitModal/Review.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Settings/SpendingLimit/RemoveLimitModal.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Settings/ThresholdSettings/ChangeThreshold/index.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Transactions/TxList/modals/RejectTxModal.tsx
Outdated
Show resolved
Hide resolved
src/routes/safe/components/Apps/components/ConfirmTxModal/ReviewConfirm.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
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 2 - Switching from future nonce to current nonce and back causes the warning message of "tx might fail" error message to popUp. 3 - The confirm icon was replaced with the execute one: |
txEstimationExecutionStatus, | ||
}: TransactionFailTextProps): React.ReactElement | null => { | ||
const { currentVersion: safeVersion = '' } = useSelector(currentSafe) |
There was a problem hiding this comment.
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.
ESLint Summary View Full Report
Report generated by eslint-plus-action |
@francovenica I've tackled points 1. and 2. the point 3. is fixed in other PR #3283 Please give it another round 🙏 |
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. |
Hey Franco, I am having the same behaviour in |
This seems like quite a major bug that's worthwhile tackling this sprint (as another issue ofc), no? |
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 |
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 returnshouldExecute
: for checkbox statewillExecute
: for instances where the above two are combinedHow to test it
In a single owner Safe, "Execute transaction" checkbox shall display when creating a transaction and
nonce
is equal to thesafe nonce
In a multi owner Safe, "Execute transaction" checkbox shall display when:
Screenshots