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

upd: fixes #364

Merged
merged 5 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
54 changes: 27 additions & 27 deletions .github/workflows/3_e2e.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
name: End-to-End Tests(Playwright)
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
# name: End-to-End Tests(Playwright)
# on:
# push:
# branches: [main, master]
# pull_request:
# branches: [main, master]

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: yarn install
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn test:e2e
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
# jobs:
# test:
# timeout-minutes: 60
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: lts/*
# - name: Install dependencies
# run: yarn install
# - name: Install Playwright Browsers
# run: yarn playwright install --with-deps
# - name: Run Playwright tests
# run: yarn test:e2e
# - uses: actions/upload-artifact@v4
# if: always()
# with:
# name: playwright-report
# path: playwright-report/
# retention-days: 30
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@astrojs/tailwind": "^5.0.2",
"@astrojs/vercel": "^5.1.0",
"@nanostores/react": "^0.7.1",
"@stabilitydao/stability": "=0.24.19",
"@stabilitydao/stability": "=0.24.20",
"@tanstack/query-sync-storage-persister": "^5.22.2",
"@tanstack/react-query": "^5.22.2",
"@tanstack/react-query-persist-client": "^5.22.2",
Expand Down
40 changes: 18 additions & 22 deletions src/layouts/AppStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useEffect } from "react";

import {createPublicClient, formatUnits, http} from "viem";
import { createPublicClient, formatUnits, http } from "viem";

import axios from "axios";

Expand Down Expand Up @@ -42,7 +42,7 @@
vaultData,
} from "@store";

import { wagmiConfig, platforms, PlatformABI, IVaultManagerABI } from "@web3";
import { wagmiConfig, platforms, PlatformABI } from "@web3";

import {
calculateAPY,
Expand Down Expand Up @@ -79,7 +79,7 @@
} from "@types";

import type { Vaults, Vault } from "@stabilitydao/stability/out/api.types";
import {sonic} from "viem/chains";
import { sonic } from "viem/chains";

const AppStore = (props: React.PropsWithChildren): JSX.Element => {
const { address, isConnected } = useAccount();
Expand Down Expand Up @@ -108,7 +108,9 @@
});*/
const sonicClient = createPublicClient({
chain: sonic,
transport: http(import.meta.env.PUBLIC_SONIC_RPC || "https://sonic.drpc.org"),
transport: http(
import.meta.env.PUBLIC_SONIC_RPC || "https://sonic.drpc.org"
),
});

const $lastTx = useStore(lastTx);
Expand Down Expand Up @@ -177,7 +179,7 @@
};

const setVaultsData = async (
data: any,

Check warning on line 182 in src/layouts/AppStore.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
prices: { [key: string]: TPriceInfo },
chainID: string
) => {
Expand Down Expand Up @@ -681,12 +683,8 @@
args: [address as TAddress],
})) as TPlatformGetBalance;

const contractVaults = (await localClient?.readContract({
address: contractBalance[6][1] as TAddress,
abi: IVaultManagerABI,
functionName: "vaults",

})) as string[];
const vaultsAddresses = contractBalance[3];
const vaultsBalances = contractBalance[5];

if (contractBalance) {
const buildingPayPerVaultTokenBalance: bigint =
Expand Down Expand Up @@ -723,20 +721,18 @@
balances.set(contractBalance);
}

