diff --git a/libs/ledger-live-common/src/wallet-api/Exchange/server.ts b/libs/ledger-live-common/src/wallet-api/Exchange/server.ts index 74f6ec5aa73d..06e3b4d16f9e 100644 --- a/libs/ledger-live-common/src/wallet-api/Exchange/server.ts +++ b/libs/ledger-live-common/src/wallet-api/Exchange/server.ts @@ -72,7 +72,7 @@ type ExchangeStartParamsUiRequest = | { exchangeType: "SELL"; provider: string; - exchange: Partial; + exchange: Partial | undefined; } | { exchangeType: "SWAP"; @@ -371,13 +371,20 @@ function extractSellStartParam( throw new ExchangeError(createWrongSellParams(params)); } - const realFromAccountId = getAccountIdFromWalletAccountId(params.fromAccountId); + if (!params.fromAccountId) { + return { + exchangeType: params.exchangeType, + provider: params.provider, + } as ExchangeStartParamsUiRequest; + } + + const realFromAccountId = getAccountIdFromWalletAccountId(params?.fromAccountId); if (!realFromAccountId) { throw new ExchangeError(createAccounIdNotFound(params.fromAccountId)); } - const fromAccount = accounts.find(acc => acc.id === realFromAccountId); + const fromAccount = accounts?.find(acc => acc.id === realFromAccountId); if (!fromAccount) { throw new ServerError(createAccountNotFound(params.fromAccountId));