Skip to content

[SDK] Add account deletion support when unlinking profiles #7211

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

Merged

Conversation

joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented May 29, 2025

Fixes TOOL-4637


PR-Codex overview

This PR introduces an optional allowAccountDeletion parameter to the unlinkProfile functionality, enabling the deletion of an entire account when unlinking the last associated profile. This enhances user control over profile management.

Detailed summary

  • Added allowAccountDeletion parameter to unlinkProfile in various files.
  • Updated function signatures to accept allowAccountDeletion.
  • Modified the unlinkAccount function to handle account deletion logic.
  • Enhanced tests to cover scenarios with account deletion.
  • Updated documentation and examples to reflect the new parameter.

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

Summary by CodeRabbit

  • New Features

    • Added the ability to delete an entire account when unlinking the last profile, available as an optional setting during the unlink process.
    • Enhanced documentation with examples showing how to enable account deletion when unlinking profiles.
  • Documentation

    • Updated usage examples to illustrate the new account deletion option during profile unlinking.

Copy link

vercel bot commented May 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2025 11:32pm
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2025 11:32pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2025 11:32pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2025 11:32pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2025 11:32pm

Copy link

changeset-bot bot commented May 29, 2025

🦋 Changeset detected

Latest commit: 6fc8afd

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

This PR includes changesets to release 2 packages
Name Type
thirdweb Patch
@thirdweb-dev/wagmi-adapter 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

Copy link
Contributor

coderabbitai bot commented May 29, 2025

## Walkthrough

The changes introduce support for account deletion when unlinking profiles in the thirdweb SDK. An optional `allowAccountDeletion` parameter is added to relevant functions and hooks, enabling deletion of the entire account if the last profile is unlinked. Function signatures, interfaces, and documentation are updated accordingly.

## Changes

| File(s)                                                                                  | Change Summary                                                                                                         |
|------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| .changeset/account-deletion-unlink.md                                                    | Documents the addition of account deletion support during profile unlinking, with usage examples.                      |
| packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.ts<br>packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.ts | Enhanced `useUnlinkProfile` hook to accept optional `allowAccountDeletion` parameter and updated documentation.        |
| packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts                  | Updated `unlinkAccount` to accept and forward optional `allowAccountDeletion` parameter in API requests.               |
| packages/thirdweb/src/wallets/in-app/core/authentication/types.ts                        | Added optional `allowAccountDeletion` property to `UnlinkParams` type.                                                |
| packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts                        | Updated `InAppConnector` interface's `unlinkProfile` method to accept optional `allowAccountDeletion` parameter.       |
| packages/thirdweb/src/wallets/in-app/native/auth/index.ts                                | Modified internal call to connector's `unlinkProfile` to include `allowAccountDeletion`.                              |
| packages/thirdweb/src/wallets/in-app/native/native-connector.ts<br>packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts | Updated `unlinkProfile` method signatures to accept and forward optional `allowAccountDeletion` parameter.             |
| packages/thirdweb/src/wallets/in-app/web/lib/auth/index.ts                               | Updated function to pass `allowAccountDeletion` to connector and extended documentation with usage examples.           |
| packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.test.ts             | Updated test to expect request body with `type`, `details`, and `allowAccountDeletion` instead of full profile object. |
| packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.test.tsx               | Added tests verifying `allowAccountDeletion` parameter handling in `useUnlinkProfile` hook mutation calls.             |
| packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.test.tsx                  | Updated tests to include `allowAccountDeletion: false` in expected calls to `unlinkProfile`.                           |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant ReactHook
    participant SDKFunction
    participant Connector
    participant API

    User->>ReactHook: useUnlinkProfile({ allowAccountDeletion })
    ReactHook->>SDKFunction: unlinkProfile({ profileToUnlink, allowAccountDeletion })
    SDKFunction->>Connector: unlinkProfile(profileToUnlink, allowAccountDeletion)
    Connector->>API: POST /account/disconnect { type, details, allowAccountDeletion }
    API-->>Connector: Response (profiles or account deleted)
    Connector-->>SDKFunction: Result
    SDKFunction-->>ReactHook: Result
    ReactHook-->>User: Success/Error

Assessment against linked issues

Objective Addressed Explanation
Add ability to delete accounts (TOOL-4637)

<!-- walkthrough_end -->

<!-- This is an auto-generated comment: resource warnings by coderabbit.ai -->

> [!WARNING]
> ## Review ran into problems
> 
> <details>
> <summary>🔥 Problems</summary>
> 
> Errors were encountered while retrieving linked issues.
> 
> <details>
> <summary>Errors (1)</summary>
> 
> * TEAM-0000: Entity not found: Issue - Could not find referenced Issue.
> 
> </details>
> 
> </details>

<!-- end of auto-generated comment: resource warnings by coderabbit.ai -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAbQBlABEAaQBdSABBWno0BiZsDFClSPF8LAdubnwKUIB3WDJIAq94DABrVqIeCnwAM3hIxGjIOSbESkghfDQg+GYwKQpSZFbcHtpsBml0LHxuUow0XwADI698Woy8/ALcRJIS+DLjnmc0Nho+AjCGyGPm1ptKw9fqRF69ApiJ5YTD0dTIfxeahRWD4fBtZC1dQILC4X54+AUWi1EgCSBJZIaGAIZDcN4fCZkFSDH4eYok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fHoazA7Q9iejyRAUEwp4bo6BcCBBOvB3Bbwv4ynfeP/AGx+A0AwCVZtGgUA3wVAagaBI/GaHPwD46gAAPr4REA0w/XtPDoDTCNYwiFeAYEmG0AAAHAACZsgDAeCL0AYCIRDhaAXoAAEY0AJAc4ecPghoAdhAgAAAwqBegAAThIDIQdhVw5COcNQjIQAArPcNgSGBJhAgf4ahFeFbCARqEAQD8POGvDXhVw2gOcMQgMALhrwgQK8NoCIRHhnwnYfBARGIQiRDAWgI8OBEbC14kAeCP8MQi9BkRjwx4TsMQgkBUIOw1CP8JJGPDegqEVEXcLQBcjPouwhgOyOFGvD/hjwxCOSMmG0iGAWws4bQHgh7CBApIgQFsJZHYj4I8EA4fBC2G9A0IpI5kVsIECsjaRiEOaOsMmGNwZhcwhYY5yWG0BphG8YEUAA== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=thirdweb-dev/js&utm_content=7211):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels May 29, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@joaquim-verges joaquim-verges changed the title Add account deletion support when unlinking profiles [SDK] Add account deletion support when unlinking profiles May 29, 2025
@joaquim-verges joaquim-verges marked this pull request as ready for review May 29, 2025 22:54
@joaquim-verges joaquim-verges requested review from a team as code owners May 29, 2025 22:54
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts (1)

86-86: Remove debug logging before production deployment.

The console.log statement appears to be for debugging purposes and should be removed before merging to production to avoid unnecessary logging in the client application.

-  console.log("allowAccountDeletion", allowAccountDeletion);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f42ad2 and d82ddc4.

