Skip to content

Commit

Permalink
feat: clean up old swap feature flags
Browse files Browse the repository at this point in the history
feat: rm legacy code

fix: borken tests

fix: rm unused hooks

fix: tsc

fix: unsuned import

fix: rm unused files

fix: rm legacy swap lld code

chore: pr comments

fix: patch changeset
  • Loading branch information
liviuciulinaru committed Dec 4, 2024
1 parent 4f80505 commit 4859d3d
Show file tree
Hide file tree
Showing 57 changed files with 67 additions and 4,823 deletions.
7 changes: 7 additions & 0 deletions .changeset/tricky-dryers-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@ledgerhq/types-live": minor
"ledger-live-desktop": minor
"@ledgerhq/live-common": minor
---

remove legacy swap code on LLD
18 changes: 1 addition & 17 deletions apps/ledger-live-desktop/src/renderer/analytics/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,6 @@ const getPtxAttributes = () => {
const fetchAdditionalCoins = analyticsFeatureFlagMethod("fetchAdditionalCoins");
const stakingProviders = analyticsFeatureFlagMethod("ethStakingProviders");
const ptxCard = analyticsFeatureFlagMethod("ptxCard");
const ptxSwapMoonpayProviderFlag = analyticsFeatureFlagMethod("ptxSwapMoonpayProvider");

const ptxSwapLiveAppDemoZero = analyticsFeatureFlagMethod("ptxSwapLiveAppDemoZero")?.enabled;
const ptxSwapLiveAppDemoOne = analyticsFeatureFlagMethod("ptxSwapLiveAppDemoOne")?.enabled;
const ptxSwapLiveAppDemoThree = analyticsFeatureFlagMethod("ptxSwapLiveAppDemoThree")?.enabled;
const ptxSwapExodusProvider = analyticsFeatureFlagMethod("ptxSwapExodusProvider")?.enabled;
const ptxSwapCoreExperimentFlag = analyticsFeatureFlagMethod("ptxSwapCoreExperiment");
const ptxSwapCoreExperiment = ptxSwapCoreExperimentFlag?.enabled
? ptxSwapCoreExperimentFlag?.params?.variant
: undefined;

const isBatch1Enabled: boolean =
!!fetchAdditionalCoins?.enabled && fetchAdditionalCoins?.params?.batch === 1;
Expand All @@ -122,19 +112,13 @@ const getPtxAttributes = () => {
stakingProviders?.params?.listProvider?.length > 0
? stakingProviders?.params?.listProvider.length
: "flag not loaded";
const ptxSwapMoonpayProviderEnabled: boolean = !!ptxSwapMoonpayProviderFlag?.enabled;

return {
isBatch1Enabled,
isBatch2Enabled,
isBatch3Enabled,
stakingProvidersEnabled,
ptxCard,
ptxSwapMoonpayProviderEnabled,
ptxSwapLiveAppDemoZero,
ptxSwapLiveAppDemoOne,
ptxSwapLiveAppDemoThree,
ptxSwapCoreExperiment,
ptxSwapExodusProvider,
};
};

Expand Down

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions apps/ledger-live-desktop/src/renderer/icons/ArrowsUpDown.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
import { useDispatch } from "react-redux";
import styled from "styled-components";
import { updateAccountWithUpdater } from "~/renderer/actions/accounts";
import { useIsSwapLiveFlagEnabled } from "~/renderer/screens/exchange/Swap2/hooks/useIsSwapLiveFlagEnabled";

import { useRedirectToSwapHistory } from "~/renderer/screens/exchange/Swap2/utils";
import { BodyContent } from "./BodyContent";

export enum ExchangeModeEnum {
Sell = "sell",
Swap = "swap",
}

export type ExchangeMode = "sell" | "swap";

export type Data = {
provider: string;
exchange: Exchange;
Expand All @@ -32,13 +39,6 @@ export type Data = {
magnitudeAwareRate?: BigNumber;
};

export enum ExchangeModeEnum {
Sell = "sell",
Swap = "swap",
}

export type ExchangeMode = "sell" | "swap";

type ResultsState = {
mode: ExchangeMode;
swapId?: string;
Expand Down Expand Up @@ -195,7 +195,6 @@ const Body = ({ data, onClose }: { data: Data; onClose?: () => void | undefined
const handleSellTransaction = (operation: Operation, result: ResultsState) => {
handleTransactionResult(result, operation);
};
const isDemo3Enabled = useIsSwapLiveFlagEnabled("ptxSwapLiveAppDemoThree");

const onBroadcastSuccess = useCallback(
(operation: Operation) => {
Expand All @@ -209,7 +208,7 @@ const Body = ({ data, onClose }: { data: Data; onClose?: () => void | undefined
const result = getResultByTransactionType(isSwapTransaction);

if (getEnv("DISABLE_TRANSACTION_BROADCAST")) {
if (!isSwapTransaction || (isSwapTransaction && !isDemo3Enabled)) {
if (!isSwapTransaction) {
const error = new DisabledTransactionBroadcastError();
setError(error);
onCancel(error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useSwapLiveConfig } from "@ledgerhq/live-common/exchange/swap/hooks/index";
import { DEFAULT_FEATURES } from "@ledgerhq/live-common/featureFlags/index";
import { useRemoteLiveAppManifest } from "@ledgerhq/live-common/platform/providers/RemoteLiveAppProvider/index";
import { useLocalLiveAppManifest } from "@ledgerhq/live-common/wallet-api/LocalLiveAppProvider/index";
import React, { useState } from "react";
Expand Down Expand Up @@ -26,10 +27,16 @@ const ErrorWrapper = styled.div`
font-weight: 500;
`;

// set the default manifest ID for the production swap live app
// in case the FF is failing to load the manifest ID
// "swap-live-app-demo-3" points to production vercel URL for the swap live app
const DEFAULT_MANIFEST_ID =
process.env.DEFAULT_SWAP_MANIFEST_ID || DEFAULT_FEATURES.ptxSwapLiveApp.params?.manifest_id;

export function SwapApp() {
const [unavailable, setUnavailable] = useState(false);
const swapLiveEnabledFlag = useSwapLiveConfig();
const swapLiveAppManifestID = swapLiveEnabledFlag?.params?.manifest_id;
const swapLiveAppManifestID = swapLiveEnabledFlag?.params?.manifest_id || DEFAULT_MANIFEST_ID;

const localManifest = useLocalLiveAppManifest(swapLiveAppManifestID || undefined);
const remoteManifest = useRemoteLiveAppManifest(swapLiveAppManifestID || undefined);
Expand Down

This file was deleted.

Loading

0 comments on commit 4859d3d

Please sign in to comment.