Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wallet-v2): not completed #23

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b6dd496
feat(wallet-v2): not completed
0xdevcollins Oct 13, 2024
65569d1
Updated layout, styling, and components in wallet-v2 app
0xdevcollins Oct 15, 2024
7a1e778
Updated layout, styling, and components in wallet-v2 app
0xdevcollins Oct 15, 2024
bb64a48
Refactor wallet-v2: update imports, remove unused code, and modify co…
0xdevcollins Oct 16, 2024
8ad6691
started working on the wallet integration
0xdevcollins Oct 16, 2024
50a339a
Block hash and block number added to footer
0xdevcollins Oct 16, 2024
4680513
build: update package.json
0xdevcollins Oct 18, 2024
c91f4fd
update TextCard.tsx
0xdevcollins Oct 18, 2024
f453133
refactor: simplify layout and improve UI components in wallet-v2 appl…
0xdevcollins Oct 18, 2024
a0eee9b
refactor(wallet-v2): update import statements and simplify state mana…
0xdevcollins Oct 18, 2024
7f28d74
feat(wallet-v2): update UI components and improve balance display
0xdevcollins Oct 18, 2024
6753f0d
feat: update UI components and loading modal behavior
0xdevcollins Oct 18, 2024
d1ed3d7
style: adjust text opacity for no transactions message
0xdevcollins Oct 18, 2024
a404b3d
refactor: standardize code formatting and fix minor code style issues…
0xdevcollins Oct 19, 2024
2c4b2f6
feat(dialog): add animations and refactor dialog components
0xdevcollins Oct 19, 2024
a69f6ae
feat(wallet-v2): add animation and hover effect to ConnectButton usin…
0xdevcollins Oct 19, 2024
a94f27d
refactor: update import statements and improve code readability
0xdevcollins Oct 19, 2024
f0bddd6
refactor(networkSlice): add initialState and update state management …
0xdevcollins Oct 19, 2024
cd89621
feat(metamask): add network switching functionality and update defaul…
0xdevcollins Oct 19, 2024
220fe20
feat(wallet-v2): add loading screen with animated logo and update Loa…
0xdevcollins Oct 19, 2024
0acf05e
feat(wallet-v2): add toast notifications and dialogs for key export a…
0xdevcollins Oct 19, 2024
1e36853
feat(wallet-v2): add SignMessageDialog component for signing messages…
0xdevcollins Oct 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/wallet-v2/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
36 changes: 36 additions & 0 deletions packages/wallet-v2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions packages/wallet-v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Binary file added packages/wallet-v2/app/assets/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/wallet-v2/app/favicon.ico
Binary file not shown.
Binary file added packages/wallet-v2/app/fonts/GeistMonoVF.woff
Binary file not shown.
Binary file added packages/wallet-v2/app/fonts/GeistVF.woff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
94 changes: 94 additions & 0 deletions packages/wallet-v2/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
}

@media (prefers-color-scheme: dark) {
:root {
}
}

body {
font-family: var(--font-thicccboi);
}

@layer utilities {
.text-balance {
text-wrap: balance;
}
}

@layer base {
:root {
/* --background: 0 0% 100%; */
--foreground: 0 0% 3.9%;
/* --card: 0 0% 100%;
--card-foreground: 0 0% 3.9%; */
--popover: 0 0% 100%;
--popover-foreground: 0 0% 3.9%;
--primary: 0 0% 9%;
--primary-foreground: 0 0% 98%;
--secondary: 0 0% 96.1%;
--secondary-foreground: 0 0% 9%;
--muted: 0 0% 96.1%;
--muted-foreground: 0 0% 45.1%;
--accent: 0 0% 96.1%;
--accent-foreground: 0 0% 9%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 89.8%;
--input: 0 0% 89.8%;
--ring: 0 0% 3.9%;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
/* --radius: 0.5rem; */
}
.dark {
/* --background: 0 0% 3.9%; */
--foreground: 0 0% 98%;
--card: 0 0% 3.9%;
--card-foreground: 0 0% 98%;
--popover: 0 0% 3.9%;
--popover-foreground: 0 0% 98%;
--primary: 0 0% 98%;
--primary-foreground: 0 0% 9%;
--secondary: 0 0% 14.9%;
--secondary-foreground: 0 0% 98%;
/* --muted: 0 0% 14.9%; */
--muted-foreground: 0 0% 63.9%;
--accent: 0 0% 14.9%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 14.9%;
--input: 0 0% 14.9%;
--ring: 0 0% 83.1%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}

.gradient-border {
border-width: 3.2px;
border-style: solid;
border-image: linear-gradient(139.26deg, #303441 -0.73%, #232836 100.78%);
border-image-slice: 1;
border-radius: 20px;
}
68 changes: 68 additions & 0 deletions packages/wallet-v2/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import type { Metadata } from 'next'
import localFont from 'next/font/local'
import './globals.css'
import { Header } from '@/shared/Header'
import Footer from '@/shared/Footer'
import { Toaster } from '@/components/ui/toaster'

const geistSans = localFont({
src: './fonts/GeistVF.woff',
variable: '--font-geist-sans',
display: 'swap',
})

const geistMono = localFont({
src: './fonts/GeistMonoVF.woff',
variable: '--font-geist-mono',
display: 'swap',
})

const thicccBoi = localFont({
src: [
{
path: './fonts/THICCCBOI/THICCCBOI-Regular.ttf',
weight: '400',
style: 'normal',
},
{
path: './fonts/THICCCBOI/THICCCBOI-Medium.ttf',
weight: '500',
style: 'normal',
},
{
path: './fonts/THICCCBOI/THICCCBOI-Bold.ttf',
weight: '700',
style: 'normal',
},
],
variable: '--font-thicccboi',
display: 'swap',
})

export const metadata: Metadata = {
title: 'Avail Wallet',
description: 'A decentralized wallet application',
}

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode
}>): JSX.Element {
return (
<html
lang="en"
className={`${geistSans.variable} ${geistMono.variable} ${thicccBoi.variable}`}
>
<body className="relative antialiased bg-main text-white min-h-screen flex flex-col">
<div className="flex-grow m-2 sm:m-4 md:m-8 lg:m-16 p-4 sm:p-6 md:p-8 rounded-2xl sm:rounded-[32px] bg-sec overflow-auto border-2 sm:border-[5px] border-[#FFFFFF1A]">
<Header />
<main className="flex-grow my-4 sm:my-6 md:my-8">{children}</main>
</div>
<Footer />
<Toaster />

</body>
</html>
)
}
Binary file added packages/wallet-v2/app/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/wallet-v2/app/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
142 changes: 142 additions & 0 deletions packages/wallet-v2/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
'use client'

