Skip to content

Commit

Permalink
style(clean of the app): cleaning the app for better readability, acc…
Browse files Browse the repository at this point in the history
…essibility and performance

cleaning from file structure, stronger configs, removal of unused modules, cleaning of files and
unusued imports ...
  • Loading branch information
Torof committed Oct 7, 2024
1 parent 0079519 commit 9e64cd9
Show file tree
Hide file tree
Showing 303 changed files with 2,254 additions and 5,877 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ contracts/foundry/out/

secrets.json

yarn.lock
yarn.lock

/frontend/.next
frontend/.next
10 changes: 0 additions & 10 deletions cache/fuzz/failures

This file was deleted.

1 change: 0 additions & 1 deletion cache/test-failures

This file was deleted.

24 changes: 24 additions & 0 deletions frontend/env.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

export const env = createEnv({
server: {
TWITTER_CLIENT_ID: z.string().optional(),
TWITTER_CLIENT_SECRET: z.string().optional(),
IPINFO_TOKEN: z.string().optional(),
SCORECHAIN_API_KEY: z.string().optional(),
AML_ALERT_WEBHOOK: z.string().url().optional(),
},
client: {
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: z.string(),
NEXT_PUBLIC_INTEGRATOR_ID: z.string(),
NEXT_PUBLIC_FRONTEND_URL: z.string(),
NEXT_PUBLIC_AFFILIATE_API_URL: z.string(),
},
experimental__runtimeEnv: {
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID,
NEXT_PUBLIC_INTEGRATOR_ID: process.env.NEXT_PUBLIC_INTEGRATOR_ID,
NEXT_PUBLIC_FRONTEND_URL: process.env.NEXT_PUBLIC_FRONTEND_URL,
NEXT_PUBLIC_AFFILIATE_API_URL: process.env.NEXT_PUBLIC_AFFILIATE_API_URL,
},
});
62 changes: 62 additions & 0 deletions frontend/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import "../env.mjs";
import { env } from "../env.mjs";
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

/** @type {import("next").NextConfig} */
const nextConfig = {
reactStrictMode: true,
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
};
}

config.resolve.alias['@'] = path.join(__dirname, 'src');
config.resolve.alias['~'] = path.join(__dirname, 'public');
config.resolve.alias['@root'] = path.join(__dirname, '..');

return config;
},
transpilePackages: ['@graphql-mesh/http', '@graphql-mesh/merger-stitching', 'graphql-yoga'],
images: {
remotePatterns: [
{
protocol: "https",
hostname: "euc.li",
},
{
protocol: "https",
hostname: "pbs.twimg.com",
},
{
protocol: "https",
hostname: "chain.link",
},
],
},
async redirects() {
return [
{
source: "/app",
destination: "/app/invest",
permanent: true,
},
];
},
env: {
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID,
NEXT_PUBLIC_INTEGRATOR_ID: env.NEXT_PUBLIC_INTEGRATOR_ID,
NEXT_PUBLIC_FRONTEND_URL: env.NEXT_PUBLIC_FRONTEND_URL,
NEXT_PUBLIC_AFFILIATE_API_URL: env.NEXT_PUBLIC_AFFILIATE_API_URL,
},
};

export default nextConfig;
88 changes: 88 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"name": "ledgity-yield-frontend",
"version": "2.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@auth/prisma-adapter": "^1.0.11",
"@graphql-mesh/graphql": "^0.102.6",
"@graphql-mesh/http": "^0.103.6",
"@graphql-mesh/merger-stitching": "^0.102.5",
"@graphql-mesh/runtime": "^0.103.6",
"@graphql-mesh/transform-prefix": "^0.102.5",
"@graphql-mesh/types": "^0.102.5",
"@graphql-mesh/utils": "^0.102.5",
"@graphql-tools/utils": "^10.0.0",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-progress": "^1.0.3",
"@radix-ui/react-radio-group": "^1.1.3",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-tooltip": "^1.0.7",
"@rainbow-me/rainbowkit": "^2",
"@swing.xyz/sdk": "^0.55.0",
"@swing.xyz/ui": "^0.54.2",
"@t3-oss/env-nextjs": "^0",
"@tanstack/react-query": "^5.20.2",
"@tanstack/react-table": "^8.11.2",
"@wagmi/core": "^2",
"@xswap-link/sdk": "^0.6.4",
"chart.js": "^4.4.1",
"chartjs-adapter-luxon": "^1.3.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cookies-next": "^4.1.0",
"d3-format": "^3.1.0",
"dayjs": "^1.11.11",
"embla-carousel-react": "^8.0.2",
"ethers": "^6.13.3",
"framer-motion": "^11.3.31",
"graphql": "^16.6.0",
"lodash.merge": "^4.6.2",
"lokijs": "^1.5.12",
"lucide-react": "^0.366.0",
"luxon": "^3.4.4",
"next": "^14.0.0",
"next-auth": "^4.24.5",
"react": "^18.2.0",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0",
"remixicon": "^4",
"sharp": "^0",
"tailwindcss-animate": "^1.0.7",
"usehooks-ts": "^3.1.0",
"viem": "^2",
"wagmi": "^2.5.7",
"zod": "^3.22.4"
},
"devDependencies": {
"@next/bundle-analyzer": "^14.0.0",
"@types/d3-format": "^3.0.4",
"@types/lodash.merge": "^4.6.9",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.18",
"autoprefixer": "^10.4.17",
"eslint": "^8.51.0",
"eslint-config-next": "^14.1.0",
"pino-pretty": "^10.3.1",
"postcss": "^8.4.35",
"prettier": "^3.1.1",
"prettier-plugin-jsdoc": "^1",
"prettier-plugin-tailwindcss": "^0.5.9",
"string-replace-loader": "^3.1.0",
"tailwind-merge": "^2.2.2",
"tailwind-scrollbar": "^3.0.5",
"tailwindcss": "^3.4.1"
}
}
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { nextAuthOptions } from "@/app/api/auth/[...nextauth]/options";
import { prisma } from "@/lib/db";
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";

