@dynamic-labs/sdk-react-core 1.1.0-alpha.25 → 1.1.0-alpha.26

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 (54) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +10 -10
  5. package/src/lib/components/Icon/Icon.cjs +1 -0
  6. package/src/lib/components/Icon/Icon.js +1 -0
  7. package/src/lib/components/Icon/Icon.types.d.ts +1 -1
  8. package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +13 -60
  9. package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
  10. package/src/lib/components/OTPVerificationView/OTPVerificationView.js +13 -60
  11. package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.cjs +97 -0
  12. package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.d.ts +9 -0
  13. package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.js +93 -0
  14. package/src/lib/components/RetrySendVerificationCodeSection/index.d.ts +1 -0
  15. package/src/lib/context/DynamicContext/DynamicContext.cjs +2 -2
  16. package/src/lib/context/DynamicContext/DynamicContext.js +2 -2
  17. package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +4 -0
  18. package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +4 -0
  19. package/src/lib/context/DynamicContext/types/index.d.ts +3 -2
  20. package/src/lib/context/DynamicContext/useCustomerCallbacks/types.d.ts +2 -4
  21. package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +4 -50
  22. package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.d.ts +1 -1
  23. package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +4 -50
  24. package/src/lib/events/dynamicEvents.d.ts +2 -0
  25. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +1 -2
  26. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +1 -2
  27. package/src/lib/styles/index.shadow.cjs +1 -1
  28. package/src/lib/styles/index.shadow.js +1 -1
  29. package/src/lib/utils/functions/index.d.ts +0 -1
  30. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +6 -6
  31. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +6 -6
  32. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +4 -5
  33. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +4 -5
  34. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +38 -5
  35. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +16 -5
  36. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +39 -6
  37. package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.cjs +3 -2
  38. package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.js +3 -2
  39. package/src/lib/views/EmailVerification/EmailVerification.cjs +5 -13
  40. package/src/lib/views/EmailVerification/EmailVerification.js +5 -13
  41. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +1 -1
  42. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +1 -1
  43. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +1 -2
  44. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +1 -2
  45. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +6 -1
  46. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +6 -1
  47. package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs +1 -1
  48. package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.js +1 -1
  49. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +1 -1
  50. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +1 -1
  51. package/src/lib/utils/functions/sendTransactionWithAutoNonce/index.d.ts +0 -1
  52. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs +0 -49
  53. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.d.ts +0 -18
  54. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js +0 -44
@@ -7,7 +7,7 @@ import { DynamicError, TransactionGasCannotBeSponsoredError } from '@dynamic-lab
7
7
  import { isAccountAbstractionConnector } from '@dynamic-labs/wallet-connector-core';
8
8
  import '../../context/DynamicContext/DynamicContext.js';
9
9
  import '@dynamic-labs/sdk-api';
10
- import '../../shared/logger.js';
10
+ import { logger } from '../../shared/logger.js';
11
11
  import { getChainIcon } from '../../shared/utils/functions/chain/getChainIcon.js';
12
12
  import '@dynamic-labs/wallet-book';
13
13
  import { shortenWalletAddress } from '../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
