@broxus/evm-connect 1.8.0 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ import Web3 from 'web3';
4
4
  import { type EthereumConnector } from '../core';
5
5
  import { type AddEthereumChainParams, type EvmNetworkConfig, type EvmWalletProviderConfig, type WatchAssetParameters } from '../types';
6
6
  export interface EvmWalletServiceCtorParams {
7
+ autoInit?: boolean;
7
8
  defaultNetworkId?: number;
8
9
  /**
9
10
  * List of supported networks
@@ -31,6 +32,7 @@ export declare class EvmWalletService extends AbstractStore<EvmWalletServiceData
31
32
  * @returns {EthereumConnector|undefined}
32
33
  */
33
34
  get connector(): EthereumConnector | undefined;
35
+ init(): Promise<void>;
34
36
  /**
35
37
  * Manually connect to the wallet
36
38
  * @returns {Promise<void>}
@@ -170,7 +172,7 @@ export declare class EvmWalletService extends AbstractStore<EvmWalletServiceData
170
172
  * Trying to resolve EVM Wallet connection
171
173
  * @protected
172
174
  */
173
- protected init(): Promise<void>;
175
+ protected _init(): Promise<void>;
174
176
  protected accountDisposer: IReactionDisposer | undefined;
175
177
  protected networkDisposer: IReactionDisposer | undefined;
176
178
  }
@@ -25,9 +25,12 @@ export class EvmWalletService extends AbstractStore {
25
25
  providerId: params?.providerId,
26
26
  }));
27
27
  makeObservable(this);
28
- this.init().catch(reason => {
29
- error('Wallet init failed with an error', reason);
30
- });
28
+ const autoInit = params?.autoInit ?? true;
29
+ if (autoInit) {
30
+ this._init().catch(reason => {
31
+ error('Wallet init failed with an error', reason);
32
+ });
33
+ }
31
34
  }
32
35
  /**
33
36
  * Define current provider connector
@@ -36,6 +39,9 @@ export class EvmWalletService extends AbstractStore {
36
39
  get connector() {
37
40
  return this.providers?.find(config => config.id === this.providerId)?.connector;
38
41
  }
42
+ async init() {
43
+ await this._init();
44
+ }
39
45
  /**
40
46
  * Manually connect to the wallet
41
47
  * @returns {Promise<void>}
@@ -283,7 +289,7 @@ export class EvmWalletService extends AbstractStore {
283
289
  * Trying to resolve EVM Wallet connection
284
290
  * @protected
285
291
  */
286
- async init() {
292
+ async _init() {
287
293
  this.accountDisposer = reaction(() => this.address, async (address, prevAddress) => {
288
294
  if (address?.toLowerCase() !== prevAddress?.toLowerCase()) {
289
295
  this.setState('isSyncing', undefined);
@@ -310,6 +316,12 @@ __decorate([
310
316
  __metadata("design:type", Object),
311
317
  __metadata("design:paramtypes", [])
312
318
  ], EvmWalletService.prototype, "connector", null);
319
+ __decorate([
320
+ action.bound,
321
+ __metadata("design:type", Function),
322
+ __metadata("design:paramtypes", []),
323
+ __metadata("design:returntype", Promise)
324
+ ], EvmWalletService.prototype, "init", null);
313
325
  __decorate([
314
326
  action.bound,
315
327
  __metadata("design:type", Function),
@@ -451,4 +463,4 @@ __decorate([
451
463
  __metadata("design:type", Function),
452
464
  __metadata("design:paramtypes", []),
453
465
  __metadata("design:returntype", Promise)
454
- ], EvmWalletService.prototype, "init", null);
466
+ ], EvmWalletService.prototype, "_init", null);