From 4fd44e03760fabe5aa9101498ee7ace53e522ec5 Mon Sep 17 00:00:00 2001 From: Jean Ribeiro Date: Mon, 1 Jul 2024 19:16:13 -0300 Subject: [PATCH] WIP --- .../desktop/features/buy-sell.features.ts | 3 + .../auxiliary/popup/enums/popup-id.enum.ts | 1 + .../buy-sell/components/TokenTile.svelte | 50 +++++++ .../components/TransakAccountPanel.svelte | 49 ------- .../components/TransakAmountInput.svelte | 26 ++++ .../components/TransakExchangePanel.svelte | 74 ++++++++++ .../components/TransakHistoryPanel.svelte | 8 ++ .../TransakWindowPlaceholder.svelte | 30 ---- .../dashboard/buy-sell/components/index.ts | 6 +- .../buy-sell/views/BuySellMainView.svelte | 47 ++----- .../components/inputs/FiatAmountInput.svelte | 130 ++++++++++++++++++ .../transak-window-data.interface.ts | 4 +- .../market/actions/getMarketPriceForToken.ts | 6 +- .../actions/getTokenValueFromFiatAmount.ts | 29 ++++ .../src/lib/core/market/actions/index.ts | 1 + .../interfaces/feature-flag.interface.ts | 1 + packages/shared/src/locales/en.json | 4 + 17 files changed, 351 insertions(+), 118 deletions(-) create mode 100644 packages/desktop/views/dashboard/buy-sell/components/TokenTile.svelte delete mode 100644 packages/desktop/views/dashboard/buy-sell/components/TransakAccountPanel.svelte create mode 100644 packages/desktop/views/dashboard/buy-sell/components/TransakAmountInput.svelte create mode 100644 packages/desktop/views/dashboard/buy-sell/components/TransakExchangePanel.svelte create mode 100644 packages/desktop/views/dashboard/buy-sell/components/TransakHistoryPanel.svelte delete mode 100644 packages/desktop/views/dashboard/buy-sell/components/TransakWindowPlaceholder.svelte create mode 100644 packages/shared/src/components/inputs/FiatAmountInput.svelte create mode 100644 packages/shared/src/lib/core/market/actions/getTokenValueFromFiatAmount.ts diff --git a/packages/desktop/features/buy-sell.features.ts b/packages/desktop/features/buy-sell.features.ts index 07735ed62c..de3c65ecb1 100644 --- a/packages/desktop/features/buy-sell.features.ts +++ b/packages/desktop/features/buy-sell.features.ts @@ -2,6 +2,9 @@ import { IFeatureFlag } from '@lib/features/interfaces' const buySellFeatures: IFeatureFlag = { enabled: true, + sell: { + enabled: true + } } export default buySellFeatures diff --git a/packages/desktop/lib/auxiliary/popup/enums/popup-id.enum.ts b/packages/desktop/lib/auxiliary/popup/enums/popup-id.enum.ts index 429921049d..dd8bb4410d 100644 --- a/packages/desktop/lib/auxiliary/popup/enums/popup-id.enum.ts +++ b/packages/desktop/lib/auxiliary/popup/enums/popup-id.enum.ts @@ -39,6 +39,7 @@ export enum PopupId { ReceiveAddress = 'receiveAddress', RemoveProposal = 'removeProposal', Revote = 'revote', + SelectToken = 'selectToken', SendFlow = 'sendFlow', SignTypedData = 'signTypedData', SignMessage = 'signMessage', diff --git a/packages/desktop/views/dashboard/buy-sell/components/TokenTile.svelte b/packages/desktop/views/dashboard/buy-sell/components/TokenTile.svelte new file mode 100644 index 0000000000..ee3336b5a2 --- /dev/null +++ b/packages/desktop/views/dashboard/buy-sell/components/TokenTile.svelte @@ -0,0 +1,50 @@ + + +{#if token && token.metadata} + +
+ +
+
+ + {token.metadata.name + ? truncateString(token.metadata.name, 13, 0) + : truncateString(token.id, 6, 7)} + + + {token.metadata + ? `≈ ${formatTokenAmount(tokenAmount ?? BigInt(0), token.metadata, { round: false })}` + : '-'} + +
+
+ + {marketPrice ? formatCurrency(marketPrice, currency) : '-'} + + + {fiatValue !== undefined ? formatCurrency(fiatValue ?? '', currency) : '-'} + +
+
+
+
+{/if} diff --git a/packages/desktop/views/dashboard/buy-sell/components/TransakAccountPanel.svelte b/packages/desktop/views/dashboard/buy-sell/components/TransakAccountPanel.svelte deleted file mode 100644 index e4a16a29cb..0000000000 --- a/packages/desktop/views/dashboard/buy-sell/components/TransakAccountPanel.svelte +++ /dev/null @@ -1,49 +0,0 @@ - - - -
-
- - - - IOTA -
- -
-
- - {fiatBalance} -
- -
- - {$selectedAccount?.depositAddress} - -
-
-
diff --git a/packages/desktop/views/dashboard/buy-sell/components/TransakAmountInput.svelte b/packages/desktop/views/dashboard/buy-sell/components/TransakAmountInput.svelte new file mode 100644 index 0000000000..61e8ab3c1d --- /dev/null +++ b/packages/desktop/views/dashboard/buy-sell/components/TransakAmountInput.svelte @@ -0,0 +1,26 @@ + + +
+ + {currency} +
diff --git a/packages/desktop/views/dashboard/buy-sell/components/TransakExchangePanel.svelte b/packages/desktop/views/dashboard/buy-sell/components/TransakExchangePanel.svelte new file mode 100644 index 0000000000..693dfc12e7 --- /dev/null +++ b/packages/desktop/views/dashboard/buy-sell/components/TransakExchangePanel.svelte @@ -0,0 +1,74 @@ + + + + {#if error} +
+ + {localize('views.buySell.error.title')} + {localize('views.buySell.error.description')} +
+ {:else if loading} +
+ {#if isFeatureEnabled('buySell.sell')} +
+ +
+ {/if} +
+
+ +
+ + +
+ +
+
+
+ {/if} +
diff --git a/packages/desktop/views/dashboard/buy-sell/components/TransakHistoryPanel.svelte b/packages/desktop/views/dashboard/buy-sell/components/TransakHistoryPanel.svelte new file mode 100644 index 0000000000..5c8eb59826 --- /dev/null +++ b/packages/desktop/views/dashboard/buy-sell/components/TransakHistoryPanel.svelte @@ -0,0 +1,8 @@ + + + + Order history + diff --git a/packages/desktop/views/dashboard/buy-sell/components/TransakWindowPlaceholder.svelte b/packages/desktop/views/dashboard/buy-sell/components/TransakWindowPlaceholder.svelte deleted file mode 100644 index 1abbf927dd..0000000000 --- a/packages/desktop/views/dashboard/buy-sell/components/TransakWindowPlaceholder.svelte +++ /dev/null @@ -1,30 +0,0 @@ - - - - {#if error} - - {localize('views.buySell.error.title')} - {localize('views.buySell.error.description')} -