📒 Files selected for processing (10)
  • .changeset/account-deletion-unlink.md (1 hunks)
  • packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.ts (3 hunks)
  • packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.ts (3 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts (3 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/types.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/native/auth/index.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/native/native-connector.ts (2 hunks)
  • packages/thirdweb/src/wallets/in-app/web/lib/auth/index.ts (2 hunks)
  • packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (6)
packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts (2)
packages/thirdweb/src/wallets/in-app/core/authentication/types.ts (1)
  • Profile (119-127)
packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts (1)
  • unlinkAccount (65-113)
packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.ts (1)
packages/thirdweb/src/wallets/in-app/core/authentication/types.ts (1)
  • Profile (119-127)
packages/thirdweb/src/wallets/in-app/native/native-connector.ts (1)
packages/thirdweb/src/wallets/in-app/core/authentication/types.ts (1)
  • Profile (119-127)
packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.ts (2)
packages/thirdweb/src/exports/thirdweb.ts (1)
  • ThirdwebClient (26-26)
packages/thirdweb/src/wallets/in-app/core/authentication/types.ts (1)
  • Profile (119-127)
packages/thirdweb/src/wallets/in-app/web/lib/auth/index.ts (4)
packages/thirdweb/src/wallets/in-app/native/auth/index.ts (1)
  • unlinkProfile (204-210)
packages/thirdweb/src/wallets/in-app/native/native-connector.ts (1)
  • unlinkProfile (370-381)
packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts (1)
  • unlinkProfile (473-481)
packages/thirdweb/src/wallets/in-app/core/authentication/types.ts (1)
  • UnlinkParams (258-263)
packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts (1)
packages/thirdweb/src/wallets/in-app/core/authentication/types.ts (1)
  • Profile (119-127)
🪛 markdownlint-cli2 (0.17.2)
.changeset/account-deletion-unlink.md

5-5: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: Build Packages
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Unit Tests
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (15)
packages/thirdweb/src/wallets/in-app/core/authentication/types.ts (1)

262-262: LGTM: Optional parameter added correctly.

The addition of the optional allowAccountDeletion boolean property to UnlinkParams is well-implemented and maintains backward compatibility.

packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts (1)

473-481: LGTM: Parameter correctly added and passed through.

The unlinkProfile method signature is properly updated with the optional allowAccountDeletion parameter, and it's correctly passed through to the underlying unlinkAccount function call. The implementation maintains backward compatibility and aligns with the interface definition.

packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts (1)

40-43: LGTM: Interface updated correctly.

The unlinkProfile method signature in the interface is properly updated to include the optional allowAccountDeletion parameter. This correctly defines the contract that both web and native connector implementations follow.

packages/thirdweb/src/wallets/in-app/native/native-connector.ts (1)

370-381: LGTM: Consistent implementation across platforms.

The unlinkProfile method in the native connector is correctly updated with the optional allowAccountDeletion parameter and properly passes it through to the unlinkAccount function. This implementation maintains consistency with the web connector and follows the interface contract.

.changeset/account-deletion-unlink.md (1)

1-36: LGTM! Comprehensive changeset documentation.

The changeset provides excellent documentation with clear examples for both React hook and direct function usage. The examples properly demonstrate the new allowAccountDeletion parameter functionality.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

5-5: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

packages/thirdweb/src/wallets/in-app/native/auth/index.ts (1)

204-210: LGTM! Correct parameter forwarding.

The implementation properly forwards the allowAccountDeletion parameter from the UnlinkParams to the connector's unlinkProfile method, maintaining consistency with the type definitions and preserving backward compatibility.

packages/thirdweb/src/wallets/in-app/web/lib/auth/index.ts (2)

227-270: Excellent documentation enhancement!

The expanded documentation with three comprehensive examples (basic unlinking, ecosystem unlinking, and account deletion) provides clear guidance for different use cases. The examples are well-structured and demonstrate proper usage of the new allowAccountDeletion parameter.


273-279: LGTM! Consistent implementation across platforms.

The implementation correctly forwards the allowAccountDeletion parameter to the connector, maintaining consistency with the native implementation and ensuring unified behavior across web and native platforms.

packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.ts (2)

34-50: Great documentation addition!

The new example clearly demonstrates how to use the allowAccountDeletion parameter with appropriate warning comments about its destructive nature. This helps developers understand the implications of enabling account deletion.


57-79: LGTM! Safe implementation with proper defaults.

The implementation correctly:

  • Defaults allowAccountDeletion to false for safety and backward compatibility
  • Uses proper TypeScript typing with optional boolean parameter
  • Forwards the parameter to the underlying unlinkProfile function

The safe default prevents accidental account deletion while maintaining backward compatibility.

packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.ts (3)

34-50: Excellent documentation with clear example.

The new documentation example clearly demonstrates how to use the allowAccountDeletion parameter and explains its purpose. This will help developers understand when and how to use this feature.


60-65: Well-implemented parameter addition with backward compatibility.

The allowAccountDeletion parameter is properly typed as optional with a sensible default value of false, ensuring backward compatibility while enabling the new functionality.


78-78: Parameter correctly passed through to underlying function.

The allowAccountDeletion parameter is properly forwarded to the unlinkProfile function, ensuring the feature works throughout the call chain.

packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts (2)

69-69: Consistent parameter implementation maintains backward compatibility.

The allowAccountDeletion parameter is properly implemented with an optional type and sensible default, maintaining consistency with the React hook implementation.

Also applies to: 75-75


97-101: Improved request body structure with explicit parameter inclusion.

The modification to explicitly include type, details, and allowAccountDeletion in the request body is clearer and ensures the new parameter is properly sent to the API endpoint.

Copy link

linear bot commented May 29, 2025

@joaquim-verges joaquim-verges force-pushed the Add_account_deletion_support_when_unlinking_profiles branch from d82ddc4 to b579835 Compare May 29, 2025 22:57
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/account-deletion-unlink.md (1)

5-5: Use a Markdown heading for the title
To satisfy markdownlint and improve readability, consider converting the title emphasis into a proper heading.

- **Add account deletion support when unlinking profiles**
+ ### Add account deletion support when unlinking profiles
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

5-5: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d82ddc4 and b579835.

📒 Files selected for processing (10)
  • .changeset/account-deletion-unlink.md (1 hunks)
  • packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.ts (3 hunks)
  • packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.ts (3 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts (2 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/types.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/native/auth/index.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/native/native-connector.ts (2 hunks)
  • packages/thirdweb/src/wallets/in-app/web/lib/auth/index.ts (2 hunks)
  • packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts
  • packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts
  • packages/thirdweb/src/wallets/in-app/native/native-connector.ts
  • packages/thirdweb/src/wallets/in-app/native/auth/index.ts
  • packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.ts
  • packages/thirdweb/src/wallets/in-app/web/lib/auth/index.ts
  • packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.ts
  • packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts
  • packages/thirdweb/src/wallets/in-app/core/authentication/types.ts
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
.changeset/account-deletion-unlink.md

5-5: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
.changeset/account-deletion-unlink.md (3)

1-3: Frontmatter format is valid
The changeset uses the correct patch bump and valid YAML frontmatter.


9-23: React Hook usage example is clear
The useUnlinkProfile snippet correctly demonstrates how to pass allowAccountDeletion when unlinking.


25-35: Direct function example looks good
The standalone unlinkProfile example accurately reflects the updated signature.

Copy link
Contributor

github-actions bot commented May 29, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 62.11 KB (0%) 1.3 s (0%) 204 ms (+133.98% 🔺) 1.5 s
thirdweb (cjs) 345.28 KB (0%) 7 s (0%) 608 ms (+1.14% 🔺) 7.6 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 73 ms (+928.95% 🔺) 187 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 35 ms (+2127.83% 🔺) 45 ms
thirdweb/react (minimal + tree-shaking) 19.52 KB (0%) 391 ms (0%) 87 ms (+723.28% 🔺) 477 ms

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.test.ts (1)

78-101: 🛠️ Refactor suggestion

Add test coverage for allowAccountDeletion: true.

The current test only covers the default behavior where allowAccountDeletion is false. Consider adding a test case to verify the behavior when allowAccountDeletion is explicitly set to true.

+    it("should successfully unlink an account with account deletion allowed", async () => {
+      const result = await unlinkAccount({
+        client: mockClient,
+        profileToUnlink,
+        storage: mockStorage,
+        allowAccountDeletion: true,
+      });
+
+      expect(mockFetch).toHaveBeenCalledWith(
+        "https://embedded-wallet.thirdweb.com/api/2024-05-05/account/disconnect",
+        {
+          method: "POST",
+          headers: {
+            Authorization: "Bearer iaw-auth-token:mock-token",
+            "Content-Type": "application/json",
+          },
+          body: JSON.stringify({
+            type: profileToUnlink.type,
+            details: profileToUnlink.details,
+            allowAccountDeletion: true,
+          }),
+        },
+      );
+      expect(result).toEqual(mockLinkedAccounts);
+    });
🧹 Nitpick comments (2)
.changeset/account-deletion-unlink.md (2)

5-5: Use a heading instead of bold text for the summary: MarkdownLint flagged MD036 (Emphasis used instead of a heading). Replace the summary line with a markdown heading (e.g., # Add account deletion support when unlinking profiles).

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

5-5: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


25-35: Document return value when account is deleted: The direct function example is accurate, but it’s unclear what unlinkProfile returns if the account is fully deleted (e.g., empty array, null, or throws). Consider adding a note or sample code illustrating that edge case.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b579835 and 456fd10.

📒 Files selected for processing (11)
  • .changeset/account-deletion-unlink.md (1 hunks)
  • packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.ts (3 hunks)
  • packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.ts (3 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.test.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts (2 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/types.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/native/auth/index.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/native/native-connector.ts (2 hunks)
  • packages/thirdweb/src/wallets/in-app/web/lib/auth/index.ts (2 hunks)
  • packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • packages/thirdweb/src/wallets/in-app/core/authentication/types.ts
  • packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.ts
  • packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts
  • packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts
  • packages/thirdweb/src/wallets/in-app/native/auth/index.ts
  • packages/thirdweb/src/wallets/in-app/native/native-connector.ts
  • packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.ts
  • packages/thirdweb/src/wallets/in-app/web/lib/auth/index.ts
  • packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
.changeset/account-deletion-unlink.md

5-5: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: Build Packages
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.test.ts (1)

93-97: Good update to match the new API contract.

The test correctly verifies that the unlinkAccount function now sends allowAccountDeletion: false by default in the request body, which aligns with the new implementation.

.changeset/account-deletion-unlink.md (2)

1-3: Frontmatter correctness: The YAML frontmatter is valid and correctly specifies the thirdweb package bump to patch.


9-23: Clarify default behavior in React Hook example: The TSX snippet and import path look correct. Please verify that allowAccountDeletion indeed defaults to false when omitted, and consider adding a note to the example or descriptive text to that effect.

@joaquim-verges joaquim-verges force-pushed the Add_account_deletion_support_when_unlinking_profiles branch from 456fd10 to 6fc8afd Compare May 29, 2025 23:22
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.test.tsx (1)

15-77: 🛠️ Refactor suggestion

Add test coverage for allowAccountDeletion: true scenario.

The web version test suite is missing a test case to verify the behavior when allowAccountDeletion is explicitly set to true. The native version includes this test case (lines 50-73), but the web version doesn't have equivalent coverage.

Consider adding a test similar to the one in the native version:

+  it("should call unlinkProfile with allowAccountDeletion if true", async () => {
+    vi.mocked(useConnectedWallets).mockReturnValue([]);
+
+    const { result } = renderHook(() => useUnlinkProfile(), {
+      wrapper,
+    });
+    const mutationFn = result.current.mutateAsync;
+
+    await act(async () => {
+      await mutationFn({
+        client: TEST_CLIENT,
+        profileToUnlink: mockProfile,
+        allowAccountDeletion: true,
+      });
+    });
+
+    expect(unlinkProfile).toHaveBeenCalledWith({
+      client: TEST_CLIENT,
+      ecosystem: undefined,
+      profileToUnlink: mockProfile,
+      allowAccountDeletion: true,
+    });
+    expect(queryClient.invalidateQueries).toHaveBeenCalledWith({
+      queryKey: ["profiles"],
+    });
+  });
🧹 Nitpick comments (2)
.changeset/account-deletion-unlink.md (2)

5-7: Use a Markdown heading instead of bold text for the changeset title
Markdownlint (MD036) flags emphasis used as a heading. It’s clearer to use an actual heading for the summary line.

- **Add account deletion support when unlinking profiles**
+ # Add account deletion support when unlinking profiles
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

5-5: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


9-23: Convert example section labels to headings
For better structure and consistency, replace the bold example labels with Markdown headings (e.g., ## React Hook Example) and remove the trailing colon. This improves readability in rendered docs.

- **React Hook Example:**
+ ## React Hook Example

@@
- ```tsx
+ ```tsx
@@
- **Direct Function Example:**
+ ## Direct Function Example
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 456fd10 and 6fc8afd.

📒 Files selected for processing (13)
  • .changeset/account-deletion-unlink.md (1 hunks)
  • packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.test.tsx (2 hunks)
  • packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.ts (3 hunks)
  • packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.test.tsx (2 hunks)
  • packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.ts (3 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.test.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts (2 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/types.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/native/auth/index.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/native/native-connector.ts (2 hunks)
  • packages/thirdweb/src/wallets/in-app/web/lib/auth/index.ts (2 hunks)
  • packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • packages/thirdweb/src/wallets/in-app/core/authentication/types.ts
  • packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.test.ts
  • packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts
  • packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.ts
  • packages/thirdweb/src/wallets/in-app/native/auth/index.ts
  • packages/thirdweb/src/wallets/in-app/native/native-connector.ts
  • packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts
  • packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts
  • packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.ts
  • packages/thirdweb/src/wallets/in-app/web/lib/auth/index.ts
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
.changeset/account-deletion-unlink.md

5-5: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • GitHub Check: Unit Tests
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (7)
.changeset/account-deletion-unlink.md (2)

1-3: Frontmatter is correct
The YAML frontmatter properly declares a patch bump for the thirdweb package. No changes needed here.


27-35: Example usage is clear and accurate
The TypeScript snippet for unlinkProfile correctly demonstrates the allowAccountDeletion flag in action. No further changes needed here.

packages/thirdweb/src/react/web/hooks/wallets/useUnlinkProfile.test.tsx (2)

43-43: LGTM! Default parameter correctly tested.

The test correctly verifies that allowAccountDeletion defaults to false when not explicitly provided.


74-74: LGTM! Ecosystem wallet test correctly updated.

The ecosystem wallet test case is properly updated to include the new parameter.

packages/thirdweb/src/react/native/hooks/wallets/useUnlinkProfile.test.tsx (3)

43-48: LGTM! Default parameter correctly tested.

The test correctly verifies that allowAccountDeletion defaults to false when not explicitly provided.


50-73: Excellent test coverage for the new parameter!

This test case properly verifies that when allowAccountDeletion: true is explicitly passed, it's correctly forwarded to the underlying unlinkProfile function. The test structure follows the existing pattern and provides comprehensive coverage.


99-99: LGTM! Ecosystem wallet test correctly updated.

The ecosystem wallet test case is properly updated to include the new parameter with its default value.

Copy link

codecov bot commented May 29, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 55.63%. Comparing base (861e623) to head (6fc8afd).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
.../thirdweb/src/wallets/in-app/web/lib/auth/index.ts 0.00% 4 Missing ⚠️
...irdweb/src/wallets/in-app/web/lib/web-connector.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7211   +/-   ##
=======================================
  Coverage   55.63%   55.63%           
=======================================
  Files         908      908           
  Lines       58531    58546   +15     
  Branches     4130     4128    -2     
=======================================
+ Hits        32561    32572   +11     
- Misses      25864    25868    +4     
  Partials      106      106           
Flag Coverage Δ
packages 55.63% <75.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
...src/react/native/hooks/wallets/useUnlinkProfile.ts 100.00% <100.00%> (ø)
...eb/src/react/web/hooks/wallets/useUnlinkProfile.ts 100.00% <100.00%> (ø)
.../wallets/in-app/core/authentication/linkAccount.ts 89.42% <100.00%> (+0.53%) ⬆️
...irdweb/src/wallets/in-app/web/lib/web-connector.ts 47.50% <50.00%> (-0.12%) ⬇️
.../thirdweb/src/wallets/in-app/web/lib/auth/index.ts 1.25% <0.00%> (-0.05%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@joaquim-verges joaquim-verges merged commit 31c4bb2 into main May 29, 2025
22 of 24 checks passed
@joaquim-verges joaquim-verges deleted the Add_account_deletion_support_when_unlinking_profiles branch May 29, 2025 23:31
@joaquim-verges joaquim-verges mentioned this pull request May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant