Skip to content

fix: fixing when the dangerous warning is presented [PERA-3786]#198

Open
fmsouza wants to merge 9 commits intomainfrom
fmsouza/pera-3786
Open

fix: fixing when the dangerous warning is presented [PERA-3786]#198
fmsouza wants to merge 9 commits intomainfrom
fmsouza/pera-3786

Conversation

@fmsouza
Copy link
Contributor

@fmsouza fmsouza commented Mar 13, 2026

Pull Request Template

Description

  • Makes sure to only show the "dangerous action" warning on the Review Transaction bottom sheet when:
    • it's a rekey transaction
    • it's a close transaction from an user wallet

Related Issues

Checklist

  • Have you tested your changes locally?
  • Have you reviewed the code for any potential issues?
  • Have you documented any necessary changes in the project's documentation?
  • Have you added any necessary tests for your changes?
  • Have you updated any relevant dependencies?

Additional Notes

  • Add any additional notes or comments that may be helpful for reviewers.

@fmsouza fmsouza requested review from wjbeau and yasincaliskan March 13, 2026 14:35
@fmsouza fmsouza self-assigned this Mar 13, 2026
Copy link
Contributor

@wjbeau wjbeau left a comment

Choose a reason for hiding this comment

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

I think this PR duplicates some existing logic. In useSigningRequestAnalysis we have some of this same functionality for the same purpose. Feels like we should unify this, and I guess this overlaps wiht the work @yasincaliskan is doing too?

@wjbeau
Copy link
Contributor

wjbeau commented Mar 13, 2026

Also we should apply the same logic to rekeys (i.e. only consider them a warning if they are rekeying your account), though I think the useSigningRequestAnalysis has a flaw there in that we should probably just exclude watch accounts and not non-signing accounts...

@fmsouza
Copy link
Contributor Author

fmsouza commented Mar 16, 2026

@wjbeau Ok, I'll hold of with work on this PR until @yasincaliskan is done with his PR so I can check that again in a better state of the codebase.

Copy link
Collaborator

@yasincaliskan yasincaliskan left a comment

Choose a reason for hiding this comment

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

I think it would be good to rebase this branch to main to see what useSigningPipeline does. Because signing refactor already handles a lot of this warning logic.

Comment on lines +53 to +61
const isSenderUserControlled = useMemo(() => {
if (!transaction.sender) return false
const senderAccount = accounts.find(
a => a.address === transaction.sender,
)
return senderAccount
? canSignWithAccount(senderAccount, accounts)
: false
}, [transaction.sender, accounts])
Copy link
Collaborator

Choose a reason for hiding this comment

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

useSigningPipeline already computes signableAddresses via canSignWithAccount() and feeds them into aggregateTransactionWarnings which does the same sender control filtering.
This rederives it independently. I think we can cosume the pipeline's prefiltered warnings instead

senderAddress: tx.sender,
targetAddress: closeAddress,
})
const isSenderSignable = signableAddresses.has(tx.sender)
Copy link
Collaborator

Choose a reason for hiding this comment

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

signableAddresses uses canSignWithAccount(), which excludes watch accounts. A watched account being closed won't trigger a warning.
Per @wjbeau 's note, should we use all user accounts for warnings and reserve canSignWithAccount() for signing only?

Comment on lines +47 to +48
const closeWarning = warnings.find(w => w.type === 'close')
const rekeyWarning = warnings.find(w => w.type === 'rekey')
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these maybe be booleans, otherwise you're arbitrarily pickingn one of potentially multiple rekey warnings I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're using them to actually show the address in the warning once it shows up on the screen. So if we turn that into a boolean we'll lose this information.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay that makes sense so we only use these if there is only one account? Or should that "find" be a "filter" and we deal with a list on the display side?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree it does make more sense. I've just pushed a change to make it more flexible, so if there are more warnings we show all of them. And then if we don't like how the UX looks like we can definitely review that later.

senderAddress: tx.sender,
targetAddress: closeAddress,
})
const isUserAccount = userAccountAddresses.has(tx.sender)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to exclude watch addresses here. Are they already excluded somewhere along the way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +53 to +54
const closeWarnings = warnings.filter(w => w.type === 'close')
const rekeyWarnings = warnings.filter(w => w.type === 'rekey')
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be cleaner and more extensible to just group the warnings by type, and then as we add more types the UI can decide which types it cares about? So basically here we create

const warningsByType: Record<'rekey' | 'close' | 'asset-freeze', TransactionWarnings[]> = {
...
}

and then that's what we return?

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.

3 participants