@ -7,11 +7,12 @@ import {
import WalletConnectProvider from "@walletconnect/web3-provider" ;
import WalletConnectProvider from "@walletconnect/web3-provider" ;
import Torus from "@toruslabs/torus-embed" ;
import Torus from "@toruslabs/torus-embed" ;
import Authereum from "authereum" ;
import Authereum from "authereum" ;
import Web3Modal from "web3modal" ;
import Web3Modal , { local } from "web3modal" ;
import BurnerConnectProvider from "@burner-wallet/burner-connect-provider" ;
import BurnerConnectProvider from "@burner-wallet/burner-connect-provider" ;
import MewConnect from "@myetherwallet/mewconnect-web-client" ;
import MewConnect from "@myetherwallet/mewconnect-web-client" ;
import EventManager from "events"
import EventManager from "events"
export const INFURA _ID _KEY = 'walletconnect-infura-id'
export class RemixClient extends PluginClient {
export class RemixClient extends PluginClient {
provider
provider
@ -21,19 +22,6 @@ export class RemixClient extends PluginClient {
this . methods = [ "sendAsync" ] ;
this . methods = [ "sendAsync" ] ;
this . internalEvents = new EventManager ( )
this . internalEvents = new EventManager ( )
this . onload ( )
this . onload ( )
this . web3Modal = new Web3Modal ( {
providerOptions : this . getProviderOptions ( ) // required
} ) ;
}
async init ( ) {
const currentTheme = await this . call ( 'theme' , 'currentTheme' )
this . web3Modal . updateTheme ( currentTheme . quality )
this . on ( 'theme' , 'themeChanged' , ( theme ) => {
this . web3Modal . updateTheme ( theme . quality )
} )
}
}
/ * *
/ * *
@ -42,6 +30,9 @@ export class RemixClient extends PluginClient {
async onConnect ( ) {
async onConnect ( ) {
try {
try {
this . web3Modal = new Web3Modal ( {
providerOptions : this . getProviderOptions ( ) // required
} )
this . provider = await this . web3Modal . connect ( ) ;
this . provider = await this . web3Modal . connect ( ) ;
} catch ( e ) {
} catch ( e ) {
console . error ( "Could not get a wallet connection" , e ) ;
console . error ( "Could not get a wallet connection" , e ) ;
@ -85,14 +76,17 @@ export class RemixClient extends PluginClient {
else if ( id === 42 ) networkName = "Kovan" ;
else if ( id === 42 ) networkName = "Kovan" ;
else networkName = "Custom" ;
else networkName = "Custom" ;
return networkName
return networkName
}
getInfuraId ( ) {
return localStorage . getItem ( INFURA _ID _KEY )
}
}
/ * *
/ * *
* Disconnect wallet button pressed .
* Disconnect wallet button pressed .
* /
* /
async onDisconnect ( ) {
async onDisconnect ( ) {
this . web3Modal = null
// TODO: Which providers have close method?
// TODO: Which providers have close method?
if ( this . provider && this . provider . close ) {
if ( this . provider && this . provider . close ) {
await this . provider . close ( ) ;
await this . provider . close ( ) ;
@ -106,7 +100,6 @@ export class RemixClient extends PluginClient {
} else {
} else {
this . internalEvents . emit ( 'disconnect' )
this . internalEvents . emit ( 'disconnect' )
}
}
}
}
getProviderOptions ( ) {
getProviderOptions ( ) {
@ -114,7 +107,7 @@ export class RemixClient extends PluginClient {
walletconnect : {
walletconnect : {
package : WalletConnectProvider ,
package : WalletConnectProvider ,
options : {
options : {
infuraId : '66e95624569c4b47a67648448e32126e' ,
infuraId : this . getInfuraId ( ) ,
bridge : 'https://wallet-connect-bridge.dyn.plugin.remixproject.org:8080/'
bridge : 'https://wallet-connect-bridge.dyn.plugin.remixproject.org:8080/'
}
}
} ,
} ,
@ -134,7 +127,7 @@ export class RemixClient extends PluginClient {
mewconnect : {
mewconnect : {
package : MewConnect , // required
package : MewConnect , // required
options : {
options : {
infuraId : "66e95624569c4b47a67648448e32126e" // required
infuraId : this . getInfuraId ( ) // required
}
}
}
}
/ * ,
/ * ,