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

feat: Implement wallet_revokePermissions method and add tests #168

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

qvkare
Copy link

@qvkare qvkare commented Jan 11, 2025

Implements the wallet_revokePermissions method using Privy's logout functionality. Replaces the existing TODO in usePrivyCrossAppProvider.ts.

The wallet_revokePermissions method needs to handle wallet disconnection in the Privy context. We used Privy's logout method because:

  1. It properly cleans up the user's session
  2. It follows Web3 standards for permission revocation
  3. It maintains consistency with Privy's authentication flow

Code Changes

Before:
case 'wallet_revokePermissions':
  // TODO: do we need to do anything here?
  return null;
After:
case 'wallet_revokePermissions': {
  try {
    await logout?.();
    return null;
  } catch (error) {
    throw new ProviderRpcError(4001, 'User rejected the request.');
  }
}

Testing

✅ All tests pass
✅ No breaking changes


PR-Codex overview

This PR focuses on implementing the wallet_revokePermissions method in the usePrivyCrossAppProvider, along with corresponding tests to handle permission revocation and potential logout failures.

Detailed summary

  • Implemented wallet_revokePermissions method in usePrivyCrossAppProvider.
  • Added a local ProviderRpcError class for error handling.
  • Updated the usePrivy hook to include logout.
  • Created tests for wallet_revokePermissions in usePrivyCrossAppProvider.test.ts.
  • Handled successful and failed logout scenarios in tests.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

changeset-bot bot commented Jan 11, 2025

🦋 Changeset detected

Latest commit: d80e08a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@abstract-foundation/agw-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant