From 7626435785458a3606fe6e0c9850e4e349da5ad7 Mon Sep 17 00:00:00 2001 From: Luis Couto Date: Tue, 17 Dec 2024 08:45:39 +0000 Subject: [PATCH 1/3] fix(LIVE-14956): set a default 0 value for swap transactions --- .../renderer/components/BalanceInfos/index.tsx | 1 + .../ContextMenu/AccountContextMenu.tsx | 1 + .../screens/account/AccountHeaderActions.tsx | 1 + .../screens/asset/AssetBalanceSummaryHeader.tsx | 1 + .../exchange/Swap2/Form/SwapWebViewDemo3.tsx | 17 +++++++++++++++-- .../screens/market/hooks/useMarketActions.ts | 1 + 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/ledger-live-desktop/src/renderer/components/BalanceInfos/index.tsx b/apps/ledger-live-desktop/src/renderer/components/BalanceInfos/index.tsx index 70d95f055136..e36ba8bf3300 100644 --- a/apps/ledger-live-desktop/src/renderer/components/BalanceInfos/index.tsx +++ b/apps/ledger-live-desktop/src/renderer/components/BalanceInfos/index.tsx @@ -168,6 +168,7 @@ export default function BalanceInfos({ state: { from: history.location.pathname, defaultAccount, + defaultAmountFrom: "0", defaultParentAccount: parentAccount, }, }); diff --git a/apps/ledger-live-desktop/src/renderer/components/ContextMenu/AccountContextMenu.tsx b/apps/ledger-live-desktop/src/renderer/components/ContextMenu/AccountContextMenu.tsx index 416cad1660f5..55974056750a 100644 --- a/apps/ledger-live-desktop/src/renderer/components/ContextMenu/AccountContextMenu.tsx +++ b/apps/ledger-live-desktop/src/renderer/components/ContextMenu/AccountContextMenu.tsx @@ -120,6 +120,7 @@ export default function AccountContextMenu({ state: { defaultCurrency: currency, defaultAccount: account, + defaultAmountFrom: "0", defaultParentAccount: parentAccount, from: history.location.pathname, }, diff --git a/apps/ledger-live-desktop/src/renderer/screens/account/AccountHeaderActions.tsx b/apps/ledger-live-desktop/src/renderer/screens/account/AccountHeaderActions.tsx index 02005b16748f..8be8d22096a2 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/account/AccountHeaderActions.tsx +++ b/apps/ledger-live-desktop/src/renderer/screens/account/AccountHeaderActions.tsx @@ -257,6 +257,7 @@ const AccountHeaderActions = ({ account, parentAccount, openModal }: Props) => { defaultCurrency: currency, defaultAccount: account, defaultParentAccount: parentAccount, + defaultAmountFrom: "0", from: history.location.pathname, }, }); diff --git a/apps/ledger-live-desktop/src/renderer/screens/asset/AssetBalanceSummaryHeader.tsx b/apps/ledger-live-desktop/src/renderer/screens/asset/AssetBalanceSummaryHeader.tsx index e135745681fa..012a641c17a2 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/asset/AssetBalanceSummaryHeader.tsx +++ b/apps/ledger-live-desktop/src/renderer/screens/asset/AssetBalanceSummaryHeader.tsx @@ -122,6 +122,7 @@ export default function AssetBalanceSummaryHeader({ defaultAccount: account, defaultParentAccount: parentAccount, defaultCurrency: currency, + defaultAmountFrom: "0", from: history.location.pathname, }, }); diff --git a/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx b/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx index d013ae215452..22c68021fa38 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx +++ b/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx @@ -127,6 +127,7 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => { const { state } = useLocation<{ defaultAccount?: AccountLike; defaultParentAccount?: Account; + defaultFromAmount?: Number; from?: string; }>(); const { networkStatus } = useNetworkStatus(); @@ -402,11 +403,23 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => { state?.defaultAccount, state?.defaultParentAccount, ).id, + amountFrom: state?.defaultAmountFrom || "", + } + : {}), + ...(state?.from + ? { + fromPath: simplifyFromPath(state?.from), } : {}), - ...(state?.from ? { fromPath: simplifyFromPath(state?.from) } : {}), }).toString(), - [isOffline, state?.defaultAccount, state?.defaultParentAccount, state?.from, walletState], + [ + isOffline, + state?.defaultAccount, + state?.defaultParentAccount, + state?.defaultAmountFrom, + state?.from, + walletState, + ], ); const onSwapWebviewError = (error?: SwapLiveError) => { diff --git a/apps/ledger-live-desktop/src/renderer/screens/market/hooks/useMarketActions.ts b/apps/ledger-live-desktop/src/renderer/screens/market/hooks/useMarketActions.ts index a453ab1bccd5..502e8b1f1be3 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/market/hooks/useMarketActions.ts +++ b/apps/ledger-live-desktop/src/renderer/screens/market/hooks/useMarketActions.ts @@ -100,6 +100,7 @@ export const useMarketActions = ({ currency, page, currenciesAll }: MarketAction state: { defaultCurrency: internalCurrency, defaultAccount, + defaultAmountFrom: "0", defaultParentAccount: "parentId" in defaultAccount && defaultAccount.parentId ? flattenedAccounts.find(a => a.id === defaultAccount.parentId) From 58de9388475f5526ee0c12ff75fa2bc6366d2b93 Mon Sep 17 00:00:00 2001 From: Luis Couto Date: Tue, 17 Dec 2024 08:52:38 +0000 Subject: [PATCH 2/3] chore(N/A): add changeset for minor version --- .changeset/moody-oranges-reply.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/moody-oranges-reply.md diff --git a/.changeset/moody-oranges-reply.md b/.changeset/moody-oranges-reply.md new file mode 100644 index 000000000000..96bdbba4304c --- /dev/null +++ b/.changeset/moody-oranges-reply.md @@ -0,0 +1,5 @@ +--- +"ledger-live-desktop": minor +--- + +Set default value for swap exchanges From 6e11c96d5196c2e3897119aad0c409893efc34f3 Mon Sep 17 00:00:00 2001 From: Luis Couto Date: Wed, 18 Dec 2024 04:46:59 +0000 Subject: [PATCH 3/3] fix: type should be string --- .../renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx b/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx index 22c68021fa38..471471beabd9 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx +++ b/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx @@ -127,7 +127,7 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => { const { state } = useLocation<{ defaultAccount?: AccountLike; defaultParentAccount?: Account; - defaultFromAmount?: Number; + defaultAmountFrom?: string; from?: string; }>(); const { networkStatus } = useNetworkStatus();