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

CN-761: added stakekit entrypoints for LLM and LLD #8722

Merged
merged 7 commits into from
Dec 19, 2024
Merged
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
6 changes: 6 additions & 0 deletions .changeset/swift-cherries-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": minor
"live-mobile": minor
---

Stake for BNB will open directly the Stakekit live app
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import IconCoins from "~/renderer/icons/Coins";
import { openModal } from "~/renderer/actions/modals";
import { isAccountEmpty } from "@ledgerhq/live-common/account/index";
import { useGetStakeLabelLocaleBased } from "~/renderer/hooks/useGetStakeLabelLocaleBased";
import { useHistory } from "react-router";

type Props = {
account: AccountLike;
Expand All @@ -13,10 +14,26 @@ type Props = {

const AccountHeaderActions = ({ account, parentAccount }: Props) => {
const dispatch = useDispatch();
const history = useHistory();
const label = useGetStakeLabelLocaleBased();

const isEthereumAccount = account.type === "Account" && account.currency.id === "ethereum";
const isBscAccount = account.type === "Account" && account.currency.id === "bsc";

const onClickStakekit = useCallback(() => {
const value = "/platform/stakekit";

history.push({
pathname: value,
state: {
yieldId: "bsc-bnb-native-staking",
accountId: account.id,
returnTo: `/account/${account.id}`,
},
});
}, [account.id, history]);

const onClickStake = useCallback(() => {
const onClickStakeModal = useCallback(() => {
if (isAccountEmpty(account)) {
dispatch(
openModal("MODAL_NO_FUNDS_STAKE", {
Expand All @@ -33,11 +50,19 @@ const AccountHeaderActions = ({ account, parentAccount }: Props) => {
}
}, [account, dispatch, parentAccount]);

if (isEthereumAccount) {
const getStakeAction = useCallback(() => {
if (isEthereumAccount) {
onClickStakeModal();
} else if (isBscAccount) {
onClickStakekit();
}
}, [isEthereumAccount, isBscAccount, onClickStakeModal, onClickStakekit]);

if (isEthereumAccount || isBscAccount) {
return [
{
key: "Stake",
onClick: onClickStake,
onClick: getStakeAction,
event: "button_clicked2",
eventProperties: {
button: "stake",
Expand Down
21 changes: 19 additions & 2 deletions apps/ledger-live-mobile/src/families/evm/accountActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ function getNavigatorParams({ parentRoute, account, parentAccount }: Props): Nav
];
}

if (account.type === "Account" && account.currency.id === "bsc") {
return [
ScreenName.PlatformApp,
{
params: {
platform: "stakekit",
name: "StakeKit",
accountId: account.id,
yieldId: "bsc-bnb-native-staking",
},
},
];
}

const params = {
screen: parentRoute.name,
drawer: {
Expand Down Expand Up @@ -64,7 +78,10 @@ function getNavigatorParams({ parentRoute, account, parentAccount }: Props): Nav
}

const getMainActions = ({ account, parentAccount, parentRoute }: Props): ActionButtonEvent[] => {
if (account.type === "Account" && account.currency.id === "ethereum") {
if (
account.type === "Account" &&
(account.currency.id === "ethereum" || account.currency.id === "bsc")
) {
const label = getStakeLabelLocaleBased();

const navigationParams = getNavigatorParams({
Expand All @@ -80,7 +97,7 @@ const getMainActions = ({ account, parentAccount, parentRoute }: Props): ActionB
label: <Trans i18nKey={label} />,
Icon: IconsLegacy.CoinsMedium,
eventProperties: {
currency: "ETH",
currency: account.currency.id === "ethereum" ? "ETH" : "BNB",
},
},
];
Expand Down
Loading