update web3modal version

pull/3674/head
yann300 4 years ago committed by Aniket
parent 97b9181494
commit 257a22769a
  1. 32010
      package-lock.json
  2. 2
      src/App.js
  3. 56
      src/RemixClient.js

32010
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -5,7 +5,7 @@ import { RemixClient } from './RemixClient'
function App() {
const p = new RemixClient()
const openModal = () => {
p.openModal()
p.onConnect()
}
const clearLocalStorage = () => {
localStorage.clear()

@ -4,7 +4,6 @@ import WalletConnectProvider from "@walletconnect/web3-provider";
import Torus from "@toruslabs/torus-embed";
import Authereum from "authereum";
import Web3Modal from "web3modal";
import UniLogin from "@unilogin/provider";
import BurnerConnectProvider from "@burner-wallet/burner-connect-provider";
import MewConnect from "@myetherwallet/mewconnect-web-client";
import EventManager from "events"
@ -18,10 +17,13 @@ export class RemixClient extends PluginClient {
this.internalEvents = new EventManager()
createClient(this);
this.onload()
this.web3Modal = new Web3Modal({
providerOptions: this.getProviderOptions() // required
});
}
async initModal () {
try {
async init() {
const currentTheme = await this.call('theme', 'currentTheme')
console.log('theme', currentTheme)
this.web3Modal.updateTheme(currentTheme.quality)
@ -31,33 +33,38 @@ export class RemixClient extends PluginClient {
console.log('theme', theme)
})
this.web3Modal.on('connect', (provider) => {
this.provider = provider
this.internalEvents.emit('accountsChanged', provider.accounts || [])
this.internalEvents.emit('chainChanged', provider.chainId)
}
/**
* Connect wallet button pressed.
*/
async onConnect() {
console.log("Opening a dialog", this.web3Modal);
try {
this.provider = await this.web3Modal.connect();
} catch(e) {
console.log("Could not get a wallet connection", e);
return;
}
this.internalEvents.emit('accountsChanged', this.provider.accounts || [])
this.internalEvents.emit('chainChanged', this.provider.chainId)
// Subscribe to accounts change
this.provider.on("accountsChanged", (accounts) => {
this.internalEvents.emit('accountsChanged', accounts || [])
});
this.provider.on("chainChanged", (chain) => {
this.internalEvents.emit('chainChanged', chain)
// Subscribe to chainId change
this.provider.on("chainChanged", (chainId) => {
this.internalEvents.emit('chainChanged', chainId)
});
})
} catch (e) {
console.log(e)
}
}
async openModal () {
if (!this.web3Modal) {
this.web3Modal = new Web3Modal({
providerOptions: this.getProviderOptions() // required
// Subscribe to networkId change
this.provider.on("networkChanged", (networkId) => {
this.internalEvents.emit('networkChanged', networkId)
});
await this.initModal()
}
if (!this.web3Modal.show) {
this.web3Modal.toggleModal()
}
}
getProviderOptions () {
@ -75,9 +82,6 @@ export class RemixClient extends PluginClient {
authereum: {
package: Authereum
},
unilogin: {
package: UniLogin // required
},
burnerconnect: {
package: BurnerConnectProvider, // required
options: {

Loading…
Cancel
Save