Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

10 changes: 0 additions & 10 deletions packages/notification-services-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@
"default": "./dist/NotificationServicesController/index.cjs"
}
},
"./notification-services/ui": {
"import": {
"types": "./dist/NotificationServicesController/ui/index.d.mts",
"default": "./dist/NotificationServicesController/ui/index.mjs"
},
"require": {
"types": "./dist/NotificationServicesController/ui/index.d.cts",
"default": "./dist/NotificationServicesController/ui/index.cjs"
}
},
"./notification-services/mocks": {
"import": {
"types": "./dist/NotificationServicesController/mocks/index.d.mts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,3 @@ export const NOTIFICATION_API_TRIGGER_TYPES_SET: Set<string> = new Set([
TRIGGER_TYPES.ERC1155_RECEIVED,
TRIGGER_TYPES.PLATFORM,
]);

export const NOTIFICATION_CHAINS_ID = {
ETHEREUM: '1',
OPTIMISM: '10',
BSC: '56',
BASE: '8453',
POLYGON: '137',
ARBITRUM: '42161',
AVALANCHE: '43114',
LINEA: '59144',
SEI: '1329',
} as const;

// Kept as SCREAMING_SNAKE_CASE for backwards compatibility
// eslint-disable-next-line @typescript-eslint/naming-convention
export type NOTIFICATION_CHAINS_IDS =
(typeof NOTIFICATION_CHAINS_ID)[keyof typeof NOTIFICATION_CHAINS_ID];
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ export * from './processors';
export * as Constants from './constants';
export * from './constants';
export * as Mocks from './mocks';
export * as UI from './ui';
export * from '../shared';
export { isVersionInBounds } from './utils/isVersionInBounds';
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ export function createMockNotificationEthSent(): NormalisedAPINotification {
tx_hash:
'0xb2256b183f2fb3872f99294ab55fb03e6a479b0d4aca556a3b27568b712505a6',
address: '0x881D40237659C251811CEC9c364ef91dC08D300C',
network: {
name: 'Ethereum',
native_symbol: 'ETH',
block_explorer: {
url: 'https://etherscan.io',
name: 'Etherscan',
},
},
data: {
kind: 'eth_sent',
network_fee: {
Expand Down Expand Up @@ -58,6 +66,14 @@ export function createMockNotificationEthReceived(): NormalisedAPINotification {
tx_hash:
'0xb2256b183f2fb3872f99294ab55fb03e6a479b0d4aca556a3b27568b712505a6',
address: '0x881D40237659C251811CEC9c364ef91dC08D300C',
network: {
name: 'Ethereum',
native_symbol: 'ETH',
block_explorer: {
url: 'https://etherscan.io',
name: 'Etherscan',
},
},
data: {
kind: 'eth_received',
network_fee: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export type Data_ERC20Sent = components['schemas']['Data_ERC20Sent'];
export type Data_ERC20Received = components['schemas']['Data_ERC20Received'];
export type Data_ERC721Sent = components['schemas']['Data_ERC721Sent'];
export type Data_ERC721Received = components['schemas']['Data_ERC721Received'];
export type NetworkMetadata = components['schemas']['NetworkMetadata'];
export type BlockExplorer = components['schemas']['BlockExplorer'];

type Notification = components['schemas']['NotificationOutputV3'][number];
type PlatformNotification = Extract<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export type components = {
/** @example 0x881D40237659C251811CEC9c364ef91dC08D300C */
tx_hash: string;
address: string;
network?: components['schemas']['NetworkMetadata'];
data?:
| components['schemas']['Data_MetamaskSwapCompleted']
| components['schemas']['Data_LidoStakeReadyToBeWithdrawn']
Expand Down Expand Up @@ -376,6 +377,28 @@ export type components = {
/** Format: decimal */
usd: string;
};
BlockExplorer: {
/**
* Format: uri
* @example https://etherscan.io
*/
url: string;
/** @example Etherscan */
name: string;
};
NetworkMetadata: {
/**
* @description Human-readable network name
* @example Ethereum
*/
name: string;
/**
* @description Native token symbol
* @example ETH
*/
native_symbol: string;
block_explorer: components['schemas']['BlockExplorer'];
};
};
responses: never;
parameters: never;
Expand Down

This file was deleted.

This file was deleted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note - this whole file can be thrown away once we start the push notification cleanup ticket
(push notifications are all derived from the server now, so we do not need any client side implementation to generate push messages).

Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { getAmount, formatAmount } from './get-notification-data';
import type {
NOTIFICATION_CHAINS_IDS,
Types,
} from '../../NotificationServicesController';
import type { Types } from '../../NotificationServicesController';
import type { Constants } from '../../NotificationServicesController';
import { NOTIFICATION_NETWORK_CURRENCY_SYMBOL } from '../../NotificationServicesController/ui';

export type TranslationKeys = {
pushPlatformNotificationsFundsSentTitle: () => string;
Expand Down Expand Up @@ -108,7 +104,7 @@ export const createOnChainPushNotificationMessages = (
defaultDescription: (): string | null =>
translate('pushPlatformNotificationsFundsSentDescriptionDefault'),
getDescription: (notification): string | null => {
const symbol = getChainSymbol(notification?.payload?.chain_id);
const symbol = notification?.payload?.network?.native_symbol;
const tokenAmount = notification?.payload?.data?.amount?.eth;
if (!symbol || !tokenAmount) {
return null;
Expand Down Expand Up @@ -153,7 +149,7 @@ export const createOnChainPushNotificationMessages = (
defaultDescription: (): string | null =>
translate('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
getDescription: (notification): string | null => {
const symbol = getChainSymbol(notification?.payload?.chain_id);
const symbol = notification?.payload?.network?.native_symbol;
const tokenAmount = notification?.payload?.data?.amount?.eth;
if (!symbol || !tokenAmount) {
return null;
Expand Down Expand Up @@ -267,20 +263,6 @@ export const createOnChainPushNotificationMessages = (
};
};

/**
* Retrieves the symbol associated with a given chain ID.
*
* @param chainId - The ID of the chain.
* @returns The symbol associated with the chain ID, or null if not found.
*/
function getChainSymbol(chainId: number): string | null {
return (
NOTIFICATION_NETWORK_CURRENCY_SYMBOL[
chainId.toString() as NOTIFICATION_CHAINS_IDS
] ?? null
);
}

/**
* Creates a push notification message based on the given on-chain raw notification.
*
Expand Down
Loading