@@ -8,7 +8,7 @@ import type { Signer } from 'ethers'
8
8
import { useEffect , useMemo , useState } from 'react'
9
9
import { whenDefined , whenDefinedAll } from '@devprotocol/util-ts'
10
10
import { i18nFactory , Signal } from '@devprotocol/clubs-core'
11
- import { connection } from '@devprotocol/clubs-core/connection'
11
+ import type { connection as Connection } from '@devprotocol/clubs-core/connection'
12
12
import {
13
13
DynamicUserProfile ,
14
14
useDynamicContext ,
@@ -34,6 +34,7 @@ export default ({
34
34
} ) => {
35
35
const dynamic = useDynamicContext ( )
36
36
const [ signer , setSigner ] = useState < Signer > ( )
37
+ const [ connection , setConnection ] = useState < ReturnType < typeof Connection > > ( )
37
38
const [ walletName , setWalletName ] = useState < string > ( )
38
39
const [ isWalletNeeded , setIsWalletNeeded ] = useState < boolean > ( false )
39
40
const [ isUnexpectedNetwork , setUnexpectedNetwork ] = useState < boolean > ( false )
@@ -52,6 +53,12 @@ export default ({
52
53
53
54
const loggedIn = useMemo ( ( ) => dynamic ?. user !== undefined , [ dynamic ?. user ] )
54
55
56
+ useEffect ( ( ) => {
57
+ import ( '@devprotocol/clubs-core/connection' ) . then ( ( it ) => {
58
+ setConnection ( it . connection ( ) )
59
+ } )
60
+ } , [ ] )
61
+
55
62
useEffect ( ( ) => {
56
63
const cryptoWallet = dynamic . user ?. verifiedCredentials . find (
57
64
( c ) => c . format === 'blockchain' && Boolean ( c . embeddedWalletId ) ,
@@ -84,24 +91,24 @@ export default ({
84
91
setUnexpectedNetwork (
85
92
typeof chainId === 'number' && connectedChain !== chainId ,
86
93
)
87
- whenDefinedAll ( [ connection ( ) ] , ( [ _connection ] ) =>
94
+ whenDefinedAll ( [ connection ] , ( [ _connection ] ) =>
88
95
_connection . chain . next ( Number ( dynamic . network ) ) ,
89
96
)
90
- } , [ dynamic . network ] )
97
+ } , [ dynamic . network , connection ] )
91
98
92
99
useEffect ( ( ) => {
93
100
const emailCredential = dynamic . user ?. verifiedCredentials ?. find (
94
101
( c ) => c . format === 'email' ,
95
102
)
96
103
console . log ( '**' , { emailCredential } )
97
- whenDefinedAll ( [ connection ( ) ] , ( [ _connection ] ) =>
104
+ whenDefinedAll ( [ connection ] , ( [ _connection ] ) =>
98
105
_connection . identifiers . next (
99
106
whenDefined ( emailCredential ?. publicIdentifier , ( email ) => ( {
100
107
email,
101
108
} ) ) ,
102
109
) ,
103
110
)
104
- } , [ dynamic . user ] )
111
+ } , [ dynamic . user , connection ] )
105
112
106
113
useEffect ( ( ) => {
107
114
const eoa = dynamic ?. primaryWallet ?. address
@@ -115,14 +122,14 @@ export default ({
115
122
} , [ dynamic ?. primaryWallet ?. address ] )
116
123
117
124
useEffect ( ( ) => {
118
- whenDefinedAll ( [ connection ( ) ] , ( [ _connection ] ) => {
125
+ whenDefinedAll ( [ connection ] , ( [ _connection ] ) => {
119
126
// console.log('Called here', signer)
120
127
_connection . signer . next ( signer )
121
128
} )
122
- } , [ signer ] )
129
+ } , [ signer , connection ] )
123
130
124
131
useEffect ( ( ) => {
125
- whenDefinedAll ( [ connection ( ) ] , ( [ _connection ] ) => {
132
+ whenDefinedAll ( [ connection ] , ( [ _connection ] ) => {
126
133
// console.log('$$$ Called here', signer)
127
134
128
135
// signal
@@ -144,7 +151,7 @@ export default ({
144
151
}
145
152
} )
146
153
} )
147
- } , [ ] )
154
+ } , [ connection ] )
148
155
149
156
return (
150
157
< span className = "group/awesome-onboarding relative block" >
0 commit comments