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

Support IPFS manifest subpath #261

Merged
merged 20 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ WIDGET_API_BASE_PATH_FOR_IPFS=

# Actual for IPFS mode
REWARDS_BACKEND_BASE_PATH=

6 changes: 4 additions & 2 deletions IPFS.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"__warning__": "For testing purposes only",
"ens": "app.jeday.eth"
"17000": {
"__warning__": "For testing purposes only",
"ens": "app.jeday.eth"
}
}
5 changes: 5 additions & 0 deletions features/ipfs/faq-placeholder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import styled from 'styled-components';

export const FaqPlaceholder = styled.div`
margin-top: 32px;
`;
4 changes: 1 addition & 3 deletions features/ipfs/home-page-ipfs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const IPFS_ROUTABLE_PAGES = [
getPathWithoutFirstSlash(SETTINGS_PATH),
];

const HomePageIpfs: FC = () => {
export const HomePageIpfs: FC = () => {
const router = useRouter();
const { asPath } = router;

Expand Down Expand Up @@ -114,5 +114,3 @@ const HomePageIpfs: FC = () => {
// Fix for runtime of `dev-ipfs` (see: package.json scripts)
return <NoSSRWrapper>{spaPage}</NoSSRWrapper>;
};

export default HomePageIpfs;
5 changes: 5 additions & 0 deletions features/ipfs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export { HomePageIpfs } from './home-page-ipfs';

export { FaqPlaceholder } from './faq-placeholder';
export { SecurityStatusBanner } from './security-status-banner';
export { InsertIpfsBaseScript } from './ipfs-base-script';
1 change: 0 additions & 1 deletion features/ipfs/outdated-hash-banner/index.ts

This file was deleted.

43 changes: 0 additions & 43 deletions features/ipfs/outdated-hash-banner/outdated-hash-banner.tsx

This file was deleted.

1 change: 1 addition & 0 deletions features/ipfs/security-status-banner/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SecurityStatusBanner } from './security-status-banner';
146 changes: 146 additions & 0 deletions features/ipfs/security-status-banner/security-status-banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import { Button, Modal } from '@lidofinance/lido-ui';

import { dynamics } from 'config';

import {
WarningIcon,
Wrapper,
WarningText,
WarningSubText,
WarningBlock,
WarningTitle,
} from './styles';
import { useVersionCheck } from './use-version-check';
import NoSsrWrapper from 'shared/components/no-ssr-wrapper';

const LIDO_TWITTER_LINK = 'https://twitter.com/LidoFinance';

type WarningContentOptions = {
isUpdateAvailable: boolean;
isVersionUnsafe: boolean;
isNotVerifiable: boolean;
isIpfs: boolean;
};

const warningContent = ({
isUpdateAvailable,
isVersionUnsafe,
isNotVerifiable,
isIpfs,
}: WarningContentOptions) => {
switch (true) {
// not veryfiable, only for IPFS
case isIpfs && isNotVerifiable:
return {
content: (
<WarningBlock>
<WarningTitle>This IPFS version can’t be verified</WarningTitle>
<WarningSubText>Please try again later</WarningSubText>
</WarningBlock>
),
canClose: false,
};
// IPFS ver is less than leastSafeVersion, but new version is available
case isIpfs && isVersionUnsafe && isUpdateAvailable:
return {
content: (
<WarningText>
This IPFS version has issues that could impact your experience
</WarningText>
),
canClose: false,
};
// we can show this banner on both infra and IPFS
case isVersionUnsafe && (!isIpfs || !isUpdateAvailable):
return {
content: (
<WarningText>
The Lido staking widget is currently down. A fix is in progress
</WarningText>
),
canClose: false,
showTwitterLink: true,
};
// outdated IPFS
case isIpfs && isUpdateAvailable:
return {
content: (
<WarningBlock>
<WarningTitle>
This is not the most up to date version of the IPFS widget
</WarningTitle>
<WarningSubText>
Please note that the functionality of this version may be lacking
</WarningSubText>
</WarningBlock>
),
canClose: true,
};
default:
return { content: null };
}
};

export const SecurityStatusBanner = () => {
const {
areConditionsAccepted,
setConditionsAccepted,
isUpdateAvailable,
isVersionUnsafe,
isNotVerifiable,
data,
} = useVersionCheck();

const { content, canClose, showTwitterLink } = warningContent({
isUpdateAvailable,
isVersionUnsafe,
isNotVerifiable,
isIpfs: dynamics.ipfsMode,
});

const showModal = !!content && !(canClose && areConditionsAccepted);

return (
<NoSsrWrapper>
<Modal open={showModal}>
<Wrapper>
<WarningIcon />
{content}
{showTwitterLink && (
<a
href={LIDO_TWITTER_LINK}
target="_self"
rel="noopener noreferrer"
>
<Button size="sm" fullwidth variant="filled">
Check X for more info
</Button>
</a>
)}
{isUpdateAvailable && (
<a
href={data.remoteCidLink}
target="_self"
rel="noopener noreferrer"
>
<Button size="sm" fullwidth variant="filled">
Click to update to the newest version
</Button>
</a>
)}
{canClose && (
<Button
size="sm"
fullwidth
color="warning"
variant="outlined"
onClick={() => setConditionsAccepted(true)}
>
Accept the possible issues and proceed
</Button>
)}
</Wrapper>
</Modal>
</NoSsrWrapper>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,33 @@ export const Wrapper = styled.div`

export const WarningText = styled(Text).attrs({
weight: 700,
size: 'lg',
})`
font-size: 26px;
text-align: center;
margin: 12px 0 28px;
text-wrap: balance;
`;

export const WarningBlock = styled.p`
text-align: center;
margin: 12px 0 28px;
`;

export const WarningTitle = styled(Text).attrs({
weight: 700,
})`
font-size: 26px;
text-align: center;
text-wrap: balance;
`;

export const WarningSubText = styled(Text).attrs({
weight: 400,
size: 'xs',
color: 'secondary',
})`
text-align: center;
margin: 0;
margin-top: 12px;
text-wrap: wrap;
`;
Loading
Loading