From 5434fd7c7eb6c09d0319ac53abe14db45f11c5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Ho=C3=A0i=20Danh?= <33005392+nguyenhoaidanh@users.noreply.github.com> Date: Thu, 14 Sep 2023 10:09:40 +0700 Subject: [PATCH] update: api crosschain (#2233) * improve save ack ann * update api domain * update state --- src/components/Announcement/helper.ts | 9 +++++++-- src/constants/env.ts | 2 +- src/hooks/useChainsConfig.ts | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/Announcement/helper.ts b/src/components/Announcement/helper.ts index c2791fd96e..1dd590f0cb 100644 --- a/src/components/Announcement/helper.ts +++ b/src/components/Announcement/helper.ts @@ -4,6 +4,7 @@ import { useNavigate } from 'react-router-dom' import AnnouncementApi from 'services/announcement' import { AnnouncementTemplatePopup, PopupContentAnnouncement, PopupItemType } from 'components/Announcement/type' +import { TIMES_IN_SECS } from 'constants/index' import { useActiveWeb3React } from 'hooks' import { useChangeNetwork } from 'hooks/web3/useChangeNetwork' import { useAppDispatch } from 'state/hooks' @@ -13,11 +14,15 @@ export const getAnnouncementsAckMap = () => JSON.parse(localStorage[LsKey] || '{ export const ackAnnouncementPopup = (id: string | number) => { const announcementsMap = getAnnouncementsAckMap() + const entries = Object.entries(announcementsMap).filter( + // keep only ids that was added in the last 30 days + ([_, value]) => typeof value === 'number' && Date.now() - value < TIMES_IN_SECS.ONE_DAY * 30 * 1000, + ) localStorage.setItem( LsKey, JSON.stringify({ - ...announcementsMap, - [id]: '1', + ...Object.fromEntries(entries), + [id]: Date.now(), }), ) } diff --git a/src/constants/env.ts b/src/constants/env.ts index 52f1659970..378da69d50 100644 --- a/src/constants/env.ts +++ b/src/constants/env.ts @@ -161,6 +161,6 @@ export const MOCK_ACCOUNT_SOLANA = mock[1] ?? '' const isSupportTestNet = ENV_LEVEL < ENV_TYPE.PROD && new URLSearchParams(window.location.search).get('test') export const CROSS_CHAIN_CONFIG = { AXELAR_SCAN_URL: isSupportTestNet ? 'https://testnet.axelarscan.io/gmp/' : 'https://axelarscan.io/gmp/', - API_DOMAIN: isSupportTestNet ? 'https://testnet.api.0xsquid.com' : 'https://api.0xsquid.com', + API_DOMAIN: isSupportTestNet ? 'https://testnet.api.0xsquid.com' : 'https://api.squidrouter.com', INTEGRATOR_ID: 'kyberswap-api', } diff --git a/src/hooks/useChainsConfig.ts b/src/hooks/useChainsConfig.ts index 2cffb5e7bd..b522619af0 100644 --- a/src/hooks/useChainsConfig.ts +++ b/src/hooks/useChainsConfig.ts @@ -10,7 +10,7 @@ export enum ChainState { NEW = 'new', ACTIVE = 'active', INACTIVE = 'inactive', - MAINTENANCE = 'maintainain', + MAINTENANCE = 'maintained', } export type ChainStateMap = { [chain in ChainId]: ChainState }