Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import WalletConnect from "walletconnect";
const defaultConfig = {
bridgeUrl: "https://test-bridge.walletconnect.org",
dappName: "Example Dapp"
};
export let webConnector = new WalletConnect(defaultConfig);
/**
* @desc Initiate WalletConnect Session
* @return {Object}
*/
export async function walletConnectInitSession() {
try {
await webConnector.initSession();
} catch (error) {
console.error(error);
}
}
/**
* @desc Get WalletConnect Accounts
* @return {Array}
throw Error(`Required parameter 'providerURL' was not provided.`)
if (typeof providerURL !== 'string')
throw Error(`Passed 'providerURL' parameter ${providerURL} is not a string.`)
if (!bridgeURL)
throw Error(`Required parameter 'bridgeURL' was not provided.`)
if (typeof bridgeURL !== 'string')
throw Error(`Passed 'bridgeURL' parameter ${bridgeURL} is not a string.`)
if (!dappName)
throw Error(`Required parameter 'dappName' was not provided.`)
if (typeof dappName !== 'string')
throw Error(`Passed 'dappName' parameter ${dappName} is not a string.`)
this.providerURL = providerURL
this.bridgeURL = bridgeURL
this.dappName = dappName
this.webConnector = new WalletConnect({ bridgeUrl: this.bridgeURL, dappName: this.dappName })
}
export const walletConnectGetSession = async () => {
const webConnector = new WalletConnect({ bridgeUrl, dappName });
await webConnector.initSession();
return webConnector;
};
export async function walletConnectResetSession() {
webConnector = new WalletConnect(defaultConfig);
}