* feat: updates auth wallet to be multi address compatible * chore: updates `auth` to v2.0.0 * chore: updates `react-dapp-auth` to auth latest * chore: updates `vue-dapp-auth` to auth latest
28 lines
772 B
TypeScript
28 lines
772 B
TypeScript
import SettingsStore from '@/store/SettingsStore'
|
|
import { createOrRestoreEIP155Wallet } from '@/utils/EIP155WalletUtil'
|
|
import { createAuthClient } from '@/utils/WalletConnectUtil'
|
|
import { useCallback, useEffect, useState } from 'react'
|
|
|
|
export default function useInitialization() {
|
|
const [initialized, setInitialized] = useState(false)
|
|
|
|
const onInitialize = useCallback(async () => {
|
|
try {
|
|
const { eip155Addresses } = createOrRestoreEIP155Wallet()
|
|
SettingsStore.setEIP155Address(eip155Addresses[0])
|
|
await createAuthClient()
|
|
setInitialized(true)
|
|
} catch (err: unknown) {
|
|
alert(err)
|
|
}
|
|
}, [])
|
|
|
|
useEffect(() => {
|
|
if (!initialized) {
|
|
onInitialize()
|
|
}
|
|
}, [initialized, onInitialize])
|
|
|
|
return initialized
|
|
}
|