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: {
121121 return (
122122 < WalletAuth
123123 meta = { props . meta }
124+ chain = { props . chain }
124125 inAppLocale = { locale }
125126 walletConnect = { props . walletConnect }
126127 wallet = { props . wallet }
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ function InAppWalletConnectUI(props: {
113113 wallet = { props . wallet }
114114 client = { props . client }
115115 size = { props . size }
116+ chain = { props . chain }
116117 done = { done }
117118 onBack = { goBackToMain || ( ( ) => setSelectionData ( { } ) ) }
118119 locale = { props . connectLocale }
Original file line number Diff line number Diff line change 11import { Suspense , useRef , useState } from "react" ;
2+ import type { Chain } from "../../../../chains/types.js" ;
23import { defineChain } from "../../../../chains/utils.js" ;
34import type { ThirdwebClient } from "../../../../client/client.js" ;
45import { getDefaultWallets } from "../../../../wallets/defaultWallets.js" ;
@@ -21,6 +22,7 @@ import type { InAppWalletLocale } from "../shared/locale/types.js";
2122
2223export function WalletAuth ( props : {
2324 wallet : Wallet < "inApp" | EcosystemWalletId > ;
25+ chain : Chain | undefined ;
2426 client : ThirdwebClient ;
2527 done : ( ) => void ;
2628 size : "compact" | "wide" ;
@@ -60,30 +62,29 @@ export function WalletAuth(props: {
6062
6163 async function login ( walletToLink : Wallet ) {
6264 setStatus ( "loading" ) ;
65+ setError ( undefined ) ;
6366 walletToConnect . current = walletToLink ;
6467 try {
6568 if ( props . isLinking ) {
6669 await linkProfile ( {
6770 client : props . client ,
6871 strategy : "wallet" ,
6972 wallet : walletToLink ,
70- chain : wallet . getChain ( ) || defineChain ( 1 ) ,
73+ chain : props . chain || wallet . getChain ( ) || defineChain ( 1 ) ,
7174 ecosystem,
72- } ) . catch ( ( e ) => {
73- setError ( e . message ) ;
74- throw e ;
7575 } ) ;
7676 } else {
7777 await wallet . connect ( {
7878 client : props . client ,
7979 strategy : "wallet" ,
8080 wallet : walletToLink ,
81- chain : walletToLink . getChain ( ) || defineChain ( 1 ) ,
81+ chain : props . chain || walletToLink . getChain ( ) || defineChain ( 1 ) ,
8282 } ) ;
8383 }
8484 addConnectedWallet ( walletToLink ) ;
8585 done ( ) ;
86- } catch {
86+ } catch ( e ) {
87+ setError ( e instanceof Error ? e . message : "Unknown error" ) ;
8788 setStatus ( "error" ) ;
8889 }
8990 }
You can’t perform that action at this time.
0 commit comments