import Image from 'next/image'
import { useEffect } from 'react'
import { motion } from 'framer-motion'
import { Button } from '@/components/ui/button'
import { TextCard } from '@/shared/TextCard'
import SendDialog from '@/shared/Dialog/SendDialog'
import LoadingModal from '@/shared/LoadingModal'
import { useAvailSnap } from '@/services/metamask'
import { useHasMetamask } from '@/hooks/useHasMetamask'
import useWalletStore from '@/slices/walletSlice'
import {useNetworkStore} from '@/slices/networkSlice'
import { useUIStore } from '@/slices/UISlice'
import Line from '@/assets/images/line.svg'
import Sign from '@/assets/images/signature.svg'
import Qr from '@/assets/images/qr.svg'
import { GET_FAUCENT_URL, SNAPS_DOC_URL } from '@/utils/constants'
import { BalanceDisplay } from '@/shared/BalanceDisplay'
import ReceiveDialog from '@/shared/Dialog/RecieveDialog'
import SignMessageDialog from '@/shared/Dialog/SignMessageDialog'

export default function Home(): JSX.Element {
const { initSnap, checkConnection, getWalletData } = useAvailSnap()
const accounts = useWalletStore((state) => state.accounts)
const _balance = useWalletStore((state) => state.tokenBalance) // Unused but prefixed
const provider = useWalletStore((state) => state.provider)
const connected = useWalletStore((state) => state.connected)
const forceReconnect = useWalletStore((state) => state.forceReconnect)
const networks = useNetworkStore((state) => state.items)
const activeNetwork = useNetworkStore((state) => state.activeNetwork)
const { hasMetamask } = useHasMetamask()
const { loader } = useUIStore()
const address =
accounts?.length > 0
? (accounts[0] as string)
: '0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

useEffect(() => {
if (!provider) return

if (connected) {
initSnap()
}

if (hasMetamask && !connected && !forceReconnect) {
checkConnection()
}
}, [connected, forceReconnect, hasMetamask, provider]);


useEffect(() => {
if (provider && networks.length > 0) {
const chainId = networks[activeNetwork].chainId
getWalletData(chainId, true)
}
}, [activeNetwork, provider, networks])

const fadeInUp = {
initial: { opacity: 0, y: 20 },
animate: { opacity: 1, y: 0 },
transition: { duration: 0.6 },
}

return (
<div className="px-4 sm:px-6 md:px-8 lg:px-12">
{loader.isLoading && <LoadingModal />}
{/* <motion.div {...fadeInUp} className="space-y-12">
<Image
src={Line}
alt="Decorative line"
width={100}
height={10}
className="w-full"
/>
<div className="flex flex-col items-center justify-center text-center">
<h2 className="text-4xl sm:text-5xl font-extrabold">
{connected ? '35875' : '--'} AVL
</h2>
<p className="mt-3 font-semibold text-lg sm:text-xl text-white/48">
4748.45 USD
</p>
</div>
<Image
src={Line}
alt="Decorative line"
width={100}
height={10}
className="w-full"
/>
</motion.div> */}
<BalanceDisplay />
<motion.div
className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6 mt-12"
variants={{
initial: { opacity: 0 },
animate: { opacity: 1, transition: { staggerChildren: 0.1 } },
}}
initial="initial"
animate="animate"
>
{true ? (
<>
<motion.div variants={fadeInUp}>
<SendDialog />
</motion.div>
<motion.div variants={fadeInUp}>
<ReceiveDialog />
</motion.div>
<motion.div variants={fadeInUp}>
<SignMessageDialog />
</motion.div>
</>
) : (
<>
<motion.div variants={fadeInUp}>
<TextCard
title="What is snap?"
content="Snaps extend the capabilities of MetaMask by adding new functionalities. This Snap allows MetaMask to be compatible with Avail and manage your keys."
link="#"
/>
</motion.div>
<motion.div variants={fadeInUp}>
<TextCard
title="Learn more about Avail?"
content="Snaps extend the capabilities of MetaMask by adding new functionalities. This Snap allows MetaMask to be compatible with Avail and manage your keys."
link={SNAPS_DOC_URL}
/>
</motion.div>
<motion.div variants={fadeInUp}>
<TextCard
title="Get testnet tokens"
content="Snaps extend the capabilities of MetaMask by adding new functionalities. This Snap allows MetaMask to be compatible with Avail and manage your keys."
link={GET_FAUCENT_URL}
/>
</motion.div>
</>
)}
</motion.div>
</div>
)
}
3 changes: 3 additions & 0 deletions packages/wallet-v2/assets/images/discord.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading