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

Pool Transition Api integration #3472

Merged
merged 35 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
72d051b
wip
SorinC6 Apr 9, 2024
6fea538
add pool transition mock UI
SorinC6 Apr 10, 2024
75ad913
updates
SorinC6 Apr 12, 2024
d79ae43
fix flow
SorinC6 Apr 12, 2024
ad6131d
add intl
SorinC6 Apr 12, 2024
ae0dfde
add missing intl
SorinC6 Apr 12, 2024
e03da02
Merge branch 'develop' into sorin/YOEXT-1069/pool-transition
SorinC6 Apr 12, 2024
852b777
move delegation function to store and remove duplication
SorinC6 Apr 16, 2024
799f208
remove unused vars
SorinC6 Apr 16, 2024
03b0bcf
move icon
SorinC6 Apr 16, 2024
cfa4378
emobe console.logs
SorinC6 Apr 16, 2024
583ebf5
fix suggested pool id
SorinC6 Apr 17, 2024
700179b
add pool icon
SorinC6 Apr 17, 2024
05a7fa0
updates
SorinC6 Apr 18, 2024
97da1c3
wip
SorinC6 Apr 9, 2024
397f1d4
Merge branch 'develop' into sorin/YOEXT-1069/pool-transition
SorinC6 May 1, 2024
d6b2c3d
remove green border
SorinC6 May 1, 2024
a2dd977
add and update right icon svg
SorinC6 May 1, 2024
72bbac0
fix styles
SorinC6 May 1, 2024
9cdbed6
banner fixes
SorinC6 May 1, 2024
88b3619
fix padding
SorinC6 May 1, 2024
ba4f6c2
move dialog
SorinC6 May 1, 2024
1c32ac2
Merge branch 'develop' into sorin/YOEXT-1069/pool-transition
SorinC6 May 13, 2024
11a8176
wip
SorinC6 May 16, 2024
1327238
add transition pool api
SorinC6 May 16, 2024
610b837
remove arg
SorinC6 May 16, 2024
80d8c63
fix naming
SorinC6 May 16, 2024
e54082e
fixes
SorinC6 May 21, 2024
bd42b05
Merge branch 'develop' into sorin/YOEXT-1069/pool-transition
vsubhuman May 21, 2024
11a8907
Merge branch 'develop' into sorin/YOEXT-1069/pool-transition
vsubhuman May 21, 2024
6e35d10
yoroi-lib update
vsubhuman May 21, 2024
2cb8ec0
await fix
vsubhuman May 21, 2024
48c9707
flow and lint fixes
vsubhuman May 22, 2024
6b110ec
lint fixes
vsubhuman May 22, 2024
20c0595
lint fixes
vsubhuman May 22, 2024
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { Box } from '@mui/material';

type Props = {|
sx: any,
|}
sx?: any,
|};

