From 541abac2f9dbdf795e4ab8a80008df50839e56d8 Mon Sep 17 00:00:00 2001 From: Kieran Gillen Date: Thu, 24 Mar 2022 18:03:12 +0100 Subject: [PATCH 1/4] Adds MangoAccountSearch --- .../account_page/MangoAccountSearch.tsx | 60 +++++++++++++++++++ pages/account.tsx | 6 ++ 2 files changed, 66 insertions(+) create mode 100644 components/account_page/MangoAccountSearch.tsx diff --git a/components/account_page/MangoAccountSearch.tsx b/components/account_page/MangoAccountSearch.tsx new file mode 100644 index 00000000..0e6b88d3 --- /dev/null +++ b/components/account_page/MangoAccountSearch.tsx @@ -0,0 +1,60 @@ +import { PublicKey } from '@solana/web3.js' +import Button from 'components/Button' +import Input from 'components/Input' +import { useRouter } from 'next/router' +import React, { useState } from 'react' +import { ExclamationCircleIcon } from '@heroicons/react/outline' + +export const MangoAccountSearch = () => { + const router = useRouter() + const [value, setValue] = useState('') + const [isInvalid, setIsInvalid] = useState(false) + + const validatePubKey = (key: string) => { + try { + const pubkey = new PublicKey(key) + return PublicKey.isOnCurve(pubkey.toBuffer()) + } catch (e) { + return false + } + } + + const onClickSearch = () => { + const isValid = validatePubKey(value) + + if (isValid) { + const route = `/account?pubkey=${value}` + setValue('') + router.push(route) + } else { + setIsInvalid(true) + } + } + + return ( +
+

Search by Mango Account

+

+ Enter a Mango account address to show account details +

+
+ setValue(e.target.value)} + /> +
+ {isInvalid && ( +
+ + The address is invalid +
+ )} +
+ +
+
+ ) +} diff --git a/pages/account.tsx b/pages/account.tsx index 17fd13ec..b200526c 100644 --- a/pages/account.tsx +++ b/pages/account.tsx @@ -55,6 +55,7 @@ import CreateAlertModal from '../components/CreateAlertModal' import { copyToClipboard } from '../utils' import DelegateModal from '../components/DelegateModal' import { Menu, Transition } from '@headlessui/react' +import { MangoAccountSearch } from 'components/account_page/MangoAccountSearch' export async function getStaticProps({ locale }) { return { @@ -444,6 +445,11 @@ export default function Account() { /> )} + {!connected && ( +
+ +
+ )} {showAccountsModal ? ( Date: Thu, 24 Mar 2022 18:09:18 +0100 Subject: [PATCH 2/4] Updates spacing on MangoAccountSearch --- components/account_page/MangoAccountSearch.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/account_page/MangoAccountSearch.tsx b/components/account_page/MangoAccountSearch.tsx index 0e6b88d3..cab4508a 100644 --- a/components/account_page/MangoAccountSearch.tsx +++ b/components/account_page/MangoAccountSearch.tsx @@ -32,12 +32,12 @@ export const MangoAccountSearch = () => { } return ( -
+

Search by Mango Account

Enter a Mango account address to show account details

-
+
Date: Thu, 24 Mar 2022 19:49:27 +0100 Subject: [PATCH 3/4] Removes z-index on Jupiter form --- components/JupiterForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/JupiterForm.tsx b/components/JupiterForm.tsx index 9989a232..f1084d2b 100644 --- a/components/JupiterForm.tsx +++ b/components/JupiterForm.tsx @@ -352,7 +352,7 @@ const JupiterForm: FunctionComponent = () => {
-
+
{connected && walletTokensWithInfos.length && walletTokenPrices && From 43fa225645631cd7f2c7d219da1e34b7aa8e82ff Mon Sep 17 00:00:00 2001 From: tjs Date: Thu, 24 Mar 2022 15:52:42 -0400 Subject: [PATCH 4/4] fix date component --- components/TradeHistoryTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/TradeHistoryTable.tsx b/components/TradeHistoryTable.tsx index 764134ac..bebcecc5 100644 --- a/components/TradeHistoryTable.tsx +++ b/components/TradeHistoryTable.tsx @@ -29,7 +29,7 @@ const formatTradeDateTime = (timestamp: BN | string) => { if (typeof timestamp === 'string') { return timestamp } else { - return (timestamp.toNumber() * 1000).toString() + return timestamp.toNumber() * 1000 } }