@@ -96,6 +96,9 @@ const TransactionConfirmationView = ({ transaction, mutation, onError, onSuccess
96
96
  }
97
97
  return primaryWallet.connector.canSponsorTransactionGas(transaction);
98
98
  }, {
99
+ onReject: (error) => {
100
+ logger.error(error);
101
+ },
99
102
  onResolve: (isGasSponsored) => {
100
103
  const { connector } = primaryWallet;
101
104
  setIsGasSponsored(isGasSponsored);
@@ -107,12 +110,14 @@ const TransactionConfirmationView = ({ transaction, mutation, onError, onSuccess
107
110
  const { mutate: send, isLoading, error: transactionError, } = useMutation(() => mutation(), {
108
111
  onFailure: (error) => {
109
112
  if (TransactionGasCannotBeSponsoredError.isInstance(error)) {
113
+ logger.debug(error);
110
114
  setIsGasSponsored(false);
111
115
  const { connector } = primaryWallet;
112
116
  if (isAccountAbstractionConnector(connector)) {
113
117
  connector.disableGasSponsorshipOnce();
114
118
  }
115
119
  }
120
+ logger.error(error);
116
121
  onError === null || onError === void 0 ? void 0 : onError(error);
117
122
  },
118
123
  onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx),
@@ -19,7 +19,7 @@ require('viem');
19
19
  require('../../../shared/consts/index.cjs');
20
20
 
21
21
  const errorCodesMapping = {
22
- '-32603': 'Could not replace existing transaction',
22
+ '-32603': 'A network error has occurred. Please try again later',
23
23
  0: 'The operation either timed out or was not allowed.',
24
24
  16: 'Invalid Passkey signature. Select the passkey for this account and device.',
25
25
  3: 'You reached the limit of passkeys for this account.',
@@ -15,7 +15,7 @@ import 'viem';
15
15
  import '../../../shared/consts/index.js';
16
16
 
17
17
  const errorCodesMapping = {
18
- '-32603': 'Could not replace existing transaction',
18
+ '-32603': 'A network error has occurred. Please try again later',
19
19
  0: 'The operation either timed out or was not allowed.',
20
20
  16: 'Invalid Passkey signature. Select the passkey for this account and device.',
21
21
  3: 'You reached the limit of passkeys for this account.',
@@ -92,7 +92,7 @@ const EmailOTPConnectorPendingSignModalContent = ({ walletConnector }) => {
92
92
  dynamicEvents.dynamicEvents.emit('emailVerificationResult', true, email);
93
93
  }),
94
94
  });
95
- return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined) }));
95
+ return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, isLoading: isLoading, onPinComplete: onSubmit, retryHandler: walletConnector.retryOneTypePassword.bind(walletConnector), isValid: isValid === true, onPinChange: () => setError(undefined) }));
96
96
  };
97
97
 
98
98
  exports.EmailOTPConnectorPendingSignModalContent = EmailOTPConnectorPendingSignModalContent;
@@ -88,7 +88,7 @@ const EmailOTPConnectorPendingSignModalContent = ({ walletConnector }) => {
88
88
  dynamicEvents.emit('emailVerificationResult', true, email);
89
89
  }),
90
90
  });
91
- return (jsx(OTPVerificationView, { email: email, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined) }));
91
+ return (jsx(OTPVerificationView, { email: email, error: error, isLoading: isLoading, onPinComplete: onSubmit, retryHandler: walletConnector.retryOneTypePassword.bind(walletConnector), isValid: isValid === true, onPinChange: () => setError(undefined) }));
92
92
  };
93
93
 
94
94
  export { EmailOTPConnectorPendingSignModalContent };
