@@ -8,7 +8,7 @@ import type { Signer } from 'ethers'
88import { useEffect , useMemo , useState } from 'react'
99import { whenDefined , whenDefinedAll } from '@devprotocol/util-ts'
1010import { i18nFactory , Signal } from '@devprotocol/clubs-core'
11- import type { connection as Connection } from '@devprotocol/clubs-core/connection'
11+ import { connection } from '@devprotocol/clubs-core/connection'
1212import {
1313 DynamicUserProfile ,
1414 useDynamicContext ,
@@ -33,7 +33,6 @@ export default ({
3333 buttonClassName ?: string
3434} ) => {
3535 const dynamic = useDynamicContext ( )
36- const [ connection , setConnection ] = useState < ReturnType < typeof Connection > > ( )
3736 const [ signer , setSigner ] = useState < Signer > ( )
3837 const [ walletName , setWalletName ] = useState < string > ( )
3938 const [ isWalletNeeded , setIsWalletNeeded ] = useState < boolean > ( false )
@@ -55,7 +54,7 @@ export default ({
5554
5655 useEffect ( ( ) => {
5756 const cryptoWallet = dynamic . user ?. verifiedCredentials . find (
58- ( c ) => c . format === 'blockchain' ,
57+ ( c ) => c . format === 'blockchain' && Boolean ( c . embeddedWalletId ) ,
5958 )
6059
6160 if ( cryptoWallet ) {
@@ -85,7 +84,7 @@ export default ({
8584 setUnexpectedNetwork (
8685 typeof chainId === 'number' && connectedChain !== chainId ,
8786 )
88- whenDefinedAll ( [ connection ] , ( [ _connection ] ) =>
87+ whenDefinedAll ( [ connection ( ) ] , ( [ _connection ] ) =>
8988 _connection . chain . next ( Number ( dynamic . network ) ) ,
9089 )
9190 } , [ dynamic . network ] )
@@ -95,7 +94,7 @@ export default ({
9594 ( c ) => c . format === 'email' ,
9695 )
9796 console . log ( '**' , { emailCredential } )
98- whenDefinedAll ( [ connection ] , ( [ _connection ] ) =>
97+ whenDefinedAll ( [ connection ( ) ] , ( [ _connection ] ) =>
9998 _connection . identifiers . next (
10099 whenDefined ( emailCredential ?. publicIdentifier , ( email ) => ( {
101100 email,
@@ -104,12 +103,6 @@ export default ({
104103 )
105104 } , [ dynamic . user ] )
106105
107- useEffect ( ( ) => {
108- import ( '@devprotocol/clubs-core/connection' ) . then ( ( C ) => {
109- setConnection ( C . connection ( ) )
110- } )
111- } , [ ] )
112-
113106 useEffect ( ( ) => {
114107 const eoa = dynamic ?. primaryWallet ?. address
115108 if ( eoa ) {
@@ -122,14 +115,14 @@ export default ({
122115 } , [ dynamic ?. primaryWallet ?. address ] )
123116
124117 useEffect ( ( ) => {
125- whenDefinedAll ( [ connection ] , ( [ _connection ] ) => {
118+ whenDefinedAll ( [ connection ( ) ] , ( [ _connection ] ) => {
126119 // console.log('Called here', signer)
127120 _connection . signer . next ( signer )
128121 } )
129- } , [ signer , connection ] )
122+ } , [ signer ] )
130123
131124 useEffect ( ( ) => {
132- whenDefinedAll ( [ connection ] , ( [ _connection ] ) => {
125+ whenDefinedAll ( [ connection ( ) ] , ( [ _connection ] ) => {
133126 // console.log('$$$ Called here', signer)
134127
135128 // signal
@@ -151,7 +144,7 @@ export default ({
151144 }
152145 } )
153146 } )
154- } , [ connection ] )
147+ } , [ ] )
155148
156149 return (
157150 < span className = "group/awesome-onboarding relative block" >
0 commit comments