Skip to content

Commit

Permalink
chore: lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanNeiverth committed Oct 14, 2024
1 parent 8817157 commit d95dc4c
Show file tree
Hide file tree
Showing 62 changed files with 334 additions and 317 deletions.
8 changes: 4 additions & 4 deletions apps/claim-vesting/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ const moduleExports = {
async headers() {
return [
{
source: '/manifest.json',
source: "/manifest.json",
headers: [
{
key: 'Access-Control-Allow-Origin',
value: '*',
key: "Access-Control-Allow-Origin",
value: "*",
},
],
},
];
},
};

module.exports = moduleExports;
module.exports = moduleExports;
2 changes: 1 addition & 1 deletion apps/claim-vesting/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function Page() {
const { account, chainId } = context || {};

const [typedAddress, setTypedAddress] = useState<string>(
context?.hookToEdit?.hook.target || ""
context?.hookToEdit?.hook.target || "",
);

const [debouncedAddress] = useDebounceValue(typedAddress, 300, {
Expand Down
6 changes: 3 additions & 3 deletions apps/claim-vesting/src/hooks/useClaimVestingData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const useClaimVestingData = ({
chain: chainMapping[chainId],
transport: http(),
}),
[chainId]
[chainId],
);
const {
claimableAmountWei,
Expand Down Expand Up @@ -96,7 +96,7 @@ export const useClaimVestingData = ({
6,
"decimal",
"standard",
0.000001
0.000001,
)
: "0.0";
const formattedClaimableAmountFullDecimals =
Expand All @@ -106,7 +106,7 @@ export const useClaimVestingData = ({
Number(decimals),
"decimal",
"standard",
Number(`0.${"0".repeat(Number(decimals) - 1)}1`)
Number(`0.${"0".repeat(Number(decimals) - 1)}1`),
)
: "0.0";
const loading = isLoadingToken || isLoadingVesting || isLoadingGasLimit;
Expand Down
2 changes: 1 addition & 1 deletion apps/create-vesting/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";

import "#/global.css";
import { IFrameContextProvider } from "@bleu/cow-hooks-ui";
import Head from "next/head";
import type * as React from "react";
import { IFrameContextProvider } from "@bleu/cow-hooks-ui";
import { TokenAmountTypeProvider } from "#/context/TokenAmountType";

export default function Layout({ children }: { children: React.ReactNode }) {
Expand Down
35 changes: 21 additions & 14 deletions apps/create-vesting/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
"use client";

import {
Input,
PeriodWithScaleInput,
ButtonPrimary,
ContentWrapper,
type HookDappContextAdjusted,
Input,
PeriodWithScaleInput,
Spinner,
TokenAmountInput,
Wrapper,
HookDappContextAdjusted,
useIFrameContext,
Spinner,
} from "@bleu/cow-hooks-ui";
import { Token } from "@uniswap/sdk-core";

import { useCallback, useMemo } from "react";
import { Form } from "@bleu/ui";
import { zodResolver } from "@hookform/resolvers/zod";
import { useCallback, useMemo } from "react";
import { useForm } from "react-hook-form";

import {
CreateVestingFormData,
type CreateVestingFormData,
createVestingSchema,
periodScaleOptions,
} from "#/utils/schema";

import { useGetHooksTransactions } from "#/hooks/useGetHooksTransactions";
import { useRouter } from "next/navigation";
import { useReadTokenContract } from "@bleu/cow-hooks-ui";
import { vestingFactoriesMapping } from "#/utils/vestingFactoriesMapping";
import { useRouter } from "next/navigation";
import {
VestAllFromSwapCheckbox,
VestAllCheckbox,
VestAllFromSwapCheckbox,
} from "#/components/Checkboxes";
import { useTokenAmountTypeContext } from "#/context/TokenAmountType";
import { useGetHooksTransactions } from "#/hooks/useGetHooksTransactions";
import { vestingFactoriesMapping } from "#/utils/vestingFactoriesMapping";

export default function Page() {
const { vestAllFromSwap } = useTokenAmountTypeContext();
Expand Down Expand Up @@ -60,7 +60,7 @@ export default function Page() {
context?.chainId && tokenAddress && tokenDecimals
? new Token(context.chainId, tokenAddress, tokenDecimals, tokenSymbol)
: undefined,
[context?.chainId, tokenAddress, tokenDecimals]
[context?.chainId, tokenAddress, tokenDecimals, tokenSymbol],
);

const vestingEscrowFactoryAddress = useMemo(() => {
Expand All @@ -71,7 +71,7 @@ export default function Page() {

const onSubmitCallback = useCallback(
async (data: CreateVestingFormData) => {
if (!context || !token || !vestingEscrowFactoryAddress) return;
if (!context?.account || !token || !vestingEscrowFactoryAddress) return;
const hookInfo = await getHooksTransactions({
token,
vestingEscrowFactoryAddress,
Expand All @@ -81,12 +81,19 @@ export default function Page() {
setHookInfo(hookInfo);
router.push("/signing");
},
[context?.account, token, vestingEscrowFactoryAddress, vestAllFromSwap]
[
context?.account,
token,
vestingEscrowFactoryAddress,
router.push,
setHookInfo,
getHooksTransactions,
],
);

const onSubmit = useMemo(
() => form.handleSubmit(onSubmitCallback),
[form, onSubmitCallback]
[form, onSubmitCallback],
);

if (!context)
Expand Down
16 changes: 8 additions & 8 deletions apps/create-vesting/src/app/signing/page.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"use client";

import {
useIFrameContext,
type BaseTransaction,
SignatureSteps,
WaitingSignature,
BaseTransaction,
useCowShedSignature,
useHandleTokenAllowance,
useIFrameContext,
useSubmitHook,
} from "@bleu/cow-hooks-ui";
import { BigNumber, BigNumberish } from "ethers";
import { BigNumber, type BigNumberish } from "ethers";
import { useCallback, useMemo, useState } from "react";
import { Address } from "viem";
import type { Address } from "viem";
import { useTokenAmountTypeContext } from "#/context/TokenAmountType";

export default function Page() {
Expand Down Expand Up @@ -60,7 +60,7 @@ export default function Page() {
target: cowShed.getFactoryAddress(),
callData: cowShedCall,
});
}, [cowShedSignature, hookInfo, permitTxs, cowShed]);
}, [cowShedSignature, submitHook, hookInfo, permitTxs, cowShed]);

const permitCallback = useCallback(
async (permit: {
Expand All @@ -70,7 +70,7 @@ export default function Page() {
}) => {
const permitData = await handleTokenAllowance(
BigNumber.from(permit.amount),
permit.tokenAddress as Address
permit.tokenAddress as Address,
);

if (permitData) {
Expand All @@ -85,7 +85,7 @@ export default function Page() {
}
setCurrentStepIndex((prev) => prev + 1);
},
[handleTokenAllowance]
[handleTokenAllowance],
);

const steps = useMemo(() => {
Expand All @@ -109,7 +109,7 @@ export default function Page() {
callback: cowShedCallback,
},
];
}, [hookInfo, permitTxs, permitCallback]);
}, [hookInfo, permitCallback, cowShedCallback]);

return (
<div className="flex flex-col gap-2 p-2 text-center h-full justify-between items-center">
Expand Down
4 changes: 2 additions & 2 deletions apps/create-vesting/src/components/Checkboxes.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTokenAmountTypeContext } from "#/context/TokenAmountType";
import React, { useEffect } from "react";
import { useFormContext } from "react-hook-form";
import { useTokenAmountTypeContext } from "#/context/TokenAmountType";

export const FormCheckbox = ({
name,
Expand All @@ -19,7 +19,7 @@ export const FormCheckbox = ({
console.log("state", state);
state ? setValue("amount", 1) : setValue("amount", 0);
setValue(name, state);
}, [state]);
}, [name, state, setValue]);

return (
<div className="flex items-center space-x-2">
Expand Down
2 changes: 1 addition & 1 deletion apps/create-vesting/src/context/TokenAmountType.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import {
type PropsWithChildren,
createContext,
PropsWithChildren,
useContext,
useEffect,
useState,
Expand Down
20 changes: 10 additions & 10 deletions apps/create-vesting/src/hooks/useGetHooksInfoVestAll.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import {
BaseTransaction,
type IHooksInfo,
useIFrameContext,
} from "@bleu/cow-hooks-ui";
import {
TRANSACTION_TYPES,
TransactionFactory,
} from "@bleu/utils/transactionFactory";
import { useCallback } from "react";
import { GetHooksTransactionsParams } from "./useGetHooksTransactions";
import {
BaseTransaction,
IHooksInfo,
useIFrameContext,
} from "@bleu/cow-hooks-ui";
import { type Address, maxUint256 } from "viem";
import { scaleToSecondsMapping } from "#/utils/scaleToSecondsMapping";
import { Address, maxUint256 } from "viem";
import type { GetHooksTransactionsParams } from "./useGetHooksTransactions";

export const useGetHooksInfoVestAll = () => {
const { context, cowShedProxy } = useIFrameContext();

return useCallback(
async (
params: GetHooksTransactionsParams
params: GetHooksTransactionsParams,
): Promise<IHooksInfo | undefined> => {
const {
token,
Expand Down Expand Up @@ -50,7 +50,7 @@ export const useGetHooksInfoVestAll = () => {
vestingDuration: BigInt(periodInSeconds),
vestingEscrowFactoryAddress: vestingEscrowFactoryAddress,
user: context.account,
}
},
),
]);

Expand All @@ -64,6 +64,6 @@ export const useGetHooksInfoVestAll = () => {

return { txs, permitData };
},
[context?.account, cowShedProxy]
[context?.account, cowShedProxy],
);
};
20 changes: 10 additions & 10 deletions apps/create-vesting/src/hooks/useGetHooksInfoVestAllFromSwap.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import {
BaseTransaction,
type IHooksInfo,
useIFrameContext,
} from "@bleu/cow-hooks-ui";
import {
TRANSACTION_TYPES,
TransactionFactory,
} from "@bleu/utils/transactionFactory";
import { useCallback } from "react";
import { GetHooksTransactionsParams } from "./useGetHooksTransactions";
import {
BaseTransaction,
IHooksInfo,
useIFrameContext,
} from "@bleu/cow-hooks-ui";
import { type Address, maxUint256, parseUnits } from "viem";
import { scaleToSecondsMapping } from "#/utils/scaleToSecondsMapping";
import { Address, maxUint256, parseUnits } from "viem";
import type { GetHooksTransactionsParams } from "./useGetHooksTransactions";

export const useGetHooksInfoVestAllFromSwap = () => {
const { context, cowShedProxy } = useIFrameContext();

return useCallback(
async (
params: GetHooksTransactionsParams
params: GetHooksTransactionsParams,
): Promise<IHooksInfo | undefined> => {
const {
token,
Expand Down Expand Up @@ -48,12 +48,12 @@ export const useGetHooksInfoVestAllFromSwap = () => {
cowShedProxy,
vestingDuration: BigInt(periodInSeconds),
vestingEscrowFactoryAddress: vestingEscrowFactoryAddress,
}
},
),
]);

return { txs };
},
[context?.account, cowShedProxy]
[context?.account, cowShedProxy],
);
};
16 changes: 8 additions & 8 deletions apps/create-vesting/src/hooks/useGetHooksInfoVestUserAmount.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { type IHooksInfo, useIFrameContext } from "@bleu/cow-hooks-ui";
import {
TRANSACTION_TYPES,
TransactionFactory,
} from "@bleu/utils/transactionFactory";
import { useCallback } from "react";
import { GetHooksTransactionsParams } from "./useGetHooksTransactions";
import { IHooksInfo, useIFrameContext } from "@bleu/cow-hooks-ui";
import { type Address, parseUnits } from "viem";
import { scaleToSecondsMapping } from "#/utils/scaleToSecondsMapping";
import { Address, parseUnits } from "viem";
import type { GetHooksTransactionsParams } from "./useGetHooksTransactions";

export const useGetHooksInfoVestUserAmount = () => {
const { context, cowShedProxy, jsonRpcProvider } = useIFrameContext();
const { context, cowShedProxy } = useIFrameContext();

return useCallback(
async (
params: GetHooksTransactionsParams
params: GetHooksTransactionsParams,
): Promise<IHooksInfo | undefined> => {
const {
token,
Expand All @@ -26,7 +26,7 @@ export const useGetHooksInfoVestUserAmount = () => {
const periodInSeconds = period * scaleToSecondsMapping[periodScale];
const amountWei = parseUnits(
amount.toFixed(token.decimals),
token.decimals
token.decimals,
);
const tokenAddress = token.address as Address;
const tokenSymbol = token.symbol ?? "";
Expand All @@ -36,7 +36,7 @@ export const useGetHooksInfoVestUserAmount = () => {
TransactionFactory.createRawTx(TRANSACTION_TYPES.ERC20_TRANSFER_FROM, {
type: TRANSACTION_TYPES.ERC20_TRANSFER_FROM,
token: tokenAddress,
from: context?.account!,
from: context?.account,
to: cowShedProxy,
amount: amountWei,
symbol: tokenSymbol,
Expand Down Expand Up @@ -69,6 +69,6 @@ export const useGetHooksInfoVestUserAmount = () => {

return { txs, permitData };
},
[context?.account, cowShedProxy, jsonRpcProvider]
[context?.account, cowShedProxy],
);
};
Loading

0 comments on commit d95dc4c

Please sign in to comment.