File tree Expand file tree Collapse file tree 4 files changed +14
-6
lines changed
packages/thirdweb/src/react/web/wallets Expand file tree Collapse file tree 4 files changed +14
-6
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " thirdweb " : patch
3
+ ---
4
+
5
+ Pass through desired chain when signing in with wallet for ecosystems
Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ function EcosystemWalletConnectUI(props: {
121
121
return (
122
122
< WalletAuth
123
123
meta = { props . meta }
124
+ chain = { props . chain }
124
125
inAppLocale = { locale }
125
126
walletConnect = { props . walletConnect }
126
127
wallet = { props . wallet }
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ function InAppWalletConnectUI(props: {
113
113
wallet = { props . wallet }
114
114
client = { props . client }
115
115
size = { props . size }
116
+ chain = { props . chain }
116
117
done = { done }
117
118
onBack = { goBackToMain || ( ( ) => setSelectionData ( { } ) ) }
118
119
locale = { props . connectLocale }
Original file line number Diff line number Diff line change 1
1
import { Suspense , useRef , useState } from "react" ;
2
+ import type { Chain } from "../../../../chains/types.js" ;
2
3
import { defineChain } from "../../../../chains/utils.js" ;
3
4
import type { ThirdwebClient } from "../../../../client/client.js" ;
4
5
import { getDefaultWallets } from "../../../../wallets/defaultWallets.js" ;
@@ -21,6 +22,7 @@ import type { InAppWalletLocale } from "../shared/locale/types.js";
21
22
22
23
export function WalletAuth ( props : {
23
24
wallet : Wallet < "inApp" | EcosystemWalletId > ;
25
+ chain : Chain | undefined ;
24
26
client : ThirdwebClient ;
25
27
done : ( ) => void ;
26
28
size : "compact" | "wide" ;
@@ -60,30 +62,29 @@ export function WalletAuth(props: {
60
62
61
63
async function login ( walletToLink : Wallet ) {
62
64
setStatus ( "loading" ) ;
65
+ setError ( undefined ) ;
63
66
walletToConnect . current = walletToLink ;
64
67
try {
65
68
if ( props . isLinking ) {
66
69
await linkProfile ( {
67
70
client : props . client ,
68
71
strategy : "wallet" ,
69
72
wallet : walletToLink ,
70
- chain : wallet . getChain ( ) || defineChain ( 1 ) ,
73
+ chain : props . chain || wallet . getChain ( ) || defineChain ( 1 ) ,
71
74
ecosystem,
72
- } ) . catch ( ( e ) => {
73
- setError ( e . message ) ;
74
- throw e ;
75
75
} ) ;
76
76
} else {
77
77
await wallet . connect ( {
78
78
client : props . client ,
79
79
strategy : "wallet" ,
80
80
wallet : walletToLink ,
81
- chain : walletToLink . getChain ( ) || defineChain ( 1 ) ,
81
+ chain : props . chain || walletToLink . getChain ( ) || defineChain ( 1 ) ,
82
82
} ) ;
83
83
}
84
84
addConnectedWallet ( walletToLink ) ;
85
85
done ( ) ;
86
- } catch {
86
+ } catch ( e ) {
87
+ setError ( e instanceof Error ? e . message : "Unknown error" ) ;
87
88
setStatus ( "error" ) ;
88
89
}
89
90
}
You can’t perform that action at this time.
0 commit comments