From 36cbbb26343d791faab8c73dc7b8db644c648da5 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Mon, 6 Jan 2025 16:05:27 -0800 Subject: [PATCH] Updating environmental vars --- README.md | 14 +++++++++++--- src/routes/[network]/+layout.svelte | 9 +++------ .../api/metrics/marketprice/ram/+server.ts | 7 +++++-- .../api/metrics/marketprice/token/+server.ts | 7 +++++-- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9e725aa7..19842035 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 2 Unicove 2 Furious +# Unicove 2.0 ![inspiration](https://i.ibb.co/2nbtvms/image-1.png) @@ -9,7 +9,13 @@ Clone this repo and run `bun install` to install the dependencies. Add a `.env` file to the root of the project with the following content: ``` +# Specify environment Unicove is operating in +PUBLIC_ENVIRONMENT="development" + +# Optional Private Key of testnet account for use with the WalletPluginPrivateKey PUBLIC_LOCAL_SIGNER="" + +# APIs for supported networks API_EOS_HISTORY=https://eos.greymass.com API_EOS_CHAIN=https://eos.greymass.com API_EOS_LIGHTAPI=https://eos.light-api.net @@ -17,8 +23,10 @@ API_JUNGLE4_HISTORY=https://jungle4.greymass.com API_JUNGLE4_CHAIN=https://jungle4.greymass.com API_KYLIN_HISTORY=https://kylintestnet.greymass.com API_KYLIN_CHAIN=https://kylintestnet.greymass.com -``` -Add your private key in there if you want to enable the local Private Key Signer instead of using Anchor for each test transaction. +# EOS Wallet for MetaMask +PUBLIC_METAMASK_SNAP_ORIGIN=npm:@greymass/eos-wallet +PUBLIC_METAMASK_SERVICE_URL=https://dev.account-creation-portal.pages.dev/buy +``` Run `bun dev` to start the development server then visit `http://localhost:5173` diff --git a/src/routes/[network]/+layout.svelte b/src/routes/[network]/+layout.svelte index d7720f67..80d8a51d 100644 --- a/src/routes/[network]/+layout.svelte +++ b/src/routes/[network]/+layout.svelte @@ -3,10 +3,7 @@ import { chainLogos } from '@wharfkit/common'; import { onMount, setContext, untrack } from 'svelte'; import X from 'lucide-svelte/icons/circle-x'; - import { - PUBLIC_ACCOUNT_UPDATE_INTERVAL, - PUBLIC_NETWORK_UPDATE_INTERVAL - } from '$env/static/public'; + import * as env from '$env/static/public'; import type { UnicoveContext } from '$lib/state/client.svelte'; import { AccountState } from '$lib/state/client/account.svelte.js'; @@ -105,8 +102,8 @@ }); // Number of ms between network updates - const ACCOUNT_UPDATE_INTERVAL = Number(PUBLIC_ACCOUNT_UPDATE_INTERVAL) || 3_000; - const NETWORK_UPDATE_INTERVAL = Number(PUBLIC_NETWORK_UPDATE_INTERVAL) || 3_000; + const ACCOUNT_UPDATE_INTERVAL = Number(env.PUBLIC_ACCOUNT_UPDATE_INTERVAL) || 3_000; + const NETWORK_UPDATE_INTERVAL = Number(env.PUBLIC_NETWORK_UPDATE_INTERVAL) || 3_000; // Default to not show a banner (avoids flash of banner when hidden) let showBanner = $state(false); diff --git a/src/routes/[network]/api/metrics/marketprice/ram/+server.ts b/src/routes/[network]/api/metrics/marketprice/ram/+server.ts index 468306fa..3345ca30 100644 --- a/src/routes/[network]/api/metrics/marketprice/ram/+server.ts +++ b/src/routes/[network]/api/metrics/marketprice/ram/+server.ts @@ -24,6 +24,9 @@ export const GET: RequestHandler = async ({ params }) => { try { const chain = getChainDefinitionFromParams(params.network); const metricsUrl = getMetricsUrl(chain); + if (!metricsUrl) { + return json([]); + } const response = await fetch(`${metricsUrl}/marketprice/ram/1h/7d`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); @@ -39,7 +42,7 @@ export const GET: RequestHandler = async ({ params }) => { headers: getCacheHeaders(30) }); } catch (error) { - console.error('Error fetching historical RAM prices:', error); - return json({ error: 'Failed to fetch RAM price history' }, { status: 500 }); + console.log(error); + return json([]); } }; diff --git a/src/routes/[network]/api/metrics/marketprice/token/+server.ts b/src/routes/[network]/api/metrics/marketprice/token/+server.ts index 286e21aa..150d965b 100644 --- a/src/routes/[network]/api/metrics/marketprice/token/+server.ts +++ b/src/routes/[network]/api/metrics/marketprice/token/+server.ts @@ -24,6 +24,9 @@ export const GET: RequestHandler = async ({ params }) => { try { const chain = getChainDefinitionFromParams(params.network); const metricsUrl = getMetricsUrl(chain); + if (!metricsUrl) { + return json([]); + } const response = await fetch(`${metricsUrl}/marketprice/eosusd/1h/7d`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); @@ -39,7 +42,7 @@ export const GET: RequestHandler = async ({ params }) => { headers: getCacheHeaders(30) }); } catch (error) { - console.error('Error fetching historical system token prices:', error); - return json({ error: 'Failed to fetch system token price history' }, { status: 500 }); + console.log(error); + return json([]); } };