How to use the @0xcert/ethereum-generic-provider.ProviderEvent.NETWORK_CHANGE function in @0xcert/ethereum-generic-provider

To help you get started, we’ve selected a few @0xcert/ethereum-generic-provider examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xcert / framework / packages / 0xcert-ethereum-metamask-provider / src / core / provider.ts View on Github external
protected async installEvents() {

    const networkVersion = await this.getNetworkVersion();
    if (networkVersion !== this._networkVersion) {
      this.emit(ProviderEvent.NETWORK_CHANGE, networkVersion, this._networkVersion);
      this._networkVersion = networkVersion;
    }

    this.accountId = await this.getAvailableAccounts().then((a) => a[0]);

    setTimeout(() => this.installEvents(), 1000);
  }