@dynamic-labs/sdk-react-core 4.1.0 → 4.2.0
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 +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/index.d.ts +1 -0
- package/src/lib/components/OverlayCardBase/OverlayCardBase.cjs +3 -2
- package/src/lib/components/OverlayCardBase/OverlayCardBase.js +3 -2
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.d.ts +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/utils.d.ts +1 -1
- package/src/lib/components/Transition/SlideInUpTransition/SlideInUpTransition.cjs +4 -3
- package/src/lib/components/Transition/SlideInUpTransition/SlideInUpTransition.js +4 -3
- package/src/lib/components/Transition/transition.type.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +2 -0
- package/src/lib/events/dynamicEvents.cjs +1 -0
- package/src/lib/events/dynamicEvents.d.ts +2 -2
- package/src/lib/events/dynamicEvents.js +1 -0
- package/src/lib/events/index.d.ts +1 -0
- package/src/lib/events/wallets.d.ts +25 -0
- package/src/lib/utils/constants/transitions.cjs +12 -0
- package/src/lib/utils/constants/transitions.d.ts +2 -0
- package/src/lib/utils/constants/transitions.js +7 -0
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAggregateWalletEvents/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAggregateWalletEvents/useAggregateWalletEvents.cjs +57 -0
- package/src/lib/utils/hooks/useAggregateWalletEvents/useAggregateWalletEvents.d.ts +1 -0
- package/src/lib/utils/hooks/useAggregateWalletEvents/useAggregateWalletEvents.js +53 -0
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +3 -0
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +3 -0
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +3 -3
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +3 -3
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.js +2 -2
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs +10 -3
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.d.ts +6 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.2.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.1.0...v4.2.0) (2025-01-14)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add EthereumWalletConnectorsWithConfig ([#7796](https://github.com/dynamic-labs/dynamic-auth/issues/7796)) ([52146c3](https://github.com/dynamic-labs/dynamic-auth/commit/52146c38acbbe9ad31d5f047527b06ea44846065))
|
|
8
|
+
* add new userWalletsChanged event that aggregates all user wallet events ([#7797](https://github.com/dynamic-labs/dynamic-auth/issues/7797)) ([058e629](https://github.com/dynamic-labs/dynamic-auth/commit/058e629f0e760ad9dff2b03f86354355c6f8bffe))
|
|
9
|
+
* add support for connect with OKX Wallet on Eclipse ([#7793](https://github.com/dynamic-labs/dynamic-auth/issues/7793)) ([b6cd047](https://github.com/dynamic-labs/dynamic-auth/commit/b6cd04781402868443b02cbce269dd3c02c358b5))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* getWalletClient method not returning client with chain for Coinbase ([#7799](https://github.com/dynamic-labs/dynamic-auth/issues/7799)) ([e075493](https://github.com/dynamic-labs/dynamic-auth/commit/e0754936582c19850c905fc3d62c3621df7c274c))
|
|
15
|
+
|
|
2
16
|
## [4.1.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.1...v4.1.0) (2025-01-14)
|
|
3
17
|
|
|
4
18
|
|
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.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.586",
|
|
6
6
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
@@ -13,17 +13,17 @@
|
|
|
13
13
|
"react-i18next": "13.5.0",
|
|
14
14
|
"yup": "0.32.11",
|
|
15
15
|
"react-international-phone": "4.2.5",
|
|
16
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
17
|
-
"@dynamic-labs/ethereum-aa": "4.
|
|
18
|
-
"@dynamic-labs/iconic": "4.
|
|
19
|
-
"@dynamic-labs/logger": "4.
|
|
20
|
-
"@dynamic-labs/multi-wallet": "4.
|
|
21
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
22
|
-
"@dynamic-labs/store": "4.
|
|
23
|
-
"@dynamic-labs/types": "4.
|
|
24
|
-
"@dynamic-labs/utils": "4.
|
|
25
|
-
"@dynamic-labs/wallet-book": "4.
|
|
26
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
16
|
+
"@dynamic-labs/assert-package-version": "4.2.0",
|
|
17
|
+
"@dynamic-labs/ethereum-aa": "4.2.0",
|
|
18
|
+
"@dynamic-labs/iconic": "4.2.0",
|
|
19
|
+
"@dynamic-labs/logger": "4.2.0",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "4.2.0",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "4.2.0",
|
|
22
|
+
"@dynamic-labs/store": "4.2.0",
|
|
23
|
+
"@dynamic-labs/types": "4.2.0",
|
|
24
|
+
"@dynamic-labs/utils": "4.2.0",
|
|
25
|
+
"@dynamic-labs/wallet-book": "4.2.0",
|
|
26
|
+
"@dynamic-labs/wallet-connector-core": "4.2.0",
|
|
27
27
|
"bs58": "5.0.0",
|
|
28
28
|
"eventemitter3": "5.0.1"
|
|
29
29
|
},
|
package/src/index.d.ts
CHANGED
|
@@ -100,6 +100,7 @@ AuthOptions as AuthOption, AuthOptions,
|
|
|
100
100
|
/** @deprecated use AuthMethod instead */
|
|
101
101
|
AuthMethod as AuthType, AuthMethod, } from '@dynamic-labs/types';
|
|
102
102
|
export { publicDynamicEvents as dynamicEvents } from './lib/events/dynamicEvents';
|
|
103
|
+
export { type UserWalletsChangedParams } from './lib/events';
|
|
103
104
|
export { mergeNetworks } from './lib/utils/functions/mergeNetworks';
|
|
104
105
|
export {
|
|
105
106
|
/** @deprecated use https://www.npmjs.com/package/classnames */
|
|
@@ -20,6 +20,7 @@ var index = require('../../shared/utils/hooks/useOnClickOutside/index.cjs');
|
|
|
20
20
|
var usePreventPageScroll = require('../../shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.cjs');
|
|
21
21
|
require('../../shared/consts/index.cjs');
|
|
22
22
|
var classNames = require('../../utils/functions/classNames/classNames.cjs');
|
|
23
|
+
var transitions = require('../../utils/constants/transitions.cjs');
|
|
23
24
|
var AnimatePresence = require('../AnimatePresence/AnimatePresence.cjs');
|
|
24
25
|
var ShadowDOM = require('../ShadowDOM/ShadowDOM.cjs');
|
|
25
26
|
require('../Transition/ZoomTransition/ZoomTransition.cjs');
|
|
@@ -97,8 +98,8 @@ const OverlayCardBase = ({ isOpen, children, onClickOverlay, style, className, }
|
|
|
97
98
|
usePreventPageScroll.usePreventPageScroll(isOpen && !target);
|
|
98
99
|
const contentRef = React.useRef(null);
|
|
99
100
|
index.useOnClickOutside(contentRef, () => onClickOverlay === null || onClickOverlay === void 0 ? void 0 : onClickOverlay());
|
|
100
|
-
const opacityTransition = (jsxRuntime.jsx(OpacityTransition.OpacityTransition, { className: 'overlay-card-base__animation' }));
|
|
101
|
-
const slideTransition = (jsxRuntime.jsx(SlideInUpTransition.SlideInUpTransition, { className: 'overlay-card-base__animation' }));
|
|
101
|
+
const opacityTransition = (jsxRuntime.jsx(OpacityTransition.OpacityTransition, { className: 'overlay-card-base__animation', duration: transitions.DURATION_DEFAULT }));
|
|
102
|
+
const slideTransition = (jsxRuntime.jsx(SlideInUpTransition.SlideInUpTransition, { className: 'overlay-card-base__animation', duration: transitions.DURATION_DEFAULT }));
|
|
102
103
|
const content = (jsxRuntime.jsx("div", { className: classNames.classNames('overlay-card-base', {
|
|
103
104
|
'overlay-card-base--disabled': !isOpen,
|
|
104
105
|
}), style: { position: target === undefined ? 'fixed' : 'absolute' }, children: isOpen && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(AnimatePresence.AnimatePresence, { animationComponent: opacityTransition, children: jsxRuntime.jsx("div", { onClick: onClickOverlay, className: 'overlay-card-base__overlay' }) }), jsxRuntime.jsx("div", { className: 'overlay-card-base__content-wrapper', children: jsxRuntime.jsx(AnimatePresence.AnimatePresence, { animationComponent: slideTransition, children: jsxRuntime.jsx("div", { ref: contentRef, className: classNames.classNames('overlay-card-base__content', className), style: style, children: children }) }) })] })) }));
|
|
@@ -16,6 +16,7 @@ import { useOnClickOutside } from '../../shared/utils/hooks/useOnClickOutside/in
|
|
|
16
16
|
import { usePreventPageScroll } from '../../shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.js';
|
|
17
17
|
import '../../shared/consts/index.js';
|
|
18
18
|
import { classNames } from '../../utils/functions/classNames/classNames.js';
|
|
19
|
+
import { DURATION_DEFAULT } from '../../utils/constants/transitions.js';
|
|
19
20
|
import { AnimatePresence } from '../AnimatePresence/AnimatePresence.js';
|
|
20
21
|
import { ShadowDOM } from '../ShadowDOM/ShadowDOM.js';
|
|
21
22
|
import '../Transition/ZoomTransition/ZoomTransition.js';
|
|
@@ -93,8 +94,8 @@ const OverlayCardBase = ({ isOpen, children, onClickOverlay, style, className, }
|
|
|
93
94
|
usePreventPageScroll(isOpen && !target);
|
|
94
95
|
const contentRef = useRef(null);
|
|
95
96
|
useOnClickOutside(contentRef, () => onClickOverlay === null || onClickOverlay === void 0 ? void 0 : onClickOverlay());
|
|
96
|
-
const opacityTransition = (jsx(OpacityTransition, { className: 'overlay-card-base__animation' }));
|
|
97
|
-
const slideTransition = (jsx(SlideInUpTransition, { className: 'overlay-card-base__animation' }));
|
|
97
|
+
const opacityTransition = (jsx(OpacityTransition, { className: 'overlay-card-base__animation', duration: DURATION_DEFAULT }));
|
|
98
|
+
const slideTransition = (jsx(SlideInUpTransition, { className: 'overlay-card-base__animation', duration: DURATION_DEFAULT }));
|
|
98
99
|
const content = (jsx("div", { className: classNames('overlay-card-base', {
|
|
99
100
|
'overlay-card-base--disabled': !isOpen,
|
|
100
101
|
}), style: { position: target === undefined ? 'fixed' : 'absolute' }, children: isOpen && (jsxs(Fragment, { children: [jsx(AnimatePresence, { animationComponent: opacityTransition, children: jsx("div", { onClick: onClickOverlay, className: 'overlay-card-base__overlay' }) }), jsx("div", { className: 'overlay-card-base__content-wrapper', children: jsx(AnimatePresence, { animationComponent: slideTransition, children: jsx("div", { ref: contentRef, className: classNames('overlay-card-base__content', className), style: style, children: children }) }) })] })) }));
|
|
@@ -4,13 +4,13 @@ import { IUITransaction } from '@dynamic-labs/types';
|
|
|
4
4
|
export declare const SendBalanceTransactionCard: ({ transaction, currentToken, currencySymbol, valueRounded, transactionValue, isGasSponsored, gasFiatValue, totalGasFiatValue, currency, total, t, walletKey, }: {
|
|
5
5
|
transaction: IUITransaction;
|
|
6
6
|
currentToken: TokenBalance | undefined;
|
|
7
|
-
currencySymbol: string;
|
|
7
|
+
currencySymbol: string | undefined;
|
|
8
8
|
valueRounded?: string;
|
|
9
9
|
transactionValue: string | undefined;
|
|
10
10
|
isGasSponsored: boolean;
|
|
11
11
|
gasFiatValue: string;
|
|
12
12
|
totalGasFiatValue: string;
|
|
13
|
-
currency: string;
|
|
13
|
+
currency: string | undefined;
|
|
14
14
|
total: bigint | undefined;
|
|
15
15
|
t: any;
|
|
16
16
|
walletKey: string;
|
package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs
CHANGED
|
@@ -115,7 +115,7 @@ const TransactionConfirmationPageLayout = ({ onClickClose, isLoading, onClickBac
|
|
|
115
115
|
const { userNeedsCrossDomainPasskey } = PasskeyContext.usePasskeyContext();
|
|
116
116
|
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery.usePasskeyRecovery();
|
|
117
117
|
const { currency } = useFetchCurrency.useFetchCurrency(walletConnector);
|
|
118
|
-
const currencySymbol = utils.useCurrencySymbol(currentToken, currency);
|
|
118
|
+
const currencySymbol = utils.useCurrencySymbol(currentToken, currency === null || currency === void 0 ? void 0 : currency.symbol);
|
|
119
119
|
const { nativePrice } = sendBalances.useSendBalanceState();
|
|
120
120
|
utils.useHandleRecovery(walletConnector, usingSessionKeys.usingSessionKey, onSuccess, shouldInitRecovery, initPasskeyRecoveryProcess, hideModal);
|
|
121
121
|
const handleSubmitWithChecks = utils.useHandleSubmitWithChecks({
|
|
@@ -129,7 +129,7 @@ const TransactionConfirmationPageLayout = ({ onClickClose, isLoading, onClickBac
|
|
|
129
129
|
const backButton = onClickBack && (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: onClickBack, "data-testid": 'back-button', children: jsxRuntime.jsx(arrowLeft.ReactComponent, {}) }));
|
|
130
130
|
const gasFiatValue = fiatUtils.getGasFiatValue(currentToken, transaction, nativePrice);
|
|
131
131
|
const totalGasFiatValue = fiatUtils.getTotalFiatCost(currentToken, transaction, nativePrice, transactionValue);
|
|
132
|
-
return hideModal ? null : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, leading: backButton, alignContent: 'bottom', children: jsxRuntime.jsx("div", { className: 'send-balance-page-layout__header-content', children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_send_transaction.data.confirmation_tx', children: t('dyn_send_transaction.data.confirmation_tx') }) }) }), jsxRuntime.jsx("div", { className: 'transaction-confirmation__banner', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_send_transaction.data.banner', children: t('dyn_send_transaction.data.banner') }) }), jsxRuntime.jsx(PasskeyCreatedSuccessBanner.PasskeyCreatedSuccessBanner, {}), jsxRuntime.jsxs("div", { className: 'transaction-confirmation__body', children: [jsxRuntime.jsxs("div", { className: 'transaction-confirmation__content', children: [!sendBalanceTransaction ? (jsxRuntime.jsx(TransactionCard.TransactionCard, { transaction: transaction, isGasSponsored: isGasSponsored, isAATransaction: walletConnector ? ethereumAa.isZeroDevConnector(walletConnector) : false, simulationResult: simulationResult, recipient: recipient })) : (jsxRuntime.jsx(SendBalanceTransactionCard.SendBalanceTransactionCard, { transaction: transaction, currentToken: currentToken, currencySymbol: currencySymbol, valueRounded: (_a = utils.getValueRounded(Boolean(isNativeToken), transaction)) === null || _a === void 0 ? void 0 : _a.toString(), transactionValue: transactionValue, isGasSponsored: isGasSponsored, gasFiatValue: gasFiatValue || '0', totalGasFiatValue: totalGasFiatValue || '0', currency: currency, total: total, t: t, walletKey: walletKey })), children && (jsxRuntime.jsx("div", { className: 'transaction-confirmation__rows', children: children }))] }), jsxRuntime.jsx(AnimatePresence.AnimatePresence, { animationComponent: jsxRuntime.jsx(VerticalDrawerTransition.VerticalDrawerTransition, {}), children: alert && (jsxRuntime.jsx("div", { className: 'transaction-confirmation__warning', children: alert })) }), jsxRuntime.jsxs("div", { className: 'transaction-confirmation__actions', children: [(onClickBack || onClickClose) && (jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'primary', buttonPadding: 'small', onClick: onClickBack || onClickClose, expanded: true, disabled: isLoading, copykey: 'dyn_send_transaction.confirmation.cancel_button', children: t('dyn_send_transaction.confirmation.cancel_button') })), jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'brand-primary', buttonPadding: 'small', onClick: handleSubmitWithChecks, expanded: true, loading: isLoading, disabled: disableSendButton, copykey: 'dyn_send_transaction.confirmation.send', startSlot:
|
|
132
|
+
return hideModal ? null : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, leading: backButton, alignContent: 'bottom', children: jsxRuntime.jsx("div", { className: 'send-balance-page-layout__header-content', children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_send_transaction.data.confirmation_tx', children: t('dyn_send_transaction.data.confirmation_tx') }) }) }), jsxRuntime.jsx("div", { className: 'transaction-confirmation__banner', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_send_transaction.data.banner', children: t('dyn_send_transaction.data.banner') }) }), jsxRuntime.jsx(PasskeyCreatedSuccessBanner.PasskeyCreatedSuccessBanner, {}), jsxRuntime.jsxs("div", { className: 'transaction-confirmation__body', children: [jsxRuntime.jsxs("div", { className: 'transaction-confirmation__content', children: [!sendBalanceTransaction ? (jsxRuntime.jsx(TransactionCard.TransactionCard, { transaction: transaction, isGasSponsored: isGasSponsored, isAATransaction: walletConnector ? ethereumAa.isZeroDevConnector(walletConnector) : false, simulationResult: simulationResult, recipient: recipient })) : (jsxRuntime.jsx(SendBalanceTransactionCard.SendBalanceTransactionCard, { transaction: transaction, currentToken: currentToken, currencySymbol: currencySymbol, valueRounded: (_a = utils.getValueRounded(Boolean(isNativeToken), transaction)) === null || _a === void 0 ? void 0 : _a.toString(), transactionValue: transactionValue, isGasSponsored: isGasSponsored, gasFiatValue: gasFiatValue || '0', totalGasFiatValue: totalGasFiatValue || '0', currency: currency === null || currency === void 0 ? void 0 : currency.symbol, total: total, t: t, walletKey: walletKey })), children && (jsxRuntime.jsx("div", { className: 'transaction-confirmation__rows', children: children }))] }), jsxRuntime.jsx(AnimatePresence.AnimatePresence, { animationComponent: jsxRuntime.jsx(VerticalDrawerTransition.VerticalDrawerTransition, {}), children: alert && (jsxRuntime.jsx("div", { className: 'transaction-confirmation__warning', children: alert })) }), jsxRuntime.jsxs("div", { className: 'transaction-confirmation__actions', children: [(onClickBack || onClickClose) && (jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'primary', buttonPadding: 'small', onClick: onClickBack || onClickClose, expanded: true, disabled: isLoading, copykey: 'dyn_send_transaction.confirmation.cancel_button', children: t('dyn_send_transaction.confirmation.cancel_button') })), jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'brand-primary', buttonPadding: 'small', onClick: handleSubmitWithChecks, expanded: true, loading: isLoading, disabled: disableSendButton, copykey: 'dyn_send_transaction.confirmation.send', startSlot:
|
|
133
133
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
134
134
|
jsxRuntime.jsx(Icon.Icon, { size: 'small', color: 'text-secondary', children: jsxRuntime.jsx(send.ReactComponent, {}) }), dataTestId: 'transaction-confirmation-send', children: t('dyn_send_transaction.confirmation.send') })] }), displayPoweredByDynamicFooter && (jsxRuntime.jsx(PoweredByDynamic.PoweredByDynamic, { classNameRoot: 'transaction-confirmation__footer' }))] })] }));
|
|
135
135
|
};
|
package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js
CHANGED
|
@@ -111,7 +111,7 @@ const TransactionConfirmationPageLayout = ({ onClickClose, isLoading, onClickBac
|
|
|
111
111
|
const { userNeedsCrossDomainPasskey } = usePasskeyContext();
|
|
112
112
|
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery();
|
|
113
113
|
const { currency } = useFetchCurrency(walletConnector);
|
|
114
|
-
const currencySymbol = useCurrencySymbol(currentToken, currency);
|
|
114
|
+
const currencySymbol = useCurrencySymbol(currentToken, currency === null || currency === void 0 ? void 0 : currency.symbol);
|
|
115
115
|
const { nativePrice } = useSendBalanceState();
|
|
116
116
|
useHandleRecovery(walletConnector, usingSessionKey, onSuccess, shouldInitRecovery, initPasskeyRecoveryProcess, hideModal);
|
|
117
117
|
const handleSubmitWithChecks = useHandleSubmitWithChecks({
|
|
@@ -125,7 +125,7 @@ const TransactionConfirmationPageLayout = ({ onClickClose, isLoading, onClickBac
|
|
|
125
125
|
const backButton = onClickBack && (jsx(IconButton, { type: 'button', onClick: onClickBack, "data-testid": 'back-button', children: jsx(SvgArrowLeft, {}) }));
|
|
126
126
|
const gasFiatValue = getGasFiatValue(currentToken, transaction, nativePrice);
|
|
127
127
|
const totalGasFiatValue = getTotalFiatCost(currentToken, transaction, nativePrice, transactionValue);
|
|
128
|
-
return hideModal ? null : (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: closeButton, leading: backButton, alignContent: 'bottom', children: jsx("div", { className: 'send-balance-page-layout__header-content', children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_send_transaction.data.confirmation_tx', children: t('dyn_send_transaction.data.confirmation_tx') }) }) }), jsx("div", { className: 'transaction-confirmation__banner', children: jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_send_transaction.data.banner', children: t('dyn_send_transaction.data.banner') }) }), jsx(PasskeyCreatedSuccessBanner, {}), jsxs("div", { className: 'transaction-confirmation__body', children: [jsxs("div", { className: 'transaction-confirmation__content', children: [!sendBalanceTransaction ? (jsx(TransactionCard, { transaction: transaction, isGasSponsored: isGasSponsored, isAATransaction: walletConnector ? isZeroDevConnector(walletConnector) : false, simulationResult: simulationResult, recipient: recipient })) : (jsx(SendBalanceTransactionCard, { transaction: transaction, currentToken: currentToken, currencySymbol: currencySymbol, valueRounded: (_a = getValueRounded(Boolean(isNativeToken), transaction)) === null || _a === void 0 ? void 0 : _a.toString(), transactionValue: transactionValue, isGasSponsored: isGasSponsored, gasFiatValue: gasFiatValue || '0', totalGasFiatValue: totalGasFiatValue || '0', currency: currency, total: total, t: t, walletKey: walletKey })), children && (jsx("div", { className: 'transaction-confirmation__rows', children: children }))] }), jsx(AnimatePresence, { animationComponent: jsx(VerticalDrawerTransition, {}), children: alert && (jsx("div", { className: 'transaction-confirmation__warning', children: alert })) }), jsxs("div", { className: 'transaction-confirmation__actions', children: [(onClickBack || onClickClose) && (jsx(TypographyButton, { buttonVariant: 'primary', buttonPadding: 'small', onClick: onClickBack || onClickClose, expanded: true, disabled: isLoading, copykey: 'dyn_send_transaction.confirmation.cancel_button', children: t('dyn_send_transaction.confirmation.cancel_button') })), jsx(TypographyButton, { buttonVariant: 'brand-primary', buttonPadding: 'small', onClick: handleSubmitWithChecks, expanded: true, loading: isLoading, disabled: disableSendButton, copykey: 'dyn_send_transaction.confirmation.send', startSlot:
|
|
128
|
+
return hideModal ? null : (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: closeButton, leading: backButton, alignContent: 'bottom', children: jsx("div", { className: 'send-balance-page-layout__header-content', children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_send_transaction.data.confirmation_tx', children: t('dyn_send_transaction.data.confirmation_tx') }) }) }), jsx("div", { className: 'transaction-confirmation__banner', children: jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_send_transaction.data.banner', children: t('dyn_send_transaction.data.banner') }) }), jsx(PasskeyCreatedSuccessBanner, {}), jsxs("div", { className: 'transaction-confirmation__body', children: [jsxs("div", { className: 'transaction-confirmation__content', children: [!sendBalanceTransaction ? (jsx(TransactionCard, { transaction: transaction, isGasSponsored: isGasSponsored, isAATransaction: walletConnector ? isZeroDevConnector(walletConnector) : false, simulationResult: simulationResult, recipient: recipient })) : (jsx(SendBalanceTransactionCard, { transaction: transaction, currentToken: currentToken, currencySymbol: currencySymbol, valueRounded: (_a = getValueRounded(Boolean(isNativeToken), transaction)) === null || _a === void 0 ? void 0 : _a.toString(), transactionValue: transactionValue, isGasSponsored: isGasSponsored, gasFiatValue: gasFiatValue || '0', totalGasFiatValue: totalGasFiatValue || '0', currency: currency === null || currency === void 0 ? void 0 : currency.symbol, total: total, t: t, walletKey: walletKey })), children && (jsx("div", { className: 'transaction-confirmation__rows', children: children }))] }), jsx(AnimatePresence, { animationComponent: jsx(VerticalDrawerTransition, {}), children: alert && (jsx("div", { className: 'transaction-confirmation__warning', children: alert })) }), jsxs("div", { className: 'transaction-confirmation__actions', children: [(onClickBack || onClickClose) && (jsx(TypographyButton, { buttonVariant: 'primary', buttonPadding: 'small', onClick: onClickBack || onClickClose, expanded: true, disabled: isLoading, copykey: 'dyn_send_transaction.confirmation.cancel_button', children: t('dyn_send_transaction.confirmation.cancel_button') })), jsx(TypographyButton, { buttonVariant: 'brand-primary', buttonPadding: 'small', onClick: handleSubmitWithChecks, expanded: true, loading: isLoading, disabled: disableSendButton, copykey: 'dyn_send_transaction.confirmation.send', startSlot:
|
|
129
129
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
130
130
|
jsx(Icon, { size: 'small', color: 'text-secondary', children: jsx(SvgSend, {}) }), dataTestId: 'transaction-confirmation-send', children: t('dyn_send_transaction.confirmation.send') })] }), displayPoweredByDynamicFooter && (jsx(PoweredByDynamic, { classNameRoot: 'transaction-confirmation__footer' }))] })] }));
|
|
131
131
|
};
|
|
@@ -23,7 +23,7 @@ interface ViewHandlers {
|
|
|
23
23
|
setView: (view: ViewType) => void;
|
|
24
24
|
setShowAuthFlow: (show: boolean, options: AuthFlowOptions) => void;
|
|
25
25
|
}
|
|
26
|
-
export declare const useCurrencySymbol: (currentToken: TokenBalance | undefined, currency: string) => string;
|
|
26
|
+
export declare const useCurrencySymbol: (currentToken: TokenBalance | undefined, currency: string | undefined) => string | undefined;
|
|
27
27
|
export declare const getValueRounded: (isNativeToken: boolean, transaction: IUITransaction) => string | number | undefined;
|
|
28
28
|
export declare const calculateFiatPrice: (amount?: number, price?: number, decimals?: number) => number | undefined;
|
|
29
29
|
export declare const getDisplayFiatPrice: (amountValue?: number, currentToken?: TokenBalance) => string;
|
|
@@ -7,12 +7,13 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var useTransition = require('../../../utils/hooks/useTransition/useTransition.cjs');
|
|
10
|
+
var transitions = require('../../../utils/constants/transitions.cjs');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
13
|
|
|
13
14
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
15
|
|
|
15
|
-
const getSlideInUpTransitionDefaultStyles = (duration, curve =
|
|
16
|
+
const getSlideInUpTransitionDefaultStyles = (duration, curve = transitions.EASING_FUNCTION_DEFAULT) => ({
|
|
16
17
|
transition: `transform ${duration}ms ${curve}, opacity ${duration}ms ${curve}`,
|
|
17
18
|
});
|
|
18
19
|
const transitionStyles = {
|
|
@@ -27,9 +28,9 @@ const transitionStyles = {
|
|
|
27
28
|
},
|
|
28
29
|
};
|
|
29
30
|
const UnoptimizedSlideInUpTransition = (_a) => {
|
|
30
|
-
var { children, className } = _a, transitionProps = _tslib.__rest(_a, ["children", "className"]);
|
|
31
|
+
var { children, className, easingFunction } = _a, transitionProps = _tslib.__rest(_a, ["children", "className", "easingFunction"]);
|
|
31
32
|
const { mount, stage, currentDuration } = useTransition.useTransition(transitionProps);
|
|
32
|
-
const defaultStyles = getSlideInUpTransitionDefaultStyles(currentDuration);
|
|
33
|
+
const defaultStyles = getSlideInUpTransitionDefaultStyles(currentDuration, easingFunction);
|
|
33
34
|
const stageStyles = transitionStyles[stage];
|
|
34
35
|
if (!mount)
|
|
35
36
|
return null;
|
|
@@ -3,8 +3,9 @@ import { __rest } from '../../../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import React__default from 'react';
|
|
5
5
|
import { useTransition } from '../../../utils/hooks/useTransition/useTransition.js';
|
|
6
|
+
import { EASING_FUNCTION_DEFAULT } from '../../../utils/constants/transitions.js';
|
|
6
7
|
|
|
7
|
-
const getSlideInUpTransitionDefaultStyles = (duration, curve =
|
|
8
|
+
const getSlideInUpTransitionDefaultStyles = (duration, curve = EASING_FUNCTION_DEFAULT) => ({
|
|
8
9
|
transition: `transform ${duration}ms ${curve}, opacity ${duration}ms ${curve}`,
|
|
9
10
|
});
|
|
10
11
|
const transitionStyles = {
|
|
@@ -19,9 +20,9 @@ const transitionStyles = {
|
|
|
19
20
|
},
|
|
20
21
|
};
|
|
21
22
|
const UnoptimizedSlideInUpTransition = (_a) => {
|
|
22
|
-
var { children, className } = _a, transitionProps = __rest(_a, ["children", "className"]);
|
|
23
|
+
var { children, className, easingFunction } = _a, transitionProps = __rest(_a, ["children", "className", "easingFunction"]);
|
|
23
24
|
const { mount, stage, currentDuration } = useTransition(transitionProps);
|
|
24
|
-
const defaultStyles = getSlideInUpTransitionDefaultStyles(currentDuration);
|
|
25
|
+
const defaultStyles = getSlideInUpTransitionDefaultStyles(currentDuration, easingFunction);
|
|
25
26
|
const stageStyles = transitionStyles[stage];
|
|
26
27
|
if (!mount)
|
|
27
28
|
return null;
|
|
@@ -74,6 +74,7 @@ var useResetCookieLocalStorage = require('../../utils/hooks/useResetCookieLocalS
|
|
|
74
74
|
require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
75
75
|
var useEndUserWarning = require('../../utils/hooks/useEndUserWarning/useEndUserWarning.cjs');
|
|
76
76
|
var useDeviceFingerprint = require('../../utils/hooks/useDeviceFingerprint/useDeviceFingerprint.cjs');
|
|
77
|
+
var useAggregateWalletEvents = require('../../utils/hooks/useAggregateWalletEvents/useAggregateWalletEvents.cjs');
|
|
77
78
|
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
78
79
|
require('../../components/IconButton/IconButton.cjs');
|
|
79
80
|
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
@@ -404,6 +405,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
404
405
|
}
|
|
405
406
|
},
|
|
406
407
|
});
|
|
408
|
+
useAggregateWalletEvents.useAggregateWalletEvents();
|
|
407
409
|
useWalletEventListeners.useWalletEventListeners({
|
|
408
410
|
authMode,
|
|
409
411
|
detectNewWalletsForLinking,
|
|
@@ -70,6 +70,7 @@ import { useResetCookieLocalStorage } from '../../utils/hooks/useResetCookieLoca
|
|
|
70
70
|
import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
71
71
|
import { useEndUserWarning } from '../../utils/hooks/useEndUserWarning/useEndUserWarning.js';
|
|
72
72
|
import { useDeviceFingerprint } from '../../utils/hooks/useDeviceFingerprint/useDeviceFingerprint.js';
|
|
73
|
+
import { useAggregateWalletEvents } from '../../utils/hooks/useAggregateWalletEvents/useAggregateWalletEvents.js';
|
|
73
74
|
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
74
75
|
import '../../components/IconButton/IconButton.js';
|
|
75
76
|
import '../../components/InlineWidget/InlineWidget.js';
|
|
@@ -400,6 +401,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
400
401
|
}
|
|
401
402
|
},
|
|
402
403
|
});
|
|
404
|
+
useAggregateWalletEvents();
|
|
403
405
|
useWalletEventListeners({
|
|
404
406
|
authMode,
|
|
405
407
|
detectNewWalletsForLinking,
|
|
@@ -11,7 +11,7 @@ import { tokenBalancesEvents } from './tokenBalances';
|
|
|
11
11
|
/** Maps internal event names to their listeners */
|
|
12
12
|
export type DynamicEvents = AuthEvents & UIEvents & OTPEvents & WalletEvents & PasskeyEvents & SocialEvents & EmbeddedWalletEvents & MultiWalletInternalEvents & tokenBalancesEvents;
|
|
13
13
|
/** Which events are accessible by our clients */
|
|
14
|
-
export declare const externalEvents: ("authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "embeddedWalletCreated")[];
|
|
14
|
+
export declare const externalEvents: ("authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "embeddedWalletCreated")[];
|
|
15
15
|
export declare const dynamicEvents: EventEmitter<DynamicEvents, any>;
|
|
16
|
-
export declare const publicDynamicEvents: EventEmitter<"authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "embeddedWalletCreated", any>;
|
|
16
|
+
export declare const publicDynamicEvents: EventEmitter<"authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "embeddedWalletCreated", any>;
|
|
17
17
|
export type DynamicEventEmitter = typeof dynamicEvents;
|
|
@@ -1,4 +1,25 @@
|
|
|
1
|
+
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
1
2
|
import { Wallet } from '../shared/types/wallets';
|
|
3
|
+
export type UserWalletsUpdateType = {
|
|
4
|
+
updateType: 'walletAdded';
|
|
5
|
+
addedWallet: Wallet;
|
|
6
|
+
} | {
|
|
7
|
+
updateType: 'walletRemoved';
|
|
8
|
+
removedWallet: Wallet;
|
|
9
|
+
} | {
|
|
10
|
+
updateType: 'primaryWalletChanged';
|
|
11
|
+
} | {
|
|
12
|
+
updateType: 'primaryWalletNetworkChanged';
|
|
13
|
+
newNetwork: string | number;
|
|
14
|
+
} | {
|
|
15
|
+
updateType: 'nonPrimaryWalletNetworkChanged';
|
|
16
|
+
newNetwork: string | number;
|
|
17
|
+
affectedWallets: Wallet[];
|
|
18
|
+
};
|
|
19
|
+
export type UserWalletsChangedParams = {
|
|
20
|
+
userWallets: Wallet[];
|
|
21
|
+
primaryWallet: Wallet | undefined;
|
|
22
|
+
} & UserWalletsUpdateType;
|
|
2
23
|
export type WalletEvents = {
|
|
3
24
|
/** Triggered when a new wallet is added to user wallets list */
|
|
4
25
|
walletAdded: (wallet: Wallet, userWallets: Wallet[]) => void;
|
|
@@ -8,4 +29,8 @@ export type WalletEvents = {
|
|
|
8
29
|
primaryWalletChanged: (newPrimaryWallet: Wallet) => void;
|
|
9
30
|
/** Triggered when the network changes in primary wallet */
|
|
10
31
|
primaryWalletNetworkChanged: (newNetwork: string | number) => void;
|
|
32
|
+
/** Triggered when the network changes in non-primary wallet */
|
|
33
|
+
nonPrimaryWalletNetworkChanged: (newNetwork: string | number, connector: WalletConnector) => void;
|
|
34
|
+
/** Triggered when there is a change in user wallets */
|
|
35
|
+
userWalletsChanged: (params: UserWalletsChangedParams) => void;
|
|
11
36
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
// Easing functions
|
|
7
|
+
const EASING_FUNCTION_DEFAULT = 'cubic-bezier(0, 0, 0.24, 1.0)';
|
|
8
|
+
// Durations
|
|
9
|
+
const DURATION_DEFAULT = 300;
|
|
10
|
+
|
|
11
|
+
exports.DURATION_DEFAULT = DURATION_DEFAULT;
|
|
12
|
+
exports.EASING_FUNCTION_DEFAULT = EASING_FUNCTION_DEFAULT;
|
|
@@ -4,5 +4,5 @@ type DynamicEventListener<E extends keyof DynamicEvents> = (...args: EventArgs<D
|
|
|
4
4
|
/** Allows us to subscribe to all dynamicEvents with a hook, even the internal ones */
|
|
5
5
|
export declare const useInternalDynamicEvents: <E extends keyof import("../../../../events/auth").AuthEvents | keyof import("../../../../events/ui").UIEvents | keyof import("../../../../events/otp").OTPEvents | keyof import("../../../../events/wallets").WalletEvents | keyof import("../../../../events/passkey").PasskeyEvents | "farcasterConnectCancelled" | keyof import("../../../../events/embeddedWallet").EmbeddedWalletEvents | keyof import("../../../../events/multiWallet").MultiWalletInternalEvents | "tokenBalancesChanged">(event: E, listener: DynamicEventListener<E>) => void;
|
|
6
6
|
/** Allows subscribing to dynamic events directly inside components with a hook */
|
|
7
|
-
export declare const useDynamicEvents: <E extends "authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "embeddedWalletCreated">(event: E, listener: DynamicEventListener<E>) => void;
|
|
7
|
+
export declare const useDynamicEvents: <E extends "authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "embeddedWalletCreated">(event: E, listener: DynamicEventListener<E>) => void;
|
|
8
8
|
export {};
|
|
@@ -71,3 +71,4 @@ export { useDebounce } from './useDebounce';
|
|
|
71
71
|
export { useDeviceFingerprint } from './useDeviceFingerprint';
|
|
72
72
|
export * from './useEmbeddedWallet';
|
|
73
73
|
export { useUpgradeEmbeddedWallet } from './useUpgradeEmbeddedWallet';
|
|
74
|
+
export { useAggregateWalletEvents } from './useAggregateWalletEvents';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useAggregateWalletEvents';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
7
|
+
var primaryWalletId = require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
8
|
+
var useDynamicEvents = require('../events/useDynamicEvents/useDynamicEvents.cjs');
|
|
9
|
+
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
10
|
+
|
|
11
|
+
const useAggregateWalletEvents = () => {
|
|
12
|
+
const { userWallets } = UserWalletsContext.useInternalUserWallets();
|
|
13
|
+
const findPrimaryWallet = (wallets) => wallets.find((wallet) => wallet.id === primaryWalletId.getPrimaryWalletId());
|
|
14
|
+
useDynamicEvents.useInternalDynamicEvents('walletAdded', (wallet, userWallets) => {
|
|
15
|
+
dynamicEvents.dynamicEvents.emit('userWalletsChanged', {
|
|
16
|
+
addedWallet: wallet,
|
|
17
|
+
primaryWallet: findPrimaryWallet(userWallets),
|
|
18
|
+
updateType: 'walletAdded',
|
|
19
|
+
userWallets,
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
useDynamicEvents.useInternalDynamicEvents('walletRemoved', (wallet, userWallets) => {
|
|
23
|
+
dynamicEvents.dynamicEvents.emit('userWalletsChanged', {
|
|
24
|
+
primaryWallet: findPrimaryWallet(userWallets),
|
|
25
|
+
removedWallet: wallet,
|
|
26
|
+
updateType: 'walletRemoved',
|
|
27
|
+
userWallets,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
useDynamicEvents.useInternalDynamicEvents('primaryWalletChanged', (newPrimaryWallet) => {
|
|
31
|
+
dynamicEvents.dynamicEvents.emit('userWalletsChanged', {
|
|
32
|
+
primaryWallet: newPrimaryWallet,
|
|
33
|
+
updateType: 'primaryWalletChanged',
|
|
34
|
+
userWallets,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
useDynamicEvents.useInternalDynamicEvents('primaryWalletNetworkChanged', (newNetwork) => {
|
|
38
|
+
dynamicEvents.dynamicEvents.emit('userWalletsChanged', {
|
|
39
|
+
newNetwork,
|
|
40
|
+
primaryWallet: findPrimaryWallet(userWallets),
|
|
41
|
+
updateType: 'primaryWalletNetworkChanged',
|
|
42
|
+
userWallets,
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
useDynamicEvents.useInternalDynamicEvents('nonPrimaryWalletNetworkChanged', (newNetwork, connector) => {
|
|
46
|
+
const affectedWallets = userWallets.filter((wallet) => wallet.connector.key === connector.key);
|
|
47
|
+
dynamicEvents.dynamicEvents.emit('userWalletsChanged', {
|
|
48
|
+
affectedWallets,
|
|
49
|
+
newNetwork,
|
|
50
|
+
primaryWallet: findPrimaryWallet(userWallets),
|
|
51
|
+
updateType: 'nonPrimaryWalletNetworkChanged',
|
|
52
|
+
userWallets,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.useAggregateWalletEvents = useAggregateWalletEvents;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAggregateWalletEvents: () => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
3
|
+
import { getPrimaryWalletId } from '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
4
|
+
import { useInternalDynamicEvents } from '../events/useDynamicEvents/useDynamicEvents.js';
|
|
5
|
+
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
6
|
+
|
|
7
|
+
const useAggregateWalletEvents = () => {
|
|
8
|
+
const { userWallets } = useInternalUserWallets();
|
|
9
|
+
const findPrimaryWallet = (wallets) => wallets.find((wallet) => wallet.id === getPrimaryWalletId());
|
|
10
|
+
useInternalDynamicEvents('walletAdded', (wallet, userWallets) => {
|
|
11
|
+
dynamicEvents.emit('userWalletsChanged', {
|
|
12
|
+
addedWallet: wallet,
|
|
13
|
+
primaryWallet: findPrimaryWallet(userWallets),
|
|
14
|
+
updateType: 'walletAdded',
|
|
15
|
+
userWallets,
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
useInternalDynamicEvents('walletRemoved', (wallet, userWallets) => {
|
|
19
|
+
dynamicEvents.emit('userWalletsChanged', {
|
|
20
|
+
primaryWallet: findPrimaryWallet(userWallets),
|
|
21
|
+
removedWallet: wallet,
|
|
22
|
+
updateType: 'walletRemoved',
|
|
23
|
+
userWallets,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
useInternalDynamicEvents('primaryWalletChanged', (newPrimaryWallet) => {
|
|
27
|
+
dynamicEvents.emit('userWalletsChanged', {
|
|
28
|
+
primaryWallet: newPrimaryWallet,
|
|
29
|
+
updateType: 'primaryWalletChanged',
|
|
30
|
+
userWallets,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
useInternalDynamicEvents('primaryWalletNetworkChanged', (newNetwork) => {
|
|
34
|
+
dynamicEvents.emit('userWalletsChanged', {
|
|
35
|
+
newNetwork,
|
|
36
|
+
primaryWallet: findPrimaryWallet(userWallets),
|
|
37
|
+
updateType: 'primaryWalletNetworkChanged',
|
|
38
|
+
userWallets,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
useInternalDynamicEvents('nonPrimaryWalletNetworkChanged', (newNetwork, connector) => {
|
|
42
|
+
const affectedWallets = userWallets.filter((wallet) => wallet.connector.key === connector.key);
|
|
43
|
+
dynamicEvents.emit('userWalletsChanged', {
|
|
44
|
+
affectedWallets,
|
|
45
|
+
newNetwork,
|
|
46
|
+
primaryWallet: findPrimaryWallet(userWallets),
|
|
47
|
+
updateType: 'nonPrimaryWalletNetworkChanged',
|
|
48
|
+
userWallets,
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { useAggregateWalletEvents };
|
|
@@ -163,6 +163,9 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
|
+
useWalletConnectorEvent.useWalletConnectorEvent(uniqueNonPrimaryWallets, 'chainChange', ({ chain }, connector) => {
|
|
167
|
+
dynamicEvents.dynamicEvents.emit('nonPrimaryWalletNetworkChanged', chain, connector);
|
|
168
|
+
});
|
|
166
169
|
};
|
|
167
170
|
|
|
168
171
|
exports.useWalletEventListeners = useWalletEventListeners;
|
|
@@ -159,6 +159,9 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
});
|
|
162
|
+
useWalletConnectorEvent(uniqueNonPrimaryWallets, 'chainChange', ({ chain }, connector) => {
|
|
163
|
+
dynamicEvents.emit('nonPrimaryWalletNetworkChanged', chain, connector);
|
|
164
|
+
});
|
|
162
165
|
};
|
|
163
166
|
|
|
164
167
|
export { useWalletEventListeners };
|
|
@@ -320,7 +320,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
320
320
|
amountLeft: transaction.format(transaction.fee.gas, {
|
|
321
321
|
precision: 6,
|
|
322
322
|
}),
|
|
323
|
-
currencySymbol: currency,
|
|
323
|
+
currencySymbol: currency === null || currency === void 0 ? void 0 : currency.symbol,
|
|
324
324
|
}) })] }));
|
|
325
325
|
}
|
|
326
326
|
// Check for insufficient funds
|
|
@@ -329,7 +329,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
329
329
|
const amountLeft = transaction.format(missingFunds, { precision: 6 });
|
|
330
330
|
return (jsxRuntime.jsxs(Alert.Alert, { icon: 'error', variant: 'error', contentDataTestId: 'warning_content', copykey: 'dyn_send_transaction.warning_message.insufficient_funds', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_send_transaction.warning_message.insufficient_funds.title', children: t('dyn_send_transaction.warning_message.insufficient_funds.title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_send_transaction.warning_message.insufficient_funds.description', children: t('dyn_send_transaction.warning_message.insufficient_funds.description', {
|
|
331
331
|
amountLeft,
|
|
332
|
-
currencySymbol: currency,
|
|
332
|
+
currencySymbol: currency === null || currency === void 0 ? void 0 : currency.symbol,
|
|
333
333
|
}) })] }));
|
|
334
334
|
}
|
|
335
335
|
// Finally, check for simulation failure
|
|
@@ -348,7 +348,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
348
348
|
isGasSponsored,
|
|
349
349
|
hasInsufficientFunds,
|
|
350
350
|
t,
|
|
351
|
-
currency,
|
|
351
|
+
currency === null || currency === void 0 ? void 0 : currency.symbol,
|
|
352
352
|
]);
|
|
353
353
|
React.useEffect(() => {
|
|
354
354
|
var _a, _b;
|
|
@@ -312,7 +312,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
312
312
|
amountLeft: transaction.format(transaction.fee.gas, {
|
|
313
313
|
precision: 6,
|
|
314
314
|
}),
|
|
315
|
-
currencySymbol: currency,
|
|
315
|
+
currencySymbol: currency === null || currency === void 0 ? void 0 : currency.symbol,
|
|
316
316
|
}) })] }));
|
|
317
317
|
}
|
|
318
318
|
// Check for insufficient funds
|
|
@@ -321,7 +321,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
321
321
|
const amountLeft = transaction.format(missingFunds, { precision: 6 });
|
|
322
322
|
return (jsxs(Alert, { icon: 'error', variant: 'error', contentDataTestId: 'warning_content', copykey: 'dyn_send_transaction.warning_message.insufficient_funds', children: [jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_send_transaction.warning_message.insufficient_funds.title', children: t('dyn_send_transaction.warning_message.insufficient_funds.title') }), jsx(Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_send_transaction.warning_message.insufficient_funds.description', children: t('dyn_send_transaction.warning_message.insufficient_funds.description', {
|
|
323
323
|
amountLeft,
|
|
324
|
-
currencySymbol: currency,
|
|
324
|
+
currencySymbol: currency === null || currency === void 0 ? void 0 : currency.symbol,
|
|
325
325
|
}) })] }));
|
|
326
326
|
}
|
|
327
327
|
// Finally, check for simulation failure
|
|
@@ -340,7 +340,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
340
340
|
isGasSponsored,
|
|
341
341
|
hasInsufficientFunds,
|
|
342
342
|
t,
|
|
343
|
-
currency,
|
|
343
|
+
currency === null || currency === void 0 ? void 0 : currency.symbol,
|
|
344
344
|
]);
|
|
345
345
|
useEffect(() => {
|
|
346
346
|
var _a, _b;
|
|
@@ -95,13 +95,13 @@ require('@dynamic-labs/ethereum-aa');
|
|
|
95
95
|
const Balance = ({ wallet, network, className }) => {
|
|
96
96
|
const { currency, isLoading: isLoadingCurrency } = useFetchCurrency.useFetchCurrency(wallet.connector, network);
|
|
97
97
|
const { balance, isLoading: isLoadingBalance } = useFetchBalance.useFetchBalance({
|
|
98
|
-
chain: currency,
|
|
98
|
+
chain: currency === null || currency === void 0 ? void 0 : currency.symbol,
|
|
99
99
|
network,
|
|
100
100
|
wallet,
|
|
101
101
|
});
|
|
102
102
|
if (!balance)
|
|
103
103
|
return null;
|
|
104
|
-
return (jsxRuntime.jsxs(Typography.Typography, { className: className, variant: 'body_normal', color: 'primary', children: [isLoadingBalance ? (jsxRuntime.jsx(Skeleton.Skeleton, { className: 'balance-skeleton' })) : (helpers.roundBalance(balance)), ' ', !isLoadingCurrency && (jsxRuntime.jsx(Typography.Typography, { as: 'span', variant: 'body_normal', color: 'secondary', children: currency }))] }));
|
|
104
|
+
return (jsxRuntime.jsxs(Typography.Typography, { className: className, variant: 'body_normal', color: 'primary', children: [isLoadingBalance ? (jsxRuntime.jsx(Skeleton.Skeleton, { className: 'balance-skeleton' })) : (helpers.roundBalance(balance)), ' ', !isLoadingCurrency && (jsxRuntime.jsx(Typography.Typography, { as: 'span', variant: 'body_normal', color: 'secondary', children: currency === null || currency === void 0 ? void 0 : currency.symbol }))] }));
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
exports.Balance = Balance;
|
|
@@ -91,13 +91,13 @@ import '@dynamic-labs/ethereum-aa';
|
|
|
91
91
|
const Balance = ({ wallet, network, className }) => {
|
|
92
92
|
const { currency, isLoading: isLoadingCurrency } = useFetchCurrency(wallet.connector, network);
|
|
93
93
|
const { balance, isLoading: isLoadingBalance } = useFetchBalance({
|
|
94
|
-
chain: currency,
|
|
94
|
+
chain: currency === null || currency === void 0 ? void 0 : currency.symbol,
|
|
95
95
|
network,
|
|
96
96
|
wallet,
|
|
97
97
|
});
|
|
98
98
|
if (!balance)
|
|
99
99
|
return null;
|
|
100
|
-
return (jsxs(Typography, { className: className, variant: 'body_normal', color: 'primary', children: [isLoadingBalance ? (jsx(Skeleton, { className: 'balance-skeleton' })) : (roundBalance(balance)), ' ', !isLoadingCurrency && (jsx(Typography, { as: 'span', variant: 'body_normal', color: 'secondary', children: currency }))] }));
|
|
100
|
+
return (jsxs(Typography, { className: className, variant: 'body_normal', color: 'primary', children: [isLoadingBalance ? (jsx(Skeleton, { className: 'balance-skeleton' })) : (roundBalance(balance)), ' ', !isLoadingCurrency && (jsx(Typography, { as: 'span', variant: 'body_normal', color: 'secondary', children: currency === null || currency === void 0 ? void 0 : currency.symbol }))] }));
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
export { Balance };
|
|
@@ -90,14 +90,17 @@ require('../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
90
90
|
|
|
91
91
|
const useFetchCurrency = (connector, network) => {
|
|
92
92
|
const fetchChainCurrency = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
93
|
-
var _a, _b, _c, _d;
|
|
93
|
+
var _a, _b, _c, _d, _e, _f;
|
|
94
94
|
if (!connector)
|
|
95
95
|
return null;
|
|
96
96
|
const chainId = yield connector.getNetwork();
|
|
97
97
|
const chainInfo = walletConnectorCore.getChainInfoWithOverrides((_a = connector.connectedChain) !== null && _a !== void 0 ? _a : '');
|
|
98
98
|
/* istanbul ignore else */
|
|
99
99
|
if (!chainId) {
|
|
100
|
-
return
|
|
100
|
+
return {
|
|
101
|
+
name: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName,
|
|
102
|
+
symbol: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
103
|
+
};
|
|
101
104
|
}
|
|
102
105
|
const network = (() => {
|
|
103
106
|
if (connector.connectedChain === 'STARK') {
|
|
@@ -111,10 +114,14 @@ const useFetchCurrency = (connector, network) => {
|
|
|
111
114
|
}
|
|
112
115
|
})();
|
|
113
116
|
const result = (_b = connector[network]) === null || _b === void 0 ? void 0 : _b.find((element) => element.chainId === chainId);
|
|
114
|
-
return
|
|
117
|
+
return {
|
|
118
|
+
name: (_d = (_c = result === null || result === void 0 ? void 0 : result.nativeCurrency) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName,
|
|
119
|
+
symbol: (_f = (_e = result === null || result === void 0 ? void 0 : result.nativeCurrency) === null || _e === void 0 ? void 0 : _e.symbol) !== null && _f !== void 0 ? _f : chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
120
|
+
};
|
|
115
121
|
});
|
|
116
122
|
const { data: currency, isLoading } = usePromise.usePromise(fetchChainCurrency, {
|
|
117
123
|
deps: [network],
|
|
124
|
+
initialData: null,
|
|
118
125
|
});
|
|
119
126
|
return { currency, isLoading };
|
|
120
127
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { WalletConnector } from '../../../../..';
|
|
2
|
+
type Currency = {
|
|
3
|
+
name: string | undefined;
|
|
4
|
+
symbol: string | undefined;
|
|
5
|
+
};
|
|
2
6
|
export declare const useFetchCurrency: (connector: WalletConnector | undefined, network?: number | string) => {
|
|
3
|
-
currency:
|
|
7
|
+
currency: Currency | null;
|
|
4
8
|
isLoading: boolean;
|
|
5
9
|
};
|
|
10
|
+
export {};
|
|
@@ -86,14 +86,17 @@ import '../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
86
86
|
|
|
87
87
|
const useFetchCurrency = (connector, network) => {
|
|
88
88
|
const fetchChainCurrency = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
-
var _a, _b, _c, _d;
|
|
89
|
+
var _a, _b, _c, _d, _e, _f;
|
|
90
90
|
if (!connector)
|
|
91
91
|
return null;
|
|
92
92
|
const chainId = yield connector.getNetwork();
|
|
93
93
|
const chainInfo = getChainInfoWithOverrides((_a = connector.connectedChain) !== null && _a !== void 0 ? _a : '');
|
|
94
94
|
/* istanbul ignore else */
|
|
95
95
|
if (!chainId) {
|
|
96
|
-
return
|
|
96
|
+
return {
|
|
97
|
+
name: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName,
|
|
98
|
+
symbol: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
99
|
+
};
|
|
97
100
|
}
|
|
98
101
|
const network = (() => {
|
|
99
102
|
if (connector.connectedChain === 'STARK') {
|
|
@@ -107,10 +110,14 @@ const useFetchCurrency = (connector, network) => {
|
|
|
107
110
|
}
|
|
108
111
|
})();
|
|
109
112
|
const result = (_b = connector[network]) === null || _b === void 0 ? void 0 : _b.find((element) => element.chainId === chainId);
|
|
110
|
-
return
|
|
113
|
+
return {
|
|
114
|
+
name: (_d = (_c = result === null || result === void 0 ? void 0 : result.nativeCurrency) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName,
|
|
115
|
+
symbol: (_f = (_e = result === null || result === void 0 ? void 0 : result.nativeCurrency) === null || _e === void 0 ? void 0 : _e.symbol) !== null && _f !== void 0 ? _f : chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
116
|
+
};
|
|
111
117
|
});
|
|
112
118
|
const { data: currency, isLoading } = usePromise(fetchChainCurrency, {
|
|
113
119
|
deps: [network],
|
|
120
|
+
initialData: null,
|
|
114
121
|
});
|
|
115
122
|
return { currency, isLoading };
|
|
116
123
|
};
|