Publish wallet docker image on release / Run docker build and publish (release) Successful in 3m47s
Co-authored-by: Pranav <jadhavpranav89@gmail.com> Reviewed-on: #9 Co-authored-by: shreerang <shreerang@noreply.git.vdb.to> Co-committed-by: shreerang <shreerang@noreply.git.vdb.to>
34 lines
897 B
TypeScript
34 lines
897 B
TypeScript
import { useCallback, useEffect, useState } from 'react';
|
|
|
|
import { IWeb3Wallet } from '@walletconnect/web3wallet';
|
|
|
|
import { createWeb3Wallet } from '../utils/wallet-connect/WalletConnectUtils';
|
|
|
|
export default function useInitialization(
|
|
setWeb3wallet: React.Dispatch<React.SetStateAction<IWeb3Wallet | undefined>>,
|
|
) {
|
|
const [initialized, setInitialized] = useState(false);
|
|
|
|
const onInitialize = useCallback(async () => {
|
|
try {
|
|
const web3walletInstance = await createWeb3Wallet();
|
|
setWeb3wallet(web3walletInstance);
|
|
setInitialized(true);
|
|
} catch (err: unknown) {
|
|
console.error('Error for initializing', err);
|
|
}
|
|
}, [setWeb3wallet]);
|
|
|
|
useEffect(() => {
|
|
if (!import.meta.env.REACT_APP_WALLET_CONNECT_PROJECT_ID) {
|
|
return;
|
|
}
|
|
|
|
if (!initialized) {
|
|
onInitialize();
|
|
}
|
|
}, [initialized, onInitialize]);
|
|
|
|
return initialized;
|
|
}
|