export default function Separator({ sx }: Props): React$Node {
return <Box width="100%" height="1px" bgcolor="grayscale.200" sx={sx} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class SuccessPageRevamp extends Component<Props> {
closeInfo ? <DialogCloseButton onClose={closeInfo.onClose} isRevampLayout /> : undefined
}
>
<Box maxWidth="600px" outline="10px solid green">
<Box maxWidth="600px">
<Box
sx={{
display: 'flex',
Expand All @@ -58,7 +58,13 @@ export class SuccessPageRevamp extends Component<Props> {
>
<SuccessImg />
</Box>
<Typography component="div" variant="body1" color="grayscale.900" textAlign="left" mt="4px">
<Typography
component="div"
variant="body1"
color="grayscale.900"
textAlign="left"
mt="4px"
>
{text}
</Typography>
{this.props.closeInfo == null && <LoadingSpinner />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ class DelegationTxDialog extends Component<Props & InjectedLayoutProps> {
{intl.formatMessage(globalMessages.stakePoolHash)}
</Typography>
<Box>
<Typography component="div"
<Typography
component="div"
variant="body1"
sx={{ '& > div > p': { p: '2px 3px' }, px: '2px', ml: '-3px', mt: '-2px' }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,78 @@ import globalMessages from '../../../../i18n/global-messages';
import { SocialMediaStakePool } from './StakePool/StakePool';
import type { PoolData } from '../../../../containers/wallet/staking/SeizaFetcher';
import { getAvatarFromPoolId } from '../utils';
import { Alert } from '@mui/material';
import { Stack } from '@mui/material';
import type { PoolTransition } from '../../../../stores/toplevel/DelegationStore';

type Props = {|
delegatedPool: PoolData,
+undelegate: void | (void => Promise<void>),
poolTransition?: PoolTransition,
delegateToSpecificPool: (id: ?string) => void,
|};

type Intl = {|
intl: $npm$ReactIntl$IntlShape,
|};

function DelegatedStakePoolCard({ delegatedPool, undelegate, intl }: Props & Intl): Node {
function DelegatedStakePoolCard({
delegatedPool,
undelegate,
intl,
poolTransition,
delegateToSpecificPool,
}: Props & Intl): Node {
const { id, name, ticker, poolSize, share, avatar, roa, socialLinks, websiteUrl } =
delegatedPool || {};
const avatarGenerated = getAvatarFromPoolId(id);
const renderDelegationBtn = () => {
if (poolTransition?.shouldShowTransitionFunnel) {
return (
<UpdatePoolButton
variant="danger"
onClick={() => delegateToSpecificPool(poolTransition.suggestedPool?.hash ?? '')}
>
{intl.formatMessage(globalMessages.updatePool)}
</UpdatePoolButton>
);
}

return (
<UndelegateButton
variant="text"
onClick={undelegate}
disabled={!undelegate}
sx={{
lineHeight: '21px',
'&.MuiButton-sizeMedium': {
height: 'unset',
p: '9px 15px',
},
}}
>
{intl.formatMessage(globalMessages.undelegateLabel)}
</UndelegateButton>
);
};

return (
<Card sx={{ border: '1px solid', borderColor: 'grayscale.200', bgcolor: 'background.card' }}>
<Stack direction="row" px={4} py={2} alignItems="center">
<Typography component="div" variant="h5" color="common.black" fontWeight={500}>
{intl.formatMessage(globalMessages.stakePoolDelegated)}
</Typography>
{renderDelegationBtn()}
</Stack>
<Box
sx={{
padding: '16px 9px 16px 24px',
borderBottom: '1px solid',
borderBottomColor: 'grayscale.200',
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
}}
>
<Typography component="div" variant="h5" color="common.black" fontWeight={500}>
{intl.formatMessage(globalMessages.stakePoolDelegated)}
</Typography>
<UndelegateButton
variant="text"
onClick={undelegate}
disabled={!undelegate}
sx={{
lineHeight: '21px',
'&.MuiButton-sizeMedium': {
height: 'unset',
p: '9px 15px',
},
}}
>
{intl.formatMessage(globalMessages.undelegateLabel)}
</UndelegateButton>
</Box>
></Box>
<Wrapper sx={{ paddingBottom: 0 }}>
<AvatarWrapper>
{avatar != null ? (
Expand All @@ -63,7 +90,13 @@ function DelegatedStakePoolCard({ delegatedPool, undelegate, intl }: Props & Int
)}
</AvatarWrapper>
<Box marginLeft="16px" sx={{ display: 'flex', alignItems: 'flex-start', gap: '10px' }}>
<Typography component="div" color="grayscale.max" variant="body1" fontWeight="medium" mb="3px">
<Typography
component="div"
color="grayscale.max"
variant="body1"
fontWeight="medium"
mb="3px"
>
{ticker !== undefined ? `[${ticker}]` : ''} {name}
</Typography>
<SocialMediaStakePool
Expand All @@ -73,10 +106,11 @@ function DelegatedStakePoolCard({ delegatedPool, undelegate, intl }: Props & Int
/>
</Box>
</Wrapper>
<Wrapper justifyContent="space-between" sx={{ paddingBottom: 0 }}>
<Wrapper justifyContent="space-between" sx={{ paddingBottom: '25px' }}>
{roa != null ? (
<Box sx={{ display: 'flex', flexFlow: 'column' }}>
<Typography component="div"
<Typography
component="div"
variant="caption1"
color="grayscale.500"
sx={{ textTransform: 'uppercase' }}
Expand All @@ -90,7 +124,8 @@ function DelegatedStakePoolCard({ delegatedPool, undelegate, intl }: Props & Int
) : null}
{poolSize != null && (
<Box sx={{ display: 'flex', flexFlow: 'column' }}>
<Typography component="div"
<Typography
component="div"
variant="caption1"
color="grayscale.500"
sx={{ textTransform: 'uppercase' }}
Expand All @@ -104,7 +139,8 @@ function DelegatedStakePoolCard({ delegatedPool, undelegate, intl }: Props & Int
)}
{share != null && (
<Box sx={{ display: 'flex', flexFlow: 'column' }}>
<Typography component="div"
<Typography
component="div"
variant="caption1"
color="grayscale.500"
sx={{ textTransform: 'uppercase' }}
Expand All @@ -117,16 +153,38 @@ function DelegatedStakePoolCard({ delegatedPool, undelegate, intl }: Props & Int
</Box>
)}
</Wrapper>
{poolTransition?.shouldShowTransitionFunnel && (
<SAlert severity="error">
<Typography variant="body2" mt="1px" ml="4px" color="grayscale.900">
{intl.formatMessage(globalMessages.poolNotGenerating)}
</Typography>
</SAlert>
)}
</Card>
);
}
export default (injectIntl(observer(DelegatedStakePoolCard)): ComponentType<Props>);

const Card = styled(Box)({
borderRadius: '8px',
flex: '1 1 100%',
display: 'flex',
flexDirection: 'column',
justifyContent: 'flex-end',
});

const SAlert = styled(Alert)({
width: '100%',
justifyContent: 'center',
backgroundColor: 'magenta.100',
borderTopLeftRadius: '0px',
borderTopRightRadius: '0px',
height: '40px',
padding: 0,
'& .MuiAlert-icon': {
color: 'magenta.500',
fontSize: '26px',
margin: '0',
},
});

const Wrapper: any = styled(Box)({
Expand All @@ -152,3 +210,18 @@ const UndelegateButton: any = styled(Button)({
width: 'unset',
marginLeft: 'auto',
});
const UpdatePoolButton: any = styled(Button)(({ theme }) => ({
minWidth: 'auto',
width: 'unset',
marginLeft: 'auto',
background: theme.palette.magenta['500'],
color: 'white',
height: '40px',
width: '140px',
padding: '0px !important',
fontSize: '14px',
'&:hover': {
backgroundColor: theme.palette.magenta['500'],
color: 'white',
},
}));
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export const RewardHistoryItem = ({
<AccordionSummary aria-controls={poolId + '-content'} id={poolId + '-header'}>
<Box>
<Box display="block">
<Typography component="div" color="var(--yoroi-palette-gray-600)">Stake Pool</Typography>
<Typography component="div" color="var(--yoroi-palette-gray-600)">
Stake Pool
</Typography>
</Box>
<Box display="flex">
<AvatarWrapper>
Expand Down Expand Up @@ -159,11 +161,7 @@ function RewardHistoryGraph({
const rewardList = rewardsGraphData.items?.perEpochRewards;
const title = intl.formatMessage(globalMessages.rewardHistory);
return (
<Box
p="24px"
pt="4px"
sx={{ display: 'flex', flexFlow: 'column', justifyContent: 'space-between' }}
>
<Box p="24px" sx={{ display: 'flex', flexFlow: 'column', justifyContent: 'space-between' }}>
<Box
sx={{
display: 'flex',
Expand Down
Loading
Loading