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

Bugfix: Solana linting #4902

Merged
merged 8 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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 src/renderer/families/solana/AccountHeaderManageActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow
import { getMainAccount } from "@ledgerhq/live-common/lib/account";
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";
Expand Down
7 changes: 0 additions & 7 deletions src/renderer/families/solana/Delegation/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ const Ellipsis: ThemedComponent<{}> = styled.div`
white-space: nowrap;
`;

const Divider: ThemedComponent<*> = styled.div`
width: 100%;
height: 1px;
margin-bottom: ${p => p.theme.space[1]}px;
background-color: ${p => p.theme.colors.palette.divider};
`;

const ManageDropDownItem = ({
item,
isActive,
Expand Down
3 changes: 0 additions & 3 deletions src/renderer/families/solana/Delegation/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @flow
import { getAccountUnit } from "@ledgerhq/live-common/lib/account";
import { getAddressExplorer, getDefaultExplorerView } from "@ledgerhq/live-common/lib/explorers";
import { useSolanaStakesWithMeta } from "@ledgerhq/live-common/lib/families/solana/react";
import type { SolanaStakeWithMeta } from "@ledgerhq/live-common/lib/families/solana/types";
Expand Down Expand Up @@ -42,8 +41,6 @@ const Delegation = ({ account }: Props) => {

const stakesWithMeta = useSolanaStakesWithMeta(account.currency, solanaResources.stakes);

const unit = getAccountUnit(account);

const onEarnRewards = useCallback(() => {
dispatch(
openModal("MODAL_SOLANA_DELEGATE", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export default function StepValidator({
account && account.solanaResources && transaction,
"solana account, resources and transaction required",
);
const { solanaResources } = account;

const updateValidator = ({ address }: { address: string }) => {
const bridge: AccountBridge<Transaction> = getAccountBridge(account, parentAccount);
Expand All @@ -51,13 +50,16 @@ export default function StepValidator({
<TrackPage category="Solana Delegation" name="Step Validator" />
{error && <ErrorBanner error={error} />}
{status.errors.fee && <ErrorDisplay error={status.errors.fee} />}
<ValidatorsField
account={account}
chosenVoteAccAddr={chosenVoteAccAddr}
onChangeValidator={updateValidator}
status={status}
t={t}
/>
{
// $FlowFixMe FIXME Not sure what's wrong here
<ValidatorsField
account={account}
chosenVoteAccAddr={chosenVoteAccAddr}
onChangeValidator={updateValidator}
status={status}
t={t}
/>
}
</Box>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
// @flow
import { getAccountUnit } from "@ledgerhq/live-common/lib/account";
import { formatCurrencyUnit } from "@ledgerhq/live-common/lib/currencies";
import {
useLedgerFirstShuffledValidators,
useSolanaStakesWithMeta,
} from "@ledgerhq/live-common/lib/families/solana/react";
import { BigNumber } from "bignumber.js";
import invariant from "invariant";
import React from "react";
import { Trans } from "react-i18next";
import TrackPage from "~/renderer/analytics/TrackPage";
import Box from "~/renderer/components/Box";
import Button from "~/renderer/components/Button";
import ErrorBanner from "~/renderer/components/ErrorBanner";
import FirstLetterIcon from "~/renderer/components/FirstLetterIcon";
import Image from "~/renderer/components/Image";
import AccountFooter from "~/renderer/modals/Send/AccountFooter";
import { Ellipsis } from "../../shared/components/Ellipsis";
import ErrorDisplay from "../../shared/components/ErrorDisplay";
import ValidatorRow from "../../shared/components/ValidatorRow";
import type { StepProps } from "../types";
Expand Down Expand Up @@ -50,8 +45,7 @@ export default function StepValidator({
throw new Error(`stake with account address <${stakeAccAddr}> not found`);
}

const { meta, stake } = stakeWithMeta;
const validatorName = meta.validator?.name ?? stakeAccAddr;
const { stake } = stakeWithMeta;

const unit = getAccountUnit(account);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default function StepValidator({
account && account.solanaResources && transaction,
"solana account, resources and transaction required",
);
const { solanaResources } = account;

const updateValidator = ({ address }: { address: string }) => {
const bridge: AccountBridge<Transaction> = getAccountBridge(account, parentAccount);
Expand All @@ -50,13 +49,16 @@ export default function StepValidator({
<Box flow={1}>
<TrackPage category="Solana Delegation" name="Step Validator" />
{error && <ErrorBanner error={error} />}
<ValidatorsField
account={account}
chosenVoteAccAddr={chosenVoteAccAddr}
onChangeValidator={updateValidator}
status={status}
t={t}
/>
{
// $FlowFixMe FIXME Not sure what's wrong here
<ValidatorsField
account={account}
chosenVoteAccAddr={chosenVoteAccAddr}
onChangeValidator={updateValidator}
status={status}
t={t}
/>
}
</Box>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
// @flow
import { getAccountUnit } from "@ledgerhq/live-common/lib/account";
import { formatCurrencyUnit } from "@ledgerhq/live-common/lib/currencies";
import { useSolanaStakesWithMeta } from "@ledgerhq/live-common/lib/families/solana/react";
import { BigNumber } from "bignumber.js";
import {
useSolanaStakesWithMeta,
useLedgerFirstShuffledValidators,
} from "@ledgerhq/live-common/lib/families/solana/react";
import invariant from "invariant";
import React from "react";
import { Trans } from "react-i18next";
import TrackPage from "~/renderer/analytics/TrackPage";
import Box from "~/renderer/components/Box";
import Button from "~/renderer/components/Button";
import ErrorBanner from "~/renderer/components/ErrorBanner";
import FirstLetterIcon from "~/renderer/components/FirstLetterIcon";
import Image from "~/renderer/components/Image";
import AccountFooter from "~/renderer/modals/Send/AccountFooter";
import { Ellipsis } from "../../shared/components/Ellipsis";
import ErrorDisplay from "../../shared/components/ErrorDisplay";
import type { StepProps } from "../types";
import ValidatorRow from "../../shared/components/ValidatorRow";
import { useLedgerFirstShuffledValidators } from "@ledgerhq/live-common/lib/families/solana/react";

export default function StepValidator({
account,
Expand Down Expand Up @@ -48,7 +45,7 @@ export default function StepValidator({
throw new Error(`stake with account address <${stakeAccAddr}> not found`);
}

const { meta, stake } = stakeWithMeta;
const { stake } = stakeWithMeta;

const unit = getAccountUnit(account);

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/families/solana/shared/components/Ellipsis.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@flow
// @flow
import styled from "styled-components";
import type { ThemedComponent } from "~/renderer/styles/StyleProvider";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@flow
// @flow
import React from "react";
import Box from "~/renderer/components/Box";
import styled from "styled-components";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@flow
// @flow
import React from "react";
import LinkWithExternalIcon from "~/renderer/components/LinkWithExternalIcon";
import { useTranslation } from "react-i18next";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@flow
// @flow
import { formatCurrencyUnit } from "@ledgerhq/live-common/lib/currencies";
import { getAddressExplorer, getDefaultExplorerView } from "@ledgerhq/live-common/lib/explorers";
import type { ValidatorAppValidator } from "@ledgerhq/live-common/lib/families/solana/validator-app";
Expand Down
20 changes: 9 additions & 11 deletions src/renderer/families/solana/shared/fields/ValidatorsField.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// @flow
import { getAccountUnit } from "@ledgerhq/live-common/lib/account";
import { getAddressExplorer, getDefaultExplorerView } from "@ledgerhq/live-common/lib/explorers";
import { useLedgerFirstShuffledValidators } from "@ledgerhq/live-common/lib/families/solana/react";
import { swap } from "@ledgerhq/live-common/lib/families/solana/utils";
import type { ValidatorAppValidator } from "@ledgerhq/live-common/lib/families/solana/validator-app";
import type { Account, TransactionStatus } from "@ledgerhq/live-common/lib/types";
import invariant from "invariant";
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
import React, { useEffect, useMemo, useRef, useState } from "react";
import type { TFunction } from "react-i18next";
import { Trans } from "react-i18next";
import styled from "styled-components";
Expand All @@ -15,7 +13,6 @@ import { NoResultPlaceholder } from "~/renderer/components/Delegation/ValidatorS
import ScrollLoadingList from "~/renderer/components/ScrollLoadingList";
import Text from "~/renderer/components/Text";
import IconAngleDown from "~/renderer/icons/AngleDown";
import { openURL } from "~/renderer/linking";
import type { ThemedComponent } from "~/renderer/styles/StyleProvider";
import ValidatorRow from "../components/ValidatorRow";

Expand All @@ -27,14 +24,17 @@ type Props = {
onChangeValidator: (v: ValidatorAppValidator) => void,
};

const ValidatorField = ({ t, account, onChangeValidator, chosenVoteAccAddr, status }: Props) => {
const MaybeValidatorField = ({ status }: Props) => {
if (!status) return null;

invariant(account && account.solanaResources, "solana account and resources required");
// $FlowFixMe FIXME Not sure what's wrong here
return ValidatorField;
};

const { solanaResources } = account;
const ValidatorField = ({ t, account, onChangeValidator, chosenVoteAccAddr, status }: Props) => {
invariant(account && account.solanaResources, "solana account and resources required");

const [search, setSearch] = useState("");
const [search] = useState("");
This conversation was marked as resolved.
Show resolved Hide resolved
const [showAll, setShowAll] = useState(false);

const unit = getAccountUnit(account);
Expand All @@ -58,8 +58,6 @@ const ValidatorField = ({ t, account, onChangeValidator, chosenVoteAccAddr, stat

const containerRef = useRef();

const onSearch = (event: SyntheticInputEvent<HTMLInputElement>) => setSearch(event.target.value);

/** auto focus first input on mount */
useEffect(() => {
/** $FlowFixMe */
Expand Down Expand Up @@ -130,4 +128,4 @@ const SeeAllButton: ThemedComponent<{ expanded: boolean }> = styled.div`
}
`;

export default ValidatorField;
export default MaybeValidatorField;