Skip to content

Commit

Permalink
fix: conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
naturexie committed Jan 30, 2025
1 parent 26bd08d commit cd85e9e
Show file tree
Hide file tree
Showing 13 changed files with 286 additions and 320 deletions.
4 changes: 1 addition & 3 deletions components/Rpc/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
import React, { useEffect, useState } from "react";
import { FiChevronDown } from "@react-icons/all-files/fi/FiChevronDown";
import { getRpcList, ping, switchPoint } from "./tool";
import { getRpcList, ping } from "./tool";
import { isMobileDevice } from "../../helpers/helpers";
import { displayCurrentRpc, ModalAddCustomNetWork } from "./component/Common";
import { MoreButtonIcon } from "./component/svg";

const RpcList = () => {
const rpclist = getRpcList();
Expand Down
80 changes: 80 additions & 0 deletions components/appInit/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { useEffect } from "react";
import { useIdle, useInterval } from "react-use";
import ModalReact from "react-modal";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
import { fetchAssets, fetchRefPrices } from "../../redux/assetsSlice";
import { fetchConfig } from "../../redux/appSlice";
import { fetchAccount } from "../../redux/accountSlice";
import { fetchAssetsMEME, fetchRefPricesMEME } from "../../redux/assetsSliceMEME";
import { fetchAccountMEME } from "../../redux/accountSliceMEME";
import { fetchConfig as fetchMemeConfig } from "../../redux/appSliceMEME";
import { fetchMarginAccount } from "../../redux/marginAccountSlice";
import { fetchMarginAccountMEME } from "../../redux/marginAccountSliceMEME";
import { fetchMarginConfig } from "../../redux/marginConfigSlice";
import { fetchMarginConfigMEME } from "../../redux/marginConfigSliceMEME";
import { fetchAllPools } from "../../redux/poolSlice";
import { getAccountId } from "../../redux/accountSelectors";

ModalReact.defaultStyles = {
overlay: {
position: "fixed",
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: "rgba(20, 22, 43, 0.8)",
zIndex: 100,
outline: "none",
},
content: {
position: "absolute",
display: "flex",
alignItems: "center",
justifyContent: "center",
top: "50%",
left: "50%",
transform: "translate(-50%, -65%)",
outline: "none",
},
};
ModalReact.setAppElement("#root");

const IDLE_INTERVAL = 90e3;
const REFETCH_INTERVAL = 60e3;

const Init = () => {
const isIdle = useIdle(IDLE_INTERVAL);
const dispatch = useAppDispatch();
const accountId = useAppSelector(getAccountId);

const fetchData = () => {
dispatch(fetchAssets()).then(() => dispatch(fetchRefPrices()));
dispatch(fetchAssetsMEME()).then(() => dispatch(fetchRefPricesMEME()));
dispatch(fetchConfig());
dispatch(fetchMemeConfig());
dispatch(fetchMarginConfig());
dispatch(fetchMarginConfigMEME());
dispatch(fetchAllPools());
};
const fetchDataAccount = () => {
dispatch(fetchAccount());
dispatch(fetchAccountMEME());
dispatch(fetchMarginAccount());
dispatch(fetchMarginAccountMEME());
};
const fetchAllData = () => {
fetchData();
fetchDataAccount();
};
useEffect(fetchData, []);
useEffect(() => {
if (accountId) {
fetchDataAccount();
}
}, [accountId]);
useInterval(fetchAllData, !isIdle ? REFETCH_INTERVAL : null);

return null;
};

export default Init;
63 changes: 63 additions & 0 deletions components/blockTip/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { useEffect, useState } from "react";
import { get_blocked } from "../../api/get-blocked";

export default function BlockTip() {
const [isBlocked, setIsBlocked] = useState(false);
const blockFeatureEnabled = true;
useEffect(() => {
if (blockFeatureEnabled) {
checkBlockedStatus();
}
}, [blockFeatureEnabled]);
function checkBlockedStatus() {
get_blocked().then((res) => {
if (res.blocked === true) {
const blockConfirmationTime = localStorage.getItem("blockConfirmationTime");
if (blockConfirmationTime) {
const currentTime = new Date().getTime();
const weekInMilliseconds = 7 * 24 * 60 * 60 * 1000;
if (currentTime - parseInt(blockConfirmationTime, 10) < weekInMilliseconds) {
setIsBlocked(false);
} else {
setIsBlocked(true);
}
} else {
setIsBlocked(true);
}
}
});
}
function handleBlockConfirmation() {
const currentTime = new Date().getTime();
localStorage.setItem("blockConfirmationTime", currentTime.toString());
setIsBlocked(false);
}
if (!(isBlocked && blockFeatureEnabled)) return null;
return (
<div
className="fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center"
style={{
zIndex: "999999999",
backdropFilter: "blur(6px)",
height: "100vh",
overflow: "hidden",
}}
>
<div
className="text-white text-center bg-dark-100 px-5 pt-9 pb-7 rounded-md border border-dark-300"
style={{ width: "278px" }}
>
<p className="text-sm">
You are prohibited from accessing app.burrow.finance due to your location or other
infringement of the Terms of Services.
</p>
<div
onClick={handleBlockConfirmation}
className="mt-6 border border-primary h-9 flex items-center justify-center rounded-md text-sm text-black text-primary cursor-pointer ml-1.5 mr-1.5"
>
Confirm
</div>
</div>
</div>
);
}
4 changes: 2 additions & 2 deletions components/popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ const Popup = ({ className }) => {
<SupplyCarousel />
</>
</SwiperSlide>
<SwiperSlide>
{/* <SwiperSlide>
<CloseButton
className="absolute cursor-pointer top-8 right-8 xsm:top-3.5 xsm:right-7 z-50"
onClick={closePopup}
/>
<div className={`${isMobileDevice() ? "mt-0" : "mt-8"} relative`}>
<StakeCarousel />
</div>
</SwiperSlide>
</SwiperSlide> */}
</Swiper>
</div>
</div>
Expand Down
24 changes: 24 additions & 0 deletions components/process/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import LoadingBar from "react-top-loading-bar";

export default function Process() {
const [progress, setProgress] = useState(0);
const router = useRouter();
useEffect(() => {
router.events.on("routeChangeStart", () => {
setProgress(30);
});
router.events.on("routeChangeComplete", () => {
setProgress(100);
});
}, []);
return (
<LoadingBar
color="#D2FF3A"
height={3}
progress={progress}
onLoaderFinished={() => setProgress(0)}
/>
);
}
79 changes: 79 additions & 0 deletions components/upgrade/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { useEffect, useState } from "react";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
import { getAccountId, getAccountPortfolio } from "../../redux/accountSelectors";
import { getAssets } from "../../redux/assetsSelectors";
import { getConfig } from "../../redux/appSelectors";
import { fetchAssets, fetchRefPrices } from "../../redux/assetsSlice";
import { fetchConfig } from "../../redux/appSlice";
import { fetchAccount, logoutAccount } from "../../redux/accountSlice";
import { logoutAccount as logoutAccountMEME } from "../../redux/accountSliceMEME";
import RpcList from "../Rpc";
import { Layout, Modal } from "..";
import Popup from "../popup";
import { ToastMessage } from "../ToastMessage";
import BalanceReminder from "../BalanceReminder";
import PubTestModal from "../PubTestModal";
import Init from "../appInit";

export default function Upgrade({ Component, pageProps }) {
const [upgrading, setUpgrading] = useState<boolean>(true);
const dispatch = useAppDispatch();
const accountId = useAppSelector(getAccountId);
const portfolio = useAppSelector(getAccountPortfolio());
const assets = useAppSelector(getAssets);
const config = useAppSelector(getConfig);
useEffect(() => {
if (
!portfolio.positions ||
!Object.keys(assets?.data || {}).length ||
!config?.booster_token_id
) {
setUpgrading(true);
fetch();
} else {
setUpgrading(false);
}
}, [
accountId,
portfolio.positions,
Object.keys(assets?.data || {}).length,
JSON.stringify(config || {}),
]);
async function fetch() {
localStorage.removeItem("persist:root");
await dispatch(fetchAssets()).then(() => dispatch(fetchRefPrices()));
await dispatch(fetchConfig());
if (accountId) {
await dispatch(fetchAccount());
// await dispatch(fetchAccountMEME()); No need to obtain a meme account when upgrading
} else {
await dispatch(logoutAccount());
await dispatch(logoutAccountMEME());
}
}
return (
<div>
{upgrading ? (
<div className="flex flex-col items-center justify-center h-screen">
<img src="/loading-brrr.gif" alt="" width="75px" />
<span className="flex items-center text-sm text-gray-300 mt-2">
Refreshing assets data...
</span>
<RpcList />
</div>
) : (
<Layout>
<Popup className="lg:hidden" />
<Init />
<Modal />
<ToastMessage />
<Component {...pageProps} />
<Popup className="xsm:hidden" />
<BalanceReminder />
<RpcList />
<PubTestModal />
</Layout>
)}
</div>
);
}
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@ref-finance/ref-sdk": "^1.4.6",
"@sentry/cli": "^2.5.2",
"@sentry/react": "^7.13.0",
"@sentry/tracing": "^7.13.0",
"@tanstack/react-query": "^5.56.2",
"@types/big.js": "^6.2.2",
"@types/bn.js": "^5.1.1",
Expand Down Expand Up @@ -83,7 +82,6 @@
"next": "latest",
"pluralize": "^8.0.0",
"postcss": "^8.4.28",
"posthog-js": "^1.20.2",
"ramda": "^0.28.0",
"react": "^18.2.0",
"react-copy-to-clipboard": "^5.1.0",
Expand Down
Loading

0 comments on commit cd85e9e

Please sign in to comment.