Merge branch 'main' into kierangillen/wallet-updates

This commit is contained in:
tjshipe 2022-03-24 15:59:28 -04:00 committed by GitHub
commit f094dd2208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 2 deletions

View File

@ -355,7 +355,7 @@ const JupiterForm: FunctionComponent = () => {
<div className="col-span-12 xl:col-span-10 xl:col-start-2 ">
<div className="flex flex-col md:flex-row md:space-x-6">
<div className="w-full md:w-1/2 lg:w-1/3">
<div className="relative z-10">
<div className="relative">
{connected &&
walletTokensWithInfos.length &&
walletTokenPrices &&

View File

@ -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
}
}

View File

@ -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 (
<div className="flex flex-col items-center rounded-lg px-4 text-th-fgd-1">
<h2 className="mb-1 text-base">Search by Mango Account</h2>
<p className="mb-2 text-center">
Enter a Mango account address to show account details
</p>
<div className="w-[350px] p-1 md:w-[400px]">
<Input
type="text"
error={isInvalid}
placeholder="Address"
value={value}
onChange={(e) => setValue(e.target.value)}
/>
</div>
{isInvalid && (
<div className="flex items-center pt-1.5 text-th-red">
<ExclamationCircleIcon className="mr-1.5 h-4 w-4" />
The address is invalid
</div>
)}
<div className="pt-3 pb-2">
<Button onClick={onClickSearch}>Search</Button>
</div>
</div>
)
}

View File

@ -53,6 +53,7 @@ import DelegateModal from 'components/DelegateModal'
import { Menu, Transition } from '@headlessui/react'
import { useWallet } from '@solana/wallet-adapter-react'
import { handleWalletConnect } from 'components/ConnectWalletButton'
import { MangoAccountSearch } from 'components/account_page/MangoAccountSearch'
export async function getStaticProps({ locale }) {
return {
@ -446,6 +447,11 @@ export default function Account() {
/>
)}
</div>
{!connected && (
<div className="mt-6 md:mt-3 md:rounded-lg md:bg-th-bkg-2 md:p-6">
<MangoAccountSearch />
</div>
)}
</PageBodyContainer>
{showAccountsModal ? (
<AccountsModal