diff --git a/app/actions/notification/helpers/constants.ts b/app/actions/notification/constants/index.ts similarity index 100% rename from app/actions/notification/helpers/constants.ts rename to app/actions/notification/constants/index.ts diff --git a/app/actions/notification/pushNotifications.ts b/app/actions/notification/helpers/index.ts similarity index 96% rename from app/actions/notification/pushNotifications.ts rename to app/actions/notification/helpers/index.ts index 52164982171..f1483a50cc9 100644 --- a/app/actions/notification/pushNotifications.ts +++ b/app/actions/notification/helpers/index.ts @@ -1,8 +1,8 @@ import { getErrorMessage } from '@metamask/utils'; -import { notificationsErrors } from './helpers/constants'; -import Engine from '../../core/Engine'; -import { Notification } from '../../util/notifications'; +import { notificationsErrors } from '../constants'; +import Engine from '../../../core/Engine'; +import { Notification } from '../../../util/notifications'; const { AuthenticationController, diff --git a/app/util/notifications/index.ts b/app/util/notifications/index.ts index 71c00e756fc..ec78eb1f67a 100644 --- a/app/util/notifications/index.ts +++ b/app/util/notifications/index.ts @@ -3,5 +3,5 @@ export * from './constants'; export * from './setupAndroidChannels'; export * from './settings'; export * from './hooks'; -export * from './notification.util'; -export * from './push-permissions'; +export * from './methods'; +export * from './pushPermissions'; diff --git a/app/util/notifications/notification.util.ts b/app/util/notifications/methods/common.ts similarity index 90% rename from app/util/notifications/notification.util.ts rename to app/util/notifications/methods/common.ts index d57b1bb1113..3e0f2fa8266 100644 --- a/app/util/notifications/notification.util.ts +++ b/app/util/notifications/methods/common.ts @@ -1,14 +1,14 @@ import { Web3Provider } from '@ethersproject/providers'; import { toHex } from '@metamask/controller-utils'; import { NotificationServicesController } from '@metamask/notification-services-controller'; -import Engine from '../../core/Engine'; +import Engine from '../../../core/Engine'; import { BigNumber } from 'bignumber.js'; -import { IconName } from '../../component-library/components/Icons/Icon'; -import images from '../../images/image-icons'; -import { hexWEIToDecETH, hexWEIToDecGWEI } from '../conversions'; -import { calcTokenAmount } from '../transactions'; -import { TRIGGER_TYPES } from './constants'; -import { Notification } from './types'; +import { IconName } from '../../../component-library/components/Icons/Icon'; +import images from '../../../images/image-icons'; +import { hexWEIToDecETH, hexWEIToDecGWEI } from '../../conversions'; +import { calcTokenAmount } from '../../transactions'; +import { TRIGGER_TYPES } from '../constants'; +import { Notification } from '../types'; const { UI } = NotificationServicesController; @@ -344,29 +344,6 @@ export function getBlockExplorerByChainId(chainId: number) { return undefined; } -/** - * Formats an ISO date string into a more readable format. - * - * @param isoDateString - The ISO date string to format. - * @returns The formatted date string. - */ -export function formatIsoDateString(isoDateString: string) { - const date = new Date(isoDateString); - - const options = { - year: 'numeric' as const, - month: 'short' as const, - day: 'numeric' as const, - hour: 'numeric' as const, - minute: 'numeric' as const, - hour12: true, - }; - - const formattedDate = new Intl.DateTimeFormat('en-US', options).format(date); - - return formattedDate; -} - export function hasNetworkFeeFields( notification: NotificationServicesController.Types.OnChainRawNotification, ): notification is NotificationServicesController.Types.OnChainRawNotificationsWithNetworkFields { @@ -450,14 +427,6 @@ export const getNetworkFees = async ( } }; -/** - * Checks if a given URL is an IPFS URL. - * - * @param url - The URL to check. - * @returns True if the URL is an IPFS URL, false otherwise. - */ -export const isIpfsURL = (url: string): boolean => url.startsWith('ipfs://'); - export const getNotificationBadge = (trigger_type: string) => { switch (trigger_type) { case TRIGGER_TYPES.ERC20_SENT: @@ -495,25 +464,6 @@ export const TRUNCATED_ADDRESS_START_CHARS = 7; // `${TRUNCATED_ADDRESS_START_CHARS}...${TRUNCATED_ADDRESS_END_CHARS}` export const TRUNCATED_ADDRESS_END_CHARS = 5; -/** - * Shortens an Ethereum address for display, preserving the beginning and end. - * Returns the given address if it is no longer than 10 characters. - * Shortened addresses are 13 characters long. - * - * Example output: 0xabcde...12345 - * - * @param {string} address - The address to shorten. - * @returns {string} The shortened address, or the original if it was no longer - * than 10 characters. - */ -export function shortenAddress(address = '') { - return shortenString(address, { - truncatedCharLimit: TRUNCATED_NAME_CHAR_LIMIT, - truncatedStartChars: TRUNCATED_ADDRESS_START_CHARS, - truncatedEndChars: TRUNCATED_ADDRESS_END_CHARS, - }); -} - /** * Shortens the given string, preserving the beginning and end. * Returns the string it is no longer than truncatedCharLimit. diff --git a/app/util/notifications/methods/index.ts b/app/util/notifications/methods/index.ts new file mode 100644 index 00000000000..17c65417c84 --- /dev/null +++ b/app/util/notifications/methods/index.ts @@ -0,0 +1,2 @@ +export * from './fcmHelper'; +export * from './common'; diff --git a/app/util/notifications/push-permissions.ts b/app/util/notifications/pushPermissions.ts similarity index 98% rename from app/util/notifications/push-permissions.ts rename to app/util/notifications/pushPermissions.ts index a584f7b066c..208996d4950 100644 --- a/app/util/notifications/push-permissions.ts +++ b/app/util/notifications/pushPermissions.ts @@ -2,7 +2,7 @@ import notifee, { AuthorizationStatus } from '@notifee/react-native'; import { Alert } from 'react-native'; import { strings } from '../../../locales/i18n'; -import Device from '../../util/device'; +import Device from '../device'; import { mmStorage } from './settings'; import { STORAGE_IDS } from './settings/storage/constants'; import Logger from '../Logger';