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

Impossible to cancel a WalletConnect approval request without refreshing #5139

Closed
ManuGowda opened this issue Jul 3, 2023 · 0 comments
Closed

Comments

@ManuGowda
Copy link
Contributor

Description

When a user rejects a WalletConnect connection, they cannot add another one until they close and reopen the desktop application because the old connection event is never deleted. This happens because the reject handler does not call removeEvent(proposalEvents) like the approve function does.

const approve = useCallback( async (selectedAccounts) => {
const proposalEvents = events.find((e) => e.name === EVENTS.SESSION_PROPOSAL);
try {
const status = await onApprove(proposalEvents.meta, selectedAccounts);
removeEvent(proposalEvents);
setSessionProposal( null );
setSessionRequest( null );
// [REDACTED]
}, []);
const reject = useCallback( async () => {
const proposalEvents = events.find((e) => e.name === EVENTS.SESSION_PROPOSAL);
try {
await onReject(proposalEvents.meta);
setSessionProposal( null );
setSessionRequest( null );
// [REDACTED]
}, []);

const approve = useCallback(async (selectedAccounts) => {
const proposalEvents = events.find((e) => e.name === EVENTS.SESSION_PROPOSAL);
try {
const status = await onApprove(proposalEvents.meta, selectedAccounts);
removeEvent(proposalEvents);
setSessionProposal(null);
setSessionRequest(null);
await loadSessions();
return {
status,
data: proposalEvents.meta,
};
} catch (e) {
return {
status: STATUS.FAILURE,
message: e.message,
};
}
}, []);
const reject = useCallback(async () => {
const proposalEvents = events.find((e) => e.name === EVENTS.SESSION_PROPOSAL);
try {
await onReject(proposalEvents.meta);
setSessionProposal(null);
setSessionRequest(null);
return {
status: STATUS.SUCCESS,
data: proposalEvents.meta,
};
} catch (e) {
return {
status: STATUS.FAILURE,
message: e.message,
};
}
}, []);

Recommendation

Clear the event from the list of events on both approval and rejection. This will ensure that a processed event is not shown to the user again.

Which version(s) does this affect? (Environment, OS, etc...)

3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

2 participants