Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async startLogin() {
let mnemonic
const isLogged = await this.isLogged()
if (isLogged) {
mnemonic = localStorage.getItem('seedphrase')
} else {
mnemonic = bip39.generateMnemonic()
localStorage.setItem('seedphrase', mnemonic)
}
localStorage.setItem('logType', 'BurnerWallet')
const provider = new HDWalletProvider(mnemonic, nodeUri, 0, 1)
this.web3 = new Web3(provider as any)
const accounts = await this.web3.eth.getAccounts()
const balance = await this.web3.eth.getBalance(accounts[0])
// fill with Ether if account balance is empty
balance === '0' && (await requestFromFaucet(provider.getAddress(0)))
}
if (provider) {
const { WebsocketProvider } = drizzle.web3.providers;
const host = new URL(Url.normalize(provider.host));
let web3Provider;
if (
Constants.regexps.providerTypes.azure.test(host.toString()) &&
provider.options &&
provider.options.mnemonic
) {
host.protocol = 'wss';
host.port = 3300;
web3Provider = new HDWalletProvider(
provider.options.mnemonic,
new WebsocketProvider(host.toString()),
);
} else {
host.protocol = 'ws';
web3Provider = new WebsocketProvider(host.toString());
}
drizzle.web3.setProvider(web3Provider);
}
const address = contractInstance.address;
const networkName = contractInstance.network.name;
const accounts = await drizzle.web3.eth.getAccounts();
const contractConfig = {