@dynamic-labs/sdk-react-core 4.0.0-alpha.30 → 4.0.0-alpha.32

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.
Files changed (23) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +11 -11
  5. package/src/lib/components/TransactionCard/TransactionCard.cjs +2 -1
  6. package/src/lib/components/TransactionCard/TransactionCard.js +2 -1
  7. package/src/lib/utils/functions/walletListBuilder/utils/applyMultiWalletFilters/applyMultiWalletFilters.cjs +5 -5
  8. package/src/lib/utils/functions/walletListBuilder/utils/applyMultiWalletFilters/applyMultiWalletFilters.js +5 -5
  9. package/src/lib/utils/functions/walletListBuilder/utils/createMetaMaskMobileFilter/createMetaMaskMobileFilter.cjs +25 -0
  10. package/src/lib/utils/functions/walletListBuilder/utils/createMetaMaskMobileFilter/createMetaMaskMobileFilter.d.ts +7 -0
  11. package/src/lib/utils/functions/walletListBuilder/utils/createMetaMaskMobileFilter/createMetaMaskMobileFilter.js +21 -0
  12. package/src/lib/utils/functions/walletListBuilder/utils/createMetaMaskMobileFilter/index.d.ts +1 -0
  13. package/src/lib/utils/functions/walletListBuilder/utils/{filterWalletConnectWallets/filterWalletConnectWallets.cjs → createWalletConnectWalletsFilter/createWalletConnectWalletsFilter.cjs} +6 -6
  14. package/src/lib/utils/functions/walletListBuilder/utils/{filterWalletConnectWallets/filterWalletConnectWallets.d.ts → createWalletConnectWalletsFilter/createWalletConnectWalletsFilter.d.ts} +1 -4
  15. package/src/lib/utils/functions/walletListBuilder/utils/createWalletConnectWalletsFilter/createWalletConnectWalletsFilter.js +16 -0
  16. package/src/lib/utils/functions/walletListBuilder/utils/createWalletConnectWalletsFilter/index.d.ts +1 -0
  17. package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.cjs +35 -12
  18. package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.d.ts +3 -2
  19. package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.js +35 -12
  20. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +25 -13
  21. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +26 -14
  22. package/src/lib/utils/functions/walletListBuilder/utils/filterWalletConnectWallets/filterWalletConnectWallets.js +0 -16
  23. package/src/lib/utils/functions/walletListBuilder/utils/filterWalletConnectWallets/index.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -1,4 +1,19 @@
1
1
 
