@relayprotocol/relay-kit-ui 7.1.6 → 8.0.1

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 (480) hide show
  1. package/_cjs/src/components/common/AmountInput.js +2 -17
  2. package/_cjs/src/components/common/AmountInput.js.map +1 -1
  3. package/_cjs/src/components/common/BalanceDisplay.js +2 -2
  4. package/_cjs/src/components/common/BalanceDisplay.js.map +1 -1
  5. package/_cjs/src/components/common/CopyToClipBoard.js +3 -7
  6. package/_cjs/src/components/common/CopyToClipBoard.js.map +1 -1
  7. package/_cjs/src/components/common/CustomAddressModal.js +10 -48
  8. package/_cjs/src/components/common/CustomAddressModal.js.map +1 -1
  9. package/_cjs/src/components/common/ErrorWell.js +9 -28
  10. package/_cjs/src/components/common/ErrorWell.js.map +1 -1
  11. package/_cjs/src/components/common/LoadingSpinner.js +7 -13
  12. package/_cjs/src/components/common/LoadingSpinner.js.map +1 -1
  13. package/_cjs/src/components/common/Modal.js +4 -22
  14. package/_cjs/src/components/common/Modal.js.map +1 -1
  15. package/_cjs/src/components/common/MultiWalletDropdown.js +23 -57
  16. package/_cjs/src/components/common/MultiWalletDropdown.js.map +1 -1
  17. package/_cjs/src/components/common/PercentageButtons.js +7 -24
  18. package/_cjs/src/components/common/PercentageButtons.js.map +1 -1
  19. package/_cjs/src/components/common/SlippageToleranceConfig.js +21 -117
  20. package/_cjs/src/components/common/SlippageToleranceConfig.js.map +1 -1
  21. package/_cjs/src/components/common/StepIcon.js +1 -7
  22. package/_cjs/src/components/common/StepIcon.js.map +1 -1
  23. package/_cjs/src/components/common/TokenSelector/ChainFilter.js +19 -109
  24. package/_cjs/src/components/common/TokenSelector/ChainFilter.js.map +1 -1
  25. package/_cjs/src/components/common/TokenSelector/ChainFilterRow.js +10 -54
  26. package/_cjs/src/components/common/TokenSelector/ChainFilterRow.js.map +1 -1
  27. package/_cjs/src/components/common/TokenSelector/ChainFilterSidebar.js +15 -98
  28. package/_cjs/src/components/common/TokenSelector/ChainFilterSidebar.js.map +1 -1
  29. package/_cjs/src/components/common/TokenSelector/ChainShortcuts.js +6 -28
  30. package/_cjs/src/components/common/TokenSelector/ChainShortcuts.js.map +1 -1
  31. package/_cjs/src/components/common/TokenSelector/CompactChainFilter.js +12 -83
  32. package/_cjs/src/components/common/TokenSelector/CompactChainFilter.js.map +1 -1
  33. package/_cjs/src/components/common/TokenSelector/MobileChainSelector.js +16 -109
  34. package/_cjs/src/components/common/TokenSelector/MobileChainSelector.js.map +1 -1
  35. package/_cjs/src/components/common/TokenSelector/PaymentMethod.js +10 -101
  36. package/_cjs/src/components/common/TokenSelector/PaymentMethod.js.map +1 -1
  37. package/_cjs/src/components/common/TokenSelector/PaymentTokenList.js +8 -69
  38. package/_cjs/src/components/common/TokenSelector/PaymentTokenList.js.map +1 -1
  39. package/_cjs/src/components/common/TokenSelector/SuggestedTokens.js +2 -33
  40. package/_cjs/src/components/common/TokenSelector/SuggestedTokens.js.map +1 -1
  41. package/_cjs/src/components/common/TokenSelector/TagPill.js +1 -9
  42. package/_cjs/src/components/common/TokenSelector/TagPill.js.map +1 -1
  43. package/_cjs/src/components/common/TokenSelector/TokenList.js +8 -57
  44. package/_cjs/src/components/common/TokenSelector/TokenList.js.map +1 -1
  45. package/_cjs/src/components/common/TokenSelector/TokenSelector.js +24 -70
  46. package/_cjs/src/components/common/TokenSelector/TokenSelector.js.map +1 -1
  47. package/_cjs/src/components/common/TokenSelector/triggers/PaymentMethodTrigger.js +2 -35
  48. package/_cjs/src/components/common/TokenSelector/triggers/PaymentMethodTrigger.js.map +1 -1
  49. package/_cjs/src/components/common/TokenSelector/triggers/TokenTrigger.js +2 -28
  50. package/_cjs/src/components/common/TokenSelector/triggers/TokenTrigger.js.map +1 -1
  51. package/_cjs/src/components/common/TransactionModal/DepositAddressModal.js +2 -10
  52. package/_cjs/src/components/common/TransactionModal/DepositAddressModal.js.map +1 -1
  53. package/_cjs/src/components/common/TransactionModal/TransactionModal.js +2 -13
  54. package/_cjs/src/components/common/TransactionModal/TransactionModal.js.map +1 -1
  55. package/_cjs/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js +8 -45
  56. package/_cjs/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js.map +1 -1
  57. package/_cjs/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js +1 -5
  58. package/_cjs/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js.map +1 -1
  59. package/_cjs/src/components/common/TransactionModal/steps/ErrorStep.js +9 -30
  60. package/_cjs/src/components/common/TransactionModal/steps/ErrorStep.js.map +1 -1
  61. package/_cjs/src/components/common/TransactionModal/steps/SwapConfirmationStep.js +26 -81
  62. package/_cjs/src/components/common/TransactionModal/steps/SwapConfirmationStep.js.map +1 -1
  63. package/_cjs/src/components/common/TransactionModal/steps/SwapSuccessStep.js +16 -76
  64. package/_cjs/src/components/common/TransactionModal/steps/SwapSuccessStep.js.map +1 -1
  65. package/_cjs/src/components/common/TransactionModal/steps/TransactionsByChain.js +3 -8
  66. package/_cjs/src/components/common/TransactionModal/steps/TransactionsByChain.js.map +1 -1
  67. package/_cjs/src/components/common/TransactionModal/steps/WaitingForDepositStep.js +27 -63
  68. package/_cjs/src/components/common/TransactionModal/steps/WaitingForDepositStep.js.map +1 -1
  69. package/_cjs/src/components/common/UnverifiedTokenModal.js +6 -32
  70. package/_cjs/src/components/common/UnverifiedTokenModal.js.map +1 -1
  71. package/_cjs/src/components/primitives/AccessibleList.js +5 -21
  72. package/_cjs/src/components/primitives/AccessibleList.js.map +1 -1
  73. package/_cjs/src/components/primitives/Anchor.js +18 -41
  74. package/_cjs/src/components/primitives/Anchor.js.map +1 -1
  75. package/_cjs/src/components/primitives/Box.js +3 -4
  76. package/_cjs/src/components/primitives/Box.js.map +1 -1
  77. package/_cjs/src/components/primitives/Button.js +63 -124
  78. package/_cjs/src/components/primitives/Button.js.map +1 -1
  79. package/_cjs/src/components/primitives/ChainIcon.js +5 -9
  80. package/_cjs/src/components/primitives/ChainIcon.js.map +1 -1
  81. package/_cjs/src/components/primitives/ChainTokenIcon.js +7 -26
  82. package/_cjs/src/components/primitives/ChainTokenIcon.js.map +1 -1
  83. package/_cjs/src/components/primitives/Collapsible.js +7 -32
  84. package/_cjs/src/components/primitives/Collapsible.js.map +1 -1
  85. package/_cjs/src/components/primitives/Dialog.js +39 -81
  86. package/_cjs/src/components/primitives/Dialog.js.map +1 -1
  87. package/_cjs/src/components/primitives/Dropdown.js +5 -35
  88. package/_cjs/src/components/primitives/Dropdown.js.map +1 -1
  89. package/_cjs/src/components/primitives/Flex.js +23 -59
  90. package/_cjs/src/components/primitives/Flex.js.map +1 -1
  91. package/_cjs/src/components/primitives/Input.js +19 -51
  92. package/_cjs/src/components/primitives/Input.js.map +1 -1
  93. package/_cjs/src/components/primitives/Pill.js +18 -49
  94. package/_cjs/src/components/primitives/Pill.js.map +1 -1
  95. package/_cjs/src/components/primitives/Skeleton.js +3 -12
  96. package/_cjs/src/components/primitives/Skeleton.js.map +1 -1
  97. package/_cjs/src/components/primitives/SlippageButton.js +1 -13
  98. package/_cjs/src/components/primitives/SlippageButton.js.map +1 -1
  99. package/_cjs/src/components/primitives/Switch.js +5 -43
  100. package/_cjs/src/components/primitives/Switch.js.map +1 -1
  101. package/_cjs/src/components/primitives/Tabs.js +9 -39
  102. package/_cjs/src/components/primitives/Tabs.js.map +1 -1
  103. package/_cjs/src/components/primitives/Text.js +36 -94
  104. package/_cjs/src/components/primitives/Text.js.map +1 -1
  105. package/_cjs/src/components/primitives/Tooltip.js +2 -30
  106. package/_cjs/src/components/primitives/Tooltip.js.map +1 -1
  107. package/_cjs/src/components/widgets/FeeBreakdown.js +25 -82
  108. package/_cjs/src/components/widgets/FeeBreakdown.js.map +1 -1
  109. package/_cjs/src/components/widgets/FetchingQuoteLoader.js +3 -9
  110. package/_cjs/src/components/widgets/FetchingQuoteLoader.js.map +1 -1
  111. package/_cjs/src/components/widgets/OnrampWidget/modals/OnrampModal.js +1 -8
  112. package/_cjs/src/components/widgets/OnrampWidget/modals/OnrampModal.js.map +1 -1
  113. package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js +2 -19
  114. package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js.map +1 -1
  115. package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js +3 -27
  116. package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js.map +1 -1
  117. package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js +2 -32
  118. package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js.map +1 -1
  119. package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js +9 -45
  120. package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js.map +1 -1
  121. package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js +5 -26
  122. package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js.map +1 -1
  123. package/_cjs/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js +7 -96
  124. package/_cjs/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js.map +1 -1
  125. package/_cjs/src/components/widgets/OnrampWidget/widget/index.js +18 -112
  126. package/_cjs/src/components/widgets/OnrampWidget/widget/index.js.map +1 -1
  127. package/_cjs/src/components/widgets/PriceImpactTooltip.js +3 -9
  128. package/_cjs/src/components/widgets/PriceImpactTooltip.js.map +1 -1
  129. package/_cjs/src/components/widgets/SwapButton.js +3 -14
  130. package/_cjs/src/components/widgets/SwapButton.js.map +1 -1
  131. package/_cjs/src/components/widgets/SwapWidget/GasTopUpSection.js +6 -11
  132. package/_cjs/src/components/widgets/SwapWidget/GasTopUpSection.js.map +1 -1
  133. package/_cjs/src/components/widgets/SwapWidget/PriceImpact.js +2 -4
  134. package/_cjs/src/components/widgets/SwapWidget/PriceImpact.js.map +1 -1
  135. package/_cjs/src/components/widgets/SwapWidget/index.js +35 -136
  136. package/_cjs/src/components/widgets/SwapWidget/index.js.map +1 -1
  137. package/_cjs/src/components/widgets/TokenSelectorContainer.js +3 -13
  138. package/_cjs/src/components/widgets/TokenSelectorContainer.js.map +1 -1
  139. package/_cjs/src/components/widgets/WidgetErrorWell.js +10 -76
  140. package/_cjs/src/components/widgets/WidgetErrorWell.js.map +1 -1
  141. package/_cjs/src/providers/RelayKitProvider.js +1 -0
  142. package/_cjs/src/providers/RelayKitProvider.js.map +1 -1
  143. package/_cjs/src/styles.css +3 -3717
  144. package/_cjs/src/themes/RelayKitTheme.js.map +1 -1
  145. package/_cjs/src/utils/cn.js +13 -0
  146. package/_cjs/src/utils/cn.js.map +1 -0
  147. package/_cjs/src/utils/theme.js +13 -1
  148. package/_cjs/src/utils/theme.js.map +1 -1
  149. package/_cjs/src/version.js +1 -1
  150. package/_cjs/tsconfig.build.tsbuildinfo +1 -1
  151. package/_esm/package.json +1 -1
  152. package/_esm/src/components/common/AmountInput.js +2 -17
  153. package/_esm/src/components/common/AmountInput.js.map +1 -1
  154. package/_esm/src/components/common/BalanceDisplay.js +2 -2
  155. package/_esm/src/components/common/BalanceDisplay.js.map +1 -1
  156. package/_esm/src/components/common/CopyToClipBoard.js +3 -7
  157. package/_esm/src/components/common/CopyToClipBoard.js.map +1 -1
  158. package/_esm/src/components/common/CustomAddressModal.js +10 -48
  159. package/_esm/src/components/common/CustomAddressModal.js.map +1 -1
  160. package/_esm/src/components/common/ErrorWell.js +9 -29
  161. package/_esm/src/components/common/ErrorWell.js.map +1 -1
  162. package/_esm/src/components/common/LoadingSpinner.js +7 -13
  163. package/_esm/src/components/common/LoadingSpinner.js.map +1 -1
  164. package/_esm/src/components/common/Modal.js +4 -22
  165. package/_esm/src/components/common/Modal.js.map +1 -1
  166. package/_esm/src/components/common/MultiWalletDropdown.js +22 -56
  167. package/_esm/src/components/common/MultiWalletDropdown.js.map +1 -1
  168. package/_esm/src/components/common/PercentageButtons.js +7 -24
  169. package/_esm/src/components/common/PercentageButtons.js.map +1 -1
  170. package/_esm/src/components/common/SlippageToleranceConfig.js +21 -117
  171. package/_esm/src/components/common/SlippageToleranceConfig.js.map +1 -1
  172. package/_esm/src/components/common/StepIcon.js +1 -7
  173. package/_esm/src/components/common/StepIcon.js.map +1 -1
  174. package/_esm/src/components/common/TokenSelector/ChainFilter.js +19 -109
  175. package/_esm/src/components/common/TokenSelector/ChainFilter.js.map +1 -1
  176. package/_esm/src/components/common/TokenSelector/ChainFilterRow.js +10 -54
  177. package/_esm/src/components/common/TokenSelector/ChainFilterRow.js.map +1 -1
  178. package/_esm/src/components/common/TokenSelector/ChainFilterSidebar.js +15 -98
  179. package/_esm/src/components/common/TokenSelector/ChainFilterSidebar.js.map +1 -1
  180. package/_esm/src/components/common/TokenSelector/ChainShortcuts.js +6 -28
  181. package/_esm/src/components/common/TokenSelector/ChainShortcuts.js.map +1 -1
  182. package/_esm/src/components/common/TokenSelector/CompactChainFilter.js +12 -83
  183. package/_esm/src/components/common/TokenSelector/CompactChainFilter.js.map +1 -1
  184. package/_esm/src/components/common/TokenSelector/MobileChainSelector.js +16 -109
  185. package/_esm/src/components/common/TokenSelector/MobileChainSelector.js.map +1 -1
  186. package/_esm/src/components/common/TokenSelector/PaymentMethod.js +10 -101
  187. package/_esm/src/components/common/TokenSelector/PaymentMethod.js.map +1 -1
  188. package/_esm/src/components/common/TokenSelector/PaymentTokenList.js +8 -69
  189. package/_esm/src/components/common/TokenSelector/PaymentTokenList.js.map +1 -1
  190. package/_esm/src/components/common/TokenSelector/SuggestedTokens.js +2 -33
  191. package/_esm/src/components/common/TokenSelector/SuggestedTokens.js.map +1 -1
  192. package/_esm/src/components/common/TokenSelector/TagPill.js +1 -9
  193. package/_esm/src/components/common/TokenSelector/TagPill.js.map +1 -1
  194. package/_esm/src/components/common/TokenSelector/TokenList.js +9 -57
  195. package/_esm/src/components/common/TokenSelector/TokenList.js.map +1 -1
  196. package/_esm/src/components/common/TokenSelector/TokenSelector.js +24 -70
  197. package/_esm/src/components/common/TokenSelector/TokenSelector.js.map +1 -1
  198. package/_esm/src/components/common/TokenSelector/triggers/PaymentMethodTrigger.js +2 -35
  199. package/_esm/src/components/common/TokenSelector/triggers/PaymentMethodTrigger.js.map +1 -1
  200. package/_esm/src/components/common/TokenSelector/triggers/TokenTrigger.js +2 -28
  201. package/_esm/src/components/common/TokenSelector/triggers/TokenTrigger.js.map +1 -1
  202. package/_esm/src/components/common/TransactionModal/DepositAddressModal.js +2 -10
  203. package/_esm/src/components/common/TransactionModal/DepositAddressModal.js.map +1 -1
  204. package/_esm/src/components/common/TransactionModal/TransactionModal.js +2 -13
  205. package/_esm/src/components/common/TransactionModal/TransactionModal.js.map +1 -1
  206. package/_esm/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js +8 -45
  207. package/_esm/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js.map +1 -1
  208. package/_esm/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js +1 -5
  209. package/_esm/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js.map +1 -1
  210. package/_esm/src/components/common/TransactionModal/steps/ErrorStep.js +9 -30
  211. package/_esm/src/components/common/TransactionModal/steps/ErrorStep.js.map +1 -1
  212. package/_esm/src/components/common/TransactionModal/steps/SwapConfirmationStep.js +26 -81
  213. package/_esm/src/components/common/TransactionModal/steps/SwapConfirmationStep.js.map +1 -1
  214. package/_esm/src/components/common/TransactionModal/steps/SwapSuccessStep.js +16 -76
  215. package/_esm/src/components/common/TransactionModal/steps/SwapSuccessStep.js.map +1 -1
  216. package/_esm/src/components/common/TransactionModal/steps/TransactionsByChain.js +3 -8
  217. package/_esm/src/components/common/TransactionModal/steps/TransactionsByChain.js.map +1 -1
  218. package/_esm/src/components/common/TransactionModal/steps/WaitingForDepositStep.js +28 -63
  219. package/_esm/src/components/common/TransactionModal/steps/WaitingForDepositStep.js.map +1 -1
  220. package/_esm/src/components/common/UnverifiedTokenModal.js +6 -32
  221. package/_esm/src/components/common/UnverifiedTokenModal.js.map +1 -1
  222. package/_esm/src/components/primitives/AccessibleList.js +5 -21
  223. package/_esm/src/components/primitives/AccessibleList.js.map +1 -1
  224. package/_esm/src/components/primitives/Anchor.js +18 -41
  225. package/_esm/src/components/primitives/Anchor.js.map +1 -1
  226. package/_esm/src/components/primitives/Box.js +3 -4
  227. package/_esm/src/components/primitives/Box.js.map +1 -1
  228. package/_esm/src/components/primitives/Button.js +63 -124
  229. package/_esm/src/components/primitives/Button.js.map +1 -1
  230. package/_esm/src/components/primitives/ChainIcon.js +5 -9
  231. package/_esm/src/components/primitives/ChainIcon.js.map +1 -1
  232. package/_esm/src/components/primitives/ChainTokenIcon.js +7 -26
  233. package/_esm/src/components/primitives/ChainTokenIcon.js.map +1 -1
  234. package/_esm/src/components/primitives/Collapsible.js +7 -32
  235. package/_esm/src/components/primitives/Collapsible.js.map +1 -1
  236. package/_esm/src/components/primitives/Dialog.js +39 -81
  237. package/_esm/src/components/primitives/Dialog.js.map +1 -1
  238. package/_esm/src/components/primitives/Dropdown.js +5 -35
  239. package/_esm/src/components/primitives/Dropdown.js.map +1 -1
  240. package/_esm/src/components/primitives/Flex.js +22 -58
  241. package/_esm/src/components/primitives/Flex.js.map +1 -1
  242. package/_esm/src/components/primitives/Input.js +19 -50
  243. package/_esm/src/components/primitives/Input.js.map +1 -1
  244. package/_esm/src/components/primitives/Pill.js +17 -48
  245. package/_esm/src/components/primitives/Pill.js.map +1 -1
  246. package/_esm/src/components/primitives/Skeleton.js +3 -12
  247. package/_esm/src/components/primitives/Skeleton.js.map +1 -1
  248. package/_esm/src/components/primitives/SlippageButton.js +1 -13
  249. package/_esm/src/components/primitives/SlippageButton.js.map +1 -1
  250. package/_esm/src/components/primitives/Switch.js +5 -43
  251. package/_esm/src/components/primitives/Switch.js.map +1 -1
  252. package/_esm/src/components/primitives/Tabs.js +9 -39
  253. package/_esm/src/components/primitives/Tabs.js.map +1 -1
  254. package/_esm/src/components/primitives/Text.js +36 -94
  255. package/_esm/src/components/primitives/Text.js.map +1 -1
  256. package/_esm/src/components/primitives/Tooltip.js +3 -30
  257. package/_esm/src/components/primitives/Tooltip.js.map +1 -1
  258. package/_esm/src/components/widgets/FeeBreakdown.js +24 -81
  259. package/_esm/src/components/widgets/FeeBreakdown.js.map +1 -1
  260. package/_esm/src/components/widgets/FetchingQuoteLoader.js +3 -9
  261. package/_esm/src/components/widgets/FetchingQuoteLoader.js.map +1 -1
  262. package/_esm/src/components/widgets/OnrampWidget/modals/OnrampModal.js +1 -8
  263. package/_esm/src/components/widgets/OnrampWidget/modals/OnrampModal.js.map +1 -1
  264. package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js +3 -20
  265. package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js.map +1 -1
  266. package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js +4 -28
  267. package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js.map +1 -1
  268. package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js +3 -33
  269. package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js.map +1 -1
  270. package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js +9 -45
  271. package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js.map +1 -1
  272. package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js +5 -26
  273. package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js.map +1 -1
  274. package/_esm/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js +7 -96
  275. package/_esm/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js.map +1 -1
  276. package/_esm/src/components/widgets/OnrampWidget/widget/index.js +18 -112
  277. package/_esm/src/components/widgets/OnrampWidget/widget/index.js.map +1 -1
  278. package/_esm/src/components/widgets/PriceImpactTooltip.js +4 -10
  279. package/_esm/src/components/widgets/PriceImpactTooltip.js.map +1 -1
  280. package/_esm/src/components/widgets/SwapButton.js +3 -14
  281. package/_esm/src/components/widgets/SwapButton.js.map +1 -1
  282. package/_esm/src/components/widgets/SwapWidget/GasTopUpSection.js +5 -10
  283. package/_esm/src/components/widgets/SwapWidget/GasTopUpSection.js.map +1 -1
  284. package/_esm/src/components/widgets/SwapWidget/PriceImpact.js +2 -4
  285. package/_esm/src/components/widgets/SwapWidget/PriceImpact.js.map +1 -1
  286. package/_esm/src/components/widgets/SwapWidget/index.js +35 -136
  287. package/_esm/src/components/widgets/SwapWidget/index.js.map +1 -1
  288. package/_esm/src/components/widgets/TokenSelectorContainer.js +3 -14
  289. package/_esm/src/components/widgets/TokenSelectorContainer.js.map +1 -1
  290. package/_esm/src/components/widgets/WidgetErrorWell.js +14 -80
  291. package/_esm/src/components/widgets/WidgetErrorWell.js.map +1 -1
  292. package/_esm/src/providers/RelayKitProvider.js +1 -0
  293. package/_esm/src/providers/RelayKitProvider.js.map +1 -1
  294. package/_esm/src/styles.css +3 -3717
  295. package/_esm/src/themes/RelayKitTheme.js.map +1 -1
  296. package/_esm/src/utils/cn.js +9 -0
  297. package/_esm/src/utils/cn.js.map +1 -0
  298. package/_esm/src/utils/theme.js +15 -1
  299. package/_esm/src/utils/theme.js.map +1 -1
  300. package/_esm/src/version.js +1 -1
  301. package/_esm/tsconfig.build.tsbuildinfo +1 -1
  302. package/_types/src/components/common/AmountInput.d.ts.map +1 -1
  303. package/_types/src/components/common/CopyToClipBoard.d.ts.map +1 -1
  304. package/_types/src/components/common/CustomAddressModal.d.ts.map +1 -1
  305. package/_types/src/components/common/ErrorWell.d.ts.map +1 -1
  306. package/_types/src/components/common/LoadingSpinner.d.ts +1 -2
  307. package/_types/src/components/common/LoadingSpinner.d.ts.map +1 -1
  308. package/_types/src/components/common/Modal.d.ts +3 -3
  309. package/_types/src/components/common/Modal.d.ts.map +1 -1
  310. package/_types/src/components/common/MultiWalletDropdown.d.ts.map +1 -1
  311. package/_types/src/components/common/PercentageButtons.d.ts +1 -1
  312. package/_types/src/components/common/PercentageButtons.d.ts.map +1 -1
  313. package/_types/src/components/common/SlippageToleranceConfig.d.ts +0 -1
  314. package/_types/src/components/common/SlippageToleranceConfig.d.ts.map +1 -1
  315. package/_types/src/components/common/StepIcon.d.ts.map +1 -1
  316. package/_types/src/components/common/TokenSelector/ChainFilter.d.ts.map +1 -1
  317. package/_types/src/components/common/TokenSelector/ChainFilterRow.d.ts.map +1 -1
  318. package/_types/src/components/common/TokenSelector/ChainFilterSidebar.d.ts.map +1 -1
  319. package/_types/src/components/common/TokenSelector/ChainShortcuts.d.ts.map +1 -1
  320. package/_types/src/components/common/TokenSelector/CompactChainFilter.d.ts.map +1 -1
  321. package/_types/src/components/common/TokenSelector/MobileChainSelector.d.ts.map +1 -1
  322. package/_types/src/components/common/TokenSelector/PaymentMethod.d.ts.map +1 -1
  323. package/_types/src/components/common/TokenSelector/PaymentTokenList.d.ts.map +1 -1
  324. package/_types/src/components/common/TokenSelector/SuggestedTokens.d.ts.map +1 -1
  325. package/_types/src/components/common/TokenSelector/TagPill.d.ts.map +1 -1
  326. package/_types/src/components/common/TokenSelector/TokenList.d.ts.map +1 -1
  327. package/_types/src/components/common/TokenSelector/TokenSelector.d.ts.map +1 -1
  328. package/_types/src/components/common/TokenSelector/triggers/PaymentMethodTrigger.d.ts.map +1 -1
  329. package/_types/src/components/common/TokenSelector/triggers/TokenTrigger.d.ts.map +1 -1
  330. package/_types/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.d.ts.map +1 -1
  331. package/_types/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.d.ts.map +1 -1
  332. package/_types/src/components/common/TransactionModal/steps/ErrorStep.d.ts.map +1 -1
  333. package/_types/src/components/common/TransactionModal/steps/SwapConfirmationStep.d.ts.map +1 -1
  334. package/_types/src/components/common/TransactionModal/steps/SwapSuccessStep.d.ts.map +1 -1
  335. package/_types/src/components/common/TransactionModal/steps/TransactionsByChain.d.ts.map +1 -1
  336. package/_types/src/components/common/TransactionModal/steps/WaitingForDepositStep.d.ts.map +1 -1
  337. package/_types/src/components/common/UnverifiedTokenModal.d.ts.map +1 -1
  338. package/_types/src/components/primitives/AccessibleList.d.ts +2 -3
  339. package/_types/src/components/primitives/AccessibleList.d.ts.map +1 -1
  340. package/_types/src/components/primitives/Anchor.d.ts +10 -39
  341. package/_types/src/components/primitives/Anchor.d.ts.map +1 -1
  342. package/_types/src/components/primitives/Box.d.ts +2 -5
  343. package/_types/src/components/primitives/Box.d.ts.map +1 -1
  344. package/_types/src/components/primitives/Button.d.ts +11 -8
  345. package/_types/src/components/primitives/Button.d.ts.map +1 -1
  346. package/_types/src/components/primitives/ChainIcon.d.ts +1 -2
  347. package/_types/src/components/primitives/ChainIcon.d.ts.map +1 -1
  348. package/_types/src/components/primitives/ChainTokenIcon.d.ts +1 -2
  349. package/_types/src/components/primitives/ChainTokenIcon.d.ts.map +1 -1
  350. package/_types/src/components/primitives/Collapsible.d.ts +3 -4
  351. package/_types/src/components/primitives/Collapsible.d.ts.map +1 -1
  352. package/_types/src/components/primitives/Dialog.d.ts +2 -3
  353. package/_types/src/components/primitives/Dialog.d.ts.map +1 -1
  354. package/_types/src/components/primitives/Dropdown.d.ts +2 -3
  355. package/_types/src/components/primitives/Dropdown.d.ts.map +1 -1
  356. package/_types/src/components/primitives/Flex.d.ts +10 -65
  357. package/_types/src/components/primitives/Flex.d.ts.map +1 -1
  358. package/_types/src/components/primitives/Input.d.ts +10 -8
  359. package/_types/src/components/primitives/Input.d.ts.map +1 -1
  360. package/_types/src/components/primitives/Pill.d.ts +9 -50
  361. package/_types/src/components/primitives/Pill.d.ts.map +1 -1
  362. package/_types/src/components/primitives/Skeleton.d.ts +1 -2
  363. package/_types/src/components/primitives/Skeleton.d.ts.map +1 -1
  364. package/_types/src/components/primitives/SlippageButton.d.ts.map +1 -1
  365. package/_types/src/components/primitives/Switch.d.ts +2 -3
  366. package/_types/src/components/primitives/Switch.d.ts.map +1 -1
  367. package/_types/src/components/primitives/Tabs.d.ts +4 -5
  368. package/_types/src/components/primitives/Tabs.d.ts.map +1 -1
  369. package/_types/src/components/primitives/Text.d.ts +10 -100
  370. package/_types/src/components/primitives/Text.d.ts.map +1 -1
  371. package/_types/src/components/primitives/Tooltip.d.ts.map +1 -1
  372. package/_types/src/components/widgets/FeeBreakdown.d.ts.map +1 -1
  373. package/_types/src/components/widgets/FetchingQuoteLoader.d.ts +1 -2
  374. package/_types/src/components/widgets/FetchingQuoteLoader.d.ts.map +1 -1
  375. package/_types/src/components/widgets/OnrampWidget/modals/OnrampModal.d.ts.map +1 -1
  376. package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.d.ts.map +1 -1
  377. package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.d.ts.map +1 -1
  378. package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.d.ts.map +1 -1
  379. package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.d.ts.map +1 -1
  380. package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.d.ts.map +1 -1
  381. package/_types/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.d.ts.map +1 -1
  382. package/_types/src/components/widgets/OnrampWidget/widget/index.d.ts.map +1 -1
  383. package/_types/src/components/widgets/PriceImpactTooltip.d.ts.map +1 -1
  384. package/_types/src/components/widgets/SwapButton.d.ts.map +1 -1
  385. package/_types/src/components/widgets/SwapWidget/GasTopUpSection.d.ts.map +1 -1
  386. package/_types/src/components/widgets/SwapWidget/PriceImpact.d.ts.map +1 -1
  387. package/_types/src/components/widgets/SwapWidget/index.d.ts.map +1 -1
  388. package/_types/src/components/widgets/TokenSelectorContainer.d.ts +1 -2
  389. package/_types/src/components/widgets/TokenSelectorContainer.d.ts.map +1 -1
  390. package/_types/src/components/widgets/WidgetErrorWell.d.ts +1 -2
  391. package/_types/src/components/widgets/WidgetErrorWell.d.ts.map +1 -1
  392. package/_types/src/providers/RelayKitProvider.d.ts.map +1 -1
  393. package/_types/src/themes/RelayKitTheme.d.ts +1 -0
  394. package/_types/src/themes/RelayKitTheme.d.ts.map +1 -1
  395. package/_types/src/utils/cn.d.ts +3 -0
  396. package/_types/src/utils/cn.d.ts.map +1 -0
  397. package/_types/src/utils/theme.d.ts.map +1 -1
  398. package/_types/src/version.d.ts +1 -1
  399. package/_types/tsconfig.build.tsbuildinfo +1 -1
  400. package/dist/styles.css +3 -3717
  401. package/package.json +20 -19
  402. package/_cjs/src/components/widgets/TokenWidget/AmountModeToggle.js +0 -31
  403. package/_cjs/src/components/widgets/TokenWidget/AmountModeToggle.js.map +0 -1
  404. package/_cjs/src/components/widgets/TokenWidget/AmountSectionHeader.js +0 -8
  405. package/_cjs/src/components/widgets/TokenWidget/AmountSectionHeader.js.map +0 -1
  406. package/_cjs/src/components/widgets/TokenWidget/BuyTabContent.js +0 -214
  407. package/_cjs/src/components/widgets/TokenWidget/BuyTabContent.js.map +0 -1
  408. package/_cjs/src/components/widgets/TokenWidget/DestinationWalletSelector.js +0 -20
  409. package/_cjs/src/components/widgets/TokenWidget/DestinationWalletSelector.js.map +0 -1
  410. package/_cjs/src/components/widgets/TokenWidget/FeeBreakdownInfo.js +0 -64
  411. package/_cjs/src/components/widgets/TokenWidget/FeeBreakdownInfo.js.map +0 -1
  412. package/_cjs/src/components/widgets/TokenWidget/FeeBreakdownTooltip.js +0 -44
  413. package/_cjs/src/components/widgets/TokenWidget/FeeBreakdownTooltip.js.map +0 -1
  414. package/_cjs/src/components/widgets/TokenWidget/SectionContainer.js +0 -25
  415. package/_cjs/src/components/widgets/TokenWidget/SectionContainer.js.map +0 -1
  416. package/_cjs/src/components/widgets/TokenWidget/SellTabContent.js +0 -261
  417. package/_cjs/src/components/widgets/TokenWidget/SellTabContent.js.map +0 -1
  418. package/_cjs/src/components/widgets/TokenWidget/TransactionDetailsFooter.js +0 -42
  419. package/_cjs/src/components/widgets/TokenWidget/TransactionDetailsFooter.js.map +0 -1
  420. package/_cjs/src/components/widgets/TokenWidget/hooks/useWalletGuards.js +0 -108
  421. package/_cjs/src/components/widgets/TokenWidget/hooks/useWalletGuards.js.map +0 -1
  422. package/_cjs/src/components/widgets/TokenWidget/index.js +0 -9
  423. package/_cjs/src/components/widgets/TokenWidget/index.js.map +0 -1
  424. package/_cjs/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.js +0 -719
  425. package/_cjs/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.js.map +0 -1
  426. package/_cjs/src/components/widgets/TokenWidget/widget/index.js +0 -1034
  427. package/_cjs/src/components/widgets/TokenWidget/widget/index.js.map +0 -1
  428. package/_esm/src/components/widgets/TokenWidget/AmountModeToggle.js +0 -30
  429. package/_esm/src/components/widgets/TokenWidget/AmountModeToggle.js.map +0 -1
  430. package/_esm/src/components/widgets/TokenWidget/AmountSectionHeader.js +0 -7
  431. package/_esm/src/components/widgets/TokenWidget/AmountSectionHeader.js.map +0 -1
  432. package/_esm/src/components/widgets/TokenWidget/BuyTabContent.js +0 -211
  433. package/_esm/src/components/widgets/TokenWidget/BuyTabContent.js.map +0 -1
  434. package/_esm/src/components/widgets/TokenWidget/DestinationWalletSelector.js +0 -16
  435. package/_esm/src/components/widgets/TokenWidget/DestinationWalletSelector.js.map +0 -1
  436. package/_esm/src/components/widgets/TokenWidget/FeeBreakdownInfo.js +0 -59
  437. package/_esm/src/components/widgets/TokenWidget/FeeBreakdownInfo.js.map +0 -1
  438. package/_esm/src/components/widgets/TokenWidget/FeeBreakdownTooltip.js +0 -43
  439. package/_esm/src/components/widgets/TokenWidget/FeeBreakdownTooltip.js.map +0 -1
  440. package/_esm/src/components/widgets/TokenWidget/SectionContainer.js +0 -25
  441. package/_esm/src/components/widgets/TokenWidget/SectionContainer.js.map +0 -1
  442. package/_esm/src/components/widgets/TokenWidget/SellTabContent.js +0 -264
  443. package/_esm/src/components/widgets/TokenWidget/SellTabContent.js.map +0 -1
  444. package/_esm/src/components/widgets/TokenWidget/TransactionDetailsFooter.js +0 -41
  445. package/_esm/src/components/widgets/TokenWidget/TransactionDetailsFooter.js.map +0 -1
  446. package/_esm/src/components/widgets/TokenWidget/hooks/useWalletGuards.js +0 -104
  447. package/_esm/src/components/widgets/TokenWidget/hooks/useWalletGuards.js.map +0 -1
  448. package/_esm/src/components/widgets/TokenWidget/index.js +0 -2
  449. package/_esm/src/components/widgets/TokenWidget/index.js.map +0 -1
  450. package/_esm/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.js +0 -742
  451. package/_esm/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.js.map +0 -1
  452. package/_esm/src/components/widgets/TokenWidget/widget/index.js +0 -1100
  453. package/_esm/src/components/widgets/TokenWidget/widget/index.js.map +0 -1
  454. package/_types/src/components/widgets/TokenWidget/AmountModeToggle.d.ts +0 -12
  455. package/_types/src/components/widgets/TokenWidget/AmountModeToggle.d.ts.map +0 -1
  456. package/_types/src/components/widgets/TokenWidget/AmountSectionHeader.d.ts +0 -11
  457. package/_types/src/components/widgets/TokenWidget/AmountSectionHeader.d.ts.map +0 -1
  458. package/_types/src/components/widgets/TokenWidget/BuyTabContent.d.ts +0 -53
  459. package/_types/src/components/widgets/TokenWidget/BuyTabContent.d.ts.map +0 -1
  460. package/_types/src/components/widgets/TokenWidget/DestinationWalletSelector.d.ts +0 -17
  461. package/_types/src/components/widgets/TokenWidget/DestinationWalletSelector.d.ts.map +0 -1
  462. package/_types/src/components/widgets/TokenWidget/FeeBreakdownInfo.d.ts +0 -16
  463. package/_types/src/components/widgets/TokenWidget/FeeBreakdownInfo.d.ts.map +0 -1
  464. package/_types/src/components/widgets/TokenWidget/FeeBreakdownTooltip.d.ts +0 -15
  465. package/_types/src/components/widgets/TokenWidget/FeeBreakdownTooltip.d.ts.map +0 -1
  466. package/_types/src/components/widgets/TokenWidget/SectionContainer.d.ts +0 -11
  467. package/_types/src/components/widgets/TokenWidget/SectionContainer.d.ts.map +0 -1
  468. package/_types/src/components/widgets/TokenWidget/SellTabContent.d.ts +0 -61
  469. package/_types/src/components/widgets/TokenWidget/SellTabContent.d.ts.map +0 -1
  470. package/_types/src/components/widgets/TokenWidget/TransactionDetailsFooter.d.ts +0 -14
  471. package/_types/src/components/widgets/TokenWidget/TransactionDetailsFooter.d.ts.map +0 -1
  472. package/_types/src/components/widgets/TokenWidget/hooks/useWalletGuards.d.ts +0 -28
  473. package/_types/src/components/widgets/TokenWidget/hooks/useWalletGuards.d.ts.map +0 -1
  474. package/_types/src/components/widgets/TokenWidget/index.d.ts +0 -3
  475. package/_types/src/components/widgets/TokenWidget/index.d.ts.map +0 -1
  476. package/_types/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.d.ts +0 -117
  477. package/_types/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.d.ts.map +0 -1
  478. package/_types/src/components/widgets/TokenWidget/widget/index.d.ts +0 -58
  479. package/_types/src/components/widgets/TokenWidget/widget/index.d.ts.map +0 -1
  480. package/dist/panda.buildinfo.json +0 -676
@@ -1,742 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
3
- import { useCurrencyBalance, useRelayClient, useDebounceState, useWalletAddress, useDisconnected, usePreviousValueChange, useIsWalletCompatible, useFallbackState, useDisplayName, useLighterAccount, useExplicitDeposit } from '../../../../hooks/index.js';
4
- import { formatUnits, parseUnits } from 'viem';
5
- import { useAccount, useWalletClient } from 'wagmi';
6
- import { useCapabilities } from 'wagmi/experimental';
7
- import { useQueryClient } from '@tanstack/react-query';
8
- import { calculatePriceTimeEstimate, calculateRelayerFeeProportionUsd, extractQuoteId, getCurrentStep, getSwapEventData, isHighRelayerServiceFeeUsd, parseFees } from '../../../../utils/quote.js';
9
- import { useQuote, useTokenPrice } from '@relayprotocol/relay-kit-hooks';
10
- import { EventNames } from '../../../../constants/events.js';
11
- import { ProviderOptionsContext } from '../../../../providers/RelayKitProvider.js';
12
- import { addressesEqual, addressWithFallback, isValidAddress, isChainVmTypeSupported, isWalletVmTypeCompatible } from '../../../../utils/address.js';
13
- import { adaptViemWallet } from '@relayprotocol/relay-sdk';
14
- import { errorToJSON } from '../../../../utils/errors.js';
15
- import { useSwapButtonCta } from '../../../../hooks/widget/useSwapButtonCta.js';
16
- import { sha256 } from '../../../../utils/hashing.js';
17
- import { get15MinuteInterval } from '../../../../utils/time.js';
18
- import { isLighterAddress } from '../../../../utils/lighter.js';
19
- // shared query options for useTokenPrice
20
- const tokenPriceQueryOptions = {
21
- staleTime: 60 * 1000, // 1 minute
22
- refetchInterval: 30 * 1000, // 30 seconds
23
- refetchOnWindowFocus: false
24
- };
25
- const TokenWidgetRenderer = ({ transactionModalOpen, setTransactionModalOpen, depositAddressModalOpen, fromToken: _fromToken, setFromToken: _setFromToken, toToken: _toToken, setToToken: _setToToken, defaultToAddress, defaultAmount, defaultTradeType, slippageTolerance, context, wallet, multiWalletSupportEnabled = false, linkedWallets, supportedWalletVMs, useSecureBaseUrl, children, onAnalyticEvent, onSwapError }) => {
26
- const [fromToken, setFromToken] = useFallbackState(_setFromToken ? _fromToken : undefined, _setFromToken
27
- ? [
28
- _fromToken,
29
- _setFromToken
30
- ]
31
- : undefined);
32
- const [toToken, setToToken] = useFallbackState(_setToToken ? _toToken : undefined, _setToToken
33
- ? [_toToken, _setToToken]
34
- : undefined);
35
- const providerOptionsContext = useContext(ProviderOptionsContext);
36
- const connectorKeyOverrides = providerOptionsContext.vmConnectorKeyOverrides;
37
- const relayClient = useRelayClient();
38
- const { connector } = useAccount();
39
- const walletClient = useWalletClient();
40
- const [customToAddress, setCustomToAddress] = useState(defaultToAddress);
41
- const [destinationAddressOverride, setDestinationAddressOverride] = useState(undefined);
42
- const [originAddressOverride, setOriginAddressOverride] = useState(undefined);
43
- const [allowUnsupportedOrigin, setAllowUnsupportedOrigin] = useState(false);
44
- const [allowUnsupportedRecipient, setAllowUnsupportedRecipient] = useState(false);
45
- const defaultAddress = useWalletAddress(wallet, linkedWallets);
46
- const [tradeType, setTradeType] = useState(defaultTradeType ?? 'EXACT_INPUT');
47
- const queryClient = useQueryClient();
48
- const [steps, setSteps] = useState(null);
49
- const [quoteInProgress, setQuoteInProgress] = useState(null);
50
- const [waitingForSteps, setWaitingForSteps] = useState(false);
51
- const [details, setDetails] = useState(null);
52
- const [abortController, setAbortController] = useState(null);
53
- const { value: amountInputValue, debouncedValue: debouncedInputAmountValue, setValue: setAmountInputValue, debouncedControls: debouncedAmountInputControls } = useDebounceState(!defaultTradeType || defaultTradeType === 'EXACT_INPUT'
54
- ? (defaultAmount ?? '')
55
- : '', 500);
56
- const { value: amountOutputValue, debouncedValue: debouncedOutputAmountValue, setValue: setAmountOutputValue, debouncedControls: debouncedAmountOutputControls } = useDebounceState(defaultTradeType === 'EXPECTED_OUTPUT' ? (defaultAmount ?? '') : '', 500);
57
- const [swapError, setSwapError] = useState(null);
58
- const toChain = useMemo(() => relayClient?.chains?.find((chain) => chain.id === toToken?.chainId), [relayClient?.chains, toToken?.chainId]);
59
- const fromChain = useMemo(() => relayClient?.chains?.find((chain) => chain.id === fromToken?.chainId), [relayClient?.chains, fromToken?.chainId]);
60
- const fromChainWalletVMSupported = useMemo(() => isChainVmTypeSupported(fromChain?.vmType, supportedWalletVMs) ||
61
- fromChain?.id === 1337, [fromChain?.vmType, fromChain?.id, supportedWalletVMs]);
62
- const toChainWalletVMSupported = useMemo(() => isChainVmTypeSupported(toChain?.vmType, supportedWalletVMs), [toChain?.vmType, supportedWalletVMs]);
63
- // Automatically select the correct wallet address based on fromToken's chain VM
64
- // In sell mode (no fromChain), use toChain to find compatible wallet
65
- const address = useMemo(() => {
66
- if (!multiWalletSupportEnabled || !linkedWallets?.length) {
67
- return defaultAddress;
68
- }
69
- if (originAddressOverride) {
70
- return originAddressOverride;
71
- }
72
- const targetChain = fromChain || toChain;
73
- if (!targetChain) {
74
- return defaultAddress;
75
- }
76
- const isCompatibleWallet = (wallet) => isWalletVmTypeCompatible(wallet.vmType, targetChain.vmType) &&
77
- isValidAddress(targetChain.vmType, wallet.address, targetChain.id, wallet.connector, connectorKeyOverrides);
78
- const activeLinkedWallet = linkedWallets.find((wallet) => addressesEqual(wallet.vmType, wallet.address, defaultAddress));
79
- if (activeLinkedWallet && isCompatibleWallet(activeLinkedWallet)) {
80
- return activeLinkedWallet.address;
81
- }
82
- const compatibleWallet = linkedWallets.find(isCompatibleWallet);
83
- return compatibleWallet?.address || defaultAddress;
84
- }, [
85
- multiWalletSupportEnabled,
86
- originAddressOverride,
87
- fromChain,
88
- toChain,
89
- linkedWallets,
90
- defaultAddress,
91
- connectorKeyOverrides
92
- ]);
93
- const defaultRecipient = useMemo(() => {
94
- const _linkedWallet = linkedWallets?.find((linkedWallet) => address ===
95
- (linkedWallet.vmType === 'evm'
96
- ? linkedWallet.address.toLowerCase()
97
- : linkedWallet.address));
98
- const _isValidToAddress = isValidAddress(toChain?.vmType, customToAddress ?? '', toChain?.id, !customToAddress && _linkedWallet?.address === address
99
- ? _linkedWallet?.connector
100
- : undefined, connectorKeyOverrides);
101
- if (multiWalletSupportEnabled &&
102
- toChain &&
103
- linkedWallets &&
104
- !_isValidToAddress) {
105
- // Find a compatible wallet, excluding the origin wallet
106
- const supportedWallet = linkedWallets.find((wallet) => wallet.address !== address &&
107
- isValidAddress(toChain.vmType, wallet.address, toChain.id, wallet.connector, connectorKeyOverrides));
108
- return supportedWallet?.address;
109
- }
110
- return undefined;
111
- }, [
112
- multiWalletSupportEnabled,
113
- toChain,
114
- customToAddress,
115
- address,
116
- linkedWallets,
117
- setCustomToAddress,
118
- connectorKeyOverrides
119
- ]);
120
- const recipient = destinationAddressOverride ??
121
- customToAddress ??
122
- defaultRecipient ??
123
- (!allowUnsupportedRecipient && address ? address : undefined);
124
- const { value: fromBalance, queryKey: fromBalanceQueryKey, isLoading: isLoadingFromBalance, isError: fromBalanceErrorFetching, isDuneBalance: fromBalanceIsDune, hasPendingBalance: fromBalancePending } = useCurrencyBalance({
125
- chain: fromChain,
126
- address: address,
127
- currency: fromToken?.address ? fromToken.address : undefined,
128
- enabled: fromToken !== undefined,
129
- refreshInterval: undefined,
130
- wallet
131
- });
132
- const { value: toBalance, queryKey: toBalanceQueryKey, isLoading: isLoadingToBalance, isDuneBalance: toBalanceIsDune, hasPendingBalance: toBalancePending } = useCurrencyBalance({
133
- chain: toChain,
134
- address: recipient,
135
- currency: toToken?.address ? toToken.address : undefined,
136
- enabled: toToken !== undefined && recipient !== undefined && recipient !== '',
137
- refreshInterval: undefined,
138
- wallet
139
- });
140
- const invalidateBalanceQueries = useCallback(() => {
141
- const invalidatePeriodically = (invalidateFn) => {
142
- let maxRefreshes = 4;
143
- let refreshCount = 0;
144
- const timer = setInterval(() => {
145
- if (maxRefreshes === refreshCount) {
146
- clearInterval(timer);
147
- return;
148
- }
149
- refreshCount++;
150
- invalidateFn();
151
- }, 3000);
152
- };
153
- queryClient.invalidateQueries({ queryKey: ['useDuneBalances'] });
154
- // Dune balances are sometimes stale, because of this we need to aggressively fetch them
155
- // for a predetermined period to make sure we get back a fresh response
156
- if (fromBalanceIsDune) {
157
- invalidatePeriodically(() => {
158
- queryClient.invalidateQueries({ queryKey: fromBalanceQueryKey });
159
- });
160
- }
161
- else {
162
- queryClient.invalidateQueries({ queryKey: fromBalanceQueryKey });
163
- }
164
- if (toBalanceIsDune) {
165
- invalidatePeriodically(() => {
166
- queryClient.invalidateQueries({ queryKey: toBalanceQueryKey });
167
- });
168
- }
169
- else {
170
- queryClient.invalidateQueries({ queryKey: toBalanceQueryKey });
171
- }
172
- }, [
173
- queryClient,
174
- fromBalanceQueryKey,
175
- toBalanceQueryKey,
176
- toBalanceIsDune,
177
- fromBalanceIsDune,
178
- address
179
- ]);
180
- const { data: capabilities } = useCapabilities({
181
- query: {
182
- enabled: connector &&
183
- (connector.id === 'coinbaseWalletSDK' || connector.id === 'coinbase')
184
- }
185
- });
186
- const hasAuxiliaryFundsSupport = Boolean(fromToken?.chainId
187
- ? capabilities?.[fromToken?.chainId]?.auxiliaryFunds?.supported
188
- : false);
189
- const isSvmSwap = fromChain?.vmType === 'svm' || toChain?.vmType === 'svm';
190
- const isBvmSwap = fromChain?.vmType === 'bvm' || toChain?.vmType === 'bvm';
191
- const linkedWallet = linkedWallets?.find((linkedWallet) => address ===
192
- (linkedWallet.vmType === 'evm'
193
- ? linkedWallet.address.toLowerCase()
194
- : linkedWallet.address) || linkedWallet.address === address);
195
- const isRecipientLinked = (recipient
196
- ? linkedWallets?.find((wallet) => wallet.address === recipient)
197
- : undefined) !== undefined;
198
- const isValidFromAddress = useMemo(() => isValidAddress(fromChain?.vmType, address ?? '', fromChain?.id, linkedWallet?.connector, connectorKeyOverrides), [
199
- fromChain?.vmType,
200
- address,
201
- fromChain?.id,
202
- linkedWallet?.connector,
203
- connectorKeyOverrides
204
- ]);
205
- const fromAddressWithFallback = addressWithFallback(fromChain?.vmType, address, fromChain?.id, linkedWallet?.connector, connectorKeyOverrides);
206
- const isValidToAddress = useMemo(() => isValidAddress(toChain?.vmType, recipient ?? '', toChain?.id), [toChain?.vmType, recipient, toChain?.id]);
207
- const toAddressWithFallback = addressWithFallback(toChain?.vmType, recipient, toChain?.id);
208
- const { displayName: toDisplayName } = useDisplayName(recipient, toChain?.vmType, toChain?.id);
209
- const [currentSlippageTolerance, setCurrentSlippageTolerance] = useState(slippageTolerance);
210
- useEffect(() => {
211
- setCurrentSlippageTolerance(slippageTolerance);
212
- }, [slippageTolerance]);
213
- // Retrieve the price of the `from` token
214
- const { data: fromTokenPriceData, isLoading: isLoadingFromTokenPrice } = useTokenPrice(relayClient?.baseApiUrl, {
215
- address: fromToken?.address ?? '',
216
- chainId: fromToken?.chainId ?? 0,
217
- referrer: relayClient?.source
218
- }, {
219
- enabled: !!(fromToken?.address && fromToken.chainId),
220
- ...tokenPriceQueryOptions
221
- });
222
- // Retrieve the price of the `to` token
223
- const { data: toTokenPriceData, isLoading: isLoadingToTokenPrice } = useTokenPrice(relayClient?.baseApiUrl, {
224
- address: toToken?.address ?? '',
225
- chainId: toToken?.chainId ?? 0,
226
- referrer: relayClient?.source
227
- }, {
228
- enabled: !!(toToken?.address && toToken.chainId),
229
- ...tokenPriceQueryOptions
230
- });
231
- const isFromNative = fromToken?.address === fromChain?.currency?.address;
232
- const explicitDeposit = useExplicitDeposit(wallet, fromToken?.chainId, fromChain?.vmType, address);
233
- const shouldSetQuoteParameters = fromToken && toToken;
234
- const quoteParameters = shouldSetQuoteParameters
235
- ? {
236
- user: fromAddressWithFallback,
237
- originChainId: fromToken.chainId,
238
- destinationChainId: toToken.chainId,
239
- originCurrency: fromToken.address,
240
- destinationCurrency: toToken.address,
241
- recipient: toAddressWithFallback,
242
- tradeType,
243
- appFees: providerOptionsContext.appFees,
244
- amount: tradeType === 'EXACT_INPUT'
245
- ? parseUnits(debouncedInputAmountValue, fromToken.decimals).toString()
246
- : parseUnits(debouncedOutputAmountValue, toToken.decimals).toString(),
247
- referrer: relayClient?.source ?? undefined,
248
- useDepositAddress: !fromChainWalletVMSupported || fromToken?.chainId === 1337,
249
- refundTo: fromToken?.chainId === 1337 ? address : undefined,
250
- slippageTolerance: slippageTolerance,
251
- ...(linkedWallet?.vmType === 'bvm' && wallet?.metadata?.publicKey
252
- ? {
253
- additionalData: {
254
- userPublicKey: wallet?.metadata?.publicKey
255
- }
256
- }
257
- : {}),
258
- ...(explicitDeposit !== undefined &&
259
- fromChain?.vmType === 'evm' && {
260
- explicitDeposit: explicitDeposit
261
- })
262
- }
263
- : undefined;
264
- const onQuoteRequested = (options, config) => {
265
- const interval = get15MinuteInterval();
266
- const quoteRequestId = sha256({ ...options, interval });
267
- onAnalyticEvent?.(EventNames.QUOTE_REQUESTED, {
268
- parameters: options,
269
- wallet_connector: linkedWallet?.connector,
270
- chain_id_in: options?.originChainId,
271
- chain_id_out: options?.destinationChainId,
272
- http_config: config,
273
- quote_request_id: quoteRequestId
274
- });
275
- };
276
- const onQuoteReceived = ({ details, steps }, options) => {
277
- const interval = get15MinuteInterval();
278
- const quoteRequestId = sha256({ ...options, interval });
279
- onAnalyticEvent?.(EventNames.QUOTE_RECEIVED, {
280
- parameters: options,
281
- wallet_connector: linkedWallet?.connector,
282
- amount_in: details?.currencyIn?.amountFormatted,
283
- amount_in_raw: details?.currencyIn?.amount,
284
- currency_in: details?.currencyIn?.currency?.symbol,
285
- chain_id_in: details?.currencyIn?.currency?.chainId,
286
- amount_out: details?.currencyOut?.amountFormatted,
287
- amount_out_raw: details?.currencyOut?.amount,
288
- currency_out: details?.currencyOut?.currency?.symbol,
289
- chain_id_out: details?.currencyOut?.currency?.chainId,
290
- slippage_tolerance_destination_percentage: details?.slippageTolerance?.destination?.percent,
291
- slippage_tolerance_origin_percentage: details?.slippageTolerance?.origin?.percent,
292
- steps,
293
- quote_request_id: quoteRequestId,
294
- quote_id: steps ? extractQuoteId(steps) : undefined
295
- });
296
- };
297
- const quoteFetchingEnabled = Boolean(relayClient &&
298
- ((tradeType === 'EXACT_INPUT' &&
299
- debouncedInputAmountValue &&
300
- debouncedInputAmountValue.length > 0 &&
301
- Number(debouncedInputAmountValue) !== 0) ||
302
- (tradeType === 'EXPECTED_OUTPUT' &&
303
- debouncedOutputAmountValue &&
304
- debouncedOutputAmountValue.length > 0 &&
305
- Number(debouncedOutputAmountValue) !== 0)) &&
306
- fromToken !== undefined &&
307
- toToken !== undefined &&
308
- !transactionModalOpen &&
309
- !depositAddressModalOpen);
310
- const quoteRefetchInterval = !transactionModalOpen &&
311
- !depositAddressModalOpen &&
312
- debouncedInputAmountValue === amountInputValue &&
313
- debouncedOutputAmountValue === amountOutputValue
314
- ? 12000
315
- : undefined;
316
- const handleQuoteError = (e) => {
317
- const errorMessage = errorToJSON(e?.response?.data?.message ? new Error(e?.response?.data?.message) : e);
318
- const interval = get15MinuteInterval();
319
- const quoteRequestId = sha256({ ...quoteParameters, interval });
320
- onAnalyticEvent?.(EventNames.QUOTE_ERROR, {
321
- wallet_connector: linkedWallet?.connector,
322
- error_message: errorMessage,
323
- parameters: quoteParameters,
324
- quote_request_id: quoteRequestId,
325
- status_code: e?.response?.status ?? e?.status ?? ''
326
- });
327
- };
328
- const { data: quote, error: quoteError, isFetching: isFetchingQuote, executeQuote: executeSwap, queryKey: quoteQueryKey } = useQuote(relayClient ? relayClient : undefined, wallet, quoteParameters, onQuoteRequested, onQuoteReceived, {
329
- refetchOnWindowFocus: false,
330
- enabled: Boolean(quoteFetchingEnabled && quoteParameters !== undefined),
331
- refetchInterval: quoteRefetchInterval
332
- }, handleQuoteError, undefined, useSecureBaseUrl?.(quoteParameters)
333
- ? providerOptionsContext?.secureBaseUrl
334
- : undefined);
335
- const invalidateQuoteQuery = useCallback(() => {
336
- queryClient.invalidateQueries({ queryKey: quoteQueryKey });
337
- }, [queryClient, quoteQueryKey]);
338
- const derivedError = quote ||
339
- (isFetchingQuote &&
340
- Boolean(quoteFetchingEnabled && quoteParameters !== undefined))
341
- ? null
342
- : quoteError;
343
- const error = derivedError;
344
- useDisconnected(address, () => {
345
- setCustomToAddress(undefined);
346
- setOriginAddressOverride(undefined);
347
- setDestinationAddressOverride(undefined);
348
- });
349
- // Auto-select Lighter account when switching to LVM chain
350
- const isLighterChain = toChain?.vmType === 'lvm';
351
- const { data: connectedLighterAccount } = useLighterAccount(isLighterChain && address ? address : undefined);
352
- useEffect(() => {
353
- if (isLighterChain &&
354
- connectedLighterAccount?.index &&
355
- // Only auto-set if no valid Lighter address is already set
356
- (!customToAddress || !isLighterAddress(customToAddress))) {
357
- setCustomToAddress(connectedLighterAccount.index.toString());
358
- }
359
- }, [isLighterChain, connectedLighterAccount, customToAddress]);
360
- useEffect(() => {
361
- if (tradeType === 'EXACT_INPUT') {
362
- const amountOut = quote?.details?.currencyOut?.amount ?? '';
363
- setAmountOutputValue(amountOut !== ''
364
- ? formatUnits(BigInt(amountOut), Number(quote?.details?.currencyOut?.currency?.decimals ?? 18))
365
- : '');
366
- }
367
- else if (tradeType === 'EXPECTED_OUTPUT') {
368
- const amountIn = quote?.details?.currencyIn?.amount ?? '';
369
- setAmountInputValue(amountIn !== ''
370
- ? formatUnits(BigInt(amountIn), Number(quote?.details?.currencyIn?.currency?.decimals ?? 18))
371
- : '');
372
- }
373
- debouncedAmountInputControls.flush();
374
- debouncedAmountOutputControls.flush();
375
- }, [quote, tradeType]);
376
- const feeBreakdown = useMemo(() => {
377
- const chains = relayClient?.chains;
378
- const fromChain = chains?.find((chain) => chain.id === fromToken?.chainId);
379
- const toChain = chains?.find((chain) => chain.id === toToken?.chainId);
380
- return fromToken && toToken && fromChain && toChain && quote
381
- ? parseFees(toChain, fromChain, quote)
382
- : null;
383
- }, [quote, fromToken, toToken, relayClient]);
384
- const totalAmount = BigInt(quote?.details?.currencyIn?.amount ?? 0n);
385
- const hasInsufficientBalance = Boolean(!fromBalanceErrorFetching &&
386
- totalAmount &&
387
- address &&
388
- (fromBalance ?? 0n) < totalAmount &&
389
- !hasAuxiliaryFundsSupport &&
390
- fromChainWalletVMSupported);
391
- const fetchQuoteErrorMessage = error
392
- ? error?.message
393
- ? error?.message
394
- : 'Unknown Error'
395
- : null;
396
- const fetchQuoteDataErrorMessage = error
397
- ? error?.response?.data?.message
398
- ? error?.response?.data.message
399
- : 'Unknown Error'
400
- : null;
401
- const isInsufficientLiquidityError = Boolean(fetchQuoteErrorMessage?.includes('No quotes available'));
402
- const isCapacityExceededError = fetchQuoteDataErrorMessage?.includes('Amount is higher than the available liquidity') || fetchQuoteDataErrorMessage?.includes('Insufficient relayer liquidity');
403
- const isCouldNotExecuteError = fetchQuoteDataErrorMessage?.includes('Could not execute');
404
- const highRelayerServiceFee = isHighRelayerServiceFeeUsd(quote);
405
- const relayerFeeProportion = calculateRelayerFeeProportionUsd(quote);
406
- const timeEstimate = calculatePriceTimeEstimate(quote?.details);
407
- const recipientWalletSupportsChain = useIsWalletCompatible(toChain?.id, recipient, linkedWallets, onAnalyticEvent);
408
- const isSameCurrencySameRecipientSwap = fromToken?.address === toToken?.address &&
409
- fromToken?.chainId === toToken?.chainId &&
410
- address === recipient;
411
- const ctaCopy = useSwapButtonCta({
412
- fromToken,
413
- toToken,
414
- multiWalletSupportEnabled,
415
- isValidFromAddress,
416
- fromChainWalletVMSupported,
417
- isValidToAddress,
418
- toChainWalletVMSupported,
419
- fromChain,
420
- toChain,
421
- isSameCurrencySameRecipientSwap,
422
- debouncedInputAmountValue,
423
- debouncedOutputAmountValue,
424
- hasInsufficientBalance,
425
- isInsufficientLiquidityError,
426
- quote,
427
- operation: quote?.details?.operation
428
- });
429
- usePreviousValueChange(isCapacityExceededError, !isFetchingQuote, (capacityExceeded) => {
430
- if (capacityExceeded) {
431
- onAnalyticEvent?.(EventNames.CTA_MAX_CAPACITY_PROMPTED, {
432
- inputAmount: debouncedInputAmountValue,
433
- outputAmount: debouncedOutputAmountValue
434
- });
435
- }
436
- });
437
- const swap = useCallback(async () => {
438
- let submittedEvents = [];
439
- const swapErrorHandler = (error, currentSteps) => {
440
- const errorMessage = errorToJSON(error?.response?.data?.message
441
- ? new Error(error?.response?.data?.message)
442
- : error);
443
- if (error &&
444
- ((typeof error.message === 'string' &&
445
- error.message.includes('rejected')) ||
446
- (typeof error === 'string' && error.includes('rejected')) ||
447
- (typeof error === 'string' && error.includes('Approval Denied')) ||
448
- (typeof error === 'string' && error.includes('denied transaction')) ||
449
- (typeof error.message === 'string' &&
450
- error.message.includes('Approval Denied')) ||
451
- (typeof error.message === 'string' &&
452
- error.message.includes('Plugin Closed')) ||
453
- (typeof error.message === 'string' &&
454
- error.message.includes('denied transaction')) ||
455
- (typeof error.message === 'string' &&
456
- error.message.includes('Failed to initialize request') &&
457
- fromChain?.id === 2741)) // Abstract @TODO: remove once privy improves handling rejected transactions
458
- ) {
459
- // Close the transaction modal if the user rejects the tx
460
- setTransactionModalOpen(false);
461
- onAnalyticEvent?.(EventNames.USER_REJECTED_WALLET, {
462
- error_message: errorMessage
463
- });
464
- return;
465
- }
466
- const { step, stepItem } = getCurrentStep(currentSteps);
467
- const swapEventData = {
468
- ...getSwapEventData(quote?.details, quote?.fees, currentSteps ?? null, linkedWallet?.connector, quoteParameters),
469
- error_message: errorMessage
470
- };
471
- const isApproval = step?.id === 'approve';
472
- const errorEvent = isApproval
473
- ? EventNames.APPROVAL_ERROR
474
- : EventNames.DEPOSIT_ERROR;
475
- //Filter out receipt/deposit transaction errors, those are approval/deposit errors
476
- const isTransactionConfirmationError = (error &&
477
- typeof error.message === 'string' &&
478
- error.message.includes('TransactionConfirmationError')) ||
479
- (error.name && error.name.includes('TransactionConfirmationError'));
480
- if (stepItem?.receipt &&
481
- stepItem.check &&
482
- !isTransactionConfirmationError &&
483
- (typeof stepItem.receipt === 'object' && 'status' in stepItem.receipt
484
- ? stepItem.receipt.status !== 'reverted'
485
- : true) &&
486
- (!stepItem.checkStatus || stepItem.checkStatus !== 'unknown')) {
487
- //In some cases there's a race condition where an error is thrown before the steps get a chance to call
488
- //the callback which triggers the success event. This is a workaround to ensure the success event is triggered when
489
- //we have a receipt and require a fill check if we haven't already send the success event.
490
- const successEvent = isApproval
491
- ? EventNames.APPROVAL_SUCCESS
492
- : EventNames.DEPOSIT_SUCCESS;
493
- if (!submittedEvents.includes(successEvent)) {
494
- onAnalyticEvent?.(successEvent, swapEventData);
495
- submittedEvents.push(successEvent);
496
- //To preserve the order of events we need to delay sending the fill error event but mark that we did send it to avoid duplicates
497
- setTimeout(() => {
498
- onAnalyticEvent?.(EventNames.FILL_ERROR, swapEventData);
499
- }, 20);
500
- }
501
- else {
502
- onAnalyticEvent?.(EventNames.FILL_ERROR, swapEventData);
503
- }
504
- }
505
- else if (!stepItem?.receipt ||
506
- (typeof stepItem.receipt === 'object' &&
507
- 'status' in stepItem.receipt &&
508
- stepItem.receipt.status === 'reverted')) {
509
- onAnalyticEvent?.(errorEvent, swapEventData);
510
- }
511
- else {
512
- onAnalyticEvent?.(EventNames.SWAP_ERROR, swapEventData);
513
- }
514
- setSwapError(errorMessage);
515
- onSwapError?.(errorMessage, { ...quote, steps: currentSteps });
516
- };
517
- try {
518
- const swapEventData = getSwapEventData(quote?.details, quote?.fees, quote?.steps ? quote?.steps : null, linkedWallet?.connector, quoteParameters);
519
- onAnalyticEvent?.(EventNames.SWAP_CTA_CLICKED, swapEventData);
520
- setWaitingForSteps(true);
521
- if (!executeSwap) {
522
- throw new Error('Missing a quote');
523
- }
524
- if (!wallet && !walletClient.data) {
525
- throw new Error('Missing a wallet');
526
- }
527
- setSteps(quote?.steps);
528
- setQuoteInProgress(quote);
529
- setTransactionModalOpen(true);
530
- const _wallet = wallet ?? adaptViemWallet(walletClient.data);
531
- const activeWalletChainId = await _wallet?.getChainId();
532
- const activeWalletChain = relayClient?.chains?.find((chain) => chain.id === activeWalletChainId);
533
- let targetChainId = fromToken?.chainId;
534
- //Special case for Hyperliquid, to sign txs on an evm chain
535
- if (fromToken?.chainId === 1337) {
536
- targetChainId =
537
- activeWalletChain?.vmType !== 'evm' ? 1 : activeWalletChainId;
538
- }
539
- if (fromToken && targetChainId && targetChainId !== activeWalletChainId) {
540
- onAnalyticEvent?.(EventNames.SWAP_SWITCH_NETWORK, {
541
- activeWalletChainId,
542
- ...swapEventData
543
- });
544
- await _wallet?.switchChain(targetChainId);
545
- }
546
- let _currentSteps = undefined;
547
- const execPromise = executeSwap(({ steps: currentSteps }) => {
548
- setSteps(currentSteps);
549
- _currentSteps = currentSteps;
550
- const { step, stepItem } = getCurrentStep(currentSteps);
551
- const swapEventData = getSwapEventData(quote?.details, quote?.fees, currentSteps, linkedWallet?.connector, quoteParameters);
552
- if (step && stepItem) {
553
- //@ts-ignore
554
- const isApproval = step.id === 'approve' || step.id === 'approval';
555
- let submittedEvent = isApproval
556
- ? EventNames.APPROVAL_SUBMITTED
557
- : EventNames.DEPOSIT_SUBMITTED;
558
- const successEvent = isApproval
559
- ? EventNames.APPROVAL_SUCCESS
560
- : EventNames.DEPOSIT_SUCCESS;
561
- const isBatchTransaction = Boolean(Array.isArray(step.items) &&
562
- step.items.length > 1 &&
563
- wallet?.handleBatchTransactionStep);
564
- if (!isApproval && isBatchTransaction) {
565
- submittedEvent = EventNames.BATCH_TX_SUBMITTED;
566
- }
567
- if (!submittedEvents.includes(submittedEvent) &&
568
- !stepItem.receipt &&
569
- stepItem?.txHashes &&
570
- stepItem?.txHashes?.length > 0) {
571
- submittedEvents.push(submittedEvent);
572
- onAnalyticEvent?.(submittedEvent, swapEventData);
573
- }
574
- else if (!submittedEvents.includes(successEvent) &&
575
- ((stepItem.receipt &&
576
- !(typeof stepItem.receipt === 'object' &&
577
- 'status' in stepItem.receipt &&
578
- stepItem.receipt.status === 'reverted')) ||
579
- stepItem.checkStatus === 'pending')) {
580
- onAnalyticEvent?.(successEvent, swapEventData);
581
- submittedEvents.push(successEvent);
582
- }
583
- if (stepItem.status === 'complete' &&
584
- stepItem.check &&
585
- !submittedEvents.includes(EventNames.FILL_SUCCESS)) {
586
- //Sometimes a fill may be quicker than the tx receipt is available, so we need to handle this scenario
587
- if (!submittedEvents.includes(EventNames.DEPOSIT_SUCCESS) &&
588
- !isBatchTransaction) {
589
- onAnalyticEvent?.(EventNames.DEPOSIT_SUCCESS, swapEventData);
590
- submittedEvents.push(EventNames.DEPOSIT_SUCCESS);
591
- //To preserve the order of events we need to delay sending the fill success event but mark that we did send it to avoid duplicates
592
- setTimeout(() => {
593
- onAnalyticEvent?.(EventNames.FILL_SUCCESS, swapEventData);
594
- }, 20);
595
- }
596
- else {
597
- onAnalyticEvent?.(EventNames.FILL_SUCCESS, swapEventData);
598
- }
599
- submittedEvents.push(EventNames.FILL_SUCCESS);
600
- }
601
- }
602
- else if (currentSteps?.every((step) => step.items?.every((item) => item.status === 'complete')) &&
603
- !submittedEvents.includes(EventNames.FILL_SUCCESS)) {
604
- //Sometimes a fill may be quicker than the tx receipt is available, so we need to handle this scenario
605
- if (!submittedEvents.includes(EventNames.DEPOSIT_SUCCESS) &&
606
- !submittedEvents.includes(EventNames.BATCH_TX_SUBMITTED)) {
607
- onAnalyticEvent?.(EventNames.DEPOSIT_SUCCESS, swapEventData);
608
- submittedEvents.push(EventNames.DEPOSIT_SUCCESS);
609
- //To preserve the order of events we need to delay sending the fill success event but mark that we did send it to avoid duplicates
610
- setTimeout(() => {
611
- onAnalyticEvent?.(EventNames.FILL_SUCCESS, swapEventData);
612
- }, 20);
613
- }
614
- else {
615
- onAnalyticEvent?.(EventNames.FILL_SUCCESS, swapEventData);
616
- }
617
- submittedEvents.push(EventNames.FILL_SUCCESS);
618
- }
619
- });
620
- // Store the AbortController for potential cancellation immediately
621
- if (execPromise &&
622
- typeof execPromise === 'object' &&
623
- 'abortController' in execPromise) {
624
- setAbortController(execPromise.abortController);
625
- }
626
- execPromise
627
- ?.catch((error) => {
628
- swapErrorHandler(error, _currentSteps);
629
- })
630
- .finally(() => {
631
- setWaitingForSteps(false);
632
- setAbortController(null);
633
- invalidateBalanceQueries();
634
- });
635
- }
636
- catch (error) {
637
- swapErrorHandler(error);
638
- setWaitingForSteps(false);
639
- }
640
- // eslint-disable-next-line react-hooks/exhaustive-deps
641
- }, [
642
- relayClient,
643
- address,
644
- connector,
645
- wallet,
646
- walletClient,
647
- fromToken,
648
- toToken,
649
- customToAddress,
650
- recipient,
651
- debouncedInputAmountValue,
652
- debouncedOutputAmountValue,
653
- tradeType,
654
- waitingForSteps,
655
- executeSwap,
656
- setSteps,
657
- setQuoteInProgress,
658
- invalidateBalanceQueries,
659
- linkedWallet,
660
- abortController
661
- ]);
662
- return (_jsx(_Fragment, { children: children({
663
- quote,
664
- steps,
665
- setSteps,
666
- swap,
667
- transactionModalOpen,
668
- feeBreakdown,
669
- fromToken,
670
- setFromToken,
671
- toToken,
672
- setToToken,
673
- swapError,
674
- error,
675
- toDisplayName,
676
- address,
677
- originAddressOverride,
678
- setOriginAddressOverride,
679
- recipient,
680
- destinationAddressOverride,
681
- customToAddress,
682
- setCustomToAddress,
683
- setDestinationAddressOverride,
684
- tradeType,
685
- setTradeType,
686
- details,
687
- isSameCurrencySameRecipientSwap,
688
- allowUnsupportedOrigin,
689
- setAllowUnsupportedOrigin,
690
- allowUnsupportedRecipient,
691
- setAllowUnsupportedRecipient,
692
- debouncedInputAmountValue,
693
- debouncedAmountInputControls,
694
- setAmountInputValue,
695
- amountInputValue,
696
- amountOutputValue,
697
- debouncedOutputAmountValue,
698
- debouncedAmountOutputControls,
699
- setAmountOutputValue,
700
- toBalance,
701
- toBalancePending,
702
- isLoadingToBalance,
703
- isFetchingQuote,
704
- isLoadingFromBalance,
705
- fromBalance,
706
- fromBalancePending,
707
- highRelayerServiceFee,
708
- relayerFeeProportion,
709
- hasInsufficientBalance,
710
- isInsufficientLiquidityError,
711
- isCapacityExceededError,
712
- isCouldNotExecuteError,
713
- ctaCopy,
714
- isFromNative,
715
- slippageTolerance: currentSlippageTolerance,
716
- timeEstimate,
717
- isSvmSwap,
718
- isBvmSwap,
719
- isValidFromAddress,
720
- isValidToAddress,
721
- supportedWalletVMs,
722
- fromChainWalletVMSupported,
723
- toChainWalletVMSupported,
724
- isRecipientLinked,
725
- recipientWalletSupportsChain,
726
- invalidateBalanceQueries,
727
- invalidateQuoteQuery,
728
- setDetails,
729
- setSwapError,
730
- quoteInProgress,
731
- setQuoteInProgress,
732
- linkedWallet,
733
- quoteParameters,
734
- abortController,
735
- fromTokenPriceData,
736
- toTokenPriceData,
737
- isLoadingFromTokenPrice,
738
- isLoadingToTokenPrice
739
- }) }));
740
- };
741
- export default TokenWidgetRenderer;
742
- //# sourceMappingURL=TokenWidgetRenderer.js.map