merge main

This commit is contained in:
saml33 2023-05-17 22:36:48 +10:00
commit 42b58d321b
36 changed files with 520 additions and 1559 deletions

View File

@ -1,14 +0,0 @@
{
"presets": [
[
"next/babel",
{
"preset-react": {
"runtime": "automatic",
"importSource": "@emotion/react"
}
}
]
],
"plugins": ["@emotion/babel-plugin", "babel-plugin-macros"]
}

1
.gitignore vendored
View File

@ -32,3 +32,4 @@ yarn-error.log*
# vercel
.vercel
tsconfig.tsbuildinfo

18
components/ColorBlur.tsx Normal file
View File

@ -0,0 +1,18 @@
const ColorBlur = ({
className,
height,
width,
}: {
className?: string
height: string
width: string
}) => {
return (
<div
className={`absolute bg-th-red-dark mix-blend-screen rounded-full filter blur-3xl opacity-10 ${className}`}
style={{ height: height, width: width }}
/>
)
}
export default ColorBlur

View File

@ -85,10 +85,10 @@ const HomePage = () => {
const spheres = self.selector('.sphere')
spheres.forEach((sphere, i) => {
gsap.to(sphere, {
y: i % 2 ? -200 : 200,
y: i % 2 ? -150 : 100,
scrollTrigger: {
trigger: sphere,
start: 'center center',
start: i % 2 ? 'bottom bottom' : 'center center',
scrub: true,
},
})
@ -119,7 +119,7 @@ const HomePage = () => {
</div>
<div className="col-span-12 lg:col-span-7 relative h-full flex justify-center">
<img
className="sphere absolute -top-12 sm:-top-28 opacity-60 -left-6 sm:left-6 w-56 h-auto xl:-left-12"
className="sphere absolute -top-12 sm:-top-28 xl:-top-40 opacity-60 -left-6 sm:left-6 w-56 h-auto xl:-left-12"
src="/images/new/black-sphere.png"
alt=""
/>
@ -129,7 +129,7 @@ const HomePage = () => {
alt=""
/>
<img
className="sphere absolute lg:-bottom-16 -right-28 sm:-right-24 md:-right-14 lg:right-0 lg:left-0 xl:-left-16 w-80 h-auto"
className="sphere absolute lg:-bottom-24 xl:-bottom-40 -right-28 sm:-right-24 md:-right-14 lg:right-0 lg:left-0 xl:-left-16 w-80 h-auto"
src="/images/new/orange-sphere.png"
alt=""
/>

View File

@ -1,58 +0,0 @@
import { useTranslation } from 'next-i18next'
import SectionWrapper from '../shared/SectionWrapper'
import ButtonLink from '../shared/ButtonLink'
const HomeTopSection = () => {
const { t } = useTranslation(['common', 'home'])
// const sideImage = useRef(null)
// const tl = gsap.timeline()
// useEffect(() => {
// //image animation
// tl.to(sideImage.current, 0.7, {
// opacity: 1,
// y: 0,
// ease: Power3.easeOut,
// })
// }, [])
return (
<SectionWrapper className="overflow-x-hidden">
<div className="grid grid-cols-12">
<div className="col-span-12 lg:col-span-5">
<h1 className="mb-6">
Safer. Smarter. Faster.
{/* <span className="bg-gradient-to-b from-th-active via-th-warning to-th-down bg-clip-text text-transparent">
{t('home:everything')}
</span> */}
</h1>
<p className="intro-p mb-10">
A magical new way to interact with DeFi. Groundbreaking safety
features designed to keep your funds secure. The easiest way to
margin trade any token pair. All powered by flashloans.
</p>
{/* <CheckBullet>{t('home:bullet-1')}</CheckBullet>
<CheckBullet>{t('home:bullet-2')}</CheckBullet>
<CheckBullet>{t('home:bullet-3')}</CheckBullet>
<CheckBullet showNewBadge>{t('home:bullet-4')}</CheckBullet>
<CheckBullet showNewBadge>{t('home:bullet-5')}</CheckBullet> */}
<ButtonLink
className="mt-8"
linkText={t('trade-now')}
path="https://app.mango.markets"
size="large"
/>
</div>
<div className="col-span-12 lg:col-span-7 relative h-48 sm:h-56 md:h-80 lg:h-full">
<img
className="w-full mt-10 lg:mt-0 absolute h-auto lg:-right-40 xl:right-0 z-10 lg:top-1/2 lg:transform lg:-translate-y-1/2"
src="/images/@1x-trade-desktop-dark-2.png"
alt=""
/>
</div>
</div>
</SectionWrapper>
)
}
export default HomeTopSection

View File

@ -1,98 +0,0 @@
import 'react-responsive-carousel/lib/styles/carousel.min.css'
import { Carousel } from 'react-responsive-carousel'
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/20/solid'
const TESTIMONIALS: TestimonialItem[] = [
{
description: 'Co-founder of Solana',
name: 'Anatoly Yakovenko',
profileImgSrc:
'https://pbs.twimg.com/profile_images/1626708518698127361/EmBuqBoT_400x400.jpg',
testimonial:
'Bitcoin Cash the hot consensus process when Satoshi Nakamoto built lots of instant Lambo, yet Zcash thinking a protocol, thinking the quick bag in many smart contract.',
twitterHandle: 'aeyakovenko',
},
{
description: 'Market Maker',
name: 'Space Monkey',
profileImgSrc:
'https://pbs.twimg.com/profile_images/1608831847802306560/msFvPpcD_400x400.jpg',
testimonial:
'Binance Coin slept on the fundamental analysis of some bear when Gwei limited many digital signature during few fiat, therefore, ether froze a dump.',
twitterHandle: 'RealSpaceMonkey',
},
]
const Testimonials = () => {
return (
<Carousel
autoPlay
infiniteLoop
interval={5000}
showIndicators={false}
showStatus={false}
renderArrowNext={(clickHandler, hasPrev) => {
return (
<div
className={`${
hasPrev ? 'absolute' : 'hidden'
} top-0 bottom-0 right-0 flex justify-center items-center p-3 cursor-pointer z-20 text-th-fgd-3 md:hover:text-th-fgd-1 default-transition`}
onClick={clickHandler}
>
<ChevronRightIcon className="w-7 h-7" />
</div>
)
}}
renderArrowPrev={(clickHandler, hasPrev) => {
return (
<div
className={`${
hasPrev ? 'absolute' : 'hidden'
} top-0 bottom-0 left-0 flex justify-center items-center p-3 cursor-pointer z-20 text-th-fgd-3 md:hover:text-th-fgd-1 default-transition`}
onClick={clickHandler}
>
<ChevronLeftIcon className="w-7 h-7" />
</div>
)
}}
>
{TESTIMONIALS.map((item) => (
<Testimonial key={item.name} item={item} />
))}
</Carousel>
)
}
export default Testimonials
interface TestimonialItem {
description: string
name: string
profileImgSrc: string
testimonial: string
twitterHandle: string
}
const Testimonial = ({ item }: { item: TestimonialItem }) => {
const { description, name, profileImgSrc, testimonial, twitterHandle } = item
return (
<div className="flex flex-col items-center h-72 md:h-64">
<div className="w-24 h-24 mb-3">
<img
className="w-full h-full rounded-full"
src={profileImgSrc}
alt="Profile Image"
/>
</div>
<h3 className="mb-1">{name}</h3>
<a
className="font-mono mb-1 text-sm text-th-fgd-4"
href={`https://twitter.com/${twitterHandle}`}
target="_blank"
rel="noopener noreferrer"
>{`@${twitterHandle}`}</a>
<p className="text-sm mb-4">{description}</p>
<p className="text-th-fgd-2 max-w-[800px]">{testimonial}</p>
</div>
)
}

View File

@ -14,7 +14,7 @@ const SectionWrapper = ({
return (
<div
className={`${noPaddingX ? '' : 'page-x-padding'} ${
noPaddingY ? '' : 'py-24 lg:py-32 xl:py-40'
noPaddingY ? '' : 'py-24 lg:py-32'
} max-w-[1600px] mx-auto ${className}`}
>
{children}

View File

@ -1,4 +1,5 @@
const { i18n } = require('./next-i18next.config')
const webpack = require('webpack')
/** @type {import('next').NextConfig} */
const nextConfig = {
@ -16,6 +17,14 @@ const nextConfig = {
}
}
config.plugins.push(
new webpack.DefinePlugin({
'process.env': {
BUILD_ID: JSON.stringify(opts.buildId),
},
})
)
return config
},
}

View File

@ -21,28 +21,17 @@
]
},
"dependencies": {
"@emotion/react": "^11.1.5",
"@emotion/styled": "^11.3.0",
"@headlessui/react": "^1.0.0",
"@heroicons/react": "^2.0.16",
"@sendgrid/client": "^7.4.3",
"@solana/spl-token": "^0.1.3",
"@solana/web3.js": "^1.5.0",
"@tanstack/react-query": "^4.24.10",
"gsap": "^3.11.5",
"i18next": "^22.4.10",
"immer": "^9.0.1",
"moment": "^2.29.1",
"next": "latest",
"next-i18next": "^13.1.5",
"next-themes": "^0.0.14",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-fast-marquee": "^1.2.1",
"react-i18next": "^12.1.5",
"react-responsive-carousel": "^3.2.23",
"recharts": "^2.4.3",
"zustand": "^3.4.1"
"react-i18next": "^12.1.5"
},
"devDependencies": {
"@testing-library/react": "^11.2.5",

View File

@ -3,9 +3,6 @@ import { ThemeProvider } from 'next-themes'
import '../styles/index.css'
import LayoutWrapper from '../components/layout/LayoutWrapper'
import { appWithTranslation } from 'next-i18next'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
const queryClient = new QueryClient()
function App({ Component, pageProps }) {
const title = 'Mango Markets'
@ -35,18 +32,14 @@ function App({ Component, pageProps }) {
<meta name="twitter:description" content={description} />
<meta
name="twitter:image"
content="https://www.mango.markets/socials/twitter-image-1200x600.png?34567878"
content="https://mango.markets/socials/meta.jpg?1234567"
/>
<link rel="manifest" href="/manifest.json"></link>
</Head>
<QueryClientProvider client={queryClient}>
<ThemeProvider defaultTheme="Mango">
<LayoutWrapper>
<Component {...pageProps} />
</LayoutWrapper>
</ThemeProvider>
</QueryClientProvider>
<ThemeProvider defaultTheme="Mango">
<LayoutWrapper>
<Component {...pageProps} />
</LayoutWrapper>
</ThemeProvider>
</>
)
}

View File

@ -1,26 +0,0 @@
import client from '@sendgrid/client'
const { SENDGRID_API_KEY } = process.env
client.setApiKey(SENDGRID_API_KEY)
export default async function handler(req, res) {
try {
if (req.method !== 'POST') {
res.status(405).json({ error: 'Method not allowed' })
return
}
const { email } = req.body
const request = {
method: 'PUT' as any,
url: '/v3/marketing/contacts',
body: { contacts: [{ email }] },
}
const [_, body] = await client.request(request)
res.status(200).send(body)
} catch (e) {
console.error(e)
res.status(500).send(e.toString())
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 104 KiB

BIN
public/img/swap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 KiB

BIN
public/img/trade-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 KiB

View File

@ -1,3 +1,3 @@
<svg width="28" height="20" viewBox="0 0 28 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M23.7187 1.67497C21.9061 0.89249 19.9681 0.323786 17.9421 0C17.6932 0.41511 17.4025 0.973432 17.2021 1.4176C15.0482 1.11872 12.9142 1.11872 10.8 1.4176C10.5996 0.973432 10.3023 0.41511 10.0513 0C8.02293 0.323786 6.08271 0.894565 4.27023 1.67912C0.614418 6.77668 -0.376613 11.7477 0.118903 16.648C2.54363 18.3188 4.89347 19.3337 7.20367 19.9979C7.77407 19.2736 8.2828 18.5036 8.72106 17.692C7.88639 17.3993 7.08696 17.0382 6.33156 16.6189C6.53197 16.482 6.72798 16.3387 6.91738 16.1914C11.5246 18.1797 16.5304 18.1797 21.0826 16.1914C21.2741 16.3387 21.4701 16.482 21.6683 16.6189C20.9107 17.0402 20.1091 17.4014 19.2744 17.6941C19.7127 18.5036 20.2192 19.2757 20.7918 20C23.1042 19.3358 25.4563 18.3209 27.881 16.648C28.4624 10.9672 26.8878 6.04193 23.7187 1.67497ZM9.34871 13.6343C7.96567 13.6343 6.83149 12.4429 6.83149 10.9922C6.83149 9.54132 7.94144 8.34791 9.34871 8.34791C10.756 8.34791 11.8901 9.53924 11.8659 10.9922C11.8682 12.4429 10.756 13.6343 9.34871 13.6343ZM18.6512 13.6343C17.2682 13.6343 16.1339 12.4429 16.1339 10.9922C16.1339 9.54132 17.2439 8.34791 18.6512 8.34791C20.0584 8.34791 21.1926 9.53924 21.1684 10.9922C21.1684 12.4429 20.0584 13.6343 18.6512 13.6343Z" fill="#4F4C67"/>
<path d="M23.7187 1.67497C21.9061 0.89249 19.9681 0.323786 17.9421 0C17.6932 0.41511 17.4025 0.973432 17.2021 1.4176C15.0482 1.11872 12.9142 1.11872 10.8 1.4176C10.5996 0.973432 10.3023 0.41511 10.0513 0C8.02293 0.323786 6.08271 0.894565 4.27023 1.67912C0.614418 6.77668 -0.376613 11.7477 0.118903 16.648C2.54363 18.3188 4.89347 19.3337 7.20367 19.9979C7.77407 19.2736 8.2828 18.5036 8.72106 17.692C7.88639 17.3993 7.08696 17.0382 6.33156 16.6189C6.53197 16.482 6.72798 16.3387 6.91738 16.1914C11.5246 18.1797 16.5304 18.1797 21.0826 16.1914C21.2741 16.3387 21.4701 16.482 21.6683 16.6189C20.9107 17.0402 20.1091 17.4014 19.2744 17.6941C19.7127 18.5036 20.2192 19.2757 20.7918 20C23.1042 19.3358 25.4563 18.3209 27.881 16.648C28.4624 10.9672 26.8878 6.04193 23.7187 1.67497ZM9.34871 13.6343C7.96567 13.6343 6.83149 12.4429 6.83149 10.9922C6.83149 9.54132 7.94144 8.34791 9.34871 8.34791C10.756 8.34791 11.8901 9.53924 11.8659 10.9922C11.8682 12.4429 10.756 13.6343 9.34871 13.6343ZM18.6512 13.6343C17.2682 13.6343 16.1339 12.4429 16.1339 10.9922C16.1339 9.54132 17.2439 8.34791 18.6512 8.34791C20.0584 8.34791 21.1926 9.53924 21.1684 10.9922C21.1684 12.4429 20.0584 13.6343 18.6512 13.6343Z" fill="#B9B5CE"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,3 +1,3 @@
<svg width="28" height="27" viewBox="0 0 28 27" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 0C6.26967 0 0 6.19744 0 13.8413C0 19.9568 4.011 25.145 9.57483 26.9755C10.2737 27.1035 10.5 26.6745 10.5 26.31V23.7332C6.60567 24.5706 5.79483 22.0999 5.79483 22.0999C5.15783 20.5001 4.23967 20.0745 4.23967 20.0745C2.96917 19.2152 4.3365 19.2336 4.3365 19.2336C5.74233 19.3305 6.482 20.6604 6.482 20.6604C7.73033 22.7758 9.75683 22.1645 10.556 21.8104C10.6808 20.9165 11.0437 20.3052 11.445 19.9603C8.33583 19.6085 5.06683 18.4216 5.06683 13.1192C5.06683 11.6071 5.614 10.3729 6.50883 9.404C6.36417 9.05451 5.88467 7.64616 6.64533 5.74067C6.64533 5.74067 7.82133 5.36926 10.4965 7.1594C11.613 6.85259 12.81 6.69918 14 6.69341C15.19 6.69918 16.3882 6.85259 17.507 7.1594C20.1798 5.36926 21.3535 5.74067 21.3535 5.74067C22.1153 7.64731 21.6358 9.05566 21.4912 9.404C22.3895 10.3729 22.932 11.6082 22.932 13.1192C22.932 18.4354 19.6572 19.6062 16.5398 19.9488C17.0415 20.3778 17.5 21.2198 17.5 22.5117V26.31C17.5 26.6779 17.724 27.1105 18.4345 26.9744C23.9937 25.1415 28 19.9545 28 13.8413C28 6.19744 21.7315 0 14 0Z" fill="#4F4C67"/>
<path d="M14 0C6.26967 0 0 6.19744 0 13.8413C0 19.9568 4.011 25.145 9.57483 26.9755C10.2737 27.1035 10.5 26.6745 10.5 26.31V23.7332C6.60567 24.5706 5.79483 22.0999 5.79483 22.0999C5.15783 20.5001 4.23967 20.0745 4.23967 20.0745C2.96917 19.2152 4.3365 19.2336 4.3365 19.2336C5.74233 19.3305 6.482 20.6604 6.482 20.6604C7.73033 22.7758 9.75683 22.1645 10.556 21.8104C10.6808 20.9165 11.0437 20.3052 11.445 19.9603C8.33583 19.6085 5.06683 18.4216 5.06683 13.1192C5.06683 11.6071 5.614 10.3729 6.50883 9.404C6.36417 9.05451 5.88467 7.64616 6.64533 5.74067C6.64533 5.74067 7.82133 5.36926 10.4965 7.1594C11.613 6.85259 12.81 6.69918 14 6.69341C15.19 6.69918 16.3882 6.85259 17.507 7.1594C20.1798 5.36926 21.3535 5.74067 21.3535 5.74067C22.1153 7.64731 21.6358 9.05566 21.4912 9.404C22.3895 10.3729 22.932 11.6082 22.932 13.1192C22.932 18.4354 19.6572 19.6062 16.5398 19.9488C17.0415 20.3778 17.5 21.2198 17.5 22.5117V26.31C17.5 26.6779 17.724 27.1105 18.4345 26.9744C23.9937 25.1415 28 19.9545 28 13.8413C28 6.19744 21.7315 0 14 0Z" fill="#B9B5CE"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
public/socials/meta.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -1,3 +1,3 @@
<svg width="28" height="23" viewBox="0 0 28 23" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.78874 23C5.55374 23 2.53817 22.0591 0 20.4356C2.15499 20.5751 5.95807 20.2411 8.32358 17.9848C4.76508 17.8215 3.16026 15.0923 2.95094 13.926C3.25329 14.0426 4.6953 14.1826 5.50934 13.856C1.4159 12.8296 0.787928 9.23732 0.927477 8.14097C1.695 8.67749 2.99745 8.8641 3.50913 8.81744C-0.305207 6.08823 1.06703 1.98276 1.74151 1.09635C4.47882 4.88867 8.5812 7.01857 13.6564 7.13704C13.5607 6.71736 13.5102 6.28042 13.5102 5.83164C13.5102 2.61092 16.1134 0 19.3247 0C21.0025 0 22.5144 0.712754 23.5757 1.85284C24.6969 1.59011 26.3843 0.975068 27.2092 0.443205C26.7934 1.93611 25.4989 3.18149 24.7159 3.64308C24.7224 3.65878 24.7095 3.62731 24.7159 3.64308C25.4037 3.53904 27.2648 3.18137 28 2.68256C27.6364 3.52125 26.264 4.91573 25.1377 5.69642C25.3473 14.9381 18.2765 23 8.78874 23Z" fill="#4F4C67"/>
<path d="M8.78874 23C5.55374 23 2.53817 22.0591 0 20.4356C2.15499 20.5751 5.95807 20.2411 8.32358 17.9848C4.76508 17.8215 3.16026 15.0923 2.95094 13.926C3.25329 14.0426 4.6953 14.1826 5.50934 13.856C1.4159 12.8296 0.787928 9.23732 0.927477 8.14097C1.695 8.67749 2.99745 8.8641 3.50913 8.81744C-0.305207 6.08823 1.06703 1.98276 1.74151 1.09635C4.47882 4.88867 8.5812 7.01857 13.6564 7.13704C13.5607 6.71736 13.5102 6.28042 13.5102 5.83164C13.5102 2.61092 16.1134 0 19.3247 0C21.0025 0 22.5144 0.712754 23.5757 1.85284C24.6969 1.59011 26.3843 0.975068 27.2092 0.443205C26.7934 1.93611 25.4989 3.18149 24.7159 3.64308C24.7224 3.65878 24.7095 3.62731 24.7159 3.64308C25.4037 3.53904 27.2648 3.18137 28 2.68256C27.6364 3.52125 26.264 4.91573 25.1377 5.69642C25.3473 14.9381 18.2765 23 8.78874 23Z" fill="#B9B5CE"/>
</svg>

Before

Width:  |  Height:  |  Size: 913 B

After

Width:  |  Height:  |  Size: 913 B

View File

@ -1,19 +0,0 @@
import create, { State } from 'zustand'
import produce from 'immer'
interface NotificationStore extends State {
notifications: Array<{
type: string
message: string
description?: string
txid?: string
}>
set: (x: any) => void
}
const useNotificationStore = create<NotificationStore>((set, _get) => ({
notifications: [],
set: (fn) => set(produce(fn)),
}))
export default useNotificationStore

View File

@ -236,43 +236,3 @@ li {
animation-delay: 4s;
}
}
.radial-gradient-bg {
background-image: radial-gradient(at 300% 100%, #5b48ad 0, transparent 75%);
@apply bg-th-bkg-1;
}
/* Animations */
@keyframes sideways-bounce {
0%,
100% {
transform: translateX(-25%);
animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
}
50% {
transform: translateX(0);
animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
}
}
.sideways-bounce {
animation: sideways-bounce 1s infinite;
}
/* stable price home page animation */
.path {
stroke-dasharray: 1;
stroke-dashoffset: 1;
animation: dash 6s linear infinite;
}
@keyframes dash {
from {
stroke-dashoffset: 1;
}
to {
stroke-dashoffset: 0;
}
}

View File

@ -1,14 +1,8 @@
// const colors = require('tailwindcss/colors')
// const defaultTheme = require('tailwindcss/defaultTheme')
module.exports = {
mode: 'jit',
purge: ['./pages/**/*.{js,ts,jsx,tsx}', './components/**/*.{js,ts,jsx,tsx}'],
future: {
removeDeprecatedGapUtilities: true,
purgeLayersByDefault: true,
},
darkMode: false,
content: [
'./pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}',
],
theme: {
fontFamily: {
display: ['TT Commons Expanded, sans-serif'],

File diff suppressed because one or more lines are too long

View File

@ -1,18 +0,0 @@
import useNotificationStore from '../stores/useNotificationStore'
export function notify(newNotification: {
type?: string
message: string
description?: string
txid?: string
}) {
const { notifications, set: setNotificationStore } =
useNotificationStore.getState()
setNotificationStore((state) => {
state.notifications = [
...notifications,
{ type: 'success', ...newNotification },
]
})
}

View File

@ -1,104 +0,0 @@
import { Connection, PublicKey } from '@solana/web3.js'
import {
AccountInfo,
AccountLayout,
MintInfo,
MintLayout,
u64,
} from '@solana/spl-token'
export type TokenAccount = AccountInfo
export type MintAccount = MintInfo
export type ProgramAccount<T> = {
publicKey: PublicKey
account: T
}
export async function getOwnedTokenAccounts(
connection: Connection,
publicKey: PublicKey
): Promise<ProgramAccount<TokenAccount>[]> {
const results = await connection.getTokenAccountsByOwner(publicKey, {
programId: TOKEN_PROGRAM_ID,
})
return results.value.map((r) => {
const publicKey = r.pubkey
const data = Buffer.from(r.account.data)
const account = parseTokenAccountData(publicKey, data)
return { publicKey, account }
})
}
export async function getMint(
connection: Connection,
publicKey: PublicKey
): Promise<ProgramAccount<MintAccount>> {
const result = await connection.getAccountInfo(publicKey)
const data = Buffer.from(result.data)
const account = parseMintAccountData(data)
return {
publicKey,
account,
}
}
// copied from @solana/spl-token
const TOKEN_PROGRAM_ID = new PublicKey(
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
)
function parseTokenAccountData(account: PublicKey, data: Buffer): TokenAccount {
const accountInfo = AccountLayout.decode(data)
accountInfo.address = account
accountInfo.mint = new PublicKey(accountInfo.mint)
accountInfo.owner = new PublicKey(accountInfo.owner)
accountInfo.amount = u64.fromBuffer(accountInfo.amount)
if (accountInfo.delegateOption === 0) {
accountInfo.delegate = null
accountInfo.delegatedAmount = new u64()
} else {
accountInfo.delegate = new PublicKey(accountInfo.delegate)
accountInfo.delegatedAmount = u64.fromBuffer(accountInfo.delegatedAmount)
}
accountInfo.isInitialized = accountInfo.state !== 0
accountInfo.isFrozen = accountInfo.state === 2
if (accountInfo.isNativeOption === 1) {
accountInfo.rentExemptReserve = u64.fromBuffer(accountInfo.isNative)
accountInfo.isNative = true
} else {
accountInfo.rentExemptReserve = null
accountInfo.isNative = false
}
if (accountInfo.closeAuthorityOption === 0) {
accountInfo.closeAuthority = null
} else {
accountInfo.closeAuthority = new PublicKey(accountInfo.closeAuthority)
}
return accountInfo
}
function parseMintAccountData(data: Buffer) {
const mintInfo = MintLayout.decode(data)
if (mintInfo.mintAuthorityOption === 0) {
mintInfo.mintAuthority = null
} else {
mintInfo.mintAuthority = new PublicKey(mintInfo.mintAuthority)
}
mintInfo.supply = u64.fromBuffer(mintInfo.supply)
mintInfo.isInitialized = mintInfo.isInitialized != 0
if (mintInfo.freezeAuthorityOption === 0) {
mintInfo.freezeAuthority = null
} else {
mintInfo.freezeAuthority = new PublicKey(mintInfo.freezeAuthority)
}
return mintInfo
}

1610
yarn.lock

File diff suppressed because it is too large Load Diff