Skip to content

Commit

Permalink
Merge pull request LedgerHQ#20 from Prashanthsoordelu/ts-fixes
Browse files Browse the repository at this point in the history
ts fixes
  • Loading branch information
pavanvora authored Aug 8, 2023
2 parents b00c9e2 + 964a5ff commit 43f2ef4
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const AccountHeaderActions = ({ account, parentAccount }: Props) => {
const { cardanoResources } = mainAccount as CardanoAccount;
invariant(cardanoResources, "cardano account expected");
const disableStakeButton =
(cardanoResources.delegation && cardanoResources.delegation.poolId) ||
(cardanoResources.delegation && !!cardanoResources.delegation.poolId) ||
mainAccount.balance.isZero();
const disabledLabel =
cardanoResources.delegation && cardanoResources.delegation.poolId
Expand All @@ -32,6 +32,7 @@ const AccountHeaderActions = ({ account, parentAccount }: Props) => {
dispatch(
openModal("MODAL_CARDANO_REWARDS_INFO", {
account,
name: "MODAL_CARDANO_REWARDS_INFO",
}),
);
}, [dispatch, account]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import React from "react";
import styled from "styled-components";
import { useTranslation } from "react-i18next";
import Text from "~/renderer/components/Text";
import { ThemedComponent } from "~/renderer/styles/StyleProvider";
import { rgba } from "~/renderer/styles/helpers";

const Wrapper: ThemedComponent<{}> = styled.div`
const Wrapper = styled.div`
display: flex;
flex-direction: row;
padding: 10px 20px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const Delegation = ({ account, parentAccount }: Props) => {
openModal("MODAL_CARDANO_REWARDS_INFO", {
parentAccount,
account,
name: "MODAL_CARDANO_REWARDS_INFO"
}),
);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ const Body = ({
);
};

const C: React.ComponentType<OwnProps> = compose(
const C = compose(
connect(mapStateToProps, mapDispatchToProps),
withTranslation(),
)(Body);
)(Body) as React.ComponentType<OwnProps>;

export default C;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { openURL } from "~/renderer/linking";
import LinkWithExternalIcon from "~/renderer/components/LinkWithExternalIcon";

type Props = {
name?: string;
name: string;
account: AccountLike;
parentAccount: Account | undefined | null;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useCallback, useState, useRef, memo, useEffect } from "react";
import debounce from "lodash/debounce";
import { StakePool } from "@ledgerhq/live-common/families/cardano/api/api-types";
import styled from "styled-components";
import { StyleProp, ViewStyle } from "react-native";
import Box from "~/renderer/components/Box";
import BigSpinner from "~/renderer/components/BigSpinner";

Expand All @@ -20,7 +19,7 @@ type ScrollLoadingListProps = {
noResultPlaceholder: React.ReactNode | undefined | null;
scrollEndThreshold?: number;
bufferSize?: number;
style?: StyleProp<ViewStyle>;
style?: React.CSSProperties;
fetchPoolsFromNextPage: () => void;
search: string;
isPaginating: boolean;
Expand All @@ -37,7 +36,7 @@ const ScrollLoadingList = ({
search,
isPaginating,
}: ScrollLoadingListProps) => {
const scrollRef = useRef<HTMLInputElement>();
const scrollRef = useRef<HTMLInputElement | null>(null);
const [scrollOffset, setScrollOffset] = useState(bufferSize);
useEffect(() => {
// $FlowFixMe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ScrollLoadingList from "../ScrollLoadingList";
import { Trans, TFunction } from "react-i18next";
import IconAngleDown from "~/renderer/icons/AngleDown";
import ValidatorRow from "./ValidatorRow";
import { ThemedComponent } from "~/renderer/styles/StyleProvider";
import { Account } from "@ledgerhq/types-live";
import { TransactionStatus } from "@ledgerhq/live-common/generated/types";
import { StakePool } from "@ledgerhq/live-common/families/cardano/api/api-types";
Expand Down Expand Up @@ -115,14 +114,14 @@ const ValidatorField = ({ account, delegation, onChangeValidator, selectedPoolId
);
};

const ValidatorsFieldContainer: ThemedComponent<{}> = styled(Box)`
const ValidatorsFieldContainer = styled(Box)`
border: 1px solid ${p => p.theme.colors.palette.divider};
border-radius: 4px;
`;

const SeeAllButton: ThemedComponent<{
const SeeAllButton = styled.div<{
expanded: boolean;
}> = styled.div`
}>`
display: flex;
color: ${p => p.theme.colors.wallet};
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Text from "~/renderer/components/Text";
import Check from "~/renderer/icons/Check";
import { openURL } from "~/renderer/linking";
import LedgerPoolIcon from "../LedgerPoolIcon";
import { ThemedComponent } from "~/renderer/styles/StyleProvider";
import { StakePool } from "@ledgerhq/live-common/families/cardano/api/api-types";
import { localeSelector } from "~/renderer/reducers/settings";

Expand All @@ -25,7 +24,7 @@ type Props = {
unit: Unit;
};

function CardanoPoolRow({ pool, active, onClick, unit, currency, disabled }: Props) {
function CardanoPoolRow({ pool, active, onClick, unit, currency }: Props) {
const discreet = useDiscreetMode();
const locale = useSelector(localeSelector);
const explorerView = getDefaultExplorerView(currency);
Expand All @@ -46,7 +45,7 @@ function CardanoPoolRow({ pool, active, onClick, unit, currency, disabled }: Pro
const poolCost = formatCurrencyUnit(unit, new BigNumber(pool.cost), formatConfig);
return (
<StyledValidatorRow
onClick={disabled ? undefined : onClick}
onClick={onClick}
key={pool.poolId}
validator={{
...pool,
Expand Down Expand Up @@ -77,7 +76,7 @@ function CardanoPoolRow({ pool, active, onClick, unit, currency, disabled }: Pro
</Text>
</Box>
<Box ml={2} justifyContent="center" alignContent="center">
<ChosenMark active={active ?? false} disabled={disabled} />
<ChosenMark active={active ?? false} />
</Box>
</Box>
}
Expand All @@ -98,19 +97,15 @@ function CardanoPoolRow({ pool, active, onClick, unit, currency, disabled }: Pro
></StyledValidatorRow>
);
}
const StyledValidatorRow: ThemedComponent<ValidatorRowProps> = styled(ValidatorRow)`
const StyledValidatorRow = styled(ValidatorRow)`
border-color: transparent;
margin-bottom: 0;
`;

const ChosenMark: ThemedComponent<{
const ChosenMark = styled(Check).attrs<{
active: boolean;
}> = styled(Check).attrs(p => ({
color: p.active
? p.disabled
? p.theme.colors.palette.action.disabled
: p.theme.colors.palette.primary.main
: "transparent",
}>(p => ({
color: p.active ? p.theme.colors.palette.primary.main : "transparent",
size: 14,
}))``;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import Ellipsis from "~/renderer/components/Ellipsis";
import FormattedVal from "~/renderer/components/FormattedVal";
import Text from "~/renderer/components/Text";
import CounterValue from "~/renderer/components/CounterValue";
import { ThemedComponent } from "~/renderer/styles/StyleProvider";
import { StepProps } from "../types";
import CardanoLedgerPoolIcon from "../LedgerPoolIcon";
import BigNumber from "bignumber.js";

const FromToWrapper: ThemedComponent<{}> = styled.div``;
const Separator: ThemedComponent<{}> = styled.div`
const FromToWrapper = styled.div``;
const Separator = styled.div`
height: 1px;
background: ${p => p.theme.colors.palette.text.shade20};
width: 100%;
Expand Down Expand Up @@ -65,7 +65,7 @@ export default class StepSummary extends PureComponent<StepProps> {
disableRounding
unit={feesUnit}
alwaysShowValue
val={selectedPool.cost}
val={new BigNumber(selectedPool.cost)}
fontSize={4}
inline
showCode
Expand Down Expand Up @@ -94,7 +94,7 @@ export default class StepSummary extends PureComponent<StepProps> {
disableRounding
unit={feesUnit}
alwaysShowValue
val={stakeKeyDeposit}
val={new BigNumber(stakeKeyDeposit)}
fontSize={4}
inline
showCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ const Body = ({
);
};

const C: React.ComponentType<OwnProps> = compose(
const C = compose(
connect(mapStateToProps, mapDispatchToProps),
withTranslation(),
)(Body);
)(Body) as React.ComponentType<OwnProps>;

export default C;
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import FormattedVal from "~/renderer/components/FormattedVal";
import Text from "~/renderer/components/Text";
import CounterValue from "~/renderer/components/CounterValue";
import ErrorBanner from "~/renderer/components/ErrorBanner";
import { ThemedComponent } from "~/renderer/styles/StyleProvider";
import { StepProps } from "../types";
import BigNumber from "bignumber.js";

const FromToWrapper: ThemedComponent<{}> = styled.div``;
const Separator: ThemedComponent<{}> = styled.div`
const FromToWrapper = styled.div``;
const Separator = styled.div`
height: 1px;
background: ${p => p.theme.colors.palette.text.shade20};
width: 100%;
Expand Down Expand Up @@ -59,7 +59,7 @@ export default class StepSummary extends PureComponent<StepProps> {
disableRounding
unit={accountUnit}
alwaysShowValue
val={stakeKeyDeposit}
val={new BigNumber(stakeKeyDeposit)}
fontSize={4}
inline
showCode
Expand Down

0 comments on commit 43f2ef4

Please sign in to comment.