Skip to content

Commit

Permalink
feat: make sure accountId is there
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisduma-ledger committed Nov 22, 2024
1 parent 4000bdb commit 1fbfcc9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions libs/ledger-live-common/src/wallet-api/Exchange/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type ExchangeStartParamsUiRequest =
| {
exchangeType: "SELL";
provider: string;
exchange: Partial<Exchange>;
exchange: Partial<Exchange> | undefined;
}
| {
exchangeType: "SWAP";
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 1fbfcc9

Please sign in to comment.