export async function POST(request: Request) {
const session = await getServerSession(nextAuthOptions);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { NextResponse, NextRequest } from "next/server";
import { env } from "../../../../../env.mjs";
import { isAddress } from "viem";
import { isAccountHighRisk, isAccountSanctioned, isIPRestricted } from "../common";

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { env } from "../../../../../env.mjs";
import { PrismaAdapter } from "@auth/prisma-adapter";
import { prisma } from "@/lib/db";
import { DefaultSession } from "next-auth";
import { isAddress } from "viem";
import NextAuth, { NextAuthOptions } from "next-auth";
import { NextAuthOptions } from "next-auth";

declare module "next-auth" {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NextAuth, { NextAuthOptions } from "next-auth";
import NextAuth from "next-auth";
import { nextAuthOptions } from "./options";

const handler = NextAuth(nextAuthOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui";
import { SwitchAppTabProvider } from "@/contexts/SwitchAppTabContext";
import { useSwitchAppTab } from "@/hooks/useSwitchAppTab";
import { FC } from "react";
import { twMerge } from "tailwind-merge";
import { AppPreMining } from "@/components/app/pre-mining/AppPreMining";
import { SessionProvider } from "next-auth/react";
import { AppStaking } from "@/components/app/staking/AppStaking";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Metadata } from "next";
import AppTabs from "./AppTabs";
import type { NextPage } from 'next';

export function generateStaticParams() {
const tabs = ["dashboard", "invest", "airdrop", "get-usdc", "pre-mining"];
Expand Down Expand Up @@ -62,8 +63,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
};
}

//@ts-ignore
const Page: NextPage = ({ params }: { params: { tab: string } }) => {
const Page = ({ params }: { params: { tab: string } }) => {
return <AppTabs defaultTab={params.tab} />;
};

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
27 changes: 25 additions & 2 deletions src/components/DApp.tsx → frontend/src/components/DApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,30 @@ import { config } from "../lib/dapp/config";
import RainbowKitProvider from "./RainbowKitProvider";
import { MainContextProvider } from "@/contexts";

const queryClient = new QueryClient();
const customSerializer = (key: string, value: any) => {
if (typeof value === 'bigint') {
return { type: 'BigInt', value: value.toString() };
}
return value;
};

const customReviver = (key: string, value: any) => {
if (value && typeof value === 'object' && value.type === 'BigInt') {
return BigInt(value.value);
}
return value;
};

const queryClient = new QueryClient({
defaultOptions: {
queries: {
structuralSharing: (oldData, newData) => {
const serialized = JSON.stringify(newData, customSerializer);
return JSON.parse(serialized, customReviver);
},
},
},
});

interface Props {
children?: React.ReactNode;
Expand All @@ -26,4 +49,4 @@ const DApp: FC<Props> = ({ children }) => {
);
};

export default DApp;
export default DApp;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
useReadContract,
useSimulateContract,
} from "wagmi";
import { getContractAbi } from "@/lib/getContractAbi";
import { zeroAddress } from "viem";
import { useContractAbi } from "@/hooks/useContractAbi";
import { useQueryClient } from "@tanstack/react-query";
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AllowanceTxButton, Card, Input, TxButton } from "@/components/ui";
import { AllowanceTxButton, Card, Input } from "@/components/ui";
import {
useReadLTokenUnderlying,
useReadLTokenWithdrawalQueue,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AllowanceTxButton, Amount, AmountInput, Card, Input, TxButton } from "@/components/ui";
import { AllowanceTxButton, Amount, AmountInput, Card } from "@/components/ui";
import {
useReadLTokenDecimals,
useReadLTokenUnderlying,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@ import {
useReadLTokenUsableUnderlyings,
useReadLTokenWithdrawalQueue,
useReadLTokenWithdrawalQueueCursor,
useSimulateLTokenProcessBigQueuedRequest,
useSimulateLTokenProcessQueuedRequests,
useSimulateLTokenRepatriate,
useWriteLTokenProcessBigQueuedRequest,
writeGenericErc20Approve,
writeLTokenProcessBigQueuedRequest,
} from "@/generated";
import clsx from "clsx";
import { UseSimulateContractReturnType, useAccount, useBlockNumber } from "wagmi";
import { useQueryClient } from "@tanstack/react-query";
import { UseSimulateContractReturnType, useAccount } from "wagmi";
import { config } from "@/lib/dapp/config";

interface ProcessBigRequestButtonProps {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
useAccount,
useBlockNumber,
useReadContract,
useSimulateContract,
} from "wagmi";
import { AdminMasonry } from "../AdminMasonry";
import { AdminBrick } from "../AdminBrick";
Expand Down
File renamed without changes.
Loading

0 comments on commit 9e64cd9

Please sign in to comment.