@dynamic-labs/sdk-react-core 0.19.0-alpha.14 → 0.19.0-alpha.16
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 +25 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +46 -26
- package/src/lib/components/SendBalanceForm/SendBalanceForm.d.ts +1 -0
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +46 -26
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +2 -2
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.d.ts +1 -0
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +1 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +20 -7
- package/src/lib/context/DynamicContext/DynamicContext.js +20 -7
- package/src/lib/context/DynamicContext/handleDisconnectWallet/handleDisconnectWallet.cjs +34 -0
- package/src/lib/context/DynamicContext/handleDisconnectWallet/handleDisconnectWallet.d.ts +13 -0
- package/src/lib/context/DynamicContext/handleDisconnectWallet/handleDisconnectWallet.js +30 -0
- package/src/lib/context/DynamicContext/handleDisconnectWallet/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/useCustomerCallbacks/types.d.ts +5 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +11 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.d.ts +1 -1
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +11 -2
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/locale/en/translation.cjs +0 -7
- package/src/lib/locale/en/translation.js +1 -7
- package/src/lib/shared/types/index.d.ts +6 -0
- package/src/lib/shared/utils/functions/getWalletListItemLabel/getWalletListItemLabel.cjs +4 -3
- package/src/lib/shared/utils/functions/getWalletListItemLabel/getWalletListItemLabel.js +4 -3
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/getOrdinalNumber/getOrdinalNumber.cjs +21 -0
- package/src/lib/utils/functions/getOrdinalNumber/getOrdinalNumber.d.ts +1 -0
- package/src/lib/utils/functions/getOrdinalNumber/getOrdinalNumber.js +17 -0
- package/src/lib/utils/functions/getOrdinalNumber/index.d.ts +1 -0
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/isTestnet/isTestnet.cjs +1 -1
- package/src/lib/utils/functions/isTestnet/isTestnet.js +1 -1
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs +1 -1
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +0 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +0 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +5 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +5 -4
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +5 -2
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.d.ts +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +1 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +1 -1
- package/src/lib/views/PasskeyIntroView/PasskeyIntroView.cjs +9 -4
- package/src/lib/views/PasskeyIntroView/PasskeyIntroView.js +9 -4
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +3 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.js +3 -2
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs +8 -0
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.d.ts +9 -2
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.js +8 -0
- package/src/lib/views/viewToComponentMap.cjs +0 -2
- package/src/lib/views/viewToComponentMap.js +0 -2
- package/src/lib/views/PasskeySuccessView/PasskeySuccessView.cjs +0 -71
- package/src/lib/views/PasskeySuccessView/PasskeySuccessView.d.ts +0 -2
- package/src/lib/views/PasskeySuccessView/PasskeySuccessView.js +0 -67
- package/src/lib/views/PasskeySuccessView/index.d.ts +0 -1
|
@@ -15,18 +15,19 @@ type Props = {
|
|
|
15
15
|
primaryWalletId: string | undefined;
|
|
16
16
|
setPrimaryWalletId: (walletId: string) => void;
|
|
17
17
|
wallets: WalletOption[];
|
|
18
|
-
onUnlink
|
|
18
|
+
onUnlink: (wallet: Wallet, connectedWalletsInfo: ConnectedWalletConnectorType[]) => void;
|
|
19
19
|
onBeforeConnectSuccessConfirmation: OnBeforeConnectSuccessConfirmation | undefined;
|
|
20
20
|
setShowAuthFlow: Dispatch<SetStateAction<boolean>>;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
type UseConnectWalletValue = {
|
|
23
23
|
connectWallet: (walletConnector: WalletConnector, fetchPublicAddressOpts?: FetchPublicAddressOpts, shouldCallCallback?: boolean) => Promise<string | undefined>;
|
|
24
|
-
connectedWallet: Wallet;
|
|
24
|
+
connectedWallet: Wallet | null;
|
|
25
25
|
connectedWallets: Wallet[];
|
|
26
|
-
connectedWalletsInfo: ConnectedWalletConnectorType[]
|
|
26
|
+
connectedWalletsInfo: ConnectedWalletConnectorType[];
|
|
27
27
|
getConnectedWalletById: (walletId: string) => Wallet | undefined;
|
|
28
28
|
refreshConnectedWallet: (walletId: string, walletConnector: WalletConnector) => Promise<void>;
|
|
29
29
|
removeConnectedWalletsInfo: () => void;
|
|
30
30
|
unlinkConnectedWallet: (walletId: string) => Promise<void>;
|
|
31
31
|
};
|
|
32
|
+
export declare const useConnectWallet: ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, wallets, onUnlink, onBeforeConnectSuccessConfirmation, setShowAuthFlow, }: Props) => UseConnectWalletValue;
|
|
32
33
|
export {};
|
|
@@ -171,13 +171,16 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
171
171
|
});
|
|
172
172
|
const unlinkConnectedWallet = (walletId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
173
|
const connectedWalletToUnlink = connectedWallets.find((wallet) => wallet.id === walletId);
|
|
174
|
-
|
|
174
|
+
if (!connectedWalletToUnlink) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
yield connectedWalletToUnlink.connector.endSession();
|
|
175
178
|
const filteredWallets = connectedWalletsInfo.filter((wallet) => wallet.id !== walletId);
|
|
176
179
|
if (walletId === primaryWalletId) {
|
|
177
180
|
clearPrimaryWalletId();
|
|
178
181
|
}
|
|
179
182
|
setConnectedWalletsInfo(filteredWallets);
|
|
180
|
-
onUnlink
|
|
183
|
+
onUnlink(connectedWalletToUnlink, filteredWallets);
|
|
181
184
|
});
|
|
182
185
|
const getConnectedWalletById = useCallback((walletId) => connectedWallets.find((wallet) => wallet.id === walletId), [connectedWallets]);
|
|
183
186
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
2
|
export declare const useHandleWalletsToConnect: () => {
|
|
3
3
|
handleWalletsToConnect: ({ walletConnector, }: {
|
|
4
|
-
walletConnector?: WalletConnector | undefined;
|
|
4
|
+
walletConnector?: import("@dynamic-labs/wallet-connector-core").WalletConnectorCore.WalletConnector | undefined;
|
|
5
5
|
}) => void;
|
|
6
6
|
};
|
|
@@ -169,7 +169,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
169
169
|
const user = yield createUserProfile.createUserProfile(decodedJwt);
|
|
170
170
|
const isKycRequired = decodedJwt.missingFields.length;
|
|
171
171
|
setOnboardingOnlyJwt(Jwt);
|
|
172
|
-
localStorage.LocalStorage.setToLS(localStorage$1.LAST_USED_WALLET, walletConnector.
|
|
172
|
+
localStorage.LocalStorage.setToLS(localStorage$1.LAST_USED_WALLET, walletConnector.key);
|
|
173
173
|
setAuthMode('connect-and-sign');
|
|
174
174
|
updatePrimaryWalletId(walletConnector, user);
|
|
175
175
|
// TODO: how can projectSettings be undefined?
|
|
@@ -165,7 +165,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
165
165
|
const user = yield createUserProfile(decodedJwt);
|
|
166
166
|
const isKycRequired = decodedJwt.missingFields.length;
|
|
167
167
|
setOnboardingOnlyJwt(Jwt);
|
|
168
|
-
LocalStorage.setToLS(LAST_USED_WALLET, walletConnector.
|
|
168
|
+
LocalStorage.setToLS(LAST_USED_WALLET, walletConnector.key);
|
|
169
169
|
setAuthMode('connect-and-sign');
|
|
170
170
|
updatePrimaryWalletId(walletConnector, user);
|
|
171
171
|
// TODO: how can projectSettings be undefined?
|
|
@@ -85,7 +85,7 @@ const useWalletUiUtils = ({ appLogoUrl, appName, getAppOrigin, }) => {
|
|
|
85
85
|
if (!shouldConfirmAction()) {
|
|
86
86
|
return handler(transaction);
|
|
87
87
|
}
|
|
88
|
-
return openSendTransaction((resolve, reject) => (jsxRuntime.jsx(TransactionConfirmationModal.TransactionConfirmationModal, { walletConnector: connector, title: '
|
|
88
|
+
return openSendTransaction((resolve, reject) => (jsxRuntime.jsx(TransactionConfirmationModal.TransactionConfirmationModal, { walletConnector: connector, title: 'Confirm Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
|
|
89
89
|
}), [openSendTransaction, shouldConfirmAction]);
|
|
90
90
|
const disabledConfirmationOnce = React.useCallback(() => {
|
|
91
91
|
confirmationStateRef.current = 'disabled';
|
|
@@ -81,7 +81,7 @@ const useWalletUiUtils = ({ appLogoUrl, appName, getAppOrigin, }) => {
|
|
|
81
81
|
if (!shouldConfirmAction()) {
|
|
82
82
|
return handler(transaction);
|
|
83
83
|
}
|
|
84
|
-
return openSendTransaction((resolve, reject) => (jsx(TransactionConfirmationModal, { walletConnector: connector, title: '
|
|
84
|
+
return openSendTransaction((resolve, reject) => (jsx(TransactionConfirmationModal, { walletConnector: connector, title: 'Confirm Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
|
|
85
85
|
}), [openSendTransaction, shouldConfirmAction]);
|
|
86
86
|
const disabledConfirmationOnce = useCallback(() => {
|
|
87
87
|
confirmationStateRef.current = 'disabled';
|
|
@@ -13,7 +13,7 @@ require('@dynamic-labs/sdk-api');
|
|
|
13
13
|
var logger = require('../../shared/logger.cjs');
|
|
14
14
|
require('@dynamic-labs/iconic');
|
|
15
15
|
require('@dynamic-labs/wallet-connector-core');
|
|
16
|
-
|
|
16
|
+
require('../../context/ViewContext/ViewContext.cjs');
|
|
17
17
|
var footerInfoIcon = require('../../shared/assets/footer-info-icon.cjs');
|
|
18
18
|
var passkeyIntroIcon = require('../../shared/assets/passkey-intro-icon.cjs');
|
|
19
19
|
var androidFaceId = require('../../shared/assets/android-face-id.cjs');
|
|
@@ -79,8 +79,7 @@ var createEmbeddedWalletWithPasskey = require('./utils/createEmbeddedWalletWithP
|
|
|
79
79
|
var findPasskeyEmailWalletConnector = require('./utils/findPasskeyEmailWalletConnector/findPasskeyEmailWalletConnector.cjs');
|
|
80
80
|
|
|
81
81
|
const PasskeyIntroView = ({ createEmbeddedWalletMutation = createEmbeddedWalletWithPasskey.createEmbeddedWalletWithPasskey, }) => {
|
|
82
|
-
const { user, wallets, setPrimaryWalletId, setUser, authToken, environmentId, handleLogOut, internalEvents, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
83
|
-
const { setView } = ViewContext.useViewContext();
|
|
82
|
+
const { user, wallets, setPrimaryWalletId, setUser, authToken, environmentId, handleLogOut, internalEvents, setShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
84
83
|
const { setIsFooterExpanded } = index.useFooterAnimationContext();
|
|
85
84
|
const { t } = reactI18next.useTranslation();
|
|
86
85
|
const { data: passkeyEnabled } = usePromise.usePromise(isPasskeyEnabled.isPasskeyEnabled);
|
|
@@ -88,6 +87,7 @@ const PasskeyIntroView = ({ createEmbeddedWalletMutation = createEmbeddedWalletW
|
|
|
88
87
|
// it should be null to force user to setup passkey even after the a refresh
|
|
89
88
|
React.useEffect(() => localStorage.LocalStorage.removeFromLS(localStorage$1.LAST_USED_WALLET), []);
|
|
90
89
|
const { mutate: createEmbeddedWalletWithPasskeyMutation, isLoading, error, } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
var _a;
|
|
91
91
|
const { embeddedWalletVerifiedCredentialId, jwt, decodedJwt, walletConnector, } = yield createEmbeddedWalletMutation({
|
|
92
92
|
authToken,
|
|
93
93
|
environmentId,
|
|
@@ -105,7 +105,12 @@ const PasskeyIntroView = ({ createEmbeddedWalletMutation = createEmbeddedWalletW
|
|
|
105
105
|
setPrimaryWalletId(embeddedWalletVerifiedCredentialId);
|
|
106
106
|
index$1.storeAuthToken(jwt);
|
|
107
107
|
setUser(createUserProfile.createUserProfile(decodedJwt));
|
|
108
|
-
|
|
108
|
+
setShowAuthFlow(false);
|
|
109
|
+
const turnkeyVerifiedCredentials = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === 'turnkey');
|
|
110
|
+
setCallback('embeddedWalletCreated', {
|
|
111
|
+
email: (turnkeyVerifiedCredentials === null || turnkeyVerifiedCredentials === void 0 ? void 0 : turnkeyVerifiedCredentials.email) || '',
|
|
112
|
+
verifiedCredential: turnkeyVerifiedCredentials,
|
|
113
|
+
});
|
|
109
114
|
}), {
|
|
110
115
|
onFailure: (err) => {
|
|
111
116
|
logger.logger.error('Failed to create embedded wallet', err);
|
|
@@ -9,7 +9,7 @@ import '@dynamic-labs/sdk-api';
|
|
|
9
9
|
import { logger } from '../../shared/logger.js';
|
|
10
10
|
import '@dynamic-labs/iconic';
|
|
11
11
|
import '@dynamic-labs/wallet-connector-core';
|
|
12
|
-
import
|
|
12
|
+
import '../../context/ViewContext/ViewContext.js';
|
|
13
13
|
import { ReactComponent as SvgFooterInfoIcon } from '../../shared/assets/footer-info-icon.js';
|
|
14
14
|
import { ReactComponent as SvgPasskeyIntroIcon } from '../../shared/assets/passkey-intro-icon.js';
|
|
15
15
|
import { ReactComponent as SvgAndroidFaceId } from '../../shared/assets/android-face-id.js';
|
|
@@ -75,8 +75,7 @@ import { createEmbeddedWalletWithPasskey } from './utils/createEmbeddedWalletWit
|
|
|
75
75
|
import { findPasskeyEmailWalletConnector } from './utils/findPasskeyEmailWalletConnector/findPasskeyEmailWalletConnector.js';
|
|
76
76
|
|
|
77
77
|
const PasskeyIntroView = ({ createEmbeddedWalletMutation = createEmbeddedWalletWithPasskey, }) => {
|
|
78
|
-
const { user, wallets, setPrimaryWalletId, setUser, authToken, environmentId, handleLogOut, internalEvents, } = useInternalDynamicContext();
|
|
79
|
-
const { setView } = useViewContext();
|
|
78
|
+
const { user, wallets, setPrimaryWalletId, setUser, authToken, environmentId, handleLogOut, internalEvents, setShowAuthFlow, setCallback, } = useInternalDynamicContext();
|
|
80
79
|
const { setIsFooterExpanded } = useFooterAnimationContext();
|
|
81
80
|
const { t } = useTranslation();
|
|
82
81
|
const { data: passkeyEnabled } = usePromise(isPasskeyEnabled);
|
|
@@ -84,6 +83,7 @@ const PasskeyIntroView = ({ createEmbeddedWalletMutation = createEmbeddedWalletW
|
|
|
84
83
|
// it should be null to force user to setup passkey even after the a refresh
|
|
85
84
|
useEffect(() => LocalStorage.removeFromLS(LAST_USED_WALLET), []);
|
|
86
85
|
const { mutate: createEmbeddedWalletWithPasskeyMutation, isLoading, error, } = useMutation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
var _a;
|
|
87
87
|
const { embeddedWalletVerifiedCredentialId, jwt, decodedJwt, walletConnector, } = yield createEmbeddedWalletMutation({
|
|
88
88
|
authToken,
|
|
89
89
|
environmentId,
|
|
@@ -101,7 +101,12 @@ const PasskeyIntroView = ({ createEmbeddedWalletMutation = createEmbeddedWalletW
|
|
|
101
101
|
setPrimaryWalletId(embeddedWalletVerifiedCredentialId);
|
|
102
102
|
storeAuthToken(jwt);
|
|
103
103
|
setUser(createUserProfile(decodedJwt));
|
|
104
|
-
|
|
104
|
+
setShowAuthFlow(false);
|
|
105
|
+
const turnkeyVerifiedCredentials = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === 'turnkey');
|
|
106
|
+
setCallback('embeddedWalletCreated', {
|
|
107
|
+
email: (turnkeyVerifiedCredentials === null || turnkeyVerifiedCredentials === void 0 ? void 0 : turnkeyVerifiedCredentials.email) || '',
|
|
108
|
+
verifiedCredential: turnkeyVerifiedCredentials,
|
|
109
|
+
});
|
|
105
110
|
}), {
|
|
106
111
|
onFailure: (err) => {
|
|
107
112
|
logger.error('Failed to create embedded wallet', err);
|
|
@@ -78,11 +78,12 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
78
78
|
const { data: balance } = usePromise.usePromise(() => walletConnector.getBalance(), {
|
|
79
79
|
deps: [walletConnector],
|
|
80
80
|
});
|
|
81
|
-
const { data: provider } = usePromise.usePromise(() => primaryWallet.connector.
|
|
81
|
+
const { data: provider } = usePromise.usePromise(() => primaryWallet.connector.getPublicClient());
|
|
82
82
|
const evmNetworks = (walletConnector && walletConnector.evmNetworks) || [];
|
|
83
83
|
const evmNetwork = evmNetworks.find((evmNetwork) => evmNetwork.chainId === network);
|
|
84
84
|
const networkIcon = evmNetwork && (jsxRuntime.jsx("img", { src: evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.iconUrls[0], alt: `${evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name} icon` }));
|
|
85
85
|
const networkName = (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.vanityName) || (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name);
|
|
86
|
+
const networkCurrencyDecimals = evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.nativeCurrency.decimals;
|
|
86
87
|
const ChainIconComponent = getChainIcon.getChainIcon(primaryWallet.chain);
|
|
87
88
|
const chainInfo = walletConnectorCore.getChainInfo(primaryWallet.chain);
|
|
88
89
|
const chainIcon = (jsxRuntime.jsx(Icon.Icon, { size: 'small', children: jsxRuntime.jsx(ChainIconComponent, {}) }));
|
|
@@ -90,7 +91,7 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
90
91
|
const buildFormStage = () => (jsxRuntime.jsx(SendBalancePageLayout.SendBalancePageLayout, { initialValues: {
|
|
91
92
|
amount: value === null ? '' : formatBigNumber.formatBigNumber(value),
|
|
92
93
|
recipient: recipientAddress,
|
|
93
|
-
}, balance: balance, onClickBack: onClickBack, chain: primaryWallet.chain, networkName: networkName, networkIcon: networkIcon, currencySymbol: currencySymbol, isLoading: false, walletAddress: shortenWalletAddress.shortenWalletAddress(primaryWallet.address, 3, 3), walletKey: primaryWallet.connector.key, onClickClose: onClickClose, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSubmit: (data) => {
|
|
94
|
+
}, balance: balance, onClickBack: onClickBack, chain: primaryWallet.chain, networkName: networkName, networkIcon: networkIcon, networkCurrencyDecimals: networkCurrencyDecimals, currencySymbol: currencySymbol, isLoading: false, walletAddress: shortenWalletAddress.shortenWalletAddress(primaryWallet.address, 3, 3), walletKey: primaryWallet.connector.key, onClickClose: onClickClose, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSubmit: (data) => {
|
|
94
95
|
setValue(viem.parseEther(data.amount, 'wei'));
|
|
95
96
|
setRecipientAddress(data.recipient);
|
|
96
97
|
setStage('confirmation');
|
|
@@ -74,11 +74,12 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
74
74
|
const { data: balance } = usePromise(() => walletConnector.getBalance(), {
|
|
75
75
|
deps: [walletConnector],
|
|
76
76
|
});
|
|
77
|
-
const { data: provider } = usePromise(() => primaryWallet.connector.
|
|
77
|
+
const { data: provider } = usePromise(() => primaryWallet.connector.getPublicClient());
|
|
78
78
|
const evmNetworks = (walletConnector && walletConnector.evmNetworks) || [];
|
|
79
79
|
const evmNetwork = evmNetworks.find((evmNetwork) => evmNetwork.chainId === network);
|
|
80
80
|
const networkIcon = evmNetwork && (jsx("img", { src: evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.iconUrls[0], alt: `${evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name} icon` }));
|
|
81
81
|
const networkName = (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.vanityName) || (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name);
|
|
82
|
+
const networkCurrencyDecimals = evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.nativeCurrency.decimals;
|
|
82
83
|
const ChainIconComponent = getChainIcon(primaryWallet.chain);
|
|
83
84
|
const chainInfo = getChainInfo(primaryWallet.chain);
|
|
84
85
|
const chainIcon = (jsx(Icon, { size: 'small', children: jsx(ChainIconComponent, {}) }));
|
|
@@ -86,7 +87,7 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
86
87
|
const buildFormStage = () => (jsx(SendBalancePageLayout, { initialValues: {
|
|
87
88
|
amount: value === null ? '' : formatBigNumber(value),
|
|
88
89
|
recipient: recipientAddress,
|
|
89
|
-
}, balance: balance, onClickBack: onClickBack, chain: primaryWallet.chain, networkName: networkName, networkIcon: networkIcon, currencySymbol: currencySymbol, isLoading: false, walletAddress: shortenWalletAddress(primaryWallet.address, 3, 3), walletKey: primaryWallet.connector.key, onClickClose: onClickClose, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSubmit: (data) => {
|
|
90
|
+
}, balance: balance, onClickBack: onClickBack, chain: primaryWallet.chain, networkName: networkName, networkIcon: networkIcon, networkCurrencyDecimals: networkCurrencyDecimals, currencySymbol: currencySymbol, isLoading: false, walletAddress: shortenWalletAddress(primaryWallet.address, 3, 3), walletKey: primaryWallet.connector.key, onClickClose: onClickClose, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSubmit: (data) => {
|
|
90
91
|
setValue(parseEther(data.amount, 'wei'));
|
|
91
92
|
setRecipientAddress(data.recipient);
|
|
92
93
|
setStage('confirmation');
|
|
@@ -18,15 +18,23 @@ require('../../../shared/consts/index.cjs');
|
|
|
18
18
|
|
|
19
19
|
const errorCodesMapping = {
|
|
20
20
|
'-32603': 'Could not replace existing transaction',
|
|
21
|
+
0: 'The operation either timed out or was not allowed.',
|
|
22
|
+
16: 'Invalid Passkey signature. Select the passkey for this account and device.',
|
|
21
23
|
INSUFFICIENT_FUNDS: 'Insufficient funds for this transaction.',
|
|
22
24
|
};
|
|
23
25
|
const errorReasonsMapping = {
|
|
24
26
|
'provided ENS name resolves to null': 'Invalid address. Please check that the entered address is correct.',
|
|
25
27
|
};
|
|
26
28
|
const transactionErrorMessage = (error) => {
|
|
29
|
+
var _a;
|
|
27
30
|
logger.logger.debug('transaction error]:', error);
|
|
28
31
|
const { code } = error;
|
|
29
32
|
const defaultMessage = 'Something went wrong.';
|
|
33
|
+
// turnkey request errors
|
|
34
|
+
if (((_a = error === null || error === void 0 ? void 0 : error.cause) === null || _a === void 0 ? void 0 : _a.code) !== undefined &&
|
|
35
|
+
errorCodesMapping[error.cause.code] !== undefined) {
|
|
36
|
+
return errorCodesMapping[error.cause.code];
|
|
37
|
+
}
|
|
30
38
|
if (!code)
|
|
31
39
|
return defaultMessage;
|
|
32
40
|
return (errorCodesMapping[code] ||
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
type TransactionError = Error & {
|
|
2
2
|
code?: string;
|
|
3
3
|
reason?: string;
|
|
4
|
-
|
|
4
|
+
cause?: {
|
|
5
|
+
code: number;
|
|
6
|
+
name: string;
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const transactionErrorMessage: (error: TransactionError) => string;
|
|
11
|
+
export {};
|
|
@@ -14,15 +14,23 @@ import '../../../shared/consts/index.js';
|
|
|
14
14
|
|
|
15
15
|
const errorCodesMapping = {
|
|
16
16
|
'-32603': 'Could not replace existing transaction',
|
|
17
|
+
0: 'The operation either timed out or was not allowed.',
|
|
18
|
+
16: 'Invalid Passkey signature. Select the passkey for this account and device.',
|
|
17
19
|
INSUFFICIENT_FUNDS: 'Insufficient funds for this transaction.',
|
|
18
20
|
};
|
|
19
21
|
const errorReasonsMapping = {
|
|
20
22
|
'provided ENS name resolves to null': 'Invalid address. Please check that the entered address is correct.',
|
|
21
23
|
};
|
|
22
24
|
const transactionErrorMessage = (error) => {
|
|
25
|
+
var _a;
|
|
23
26
|
logger.debug('transaction error]:', error);
|
|
24
27
|
const { code } = error;
|
|
25
28
|
const defaultMessage = 'Something went wrong.';
|
|
29
|
+
// turnkey request errors
|
|
30
|
+
if (((_a = error === null || error === void 0 ? void 0 : error.cause) === null || _a === void 0 ? void 0 : _a.code) !== undefined &&
|
|
31
|
+
errorCodesMapping[error.cause.code] !== undefined) {
|
|
32
|
+
return errorCodesMapping[error.cause.code];
|
|
33
|
+
}
|
|
26
34
|
if (!code)
|
|
27
35
|
return defaultMessage;
|
|
28
36
|
return (errorCodesMapping[code] ||
|
|
@@ -32,7 +32,6 @@ var MergeUserAccountsView = require('./MergeUserAccountsView/MergeUserAccountsVi
|
|
|
32
32
|
var WalletCannotBeTransferredView = require('./WalletCannotBeTransferredView/WalletCannotBeTransferredView.cjs');
|
|
33
33
|
var LoginView = require('./LoginView/LoginView.cjs');
|
|
34
34
|
var PasskeyIntroView = require('./PasskeyIntroView/PasskeyIntroView.cjs');
|
|
35
|
-
var PasskeySuccessView = require('./PasskeySuccessView/PasskeySuccessView.cjs');
|
|
36
35
|
|
|
37
36
|
const viewToComponentMap = {
|
|
38
37
|
'account-exists': jsxRuntime.jsx(AccountExistsView.AccountExistsView, {}),
|
|
@@ -56,7 +55,6 @@ const viewToComponentMap = {
|
|
|
56
55
|
'no-access': jsxRuntime.jsx(NoAccess.NoAccess, {}),
|
|
57
56
|
'no-qr-not-installed': jsxRuntime.jsx(NoQrNotInstalledView.NoQrNotInstalledView, {}),
|
|
58
57
|
'passkey-intro': jsxRuntime.jsx(PasskeyIntroView.PasskeyIntroView, {}),
|
|
59
|
-
'passkey-success': jsxRuntime.jsx(PasskeySuccessView.PasskeySuccessView, {}),
|
|
60
58
|
'pending-connect': jsxRuntime.jsx(PendingConnectView.PendingConnectView, {}),
|
|
61
59
|
'pending-signature': jsxRuntime.jsx(PendingSignatureView.PendingSignatureView, {}),
|
|
62
60
|
'pending-signature-without-back-button': jsxRuntime.jsx(PendingSignatureView.PendingSignatureView, {}),
|
|
@@ -28,7 +28,6 @@ import { MergeUserAccountsView } from './MergeUserAccountsView/MergeUserAccounts
|
|
|
28
28
|
import { WalletCannotBeTransferredView } from './WalletCannotBeTransferredView/WalletCannotBeTransferredView.js';
|
|
29
29
|
import { LoginView } from './LoginView/LoginView.js';
|
|
30
30
|
import { PasskeyIntroView } from './PasskeyIntroView/PasskeyIntroView.js';
|
|
31
|
-
import { PasskeySuccessView } from './PasskeySuccessView/PasskeySuccessView.js';
|
|
32
31
|
|
|
33
32
|
const viewToComponentMap = {
|
|
34
33
|
'account-exists': jsx(AccountExistsView, {}),
|
|
@@ -52,7 +51,6 @@ const viewToComponentMap = {
|
|
|
52
51
|
'no-access': jsx(NoAccess, {}),
|
|
53
52
|
'no-qr-not-installed': jsx(NoQrNotInstalledView, {}),
|
|
54
53
|
'passkey-intro': jsx(PasskeyIntroView, {}),
|
|
55
|
-
'passkey-success': jsx(PasskeySuccessView, {}),
|
|
56
54
|
'pending-connect': jsx(PendingConnectView, {}),
|
|
57
55
|
'pending-signature': jsx(PendingSignatureView, {}),
|
|
58
56
|
'pending-signature-without-back-button': jsx(PendingSignatureView, {}),
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var reactI18next = require('react-i18next');
|
|
7
|
-
require('react');
|
|
8
|
-
var Typography = require('../../components/Typography/Typography.cjs');
|
|
9
|
-
require('@dynamic-labs/sdk-api');
|
|
10
|
-
require('../../shared/logger.cjs');
|
|
11
|
-
require('@dynamic-labs/iconic');
|
|
12
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
13
|
-
require('../../context/ViewContext/ViewContext.cjs');
|
|
14
|
-
var close = require('../../shared/assets/close.cjs');
|
|
15
|
-
var passkeySuccessIcon = require('../../shared/assets/passkey-success-icon.cjs');
|
|
16
|
-
require('@dynamic-labs/wallet-book');
|
|
17
|
-
require('@dynamic-labs/utils');
|
|
18
|
-
require('../../utils/constants/colors.cjs');
|
|
19
|
-
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
20
|
-
require('viem');
|
|
21
|
-
require('../../shared/consts/index.cjs');
|
|
22
|
-
var useInternalDynamicContext = require('../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
23
|
-
require('@dynamic-labs/multi-wallet');
|
|
24
|
-
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
25
|
-
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
26
|
-
require('react-dom');
|
|
27
|
-
require('react-focus-lock');
|
|
28
|
-
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
29
|
-
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
30
|
-
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
31
|
-
require('../../config/ApiEndpoint.cjs');
|
|
32
|
-
require('@dynamic-labs/rpc-providers');
|
|
33
|
-
require('../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
34
|
-
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
35
|
-
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
36
|
-
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
37
|
-
require('../../components/OverlayCard/OverlayCard.context.cjs');
|
|
38
|
-
require('../../context/FooterAnimationContext/index.cjs');
|
|
39
|
-
require('../../context/MockContext/MockContext.cjs');
|
|
40
|
-
require('../../context/QrCodeContext/QrCodeContext.cjs');
|
|
41
|
-
require('../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
42
|
-
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
43
|
-
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
44
|
-
require('../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
45
|
-
require('qrcode');
|
|
46
|
-
require('../../context/LoadingContext/LoadingContext.cjs');
|
|
47
|
-
require('../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
48
|
-
require('../CollectUserDataView/fieldsConfig.cjs');
|
|
49
|
-
require('../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.cjs');
|
|
50
|
-
require('@dynamic-labs/types');
|
|
51
|
-
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
52
|
-
require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
53
|
-
require('formik');
|
|
54
|
-
require('yup');
|
|
55
|
-
var Button = require('../../components/Button/Button.cjs');
|
|
56
|
-
var ModalHeader = require('../../components/ModalHeader/ModalHeader.cjs');
|
|
57
|
-
var IconButton = require('../../components/IconButton/IconButton.cjs');
|
|
58
|
-
require('../../components/Alert/Alert.cjs');
|
|
59
|
-
require('../../components/Popper/Popper/Popper.cjs');
|
|
60
|
-
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
61
|
-
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
62
|
-
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
63
|
-
|
|
64
|
-
const PasskeySuccessView = () => {
|
|
65
|
-
const { setShowAuthFlow, appName } = useInternalDynamicContext.useInternalDynamicContext();
|
|
66
|
-
const { t } = reactI18next.useTranslation();
|
|
67
|
-
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', "data-testid": 'close-button', onClick: () => setShowAuthFlow(false), children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
68
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, alignContent: 'bottom', children: jsxRuntime.jsx("div", { className: 'passkey-success-view__header', children: jsxRuntime.jsx(passkeySuccessIcon.ReactComponent, {}) }) }), jsxRuntime.jsxs("div", { className: 'passkey-success-view', children: [jsxRuntime.jsxs("div", { className: 'passkey-success-view__content', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', className: 'passkey-success-view__title', children: t('dyn_passkey_success.title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-success-view__subtitle', children: t('dyn_passkey_success.subtitle', { appName }) })] }), jsxRuntime.jsx("div", { className: 'passkey-success-view__actions', children: jsxRuntime.jsx(Button.Button, { buttonPadding: 'large', buttonRounded: 'default', onClick: () => setShowAuthFlow(false), children: t('dyn_passkey_success.button') }) })] })] }));
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
exports.PasskeySuccessView = PasskeySuccessView;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import 'react';
|
|
4
|
-
import { Typography } from '../../components/Typography/Typography.js';
|
|
5
|
-
import '@dynamic-labs/sdk-api';
|
|
6
|
-
import '../../shared/logger.js';
|
|
7
|
-
import '@dynamic-labs/iconic';
|
|
8
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
9
|
-
import '../../context/ViewContext/ViewContext.js';
|
|
10
|
-
import { ReactComponent as SvgClose } from '../../shared/assets/close.js';
|
|
11
|
-
import { ReactComponent as SvgPasskeySuccessIcon } from '../../shared/assets/passkey-success-icon.js';
|
|
12
|
-
import '@dynamic-labs/wallet-book';
|
|
13
|
-
import '@dynamic-labs/utils';
|
|
14
|
-
import '../../utils/constants/colors.js';
|
|
15
|
-
import '../../shared/utils/classes/storage/localStorage.js';
|
|
16
|
-
import 'viem';
|
|
17
|
-
import '../../shared/consts/index.js';
|
|
18
|
-
import { useInternalDynamicContext } from '../../context/DynamicContext/useInternalDynamicContext.js';
|
|
19
|
-
import '@dynamic-labs/multi-wallet';
|
|
20
|
-
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
21
|
-
import '../../context/ThemeContext/ThemeContext.js';
|
|
22
|
-
import 'react-dom';
|
|
23
|
-
import 'react-focus-lock';
|
|
24
|
-
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
25
|
-
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
26
|
-
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
27
|
-
import '../../config/ApiEndpoint.js';
|
|
28
|
-
import '@dynamic-labs/rpc-providers';
|
|
29
|
-
import '../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
30
|
-
import '../../context/ErrorContext/ErrorContext.js';
|
|
31
|
-
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
32
|
-
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
33
|
-
import '../../components/OverlayCard/OverlayCard.context.js';
|
|
34
|
-
import '../../context/FooterAnimationContext/index.js';
|
|
35
|
-
import '../../context/MockContext/MockContext.js';
|
|
36
|
-
import '../../context/QrCodeContext/QrCodeContext.js';
|
|
37
|
-
import '../../context/WalletGroupContext/WalletGroupContext.js';
|
|
38
|
-
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
39
|
-
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
40
|
-
import '../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
41
|
-
import 'qrcode';
|
|
42
|
-
import '../../context/LoadingContext/LoadingContext.js';
|
|
43
|
-
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
44
|
-
import '../CollectUserDataView/fieldsConfig.js';
|
|
45
|
-
import '../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.js';
|
|
46
|
-
import '@dynamic-labs/types';
|
|
47
|
-
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
48
|
-
import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
49
|
-
import 'formik';
|
|
50
|
-
import 'yup';
|
|
51
|
-
import { Button } from '../../components/Button/Button.js';
|
|
52
|
-
import { ModalHeader } from '../../components/ModalHeader/ModalHeader.js';
|
|
53
|
-
import { IconButton } from '../../components/IconButton/IconButton.js';
|
|
54
|
-
import '../../components/Alert/Alert.js';
|
|
55
|
-
import '../../components/Popper/Popper/Popper.js';
|
|
56
|
-
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
57
|
-
import '../../components/InlineWidget/InlineWidget.js';
|
|
58
|
-
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
59
|
-
|
|
60
|
-
const PasskeySuccessView = () => {
|
|
61
|
-
const { setShowAuthFlow, appName } = useInternalDynamicContext();
|
|
62
|
-
const { t } = useTranslation();
|
|
63
|
-
const closeButton = (jsx(IconButton, { type: 'button', "data-testid": 'close-button', onClick: () => setShowAuthFlow(false), children: jsx(SvgClose, {}) }));
|
|
64
|
-
return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: closeButton, alignContent: 'bottom', children: jsx("div", { className: 'passkey-success-view__header', children: jsx(SvgPasskeySuccessIcon, {}) }) }), jsxs("div", { className: 'passkey-success-view', children: [jsxs("div", { className: 'passkey-success-view__content', children: [jsx(Typography, { variant: 'title', color: 'primary', className: 'passkey-success-view__title', children: t('dyn_passkey_success.title') }), jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-success-view__subtitle', children: t('dyn_passkey_success.subtitle', { appName }) })] }), jsx("div", { className: 'passkey-success-view__actions', children: jsx(Button, { buttonPadding: 'large', buttonRounded: 'default', onClick: () => setShowAuthFlow(false), children: t('dyn_passkey_success.button') }) })] })] }));
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export { PasskeySuccessView };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { PasskeySuccessView } from './PasskeySuccessView';
|