From 5f95d74e985cb202c46d402b1d1307c40e6b8dd6 Mon Sep 17 00:00:00 2001 From: Iveta Date: Thu, 5 Sep 2024 17:19:04 -0400 Subject: [PATCH] Fix SEP-6 flow --- .../src/components/Sep6Deposit.tsx | 33 +++++++++---------- .../src/components/Sep6QuoteModal.tsx | 6 +++- .../src/components/Sep6Withdraw.tsx | 33 +++++++++---------- .../src/ducks/sep6Deposit.ts | 11 ++++++- .../src/ducks/sep6Withdraw.ts | 20 ++++++----- 5 files changed, 59 insertions(+), 44 deletions(-) diff --git a/packages/demo-wallet-client/src/components/Sep6Deposit.tsx b/packages/demo-wallet-client/src/components/Sep6Deposit.tsx index 049737f7..ae37aa63 100644 --- a/packages/demo-wallet-client/src/components/Sep6Deposit.tsx +++ b/packages/demo-wallet-client/src/components/Sep6Deposit.tsx @@ -297,23 +297,21 @@ export const Sep6Deposit = () => { ))} - {a.country_codes?.length && a.country_codes.length > 1 ? ( -
-
Country code
- {a.country_codes?.map((c) => ( - { - setSelectedDepositAssetCountryCode(c); - }} - checked={c === selectedDepositAssetCountryCode} - /> - ))} -
- ) : null} +
+
Country code
+ {a.country_codes?.map((c) => ( + { + setSelectedDepositAssetCountryCode(c); + }} + checked={c === selectedDepositAssetCountryCode} + /> + ))} +
))} @@ -458,6 +456,7 @@ export const Sep6Deposit = () => { ) { return ( void; onSubmit: (event: React.MouseEvent) => void; }; export const Sep6QuoteModal = ({ + type, quote, onClose, onSubmit, @@ -66,7 +68,9 @@ export const Sep6QuoteModal = ({ return ( - SEP-6 Deposit Quote + {`SEP-6 ${ + type === "deposit" ? "Deposit" : "Withdrawal" + } Quote`}

These prices are indicative. The actual price will be calculated at diff --git a/packages/demo-wallet-client/src/components/Sep6Withdraw.tsx b/packages/demo-wallet-client/src/components/Sep6Withdraw.tsx index b56d3616..c035aa38 100644 --- a/packages/demo-wallet-client/src/components/Sep6Withdraw.tsx +++ b/packages/demo-wallet-client/src/components/Sep6Withdraw.tsx @@ -316,23 +316,21 @@ export const Sep6Withdraw = () => { ))} - {a.country_codes?.length && a.country_codes.length > 1 ? ( -

-
Country code
- {a.country_codes?.map((c) => ( - { - setSelectedWithdrawAssetCountryCode(c); - }} - checked={c === selectedWithdrawAssetCountryCode} - /> - ))} -
- ) : null} +
+
Country code
+ {a.country_codes?.map((c) => ( + { + setSelectedWithdrawAssetCountryCode(c); + }} + checked={c === selectedWithdrawAssetCountryCode} + /> + ))} +
))} @@ -502,6 +500,7 @@ export const Sep6Withdraw = () => { ) { return ( a.asset !== buyAsset && a.buy_delivery_methods, + (a) => a.asset !== buyAsset && a.sell_delivery_methods, ); log.instruction({ @@ -131,6 +131,15 @@ export const initiateDepositAction = createAsyncThunk< }); } + const actionType = + supportsQuotes && depositAssets && depositAssets?.length > 0 + ? AnchorActionType.DEPOSIT_EXCHANGE + : AnchorActionType.DEPOSIT; + + log.instruction({ + title: `Selected ${actionType} path`, + }); + // Get either deposit or deposit-exchange asset data const assetInfoData = infoData[ diff --git a/packages/demo-wallet-client/src/ducks/sep6Withdraw.ts b/packages/demo-wallet-client/src/ducks/sep6Withdraw.ts index 04488706..fec4a420 100644 --- a/packages/demo-wallet-client/src/ducks/sep6Withdraw.ts +++ b/packages/demo-wallet-client/src/ducks/sep6Withdraw.ts @@ -122,7 +122,7 @@ export const initiateWithdrawAction = createAsyncThunk< }); withdrawAssets = quotesResult.assets.filter( - (a) => a.asset !== sellAsset && a.sell_delivery_methods, + (a) => a.asset !== sellAsset && a.buy_delivery_methods, ); log.instruction({ @@ -131,13 +131,17 @@ export const initiateWithdrawAction = createAsyncThunk< }); } - // Get either deposit or deposit-exchange asset data - const assetInfoData = - infoData[ - supportsQuotes && withdrawAssets && withdrawAssets?.length > 0 - ? AnchorActionType.WITHDRAW_EXCHANGE - : AnchorActionType.WITHDRAWAL - ]?.[assetCode]; + const actionType = + supportsQuotes && withdrawAssets && withdrawAssets?.length > 0 + ? AnchorActionType.WITHDRAW_EXCHANGE + : AnchorActionType.WITHDRAWAL; + + log.instruction({ + title: `Selected ${actionType} path`, + }); + + // Get either withdarw or withdraw-exchange asset data + const assetInfoData = infoData[actionType]?.[assetCode]; // This is unlikely if (!assetInfoData) {