Skip to content

Commit

Permalink
Merge pull request #42 from RedDuck-Software/refactor/20.01.2025
Browse files Browse the repository at this point in the history
Refactor/20.01.2025
  • Loading branch information
yarre-uk authored Jan 20, 2025
2 parents 013629a + 227a5d2 commit f69978e
Show file tree
Hide file tree
Showing 54 changed files with 498 additions and 516 deletions.
67 changes: 31 additions & 36 deletions .github/workflows/static-checks.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
name: Static Checks

on:
push:
branches:
- main
- staging
pull_request: {}
workflow_dispatch: {}

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: '20'

- name: Enable Corepack
run: corepack enable

- uses: actions/cache@v3
id: cache2
with:
path: '**/node_modules'
key: ${{ runner.os }}-npm-${{ hashFiles('**/yarn.lock') }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-npm-

- name: Install project dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: Testing
run: yarn tsc --noEmit && yarn lint && yarn build
name: Static Checks

on:
push:
branches:
- main
- dev
pull_request:

permissions:
actions: read
contents: read

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Enable Corepack
run: corepack enable
- name: Prepare Yarn
run: corepack prepare [email protected] --activate
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Testing
run: yarn tsc --noEmit && yarn lint && yarn build
14 changes: 7 additions & 7 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
singleQuote: true,
trailingComma: 'all',
printWidth: 120,
semi: true,
plugins: ['prettier-plugin-tailwindcss'],
};
module.exports = {
singleQuote: true,
trailingComma: 'all',
printWidth: 120,
semi: true,
plugins: ['prettier-plugin-tailwindcss'],
};
2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodeLinker: node-modules
nodeLinker: node-modules
2 changes: 1 addition & 1 deletion components.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"hooks": "@/hooks"
},
"iconLibrary": "lucide"
}
}
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default tseslint.config(
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
},
},
);
2 changes: 1 addition & 1 deletion postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export default {
tailwindcss: {},
autoprefixer: {},
},
}
};
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
14 changes: 6 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Suspense } from 'react';
import { ToastContainer } from 'react-toastify';

import { FullPageLoader } from '@/components/common/Loader';
import { QueryProvider } from '@/providers/query-provider';
import { RouterProvider } from '@/providers/router-provider';
import { SolanaProvider } from '@/providers/solana-provider';
import { FullPageLoader } from './components/common/loader';

Check failure on line 4 in src/App.tsx

View workflow job for this annotation

GitHub Actions / main

Cannot find module './components/common/loader' or its corresponding type declarations.
import { QueryProvider } from './providers/query-provider';
import { RouterProvider } from './providers/router-provider';
import { SolanaProvider } from './providers/solana-provider';

import '@fontsource/bona-nova-sc/400.css';
import '@fontsource/bona-nova-sc/700.css';
import '@fontsource/poppins/400.css';

function App() {
export const App = () => {
return (
<SolanaProvider>
<QueryProvider>
Expand All @@ -21,6 +21,4 @@ function App() {
</QueryProvider>
</SolanaProvider>
);
}

export default App;
};
2 changes: 1 addition & 1 deletion src/components/common/About/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useLocation } from 'react-router';

import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
import { routes } from '@/lib/router';
import { routes } from '@/constants/router';

const INSTRUCTIONS = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Link } from 'react-router';
import { NavMenu } from './nav-menu';

import { Button } from '@/components/ui/button';
import { routes } from '@/constants/router';
import { useBreakpoint } from '@/hooks/use-breakpoint';
import { routes } from '@/lib/router';
import { cn } from '@/lib/utils';

