diff --git a/packages/wallet-manager/src/WalletManagerController.ts b/packages/wallet-manager/src/WalletManagerController.ts index ed2ca6c9..590bcd54 100644 --- a/packages/wallet-manager/src/WalletManagerController.ts +++ b/packages/wallet-manager/src/WalletManagerController.ts @@ -95,7 +95,7 @@ export class WalletManagerController implements IWalletManagerController { */ public async connectEvmWallet(): Promise { await this.evmWallet?.connect(); - this.account = this.evmWallet?.account; + this.account = this.evmWallet?.address; this.host.requestUpdate(); } diff --git a/packages/wallet-manager/src/wallets/Evm/Evm.ts b/packages/wallet-manager/src/wallets/Evm/Evm.ts index 640b63ad..99bda695 100644 --- a/packages/wallet-manager/src/wallets/Evm/Evm.ts +++ b/packages/wallet-manager/src/wallets/Evm/Evm.ts @@ -9,9 +9,10 @@ import { IEvmWallet } from '../interfaces'; import { AddChain } from '../../types'; class EvmWallet extends events.EventEmitter implements IEvmWallet { - public account: string | undefined; - public web3Provider!: Web3Provider; - public windowConnector: ExternalProvider; + address?: string; + signer?: ethers.Signer; + web3Provider!: Web3Provider; + windowConnector: ExternalProvider; constructor(provider?: Web3Provider) { super(); @@ -57,7 +58,7 @@ class EvmWallet extends events.EventEmitter implements IEvmWallet { */ private async calculateAccountData(accounts?: string[]): Promise { if (accounts?.length) { - this.account = accounts[0]; + this.address = accounts[0]; } const _accounts = await this.web3Provider.listAccounts(); @@ -66,7 +67,8 @@ class EvmWallet extends events.EventEmitter implements IEvmWallet { return; } - this.account = _accounts![0]; + this.address = _accounts![0]; + this.signer = this.web3Provider.getSigner(); } /** @@ -117,7 +119,7 @@ class EvmWallet extends events.EventEmitter implements IEvmWallet { this.reConnectToProvider(); await this.calculateAccountData(accounts); - this.emit('walletAccountChanged', this.account); + this.emit('walletAccountChanged', this.address); } ); } @@ -141,7 +143,8 @@ class EvmWallet extends events.EventEmitter implements IEvmWallet { .request!({ method: 'eth_requestAccounts' }); - this.account = accounts[0]; + this.address = accounts[0]; + this.signer = this.web3Provider.getSigner(); } catch (e) { throw e; } diff --git a/packages/wallet-manager/src/wallets/interfaces/index.ts b/packages/wallet-manager/src/wallets/interfaces/index.ts index 075eb170..9b988822 100644 --- a/packages/wallet-manager/src/wallets/interfaces/index.ts +++ b/packages/wallet-manager/src/wallets/interfaces/index.ts @@ -2,6 +2,7 @@ import { Web3Provider, ExternalProvider } from '@ethersproject/providers'; import { ApiPromise, WsProvider } from '@polkadot/api'; import { ReactiveController } from 'lit'; import { AddChain } from '../../types'; +import { Signer } from '@ethersproject/abstract-signer'; export interface SupportedWallet { id: string; @@ -13,7 +14,8 @@ export interface SupportedWallet { export interface IEvmWallet { web3Provider: Web3Provider; windowConnector: ExternalProvider; - account?: string; + address?: string; + signer?: Signer; connect(): Promise; addChain({ chainId, @@ -53,4 +55,4 @@ export interface IWalletManagerController extends ReactiveController { addChain(addChainParameters: AddChain): Promise; connectoToSubstrate(): Promise; connectEvmWallet(): Promise; -} \ No newline at end of file +}