diff --git a/.changeset/great-baboons-enjoy.md b/.changeset/great-baboons-enjoy.md new file mode 100644 index 000000000000..91edc8ccbd76 --- /dev/null +++ b/.changeset/great-baboons-enjoy.md @@ -0,0 +1,6 @@ +--- +"ledger-live-desktop": minor +"live-mobile": minor +--- + +Change entrypoints for DOT so they open the Stakekit live app directly without modal diff --git a/apps/ledger-live-desktop/src/renderer/families/polkadot/AccountHeaderManageActions.ts b/apps/ledger-live-desktop/src/renderer/families/polkadot/AccountHeaderManageActions.ts index d24119c8f00d..ce01e13be92e 100644 --- a/apps/ledger-live-desktop/src/renderer/families/polkadot/AccountHeaderManageActions.ts +++ b/apps/ledger-live-desktop/src/renderer/families/polkadot/AccountHeaderManageActions.ts @@ -1,5 +1,3 @@ -import { useCallback } from "react"; -import { useDispatch } from "react-redux"; import { useTranslation } from "react-i18next"; import { SubAccount } from "@ledgerhq/types-live"; import { @@ -7,11 +5,11 @@ import { hasExternalStash, hasPendingOperationType, } from "@ledgerhq/live-common/families/polkadot/logic"; -import { isAccountEmpty, getMainAccount } from "@ledgerhq/live-common/account/index"; -import { openModal } from "~/renderer/actions/modals"; +import { getMainAccount } from "@ledgerhq/live-common/account/index"; import IconCoins from "~/renderer/icons/Coins"; import { PolkadotAccount } from "@ledgerhq/live-common/families/polkadot/types"; import { useGetStakeLabelLocaleBased } from "~/renderer/hooks/useGetStakeLabelLocaleBased"; +import { useHistory } from "react-router"; type Props = { account: PolkadotAccount | SubAccount; @@ -19,37 +17,29 @@ type Props = { source?: string; }; -const AccountHeaderManageActions = ({ account, parentAccount, source = "Account Page" }: Props) => { +const AccountHeaderManageActions = ({ account, parentAccount }: Props) => { const { t } = useTranslation(); const label = useGetStakeLabelLocaleBased(); - const dispatch = useDispatch(); const mainAccount = getMainAccount(account, parentAccount); const { polkadotResources } = mainAccount; const hasBondedBalance = polkadotResources.lockedBalance && polkadotResources.lockedBalance.gt(0); const hasPendingBondOperation = hasPendingOperationType(mainAccount, "BOND"); + const history = useHistory(); + if (!polkadotResources || parentAccount) return null; - const onClick = useCallback(() => { - if (isAccountEmpty(mainAccount)) { - dispatch( - openModal("MODAL_NO_FUNDS_STAKE", { - account: mainAccount, - }), - ); - } else if (hasBondedBalance || hasPendingBondOperation) { - dispatch( - openModal("MODAL_POLKADOT_MANAGE", { - account: mainAccount, - source, - }), - ); - } else { - dispatch( - openModal("MODAL_POLKADOT_REWARDS_INFO", { - account: mainAccount, - }), - ); - } - }, [mainAccount, hasBondedBalance, hasPendingBondOperation, dispatch, source]); + const onClick = () => { + history.push({ + pathname: "/platform/stakekit", + state: { + yieldId: "polkadot-dot-validator-staking", + accountId: account.id, + returnTo: + account.type === "TokenAccount" + ? `/account/${account.parentId}/${account.id}` + : `/account/${account.id}`, + }, + }); + }; const _hasExternalController = hasExternalController(mainAccount); const _hasExternalStash = hasExternalStash(mainAccount); @@ -72,7 +62,7 @@ const AccountHeaderManageActions = ({ account, parentAccount, source = "Account return [ { key: "Stake", - onClick: onClick, + onClick, icon: IconCoins, disabled: !manageEnabled, label, diff --git a/apps/ledger-live-mobile/src/families/polkadot/accountActions.tsx b/apps/ledger-live-mobile/src/families/polkadot/accountActions.tsx index 24809e00825f..2298c9e5d23e 100644 --- a/apps/ledger-live-mobile/src/families/polkadot/accountActions.tsx +++ b/apps/ledger-live-mobile/src/families/polkadot/accountActions.tsx @@ -10,7 +10,6 @@ import { hasExternalStash, hasPendingOperationType, isElectionOpen, - isStash, } from "@ledgerhq/live-common/families/polkadot/logic"; import { IconsLegacy } from "@ledgerhq/native-ui"; import { PolkadotAccount } from "@ledgerhq/live-common/families/polkadot/types"; @@ -29,7 +28,7 @@ const getMainActions = (args: { parentAccount?: Account; parentRoute?: RouteProp; }): ActionButtonEvent[] | null => { - const { account, parentAccount, parentRoute } = args; + const { account, parentAccount } = args; invariant(account.polkadotResources, "polkadot resources required"); const accountId = account.id; const { lockedBalance } = account.polkadotResources || {}; @@ -45,43 +44,29 @@ const getMainActions = (args: { return null; } - const getNavigationParams = (): NavigationParamsType => { - if (!earnRewardsEnabled && !nominationEnabled) { - return [ - NavigatorName.NoFundsFlow, - { - screen: ScreenName.NoFunds, - params: { - account, - parentAccount, + const navigationParams: NavigationParamsType = + !earnRewardsEnabled && !nominationEnabled + ? [ + NavigatorName.NoFundsFlow, + { + screen: ScreenName.NoFunds, + params: { + account, + parentAccount, + }, }, - }, - ]; - } - if (isStash(account)) { - return [ - NavigatorName.PolkadotNominateFlow, - { - screen: ScreenName.PolkadotNominateSelectValidators, - params: { - accountId, - source: parentRoute, + ] + : [ + ScreenName.PlatformApp, + { + params: { + platform: "stakekit", + name: "StakeKit", + accountId, + yieldId: "polkadot-dot-validator-staking", + }, }, - }, - ]; - } - return [ - NavigatorName.PolkadotBondFlow, - { - screen: ScreenName.PolkadotBondStarted, - params: { - accountId, - }, - }, - ]; - }; - - const navigationParams = getNavigationParams(); + ]; return [ {