Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Solana integration staking #4857

Closed
wants to merge 76 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
df8f3b4
add solana memo field
konoart Oct 19, 2021
029671f
add allow not created recipient checkbox
konoart Oct 19, 2021
9f24ca8
tweak allow not created recipient checkbox
konoart Oct 19, 2021
0169929
update yarn.lock
konoart Oct 21, 2021
01dee72
remove local specifics
konoart Oct 21, 2021
41ac293
restore yarn.lock
konoart Oct 22, 2021
e09bad9
Merge remote-tracking branch 'upstream/develop' into solana-integration
konoart Nov 11, 2021
e911736
solana: add backbone for opt in flow
konoart Nov 11, 2021
70e57fa
solana improve opt in flow
konoart Nov 15, 2021
35561a4
solana adapt reworked tx model
konoart Nov 18, 2021
68ef7ce
solana add en translations for errors
konoart Nov 18, 2021
e2a1fc6
Merge remote-tracking branch 'upstream/develop' into solana-integration
konoart Nov 24, 2021
e8ee104
Merge remote-tracking branch 'upstream/develop' into solana-integration
konoart Dec 1, 2021
09ead31
solana add info link to send flow
konoart Dec 2, 2021
5fae781
solana switch to common info
konoart Dec 6, 2021
efa058b
Merge remote-tracking branch 'upstream/develop' into solana-integration
konoart Dec 8, 2021
5812ba2
solana remove redundant error
konoart Dec 9, 2021
24cbff4
Merge remote-tracking branch 'upstream/develop' into solana-integration
konoart Dec 10, 2021
a7623e0
solana improve send memo
konoart Dec 10, 2021
1e06138
Merge remote-tracking branch 'upstream/develop' into solana-integration
konoart Dec 13, 2021
26ffeda
Merge remote-tracking branch 'upstream/develop' into solana-integration
konoart Dec 14, 2021
92e8a14
solana remove token related code
konoart Dec 14, 2021
3dd1a24
solana initial staking
konoart Dec 21, 2021
a7c31c3
solana improve staking
konoart Dec 21, 2021
36c1afe
solana improve staking
konoart Dec 22, 2021
c6ddd32
solana improve staking
konoart Dec 22, 2021
9297e3c
solana use stakes with meta
konoart Dec 27, 2021
edcc377
solana add meta to validators
konoart Dec 27, 2021
e848fec
solana make validators searchable
konoart Dec 27, 2021
3bbe5ee
solana improve staking
konoart Dec 28, 2021
27d668c
solana fix delegation amount
konoart Dec 29, 2021
1c93e7d
solana add stake reward
konoart Dec 29, 2021
60540f2
solana add unstake flow modal
konoart Dec 29, 2021
3f77d9e
Merge remote-tracking branch 'upstream/develop' into solana-integrati…
konoart Feb 2, 2022
8ba1301
solana show correct delegation dialogs
konoart Feb 9, 2022
f181fab
solana add delegation modals
konoart Feb 11, 2022
1da1817
Merge remote-tracking branch 'upstream/develop' into solana-integrati…
konoart Feb 14, 2022
4a9af3f
solana build undelegate flow modal
konoart Feb 14, 2022
4eb9133
solana build delegation reactivate flow modal
konoart Feb 14, 2022
e802972
solana build delegation withdraw modal flow
konoart Feb 15, 2022
436bfc5
solana build delegation modal flow
konoart Feb 15, 2022
7f0b2b4
solana improve delegation ux
konoart Feb 18, 2022
fbb8a9c
solana improve delegation ux
konoart Feb 18, 2022
5314455
solana improve staking ux
konoart Feb 22, 2022
e70286e
solana address mandatory autodelegate on staking
konoart Feb 22, 2022
8123052
solana add delegation activate flow
konoart Feb 22, 2022
64af3ed
solana rename error prop
konoart Feb 22, 2022
c7996d1
Merge remote-tracking branch 'upstream/develop' into solana-integrati…
konoart Mar 14, 2022
b77a7cf
solana switch to validators app validators
konoart Mar 14, 2022
42a9f26
solana refactor delegation validators
konoart Mar 15, 2022
4dcb183
solana fallback to explorer if no validator url
konoart Mar 15, 2022
e76495f
solana show correct stakes meta info
konoart Mar 16, 2022
4a6adc5
solana add fee error to stake withdraw
konoart Mar 16, 2022
dee090e
solana show fee error on stake withdraw & activate
konoart Mar 17, 2022
5242a84
solana add validator step to stake deactivate
konoart Mar 17, 2022
a643a2d
solana add validator step to reactivate stake
konoart Mar 17, 2022
ea021ab
solana update delegated amount of a stake
konoart Mar 17, 2022
4f913d2
solana use shuffled staking validators
konoart Mar 21, 2022
0d325e3
solana refine validators search
konoart Mar 21, 2022
94420ab
solana clean delegations
konoart Mar 21, 2022
a016bd5
solana organize imports
konoart Mar 21, 2022
34eb285
solana update tracking info
konoart Mar 21, 2022
f54a2de
solana add delegation translations
konoart Mar 21, 2022
ac095ed
Merge remote-tracking branch 'upstream/develop' into solana-integrati…
konoart Mar 22, 2022
31c733c
solana add loading icon to stake in transition
konoart Mar 22, 2022
d4bea93
solana fix stake tooltip color
konoart Mar 22, 2022
ba27b5b
solana add account balance summary footer
konoart Mar 22, 2022
4686f77
solana add staking info modal
konoart Mar 22, 2022
c5a6204
solana refactor staking validators field
konoart Mar 29, 2022
6d685b6
solana move validator row to a shared cmp
konoart Mar 29, 2022
9146985
solana update stake validator row
konoart Mar 29, 2022
d908ee5
solana add border around validators field
konoart Mar 29, 2022
2e6b3b9
solana switch to ledger by figment TC footer for staking flow
konoart Mar 29, 2022
a092669
solana fix stake reactivate error i18n
konoart Mar 30, 2022
4b3cfa7
solana refactor stake active percent calc
konoart Apr 1, 2022
9773385
solana show percent as fixed number
konoart Apr 4, 2022
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
2 changes: 2 additions & 0 deletions src/config/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ export const urls = {
website: "https://elrond.com",
},
solana: {
staking: "https://support.ledger.com",
recipient_info: "https://support.ledger.com",
ledgerByFigmentTC: "https://support.ledger.com",
},
};
12 changes: 10 additions & 2 deletions src/renderer/components/Delegation/ValidatorRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const Row: ThemedComponent<{ active: boolean, disabled: boolean }> = styled(Box)
: ""}
`;

type ValidatorRowProps = {
export type ValidatorRowProps = {
validator: { address: string },
icon: React$Node,
title: React$Node,
Expand All @@ -188,6 +188,7 @@ type ValidatorRowProps = {
unit: Unit,
onMax?: () => void,
shouldRenderMax?: boolean,
className?: string,
};

const ValidatorRow = ({
Expand All @@ -207,6 +208,7 @@ const ValidatorRow = ({
unit,
onMax,
shouldRenderMax,
className,
}: ValidatorRowProps) => {
const inputRef = useRef();
const onTitleClick = useCallback(
Expand Down Expand Up @@ -269,7 +271,13 @@ const ValidatorRow = ({
);

return (
<Row style={style} disabled={!value && disabled} active={!!value} onClick={onRowClick}>
<Row
className={className}
style={style}
disabled={!value && disabled}
active={!!value}
onClick={onRowClick}
>
{icon}
<InfoContainer>
<Title onClick={onTitleClick}>
Expand Down
144 changes: 144 additions & 0 deletions src/renderer/families/solana/AccountBalanceSummaryFooter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
// @flow

import { getAccountUnit } from "@ledgerhq/live-common/lib/account";
import { formatCurrencyUnit } from "@ledgerhq/live-common/lib/currencies";
import React from "react";
import { Trans } from "react-i18next";
import { useSelector } from "react-redux";
import styled from "styled-components";
import Box from "~/renderer/components/Box/Box";
import Discreet, { useDiscreetMode } from "~/renderer/components/Discreet";
import Text from "~/renderer/components/Text";
import ToolTip from "~/renderer/components/Tooltip";
import InfoCircle from "~/renderer/icons/InfoCircle";
import { localeSelector } from "~/renderer/reducers/settings";
import type { ThemedComponent } from "~/renderer/styles/StyleProvider";
import type { Account } from "@ledgerhq/live-common/lib/types";
import { BigNumber } from "bignumber.js";

const Wrapper: ThemedComponent<*> = styled(Box).attrs(() => ({
horizontal: true,
mt: 4,
p: 5,
pb: 0,
}))`
border-top: 1px solid ${p => p.theme.colors.palette.text.shade10};
`;

const BalanceDetail = styled(Box).attrs(() => ({
flex: "0.25 0 auto",
vertical: true,
alignItems: "start",
}))`
&:nth-child(n + 3) {
flex: 0.75;
}
`;

const TitleWrapper = styled(Box).attrs(() => ({ horizontal: true, alignItems: "center", mb: 1 }))``;

const Title = styled(Text).attrs(() => ({
fontSize: 4,
ff: "Inter|Medium",
color: "palette.text.shade60",
}))`
line-height: ${p => p.theme.space[4]}px;
margin-right: ${p => p.theme.space[1]}px;
`;

const AmountValue = styled(Text).attrs(() => ({
fontSize: 6,
ff: "Inter|SemiBold",
color: "palette.text.shade100",
}))``;

type Props = {
account: Account,
countervalue: any,
};

const AccountBalanceSummaryFooter = ({ account, countervalue }: Props) => {
const discreet = useDiscreetMode();
const locale = useSelector(localeSelector);
if (!account.solanaResources) return null;

const { spendableBalance: _spendableBalance, solanaResources } = account;

const { stakes } = solanaResources;

const _delegatedBalance = new BigNumber(
stakes.reduce((sum, s) => sum + (s.delegation?.stake ?? 0), 0),
);

const _delegatedWithdrawableBalance = new BigNumber(
stakes.reduce((sum, s) => sum + s.withdrawable, 0),
);

const unit = getAccountUnit(account);

const formatConfig = {
disableRounding: true,
alwaysShowSign: false,
showCode: true,
discreet,
locale,
};

const spendableBalance = formatCurrencyUnit(unit, _spendableBalance, formatConfig);

const delegatedBalance = formatCurrencyUnit(unit, _delegatedBalance, formatConfig);

const delegatedWithdrawableBalance = formatCurrencyUnit(
unit,
_delegatedWithdrawableBalance,
formatConfig,
);

return (
<Wrapper>
<BalanceDetail>
<ToolTip content={<Trans i18nKey="account.availableBalanceTooltip" />}>
<TitleWrapper>
<Title>
<Trans i18nKey="account.availableBalance" />
</Title>
<InfoCircle size={13} />
</TitleWrapper>
</ToolTip>
<AmountValue>
<Discreet>{spendableBalance}</Discreet>
</AmountValue>
</BalanceDetail>
<BalanceDetail>
<ToolTip content={<Trans i18nKey="solana.delegation.delegatedInfoTooltip" />}>
<TitleWrapper>
<Title>
<Trans i18nKey="account.delegatedAssets" />
</Title>
<InfoCircle size={13} />
</TitleWrapper>
</ToolTip>
<AmountValue>
<Discreet>{delegatedBalance}</Discreet>
</AmountValue>
</BalanceDetail>
{_delegatedWithdrawableBalance.gt(0) && (
<BalanceDetail>
<ToolTip content={<Trans i18nKey="solana.delegation.withdrawableInfoTooltip" />}>
<TitleWrapper>
<Title>
<Trans i18nKey="solana.delegation.withdrawableTitle" />
</Title>
<InfoCircle size={13} />
</TitleWrapper>
</ToolTip>
<AmountValue>
<Discreet>{delegatedWithdrawableBalance}</Discreet>
</AmountValue>
</BalanceDetail>
)}
</Wrapper>
);
};

export default AccountBalanceSummaryFooter;
5 changes: 5 additions & 0 deletions src/renderer/families/solana/AccountBodyHeader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @flow

import Delegation from "./Delegation";

export default Delegation;
48 changes: 48 additions & 0 deletions src/renderer/families/solana/AccountHeaderManageActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// @flow
import { getMainAccount } from "@ledgerhq/live-common/lib/account";
import { canDelegate } from "@ledgerhq/live-common/lib/families/cosmos/logic";
import type { Account, AccountLike } from "@ledgerhq/live-common/lib/types";
import invariant from "invariant";
import { useCallback } from "react";
import { useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
import { openModal } from "~/renderer/actions/modals";
import IconChartLine from "~/renderer/icons/ChartLine";

type Props = {
account: AccountLike,
parentAccount: ?Account,
};

const AccountHeaderActions = ({ account, parentAccount }: Props) => {
const { t } = useTranslation();
const dispatch = useDispatch();
const mainAccount = getMainAccount(account, parentAccount);

const { solanaResources } = mainAccount;

invariant(solanaResources, "solana account expected");

if (solanaResources.stakes.length > 0) {
return null;
}

const onClick = useCallback(() => {
dispatch(
openModal("MODAL_SOLANA_REWARDS_INFO", {
account,
}),
);
}, [dispatch, account]);

return [
{
key: "solana",
onClick: onClick,
icon: IconChartLine,
label: t("delegation.title"),
},
];
};

export default AccountHeaderActions;
65 changes: 65 additions & 0 deletions src/renderer/families/solana/Delegation/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// @flow

import React from "react";
import { Trans } from "react-i18next";
import styled from "styled-components";
import Box from "~/renderer/components/Box/Box";
import { HeaderWrapper } from "~/renderer/components/TableContainer";
import type { ThemedComponent } from "~/renderer/styles/StyleProvider";

export const TableLine: ThemedComponent<{}> = styled(Box).attrs(() => ({
ff: "Inter|SemiBold",
color: "palette.text.shade60",
horizontal: true,
alignItems: "center",
justifyContent: "flex-start",
fontSize: 3,
flex: 1.125,
pr: 2,
}))`
box-sizing: border-box;
&:last-child {
justify-content: flex-end;
flex: 0.5;
text-align: right;
white-space: nowrap;
}
`;

export const Header = () => (
<HeaderWrapper>
<TableLine>
<Trans i18nKey="delegation.validator" />
</TableLine>
<TableLine>
<Trans i18nKey="delegation.status" />
</TableLine>
<TableLine>
<Trans i18nKey="delegation.delegated" />
</TableLine>
<TableLine>
<Trans i18nKey="solana.delegation.active" />
</TableLine>
<TableLine>
<Trans i18nKey="solana.delegation.availableBalance" />
</TableLine>
<TableLine />
</HeaderWrapper>
);

export const UnbondingHeader = () => (
<HeaderWrapper>
<TableLine>
<Trans i18nKey="delegation.validator" />
</TableLine>
<TableLine>
<Trans i18nKey="delegation.status" />
</TableLine>
<TableLine>
<Trans i18nKey="delegation.delegated" />
</TableLine>
<TableLine>
<Trans i18nKey="delegation.completionDate" />
</TableLine>
</HeaderWrapper>
);
Loading