diff --git a/apps/ledger-live-desktop/src/renderer/families/celo/AccountBodyHeader/AccountBodyHeader.tsx b/apps/ledger-live-desktop/src/renderer/families/celo/AccountBodyHeader/AccountBodyHeader.tsx index 8c909287662e..38fe6168eee6 100644 --- a/apps/ledger-live-desktop/src/renderer/families/celo/AccountBodyHeader/AccountBodyHeader.tsx +++ b/apps/ledger-live-desktop/src/renderer/families/celo/AccountBodyHeader/AccountBodyHeader.tsx @@ -1,7 +1,7 @@ import { getAddressExplorer, getDefaultExplorerView } from "@ledgerhq/live-common/explorers"; import React, { useCallback } from "react"; import { Trans } from "react-i18next"; -import { useDispatch, useSelector } from "react-redux"; +import { useDispatch } from "react-redux"; import { urls } from "~/config/urls"; import { openModal } from "~/renderer/actions/modals"; import Alert from "~/renderer/components/Alert"; @@ -12,7 +12,6 @@ import TableContainer, { TableHeader } from "~/renderer/components/TableContaine import Text from "~/renderer/components/Text"; import IconChartLine from "~/renderer/icons/ChartLine"; import { openURL } from "~/renderer/linking"; -import { accountsSelector } from "~/renderer/reducers/accounts"; import { Header } from "./Header"; import { Row } from "./Row"; import { @@ -28,11 +27,11 @@ type Props = { account: CeloAccount; }; const AccountBodyHeaderComponent = ({ account }: Props) => { - const { celoResources } = account; + const { + celoResources: { votes }, + } = account; const dispatch = useDispatch(); - const accounts = useSelector(accountsSelector) as CeloAccount[]; // FIXME: how to not cast here ? - const isRegistrationPending = isAccountRegistrationPending(account?.id, accounts); - const { votes } = celoResources; + const isRegistrationPending = isAccountRegistrationPending(account); const onEarnRewards = useCallback(() => { dispatch( openModal("MODAL_CELO_REWARDS_INFO", { @@ -116,7 +115,7 @@ const AccountBodyHeaderComponent = ({ account }: Props) => { {votes.map(vote => ( {actions.length > 0 && } {actions.length === 0 && ( - - } - > + }> diff --git a/apps/ledger-live-desktop/src/renderer/families/celo/AccountHeaderManageActions/AccountHeaderManageActions.tsx b/apps/ledger-live-desktop/src/renderer/families/celo/AccountHeaderManageActions/AccountHeaderManageActions.tsx index 903241deac80..65c60b19d8f2 100644 --- a/apps/ledger-live-desktop/src/renderer/families/celo/AccountHeaderManageActions/AccountHeaderManageActions.tsx +++ b/apps/ledger-live-desktop/src/renderer/families/celo/AccountHeaderManageActions/AccountHeaderManageActions.tsx @@ -3,9 +3,8 @@ import { isAccountRegistrationPending } from "@ledgerhq/live-common/families/cel import { CeloAccount } from "@ledgerhq/live-common/families/celo/types"; import React, { useCallback } from "react"; import { useTranslation } from "react-i18next"; -import { useDispatch, useSelector } from "react-redux"; +import { useDispatch } from "react-redux"; import { openModal } from "~/renderer/actions/modals"; -import { accountsSelector } from "~/renderer/reducers/accounts"; import { IconType } from "../../types"; import { CeloFamily } from "../types"; import Icon from "./Icon"; @@ -17,8 +16,7 @@ const AccountHeaderManageActions: CeloFamily["accountHeaderManageActions"] = ({ }) => { const { t } = useTranslation(); const dispatch = useDispatch(); - const accounts = useSelector(accountsSelector) as CeloAccount[]; // FIXME: Celo Account - const isRegistrationPending = isAccountRegistrationPending(account.id, accounts); + const isRegistrationPending = isAccountRegistrationPending(account as CeloAccount); const onClick = useCallback(() => { if (isAccountEmpty(account)) { dispatch( diff --git a/apps/ledger-live-desktop/src/renderer/families/celo/operationDetails.tsx b/apps/ledger-live-desktop/src/renderer/families/celo/operationDetails.tsx index 619c778b0c78..16e10c977d4c 100644 --- a/apps/ledger-live-desktop/src/renderer/families/celo/operationDetails.tsx +++ b/apps/ledger-live-desktop/src/renderer/families/celo/operationDetails.tsx @@ -43,7 +43,7 @@ const OperationDetailsExtra = ({ : null; return ( <> - {type !== "ACTIVATE" && ( + {type !== "ACTIVATE" && operation.extra && operation.extra.celoOperationValue && ( @@ -51,7 +51,7 @@ const OperationDetailsExtra = ({ - - - - - - - - - - + {operation.extra && operation.extra.celoOperationValue && ( + + + + + + + + + + + )} ); default: diff --git a/libs/ledger-live-common/src/families/celo/account.ts b/libs/ledger-live-common/src/families/celo/account.ts new file mode 100644 index 000000000000..266267be86d7 --- /dev/null +++ b/libs/ledger-live-common/src/families/celo/account.ts @@ -0,0 +1,20 @@ +import { BigNumber } from "bignumber.js"; + +export function fromOperationExtraRaw(extra: Record | null | undefined) { + if (extra && extra.celoOperationValue) { + return { ...extra, celoOperationValue: new BigNumber(extra.celoOperationValue) }; + } + return extra; +} + +export function toOperationExtraRaw(extra: Record | null | undefined) { + if (extra && extra.celoOperationValue) { + return { ...extra, celoOperationValue: extra.celoOperationValue.toString() }; + } + return extra; +} + +export default { + fromOperationExtraRaw, + toOperationExtraRaw, +}; diff --git a/libs/ledger-live-common/src/families/celo/logic.ts b/libs/ledger-live-common/src/families/celo/logic.ts index 8478227f6ade..cc3c2d3c8578 100644 --- a/libs/ledger-live-common/src/families/celo/logic.ts +++ b/libs/ledger-live-common/src/families/celo/logic.ts @@ -75,14 +75,10 @@ export const fallbackValidatorGroup = (address: string): CeloValidatorGroup => ( votes: new BigNumber(0), }); -export const isAccountRegistrationPending = ( - accountId: string, - accounts: CeloAccount[], -): boolean => { +export const isAccountRegistrationPending = (account: CeloAccount): boolean => { // If there's a pending "REGISTER" operation and the // account's registration status is false, then // we know that the account is truly not registered yet. - const account = accounts.find(currentAccount => accountId === currentAccount.id); const isAccountRegistrationPending = !!account && diff --git a/libs/ledger-live-common/src/generated/account.ts b/libs/ledger-live-common/src/generated/account.ts index 61517489a517..fbd673521ed5 100644 --- a/libs/ledger-live-common/src/generated/account.ts +++ b/libs/ledger-live-common/src/generated/account.ts @@ -1,4 +1,5 @@ import bitcoin from "../families/bitcoin/account"; +import celo from "../families/celo/account"; import cosmos from "../families/cosmos/account"; import crypto_org from "../families/crypto_org/account"; import elrond from "../families/elrond/account"; @@ -11,6 +12,7 @@ import polkadot from "@ledgerhq/coin-polkadot/account"; export default { bitcoin, + celo, cosmos, crypto_org, elrond,