@aptos-labs/wallet-adapter-core 5.1.0 → 5.1.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/src/WalletCore.ts CHANGED
@@ -486,6 +486,26 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
486
486
  * @param walletName. The wallet name we want to connect with.
487
487
  */
488
488
  async connect(walletName: string): Promise<void | string> {
489
+ // First, handle mobile case
490
+ // Check if we are in a redirectable view (i.e on mobile AND not in an in-app browser)
491
+ if (isRedirectable()) {
492
+ const selectedWallet = this._standard_not_detected_wallets.find(
493
+ (wallet: AdapterNotDetectedWallet) => wallet.name === walletName
494
+ );
495
+
496
+ if (selectedWallet) {
497
+ // If wallet has a deeplinkProvider property, use it
498
+ const uninstalledWallet =
499
+ selectedWallet as unknown as AptosStandardSupportedWallet;
500
+ if (uninstalledWallet.deeplinkProvider) {
501
+ const url = encodeURIComponent(window.location.href);
502
+ const location = uninstalledWallet.deeplinkProvider.concat(url);
503
+ window.location.href = location;
504
+ return;
505
+ }
506
+ }
507
+ }
508
+
489
509
  // Checks the wallet exists in the detected wallets array
490
510
  const allDetectedWallets = this._standard_wallets;
491
511
 
@@ -504,33 +524,6 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
504
524
  ).message;
505
525
  }
506
526
 
507
- // Check if we are in a redirectable view (i.e on mobile AND not in an in-app browser)
508
- // Ignore if wallet is installed (iOS extension)
509
- if (isRedirectable()) {
510
- if (selectedWallet.readyState === WalletReadyState.Installed) {
511
- // If wallet has a openInMobileApp method, use it
512
- if (selectedWallet.features["aptos:openInMobileApp"]?.openInMobileApp) {
513
- selectedWallet.features["aptos:openInMobileApp"]?.openInMobileApp();
514
- return;
515
- }
516
- }
517
-
518
- if (selectedWallet.readyState === WalletReadyState.NotDetected) {
519
- // If wallet has a deeplinkProvider property, i.e wallet is on the internal registry, use it
520
- const uninstalledWallet =
521
- selectedWallet as unknown as AptosStandardSupportedWallet;
522
- if (uninstalledWallet.deeplinkProvider) {
523
- const url = encodeURIComponent(window.location.href);
524
- const location = uninstalledWallet.deeplinkProvider.concat(url);
525
- window.location.href = location;
526
- return;
527
- }
528
- }
529
- }
530
-
531
- // If true, the wallet was redirected to the mobile app's browser.
532
- if (this.redirectIfRedirectable(selectedWallet)) return;
533
-
534
527
  await this.connectWallet(selectedWallet, async () => {
535
528
  const response = await selectedWallet.features["aptos:connect"].connect();
536
529
  if (response.status === UserResponseStatus.REJECTED) {
@@ -564,26 +557,27 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
564
557
  );
565
558
 
566
559
  if (!selectedWallet) {
567
- throw new WalletNotFoundError(`Wallet ${walletName} not found`);
560
+ throw new WalletNotFoundError(`Wallet ${walletName} not found`).message;
568
561
  }
569
562
 
570
563
  if (!selectedWallet.features["aptos:signIn"]) {
571
564
  throw new WalletNotSupportedMethod(
572
565
  `aptos:signIn is not supported by ${walletName}`
573
- );
566
+ ).message;
574
567
  }
575
568
 
576
569
  return await this.connectWallet(selectedWallet, async () => {
577
570
  if (!selectedWallet.features["aptos:signIn"]) {
578
571
  throw new WalletNotSupportedMethod(
579
572
  `aptos:signIn is not supported by ${selectedWallet.name}`
580
- );
573
+ ).message;
581
574
  }
582
575
 
583
576
  const response =
584
577
  await selectedWallet.features["aptos:signIn"].signIn(input);
585
578
  if (response.status === UserResponseStatus.REJECTED) {
586
- throw new WalletConnectionError("User has rejected the request");
579
+ throw new WalletConnectionError("User has rejected the request")
580
+ .message;
587
581
  }
588
582
 
589
583
  return { account: response.args.account, output: response.args };
@@ -625,39 +619,6 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
625
619
  }
626
620
  }
627
621
 
628
- /**
629
- * If the wallet is in a Mobile browser, it should be redirected to the Mobile wallet's browser.
630
- * 1. Check if we are in a redirectable view (i.e on mobile AND not in an in-app browser)
631
- * 2. Ignore if wallet is installed (iOS extension)
632
- *
633
- * @returns boolean true if the wallet was redirected, false otherwise.
634
- */
635
- private redirectIfRedirectable(selectedWallet: AdapterWallet): boolean {
636
- if (isRedirectable()) {
637
- if (selectedWallet.readyState === WalletReadyState.Installed) {
638
- // If wallet has a openInMobileApp method, use it
639
- if (selectedWallet.features["aptos:openInMobileApp"]?.openInMobileApp) {
640
- selectedWallet.features["aptos:openInMobileApp"]?.openInMobileApp();
641
- return true;
642
- }
643
- }
644
-
645
- if (selectedWallet.readyState === WalletReadyState.NotDetected) {
646
- // If wallet has a deeplinkProvider property, i.e wallet is on the internal registry, use it
647
- const uninstalledWallet =
648
- selectedWallet as unknown as AptosStandardSupportedWallet;
649
- if (uninstalledWallet.deeplinkProvider) {
650
- const url = encodeURIComponent(window.location.href);
651
- const location = uninstalledWallet.deeplinkProvider.concat(url);
652
- window.location.href = location;
653
- return true;
654
- }
655
- }
656
- }
657
-
658
- return false;
659
- }
660
-
661
622
  /**
662
623
  * Disconnect the current connected wallet. On success, we clear the
663
624
  * current account, current network and LocalStorage data.
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const WALLET_ADAPTER_CORE_VERSION = "5.1.0";
1
+ export const WALLET_ADAPTER_CORE_VERSION = "5.1.2";