-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Problem solved Short description of the bug fixed or feature added ## Changes made - [ ] Public API changes: list the public API changes made if any - [ ] Internal API changes: explain the internal logic changes ## How to test - [ ] Automated tests: link to unit test file - [ ] Manual tests: step by step instructions on how to test ## Contributor NFT Paste in your wallet address below and we will airdrop you a special NFT when your pull request is merged. ```Address: ``` <!-- start pr-codex --> --- ## PR-Codex overview This PR adds account linking functionality, SIWE authentication, and profile management features to the Connect UI in `thirdweb`. ### Detailed summary - Added account linking to Connect UI - Introduced `useProfiles` hook for fetching linked profiles - Updated UI components and locales for profile management - Enhanced authentication options with SIWE - Improved wallet icons and authentication methods > The following files were skipped due to too many changes: `packages/thirdweb/src/react/web/ui/ConnectWallet/icons/AddUserIcon.tsx`, `packages/thirdweb/src/react/web/wallets/shared/oauthSignIn.ts`, `packages/thirdweb/src/wallets/ecosystem/types.ts`, `packages/thirdweb/src/wallets/in-app/core/authentication/types.ts`, `packages/thirdweb/src/react/web/ui/ConnectWallet/Modal/AnyWalletConnectUI.tsx`, `packages/thirdweb/src/react/web/ui/ConnectWallet/icons/MultiUserIcon.tsx`, `packages/thirdweb/src/wallets/in-app/web/lib/auth/oauth.ts`, `packages/thirdweb/src/wallets/in-app/core/authentication/getLoginPath.ts`, `packages/thirdweb/src/react/web/wallets/ecosystem/EcosystemWalletFormUI.tsx`, `packages/thirdweb/src/wallets/in-app/core/authentication/linkAccount.ts`, `packages/thirdweb/src/react/core/hooks/others/useProfiles.ts`, `packages/thirdweb/src/react/web/ui/components/WalletImage.tsx`, `packages/thirdweb/src/react/web/wallets/ecosystem/EcosystemWalletConnectUI.tsx`, `packages/thirdweb/src/react/web/ui/ConnectWallet/screens/ManageWalletScreen.tsx`, `packages/thirdweb/src/react/web/wallets/in-app/InAppWalletConnectUI.tsx`, `packages/thirdweb/src/react/web/wallets/in-app/InAppWalletFormUI.tsx`, `packages/thirdweb/src/wallets/in-app/core/authentication/siwe.ts`, `packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkProfileScreen.tsx`, `packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts`, `packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx`, `packages/thirdweb/src/react/web/ui/ConnectWallet/Details.tsx`, `packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkedProfilesScreen.tsx`, `packages/thirdweb/src/react/web/wallets/shared/SocialLogin.tsx`, `packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts`, `packages/thirdweb/src/wallets/in-app/native/native-connector.ts`, `packages/thirdweb/src/react/web/wallets/shared/PassKeyLogin.tsx`, `packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx`, `packages/thirdweb/src/wallets/in-app/native/auth/native-auth.ts` > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
1 parent
f74d523
commit bbb4f1c
Showing
54 changed files
with
1,123 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
"thirdweb": minor | ||
--- | ||
|
||
Adds useProfiles hook to fetch linked profiles for the current wallet. | ||
|
||
```jsx | ||
import { useProfiles } from "thirdweb/react"; | ||
|
||
const { data: profiles } = useProfiles(); | ||
|
||
console.log("Type:", profiles[0].type); // "discord" | ||
console.log("Email:", profiles[0].email); // "[email protected]" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
"thirdweb": minor | ||
--- | ||
|
||
Adds SIWE authentication on in-app wallets | ||
|
||
```ts | ||
import { inAppWallet } from "thirdweb/wallets" | ||
|
||
const wallet = inAppWallet(); | ||
const account = await wallet.connect({ | ||
client, | ||
walletId: "io.metamask", | ||
chainId: 1 // can be anything unless using smart accounts | ||
}); | ||
``` | ||
|
||
This will give you a new in-app wallet, **not** the injected provider wallet. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"thirdweb": minor | ||
--- | ||
|
||
Adds account linking to the Connect UI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/thirdweb/src/react/core/hooks/others/useProfiles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { type UseQueryResult, useQuery } from "@tanstack/react-query"; | ||
import type { Profile } from "../../../../wallets/in-app/core/authentication/types.js"; | ||
import { getProfiles } from "../../../../wallets/in-app/core/wallet/profiles.js"; | ||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js"; | ||
import { useActiveWallet } from "../wallets/useActiveWallet.js"; | ||
|
||
/** | ||
* @description Retrieves all linked profiles for the current wallet. | ||
* | ||
* @returns A React Query result containing the linked profiles for the connected in-app wallet. | ||
* | ||
* @note This hook will only run if the connected wallet supports multi-auth (in-app wallets). | ||
* | ||
* @example | ||
* ```jsx | ||
* import { use } from "thirdweb/react"; | ||
* | ||
* const { data: profiles } = useProfiles(); | ||
* | ||
* console.log("Type:", profiles[0].type); // "discord" | ||
* console.log("Email:", profiles[0].email); // "[email protected]" | ||
* ``` | ||
* | ||
* @wallet | ||
*/ | ||
export function useProfiles(): UseQueryResult<Profile[]> { | ||
const wallet = useActiveWallet(); | ||
|
||
return useQuery({ | ||
queryKey: ["profiles", wallet?.id], | ||
enabled: !!wallet && wallet.id === "inApp", | ||
queryFn: async () => { | ||
return getProfiles(wallet as Wallet<"inApp">); | ||
}, | ||
}); | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/thirdweb/src/react/web/ui/ConnectWallet/icons/AddUserIcon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { IconFC } from "./types.js"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const AddUserIcon: IconFC = (props) => { | ||
return ( | ||
<svg | ||
width={props.size} | ||
height={props.size} | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
role="presentation" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M12 15.5H7.5C6.10444 15.5 5.40665 15.5 4.83886 15.6722C3.56045 16.06 2.56004 17.0605 2.17224 18.3389C2 18.9067 2 19.6044 2 21M19 21V15M16 18H22M14.5 7.5C14.5 9.98528 12.4853 12 10 12C7.51472 12 5.5 9.98528 5.5 7.5C5.5 5.01472 7.51472 3 10 3C12.4853 3 14.5 5.01472 14.5 7.5Z" | ||
stroke="currentColor" | ||
strokeWidth="2" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
/> | ||
</svg> | ||
); | ||
}; | ||
25 changes: 25 additions & 0 deletions
25
packages/thirdweb/src/react/web/ui/ConnectWallet/icons/MultiUserIcon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { IconFC } from "./types.js"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const MultiUserIcon: IconFC = (props) => { | ||
return ( | ||
<svg | ||
width={props.size} | ||
height={props.size} | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
role="presentation" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M22 21V19C22 17.1362 20.7252 15.5701 19 15.126M15.5 3.29076C16.9659 3.88415 18 5.32131 18 7C18 8.67869 16.9659 10.1159 15.5 10.7092M17 21C17 19.1362 17 18.2044 16.6955 17.4693C16.2895 16.4892 15.5108 15.7105 14.5307 15.3045C13.7956 15 12.8638 15 11 15H8C6.13623 15 5.20435 15 4.46927 15.3045C3.48915 15.7105 2.71046 16.4892 2.30448 17.4693C2 18.2044 2 19.1362 2 21M13.5 7C13.5 9.20914 11.7091 11 9.5 11C7.29086 11 5.5 9.20914 5.5 7C5.5 4.79086 7.29086 3 9.5 3C11.7091 3 13.5 4.79086 13.5 7Z" | ||
stroke="currentColor" | ||
strokeWidth="2" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
/> | ||
</svg> | ||
); | ||
}; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.