@xswap-link/sdk 0.6.10 → 0.8.0

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 (46) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/index.d.mts +124 -72
  3. package/dist/index.d.ts +124 -72
  4. package/dist/index.global.js +686 -281
  5. package/dist/index.js +10 -10
  6. package/dist/index.mjs +10 -10
  7. package/package.json +1 -1
  8. package/src/assets/icons/ArrowsExchange.tsx +18 -0
  9. package/src/assets/icons/index.ts +1 -0
  10. package/src/components/Modal/index.tsx +48 -41
  11. package/src/components/Swap/Header/index.tsx +4 -2
  12. package/src/components/Swap/HistoryView/index.tsx +2 -2
  13. package/src/components/Swap/ReorderButton/ReorderButton.tsx +37 -0
  14. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/ArrowIcon.tsx +1 -1
  15. package/src/components/Swap/SwapView/SwapButton/index.tsx +31 -22
  16. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/ChainItem/index.tsx +55 -22
  17. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/index.tsx +74 -10
  18. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/index.tsx +83 -28
  19. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/TokenItem/index.tsx +9 -5
  20. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +12 -6
  21. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/index.tsx +50 -29
  22. package/src/components/Swap/SwapView/SwapPanel/index.tsx +8 -3
  23. package/src/components/Swap/SwapView/WalletPicker/index.tsx +7 -6
  24. package/src/components/Swap/SwapView/index.tsx +3 -3
  25. package/src/components/Swap/index.tsx +1 -1
  26. package/src/components/TxConfigForm/index.tsx +69 -19
  27. package/src/components/TxModal/index.tsx +59 -0
  28. package/src/components/TxWidgetWC/index.tsx +47 -2
  29. package/src/components/TxWidgetWCWrapped/index.tsx +33 -1
  30. package/src/components/index.ts +1 -0
  31. package/src/config/index.ts +1 -1
  32. package/src/context/SwapProvider.tsx +177 -27
  33. package/src/context/TxUIWrapper.tsx +5 -5
  34. package/src/hooks/index.ts +0 -1
  35. package/src/models/BridgeTokensDictionary.ts +7 -0
  36. package/src/models/TokenData.ts +3 -1
  37. package/src/models/index.ts +6 -5
  38. package/src/models/payloads/ModalIntegrationPayload.ts +17 -3
  39. package/src/models/payloads/WidgetIntegrationPayload.ts +15 -1
  40. package/src/services/api.ts +6 -1
  41. package/src/services/integrations/transactions.ts +40 -17
  42. package/src/types/global.d.ts +15 -0
  43. package/src/utils/validation.ts +367 -0
  44. package/tsconfig.json +3 -2
  45. package/src/context/ModalProvider.tsx +0 -63
  46. package/src/hooks/usePortal.ts +0 -79
@@ -1,79 +0,0 @@
1
- import { useEffect, useRef } from "react";
2
-
3
- /**
4
- * Creates DOM element to be used as React root.
5
- */
6
- function createRootElement(id: string): HTMLElement {
7
- const rootContainer = document.createElement("div");
8
- rootContainer.setAttribute("id", id);
9
- return rootContainer;
10
- }
11
-
12
- /**
13
- * Appends element as last child of body.
14
- */
15
- function addRootElement(rootElem: Element): void {
16
- document.body.insertBefore(
17
- rootElem,
18
- document.body.lastElementChild!.nextElementSibling,
19
- );
20
- }
21
-
22
- /**
23
- * Hook to create a React Portal.
24
- * Automatically handles creating and tearing-down the root elements (no SRR
25
- * makes this trivial), so there is no need to ensure the parent target already
26
- * exists.
27
- * @example
28
- * const target = usePortal(id, [id]);
29
- * return createPortal(children, target);
30
- * @param {string} id The id of the target container, e.g 'modal' or 'spotlight'
31
- * @returns {HTMLElement} The DOM node to use as the Portal target.
32
- */
33
- export function usePortal(id: string): HTMLElement {
34
- const rootElemRef = useRef<HTMLElement | null>(null);
35
-
36
- useEffect(
37
- function setupElement() {
38
- // Look for existing target dom element to append to
39
- const existingParent = document.querySelector(`#${id}`);
40
- // Parent is either a new root or the existing dom element
41
- const parentElem = existingParent || createRootElement(id);
42
-
43
- // If there is no existing DOM element, add a new one.
44
- if (!existingParent) {
45
- addRootElement(parentElem);
46
- }
47
-
48
- // Add the detached element to the parent
49
- parentElem.appendChild(rootElemRef.current!);
50
-
51
- return function removeElement() {
52
- rootElemRef.current!.remove();
53
- if (!parentElem.childElementCount) {
54
- parentElem.remove();
55
- }
56
- };
57
- },
58
- [id],
59
- );
60
-
61
- /**
62
- * It's important we evaluate this lazily:
63
- * - We need first render to contain the DOM element, so it shouldn't happen
64
- * in useEffect. We would normally put this in the constructor().
65
- * - We can't do 'const rootElemRef = useRef(document.createElement('div))',
66
- * since this will run every single render (that's a lot).
67
- * - We want the ref to consistently point to the same DOM element and only
68
- * ever run once.
69
- * @link https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
70
- */
71
- function getRootElem(): HTMLElement {
72
- if (!rootElemRef.current) {
73
- rootElemRef.current = document.createElement("div");
74
- }
75
- return rootElemRef.current;
76
- }
77
-
78
- return getRootElem();
79
- }