From 4d5230cf05b98ccbf649bc7c6cb7c592b99fedd9 Mon Sep 17 00:00:00 2001 From: Riordan Panayides Date: Wed, 18 Jan 2023 13:13:29 +0000 Subject: [PATCH] Replace references to mango-transaction-log --- components/profile/EditNftProfilePic.tsx | 5 +++-- components/profile/EditProfileForm.tsx | 5 +++-- components/tours/CustomTooltip.tsx | 3 ++- components/trade/PerpFundingRate.tsx | 3 ++- store/mangoStore.ts | 21 +++++++++++---------- utils/constants.ts | 2 ++ 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/components/profile/EditNftProfilePic.tsx b/components/profile/EditNftProfilePic.tsx index b711d950..0a11b390 100644 --- a/components/profile/EditNftProfilePic.tsx +++ b/components/profile/EditNftProfilePic.tsx @@ -6,6 +6,7 @@ import { useTranslation } from 'next-i18next' import Button, { LinkButton } from '../shared/Button' import { bs58 } from '@project-serum/anchor/dist/cjs/utils/bytes' import { notify } from 'utils/notifications' +import { MANGO_DATA_API_URL } from 'utils/constants' const ImgWithLoader = (props: any) => { const [isLoading, setIsLoading] = useState(true) @@ -67,7 +68,7 @@ const EditNftProfilePic = ({ onClose }: { onClose: () => void }) => { }), } const response = await fetch( - 'https://mango-transaction-log.herokuapp.com/v4/user-data/profile-details', + `${MANGO_DATA_API_URL}/user-data/profile-details`, requestOptions ) if (response.status === 200) { @@ -113,7 +114,7 @@ const EditNftProfilePic = ({ onClose }: { onClose: () => void }) => { }), } const response = await fetch( - 'https://mango-transaction-log.herokuapp.com/v4/user-data/profile-details', + `${MANGO_DATA_API_URL}/user-data/profile-details`, requestOptions ) if (response.status === 200) { diff --git a/components/profile/EditProfileForm.tsx b/components/profile/EditProfileForm.tsx index 6d238d91..5d268824 100644 --- a/components/profile/EditProfileForm.tsx +++ b/components/profile/EditProfileForm.tsx @@ -14,6 +14,7 @@ import mangoStore from '@store/mangoStore' import startCase from 'lodash/startCase' import { useTranslation } from 'next-i18next' import { ChangeEvent, useState } from 'react' +import { MANGO_DATA_API_URL } from 'utils/constants' import { notify } from 'utils/notifications' import ProfileImage from './ProfileImage' @@ -42,7 +43,7 @@ const EditProfileForm = ({ try { setLoadUniquenessCheck(true) const response = await fetch( - `https://mango-transaction-log.herokuapp.com/v4/user-data/check-profile-name-unique?profile-name=${name}` + `${MANGO_DATA_API_URL}/user-data/check-profile-name-unique?profile-name=${name}` ) const uniquenessCheck = await response.json() @@ -103,7 +104,7 @@ const EditProfileForm = ({ }), } const response = await fetch( - 'https://mango-transaction-log.herokuapp.com/v4/user-data/profile-details', + `${MANGO_DATA_API_URL}/user-data/profile-details`, requestOptions ) if (response.status === 200) { diff --git a/components/tours/CustomTooltip.tsx b/components/tours/CustomTooltip.tsx index cf5313f0..d35b433a 100644 --- a/components/tours/CustomTooltip.tsx +++ b/components/tours/CustomTooltip.tsx @@ -3,6 +3,7 @@ import { XMarkIcon } from '@heroicons/react/20/solid' import { useWallet } from '@solana/wallet-adapter-react' import mangoStore from '@store/mangoStore' import { useState } from 'react' +import { MANGO_DATA_API_URL } from 'utils/constants' import { WalktourLogic } from 'walktour' const CustomTooltip = ({ @@ -37,7 +38,7 @@ const CustomTooltip = ({ body: message, } const response = await fetch( - 'https://mango-transaction-log.herokuapp.com/v4/user-data/settings-unsigned', + `${MANGO_DATA_API_URL}/user-data/settings-unsigned`, requestOptions ) if (response.status === 200) { diff --git a/components/trade/PerpFundingRate.tsx b/components/trade/PerpFundingRate.tsx index 13a8fb5e..4cf18363 100644 --- a/components/trade/PerpFundingRate.tsx +++ b/components/trade/PerpFundingRate.tsx @@ -5,10 +5,11 @@ import { useQuery } from '@tanstack/react-query' import useMangoGroup from 'hooks/useMangoGroup' import useSelectedMarket from 'hooks/useSelectedMarket' import { useMemo } from 'react' +import { MANGO_DATA_API_URL } from 'utils/constants' const fetchFundingRate = async (groupPk: string | undefined) => { const res = await fetch( - `https://mango-transaction-log.herokuapp.com/v4/one-hour-funding-rate?mango-group=${groupPk}` + `${MANGO_DATA_API_URL}/one-hour-funding-rate?mango-group=${groupPk}` ) return await res.json() } diff --git a/store/mangoStore.ts b/store/mangoStore.ts index f8c13c4a..22bfc3d8 100644 --- a/store/mangoStore.ts +++ b/store/mangoStore.ts @@ -33,6 +33,7 @@ import { DEFAULT_MARKET_NAME, INPUT_TOKEN_DEFAULT, LAST_ACCOUNT_KEY, + MANGO_DATA_API_URL, OUTPUT_TOKEN_DEFAULT, RPC_PROVIDER_KEY, } from '../utils/constants' @@ -461,7 +462,7 @@ const mangoStore = create()( }) try { const response = await fetch( - `https://mango-transaction-log.herokuapp.com/v4/stats/interest-account-total?mango-account=${mangoAccountPk}` + `${MANGO_DATA_API_URL}/stats/interest-account-total?mango-account=${mangoAccountPk}` ) const parsedResponse = await response.json() const entries: any = Object.entries(parsedResponse).sort((a, b) => @@ -498,7 +499,7 @@ const mangoStore = create()( }) try { const response = await fetch( - `https://mango-transaction-log.herokuapp.com/v4/stats/performance_account?mango-account=${mangoAccountPk}&start-date=${dayjs() + `${MANGO_DATA_API_URL}/stats/performance_account?mango-account=${mangoAccountPk}&start-date=${dayjs() .subtract(range, 'day') .format('YYYY-MM-DD')}` ) @@ -541,7 +542,7 @@ const mangoStore = create()( try { const response = await fetch( - `https://mango-transaction-log.herokuapp.com/v4/stats/activity-feed?mango-account=${mangoAccountPk}&offset=${offset}&limit=25${ + `${MANGO_DATA_API_URL}/stats/activity-feed?mango-account=${mangoAccountPk}&offset=${offset}&limit=25${ params ? params : '' }` ) @@ -817,7 +818,7 @@ const mangoStore = create()( }) try { const response = await fetch( - `https://mango-transaction-log.herokuapp.com/v4/perp-historical-stats?mango-group=${group?.publicKey.toString()}` + `${MANGO_DATA_API_URL}/perp-historical-stats?mango-group=${group?.publicKey.toString()}` ) const data = await response.json() @@ -840,7 +841,7 @@ const mangoStore = create()( setTimeout(async () => { try { const history = await fetch( - `https://mango-transaction-log.herokuapp.com/v4/stats/swap-history?mango-account=${mangoAccountPk}` + `${MANGO_DATA_API_URL}/stats/swap-history?mango-account=${mangoAccountPk}` ) const parsedHistory = await history.json() const sortedHistory = @@ -876,7 +877,7 @@ const mangoStore = create()( }) try { const response = await fetch( - `https://mango-transaction-log.herokuapp.com/v4/token-historical-stats?mango-group=${group?.publicKey.toString()}` + `${MANGO_DATA_API_URL}/token-historical-stats?mango-group=${group?.publicKey.toString()}` ) const data = await response.json() @@ -945,7 +946,7 @@ const mangoStore = create()( }) try { const response = await fetch( - `https://mango-transaction-log.herokuapp.com/v4/user-data/profile-details?wallet-pk=${walletPk}` + `${MANGO_DATA_API_URL}/user-data/profile-details?wallet-pk=${walletPk}` ) const data = await response.json() set((state) => { @@ -967,7 +968,7 @@ const mangoStore = create()( }) try { const response = await fetch( - `https://mango-transaction-log.herokuapp.com/v4/user-data/settings-unsigned?wallet-pk=${walletPk}` + `${MANGO_DATA_API_URL}/user-data/settings-unsigned?wallet-pk=${walletPk}` ) const data = await response.json() set((state) => { @@ -1021,10 +1022,10 @@ const mangoStore = create()( try { const [spotRes, perpRes] = await Promise.all([ fetch( - `https://mango-transaction-log.herokuapp.com/v4/stats/openbook-trades?address=${mangoAccount?.publicKey.toString()}&address-type=mango-account` + `${MANGO_DATA_API_URL}/stats/openbook-trades?address=${mangoAccount?.publicKey.toString()}&address-type=mango-account` ), fetch( - `https://mango-transaction-log.herokuapp.com/v4/stats/perp-trade-history?mango-account=${mangoAccount?.publicKey.toString()}&limit=1000` + `${MANGO_DATA_API_URL}/stats/perp-trade-history?mango-account=${mangoAccount?.publicKey.toString()}&limit=1000` ), ]) const spotHistory = await spotRes.json() diff --git a/utils/constants.ts b/utils/constants.ts index 1a19ddab..13421363 100644 --- a/utils/constants.ts +++ b/utils/constants.ts @@ -60,6 +60,8 @@ export const CHART_DATA_FEED = `https://dry-ravine-67635.herokuapp.com/tv` export const MANGO_ROUTER_API_URL = 'https://api.mngo.cloud/router/v1' +export const MANGO_DATA_API_URL = 'https://api.mngo.cloud/data/v4' + export const DEFAULT_MARKET_NAME = 'SOL/USDC' export const MIN_SOL_BALANCE = 0.001