From 637598184b4621fc468bfcc7d93395276f25dfbd Mon Sep 17 00:00:00 2001 From: Petar Todorovic Date: Sat, 26 Oct 2024 22:51:42 +0200 Subject: [PATCH] feat(): enable crypto_org staking via stakekit --- .../crypto_org/AccountHeaderManageActions.ts | 47 +++++++++++++++++++ .../src/renderer/families/crypto_org/index.ts | 2 + .../families/crypto_org/accountActions.tsx | 33 +++++++++++++ apps/ledger-live-mobile/src/families/index.ts | 1 + 4 files changed, 83 insertions(+) create mode 100644 apps/ledger-live-desktop/src/renderer/families/crypto_org/AccountHeaderManageActions.ts create mode 100644 apps/ledger-live-mobile/src/families/crypto_org/accountActions.tsx diff --git a/apps/ledger-live-desktop/src/renderer/families/crypto_org/AccountHeaderManageActions.ts b/apps/ledger-live-desktop/src/renderer/families/crypto_org/AccountHeaderManageActions.ts new file mode 100644 index 000000000000..f557db4df120 --- /dev/null +++ b/apps/ledger-live-desktop/src/renderer/families/crypto_org/AccountHeaderManageActions.ts @@ -0,0 +1,47 @@ +import { CryptoOrgAccount } from "@ledgerhq/live-common/families/crypto_org/types"; +import { SubAccount } from "@ledgerhq/types-live"; +import { useCallback } from "react"; +import { useTranslation } from "react-i18next"; +import { useHistory } from "react-router"; +import IconCoins from "~/renderer/icons/Coins"; + +type Props = { + account: CryptoOrgAccount | SubAccount; + parentAccount: CryptoOrgAccount | undefined | null; + source?: string; +}; + +const AccountHeaderActions = ({ account, parentAccount }: Props) => { + const { t } = useTranslation(); + const history = useHistory(); + + const onClick = useCallback(() => { + history.push({ + pathname: "/platform/stakekit", + state: { + yieldId: "cronos-cro-native-staking", + accountId: account.id, + returnTo: + account.type === "TokenAccount" + ? `/account/${account.parentId}/${account.id}` + : `/account/${account.id}`, + }, + }); + }, [history, account]); + + if (parentAccount) return null; + + return [ + { + key: "Stake", + onClick, + event: "button_clicked2", + eventProperties: { button: "stake" }, + icon: IconCoins, + label: t("account.stake"), + accountActionsTestId: "stake-from-account-action-button", + }, + ]; +}; + +export default AccountHeaderActions; diff --git a/apps/ledger-live-desktop/src/renderer/families/crypto_org/index.ts b/apps/ledger-live-desktop/src/renderer/families/crypto_org/index.ts index 2bbd4db6f381..900db9b573fb 100644 --- a/apps/ledger-live-desktop/src/renderer/families/crypto_org/index.ts +++ b/apps/ledger-live-desktop/src/renderer/families/crypto_org/index.ts @@ -1,10 +1,12 @@ import AccountSubHeader from "./AccountSubHeader"; import sendRecipientFields from "./SendRecipientFields"; import { CryptoOrgFamily } from "./types"; +import accountHeaderManageActions from "./AccountHeaderManageActions"; const family: CryptoOrgFamily = { AccountSubHeader, sendRecipientFields, + accountHeaderManageActions, }; export default family; diff --git a/apps/ledger-live-mobile/src/families/crypto_org/accountActions.tsx b/apps/ledger-live-mobile/src/families/crypto_org/accountActions.tsx new file mode 100644 index 000000000000..a4de8024c8c0 --- /dev/null +++ b/apps/ledger-live-mobile/src/families/crypto_org/accountActions.tsx @@ -0,0 +1,33 @@ +import React from "react"; +import { Trans } from "react-i18next"; +import { IconsLegacy } from "@ledgerhq/native-ui"; +import { CryptoOrgAccount } from "@ledgerhq/live-common/families/crypto_org/types"; +import { ScreenName } from "~/const"; +import { ActionButtonEvent, NavigationParamsType } from "~/components/FabActions"; + +const getMainActions = ({ account }: { account: CryptoOrgAccount }): ActionButtonEvent[] => { + const navigationParams: NavigationParamsType = [ + ScreenName.PlatformApp, + { + params: { + platform: "stakekit", + name: "StakeKit", + accountId: account.id, + yieldId: "cronos-cro-native-staking", + }, + }, + ]; + + return [ + { + id: "stake", + navigationParams, + label: , + Icon: IconsLegacy.CoinsMedium, + }, + ]; +}; + +export default { + getMainActions, +}; diff --git a/apps/ledger-live-mobile/src/families/index.ts b/apps/ledger-live-mobile/src/families/index.ts index c272b073973f..b9a06d6b03a7 100644 --- a/apps/ledger-live-mobile/src/families/index.ts +++ b/apps/ledger-live-mobile/src/families/index.ts @@ -18,3 +18,4 @@ export * from "./stellar"; export * from "./tezos"; export * from "./tron"; export * from "./ton"; +export * from "./crypto_org";