@dynamic-labs/sdk-react-core 4.91.2 → 4.91.4
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 +20 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/lib/client/client.cjs +1 -1
- package/src/lib/client/client.js +1 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +4 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +4 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +3 -0
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +3 -0
- package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.cjs +1 -1
- package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.js +1 -1
- package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +13 -1
- package/src/lib/context/ErrorContext/ErrorContext.cjs +48 -28
- package/src/lib/context/ErrorContext/ErrorContext.js +49 -29
- package/src/lib/context/OnrampContext/OnrampContext.cjs +21 -16
- package/src/lib/context/OnrampContext/OnrampContext.js +21 -16
- package/src/lib/context/SendBalanceContext/SendBalanceContext.errors.cjs +2 -2
- package/src/lib/context/SendBalanceContext/SendBalanceContext.errors.js +2 -2
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +3 -3
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +3 -3
- package/src/lib/data/api/email/email.cjs +6 -3
- package/src/lib/data/api/email/email.js +6 -3
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +15 -14
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +8 -7
- package/src/lib/data/api/exchangeAccounts/exchangeAccounts.cjs +3 -3
- package/src/lib/data/api/exchangeAccounts/exchangeAccounts.js +3 -3
- package/src/lib/data/api/oauth/oauth.cjs +3 -2
- package/src/lib/data/api/oauth/oauth.js +3 -2
- package/src/lib/data/api/session/session.cjs +3 -3
- package/src/lib/data/api/session/session.js +3 -3
- package/src/lib/data/api/sms/sms.cjs +4 -1
- package/src/lib/data/api/sms/sms.js +4 -1
- package/src/lib/data/api/user/user.cjs +5 -5
- package/src/lib/data/api/user/user.js +6 -6
- package/src/lib/data/api/utils.cjs +6 -1
- package/src/lib/data/api/utils.d.ts +1 -0
- package/src/lib/data/api/utils.js +6 -2
- package/src/lib/data/api/wallets/wallets.cjs +17 -15
- package/src/lib/data/api/wallets/wallets.js +18 -16
- package/src/lib/events/auth.d.ts +3 -2
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +2 -1
- package/src/lib/store/state/nonce/nonce.cjs +1 -1
- package/src/lib/store/state/nonce/nonce.js +1 -1
- package/src/lib/utils/functions/generateMessages/index.cjs +3 -3
- package/src/lib/utils/functions/generateMessages/index.js +3 -3
- package/src/lib/utils/functions/getEmbeddedWalletAuthHandler/getEmbeddedWalletAuthHandler.cjs +1 -1
- package/src/lib/utils/functions/getEmbeddedWalletAuthHandler/getEmbeddedWalletAuthHandler.js +1 -1
- package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.cjs +30 -0
- package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.d.ts +17 -0
- package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.js +29 -1
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.cjs +13 -1
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.d.ts +2 -1
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.js +14 -2
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.cjs +4 -0
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.js +5 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +2 -2
- package/src/lib/utils/hooks/useAuthenticateConnectedUser/useAuthenticateConnectedUser.cjs +2 -2
- package/src/lib/utils/hooks/useAuthenticateConnectedUser/useAuthenticateConnectedUser.js +2 -2
- package/src/lib/utils/hooks/useConfirmationPortal/useConfirmationPortal.cjs +1 -1
- package/src/lib/utils/hooks/useConfirmationPortal/useConfirmationPortal.js +1 -1
- package/src/lib/utils/hooks/useConnectExchangeForFunding/useConnectExchangeForFunding.cjs +1 -1
- package/src/lib/utils/hooks/useConnectExchangeForFunding/useConnectExchangeForFunding.js +1 -1
- package/src/lib/utils/hooks/useConnectUnifiedForFunding/useConnectUnifiedForFunding.cjs +2 -2
- package/src/lib/utils/hooks/useConnectUnifiedForFunding/useConnectUnifiedForFunding.js +2 -2
- package/src/lib/utils/hooks/useConnectWallet/HandleConnectWalletRejectionError.cjs +1 -1
- package/src/lib/utils/hooks/useConnectWallet/HandleConnectWalletRejectionError.js +1 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +1 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +1 -1
- package/src/lib/utils/hooks/useCreateWalletConnectorOptions/utils/errors/ConnectorSetupError.cjs +1 -1
- package/src/lib/utils/hooks/useCreateWalletConnectorOptions/utils/errors/ConnectorSetupError.js +1 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +8 -8
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +8 -8
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +4 -4
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +4 -4
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +9 -9
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +9 -9
- package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.cjs +2 -2
- package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.js +2 -2
- package/src/lib/utils/hooks/useFundingHelpers/useFundingHelpers.cjs +2 -2
- package/src/lib/utils/hooks/useFundingHelpers/useFundingHelpers.js +2 -2
- package/src/lib/utils/hooks/useGetMfaToken/useGetMfaToken.cjs +1 -1
- package/src/lib/utils/hooks/useGetMfaToken/useGetMfaToken.js +1 -1
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.cjs +2 -2
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.js +2 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +2 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +2 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +2 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +2 -2
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +2 -2
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +2 -2
- package/src/lib/utils/hooks/useUpgradeEmbeddedWallet/useUpgradeEmbeddedWallet.cjs +3 -3
- package/src/lib/utils/hooks/useUpgradeEmbeddedWallet/useUpgradeEmbeddedWallet.js +3 -3
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +1 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +1 -1
- package/src/lib/utils/hooks/useUserDataForm/useUserDataForm.cjs +1 -1
- package/src/lib/utils/hooks/useUserDataForm/useUserDataForm.js +1 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/unlinkUserEmail/unlinkUserEmail.cjs +3 -3
- package/src/lib/utils/hooks/useUserUpdateRequest/unlinkUserEmail/unlinkUserEmail.js +3 -3
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.cjs +1 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.js +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -2
- package/src/lib/utils/hooks/useViewSettings/useViewSettings.d.ts +5 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +1 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +1 -1
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.cjs +1 -1
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +1 -1
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.cjs +1 -1
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.js +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.cjs +4 -4
- package/src/lib/views/EmailVerification/EmailVerification.js +4 -4
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +2 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +2 -2
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +2 -2
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +2 -2
- package/src/lib/views/EmbeddedReveal/utils/waasExport/waasExport.cjs +2 -2
- package/src/lib/views/EmbeddedReveal/utils/waasExport/waasExport.js +2 -2
- package/src/lib/views/ExportSharesView/ExportSharesView.cjs +2 -2
- package/src/lib/views/ExportSharesView/ExportSharesView.js +2 -2
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.cjs +2 -2
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.js +2 -2
- package/src/lib/views/LoginView/useLoginView/useLoginView.cjs +1 -1
- package/src/lib/views/LoginView/useLoginView/useLoginView.js +1 -1
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.cjs +1 -1
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.js +1 -1
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +2 -2
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +2 -2
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.cjs +1 -1
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.js +1 -1
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.cjs +1 -1
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.js +1 -1
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +3 -3
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +3 -3
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +14 -14
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +14 -14
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +2 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.js +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +2 -2
- package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.cjs +1 -1
- package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.js +1 -1
- package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.cjs +1 -1
- package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/getPromptAmountParams/getPromptAmountParams.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/getPromptAmountParams/getPromptAmountParams.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/utils/useSubmitWalletFunding/useSubmitWalletFunding.cjs +10 -1
- package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/utils/useSubmitWalletFunding/useSubmitWalletFunding.js +10 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.91.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.3...v4.91.4) (2026-07-01)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* conditionally use /op/ route for AA transactions based on block explorer support ([#11628](https://github.com/dynamic-labs/dynamic-auth/issues/11628)) ([95822dc](https://github.com/dynamic-labs/dynamic-auth/commit/95822dc0edbcd739afe870f0b3881555fdb17eb6))
|
|
8
|
+
* require error codes in all SDK error classes ([#11761](https://github.com/dynamic-labs/dynamic-auth/issues/11761)) ([5744811](https://github.com/dynamic-labs/dynamic-auth/commit/5744811efdd1e415aaf51eec5b3300b323ec1347))
|
|
9
|
+
|
|
10
|
+
### [4.91.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.2...v4.91.3) (2026-06-30)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **bitcoin:** detect late-registering wallet-standard wallets (DYNT-1210) ([#11747](https://github.com/dynamic-labs/dynamic-auth/issues/11747)) ([17809f6](https://github.com/dynamic-labs/dynamic-auth/commit/17809f6e811fe101367cc31a2d899a8d0b0d107e))
|
|
16
|
+
* fetch onramp providers lazily instead of eagerly on mount ([#11767](https://github.com/dynamic-labs/dynamic-auth/issues/11767)) ([3ee6708](https://github.com/dynamic-labs/dynamic-auth/commit/3ee67087142ae1942f865e0ab37b7108700b3327))
|
|
17
|
+
* **iframe-setup:** sync parent URL to iframe on pushState/replaceState ([#11751](https://github.com/dynamic-labs/dynamic-auth/issues/11751)) ([c8be3af](https://github.com/dynamic-labs/dynamic-auth/commit/c8be3afc301f77b349f23398bed940ce40f93b73))
|
|
18
|
+
* **nonce:** fetch nonce on demand when missing before wallet verification ([#11753](https://github.com/dynamic-labs/dynamic-auth/issues/11753)) ([4f01a21](https://github.com/dynamic-labs/dynamic-auth/commit/4f01a21b6081c852f32868c8a5e04d70aaf280a2)), closes [#1](https://github.com/dynamic-labs/dynamic-auth/issues/1)
|
|
19
|
+
* **react-native-extension:** arm loading timer before setUrl to cover pre-onLoadStart gap ([#11764](https://github.com/dynamic-labs/dynamic-auth/issues/11764)) ([31f2015](https://github.com/dynamic-labs/dynamic-auth/commit/31f20151a4b59279f9c133b723e50de771b06436))
|
|
20
|
+
* **webview-controller:** unwrap ZeroDev smart wallet for native gasless ([#11758](https://github.com/dynamic-labs/dynamic-auth/issues/11758)) ([989714e](https://github.com/dynamic-labs/dynamic-auth/commit/989714e414556868c8e0c54401aac1ed7354331b))
|
|
21
|
+
|
|
2
22
|
### [4.91.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.1...v4.91.2) (2026-06-26)
|
|
3
23
|
|
|
4
24
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.91.
|
|
3
|
+
"version": "4.91.4",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.1046",
|
|
6
6
|
"@dynamic-labs-sdk/client": "1.12.1",
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"yup": "0.32.11",
|
|
18
18
|
"react-international-phone": "4.5.0",
|
|
19
19
|
"bs58": "5.0.0",
|
|
20
|
-
"@dynamic-labs/assert-package-version": "4.91.
|
|
21
|
-
"@dynamic-labs/iconic": "4.91.
|
|
22
|
-
"@dynamic-labs/locale": "4.91.
|
|
23
|
-
"@dynamic-labs/logger": "4.91.
|
|
24
|
-
"@dynamic-labs/multi-wallet": "4.91.
|
|
25
|
-
"@dynamic-labs/rpc-providers": "4.91.
|
|
26
|
-
"@dynamic-labs/store": "4.91.
|
|
27
|
-
"@dynamic-labs/types": "4.91.
|
|
28
|
-
"@dynamic-labs/utils": "4.91.
|
|
29
|
-
"@dynamic-labs/wallet-book": "4.91.
|
|
30
|
-
"@dynamic-labs/wallet-connector-core": "4.91.
|
|
20
|
+
"@dynamic-labs/assert-package-version": "4.91.4",
|
|
21
|
+
"@dynamic-labs/iconic": "4.91.4",
|
|
22
|
+
"@dynamic-labs/locale": "4.91.4",
|
|
23
|
+
"@dynamic-labs/logger": "4.91.4",
|
|
24
|
+
"@dynamic-labs/multi-wallet": "4.91.4",
|
|
25
|
+
"@dynamic-labs/rpc-providers": "4.91.4",
|
|
26
|
+
"@dynamic-labs/store": "4.91.4",
|
|
27
|
+
"@dynamic-labs/types": "4.91.4",
|
|
28
|
+
"@dynamic-labs/utils": "4.91.4",
|
|
29
|
+
"@dynamic-labs/wallet-book": "4.91.4",
|
|
30
|
+
"@dynamic-labs/wallet-connector-core": "4.91.4",
|
|
31
31
|
"eventemitter3": "5.0.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
@@ -35,7 +35,7 @@ const hasDynamicClient = () => getClientStore().client !== null;
|
|
|
35
35
|
const getDynamicClient = () => {
|
|
36
36
|
const { client } = getClientStore();
|
|
37
37
|
if (!client) {
|
|
38
|
-
throw new utils.DynamicError('Tried to getClient when it was still null');
|
|
38
|
+
throw new utils.DynamicError('Tried to getClient when it was still null', 'tried_to_getclient_when_it_was');
|
|
39
39
|
}
|
|
40
40
|
return client;
|
|
41
41
|
};
|
package/src/lib/client/client.js
CHANGED
|
@@ -27,7 +27,7 @@ const hasDynamicClient = () => getClientStore().client !== null;
|
|
|
27
27
|
const getDynamicClient = () => {
|
|
28
28
|
const { client } = getClientStore();
|
|
29
29
|
if (!client) {
|
|
30
|
-
throw new DynamicError('Tried to getClient when it was still null');
|
|
30
|
+
throw new DynamicError('Tried to getClient when it was still null', 'tried_to_getclient_when_it_was');
|
|
31
31
|
}
|
|
32
32
|
return client;
|
|
33
33
|
};
|
package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs
CHANGED
|
@@ -118,6 +118,7 @@ var utils = require('./utils.cjs');
|
|
|
118
118
|
var TransactionCard = require('../TransactionCard/TransactionCard.cjs');
|
|
119
119
|
var SendBalanceTransactionCard = require('../TransactionCard/SendBalanceTransactionCard.cjs');
|
|
120
120
|
var getTransactionLink = require('../../utils/functions/getTransactionLink/getTransactionLink.cjs');
|
|
121
|
+
var useViewSettings = require('../../utils/hooks/useViewSettings/useViewSettings.cjs');
|
|
121
122
|
require('../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
122
123
|
require('../OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
123
124
|
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
@@ -136,14 +137,16 @@ require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
136
137
|
const TransactionConfirmationPageLayout = ({ onClickClose, isLoading, onClickBack, onClickSend, disableSendButton, displayPoweredByDynamicFooter = false, error, fetchTransactionFee, alert, walletConnector, transaction, transactionSignature, currentToken, children, hideModal, onSuccess, transactionValue, total, isGasSponsored, isNativeToken, walletKey, simulationResult, sendBalanceTransaction, recipient, }) => {
|
|
137
138
|
var _a;
|
|
138
139
|
const { t } = reactI18next.useTranslation();
|
|
140
|
+
const txConfirmationSettings = useViewSettings.useViewSettings('transaction-confirmation');
|
|
139
141
|
const { data: transactionLink } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
140
142
|
return walletConnector && transactionSignature
|
|
141
143
|
? getTransactionLink.getTransactionLink({
|
|
142
144
|
transactionHash: transactionSignature,
|
|
145
|
+
userOpSupportedExplorers: txConfirmationSettings === null || txConfirmationSettings === void 0 ? void 0 : txConfirmationSettings.userOpSupportedExplorers,
|
|
143
146
|
walletConnector,
|
|
144
147
|
})
|
|
145
148
|
: undefined;
|
|
146
|
-
}), { deps: [walletConnector, transactionSignature] });
|
|
149
|
+
}), { deps: [walletConnector, transactionSignature, txConfirmationSettings] });
|
|
147
150
|
const { isTurnkeyWallet } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
148
151
|
const { setShowAuthFlow, user, primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
149
152
|
const { pushView } = ViewContext.useViewContext();
|
package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js
CHANGED
|
@@ -114,6 +114,7 @@ import { useCurrencySymbol, useHandleRecovery, getValueRounded, useHandleSubmitW
|
|
|
114
114
|
import { TransactionCard } from '../TransactionCard/TransactionCard.js';
|
|
115
115
|
import { SendBalanceTransactionCard } from '../TransactionCard/SendBalanceTransactionCard.js';
|
|
116
116
|
import { getTransactionLink } from '../../utils/functions/getTransactionLink/getTransactionLink.js';
|
|
117
|
+
import { useViewSettings } from '../../utils/hooks/useViewSettings/useViewSettings.js';
|
|
117
118
|
import '../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
118
119
|
import '../OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
119
120
|
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
@@ -132,14 +133,16 @@ import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
132
133
|
const TransactionConfirmationPageLayout = ({ onClickClose, isLoading, onClickBack, onClickSend, disableSendButton, displayPoweredByDynamicFooter = false, error, fetchTransactionFee, alert, walletConnector, transaction, transactionSignature, currentToken, children, hideModal, onSuccess, transactionValue, total, isGasSponsored, isNativeToken, walletKey, simulationResult, sendBalanceTransaction, recipient, }) => {
|
|
133
134
|
var _a;
|
|
134
135
|
const { t } = useTranslation();
|
|
136
|
+
const txConfirmationSettings = useViewSettings('transaction-confirmation');
|
|
135
137
|
const { data: transactionLink } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
138
|
return walletConnector && transactionSignature
|
|
137
139
|
? getTransactionLink({
|
|
138
140
|
transactionHash: transactionSignature,
|
|
141
|
+
userOpSupportedExplorers: txConfirmationSettings === null || txConfirmationSettings === void 0 ? void 0 : txConfirmationSettings.userOpSupportedExplorers,
|
|
139
142
|
walletConnector,
|
|
140
143
|
})
|
|
141
144
|
: undefined;
|
|
142
|
-
}), { deps: [walletConnector, transactionSignature] });
|
|
145
|
+
}), { deps: [walletConnector, transactionSignature, txConfirmationSettings] });
|
|
143
146
|
const { isTurnkeyWallet } = useIsTurnkeyWallet();
|
|
144
147
|
const { setShowAuthFlow, user, primaryWallet } = useInternalDynamicContext();
|
|
145
148
|
const { pushView } = useViewContext();
|
|
@@ -94,6 +94,7 @@ require('../Input/Input.cjs');
|
|
|
94
94
|
require('../OverlayCard/OverlayCard.cjs');
|
|
95
95
|
var utils = require('../TransactionConfirmationPageLayout/utils.cjs');
|
|
96
96
|
var getTransactionLink = require('../../utils/functions/getTransactionLink/getTransactionLink.cjs');
|
|
97
|
+
var useViewSettings = require('../../utils/hooks/useViewSettings/useViewSettings.cjs');
|
|
97
98
|
require('../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
98
99
|
require('../PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
99
100
|
require('../../context/PasskeyContext/PasskeyContext.cjs');
|
|
@@ -131,11 +132,13 @@ const TransactionStatusLayout = ({ destinationAddress, transactionValue, network
|
|
|
131
132
|
const { t } = reactI18next.useTranslation();
|
|
132
133
|
const { showFiat, primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
133
134
|
const { nativePrice } = sendBalances.useSendBalanceState();
|
|
135
|
+
const txConfirmationSettings = useViewSettings.useViewSettings('transaction-confirmation');
|
|
134
136
|
const { data: txLink } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
135
137
|
if (!(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) || !transactionHash)
|
|
136
138
|
return;
|
|
137
139
|
return getTransactionLink.getTransactionLink({
|
|
138
140
|
transactionHash,
|
|
141
|
+
userOpSupportedExplorers: txConfirmationSettings === null || txConfirmationSettings === void 0 ? void 0 : txConfirmationSettings.userOpSupportedExplorers,
|
|
139
142
|
walletConnector: primaryWallet.connector,
|
|
140
143
|
});
|
|
141
144
|
}));
|
|
@@ -90,6 +90,7 @@ import '../Input/Input.js';
|
|
|
90
90
|
import '../OverlayCard/OverlayCard.js';
|
|
91
91
|
import { getValueRounded } from '../TransactionConfirmationPageLayout/utils.js';
|
|
92
92
|
import { getTransactionLink } from '../../utils/functions/getTransactionLink/getTransactionLink.js';
|
|
93
|
+
import { useViewSettings } from '../../utils/hooks/useViewSettings/useViewSettings.js';
|
|
93
94
|
import '../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
94
95
|
import '../PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
95
96
|
import '../../context/PasskeyContext/PasskeyContext.js';
|
|
@@ -127,11 +128,13 @@ const TransactionStatusLayout = ({ destinationAddress, transactionValue, network
|
|
|
127
128
|
const { t } = useTranslation();
|
|
128
129
|
const { showFiat, primaryWallet } = useInternalDynamicContext();
|
|
129
130
|
const { nativePrice } = useSendBalanceState();
|
|
131
|
+
const txConfirmationSettings = useViewSettings('transaction-confirmation');
|
|
130
132
|
const { data: txLink } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
133
|
if (!(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) || !transactionHash)
|
|
132
134
|
return;
|
|
133
135
|
return getTransactionLink({
|
|
134
136
|
transactionHash,
|
|
137
|
+
userOpSupportedExplorers: txConfirmationSettings === null || txConfirmationSettings === void 0 ? void 0 : txConfirmationSettings.userOpSupportedExplorers,
|
|
135
138
|
walletConnector: primaryWallet.connector,
|
|
136
139
|
});
|
|
137
140
|
}));
|
|
@@ -50,7 +50,7 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOutWithReason, setPrimaryW
|
|
|
50
50
|
if (authMode$1 === 'connect-and-sign') {
|
|
51
51
|
const isLastVerifiedCredential = (user === null || user === void 0 ? void 0 : user.verifiedCredentials.length) === 1;
|
|
52
52
|
if (isLastVerifiedCredential) {
|
|
53
|
-
throw new utils.DynamicError('This is your only login method. Add another wallet or log in method before removing it.');
|
|
53
|
+
throw new utils.DynamicError('This is your only login method. Add another wallet or log in method before removing it.', 'last_verified_credential');
|
|
54
54
|
}
|
|
55
55
|
yield wallets.unlinkWallet({
|
|
56
56
|
environmentId: dynamicContextProps.getEnvironmentId(),
|
|
@@ -46,7 +46,7 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOutWithReason, setPrimaryW
|
|
|
46
46
|
if (authMode === 'connect-and-sign') {
|
|
47
47
|
const isLastVerifiedCredential = (user === null || user === void 0 ? void 0 : user.verifiedCredentials.length) === 1;
|
|
48
48
|
if (isLastVerifiedCredential) {
|
|
49
|
-
throw new DynamicError('This is your only login method. Add another wallet or log in method before removing it.');
|
|
49
|
+
throw new DynamicError('This is your only login method. Add another wallet or log in method before removing it.', 'last_verified_credential');
|
|
50
50
|
}
|
|
51
51
|
yield unlinkWallet({
|
|
52
52
|
environmentId: getEnvironmentId(),
|
|
@@ -9,8 +9,20 @@ export type WalletListViewSettings = {
|
|
|
9
9
|
items: WalletListViewTabItem[];
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
+
export type TransactionConfirmationViewSettings = {
|
|
13
|
+
type: 'transaction-confirmation';
|
|
14
|
+
/**
|
|
15
|
+
* Additional block explorer domains that support the /op/{userOpHash} route
|
|
16
|
+
* for ERC-4337 UserOperation lookups.
|
|
17
|
+
* These are merged with the built-in list of supported explorers
|
|
18
|
+
* (e.g. etherscan.io, blockscout.com, etc.).
|
|
19
|
+
*
|
|
20
|
+
* Example: ['my-custom-explorer.com', 'my-l2-explorer.xyz']
|
|
21
|
+
*/
|
|
22
|
+
userOpSupportedExplorers?: string[];
|
|
23
|
+
};
|
|
12
24
|
export type NetworksOverrides = GenericNetwork[] | ((dashboardNetworks: GenericNetwork[]) => GenericNetwork[]);
|
|
13
|
-
export type ViewsOverrides = SdkView | WalletListViewSettings;
|
|
25
|
+
export type ViewsOverrides = SdkView | WalletListViewSettings | TransactionConfirmationViewSettings;
|
|
14
26
|
export type OnrampOption = {
|
|
15
27
|
/**
|
|
16
28
|
* The name of the onramp provider to be displayed in UI
|
|
@@ -10,30 +10,50 @@ var logger = require('../../shared/logger.cjs');
|
|
|
10
10
|
var createProviderHook = require('../../shared/utils/functions/createProviderHook/createProviderHook.cjs');
|
|
11
11
|
|
|
12
12
|
const FALLBACK_ERROR_LOG_EVENT = 'ui.fallback_error_shown';
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
const DEFAULT_ERROR_MESSAGE = 'Something went wrong. Please try again.';
|
|
14
|
+
const MESSAGE_SIGNATURE_DENIED = 'Message signature denied.';
|
|
15
|
+
const UNLOCK_WALLET_MESSAGE = 'Please unlock your wallet extension and try again.';
|
|
16
|
+
const INTERNAL_ERROR_MESSAGE = 'There was an internal error. Please try again.';
|
|
17
|
+
let _errorMessageMap;
|
|
18
|
+
const getErrorMessageMap = () => {
|
|
19
|
+
if (!_errorMessageMap) {
|
|
20
|
+
_errorMessageMap = {
|
|
21
|
+
'-1': DEFAULT_ERROR_MESSAGE,
|
|
22
|
+
'-32000': MESSAGE_SIGNATURE_DENIED,
|
|
23
|
+
'-32002': UNLOCK_WALLET_MESSAGE,
|
|
24
|
+
'-32003': MESSAGE_SIGNATURE_DENIED,
|
|
25
|
+
'-32602': 'Invalid parameters. Please try again.',
|
|
26
|
+
'-32603': INTERNAL_ERROR_MESSAGE,
|
|
27
|
+
0: MESSAGE_SIGNATURE_DENIED,
|
|
28
|
+
4001: MESSAGE_SIGNATURE_DENIED,
|
|
29
|
+
4100: UNLOCK_WALLET_MESSAGE,
|
|
30
|
+
4900: INTERNAL_ERROR_MESSAGE,
|
|
31
|
+
5001: MESSAGE_SIGNATURE_DENIED,
|
|
32
|
+
5002: MESSAGE_SIGNATURE_DENIED,
|
|
33
|
+
account_already_linked_to_different_profile: 'This social account is already linked to a different profile.',
|
|
34
|
+
[utils.SdkErrorCode.CONNECTION_REJECTED]: 'Connection rejected. Please try again.',
|
|
35
|
+
general_error: DEFAULT_ERROR_MESSAGE,
|
|
36
|
+
[utils.SdkErrorCode.INVALID_EMAIL_VERIFICATION]: 'The verification link is no longer valid. Please start again.',
|
|
37
|
+
metamask_timeout: 'Whoops. Looks like something went wrong. Please try again.',
|
|
38
|
+
[utils.SdkErrorCode.MISSING_NONCE]: DEFAULT_ERROR_MESSAGE,
|
|
39
|
+
'missing-public-address': 'Connection cancelled. Please try again',
|
|
40
|
+
no_webauthn_support_error: 'Your browser does not support passkeys. Please try a different browser.',
|
|
41
|
+
oauth_error: 'Authentication failed. Please try again.',
|
|
42
|
+
oauth_window_blocked: 'To connect to your social account, enable popups in your browser and then try again.',
|
|
43
|
+
oauth_window_timeout: 'Session time out. Please try again.',
|
|
44
|
+
provider_not_enabled: 'This sign-in provider is not enabled. Please contact the app administrator.',
|
|
45
|
+
signin_error: 'Sign-in failed. Please try again.',
|
|
46
|
+
social_linking_not_enabled: 'Social account linking is not enabled for this application.',
|
|
47
|
+
[utils.SdkErrorCode.TOO_MANY_EMAIL_VERIFICATION_ATTEMPTS]: 'Too many email verification attempts, please try again later',
|
|
48
|
+
[utils.SdkErrorCode.UNKNOWN_ERROR]: 'An unexpected error occurred. Please try again.',
|
|
49
|
+
[utils.SdkErrorCode.USER_CANCELLED]: '',
|
|
50
|
+
[utils.SdkErrorCode.USER_CANCELLED_OAUTH]: '',
|
|
51
|
+
verification_error: 'Verification failed. Please try again.',
|
|
52
|
+
[utils.SdkErrorCode.WALLET_NOT_DEPLOYED]: 'Your smart wallet has not been deployed.',
|
|
53
|
+
wrong_email_verification_token: 'The code you entered is incorrect. Please try again.',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return _errorMessageMap;
|
|
37
57
|
};
|
|
38
58
|
const ErrorContext = React.createContext(undefined);
|
|
39
59
|
const ErrorContextProvider = ({ children }) => {
|
|
@@ -54,12 +74,12 @@ const ErrorContextProvider = ({ children }) => {
|
|
|
54
74
|
source: 'setDefaultError',
|
|
55
75
|
time: 0,
|
|
56
76
|
});
|
|
57
|
-
setError(
|
|
77
|
+
setError(DEFAULT_ERROR_MESSAGE, utils.ErrorCode.DEFAULT);
|
|
58
78
|
}, [setError]);
|
|
59
79
|
/** @deprecated Prefer setError with a translation key instead */
|
|
60
80
|
const setErrorMessage = React.useCallback((status, error, source) => {
|
|
61
|
-
const mappedMessage =
|
|
62
|
-
if (
|
|
81
|
+
const mappedMessage = getErrorMessageMap()[status];
|
|
82
|
+
if (mappedMessage === undefined) {
|
|
63
83
|
logger.logger.instrument(FALLBACK_ERROR_LOG_EVENT, {
|
|
64
84
|
error: error instanceof Error ? error.message : undefined,
|
|
65
85
|
errorCode: status,
|
|
@@ -68,7 +88,7 @@ const ErrorContextProvider = ({ children }) => {
|
|
|
68
88
|
time: 0,
|
|
69
89
|
});
|
|
70
90
|
}
|
|
71
|
-
setError(mappedMessage !== null && mappedMessage !== void 0 ? mappedMessage :
|
|
91
|
+
setError(mappedMessage !== null && mappedMessage !== void 0 ? mappedMessage : DEFAULT_ERROR_MESSAGE);
|
|
72
92
|
}, [setError]);
|
|
73
93
|
const clearError = React.useCallback(() => {
|
|
74
94
|
_setError(undefined);
|
|
@@ -1,35 +1,55 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { createContext, useState, useCallback, useMemo } from 'react';
|
|
4
|
-
import { ErrorCode } from '@dynamic-labs/utils';
|
|
4
|
+
import { ErrorCode, SdkErrorCode } from '@dynamic-labs/utils';
|
|
5
5
|
import { logger } from '../../shared/logger.js';
|
|
6
6
|
import { createProviderHook } from '../../shared/utils/functions/createProviderHook/createProviderHook.js';
|
|
7
7
|
|
|
8
8
|
const FALLBACK_ERROR_LOG_EVENT = 'ui.fallback_error_shown';
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
9
|
+
const DEFAULT_ERROR_MESSAGE = 'Something went wrong. Please try again.';
|
|
10
|
+
const MESSAGE_SIGNATURE_DENIED = 'Message signature denied.';
|
|
11
|
+
const UNLOCK_WALLET_MESSAGE = 'Please unlock your wallet extension and try again.';
|
|
12
|
+
const INTERNAL_ERROR_MESSAGE = 'There was an internal error. Please try again.';
|
|
13
|
+
let _errorMessageMap;
|
|
14
|
+
const getErrorMessageMap = () => {
|
|
15
|
+
if (!_errorMessageMap) {
|
|
16
|
+
_errorMessageMap = {
|
|
17
|
+
'-1': DEFAULT_ERROR_MESSAGE,
|
|
18
|
+
'-32000': MESSAGE_SIGNATURE_DENIED,
|
|
19
|
+
'-32002': UNLOCK_WALLET_MESSAGE,
|
|
20
|
+
'-32003': MESSAGE_SIGNATURE_DENIED,
|
|
21
|
+
'-32602': 'Invalid parameters. Please try again.',
|
|
22
|
+
'-32603': INTERNAL_ERROR_MESSAGE,
|
|
23
|
+
0: MESSAGE_SIGNATURE_DENIED,
|
|
24
|
+
4001: MESSAGE_SIGNATURE_DENIED,
|
|
25
|
+
4100: UNLOCK_WALLET_MESSAGE,
|
|
26
|
+
4900: INTERNAL_ERROR_MESSAGE,
|
|
27
|
+
5001: MESSAGE_SIGNATURE_DENIED,
|
|
28
|
+
5002: MESSAGE_SIGNATURE_DENIED,
|
|
29
|
+
account_already_linked_to_different_profile: 'This social account is already linked to a different profile.',
|
|
30
|
+
[SdkErrorCode.CONNECTION_REJECTED]: 'Connection rejected. Please try again.',
|
|
31
|
+
general_error: DEFAULT_ERROR_MESSAGE,
|
|
32
|
+
[SdkErrorCode.INVALID_EMAIL_VERIFICATION]: 'The verification link is no longer valid. Please start again.',
|
|
33
|
+
metamask_timeout: 'Whoops. Looks like something went wrong. Please try again.',
|
|
34
|
+
[SdkErrorCode.MISSING_NONCE]: DEFAULT_ERROR_MESSAGE,
|
|
35
|
+
'missing-public-address': 'Connection cancelled. Please try again',
|
|
36
|
+
no_webauthn_support_error: 'Your browser does not support passkeys. Please try a different browser.',
|
|
37
|
+
oauth_error: 'Authentication failed. Please try again.',
|
|
38
|
+
oauth_window_blocked: 'To connect to your social account, enable popups in your browser and then try again.',
|
|
39
|
+
oauth_window_timeout: 'Session time out. Please try again.',
|
|
40
|
+
provider_not_enabled: 'This sign-in provider is not enabled. Please contact the app administrator.',
|
|
41
|
+
signin_error: 'Sign-in failed. Please try again.',
|
|
42
|
+
social_linking_not_enabled: 'Social account linking is not enabled for this application.',
|
|
43
|
+
[SdkErrorCode.TOO_MANY_EMAIL_VERIFICATION_ATTEMPTS]: 'Too many email verification attempts, please try again later',
|
|
44
|
+
[SdkErrorCode.UNKNOWN_ERROR]: 'An unexpected error occurred. Please try again.',
|
|
45
|
+
[SdkErrorCode.USER_CANCELLED]: '',
|
|
46
|
+
[SdkErrorCode.USER_CANCELLED_OAUTH]: '',
|
|
47
|
+
verification_error: 'Verification failed. Please try again.',
|
|
48
|
+
[SdkErrorCode.WALLET_NOT_DEPLOYED]: 'Your smart wallet has not been deployed.',
|
|
49
|
+
wrong_email_verification_token: 'The code you entered is incorrect. Please try again.',
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return _errorMessageMap;
|
|
33
53
|
};
|
|
34
54
|
const ErrorContext = createContext(undefined);
|
|
35
55
|
const ErrorContextProvider = ({ children }) => {
|
|
@@ -50,12 +70,12 @@ const ErrorContextProvider = ({ children }) => {
|
|
|
50
70
|
source: 'setDefaultError',
|
|
51
71
|
time: 0,
|
|
52
72
|
});
|
|
53
|
-
setError(
|
|
73
|
+
setError(DEFAULT_ERROR_MESSAGE, ErrorCode.DEFAULT);
|
|
54
74
|
}, [setError]);
|
|
55
75
|
/** @deprecated Prefer setError with a translation key instead */
|
|
56
76
|
const setErrorMessage = useCallback((status, error, source) => {
|
|
57
|
-
const mappedMessage =
|
|
58
|
-
if (
|
|
77
|
+
const mappedMessage = getErrorMessageMap()[status];
|
|
78
|
+
if (mappedMessage === undefined) {
|
|
59
79
|
logger.instrument(FALLBACK_ERROR_LOG_EVENT, {
|
|
60
80
|
error: error instanceof Error ? error.message : undefined,
|
|
61
81
|
errorCode: status,
|
|
@@ -64,7 +84,7 @@ const ErrorContextProvider = ({ children }) => {
|
|
|
64
84
|
time: 0,
|
|
65
85
|
});
|
|
66
86
|
}
|
|
67
|
-
setError(mappedMessage !== null && mappedMessage !== void 0 ? mappedMessage :
|
|
87
|
+
setError(mappedMessage !== null && mappedMessage !== void 0 ? mappedMessage : DEFAULT_ERROR_MESSAGE);
|
|
68
88
|
}, [setError]);
|
|
69
89
|
const clearError = useCallback(() => {
|
|
70
90
|
_setError(undefined);
|
|
@@ -20,7 +20,7 @@ var getOnrampProviders = require('./utils/getOnrampProviders.cjs');
|
|
|
20
20
|
|
|
21
21
|
const OnrampContext = React.createContext(undefined);
|
|
22
22
|
const OnrampContextProvider = ({ children, }) => {
|
|
23
|
-
var _a, _b, _c, _d, _e;
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
24
24
|
const promiseRef = React.useRef(null);
|
|
25
25
|
const [selectedOnrampProvider, setSelectedOnrampProvider] = React.useState();
|
|
26
26
|
const [showOnramp, _setShowOnramp] = React.useState(false);
|
|
@@ -29,12 +29,17 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
29
29
|
const { environmentId, network, primaryWallet, projectSettings, overrides } = useInternalDynamicContext.useInternalDynamicContext();
|
|
30
30
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
31
31
|
const [enabledOnrampProvidersTarget, setEnabledOnrampProvidersTarget] = React.useState({});
|
|
32
|
-
//
|
|
33
|
-
const [
|
|
32
|
+
// Manual trigger for programmatic flows (openOnramp, setEnabledOnrampProvidersTargetValue)
|
|
33
|
+
const [manualFetchTriggered, setManualFetchTriggered] = React.useState(false);
|
|
34
|
+
// Auto-fetch when onramps are configured in the dashboard so the Buy button
|
|
35
|
+
// is available in the funding-methods view. When unconfigured, skip the fetch
|
|
36
|
+
// to avoid wasting bandwidth on SDK mount (esp. on slow mobile connections).
|
|
37
|
+
const hasOnrampsConfigured = Boolean((_c = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.funding) === null || _b === void 0 ? void 0 : _b.onramps) === null || _c === void 0 ? void 0 : _c.length);
|
|
38
|
+
const shouldFetchOnramps = manualFetchTriggered || hasOnrampsConfigured;
|
|
34
39
|
const setShowOnramp = React.useCallback((value) => {
|
|
35
40
|
_setShowOnramp(value);
|
|
36
41
|
if (!value && promiseRef.current) {
|
|
37
|
-
rejectPromiseRef.rejectPromiseRef(promiseRef, new utils.DynamicError('User cancelled'));
|
|
42
|
+
rejectPromiseRef.rejectPromiseRef(promiseRef, new utils.DynamicError('User cancelled', 'user_cancelled'));
|
|
38
43
|
}
|
|
39
44
|
}, []);
|
|
40
45
|
const setEnabledOnrampProvidersTargetValue = React.useCallback(({ address, token, network, tokenAmount, chainName, currency, }) => {
|
|
@@ -48,7 +53,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
48
53
|
});
|
|
49
54
|
// Trigger fetch when target is set with specific parameters
|
|
50
55
|
if (address || token || network || tokenAmount || chainName || currency) {
|
|
51
|
-
|
|
56
|
+
setManualFetchTriggered(true);
|
|
52
57
|
}
|
|
53
58
|
}, []);
|
|
54
59
|
const resetOverrides = React.useCallback(() => {
|
|
@@ -60,7 +65,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
60
65
|
includeDisabled: true,
|
|
61
66
|
network,
|
|
62
67
|
primaryWallet,
|
|
63
|
-
projectSettingsOnramps: (
|
|
68
|
+
projectSettingsOnramps: (_e = (_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _d === void 0 ? void 0 : _d.funding) === null || _e === void 0 ? void 0 : _e.onramps,
|
|
64
69
|
shouldFetch: shouldFetchOnramps,
|
|
65
70
|
target: enabledOnrampProvidersTarget,
|
|
66
71
|
});
|
|
@@ -101,7 +106,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
101
106
|
return Boolean(((_c = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.funding) === null || _b === void 0 ? void 0 : _b.onramps) === null || _c === void 0 ? void 0 : _c.length) &&
|
|
102
107
|
enabledOnrampProvidersInDashboard.length);
|
|
103
108
|
}, [
|
|
104
|
-
(
|
|
109
|
+
(_h = (_g = (_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _f === void 0 ? void 0 : _f.funding) === null || _g === void 0 ? void 0 : _g.onramps) === null || _h === void 0 ? void 0 : _h.length,
|
|
105
110
|
enabledOnrampProvidersInDashboard.length,
|
|
106
111
|
onrampOverrides.length,
|
|
107
112
|
overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions,
|
|
@@ -131,8 +136,8 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
131
136
|
onrampOverrides,
|
|
132
137
|
overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions,
|
|
133
138
|
]);
|
|
134
|
-
const openOnramp = React.useCallback((
|
|
135
|
-
var
|
|
139
|
+
const openOnramp = React.useCallback((_j) => _tslib.__awaiter(void 0, [_j], void 0, function* ({ onrampProvider, address, token, tokenAmount, network: networkOverride, chainName, currency, overrideOnRamp, payingWithDynamic, merchantName, }) {
|
|
140
|
+
var _k, _l, _m, _o;
|
|
136
141
|
if (!onrampEnabled && !overrideOnRamp && !payingWithDynamic) {
|
|
137
142
|
throw new Error('Onramp is not enabled');
|
|
138
143
|
}
|
|
@@ -142,8 +147,8 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
142
147
|
}
|
|
143
148
|
promiseRef.current = new utils.DeferredPromise();
|
|
144
149
|
// Trigger onramp providers fetch if not already done
|
|
145
|
-
if (!
|
|
146
|
-
|
|
150
|
+
if (!manualFetchTriggered) {
|
|
151
|
+
setManualFetchTriggered(true);
|
|
147
152
|
}
|
|
148
153
|
let localOnrampProviders = enabledOnrampProvidersInDashboardOptions;
|
|
149
154
|
const networkToUse = networkOverride || network;
|
|
@@ -162,7 +167,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
162
167
|
Boolean(address);
|
|
163
168
|
if (payingWithDynamic && !allPayingParameters) {
|
|
164
169
|
rejectPromiseRef.rejectPromiseRef(promiseRef, new Error('PayingWithDynamic: Missing parameters'));
|
|
165
|
-
return (
|
|
170
|
+
return (_k = promiseRef.current) === null || _k === void 0 ? void 0 : _k.promise;
|
|
166
171
|
}
|
|
167
172
|
if (shouldOverrideOnrampProviders)
|
|
168
173
|
setOverride(true);
|
|
@@ -184,15 +189,15 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
184
189
|
const onrampOption = localOnrampProviders.find((p) => p.id === onrampProvider);
|
|
185
190
|
if (payingWithDynamic && !onrampOption) {
|
|
186
191
|
rejectPromiseRef.rejectPromiseRef(promiseRef, new Error('PayingWithDynamic: Onramp provider not found'));
|
|
187
|
-
return (
|
|
192
|
+
return (_l = promiseRef.current) === null || _l === void 0 ? void 0 : _l.promise;
|
|
188
193
|
}
|
|
189
194
|
if (!onrampOption) {
|
|
190
195
|
rejectPromiseRef.rejectPromiseRef(promiseRef, new Error('Onramp provider not found'));
|
|
191
|
-
return (
|
|
196
|
+
return (_m = promiseRef.current) === null || _m === void 0 ? void 0 : _m.promise;
|
|
192
197
|
}
|
|
193
198
|
setOverrideOnrampProvider(onrampOption);
|
|
194
199
|
setSelectedAndShowOnramp({ payingWithDynamic, provider: onrampOption });
|
|
195
|
-
return (
|
|
200
|
+
return (_o = promiseRef.current) === null || _o === void 0 ? void 0 : _o.promise;
|
|
196
201
|
}), [
|
|
197
202
|
enabledOnrampProvidersInDashboardOptions,
|
|
198
203
|
environmentId,
|
|
@@ -200,7 +205,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
200
205
|
primaryWallet,
|
|
201
206
|
network,
|
|
202
207
|
setSelectedAndShowOnramp,
|
|
203
|
-
|
|
208
|
+
manualFetchTriggered,
|
|
204
209
|
]);
|
|
205
210
|
const selectedOnramp = React.useMemo(() => {
|
|
206
211
|
let selected;
|