import { type Dispatch } from 'redux'; import { openModal } from '@suite/modal'; import { notificationsActions } from '@suite-common/toast-notifications'; import { type AddressType } from '@suite-common/wallet-types'; import { copyToClipboard } from '@trezor/dom-utils'; type ShowCopyAddressModalOptions = { copyAnalyticsFrom?: 'asset-detail'; }; export const showCopyAddressModal = ( address: string, addressType: AddressType, { copyAnalyticsFrom }: ShowCopyAddressModalOptions = {}, ) => (dispatch: Dispatch) => { dispatch( openModal({ type: 'copy-address', addressType, address, copyAnalyticsFrom, }), ); }; export const copyAddressToClipboard = (address: string) => async (dispatch: Dispatch) => { const result = await copyToClipboard(address); const isSuccess = result === true; if (isSuccess) { dispatch(notificationsActions.addToast({ type: 'copy-to-clipboard' })); } };