forked from l2beat/l2beat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Two sub-section risk summary (l2beat#5695)
- Loading branch information
Showing
7 changed files
with
226 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
packages/frontend/src/components/projects/sections/da-risk-summary-section.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { type Meta, type StoryObj } from '@storybook/react' | ||
import { DaRiskSummarySection } from './da-risk-summary-section' | ||
import { type RiskGroup } from './risk-summary-section' | ||
|
||
const meta = { | ||
title: 'Components/Projects/Sections/DA Risk Summary', | ||
component: DaRiskSummarySection, | ||
args: { | ||
id: 'risk-analysis', | ||
title: 'Risks summary', | ||
sectionOrder: '1', | ||
isVerified: true, | ||
redWarning: undefined, | ||
warning: undefined, | ||
}, | ||
} satisfies Meta<typeof DaRiskSummarySection> | ||
export default meta | ||
|
||
type Story = StoryObj<typeof meta> | ||
|
||
const risks: RiskGroup[] = [ | ||
{ | ||
name: 'Funds can be stolen if', | ||
start: 1, | ||
items: [ | ||
{ | ||
text: "a dishonest supermajority of Celestia validators finalizes an unavailable block, and there aren't light nodes on the network verifying data availability, or they fail at social signaling unavailable data.", | ||
isCritical: true, | ||
referencedId: '', | ||
}, | ||
{ | ||
text: "a dishonest supermajority of Celestia validators finalizes an unavailable block, and there aren't light nodes on the network verifying data availability, or they fail at social signaling unavailable data.", | ||
isCritical: true, | ||
referencedId: '', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'Funds can be frozen if', | ||
start: 3, | ||
items: [ | ||
{ | ||
text: 'the centralized validator goes down. Users cannot produce blocks themselves and exiting the system requires new block production.', | ||
isCritical: true, | ||
referencedId: '', | ||
}, | ||
], | ||
}, | ||
] as const | ||
|
||
export const Default: Story = { | ||
args: { | ||
layer: { | ||
name: 'DA Layer', | ||
risks, | ||
}, | ||
bridge: { | ||
name: 'Bridge', | ||
risks, | ||
}, | ||
}, | ||
} |
82 changes: 82 additions & 0 deletions
82
packages/frontend/src/components/projects/sections/da-risk-summary-section.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { HorizontalSeparator } from '~/components/core/horizontal-separator' | ||
import { WarningBar } from '~/components/warning-bar' | ||
import { ShieldIcon } from '~/icons/shield' | ||
import { UnverifiedIcon } from '~/icons/unverified' | ||
import { ProjectSection } from './project-section' | ||
import { EnumeratedRisks, type RiskGroup } from './risk-summary-section' | ||
import { type ProjectSectionProps } from './types' | ||
|
||
export interface DaRiskSummarySectionProps extends ProjectSectionProps { | ||
layer: { | ||
risks: RiskGroup[] | ||
name: string | ||
} | ||
bridge: { | ||
risks: RiskGroup[] | ||
name: string | ||
} | ||
warning: string | undefined | ||
isVerified: boolean | undefined | ||
redWarning: string | undefined | ||
} | ||
|
||
export function DaRiskSummarySection({ | ||
layer, | ||
bridge, | ||
isVerified, | ||
redWarning, | ||
warning, | ||
...sectionProps | ||
}: DaRiskSummarySectionProps) { | ||
if (layer.risks.concat(bridge.risks).length === 0) { | ||
return null | ||
} | ||
return ( | ||
<ProjectSection {...sectionProps}> | ||
{isVerified === false && ( | ||
<WarningBar | ||
text="This project includes unverified contracts." | ||
color="red" | ||
isCritical={true} | ||
className="mt-4" | ||
icon={UnverifiedIcon} | ||
/> | ||
)} | ||
{redWarning && ( | ||
<WarningBar | ||
text={redWarning} | ||
color="red" | ||
className="mt-4" | ||
icon={ShieldIcon} | ||
/> | ||
)} | ||
{warning && ( | ||
<WarningBar | ||
text={warning} | ||
color="yellow" | ||
isCritical={false} | ||
className="mt-4" | ||
/> | ||
)} | ||
{layer.risks.length > 0 && ( | ||
<div className="flex flex-col gap-2 "> | ||
<span className="text-xs font-medium uppercase text-zinc-500 dark:text-gray-50"> | ||
{layer.name} risks | ||
</span> | ||
<EnumeratedRisks risks={layer.risks} /> | ||
</div> | ||
)} | ||
{layer.risks.length > 0 && bridge.risks.length > 0 && ( | ||
<HorizontalSeparator className="my-4 border-divider md:my-6" /> | ||
)} | ||
{bridge.risks.length > 0 && ( | ||
<div className="flex flex-col gap-2"> | ||
<span className="text-xs font-medium uppercase text-zinc-500 dark:text-gray-50"> | ||
{bridge.name} risks | ||
</span> | ||
<EnumeratedRisks risks={bridge.risks} /> | ||
</div> | ||
)} | ||
</ProjectSection> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters