File tree Expand file tree Collapse file tree 5 files changed +49
-24
lines changed
components/ConnectWalletDetails Expand file tree Collapse file tree 5 files changed +49
-24
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @thirdweb-dev/react-native " : patch
3
+ " @thirdweb-dev/react-core " : patch
4
+ ---
5
+
6
+ Adds usePersonalWalletAddress hook to React/RN
7
+
8
+ ``` typescript
9
+ // React
10
+ import { usePersonalWalletAddress } from " @thirdweb-dev/react" ;
11
+
12
+ const personalWalletAddress = usePersonalWalletAddress ();
13
+ ```
14
+
15
+ ``` typescript
16
+ // React-Native
17
+ import { usePersonalWalletAddress } from " @thirdweb-dev/react-native" ;
18
+
19
+ const personalWalletAddress = usePersonalWalletAddress ();
20
+ ```
Original file line number Diff line number Diff line change
1
+ import { useEffect , useState } from "react" ;
2
+ import { useWallet } from "../../core/hooks/wallet-hooks" ;
3
+
4
+ export const usePersonalWalletAddress = ( ) => {
5
+ const [ personalWalletAddress , setPersonalWalletAddress ] = useState <
6
+ string | undefined
7
+ > ( ) ;
8
+ const activeWallet = useWallet ( ) ;
9
+
10
+ useEffect ( ( ) => {
11
+ ( async ( ) => {
12
+ const possiblePersonalWallet = activeWallet ?. getPersonalWallet ( ) ;
13
+
14
+ if ( ! possiblePersonalWallet ) {
15
+ setPersonalWalletAddress ( undefined ) ;
16
+ return ;
17
+ }
18
+
19
+ const address = await (
20
+ await possiblePersonalWallet ?. getSigner ( )
21
+ ) ?. getAddress ( ) ;
22
+ setPersonalWalletAddress ( address ) ;
23
+ } ) ( ) ;
24
+ } , [ activeWallet ] ) ;
25
+
26
+ return personalWalletAddress ;
27
+ } ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ export {
22
22
} from "../core/hooks/wallet-hooks" ;
23
23
export { useNetwork } from "../core/hooks/useNetwork" ;
24
24
export { useWalletContext } from "../core/providers/thirdweb-wallet-provider" ;
25
+ export { usePersonalWalletAddress } from "./hooks/usePersonalWalletAddress" ;
25
26
26
27
// connected wallet hooks
27
28
export {
Original file line number Diff line number Diff line change @@ -13,12 +13,12 @@ import { ModalHeaderTextClose } from "../base/modal/ModalHeaderTextClose";
13
13
import {
14
14
shortenAddress ,
15
15
useAddress ,
16
+ usePersonalWalletAddress ,
16
17
useWallet ,
17
18
} from "@thirdweb-dev/react-core" ;
18
19
import { PasswordInput } from "../PasswordInput" ;
19
20
import * as FileSystem from "expo-file-system" ;
20
21
import { SmartWallet } from "@thirdweb-dev/wallets" ;
21
- import { usePersonalWalletAddress } from "../../wallets/hooks/usePersonalWalletAddress" ;
22
22
import { LocalWallet } from "../../wallets/wallets/LocalWallet" ;
23
23
import { TWModal } from "../base/modal/TWModal" ;
24
24
import { useLocale } from "../../providers/ui-context-provider" ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments