Skip to content

Commit

Permalink
Merge pull request #9214 from LedgerHQ/feat/LIVE-17004-extract-swap-p…
Browse files Browse the repository at this point in the history
…arameters-from-deeplink

feat: extract swap parameters from deeplink
  • Loading branch information
ejaycoleman authored Feb 19, 2025
2 parents 68d0171 + aae075c commit 6d855fd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/real-buttons-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": minor
---

Extract swap parameters from deeplink
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function useDeepLinkHandler() {
(
pathname: string,
state?: {
[k: string]: string;
[k: string]: string | Object;
},
search?: string,
) => {
Expand Down Expand Up @@ -203,9 +203,26 @@ export function useDeepLinkHandler() {
}
break;
}
case "swap":
navigate("/swap");
case "swap": {
const { amountFrom, fromToken, toToken } = query;

const state: {
defaultToken?: { fromTokenId: string; toTokenId: string };
defaultAmountFrom?: string;
} = {};

if (fromToken !== toToken) {
state.defaultToken = { fromTokenId: fromToken, toTokenId: toToken };
}

if (amountFrom) {
state.defaultAmountFrom = amountFrom;
}

navigate("/swap", state);

break;
}

case "bridge": {
const { origin, appName } = query;
Expand Down

0 comments on commit 6d855fd

Please sign in to comment.