diff --git a/dapp/.env b/dapp/.env index 60e4f4a3b..339cf4e95 100644 --- a/dapp/.env +++ b/dapp/.env @@ -17,8 +17,6 @@ VITE_ACRE_API_ENDPOINT="http://localhost:8788/api/v1/" VITE_GELATO_RELAY_API_KEY="htaJCy_XHj8WsE3w53WBMurfySDtjLP_TrNPPa6IPIc_" # this key should not be used on production # Get the API key from: https://thegraph.com/studio/apikeys/. VITE_SUBGRAPH_API_KEY="" -# Get the API key from: 1Password. -VITE_MEZO_PORTAL_API_KEY="" # Feature flags VITE_FEATURE_FLAG_GAMIFICATION_ENABLED="false" diff --git a/dapp/src/constants/env.ts b/dapp/src/constants/env.ts index d2b31b236..034bd01a9 100644 --- a/dapp/src/constants/env.ts +++ b/dapp/src/constants/env.ts @@ -16,8 +16,6 @@ const GELATO_RELAY_API_KEY = import.meta.env.VITE_GELATO_RELAY_API_KEY const SUBGRAPH_API_KEY = import.meta.env.VITE_SUBGRAPH_API_KEY -const MEZO_PORTAL_API_KEY = import.meta.env.VITE_MEZO_PORTAL_API_KEY - const NETWORK_TYPE = USE_TESTNET ? "testnet" : "mainnet" const LATEST_COMMIT_HASH = import.meta.env.VITE_LATEST_COMMIT_HASH @@ -34,7 +32,6 @@ export default { TBTC_API_ENDPOINT, GELATO_RELAY_API_KEY, SUBGRAPH_API_KEY, - MEZO_PORTAL_API_KEY, NETWORK_TYPE, LATEST_COMMIT_HASH, ACRE_API_ENDPOINT, diff --git a/dapp/src/hooks/useMats.ts b/dapp/src/hooks/useMats.ts index c242e485b..fe62d63f2 100644 --- a/dapp/src/hooks/useMats.ts +++ b/dapp/src/hooks/useMats.ts @@ -1,13 +1,13 @@ import { useQuery } from "@tanstack/react-query" import { REFETCH_INTERVAL_IN_MILLISECONDS, queryKeysFactory } from "#/constants" -import { mezoPortalAPI } from "#/utils" +import { acreApi } from "#/utils" const { acreKeys } = queryKeysFactory export default function useMats() { return useQuery({ queryKey: [...acreKeys.mats()], - queryFn: async () => mezoPortalAPI.getMats(), + queryFn: async () => acreApi.getMats(), refetchInterval: REFETCH_INTERVAL_IN_MILLISECONDS, }) } diff --git a/dapp/src/store/btc/btcThunk.ts b/dapp/src/store/btc/btcThunk.ts index f6371b53d..87f121201 100644 --- a/dapp/src/store/btc/btcThunk.ts +++ b/dapp/src/store/btc/btcThunk.ts @@ -1,17 +1,7 @@ import { createAsyncThunk } from "@reduxjs/toolkit" -import { fetchCryptoCurrencyPriceUSD } from "#/utils/exchangeApi" -import sentry from "#/sentry" +import { acreApi } from "#/utils" export const fetchBTCPriceUSD = createAsyncThunk( "btc/fetchBTCPriceUSD", - async () => { - try { - const priceUSD = await fetchCryptoCurrencyPriceUSD("bitcoin") - return priceUSD - } catch (error) { - sentry.captureException(error) - console.error(error) - return 0 - } - }, + async () => acreApi.getBtcUsdPrice(), ) diff --git a/dapp/src/types/coingecko.ts b/dapp/src/types/coingecko.ts deleted file mode 100644 index 5d43c6fdc..000000000 --- a/dapp/src/types/coingecko.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type CoingeckoIdType = "bitcoin" -export type CoingeckoCurrencyType = "usd" diff --git a/dapp/src/types/index.ts b/dapp/src/types/index.ts index 5411acd06..c67a3683b 100644 --- a/dapp/src/types/index.ts +++ b/dapp/src/types/index.ts @@ -4,7 +4,6 @@ export * from "./callback" export * from "./chain" export * from "./action-flow" export * from "./activity" -export * from "./coingecko" export * from "./time" export * from "./core" export * from "./fee" diff --git a/dapp/src/utils/acreApi.ts b/dapp/src/utils/acreApi.ts index a5836d9b3..bf1b7ca17 100644 --- a/dapp/src/utils/acreApi.ts +++ b/dapp/src/utils/acreApi.ts @@ -82,6 +82,22 @@ const claimPoints = async (address: string) => { } } +async function getMats() { + const response = await axios.get<{ totalMats: number; dailyMats: number }>( + "mezo/points", + ) + + return { + totalMats: response.data.totalMats, + dailyMats: response.data.dailyMats, + } +} + +async function getBtcUsdPrice(): Promise { + const response = await axios.get<{ btcUsdPrice: number }>("currency/btc") + return response.data.btcUsdPrice +} + export default { createSession, getSession, @@ -89,4 +105,6 @@ export default { getPointsData, getPointsDataByUser, claimPoints, + getMats, + getBtcUsdPrice, } diff --git a/dapp/src/utils/exchangeApi.ts b/dapp/src/utils/exchangeApi.ts deleted file mode 100644 index 2f83c4ebf..000000000 --- a/dapp/src/utils/exchangeApi.ts +++ /dev/null @@ -1,20 +0,0 @@ -import axios from "axios" -import { CoingeckoIdType, CoingeckoCurrencyType } from "#/types" - -const coingeckoApiURL = "https://api.coingecko.com/api/v3" - -type CoingeckoSimplePriceResponse = { - data: { - [id in CoingeckoIdType]: Record - } -} - -export const fetchCryptoCurrencyPriceUSD = async ( - coingeckoId: CoingeckoIdType, -): Promise => { - const response: CoingeckoSimplePriceResponse = await axios.get( - `${coingeckoApiURL}/simple/price?ids=${coingeckoId}&vs_currencies=usd`, - ) - - return response.data[coingeckoId].usd -} diff --git a/dapp/src/utils/index.ts b/dapp/src/utils/index.ts index 3154265d9..dd28bfd8f 100644 --- a/dapp/src/utils/index.ts +++ b/dapp/src/utils/index.ts @@ -6,7 +6,6 @@ export * from "./chain" export * from "./text" export * from "./time" export * from "./promise" -export * from "./exchangeApi" export * from "./verifyDepositAddress" export * from "./json" export * from "./activities" @@ -15,6 +14,5 @@ export { default as eip1193 } from "./eip1193" export { default as orangeKit } from "./orangeKit" export { default as userAgent } from "./userAgent" export { default as referralProgram } from "./referralProgram" -export { default as mezoPortalAPI } from "./mezoPortalApi" export { default as acreApi } from "./acreApi" export { default as router } from "./router" diff --git a/dapp/src/utils/mezoPortalApi.ts b/dapp/src/utils/mezoPortalApi.ts deleted file mode 100644 index 4897154bd..000000000 --- a/dapp/src/utils/mezoPortalApi.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { env } from "#/constants" -import axios from "axios" - -export const endpoint = env.USE_TESTNET - ? "https://portal.api.test.mezo.org/api/v1" - : "https://portal.api.mezo.org/api/v1" - -async function getMats() { - try { - const url = `${endpoint}/acre` - const response = await axios.get<{ totalMats: number; dailyMats: number }>( - url, - { - headers: { Authorization: `Bearer ${env.MEZO_PORTAL_API_KEY}` }, - }, - ) - - return response.data - } catch (error) { - console.error(error) - throw error - } -} - -export default { - getMats, -} diff --git a/dapp/src/vite-env.d.ts b/dapp/src/vite-env.d.ts index 3236c085e..0f4174de1 100644 --- a/dapp/src/vite-env.d.ts +++ b/dapp/src/vite-env.d.ts @@ -15,7 +15,6 @@ interface ImportMetaEnv { readonly VITE_FEATURE_FLAG_ACRE_POINTS_ENABLED: string readonly VITE_FEATURE_FLAG_TVL_ENABLED: string readonly VITE_SUBGRAPH_API_KEY: string - readonly VITE_MEZO_PORTAL_API_KEY: string readonly VITE_LATEST_COMMIT_HASH: string readonly VITE_ACRE_API_ENDPOINT: string }