2
+ ## [4.0.0-alpha.32](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.31...v4.0.0-alpha.32) (2024-11-13)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * **client:** convert the wallet when using wallets.embedded.getWallet ([#7430](https://github.com/dynamic-labs/dynamic-auth/issues/7430)) ([f852a09](https://github.com/dynamic-labs/dynamic-auth/commit/f852a09695141389c275d1ca27c26595a78d8051))
8
+ * refresh blockhash for solana embedded and use confirmed commitment ([#7425](https://github.com/dynamic-labs/dynamic-auth/issues/7425)) ([25b4169](https://github.com/dynamic-labs/dynamic-auth/commit/25b4169950b32619731f10f3372f80e71ede4ae5))
9
+
10
+ ## [4.0.0-alpha.31](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.30...v4.0.0-alpha.31) (2024-11-13)
11
+
12
+
13
+ ### Features
14
+
15
+ * allow passing telegram auth token into telegramSignIn function ([#7423](https://github.com/dynamic-labs/dynamic-auth/issues/7423)) ([4b8d594](https://github.com/dynamic-labs/dynamic-auth/commit/4b8d594984d1ac7851ce8d94fe4329ba94730f35))
16
+
2
17
  ## [4.0.0-alpha.30](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.29...v4.0.0-alpha.30) (2024-11-13)
3
18
 
4
19
 
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.0.0-alpha.30";
6
+ var version = "4.0.0-alpha.32";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.563",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "4.0.0-alpha.30";
2
+ var version = "4.0.0-alpha.32";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.563",
5
5
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "4.0.0-alpha.30",
3
+ "version": "4.0.0-alpha.32",
4
4
  "dependencies": {
5
5
  "@dynamic-labs/sdk-api-core": "0.0.563",
6
6
  "@hcaptcha/react-hcaptcha": "1.4.4",
@@ -13,16 +13,16 @@
13
13
  "react-i18next": "13.5.0",
14
14
  "yup": "0.32.11",
15
15
  "react-international-phone": "4.2.5",
16
- "@dynamic-labs/assert-package-version": "4.0.0-alpha.30",
17
- "@dynamic-labs/iconic": "4.0.0-alpha.30",
18
- "@dynamic-labs/logger": "4.0.0-alpha.30",
19
- "@dynamic-labs/multi-wallet": "4.0.0-alpha.30",
20
- "@dynamic-labs/rpc-providers": "4.0.0-alpha.30",
21
- "@dynamic-labs/store": "4.0.0-alpha.30",
22
- "@dynamic-labs/types": "4.0.0-alpha.30",
23
- "@dynamic-labs/utils": "4.0.0-alpha.30",
24
- "@dynamic-labs/wallet-book": "4.0.0-alpha.30",
25
- "@dynamic-labs/wallet-connector-core": "4.0.0-alpha.30",
16
+ "@dynamic-labs/assert-package-version": "4.0.0-alpha.32",
17
+ "@dynamic-labs/iconic": "4.0.0-alpha.32",
18
+ "@dynamic-labs/logger": "4.0.0-alpha.32",
19
+ "@dynamic-labs/multi-wallet": "4.0.0-alpha.32",
20
+ "@dynamic-labs/rpc-providers": "4.0.0-alpha.32",
21
+ "@dynamic-labs/store": "4.0.0-alpha.32",
22
+ "@dynamic-labs/types": "4.0.0-alpha.32",
23
+ "@dynamic-labs/utils": "4.0.0-alpha.32",
24
+ "@dynamic-labs/wallet-book": "4.0.0-alpha.32",
25
+ "@dynamic-labs/wallet-connector-core": "4.0.0-alpha.32",
26
26
  "bs58": "5.0.0",
27
27
  "eventemitter3": "5.0.1"
28
28
  },
@@ -110,7 +110,8 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, }) =>
110
110
  const renderAssetTransfer = (transfer, index, array) => {
111
111
  var _a, _b;
112
112
  if (transfer.asset.type === 'NATIVE' &&
113
- transfer.asset.chainName === 'Solana') {
113
+ transfer.asset.chainName === 'Solana' &&
114
+ transaction.fee.gas) {
114
115
  transfer.amount = (Number(transfer.amount) -
115
116
  Number(transaction.fee.gas) / Math.pow(10, 9)).toString();
116
117
  }
@@ -102,7 +102,8 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, }) =>
102
102
  const renderAssetTransfer = (transfer, index, array) => {
103
103
  var _a, _b;
104
104
  if (transfer.asset.type === 'NATIVE' &&
105
- transfer.asset.chainName === 'Solana') {
105
+ transfer.asset.chainName === 'Solana' &&
106
+ transaction.fee.gas) {
106
107
  transfer.amount = (Number(transfer.amount) -
107
108
  Number(transaction.fee.gas) / Math.pow(10, 9)).toString();
108
109
  }
@@ -5,13 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var filterConnectedWallets = require('../filterConnectedWallets/filterConnectedWallets.cjs');
7
7
  var staticLinkedWalletFilter = require('../staticLinkedWalletFilter/staticLinkedWalletFilter.cjs');
8
- var filterWalletConnectWallets = require('../filterWalletConnectWallets/filterWalletConnectWallets.cjs');
8
+ var createWalletConnectWalletsFilter = require('../createWalletConnectWalletsFilter/createWalletConnectWalletsFilter.cjs');
9
+ var createMetaMaskMobileFilter = require('../createMetaMaskMobileFilter/createMetaMaskMobileFilter.cjs');
9
10
 
10
11
  const applyMultiWalletFilters = ({ authMode, userWallets, walletOptions, }) => {
11
- const walletList = filterWalletConnectWallets.filterWalletConnectWallets({
12
- userWallets,
13
- walletOptions,
14
- });
12
+ const walletList = walletOptions
13
+ .filter(createWalletConnectWalletsFilter.createWalletConnectWalletsFilter(userWallets))
14
+ .filter(createMetaMaskMobileFilter.createMetaMaskMobileFilter(userWallets));
15
15
  if (authMode === 'connect-only') {
16
16
  return filterConnectedWallets.filterConnectedWallets({
17
17
  userWallets,
@@ -1,13 +1,13 @@
1
1
  'use client'
2
2
  import { filterConnectedWallets } from '../filterConnectedWallets/filterConnectedWallets.js';
3
3
  import { staticWalletFilter } from '../staticLinkedWalletFilter/staticLinkedWalletFilter.js';
4
- import { filterWalletConnectWallets } from '../filterWalletConnectWallets/filterWalletConnectWallets.js';
4
+ import { createWalletConnectWalletsFilter } from '../createWalletConnectWalletsFilter/createWalletConnectWalletsFilter.js';
5
+ import { createMetaMaskMobileFilter } from '../createMetaMaskMobileFilter/createMetaMaskMobileFilter.js';
5
6
 
6
7
  const applyMultiWalletFilters = ({ authMode, userWallets, walletOptions, }) => {
7
- const walletList = filterWalletConnectWallets({
8
- userWallets,
9
- walletOptions,
10
- });
8
+ const walletList = walletOptions
9
+ .filter(createWalletConnectWalletsFilter(userWallets))
10
+ .filter(createMetaMaskMobileFilter(userWallets));
11
11
  if (authMode === 'connect-only') {
12
12
  return filterConnectedWallets({
13
13
  userWallets,
@@ -0,0 +1,25 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var utils = require('@dynamic-labs/utils');
7
+
8
+ const metaMaskConnectorKey = 'metamask';
9
+ /**
10
+ * Creates a filter for MetaMask Mobile wallets
11
+ * If user has MetaMask Mobile wallet, filter out all other wallets
12
+ * because MetaMask Mobile doesn't support multiwallet
13
+ */
14
+ const createMetaMaskMobileFilter = (userWallets) => {
15
+ if (!utils.isMobile()) {
16
+ return () => true;
17
+ }
18
+ const hasMetaMaskWallet = userWallets.some((wallet) => wallet.key === metaMaskConnectorKey);
19
+ if (!hasMetaMaskWallet) {
20
+ return () => true;
21
+ }
22
+ return (walletOption) => walletOption.walletConnector.key !== metaMaskConnectorKey;
23
+ };
24
+
25
+ exports.createMetaMaskMobileFilter = createMetaMaskMobileFilter;
@@ -0,0 +1,7 @@
1
+ import { Wallet, WalletOption } from '../../../../../shared/types/wallets';
2
+ /**
3
+ * Creates a filter for MetaMask Mobile wallets
4
+ * If user has MetaMask Mobile wallet, filter out all other wallets
5
+ * because MetaMask Mobile doesn't support multiwallet
6
+ */
7
+ export declare const createMetaMaskMobileFilter: (userWallets: Wallet[]) => (walletOption: WalletOption) => boolean;
@@ -0,0 +1,21 @@
1
+ 'use client'
2
+ import { isMobile } from '@dynamic-labs/utils';
3
+
4
+ const metaMaskConnectorKey = 'metamask';
5
+ /**
6
+ * Creates a filter for MetaMask Mobile wallets
7
+ * If user has MetaMask Mobile wallet, filter out all other wallets
8
+ * because MetaMask Mobile doesn't support multiwallet
9
+ */
10
+ const createMetaMaskMobileFilter = (userWallets) => {
11
+ if (!isMobile()) {
12
+ return () => true;
13
+ }
14
+ const hasMetaMaskWallet = userWallets.some((wallet) => wallet.key === metaMaskConnectorKey);
15
+ if (!hasMetaMaskWallet) {
16
+ return () => true;
17
+ }
18
+ return (walletOption) => walletOption.walletConnector.key !== metaMaskConnectorKey;
19
+ };
20
+
21
+ export { createMetaMaskMobileFilter };
@@ -0,0 +1 @@
1
+ export { createMetaMaskMobileFilter } from './createMetaMaskMobileFilter';
@@ -7,14 +7,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
7
7
  * Used to filter out WalletConnect wallets if user has already a WalletConnect wallet connected/linked
8
8
  * This is useful for multi-wallet on mobile, since WalletConnect doesn't work very well with multiwallet
9
9
  */
10
- const filterWalletConnectWallets = ({ walletOptions, userWallets, }) => {
10
+ const createWalletConnectWalletsFilter = (userWallets) => {
11
11
  const hasWCWallet = userWallets.some((wallet) => wallet.connector.isWalletConnect);
12
- // user doesn't have any WalletConnect wallet connected/linked, so we don't need to filter anything
12
+ // If user doesn't have WC wallet, keep all wallets (return true)
13
13
  if (!hasWCWallet) {
14
- return walletOptions;
14
+ return () => true;
15
15
  }
16
- // filter out WalletConnect wallets
17
- return walletOptions.filter((walletOption) => !walletOption.walletConnector.isWalletConnect);
16
+ // If user has WC wallet, filter out other WC wallets
17
+ return (walletOption) => !walletOption.walletConnector.isWalletConnect;
18
18
  };
19
19
 
20
- exports.filterWalletConnectWallets = filterWalletConnectWallets;
20
+ exports.createWalletConnectWalletsFilter = createWalletConnectWalletsFilter;
@@ -3,7 +3,4 @@ import { Wallet, WalletOption } from '../../../../../shared';
3
3
  * Used to filter out WalletConnect wallets if user has already a WalletConnect wallet connected/linked
4
4
  * This is useful for multi-wallet on mobile, since WalletConnect doesn't work very well with multiwallet
5
5
  */
6
- export declare const filterWalletConnectWallets: ({ walletOptions, userWallets, }: {
7
- walletOptions: WalletOption[];
8
- userWallets: Wallet[];
9
- }) => WalletOption[];
6
+ export declare const createWalletConnectWalletsFilter: (userWallets: Wallet[]) => (walletOption: WalletOption) => boolean;
@@ -0,0 +1,16 @@
1
+ 'use client'
2
+ /**
3
+ * Used to filter out WalletConnect wallets if user has already a WalletConnect wallet connected/linked
4
+ * This is useful for multi-wallet on mobile, since WalletConnect doesn't work very well with multiwallet
5
+ */
6
+ const createWalletConnectWalletsFilter = (userWallets) => {
7
+ const hasWCWallet = userWallets.some((wallet) => wallet.connector.isWalletConnect);
8
+ // If user doesn't have WC wallet, keep all wallets (return true)
9
+ if (!hasWCWallet) {
10
+ return () => true;
11
+ }
12
+ // If user has WC wallet, filter out other WC wallets
13
+ return (walletOption) => !walletOption.walletConnector.isWalletConnect;
14
+ };
15
+
16
+ export { createWalletConnectWalletsFilter };
@@ -0,0 +1 @@
1
+ export { createWalletConnectWalletsFilter } from './createWalletConnectWalletsFilter';
@@ -101,20 +101,43 @@ const useTelegramLogin = () => {
101
101
  }
102
102
  return telegramAuthToken;
103
103
  };
104
- const canProceedWithTelegram = (telegramAuthToken) => isProviderEnabled.isProviderEnabled(providers, sdkApiCore.ProviderEnum.Telegram) &&
105
- sdkHasLoaded &&
106
- !user &&
107
- telegramAuthToken;
108
- const isAuthWithTelegram = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
109
- const telegramAuthToken = getTelegramAuthToken();
104
+ const canProceedWithTelegram = (telegramAuthToken) => {
105
+ let failureReason;
106
+ if (!isProviderEnabled.isProviderEnabled(providers, sdkApiCore.ProviderEnum.Telegram)) {
107
+ failureReason = 'Telegram provider is not enabled';
108
+ }
109
+ else if (!sdkHasLoaded) {
110
+ failureReason = 'SDK has not loaded';
111
+ }
112
+ else if (user) {
113
+ failureReason = 'User is already logged in';
114
+ }
115
+ else if (!telegramAuthToken) {
116
+ failureReason = 'Telegram auth token is missing';
117
+ }
118
+ if (failureReason) {
119
+ logger.logger.error(`Failed to check user Telegram authentication status due to reason: ${failureReason}`);
120
+ }
121
+ return !failureReason;
122
+ };
123
+ /**
124
+ * Returns whether or not this telegram user has been authenticated with Dynamic.
125
+ * @param authToken (Optional) the Telegram auth token of the user to check.
126
+ * If not provided, the SDK will attempt to grab the auth token from the URL if exists.
127
+ * @returns Promise<boolean> of whether or not the Telegram user has authenticated with Dynamic.
128
+ */
129
+ const isAuthWithTelegram = (authToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
130
+ const telegramAuthToken = authToken || getTelegramAuthToken();
110
131
  if (!canProceedWithTelegram(telegramAuthToken)) {
111
- return;
132
+ return false;
112
133
  }
113
- return oauth.isUserLinkedWithTelegram(environmentId, { telegramAuthToken });
134
+ return Boolean(oauth.isUserLinkedWithTelegram(environmentId, { telegramAuthToken }));
114
135
  });
115
- const telegramSignIn = (...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* ({ forceCreateUser = false, } = {}) {
116
- const telegramAuthToken = getTelegramAuthToken();
117
- if (!canProceedWithTelegram(telegramAuthToken)) {
136
+ const telegramSignIn = (...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* ({ forceCreateUser = false, authToken, } = {}) {
137
+ if (!authToken) {
138
+ authToken = getTelegramAuthToken();
139
+ }
140
+ if (!canProceedWithTelegram(authToken)) {
118
141
  return;
119
142
  }
120
143
  yield completeConnection({
@@ -122,7 +145,7 @@ const useTelegramLogin = () => {
122
145
  forceCreateUser,
123
146
  provider: sdkApiCore.ProviderEnum.Telegram,
124
147
  state: '',
125
- telegramAuthToken,
148
+ telegramAuthToken: authToken,
126
149
  });
127
150
  });
128
151
  return {
@@ -1,8 +1,9 @@
1
1
  interface TelegramConfig {
2
2
  forceCreateUser?: boolean;
3
+ authToken?: string;
3
4
  }
4
5
  export declare const useTelegramLogin: () => {
5
- isAuthWithTelegram: () => Promise<boolean | undefined>;
6
- telegramSignIn: ({ forceCreateUser, }?: TelegramConfig) => Promise<void>;
6
+ isAuthWithTelegram: (authToken?: string) => Promise<boolean>;
7
+ telegramSignIn: ({ forceCreateUser, authToken, }?: TelegramConfig) => Promise<void>;
7
8
  };
8
9
  export {};
@@ -97,20 +97,43 @@ const useTelegramLogin = () => {
97
97
  }
98
98
  return telegramAuthToken;
99
99
  };
100
- const canProceedWithTelegram = (telegramAuthToken) => isProviderEnabled(providers, ProviderEnum.Telegram) &&
101
- sdkHasLoaded &&
102
- !user &&
103
- telegramAuthToken;
104
- const isAuthWithTelegram = () => __awaiter(void 0, void 0, void 0, function* () {
105
- const telegramAuthToken = getTelegramAuthToken();
100
+ const canProceedWithTelegram = (telegramAuthToken) => {
101
+ let failureReason;
102
+ if (!isProviderEnabled(providers, ProviderEnum.Telegram)) {
103
+ failureReason = 'Telegram provider is not enabled';
104
+ }
105
+ else if (!sdkHasLoaded) {
106
+ failureReason = 'SDK has not loaded';
107
+ }
108
+ else if (user) {
109
+ failureReason = 'User is already logged in';
110
+ }
111
+ else if (!telegramAuthToken) {
112
+ failureReason = 'Telegram auth token is missing';
113
+ }
114
+ if (failureReason) {
115
+ logger.error(`Failed to check user Telegram authentication status due to reason: ${failureReason}`);
116
+ }
117
+ return !failureReason;
118
+ };
119
+ /**
120
+ * Returns whether or not this telegram user has been authenticated with Dynamic.
121
+ * @param authToken (Optional) the Telegram auth token of the user to check.
122
+ * If not provided, the SDK will attempt to grab the auth token from the URL if exists.
123
+ * @returns Promise<boolean> of whether or not the Telegram user has authenticated with Dynamic.
124
+ */
125
+ const isAuthWithTelegram = (authToken) => __awaiter(void 0, void 0, void 0, function* () {
126
+ const telegramAuthToken = authToken || getTelegramAuthToken();
106
127
  if (!canProceedWithTelegram(telegramAuthToken)) {
107
- return;
128
+ return false;
108
129
  }
109
- return isUserLinkedWithTelegram(environmentId, { telegramAuthToken });
130
+ return Boolean(isUserLinkedWithTelegram(environmentId, { telegramAuthToken }));
110
131
  });
111
- const telegramSignIn = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ forceCreateUser = false, } = {}) {
112
- const telegramAuthToken = getTelegramAuthToken();
113
- if (!canProceedWithTelegram(telegramAuthToken)) {
132
+ const telegramSignIn = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ forceCreateUser = false, authToken, } = {}) {
133
+ if (!authToken) {
134
+ authToken = getTelegramAuthToken();
135
+ }
136
+ if (!canProceedWithTelegram(authToken)) {
114
137
  return;
115
138
  }
116
139
  yield completeConnection({
@@ -118,7 +141,7 @@ const useTelegramLogin = () => {
118
141
  forceCreateUser,
119
142
  provider: ProviderEnum.Telegram,
120
143
  state: '',
121
- telegramAuthToken,
144
+ telegramAuthToken: authToken,
122
145
  });
123
146
  });
124
147
  return {
@@ -100,7 +100,6 @@ var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
100
100
 
101
101
  const FEE_REFRESH_INTERVAL = 20000;
102
102
  const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation, onClickBack, walletConnector, onClickClose, title, displayPoweredByDynamicFooter = false, copykey, hideModal, currentToken, isNativeToken, transactionValue, isModal, sendBalanceTransaction, }) => {
103
- var _a, _b;
104
103
  const { primaryWallet, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
105
104
  const [isGasSponsored, setIsGasSponsored] = React.useState(false);
106
105
  const update = useForceUpdate.useForceUpdate();
@@ -189,10 +188,13 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
189
188
  }
190
189
  },
191
190
  });
192
- // solana gas sponsorship check
193
- if ((_a = transaction.isGasSponsored) === null || _a === void 0 ? void 0 : _a.call(transaction)) {
194
- setIsGasSponsored(true);
195
- }
191
+ React.useEffect(() => {
192
+ var _a;
193
+ // solana gas sponsorship check
194
+ if ((_a = transaction.isGasSponsored) === null || _a === void 0 ? void 0 : _a.call(transaction)) {
195
+ setIsGasSponsored(true);
196
+ }
197
+ }, [transaction]);
196
198
  const { mutate: send, isLoading, error: transactionError, } = useMutation.useMutation(mutation, {
197
199
  onFailure: (error) => {
198
200
  fetchTransactionFee();
@@ -270,17 +272,27 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
270
272
  isLoading,
271
273
  simulationResult,
272
274
  ]);
275
+ React.useEffect(() => {
276
+ var _a;
277
+ if (isSimulationComplete && !sendBalanceTransaction) {
278
+ // if simulation threw an error, or if there are no out assets for solana (which means the simulation failed)
279
+ if (!simulationResult ||
280
+ (simulationResult.outAssets.length === 0 &&
281
+ !chainId &&
282
+ !((_a = transaction.isGasSponsored) === null || _a === void 0 ? void 0 : _a.call(transaction)))) {
283
+ transaction.simulationFailed = true;
284
+ }
285
+ }
286
+ }, [
287
+ simulationResult,
288
+ chainId,
289
+ transaction,
290
+ sendBalanceTransaction,
291
+ isSimulationComplete,
292
+ ]);
273
293
  if (!isSimulationComplete) {
274
294
  return null;
275
295
  }
276
- // if simulation threw an error, or if there are no out assets for solana (which means the simulation failed)
277
- if ((!simulationResult ||
278
- (!simulationResult.outAssets.length &&
279
- !chainId &&
280
- !((_b = transaction.isGasSponsored) === null || _b === void 0 ? void 0 : _b.call(transaction)))) &&
281
- !sendBalanceTransaction) {
282
- transaction.simulationFailed = true;
283
- }
284
296
  return (jsxRuntime.jsx(TransactionConfirmationPageLayout.TransactionConfirmationPageLayout, { total: total, currentToken: currentToken, transactionValue: transactionValue, isNativeToken: isNativeToken, onClickBack: onClickBack, onClickClose: onClickClose, copykey: copykey, title: title, hideModal: hideModal, isLoading: isLoading, onClickSend: () => send(), onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton: isBalanceLoading, error: errorMessage, alert: alert, walletConnector: walletConnector, transaction: transaction, isGasSponsored: isGasSponsored, isGasSponsoredLoading: isGasSponsoredLoading, walletKey: (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.key) || '', simulationResult: simulationResult, sendBalanceTransaction: sendBalanceTransaction }));
285
297
  };
286
298
 
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../_virtual/_tslib.js';
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
- import { useState, useMemo } from 'react';
4
+ import { useState, useMemo, useEffect } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import bs58 from 'bs58';
7
7
  import { TransactionGasCannotBeSponsoredError } from '@dynamic-labs/utils';
@@ -92,7 +92,6 @@ import { useInternalDynamicContext } from '../../context/DynamicContext/useDynam
92
92
 
93
93
  const FEE_REFRESH_INTERVAL = 20000;
94
94
  const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation, onClickBack, walletConnector, onClickClose, title, displayPoweredByDynamicFooter = false, copykey, hideModal, currentToken, isNativeToken, transactionValue, isModal, sendBalanceTransaction, }) => {
95
- var _a, _b;
96
95
  const { primaryWallet, environmentId } = useInternalDynamicContext();
97
96
  const [isGasSponsored, setIsGasSponsored] = useState(false);
98
97
  const update = useForceUpdate();
@@ -181,10 +180,13 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
181
180
  }
182
181
  },
183
182
  });
184
- // solana gas sponsorship check
185
- if ((_a = transaction.isGasSponsored) === null || _a === void 0 ? void 0 : _a.call(transaction)) {
186
- setIsGasSponsored(true);
187
- }
183
+ useEffect(() => {
184
+ var _a;
185
+ // solana gas sponsorship check
186
+ if ((_a = transaction.isGasSponsored) === null || _a === void 0 ? void 0 : _a.call(transaction)) {
187
+ setIsGasSponsored(true);
188
+ }
189
+ }, [transaction]);
188
190
  const { mutate: send, isLoading, error: transactionError, } = useMutation(mutation, {
189
191
  onFailure: (error) => {
190
192
  fetchTransactionFee();
@@ -262,17 +264,27 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
262
264
  isLoading,
263
265
  simulationResult,
264
266
  ]);
267
+ useEffect(() => {
268
+ var _a;
269
+ if (isSimulationComplete && !sendBalanceTransaction) {
270
+ // if simulation threw an error, or if there are no out assets for solana (which means the simulation failed)
271
+ if (!simulationResult ||
272
+ (simulationResult.outAssets.length === 0 &&
273
+ !chainId &&
274
+ !((_a = transaction.isGasSponsored) === null || _a === void 0 ? void 0 : _a.call(transaction)))) {
275
+ transaction.simulationFailed = true;
276
+ }
277
+ }
278
+ }, [
279
+ simulationResult,
280
+ chainId,
281
+ transaction,
282
+ sendBalanceTransaction,
283
+ isSimulationComplete,
284
+ ]);
265
285
  if (!isSimulationComplete) {
266
286
  return null;
267
287
  }
268
- // if simulation threw an error, or if there are no out assets for solana (which means the simulation failed)
269
- if ((!simulationResult ||
270
- (!simulationResult.outAssets.length &&
271
- !chainId &&
272
- !((_b = transaction.isGasSponsored) === null || _b === void 0 ? void 0 : _b.call(transaction)))) &&
273
- !sendBalanceTransaction) {
274
- transaction.simulationFailed = true;
275
- }
276
288
  return (jsx(TransactionConfirmationPageLayout, { total: total, currentToken: currentToken, transactionValue: transactionValue, isNativeToken: isNativeToken, onClickBack: onClickBack, onClickClose: onClickClose, copykey: copykey, title: title, hideModal: hideModal, isLoading: isLoading, onClickSend: () => send(), onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton: isBalanceLoading, error: errorMessage, alert: alert, walletConnector: walletConnector, transaction: transaction, isGasSponsored: isGasSponsored, isGasSponsoredLoading: isGasSponsoredLoading, walletKey: (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.key) || '', simulationResult: simulationResult, sendBalanceTransaction: sendBalanceTransaction }));
277
289
  };
278
290
 
@@ -1,16 +0,0 @@
1
- 'use client'
2
- /**
3
- * Used to filter out WalletConnect wallets if user has already a WalletConnect wallet connected/linked
4
- * This is useful for multi-wallet on mobile, since WalletConnect doesn't work very well with multiwallet
5
- */
6
- const filterWalletConnectWallets = ({ walletOptions, userWallets, }) => {
7
- const hasWCWallet = userWallets.some((wallet) => wallet.connector.isWalletConnect);
8
- // user doesn't have any WalletConnect wallet connected/linked, so we don't need to filter anything
9
- if (!hasWCWallet) {
10
- return walletOptions;
11
- }
12
- // filter out WalletConnect wallets
13
- return walletOptions.filter((walletOption) => !walletOption.walletConnector.isWalletConnect);
14
- };
15
-
16
- export { filterWalletConnectWallets };
@@ -1 +0,0 @@
1
- export * from './filterWalletConnectWallets';