@dynamic-labs/sdk-react-core 4.9.5 → 4.9.7

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.
@@ -137,6 +137,9 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
137
137
  clearStackAndPushInitialView();
138
138
  };
139
139
  const handleWalletConnectionError = (error) => {
140
+ if (error instanceof utils.GetAddressCancelledError) {
141
+ return;
142
+ }
140
143
  clearStackAndPushInitialView();
141
144
  if (error instanceof utils.CustomError) {
142
145
  setError(error.message, error.code);
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../../_virtual/_tslib.js';
3
- import { StorageService, CustomError } from '@dynamic-labs/utils';
3
+ import { StorageService, GetAddressCancelledError, CustomError } from '@dynamic-labs/utils';
4
4
  import { isEmailWalletConnector, isEmailOTPWalletConnector, isBloctoConnector } from '@dynamic-labs/wallet-connector-core';
5
5
  import { useCaptchaContext } from '../../../../context/CaptchaContext/CaptchaContext.js';
6
6
  import 'react';
@@ -133,6 +133,9 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
133
133
  clearStackAndPushInitialView();
134
134
  };
135
135
  const handleWalletConnectionError = (error) => {
136
+ if (error instanceof GetAddressCancelledError) {
137
+ return;
138
+ }
136
139
  clearStackAndPushInitialView();
137
140
  if (error instanceof CustomError) {
138
141
  setError(error.message, error.code);
@@ -6,10 +6,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
7
  var React = require('react');
8
8
  var utils = require('@dynamic-labs/utils');
9
- var sdkApiCore = require('@dynamic-labs/sdk-api-core');
10
9
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
11
10
  var localStorage = require('../../constants/localStorage.cjs');
12
11
  var utils$1 = require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/utils.cjs');
12
+ require('@dynamic-labs/sdk-api-core');
13
13
  require('../../../config/ApiEndpoint.cjs');
14
14
  require('../../constants/values.cjs');
15
15
  require('@dynamic-labs/multi-wallet');
@@ -110,11 +110,10 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
110
110
  }
111
111
  return decodedSessionKeys === null || decodedSessionKeys === void 0 ? void 0 : decodedSessionKeys.publicKey;
112
112
  };
113
- const shouldRegisterSessionKeysOnSignin = () => {
114
- var _a;
115
- return ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.defaultWalletVersion) ===
116
- sdkApiCore.EmbeddedWalletVersionEnum.V2;
117
- };
113
+ // this is a temporary fix to ensure that session keys are registered on signin for all wallets
114
+ // the user is undefined at this point in the auth flow and we cant check the users wallet version
115
+ // so we just return true for now
116
+ const shouldRegisterSessionKeysOnSignin = () => true;
118
117
  const toEncodedFormat = (publicKey, privateKey, privateKeyJwk, registered, expirationDate) => {
119
118
  const sessionKeys = {
120
119
  expirationDate,
@@ -2,10 +2,10 @@
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { useCallback } from 'react';
4
4
  import { StorageService, InvalidEmbeddedWalletSessionKeyError } from '@dynamic-labs/utils';
5
- import { EmbeddedWalletVersionEnum } from '@dynamic-labs/sdk-api-core';
6
5
  import { logger } from '@dynamic-labs/wallet-connector-core';
7
6
  import { SECURE_ENCLAVE_WALLET_SESSION_KEYS, SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS } from '../../constants/localStorage.js';
8
7
  import { p256Sign, p256Keygen } from '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/utils.js';
8
+ import '@dynamic-labs/sdk-api-core';
9
9
  import '../../../config/ApiEndpoint.js';
10
10
  import '../../constants/values.js';
11
11
  import '@dynamic-labs/multi-wallet';
@@ -106,11 +106,10 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
106
106
  }
107
107
  return decodedSessionKeys === null || decodedSessionKeys === void 0 ? void 0 : decodedSessionKeys.publicKey;
108
108
  };
109
- const shouldRegisterSessionKeysOnSignin = () => {
110
- var _a;
111
- return ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.defaultWalletVersion) ===
112
- EmbeddedWalletVersionEnum.V2;
113
- };
109
+ // this is a temporary fix to ensure that session keys are registered on signin for all wallets
110
+ // the user is undefined at this point in the auth flow and we cant check the users wallet version
111
+ // so we just return true for now
112
+ const shouldRegisterSessionKeysOnSignin = () => true;
114
113
  const toEncodedFormat = (publicKey, privateKey, privateKeyJwk, registered, expirationDate) => {
115
114
  const sessionKeys = {
116
115
  expirationDate,
@@ -102,7 +102,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
102
102
  const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnectorKey, walletConnectorOptions, setQrcodeUri, setDesktopUri, user, linkedWallets, setLegacyIsVerifying, authMode, } = useInternalDynamicContext.useInternalDynamicContext();
103
103
  const { mockedSDK } = MockContext.useMockContext();
104
104
  const { setError, setErrorMessage } = ErrorContext.useErrorContext();
105
- const { pushView, clearStackAndPushInitialView } = ViewContext.useViewContext();
105
+ const { pushView, clearStackAndPushInitialView, replaceView } = ViewContext.useViewContext();
106
106
  const handleCustodialWalletClick = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
107
107
  logger.logger.debug('handleCustodialWalletClick', walletConnector);
108
108
  const twoStepAuthentication = requiresTwoStepAuthentication.requiresTwoStepAuthentication(walletConnector);
@@ -149,7 +149,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
149
149
  logger.logger.debug('handleUninstalledClick', walletConnector);
150
150
  setSelectedWalletConnectorKey(walletConnector.key);
151
151
  if (!walletConnector.canConnectViaQrCode) {
152
- pushView('no-qr-not-installed');
152
+ replaceView('no-qr-not-installed');
153
153
  }
154
154
  else {
155
155
  onQrCodeConnect({
@@ -163,7 +163,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
163
163
  },
164
164
  walletConnector,
165
165
  });
166
- pushView('qr-code');
166
+ replaceView('qr-code');
167
167
  }
