@@ -25,7 +25,7 @@ import {
2525 hasWritePermission ,
2626} from ' ../../fixtures/memberships'
2727import { JsonRpcProvider } from ' ethers'
28- import { getSignature , getMessage , consoleWarn } from ' ../../fixtures/session'
28+ import { getSignature , getMessage , checkSession , consoleWarn } from ' ../../fixtures/session'
2929import { Strings } from ' ../../i18n'
3030
3131type Props = {
@@ -123,20 +123,15 @@ const handleConnection = async (signer: UndefinedOr<Signer>) => {
123123 const connectedAddress = signer
124124 ? await signer .getAddress ()
125125 : await newSigner .getAddress ()
126- // const connectedAddress = '0x57E21bd98612DE0Bd1723F4bf81A944eF7BfF526'
126+
127127 walletAddress .value = connectedAddress
128- console .log ({ connectedAddress })
129128
130- const hash = getMessage (connectedAddress )
131-
132- let sig = await getSignature (connectedAddress , signer )
133-
134- fetchPosts ({ hash , sig })
135-
136- hasEditableRole .value = await testPermission (
137- walletAddress .value ,
138- new JsonRpcProvider (props .rpcUrl ),
139- )
129+ if (isVerified .value ){
130+ hasEditableRole .value = await testPermission (
131+ walletAddress .value ,
132+ new JsonRpcProvider (props .rpcUrl ),
133+ )
134+ }
140135}
141136
142137const fetchPosts = async ({ hash , sig }: { hash? : string ; sig? : string }) => {
@@ -182,32 +177,32 @@ onMounted(async () => {
182177 ' @devprotocol/clubs-core/connection'
183178 )
184179 connection .value = conct
185- conct ().signer .subscribe ((signer : UndefinedOr <Signer >) => {
186- walletSigner = signer
187- })
188- const signer = conct ().signer .value
189- console .log ({ signer })
190- console .log ({ walletSigner })
191- if (signer ) {
180+ conct ().signer .subscribe (async (signer : UndefinedOr <Signer >) => {
181+ if (signer ) {
192182 const connectedAddress = await signer .getAddress ()
193183 walletAddress .value = connectedAddress
194- isVerified .value = true
195- }
196- setTimeout (() => {
197- handleConnection (walletSigner )
198- }, 1000 )
199-
184+ isVerified .value = await checkSession ( connectedAddress )
185+ console . log ( " isverfied " , isVerified . value )
186+ walletSigner = signer
187+ handleConnection (signer )
188+ }
189+ })
200190 i18n .value = i18nBase (navigator .languages )
201191})
202192
203193const isVerified = ref (false )
204194
205195const handleVerify = async () => {
206- handleConnection (walletSigner )
196+ const walletAddres = await walletSigner ?.getAddress () as string
197+ const hash = getMessage (walletAddres )
198+ let sig = await getSignature (walletAddres , walletSigner as Signer )
199+ fetchPosts ({ hash , sig })
207200 //
208201 if (connection .value ?.().signer .value ) {
209202 isVerified .value = true
210203 }
204+
205+ handleConnection (walletSigner )
211206}
212207
213208const handlePostSuccess = (post : Posts ) => {
0 commit comments