@aptos-labs/wallet-adapter-core 2.3.0 → 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,23 @@
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
+
9
+ ## 2.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 06f334f: @aptos-labs/wallet-adapter-core:
14
+ Fixes ssr issue with checking for mobile wallets
15
+
16
+ @aptos-labs/wallet-adapter-mui-design:
17
+ Breaking:
18
+ When on a mobile phone on the native browser, we removed all wallets that are not able to be deep linked to.
19
+ The previous functionally would take them to the extension, which would not help users on mobile phones.
20
+
3
21
  ## 2.3.0
4
22
 
5
23
  ### Minor 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
@@ -210,7 +210,7 @@ function isInAppBrowser() {
210
210
  return isIphone || isAndroid;
211
211
  }
212
212
  function isRedirectable() {
213
- if (!navigator)
213
+ if (typeof navigator === "undefined" || !navigator)
214
214
  return false;
215
215
  return isMobile() && !isInAppBrowser();
216
216
  }
@@ -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
@@ -169,7 +169,7 @@ function isInAppBrowser() {
169
169
  return isIphone || isAndroid;
170
170
  }
171
171
  function isRedirectable() {
172
- if (!navigator)
172
+ if (typeof navigator === "undefined" || !navigator)
173
173
  return false;
174
174
  return isMobile() && !isInAppBrowser();
175
175
  }
@@ -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.0",
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
  }
@@ -18,7 +18,7 @@ export function isInAppBrowser(): boolean {
18
18
 
19
19
  export function isRedirectable(): boolean {
20
20
  // SSR: return false
21
- if (!navigator) return false;
21
+ if (typeof navigator === 'undefined' || !navigator) return false;
22
22
 
23
23
  // if we are on mobile and NOT in a in-app browser we will redirect to a wallet app
24
24