From 98894c26da3d05f4d5fce1cd0c28738ebebbc33a Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 25 Jan 2024 19:22:57 -0500 Subject: [PATCH] added default pair env --- .env.example | 3 ++- src/app/components/PairSelector.tsx | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 18aedf7d..c42ecd74 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ NEXT_PUBLIC_NETWORK=stokenet # Options: mainnet or stokenet -NEXT_PUBLIC_DAPP_DEFINITION_ADDRESS=account_tdx_2_129kev9w27tsl7qjg0dlyze70kxnlzycs8v2c85kzec40gg8mt73f7y \ No newline at end of file +NEXT_PUBLIC_DAPP_DEFINITION_ADDRESS=account_tdx_2_129kev9w27tsl7qjg0dlyze70kxnlzycs8v2c85kzec40gg8mt73f7y +NEXT_PUBLIC_DEFAULT_PAIR_ADDRESS= \ No newline at end of file diff --git a/src/app/components/PairSelector.tsx b/src/app/components/PairSelector.tsx index 859a6792..94c4ddc4 100644 --- a/src/app/components/PairSelector.tsx +++ b/src/app/components/PairSelector.tsx @@ -1,14 +1,14 @@ import { useAppSelector, useAppDispatch } from "../hooks"; import { selectPairAddress } from "../state/pairSelectorSlice"; import { orderInputSlice } from "../state/orderInputSlice"; -import { useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; interface PairInfo { name: string; address: string; } function displayName(name?: string) { - return name?.replace("/", " - "); + return name?.replace("/", " - ").toUpperCase(); } export function PairSelector() { @@ -18,6 +18,14 @@ export function PairSelector() { const options = pairSelector.pairsList; const id = "pairOption"; + useEffect(() => { + if (process.env.NEXT_PUBLIC_DEFAULT_PAIR_ADDRESS != "") { + dispatch( + selectPairAddress(process.env.NEXT_PUBLIC_DEFAULT_PAIR_ADDRESS || "") + ); + } + }, [dispatch]); + const handleChange = (val: PairInfo | null) => { if (val == null) return;