From 5b67938402d11e999ff056b035505d09c11fce83 Mon Sep 17 00:00:00 2001 From: Louis Paquet Date: Tue, 26 Nov 2024 12:15:08 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"feat(LIVE-14948):=20remove=20CDN=20fo?= =?UTF-8?q?r=20release=20issues=20and=20thorswap=20=E2=80=A6=20(#8480)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revert "feat(LIVE-14948): remove CDN for release issues and thorswap as DEX (#8436)" This reverts commit 2ebf40493b17f449e323ae5a9dceb6c428a4392a. --- .changeset/mighty-days-tan.md | 5 --- libs/ledger-live-common/src/cal/partners.ts | 9 +++-- .../src/exchange/platform/startExchange.ts | 2 +- .../src/exchange/providers/swap.ts | 39 +++++++------------ .../src/exchange/swap/completeExchange.ts | 9 ++--- .../src/exchange/swap/initSwap.ts | 9 ++--- 6 files changed, 28 insertions(+), 45 deletions(-) delete mode 100644 .changeset/mighty-days-tan.md diff --git a/.changeset/mighty-days-tan.md b/.changeset/mighty-days-tan.md deleted file mode 100644 index f39d1059f9c7..000000000000 --- a/.changeset/mighty-days-tan.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@ledgerhq/live-common": minor ---- - -remove CDN for release issues and thorswap as DEX diff --git a/libs/ledger-live-common/src/cal/partners.ts b/libs/ledger-live-common/src/cal/partners.ts index f813605950c6..e3503345e2ff 100644 --- a/libs/ledger-live-common/src/cal/partners.ts +++ b/libs/ledger-live-common/src/cal/partners.ts @@ -1,6 +1,5 @@ import { getEnv } from "@ledgerhq/live-env"; import network from "@ledgerhq/live-network"; -import { AdditionalProviderConfig, SWAP_DATA_CDN } from "../exchange/providers/swap"; const CAL_BASE_URL = getEnv("CAL_SERVICE_URL"); @@ -15,8 +14,12 @@ export type PartnerType = { version?: number; }; -export function getProvidersCDNData(): Record { - return SWAP_DATA_CDN; +export async function getProvidersCDNData(): Promise> { + const { data: providers } = await network>({ + url: "https://cdn.live.ledger.com/swap-providers/data.json", + }); + + return providers; } export type ExchangeProvider = { diff --git a/libs/ledger-live-common/src/exchange/platform/startExchange.ts b/libs/ledger-live-common/src/exchange/platform/startExchange.ts index de601ec794ed..1bfbce785695 100644 --- a/libs/ledger-live-common/src/exchange/platform/startExchange.ts +++ b/libs/ledger-live-common/src/exchange/platform/startExchange.ts @@ -23,7 +23,7 @@ const startExchange = (input: StartExchangeInput): Observable = { - exodus: { - type: "CEX", - useInExchangeApp: true, - displayName: "Exodus", - termsOfUseUrl: "https://www.exodus.com/terms/", - supportUrl: "mailto:support@xopay.com", - mainUrl: "https://www.exodus.com/", - needsKYC: false, - version: 2, - }, changelly: { + needsKYC: false, + needsBearerToken: false, type: "CEX", - useInExchangeApp: true, displayName: "Changelly", termsOfUseUrl: "https://changelly.com/terms-of-use", supportUrl: "https://support.changelly.com/en/support/home", mainUrl: "https://changelly.com/", + }, + exodus: { + type: "CEX", + displayName: "Exodus", + needsBearerToken: false, + termsOfUseUrl: "https://www.exodus.com/legal/exodus-tos-20240219-v29.pdf", + supportUrl: "https://www.exodus.com/contact-support/", + mainUrl: "https://www.exodus.com/", needsKYC: false, version: 2, }, @@ -48,7 +45,6 @@ export const SWAP_DATA_CDN: Record = { needsBearerToken: false, displayName: "CIC", type: "CEX", - useInExchangeApp: true, termsOfUseUrl: "https://criptointercambio.com/terms-of-use", supportUrl: "https://criptointercambio.com/en/about", mainUrl: "https://criptointercambio.com/", @@ -58,7 +54,7 @@ export const SWAP_DATA_CDN: Record = { needsBearerToken: false, displayName: "MoonPay", type: "CEX", - useInExchangeApp: true, + version: 2, termsOfUseUrl: "https://www.moonpay.com/legal/terms_of_use_row", supportUrl: "https://support.moonpay.com/", mainUrl: "https://www.moonpay.com/", @@ -66,7 +62,6 @@ export const SWAP_DATA_CDN: Record = { oneinch: { type: "DEX", needsKYC: false, - useInExchangeApp: false, displayName: "1inch", needsBearerToken: false, termsOfUseUrl: "https://1inch.io/assets/1inch_network_terms_of_use.pdf", @@ -76,7 +71,6 @@ export const SWAP_DATA_CDN: Record = { paraswap: { type: "DEX", needsKYC: false, - useInExchangeApp: false, displayName: "Paraswap", needsBearerToken: false, termsOfUseUrl: "https://files.paraswap.io/tos_v4.pdf", @@ -84,19 +78,17 @@ export const SWAP_DATA_CDN: Record = { mainUrl: "https://www.paraswap.io/", }, thorswap: { - type: "DEX", + type: "CEX", needsBearerToken: false, - useInExchangeApp: true, displayName: "THORChain", termsOfUseUrl: "https://docs.thorswap.finance/thorswap/resources/terms-of-service", - supportUrl: "https://ledgerhelp.swapkit.dev/", + supportUrl: "mailto:support@thorswap.finance", mainUrl: "https://www.thorswap.finance/", needsKYC: false, }, uniswap: { type: "DEX", needsBearerToken: false, - useInExchangeApp: false, displayName: "Uniswap", termsOfUseUrl: "https://support.uniswap.org/hc/en-us/articles/30935100859661-Uniswap-Labs-Terms-of-Service", @@ -245,7 +237,6 @@ export const getSwapProvider = async ( if (ledgerSignatureEnv === "test" && testProviderInfo) { return { needsKYC: false, - useInExchangeApp: false, needsBearerToken: false, type: "CEX", termsOfUseUrl: "https://example.com", diff --git a/libs/ledger-live-common/src/exchange/swap/completeExchange.ts b/libs/ledger-live-common/src/exchange/swap/completeExchange.ts index be9681865fb4..4f4e0fd15692 100644 --- a/libs/ledger-live-common/src/exchange/swap/completeExchange.ts +++ b/libs/ledger-live-common/src/exchange/swap/completeExchange.ts @@ -25,7 +25,6 @@ import { convertToAppExchangePartnerKey } from "../providers"; import { CompleteExchangeStep, convertTransportError } from "../error"; import { getDefaultAccountName } from "@ledgerhq/live-wallet/accountName"; import BigNumber from "bignumber.js"; -import { CEXProviderConfig } from "../providers/swap"; const withDevicePromise = (deviceId, fn) => firstValueFrom(withDevice(deviceId)(transport => from(fn(transport)))); @@ -50,7 +49,7 @@ const completeExchange = ( const confirmExchange = async () => { await withDevicePromise(deviceId, async transport => { const providerConfig = await getSwapProvider(provider); - if (providerConfig.useInExchangeApp === false) { + if (providerConfig.type !== "CEX") { throw new Error(`Unsupported provider type ${providerConfig.type}`); } @@ -103,13 +102,11 @@ const completeExchange = ( if (errorsKeys.length > 0) throw errors[errorsKeys[0]]; // throw the first error currentStep = "SET_PARTNER_KEY"; - await exchange.setPartnerKey( - convertToAppExchangePartnerKey(providerConfig as CEXProviderConfig), - ); + await exchange.setPartnerKey(convertToAppExchangePartnerKey(providerConfig)); if (unsubscribed) return; currentStep = "CHECK_PARTNER"; - await exchange.checkPartner((providerConfig as CEXProviderConfig).signature); + await exchange.checkPartner(providerConfig.signature); if (unsubscribed) return; currentStep = "PROCESS_TRANSACTION"; diff --git a/libs/ledger-live-common/src/exchange/swap/initSwap.ts b/libs/ledger-live-common/src/exchange/swap/initSwap.ts index 0d9675994348..b1965fdc42c1 100644 --- a/libs/ledger-live-common/src/exchange/swap/initSwap.ts +++ b/libs/ledger-live-common/src/exchange/swap/initSwap.ts @@ -30,7 +30,6 @@ import { decodePayloadProtobuf } from "@ledgerhq/hw-app-exchange"; import { getSwapProvider } from "../providers"; import { convertToAppExchangePartnerKey } from "../providers"; import { getDefaultAccountName } from "@ledgerhq/live-wallet/accountName"; -import { CEXProviderConfig } from "../providers/swap"; const withDevicePromise = (deviceId, fn) => firstValueFrom(withDevice(deviceId)(transport => from(fn(transport)))); @@ -168,17 +167,15 @@ const initSwap = (input: InitSwapInput): Observable => { throw errors[errorsKeys[0]]; // throw the first error } - if (swapProviderConfig.useInExchangeApp === false) { + if (swapProviderConfig.type !== "CEX") { throw new Error(`Unsupported provider type ${swapProviderConfig.type}`); } // Prepare swap app to receive the tx to forward. - await swap.setPartnerKey( - convertToAppExchangePartnerKey(swapProviderConfig as CEXProviderConfig), - ); + await swap.setPartnerKey(convertToAppExchangePartnerKey(swapProviderConfig)); if (unsubscribed) return; - await swap.checkPartner((swapProviderConfig as CEXProviderConfig).signature!); + await swap.checkPartner(swapProviderConfig.signature!); if (unsubscribed) return; await swap.processTransaction(Buffer.from(swapResult.binaryPayload, "hex"), estimatedFees);