@ngeth/ethers-core
Advanced tools
Comparing version 0.0.21 to 0.0.22
{ | ||
"name": "@ngeth/ethers-core", | ||
"version": "0.0.21", | ||
"version": "0.0.22", | ||
"type": "commonjs", | ||
@@ -5,0 +5,0 @@ "peerDependencies": { |
@@ -12,2 +12,4 @@ import { JsonRpcSigner, Web3Provider } from '@ethersproject/providers'; | ||
protected abstract onWalletChange(wallet: Wallet): void; | ||
/** Used to run AFTER constructor from the mixins like ngErc1193 */ | ||
protected onInit?(): void; | ||
get ethersProvider(): Web3Provider | undefined; | ||
@@ -14,0 +16,0 @@ get ethersSigner(): JsonRpcSigner | undefined; |
@@ -6,3 +6,3 @@ import { ERC1193 } from './erc1193'; | ||
wallets: WalletProfile[]; | ||
constructor(); | ||
protected onInit(): void; | ||
protected onWalletChange(wallet: WalletProfile): void; | ||
@@ -9,0 +9,0 @@ protected getWallet(): Promise<WalletProfile | undefined>; |
@@ -25,9 +25,18 @@ "use strict"; | ||
constructor() { | ||
super(); | ||
super(...arguments); | ||
this.wallets = getInjectedProviders().map(toInjectedWallet); | ||
} | ||
onInit() { | ||
if (this.wallets.length === 1) | ||
this.selectWallet(this.wallets[0]); | ||
const label = localStorage.getItem('ngeth:erc1193'); | ||
if (label) { | ||
const wallet = this.wallets.find(wallet => wallet.label === label); | ||
if (wallet) | ||
this.selectWallet(wallet); | ||
} | ||
} | ||
onWalletChange(wallet) { | ||
this.wallet = wallet; | ||
localStorage.setItem('ngeth:erc1193', wallet.label); | ||
} | ||
@@ -34,0 +43,0 @@ async getWallet() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
40383
589