Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675) - Refactor `web3wallet` variable into a state variable Co-authored-by: Adw8 <adwaitgharpure@gmail.com> Reviewed-on: cerc-io/laconic-wallet-web#4
38 lines
880 B
TypeScript
38 lines
880 B
TypeScript
|
|
import '@ethersproject/shims';
|
|
import { Core } from '@walletconnect/core';
|
|
import { ICore } from '@walletconnect/types';
|
|
import { Web3Wallet, IWeb3Wallet } from '@walletconnect/web3wallet';
|
|
|
|
export let web3wallet:
|
|
| IWeb3Wallet
|
|
| undefined;
|
|
export let core: ICore;
|
|
|
|
export async function createWeb3Wallet() {
|
|
core = new Core({
|
|
projectId: process.env.REACT_APP_WALLET_CONNECT_PROJECT_ID,
|
|
});
|
|
|
|
const web3wallet = await Web3Wallet.init({
|
|
core,
|
|
metadata: {
|
|
name: 'Laconic Wallet',
|
|
description: 'Laconic Wallet',
|
|
url: 'https://wallet.laconic.com/',
|
|
icons: ['https://avatars.githubusercontent.com/u/92608123'],
|
|
},
|
|
});
|
|
|
|
return web3wallet;
|
|
}
|
|
|
|
export async function web3WalletPair(
|
|
web3wallet: IWeb3Wallet,
|
|
params: { uri: string },
|
|
) {
|
|
if (web3wallet) {
|
|
return await web3wallet.core.pairing.pair({ uri: params.uri });
|
|
}
|
|
}
|