@rango-dev/widget-embedded 0.27.3-next.5 → 0.27.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -2
  2. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
  4. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  5. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +1 -1
  6. package/dist/components/Quote/Quote.d.ts.map +1 -1
  7. package/dist/components/Quote/Quote.styles.d.ts +1 -1
  8. package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
  9. package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
  10. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
  11. package/dist/hooks/useFetch.d.ts +1 -1
  12. package/dist/hooks/useFetch.d.ts.map +1 -1
  13. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
  14. package/dist/index.js +2 -2
  15. package/dist/index.js.map +4 -4
  16. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  17. package/dist/pages/Home.d.ts.map +1 -1
  18. package/dist/utils/swap.d.ts +2 -3
  19. package/dist/utils/swap.d.ts.map +1 -1
  20. package/dist/utils/wallets.d.ts +4 -1
  21. package/dist/utils/wallets.d.ts.map +1 -1
  22. package/package.json +8 -8
  23. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +1 -19
  24. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +22 -23
  25. package/src/components/Quote/Quote.styles.ts +1 -19
  26. package/src/components/Quote/Quote.tsx +2 -12
  27. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +3 -3
  28. package/src/hooks/useFetch.ts +2 -13
  29. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +1 -1
  30. package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +1 -10
  31. package/src/pages/ConfirmSwapPage.tsx +0 -65
  32. package/src/pages/Home.tsx +2 -1
  33. package/src/utils/swap.ts +32 -32
  34. package/src/utils/wallets.ts +30 -17
@@ -199,34 +199,47 @@ export function prepareAccountsForWalletStore(
199
199
  return result;
200
200
  }
201
201
 
202
- export function getRequiredChains(quote: SelectedQuote | null) {
203
- const wallets: string[] = [];
204
-
205
- quote?.swaps.forEach((swap) => {
202
+ export function getQuoteWallets(params: {
203
+ filter: 'all' | 'required';
204
+ quote: SelectedQuote | null;
205
+ }): string[] {
206
+ const { filter, quote } = params;
207
+ const wallets = new Set<string>();
208
+
209
+ quote?.swaps.forEach((swap, swapIndex) => {
206
210
  const currentStepFromBlockchain = swap.from.blockchain;
207
211
  const currentStepToBlockchain = swap.to.blockchain;
208
- if (!wallets.includes(currentStepFromBlockchain)) {
209
- wallets.push(currentStepFromBlockchain);
210
- }
211
- if (!wallets.includes(currentStepToBlockchain)) {
212
- wallets.push(currentStepToBlockchain);
213
- }
212
+ wallets.add(currentStepFromBlockchain);
214
213
 
215
214
  // Check if internalSwaps array exists
216
- if (swap.internalSwaps && Array.isArray(swap.internalSwaps)) {
217
- swap.internalSwaps.forEach((internalSwap) => {
215
+ if (swap.internalSwaps) {
216
+ const { internalSwaps } = swap;
217
+ internalSwaps.forEach((internalSwap, internalSwapIndex) => {
218
218
  const internalStepFromBlockchain = internalSwap.from.blockchain;
219
219
  const internalStepToBlockchain = internalSwap.to.blockchain;
220
- if (!wallets.includes(internalStepFromBlockchain)) {
221
- wallets.push(internalStepFromBlockchain);
220
+ const isLastStep = swapIndex === quote.swaps.length - 1;
221
+ const isLastInternalStep =
222
+ internalSwapIndex === internalSwaps.length - 1;
223
+
224
+ if (
225
+ (!isLastStep && !isLastInternalStep) ||
226
+ (isLastStep &&
227
+ currentStepToBlockchain !== internalStepFromBlockchain) ||
228
+ filter === 'all'
229
+ ) {
230
+ wallets.add(internalStepFromBlockchain);
222
231
  }
223
- if (!wallets.includes(internalStepToBlockchain)) {
224
- wallets.push(internalStepToBlockchain);
232
+ if (filter === 'all') {
233
+ wallets.add(internalStepToBlockchain);
225
234
  }
226
235
  });
227
236
  }
237
+
238
+ if (filter === 'all') {
239
+ wallets.add(currentStepToBlockchain);
240
+ }
228
241
  });
229
- return wallets;
242
+ return Array.from(wallets);
230
243
  }
231
244
 
232
245
  type Blockchain = { name: string; accounts: ConnectedWallet[] };