export const Header = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Header/modals/base-error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const BaseErrorModal = () => {

return (
<div className="flex w-[75vw] flex-col items-center justify-center gap-[15px] text-center text-[20px] leading-[30px] md:w-[480px]">
<img src="/icons/failed.svg" alt="failed" className="h-[120px] w-[93px] md:h-[180px] md:w-[140px]" />
<img src="/icons/modals/failed.svg" alt="failed" className="h-[120px] w-[93px] md:h-[180px] md:w-[140px]" />

<p className="text-[22px] leading-[30px] md:text-[28px] md:leading-[39px]">Oracle Response Failed</p>
<p className="text-[16px] leading-[22px] md:text-[18px] md:leading-[25px]">
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Header/modals/cancelled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const CanceledModal = () => {

return (
<div className="flex w-[75vw] flex-col items-center justify-center gap-[15px] text-center text-[20px] leading-[30px] md:w-[480px]">
<img src="/icons/scissors.svg" alt="failed" className="h-[116px] w-[107px] md:h-[173px] md:w-[159px]" />
<img src="/icons/modals/scissors.svg" alt="failed" className="h-[116px] w-[107px] md:h-[173px] md:w-[159px]" />

<p className="text-[22px] leading-[30px] md:text-[28px] md:leading-[39px]">Transaction Cancelled</p>
<p className="text-[16px] leading-[22px] md:text-[18px] md:leading-[25px]">
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Header/modals/insufficient-funds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const InsufficientFundsModal = () => {

return (
<div className="flex w-[75vw] flex-col items-center justify-center gap-[15px] text-center text-[20px] leading-[30px] md:w-[484px]">
<img src="/icons/funds.svg" alt="failed" className="h-[116px] w-[181px] md:h-[167px] md:w-[261px]" />
<img src="/icons/modals/funds.svg" alt="failed" className="h-[116px] w-[181px] md:h-[167px] md:w-[261px]" />

<p className="text-[22px] leading-[30px] md:text-[28px] md:leading-[39px]">Insufficient Funds</p>
<p className="text-[16px] leading-[22px] md:text-[18px] md:leading-[25px]">
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Header/modals/successful.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const SuccessfulModal = () => {

return (
<div className="flex w-[75vw] flex-col items-center justify-center gap-[15px] text-center text-[20px] leading-[30px] md:w-[480px]">
<img src="/icons/successful.svg" alt="success" className="h-[120px] w-[93px] md:h-[180px] md:w-[140px]" />
<img src="/icons/modals/successful.svg" alt="success" className="h-[120px] w-[93px] md:h-[180px] md:w-[140px]" />

<p className="text-[22px] leading-[30px] md:text-[28px] md:leading-[39px]">Payment Successful</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { ReactNode, useState } from 'react';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
import { cn } from '@/lib/utils';

interface BaseTooltipProps {
type BaseTooltipProps = {
content: ReactNode;
children: ReactNode;
className?: string;
contentClassName?: string;
as?: 'div' | 'span';
ignoreOnKeyDown?: boolean;
forceOpen?: boolean;
}
};

export const BaseTooltip = ({
children,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Link } from 'react-router';

import { Button } from '@/components/ui/button';
import { routes } from '@/lib/router';
import { routes } from '@/constants/router';

export const AdminBtn = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Link } from 'react-router';

import { Button } from '@/components/ui/button';
import { routes } from '@/lib/router';
import { routes } from '@/constants/router';

export const PredictFutureBtn = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Select, SelectTrigger, SelectItem, SelectValue, SelectContent } from '@/components/ui/select.tsx';
import { currencies, TCurrencies } from '@/constants/addresses.ts';
import { currencies, Currencies } from '@/constants/addresses';

interface ICurrencySelect {
type ICurrencySelect = {
value: string;
onValueChange: (value: TCurrencies) => void;
}
onValueChange: (value: Currencies) => void;
};

export const CurrencySelect = ({ value, onValueChange }: ICurrencySelect) => {
return (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Outlet } from 'react-router';

import { Footer } from '@/components/common/Footer';
import { Footer } from '@/components/common/footer';

Check failure on line 3 in src/components/common/layouts/main-layout.tsx

View workflow job for this annotation

GitHub Actions / main

Cannot find module '@/components/common/footer' or its corresponding type declarations.

export function MainLayout() {
return (
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions src/components/pages/game/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { SubmitHandler, useForm } from 'react-hook-form';
import { toast } from 'react-toastify';
import { z } from 'zod';

import { BaseTooltip } from '@/components/common/BaseTooltip';
import { CurrencySelect } from '@/components/common/CurrencySelect';
import { BaseTooltip } from '@/components/common/base-tooltip';
import { CurrencySelect } from '@/components/common/currency-select';
import { Button } from '@/components/ui/button.tsx';
import { currencies, TCurrencies } from '@/constants/addresses.ts';
import { currencies, Currencies } from '@/constants/addresses';
import useStatus from '@/hooks/api/use-status';
import useMakePrediction from '@/hooks/contracts/write/use-make-prediction';
import useSend from '@/hooks/contracts/write/use-send.ts';
import useSend from '@/hooks/contracts/write/use-send';
import { cn, showTxToast } from '@/lib/utils';
import { useWalletModalStore } from '@/store/wallet-modal.tsx';

Expand Down Expand Up @@ -56,7 +56,7 @@ export const GameSection = () => {
const [showTip, setShowTip] = useState<boolean>(false);
const [isRetry, setRetry] = useState(false);
const [dontReload, setDontReload] = useState(false);
const [currencyName, setCurrencyName] = useState<TCurrencies>(Object.keys(currencies)[0] as TCurrencies);
const [currencyName, setCurrencyName] = useState<Currencies>(Object.keys(currencies)[0] as Currencies);

const {
register,
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/home/cta.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PredictFutureBtn } from '@/components/common/PredictFutureBtn';
import { PredictFutureBtn } from '@/components/common/buttons/predict-future';
import { useBreakpoint } from '@/hooks/use-breakpoint';
import { cn } from '@/lib/utils';
import { BaseComponentProps } from '@/types';
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/home/faq.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GoToTwitterBtn } from '@/components/common/GoToTwitterBtn';
import { GoToTwitterBtn } from '@/components/common/buttons/go-to-twitter';
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';

const BENEFITS = [
Expand Down
8 changes: 4 additions & 4 deletions src/components/pages/home/hero.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useWallet } from '@solana/wallet-adapter-react';

import { AdminBtn } from '@/components/common/AdminBtn';
import { GoToTwitterBtn } from '@/components/common/GoToTwitterBtn';
import { PredictFutureBtn } from '@/components/common/PredictFutureBtn';
import { AdminBtn } from '@/components/common/buttons/admin';
import { GoToTwitterBtn } from '@/components/common/buttons/go-to-twitter';
import { PredictFutureBtn } from '@/components/common/buttons/predict-future';
import { OwnerAddress } from '@/constants/addresses';
import { network } from '@/lib/solana';
import { network } from '@/constants/solana';

export const Hero = () => {
const { publicKey } = useWallet();
Expand Down
7 changes: 3 additions & 4 deletions src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ const buttonVariants = cva(
},
);

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
export type ButtonProps = {
asChild?: boolean;
}
} & React.ButtonHTMLAttributes<HTMLButtonElement> &
VariantProps<typeof buttonVariants>;

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ const inputVariants = cva(
},
);

export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement>, VariantProps<typeof inputVariants> {
export type InputProps = {
asChild?: boolean;
error?: ReactNode;
label?: ReactNode;
endAdornment?: ReactNode;
startAdornment?: ReactNode;
wrapperClassName?: string;
}
} & React.InputHTMLAttributes<HTMLInputElement> &
VariantProps<typeof inputVariants>;

const Input = React.forwardRef<HTMLInputElement, InputProps>(
(
Expand Down
2 changes: 1 addition & 1 deletion src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ export const currencies = {
},
};

export type TCurrencies = keyof typeof currencies;
export type Currencies = keyof typeof currencies;
4 changes: 2 additions & 2 deletions src/lib/router.ts → src/constants/router.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { lazy } from 'react';
import { createBrowserRouter } from 'react-router';

import { DefaultLayout } from '@/layouts/default-layout';
import { MainLayout } from '@/layouts/main-layout';
import { DefaultLayout } from '@/components/common/layouts/default-layout';
import { MainLayout } from '@/components/common/layouts/main-layout';

export const routes = {
HOME: '/',
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/hooks/contracts/read/use-get-token-and-sol-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useWallet } from '@solana/wallet-adapter-react';
import { useQuery } from '@tanstack/react-query';

import { wSolMint } from '@/constants/addresses';
import { connection } from '@/lib/solana';
import { connection } from '@/constants/solana';

export const useGetTokenAndSolBalance = () => {
const { publicKey } = useWallet();
Expand Down
12 changes: 6 additions & 6 deletions src/hooks/contracts/write/use-make-prediction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { useWallet } from '@solana/wallet-adapter-react';
import { useMutation } from '@tanstack/react-query';
import { toast } from 'react-toastify';

import { currencies, TCurrencies } from '@/constants/addresses.ts';
import { currencies, Currencies } from '@/constants/addresses';
import useSubmitTarotCards from '@/hooks/api/use-submit-cards';
import useSend from '@/hooks/contracts/write/use-send.ts';
import useSend from '@/hooks/contracts/write/use-send';
import { getRandomTarotCards } from '@/lib/utils';
import { Status, useStatusModalStore } from '@/store/status-modal';

Expand All @@ -20,10 +20,10 @@ const notify = () => {
});
};

interface IMakePrediction {
type MakePrediction = {
question: string;
tokenName: TCurrencies;
}
tokenName: Currencies;
};

const useMakePrediction = () => {
const { publicKey } = useWallet();
Expand All @@ -32,7 +32,7 @@ const useMakePrediction = () => {
const { setStatus } = useStatusModalStore();

return useMutation({
async mutationFn({ question, tokenName }: IMakePrediction) {
async mutationFn({ question, tokenName }: MakePrediction) {
if (!publicKey) {
return;
}
Expand Down
Loading

0 comments on commit f69978e

Please sign in to comment.