@@ -1 +0,0 @@
1
- export { sendTransactionWithAutoNonce } from './sendTransactionWithAutoNonce';
@@ -1,49 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _tslib = require('../../../../../_virtual/_tslib.cjs');
6
-
7
- const MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE = -32603;
8
- /**
9
- * Sends a transaction with an automatically determined nonce, if not provided.
10
- *
11
- * In Ethereum, each transaction sent from a particular address must have a unique nonce.
12
- * If the transaction does not already have a nonce, this function helps to automatically set it.
13
- * If a transaction with a particular nonce fails due to a "could not replace transaction" error,
14
- * this function will automatically retry with the next nonce.
15
- *
16
- * @param connector - A Dynamic connector to interact with the Ethereum network.
17
- * @param transaction - The transaction details.
18
- * @param sendTransactionHandler - A handler function to send the transaction.
19
- *
20
- * @returns A promise that resolves to the transaction response.
21
- */
22
- const sendTransactionWithAutoNonce = (connector, transaction, sendTransactionHandler) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
23
- var _a;
24
- if (transaction.nonce !== undefined) {
25
- return sendTransactionHandler(transaction);
26
- }
27
- const publicClient = yield connector.getPublicClient();
28
- const walletClient = yield connector.getSigner();
29
- const address = (yield walletClient.getAddresses())[0] || ((_a = walletClient.account) === null || _a === void 0 ? void 0 : _a.address);
30
- const nonce = yield publicClient.getTransactionCount({
31
- address,
32
- });
33
- const transactionWithNonce = Object.assign(Object.assign({}, transaction), { nonce });
34
- try {
35
- const response = yield sendTransactionHandler(transactionWithNonce);
36
- return response;
37
- }
38
- catch (err) {
39
- if (err.code ===
40
- MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE) {
41
- const transactionWithNextNonce = Object.assign(Object.assign({}, transaction), { nonce: nonce + 1 });
42
- return sendTransactionHandler(transactionWithNextNonce);
43
- }
44
- throw err;
45
- }
46
- });
47
-
48
- exports.MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE = MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE;
49
- exports.sendTransactionWithAutoNonce = sendTransactionWithAutoNonce;
@@ -1,18 +0,0 @@
1
- import { TransactionRequest, Address } from 'viem';
2
- import { WalletConnector } from '../../../..';
3
- export declare const MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE = -32603;
4
- /**
5
- * Sends a transaction with an automatically determined nonce, if not provided.
6
- *
7
- * In Ethereum, each transaction sent from a particular address must have a unique nonce.
8
- * If the transaction does not already have a nonce, this function helps to automatically set it.
9
- * If a transaction with a particular nonce fails due to a "could not replace transaction" error,
10
- * this function will automatically retry with the next nonce.
11
- *
12
- * @param connector - A Dynamic connector to interact with the Ethereum network.
13
- * @param transaction - The transaction details.
14
- * @param sendTransactionHandler - A handler function to send the transaction.
15
- *
16
- * @returns A promise that resolves to the transaction response.
17
- */
18
- export declare const sendTransactionWithAutoNonce: (connector: WalletConnector, transaction: TransactionRequest, sendTransactionHandler: (transaction: TransactionRequest) => Promise<Address>) => Promise<`0x${string}`>;
@@ -1,44 +0,0 @@
1
- import { __awaiter } from '../../../../../_virtual/_tslib.js';
2
-
3
- const MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE = -32603;
4
- /**
5
- * Sends a transaction with an automatically determined nonce, if not provided.
6
- *
7
- * In Ethereum, each transaction sent from a particular address must have a unique nonce.
8
- * If the transaction does not already have a nonce, this function helps to automatically set it.
9
- * If a transaction with a particular nonce fails due to a "could not replace transaction" error,
10
- * this function will automatically retry with the next nonce.
11
- *
12
- * @param connector - A Dynamic connector to interact with the Ethereum network.
13
- * @param transaction - The transaction details.
14
- * @param sendTransactionHandler - A handler function to send the transaction.
15
- *
16
- * @returns A promise that resolves to the transaction response.
17
- */
18
- const sendTransactionWithAutoNonce = (connector, transaction, sendTransactionHandler) => __awaiter(void 0, void 0, void 0, function* () {
19
- var _a;
20
- if (transaction.nonce !== undefined) {
21
- return sendTransactionHandler(transaction);
22
- }
23
- const publicClient = yield connector.getPublicClient();
24
- const walletClient = yield connector.getSigner();
25
- const address = (yield walletClient.getAddresses())[0] || ((_a = walletClient.account) === null || _a === void 0 ? void 0 : _a.address);
26
- const nonce = yield publicClient.getTransactionCount({
27
- address,
28
- });
29
- const transactionWithNonce = Object.assign(Object.assign({}, transaction), { nonce });
30
- try {
31
- const response = yield sendTransactionHandler(transactionWithNonce);
32
- return response;
33
- }
34
- catch (err) {
35
- if (err.code ===
36
- MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE) {
37
- const transactionWithNextNonce = Object.assign(Object.assign({}, transaction), { nonce: nonce + 1 });
38
- return sendTransactionHandler(transactionWithNextNonce);
39
- }
40
- throw err;
41
- }
42
- });
43
-
44
- export { MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE, sendTransactionWithAutoNonce };