Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c02b4cea3a | ||
|
|
dfa8af63e2 | ||
|
|
c01ec6304d |
+1
-1
@@ -42,7 +42,7 @@
|
|||||||
"@cosmjs/tendermint-rpc": "^0.32.1",
|
"@cosmjs/tendermint-rpc": "^0.32.1",
|
||||||
"@dydxprotocol/v4-abacus": "^1.4.9",
|
"@dydxprotocol/v4-abacus": "^1.4.9",
|
||||||
"@dydxprotocol/v4-client-js": "^1.0.20",
|
"@dydxprotocol/v4-client-js": "^1.0.20",
|
||||||
"@dydxprotocol/v4-localization": "^1.1.34",
|
"@dydxprotocol/v4-localization": "^1.1.35",
|
||||||
"@ethersproject/providers": "^5.7.2",
|
"@ethersproject/providers": "^5.7.2",
|
||||||
"@js-joda/core": "^5.5.3",
|
"@js-joda/core": "^5.5.3",
|
||||||
"@radix-ui/react-accordion": "^1.1.2",
|
"@radix-ui/react-accordion": "^1.1.2",
|
||||||
|
|||||||
Generated
+4
-4
@@ -36,8 +36,8 @@ dependencies:
|
|||||||
specifier: ^1.0.20
|
specifier: ^1.0.20
|
||||||
version: 1.0.20
|
version: 1.0.20
|
||||||
'@dydxprotocol/v4-localization':
|
'@dydxprotocol/v4-localization':
|
||||||
specifier: ^1.1.34
|
specifier: ^1.1.35
|
||||||
version: 1.1.34
|
version: 1.1.35
|
||||||
'@ethersproject/providers':
|
'@ethersproject/providers':
|
||||||
specifier: ^5.7.2
|
specifier: ^5.7.2
|
||||||
version: 5.7.2
|
version: 5.7.2
|
||||||
@@ -1323,8 +1323,8 @@ packages:
|
|||||||
- utf-8-validate
|
- utf-8-validate
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@dydxprotocol/v4-localization@1.1.34:
|
/@dydxprotocol/v4-localization@1.1.35:
|
||||||
resolution: {integrity: sha512-I7zivjv8gS+6b9n7/wh7PY9QEUDIIyLx9ugZ5K6ybar0xT/06yupOVdVE6iLivQ/IAsVi/RFHkD8bQd0DWCetg==}
|
resolution: {integrity: sha512-q5JFYoL/QanHXOtFqRa2owBZJibi1sMpSm3dAcxs9x0/xe8mo6fWcnbQfhl8k7g0/tv7PsBc+e3rbWD0EfvGiA==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@dydxprotocol/v4-proto@4.0.0-dev.0:
|
/@dydxprotocol/v4-proto@4.0.0-dev.0:
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ export enum AnalyticsEvent {
|
|||||||
TradePlaceOrderConfirmed = 'TradePlaceOrderConfirmed',
|
TradePlaceOrderConfirmed = 'TradePlaceOrderConfirmed',
|
||||||
TradeCancelOrder = 'TradeCancelOrder',
|
TradeCancelOrder = 'TradeCancelOrder',
|
||||||
TradeCancelOrderConfirmed = 'TradeCancelOrderConfirmed',
|
TradeCancelOrderConfirmed = 'TradeCancelOrderConfirmed',
|
||||||
|
|
||||||
|
// Notification
|
||||||
|
NotificationAction = 'NotificationAction',
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AnalyticsEventData<T extends AnalyticsEvent> =
|
export type AnalyticsEventData<T extends AnalyticsEvent> =
|
||||||
@@ -180,6 +183,12 @@ export type AnalyticsEventData<T extends AnalyticsEvent> =
|
|||||||
/** URL/IP of node the order was sent to */
|
/** URL/IP of node the order was sent to */
|
||||||
validatorUrl: string;
|
validatorUrl: string;
|
||||||
}
|
}
|
||||||
|
: // Notifcation
|
||||||
|
T extends AnalyticsEvent.NotificationAction
|
||||||
|
? {
|
||||||
|
type: string;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
: never;
|
: never;
|
||||||
|
|
||||||
export const DEFAULT_TRANSACTION_MEMO = 'dYdX Frontend (web)';
|
export const DEFAULT_TRANSACTION_MEMO = 'dYdX Frontend (web)';
|
||||||
|
|||||||
@@ -143,6 +143,11 @@ export type TransferNotifcation = {
|
|||||||
isExchange?: boolean;
|
isExchange?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export enum ReleaseUpdateNotificationIds {
|
||||||
|
RewardsAndFullTradingLive = 'rewards-and-full-trading-live',
|
||||||
|
IncentivesS3 = 'incentives-s3',
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Struct to store whether a NotificationType should be triggered
|
* @description Struct to store whether a NotificationType should be triggered
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { isEqual, groupBy } from 'lodash';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { DialogTypes } from '@/constants/dialogs';
|
import { DialogTypes } from '@/constants/dialogs';
|
||||||
import { AppRoute } from '@/constants/routes';
|
import { AppRoute, TokenRoute } from '@/constants/routes';
|
||||||
import { DydxChainAsset } from '@/constants/wallets';
|
import { DydxChainAsset } from '@/constants/wallets';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -20,9 +20,10 @@ import {
|
|||||||
NotificationType,
|
NotificationType,
|
||||||
DEFAULT_TOAST_AUTO_CLOSE_MS,
|
DEFAULT_TOAST_AUTO_CLOSE_MS,
|
||||||
TransferNotificationTypes,
|
TransferNotificationTypes,
|
||||||
|
ReleaseUpdateNotificationIds,
|
||||||
} from '@/constants/notifications';
|
} from '@/constants/notifications';
|
||||||
|
|
||||||
import { useStringGetter } from '@/hooks';
|
import { useStringGetter, useTokenConfigs } from '@/hooks';
|
||||||
import { useLocalNotifications } from '@/hooks/useLocalNotifications';
|
import { useLocalNotifications } from '@/hooks/useLocalNotifications';
|
||||||
|
|
||||||
import { AssetIcon } from '@/components/AssetIcon';
|
import { AssetIcon } from '@/components/AssetIcon';
|
||||||
@@ -238,13 +239,16 @@ export const notificationTypes: NotificationTypeConfig[] = [
|
|||||||
{
|
{
|
||||||
type: NotificationType.ReleaseUpdates,
|
type: NotificationType.ReleaseUpdates,
|
||||||
useTrigger: ({ trigger }) => {
|
useTrigger: ({ trigger }) => {
|
||||||
|
const { chainTokenLabel } = useTokenConfigs();
|
||||||
const stringGetter = useStringGetter();
|
const stringGetter = useStringGetter();
|
||||||
|
const expirationDate = new Date('2024-03-08T23:59:59');
|
||||||
|
const currentDate = new Date();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
trigger(
|
trigger(
|
||||||
'rewards-and-full-trading-live',
|
ReleaseUpdateNotificationIds.RewardsAndFullTradingLive,
|
||||||
{
|
{
|
||||||
icon: <AssetIcon symbol="DYDX" />,
|
icon: <AssetIcon symbol={chainTokenLabel} />,
|
||||||
title: stringGetter({ key: 'NOTIFICATIONS.RELEASE_REWARDS_AND_FULL_TRADING.TITLE' }),
|
title: stringGetter({ key: 'NOTIFICATIONS.RELEASE_REWARDS_AND_FULL_TRADING.TITLE' }),
|
||||||
body: stringGetter({
|
body: stringGetter({
|
||||||
key: 'NOTIFICATIONS.RELEASE_REWARDS_AND_FULL_TRADING.BODY',
|
key: 'NOTIFICATIONS.RELEASE_REWARDS_AND_FULL_TRADING.BODY',
|
||||||
@@ -270,14 +274,41 @@ export const notificationTypes: NotificationTypeConfig[] = [
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
toastSensitivity: 'foreground',
|
toastSensitivity: 'foreground',
|
||||||
groupKey: NotificationType.ReleaseUpdates,
|
groupKey: ReleaseUpdateNotificationIds.RewardsAndFullTradingLive,
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
if (currentDate <= expirationDate) {
|
||||||
|
trigger(
|
||||||
|
ReleaseUpdateNotificationIds.IncentivesS3,
|
||||||
|
{
|
||||||
|
icon: <AssetIcon symbol={chainTokenLabel} />,
|
||||||
|
title: stringGetter({ key: 'NOTIFICATIONS.INCENTIVES_SEASON_BEGUN.TITLE' }),
|
||||||
|
body: stringGetter({
|
||||||
|
key: 'NOTIFICATIONS.INCENTIVES_SEASON_BEGUN.BODY',
|
||||||
|
params: {
|
||||||
|
SEASON_NUMBER: '3',
|
||||||
|
PREV_SEASON_NUMBER: '1',
|
||||||
|
DYDX_AMOUNT: '34',
|
||||||
|
USDC_AMOUNT: '100',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
toastSensitivity: 'foreground',
|
||||||
|
groupKey: ReleaseUpdateNotificationIds.IncentivesS3,
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
}
|
||||||
}, [stringGetter]);
|
}, [stringGetter]);
|
||||||
},
|
},
|
||||||
useNotificationAction: () => {
|
useNotificationAction: () => {
|
||||||
return () => {};
|
const { chainTokenLabel } = useTokenConfigs();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
return (notificationId: string) => {
|
||||||
|
if (notificationId === ReleaseUpdateNotificationIds.IncentivesS3) {
|
||||||
|
navigate(`${chainTokenLabel}/${TokenRoute.TradingRewards}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
|
import { AnalyticsEvent } from '@/constants/analytics';
|
||||||
import { LOCAL_STORAGE_VERSIONS, LocalStorageKey } from '@/constants/localStorage';
|
import { LOCAL_STORAGE_VERSIONS, LocalStorageKey } from '@/constants/localStorage';
|
||||||
import {
|
import {
|
||||||
type Notification,
|
type Notification,
|
||||||
@@ -13,7 +14,8 @@ import {
|
|||||||
import { useLocalStorage } from './useLocalStorage';
|
import { useLocalStorage } from './useLocalStorage';
|
||||||
import { notificationTypes } from './useNotificationTypes';
|
import { notificationTypes } from './useNotificationTypes';
|
||||||
|
|
||||||
import { renderSvgToDataUrl } from '../lib/renderSvgToDataUrl';
|
import { track } from '@/lib/analytics';
|
||||||
|
import { renderSvgToDataUrl } from '@/lib/renderSvgToDataUrl';
|
||||||
|
|
||||||
type NotificationsContextType = ReturnType<typeof useNotificationsContext>;
|
type NotificationsContextType = ReturnType<typeof useNotificationsContext>;
|
||||||
|
|
||||||
@@ -48,6 +50,7 @@ const useNotificationsContext = () => {
|
|||||||
defaultValue: {
|
defaultValue: {
|
||||||
[NotificationType.AbacusGenerated]: true,
|
[NotificationType.AbacusGenerated]: true,
|
||||||
[NotificationType.SquidTransfer]: true,
|
[NotificationType.SquidTransfer]: true,
|
||||||
|
[NotificationType.ReleaseUpdates]: true,
|
||||||
version: LOCAL_STORAGE_VERSIONS[LocalStorageKey.NotificationPreferences],
|
version: LOCAL_STORAGE_VERSIONS[LocalStorageKey.NotificationPreferences],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -176,8 +179,10 @@ const useNotificationsContext = () => {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const onNotificationAction = async (notification: Notification) =>
|
const onNotificationAction = async (notification: Notification) => {
|
||||||
await actions[notification.type]?.(notification.id);
|
track(AnalyticsEvent.NotificationAction, { type: notification.type, id: notification.id });
|
||||||
|
return await actions[notification.type]?.(notification.id);
|
||||||
|
};
|
||||||
|
|
||||||
// Push notifications
|
// Push notifications
|
||||||
const [hasEnabledPush, setHasEnabledPush] = useLocalStorage({
|
const [hasEnabledPush, setHasEnabledPush] = useLocalStorage({
|
||||||
|
|||||||
Reference in New Issue
Block a user