Skip to content

Commit 2e84dd3

Browse files
fix: repeated signin
1 parent a8a8d63 commit 2e84dd3

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devprotocol/clubs-plugin-posts",
3-
"version": "0.20.10",
3+
"version": "0.20.11",
44
"type": "module",
55
"description": "Template repository for using TypeScript",
66
"main": "dist/index.js",

src/components/Page/Index.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,22 @@ const testPermission = async (
108108
}
109109
110110
const handleConnection = async (signer: UndefinedOr<Signer>) => {
111+
let newSigner: Signer = signer as Signer
112+
console.log({ signer })
111113
if (!signer) {
112-
return
114+
const { connection: conct } = await import(
115+
'@devprotocol/clubs-core/connection'
116+
)
117+
connection.value = conct
118+
newSigner = conct().signer.value
119+
console.log({ newSigner })
113120
}
114-
121+
console.log('inside Handle Connection')
115122
// get wallet address
116-
const connectedAddress = await signer.getAddress()
123+
const connectedAddress = signer ? await signer.getAddress() : await newSigner.getAddress()
117124
// const connectedAddress = '0x57E21bd98612DE0Bd1723F4bf81A944eF7BfF526'
118125
walletAddress.value = connectedAddress
126+
console.log({ connectedAddress })
119127
120128
const hash = getMessage(connectedAddress)
121129
@@ -176,11 +184,16 @@ onMounted(async () => {
176184
walletSigner = signer
177185
})
178186
const signer = conct().signer.value
187+
console.log({signer})
188+
console.log({walletSigner})
179189
if (signer) {
180190
const connectedAddress = await signer.getAddress()
181191
walletAddress.value = connectedAddress
182192
isVerified.value = true
183193
}
194+
setTimeout(() => {
195+
handleConnection(walletSigner)
196+
}, 1000)
184197
185198
i18n.value = i18nBase(navigator.languages)
186199
})

src/fixtures/session.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { type UndefinedOr } from '@devprotocol/util-ts'
33
import { type Signer } from 'ethers'
44
import { encode, decode } from '@devprotocol/clubs-core'
5+
import { verifyMessage } from 'ethers'
56

67
const maxValidity = 1 * 60 * 60 * 1000 // 1 hour
78

@@ -38,6 +39,14 @@ export const getSignature = async (
3839
return decode(sig) as string
3940
}
4041

42+
export const getSessionAddress = async(
43+
hash: string,
44+
sig: string,
45+
) => {
46+
const address = verifyMessage(hash, sig)
47+
return address
48+
}
49+
4150
export const consoleWarn = () => {
4251
console.log('%cWarning!!', 'color: red; font-size: 20px; background: yellow;')
4352
console.log(

0 commit comments

Comments
 (0)