@aptos-labs/wallet-adapter-core 2.3.1 → 2.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @aptos-labs/wallet-adapter-core
2
2
 
3
+ ## 2.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 22ecf6a: Throw `wallet already connected` error when trying to connect to an already connected wallet
8
+
3
9
  ## 2.3.1
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -160,7 +160,7 @@ declare class WalletCore extends EventEmitter<WalletCoreEvents> {
160
160
  @emit emits "connect" event
161
161
  @throws WalletConnectionError
162
162
  */
163
- connect(walletName: WalletName): Promise<void>;
163
+ connect(walletName: WalletName): Promise<void | string>;
164
164
  /**
165
165
  Disconnect the exisitng wallet. On success, we clear the
166
166
  current account, current network and LocalStorage data.
package/dist/index.js CHANGED
@@ -344,7 +344,9 @@ var WalletCore = class extends import_eventemitter3.default {
344
344
  return;
345
345
  if (this._connected) {
346
346
  if (((_b = this.wallet) == null ? void 0 : _b.name) === walletName)
347
- return;
347
+ throw new WalletConnectionError(
348
+ `${walletName} wallet is already connected`
349
+ ).message;
348
350
  await this.disconnect();
349
351
  }
350
352
  if (isRedirectable()) {
package/dist/index.mjs CHANGED
@@ -303,7 +303,9 @@ var WalletCore = class extends EventEmitter {
303
303
  return;
304
304
  if (this._connected) {
305
305
  if (((_b = this.wallet) == null ? void 0 : _b.name) === walletName)
306
- return;
306
+ throw new WalletConnectionError(
307
+ `${walletName} wallet is already connected`
308
+ ).message;
307
309
  await this.disconnect();
308
310
  }
309
311
  if (isRedirectable()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-labs/wallet-adapter-core",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Aptos Wallet Adapter Core",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/WalletCore.ts CHANGED
@@ -181,7 +181,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
181
181
  @emit emits "connect" event
182
182
  @throws WalletConnectionError
183
183
  */
184
- async connect(walletName: WalletName): Promise<void> {
184
+ async connect(walletName: WalletName): Promise<void | string> {
185
185
  try {
186
186
  const selectedWallet = this._wallets?.find(
187
187
  (wallet: Wallet) => wallet.name === walletName
@@ -191,7 +191,10 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
191
191
 
192
192
  if (this._connected) {
193
193
  // if the selected wallet is already connected, we don't need to connect again
194
- if (this.wallet?.name === walletName) return;
194
+ if (this.wallet?.name === walletName)
195
+ throw new WalletConnectionError(
196
+ `${walletName} wallet is already connected`
197
+ ).message;
195
198
 
196
199
  await this.disconnect();
197
200
  }