From 28d3be037086cb88db6c0a10ad0028e074f42029 Mon Sep 17 00:00:00 2001 From: aleka Date: Tue, 28 Nov 2023 12:36:29 -0500 Subject: [PATCH] Release notification (#169) * add release notif --- package.json | 2 +- pnpm-lock.yaml | 16 ++++---- src/constants/notifications.ts | 1 + src/hooks/useNotificationTypes.tsx | 50 +++++++++++++++++++++++++ src/hooks/useNotifications.tsx | 1 + src/views/dialogs/PreferencesDialog.tsx | 12 ++++++ 6 files changed, 73 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 88cc91f..e702766 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@cosmjs/tendermint-rpc": "^0.31.0", "@dydxprotocol/v4-abacus": "^1.0.30", "@dydxprotocol/v4-client-js": "^1.0.0", - "@dydxprotocol/v4-localization": "^1.0.6", + "@dydxprotocol/v4-localization": "^1.0.8", "@ethersproject/providers": "^5.7.2", "@js-joda/core": "^5.5.3", "@radix-ui/react-checkbox": "^1.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2aae971..a855c47 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,9 +1,5 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - dependencies: '@0xsquid/sdk': specifier: ^1.10.0 @@ -33,8 +29,8 @@ dependencies: specifier: ^1.0.0 version: 1.0.0 '@dydxprotocol/v4-localization': - specifier: ^1.0.6 - version: 1.0.6 + specifier: ^1.0.8 + version: 1.0.8 '@ethersproject/providers': specifier: ^5.7.2 version: 5.7.2 @@ -1020,8 +1016,8 @@ packages: - utf-8-validate dev: false - /@dydxprotocol/v4-localization@1.0.6: - resolution: {integrity: sha512-nv/QBKKwixBmhjYmRbA4kSMFznjzYk0MDW8Lq/ht2AUGDnUiBDztxFgYDlxzbf14+1w967NIP0N77GaAZKiFyg==} + /@dydxprotocol/v4-localization@1.0.8: + resolution: {integrity: sha512-h5CSkWHPct1BWmiwJBeX9vOauXSwlx8RK9ryOsaCipJWS4AnBni07p3/jj3L/HgmU1BZXwfcr2hBouXVxxZS8A==} dev: false /@dydxprotocol/v4-proto@0.4.1: @@ -14140,3 +14136,7 @@ packages: /zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} dev: true + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false diff --git a/src/constants/notifications.ts b/src/constants/notifications.ts index 333a0a4..2bae6d5 100644 --- a/src/constants/notifications.ts +++ b/src/constants/notifications.ts @@ -4,6 +4,7 @@ import { StatusResponse } from '@0xsquid/sdk'; export enum NotificationType { AbacusGenerated = 'AbacusGenerated', SquidTransfer = 'SquidTransfer', + ReleaseUpdates = 'ReleaseUpdates', } export enum NotificationComponentType {} diff --git a/src/hooks/useNotificationTypes.tsx b/src/hooks/useNotificationTypes.tsx index c5a340b..9c89321 100644 --- a/src/hooks/useNotificationTypes.tsx +++ b/src/hooks/useNotificationTypes.tsx @@ -25,6 +25,7 @@ import { import { useSelectedNetwork, useStringGetter } from '@/hooks'; import { useLocalNotifications } from '@/hooks/useLocalNotifications'; +import { AssetIcon } from '@/components/AssetIcon'; import { Icon, IconName } from '@/components/Icon'; import { TradeNotification } from '@/views/notifications/TradeNotification'; import { TransferStatusNotification } from '@/views/notifications/TransferStatusNotification'; @@ -205,9 +206,58 @@ export const notificationTypes: NotificationTypeConfig[] = [ return () => {}; }, }, + { + type: NotificationType.ReleaseUpdates, + useTrigger: ({ trigger }) => { + const stringGetter = useStringGetter(); + + useEffect(() => { + trigger( + 'rewards-and-full-trading-live', + { + icon: , + title: stringGetter({ key: 'NOTIFICATIONS.RELEASE_REWARDS_AND_FULL_TRADING.TITLE' }), + body: stringGetter({ + key: 'NOTIFICATIONS.RELEASE_REWARDS_AND_FULL_TRADING.BODY', + params: { + BLOGPOST: ( + <$Link + href="https://www.dydxopsdao.com/blog/deep-dive-full-trading" + target="_blank" + rel="noopener noreferrer" + > + {stringGetter({ key: STRING_KEYS.HERE })} + + ), + // todo: update localization to flip the two + DOS_BLOGPOST: ( + <$Link + href="https://dydx.exchange/blog/v4-full-trading" + target="_blank" + rel="noopener noreferrer" + > + {stringGetter({ key: STRING_KEYS.HERE })} + + ), + }, + }), + toastSensitivity: 'foreground', + }, + [] + ); + }, [stringGetter]); + }, + useNotificationAction: () => { + return () => {}; + }, + }, ]; const $Icon = styled.img` height: 1.5rem; width: 1.5rem; `; + +const $Link = styled.a` + --link-color: var(--color-text-2); +`; diff --git a/src/hooks/useNotifications.tsx b/src/hooks/useNotifications.tsx index 3c12b8b..863d0df 100644 --- a/src/hooks/useNotifications.tsx +++ b/src/hooks/useNotifications.tsx @@ -81,6 +81,7 @@ const useNotificationsContext = () => { setNotificationPreferences({ [NotificationType.AbacusGenerated]: true, [NotificationType.SquidTransfer]: true, + [NotificationType.ReleaseUpdates]: true, version: LOCAL_STORAGE_VERSIONS[LocalStorageKey.NotificationPreferences], }); } diff --git a/src/views/dialogs/PreferencesDialog.tsx b/src/views/dialogs/PreferencesDialog.tsx index 1d06f7b..8562eb9 100644 --- a/src/views/dialogs/PreferencesDialog.tsx +++ b/src/views/dialogs/PreferencesDialog.tsx @@ -53,6 +53,18 @@ export const usePreferenceMenu = () => { ), onSelect: () => toggleNotifPreference(NotificationType.SquidTransfer), }, + { + value: NotificationType.ReleaseUpdates, + label: "Release Updates", + slotAfter: ( + null} + /> + ), + onSelect: () => toggleNotifPreference(NotificationType.ReleaseUpdates), + } ], }), [stringGetter, enabledNotifs]