168
168
  setError(undefined);
169
169
  });
@@ -211,11 +211,11 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
211
211
  const { walletConnector, isInstalledOnBrowser } = wallet;
212
212
  const shouldEndWalletConnectorSession = walletConnector.connectedChain === 'FLOW' ||
213
213
  walletConnectorCore.isPhantomRedirectConnector(walletConnector) ||
214
- // because WC only supports one connection at a time,
214
+ // because some wallet connectors only supports one connection at a time,
215
215
  // we need to end the session (disconnect) when the user selects
216
216
  // a different wallet to connect with
217
217
  // a new connection is established a few steps further down
218
- walletConnectorCore.isWalletConnectConnector(walletConnector);
218
+ !walletConnector.canHandleMultipleConnections;
219
219
  logger.logger.logVerboseTroubleshootingMessage('[handleWalletItemClick]', {
220
220
  mockedSDK,
221
221
  shouldEndWalletConnectorSession,
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../../_virtual/_tslib.js';
3
3
  import { StorageService, isMobile, UserRejectedRequestError } from '@dynamic-labs/utils';
4
- import { isPhantomRedirectConnector, isWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
4
+ import { isPhantomRedirectConnector } from '@dynamic-labs/wallet-connector-core';
5
5
  import 'react';
6
6
  import '../../../../context/DynamicContext/DynamicContext.js';
7
7
  import '@dynamic-labs/sdk-api-core';
@@ -98,7 +98,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
98
98
  const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnectorKey, walletConnectorOptions, setQrcodeUri, setDesktopUri, user, linkedWallets, setLegacyIsVerifying, authMode, } = useInternalDynamicContext();
99
99
  const { mockedSDK } = useMockContext();
100
100
  const { setError, setErrorMessage } = useErrorContext();
101
- const { pushView, clearStackAndPushInitialView } = useViewContext();
101
+ const { pushView, clearStackAndPushInitialView, replaceView } = useViewContext();
102
102
  const handleCustodialWalletClick = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
103
103
  logger.debug('handleCustodialWalletClick', walletConnector);
104
104
  const twoStepAuthentication = requiresTwoStepAuthentication(walletConnector);
@@ -145,7 +145,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
145
145
  logger.debug('handleUninstalledClick', walletConnector);
146
146
  setSelectedWalletConnectorKey(walletConnector.key);
147
147
  if (!walletConnector.canConnectViaQrCode) {
148
- pushView('no-qr-not-installed');
148
+ replaceView('no-qr-not-installed');
149
149
  }
150
150
  else {
151
151
  onQrCodeConnect({
@@ -159,7 +159,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
159
159
  },
160
160
  walletConnector,
161
161
  });
162
- pushView('qr-code');
162
+ replaceView('qr-code');
163
163
  }
164
164
  setError(undefined);
165
165
  });
@@ -207,11 +207,11 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
207
207
  const { walletConnector, isInstalledOnBrowser } = wallet;
208
208
  const shouldEndWalletConnectorSession = walletConnector.connectedChain === 'FLOW' ||
209
209
  isPhantomRedirectConnector(walletConnector) ||
210
- // because WC only supports one connection at a time,
210
+ // because some wallet connectors only supports one connection at a time,
211
211
  // we need to end the session (disconnect) when the user selects
212
212
  // a different wallet to connect with
213
213
  // a new connection is established a few steps further down
214
- isWalletConnectConnector(walletConnector);
214
+ !walletConnector.canHandleMultipleConnections;
215
215
  logger.logVerboseTroubleshootingMessage('[handleWalletItemClick]', {
216
216
  mockedSDK,
217
217
  shouldEndWalletConnectorSession,
@@ -1,7 +1,7 @@
1
1
  import { WalletOption } from '../../../shared';
2
2
  export declare const useWalletOptions: () => {
3
3
  getFilteredWalletOptions: (filter: (options: WalletOption[]) => WalletOption[]) => {
4
- chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS" | "BTC" | "ECLIPSE";
4
+ chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS" | "BTC" | "ECLIPSE" | "SUI";
5
5
  group: string | undefined;
6
6
  groupName: string | undefined;
7
7
  isInstalledOnBrowser: boolean;
@@ -11,7 +11,7 @@ export declare const useWalletOptions: () => {
11
11
  }[];
12
12
  selectWalletOption: (walletKey: string, selectGroupIfAvailable?: boolean) => Promise<void>;
13
13
  walletOptions: {
14
- chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS" | "BTC" | "ECLIPSE";
14
+ chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS" | "BTC" | "ECLIPSE" | "SUI";
15
15
  group: string | undefined;
16
16
  groupName: string | undefined;
17
17
  isInstalledOnBrowser: boolean;
@@ -4,7 +4,7 @@ interface IChain {
4
4
  enabled: boolean;
5
5
  name: string;
6
6
  }
7
- export declare const getEnabledChains: (chains: IChain[]) => ("STARK" | "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "ATOM" | "COSMOS" | "BTC" | "ECLIPSE")[];
7
+ export declare const getEnabledChains: (chains: IChain[]) => ("STARK" | "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "ATOM" | "COSMOS" | "BTC" | "ECLIPSE" | "SUI")[];
8
8
  type BaseGetSupportedWalletOpts = Omit<GetSupportedWalletsOpts, 'walletConnectProjectId' | 'chainRpcProviders'>;
9
9
  export declare const getWallets: (props: {
10
10
  getSupportedWalletOpts: BaseGetSupportedWalletOpts;