if (Array.isArray(contractVaults[0])) {
if (Array.isArray(vaultsAddresses)) {
const vaultsPromise = await Promise.all(
contractVaults[0].map(
async (vault: string, index: number) => {
if (localVaults[chain.id][vault.toLowerCase()]) {
return {
[vault.toLowerCase()]: {
...localVaults[chain.id][vault.toLowerCase()],
balance: contractBalance[5][index],
},
};
}
vaultsAddresses.map(async (vault: string, index: number) => {
if (localVaults[chain.id][vault.toLowerCase()]) {
return {
[vault.toLowerCase()]: {
...localVaults[chain.id][vault.toLowerCase()],
balance: vaultsBalances[index],
},
};
}
)
})
);

localVaults[chain.id] = vaultsPromise.reduce(
Expand All @@ -745,7 +741,7 @@
) as TVaults;
}
isVaultsLoaded.set(true);
} catch (txError: any) {

Check warning on line 744 in src/layouts/AppStore.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
console.log("BLOCKCHAIN ERROR:", txError);

error.set({
Expand Down
16 changes: 16 additions & 0 deletions src/modules/SonicVaults/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ const Pagination: React.FC<IProps> = memo(({ vaults, tab, setTab }) => {
? vaults.length
: PAGINATION_VAULTS * tab,
};

// useEffect(() => {
// ///// For vaults URL filters
// const newUrl = new URL(window.location.href);
// const params = new URLSearchParams(newUrl.search);
// /////

// if (tab === 1) {
// params.delete("page");
// } else {
// params.set("page", String(tab));
// }

// newUrl.search = `?${params.toString()}`;
// window.history.pushState({}, "", newUrl.toString());
// }, [tab]);
return (
paginationNumbers.length > 1 && (
<div className="flex items-center gap-5 mt-3 font-manrope">
Expand Down
3 changes: 1 addition & 2 deletions src/modules/SonicVaults/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
const $visible = useStore(visible);
const $publicClient = useStore(publicClient);
const $platformVersions = useStore(platformVersions);
const $currentChainID = "146";
// const $currentChainID = useStore(currentChainID);
// const $assetsPrices = useStore(assetsPrices);

Expand Down Expand Up @@ -216,11 +217,9 @@
setActiveNetworks(updatedNetworks);
};

const $currentChainID = "146";

const fetchPlatformUpdates = async () => {
try {
const pendingPlatformUpgrade: any = await $publicClient?.readContract({

Check warning on line 222 in src/modules/SonicVaults/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
address: deployments[$currentChainID]?.core.platform,
abi: PlatformABI,
functionName: "pendingPlatformUpgrade",
Expand Down Expand Up @@ -290,12 +289,12 @@
}

/////***** TIME CHECK *****/////
const lockTime: any = await $publicClient?.readContract({

Check warning on line 292 in src/modules/SonicVaults/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
address: deployments[$currentChainID].core.platform,
abi: PlatformABI,
functionName: "TIME_LOCK",
});
const platformUpgradeTimelock: any = await $publicClient?.readContract({

Check warning on line 297 in src/modules/SonicVaults/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
address: deployments[$currentChainID].core.platform,
abi: PlatformABI,
functionName: "platformUpgradeTimelock",
Expand Down
16 changes: 10 additions & 6 deletions src/modules/Vault/components/InvestForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@

if (tab === "Deposit") {
setInputs(
(prevInputs: any) =>

Check warning on line 316 in src/modules/Vault/components/InvestForm/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
({
...prevInputs,
[asset]: amount,
Expand All @@ -326,7 +326,7 @@
previewDeposit(asset, amount);
}
} else {
const preview: TVaultInput | any = {};

Check warning on line 329 in src/modules/Vault/components/InvestForm/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
for (let i = 0; i < option.length; i++) {
preview[option[i]] = amount as string;
}
Expand All @@ -347,7 +347,7 @@
};

const resetInputs = (options: string[] = option) => {
const reset: TVaultInput | any = {};

Check warning on line 350 in src/modules/Vault/components/InvestForm/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

for (let i = 0; i < options.length; i++) {
reset[options[i]] = "";
Expand Down Expand Up @@ -595,7 +595,7 @@
);
const zapInputHandler = (amount: string, asset: string) => {
setInputs(
(prevInputs: any) =>

Check warning on line 598 in src/modules/Vault/components/InvestForm/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
({
...prevInputs,
[asset]: amount,
Expand All @@ -610,7 +610,9 @@
} else {
setLoader(false);
}

if (tab === "Withdraw" && option[0] === underlyingToken?.address) {
return;
}
//@ts-ignore
debouncedZap(amount, asset);
};
Expand Down Expand Up @@ -920,6 +922,7 @@
depositCCF(amount);
return;
}

try {
const decimals = Number(getTokenData(option[0])?.decimals);

Expand Down Expand Up @@ -1656,6 +1659,7 @@
amount: formatUnits(result[0], 18),
},
]);
setLoader(false);
setButton("withdraw");
} else {
let assetsLength = defaultOption?.assetsArray.map(
Expand Down Expand Up @@ -2028,10 +2032,10 @@
useEffect(() => {
setUnderlyingShares(false);
setZapShares(false);
if (option[0] === underlyingToken?.address) {
setIsRefresh(false);
return;
}
// if (option[0] === underlyingToken?.address) {
// setIsRefresh(false);
// return;
// }
setIsRefresh(true);
}, [option, inputs]);

Expand Down Expand Up @@ -2355,7 +2359,7 @@
>
{loader && !transactionInProgress ? (
<div
className={`text-[18px] w-[372px] ${ichiAllow.every((ichi) => ichi === true) ? "h-[64px]" : "h-[116px] flex items-end justify-end"}`}
className={`text-[18px] w-[320px] ${ichiAllow.every((ichi) => ichi === true) ? "h-[64px]" : "h-[116px] flex items-end justify-end"}`}
>
<ShareSkeleton />
</div>
Expand Down
8 changes: 3 additions & 5 deletions src/modules/Vault/components/YieldRates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useStore } from "@nanostores/react";

import { HoldTable, VSHoldTableCell, YieldTableCell } from "./table";

import { HoldModal, HeadingText } from "@ui";
import { TextModal, HeadingText } from "@ui";

import { connected } from "@store";

Expand Down Expand Up @@ -255,11 +255,9 @@ const YieldRates: React.FC<IProps> = memo(({ vault }) => {
)}
</div>
{modal && (
<HoldModal
<TextModal
setModalState={setModal}
table={
<HoldTable shareData={shareData} holdData={vault.assetsVsHold} />
}
text="VS HODL APR compares depositing tokens into a vault vs holding them in a wallet with it's ratio and timeline."
/>
)}
</div>
Expand Down
11 changes: 6 additions & 5 deletions src/ui/Toast/HoldModal.tsx → src/ui/Modals/TextModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { useEffect, useRef } from "react";

interface IProps {
setModalState: React.Dispatch<React.SetStateAction<boolean>>;
table: JSX.Element;
text: String;
}

const HoldModal: React.FC<IProps> = ({ setModalState, table }) => {
const TextModal: React.FC<IProps> = ({ setModalState, text }) => {
const modalRef = useRef<HTMLDivElement>(null);

const handleClickOutside = (event: React.MouseEvent | MouseEvent) => {
Expand All @@ -15,14 +15,15 @@ const HoldModal: React.FC<IProps> = ({ setModalState, table }) => {
};

useEffect(() => {
document.body.style.overflow = "hidden";
document.body.style.overflowY = "hidden";
document.addEventListener("mousedown", handleClickOutside);

return () => {
document.body.style.overflowY = "unset";
document.removeEventListener("mousedown", handleClickOutside);
};
}, []);

return (
<div>
<div className="bg-[#13141f] w-full h-full fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-[50] opacity-80"></div>
Expand Down Expand Up @@ -94,10 +95,10 @@ const HoldModal: React.FC<IProps> = ({ setModalState, table }) => {
</svg>

<div className="p-10 flex items-start justify-center flex-col gap-4">
{table}
{text}
</div>
</div>
</div>
);
};
export { HoldModal };
export { TextModal };
4 changes: 2 additions & 2 deletions src/ui/Skeletons/ShareSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const ShareSkeleton = (props: React.SVGProps<SVGSVGElement>): JSX.Element => {
return (
<svg
width="900"
width="320"
height="63"
viewBox="0 0 900 63"
viewBox="0 0 320 63"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Toast } from "./Toast";
import { HoldModal } from "./Toast/HoldModal";
import { TextModal } from "./Modals/TextModal";
import { APRtimeSwitcher } from "./APRtimeSwitcher";
import { ErrorMessage } from "./ErrorMessage";
import { FeeAPRModal } from "./FeeAPRModal";
Expand Down Expand Up @@ -27,7 +27,7 @@ import { Skeleton } from "./Skeletons/Skeleton";

export {
Toast,
HoldModal,
TextModal,
APRtimeSwitcher,
AssetsSkeleton,
ChartSkeleton,
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10922,4 +10922,4 @@ zustand@4.4.1:
zwitch@^2.0.0, zwitch@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-2.0.4.tgz#c827d4b0acb76fc3e685a4c6ec2902d51070e9d7"
integrity sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==
integrity sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==
Loading