Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(): enable crypto_org staking via stakekit #8215

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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: <Trans i18nKey="account.stake" />,
Icon: IconsLegacy.CoinsMedium,
},
];
};

export default {
getMainActions,
};
1 change: 1 addition & 0 deletions apps/ledger-live-mobile/src/families/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from "./stellar";
export * from "./tezos";
export * from "./tron";
export * from "./ton";
export * from "./crypto_org";
Loading