Skip to content

Commit

Permalink
fix(LIVE-14956): Set a default 0 value for swap transactions (#8710)
Browse files Browse the repository at this point in the history
<!--
Thank you for your contribution! 👍
Please make sure to read CONTRIBUTING.md if you have not already. Pull Requests that do not comply with the rules will be arbitrarily closed.
-->

### ✅ Checklist

<!-- Pull Requests must pass the CI and be code reviewed. Set as Draft if the PR is not ready. -->

- [x] `npx changeset` was attached.
- [x] **Covered by automatic tests.** <!-- if not, please explain. (Feature must be tested / Bug fix must bring non-regression) -->
- [ ] **Impact of the changes:** <!-- Please take some time to list the impact & what specific areas Quality Assurance (QA) should focus on -->
  - ...

### 📝 Description

Allow ledger-live to define an amount to swap. (Set to 0)

<!--
| Before        | After         |
| ------------- | ------------- |
|               |               |
-->

### ❓ Context

- https://ledgerhq.atlassian.net/browse/LIVE-14956


---

### 🧐 Checklist for the PR Reviewers

<!-- Please do not edit this if you are the PR author -->

- **The code aligns with the requirements** described in the linked JIRA or GitHub issue.
- **The PR description clearly documents the changes** made and explains any technical trade-offs or design decisions.
- **There are no undocumented trade-offs**, technical debt, or maintainability issues.
- **The PR has been tested** thoroughly, and any potential edge cases have been considered and handled.
- **Any new dependencies** have been justified and documented.
- **Performance** considerations have been taken into account. (changes have been profiled or benchmarked if necessary)
  • Loading branch information
Couto authored Dec 20, 2024
1 parent 9fce32f commit 02fd6c3
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-oranges-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": minor
---

Set default value for swap exchanges
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default function BalanceInfos({
state: {
from: history.location.pathname,
defaultAccount,
defaultAmountFrom: "0",
defaultParentAccount: parentAccount,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export default function AccountContextMenu({
state: {
defaultCurrency: currency,
defaultAccount: account,
defaultAmountFrom: "0",
defaultParentAccount: parentAccount,
from: history.location.pathname,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ const AccountHeaderActions = ({ account, parentAccount, openModal }: Props) => {
defaultCurrency: currency,
defaultAccount: account,
defaultParentAccount: parentAccount,
defaultAmountFrom: "0",
from: history.location.pathname,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default function AssetBalanceSummaryHeader({
defaultAccount: account,
defaultParentAccount: parentAccount,
defaultCurrency: currency,
defaultAmountFrom: "0",
from: history.location.pathname,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => {
const { state } = useLocation<{
defaultAccount?: AccountLike;
defaultParentAccount?: Account;
defaultAmountFrom?: string;
from?: string;
}>();
const { networkStatus } = useNetworkStatus();
Expand Down Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 02fd6c3

Please sign in to comment.