@rango-dev/widget-embedded 0.17.1-next.1 → 0.17.1-next.11

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 (325) hide show
  1. package/dist/QueueManager.d.ts +5 -2
  2. package/dist/QueueManager.d.ts.map +1 -1
  3. package/dist/components/AppRouter.d.ts +0 -2
  4. package/dist/components/AppRouter.d.ts.map +1 -1
  5. package/dist/components/AppRoutes.d.ts +1 -6
  6. package/dist/components/AppRoutes.d.ts.map +1 -1
  7. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -3
  8. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
  9. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
  10. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  11. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +1 -3
  12. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
  13. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  14. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +1 -4
  15. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
  16. package/dist/components/NoResult/NoResult.d.ts +4 -0
  17. package/dist/components/NoResult/NoResult.d.ts.map +1 -0
  18. package/dist/components/NoResult/NoResult.helpers.d.ts +4 -0
  19. package/dist/components/NoResult/NoResult.helpers.d.ts.map +1 -0
  20. package/dist/components/{NoRoutes/NoRoutes.styles.d.ts → NoResult/NoResult.styles.d.ts} +1 -1
  21. package/dist/components/{NoRoutes/NoRoutes.styles.d.ts.map → NoResult/NoResult.styles.d.ts.map} +1 -1
  22. package/dist/components/{NoRoutes/NoRoutes.types.d.ts → NoResult/NoResult.types.d.ts} +3 -3
  23. package/dist/components/NoResult/NoResult.types.d.ts.map +1 -0
  24. package/dist/components/NoResult/index.d.ts +2 -0
  25. package/dist/components/NoResult/index.d.ts.map +1 -0
  26. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  27. package/dist/components/Quote/Quote.d.ts +4 -0
  28. package/dist/components/Quote/Quote.d.ts.map +1 -0
  29. package/dist/components/Quote/Quote.styles.d.ts +1429 -0
  30. package/dist/components/Quote/Quote.styles.d.ts.map +1 -0
  31. package/dist/components/Quote/Quote.types.d.ts +22 -0
  32. package/dist/components/Quote/Quote.types.d.ts.map +1 -0
  33. package/dist/components/Quote/QuoteSkeleton.d.ts +4 -0
  34. package/dist/components/Quote/QuoteSkeleton.d.ts.map +1 -0
  35. package/dist/components/Quote/QuoteSkeleton.styles.d.ts +319 -0
  36. package/dist/components/Quote/QuoteSkeleton.styles.d.ts.map +1 -0
  37. package/dist/components/Quote/QuoteSkeleton.types.d.ts +6 -0
  38. package/dist/components/Quote/QuoteSkeleton.types.d.ts.map +1 -0
  39. package/dist/components/Quote/QuoteSummary.d.ts +11 -0
  40. package/dist/components/Quote/QuoteSummary.d.ts.map +1 -0
  41. package/dist/components/Quote/QuoteSummary.styles.d.ts +158 -0
  42. package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -0
  43. package/dist/components/Quote/index.d.ts +4 -0
  44. package/dist/components/Quote/index.d.ts.map +1 -0
  45. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +11 -0
  46. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +1 -0
  47. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +4 -0
  48. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +1 -0
  49. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +4 -0
  50. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -0
  51. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +9 -0
  52. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -0
  53. package/dist/components/{RouteErrors/RouteErrors.styles.d.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts} +1 -1
  54. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -0
  55. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +22 -0
  56. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -0
  57. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +11 -0
  58. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -0
  59. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +11 -0
  60. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +1 -0
  61. package/dist/components/QuoteWarningsAndErrors/index.d.ts +2 -0
  62. package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +1 -0
  63. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  64. package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
  65. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
  66. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  67. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  68. package/dist/components/UpdateUrl.d.ts +1 -6
  69. package/dist/components/UpdateUrl.d.ts.map +1 -1
  70. package/dist/components/WidgetEvents.d.ts.map +1 -1
  71. package/dist/constants/errors.d.ts +4 -4
  72. package/dist/constants/errors.d.ts.map +1 -1
  73. package/dist/constants/messages.d.ts +1 -1
  74. package/dist/constants/searchParams.d.ts +2 -1
  75. package/dist/constants/searchParams.d.ts.map +1 -1
  76. package/dist/constants/warnings.d.ts +2 -2
  77. package/dist/constants/warnings.d.ts.map +1 -1
  78. package/dist/containers/App/App.d.ts +3 -0
  79. package/dist/containers/App/App.d.ts.map +1 -0
  80. package/dist/containers/App/App.styles.d.ts +158 -0
  81. package/dist/containers/App/App.styles.d.ts.map +1 -0
  82. package/dist/containers/App/index.d.ts +2 -0
  83. package/dist/containers/App/index.d.ts.map +1 -0
  84. package/dist/containers/QuoteInfo/QuoteInfo.d.ts +4 -0
  85. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -0
  86. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +472 -0
  87. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -0
  88. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +17 -0
  89. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -0
  90. package/dist/containers/QuoteInfo/index.d.ts +2 -0
  91. package/dist/containers/QuoteInfo/index.d.ts.map +1 -0
  92. package/dist/containers/Wallets/Wallets.d.ts +6 -0
  93. package/dist/containers/Wallets/Wallets.d.ts.map +1 -0
  94. package/dist/containers/Wallets/Wallets.types.d.ts +11 -0
  95. package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -0
  96. package/dist/containers/Wallets/index.d.ts +2 -0
  97. package/dist/containers/Wallets/index.d.ts.map +1 -0
  98. package/dist/containers/Widget/Widget.d.ts +5 -0
  99. package/dist/containers/Widget/Widget.d.ts.map +1 -0
  100. package/dist/containers/Widget/Widget.types.d.ts +5 -0
  101. package/dist/containers/Widget/Widget.types.d.ts.map +1 -0
  102. package/dist/containers/Widget/index.d.ts +3 -0
  103. package/dist/containers/Widget/index.d.ts.map +1 -0
  104. package/dist/containers/WidgetInfo/WidgetInfo.d.ts +6 -0
  105. package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -0
  106. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +5 -0
  107. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -0
  108. package/dist/containers/WidgetInfo/index.d.ts +2 -0
  109. package/dist/containers/WidgetInfo/index.d.ts.map +1 -0
  110. package/dist/containers/WidgetProvider/WidgetProvider.d.ts +5 -0
  111. package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -0
  112. package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +7 -0
  113. package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +1 -0
  114. package/dist/containers/WidgetProvider/index.d.ts +2 -0
  115. package/dist/containers/WidgetProvider/index.d.ts.map +1 -0
  116. package/dist/hooks/useConfirmSwap/index.d.ts +2 -0
  117. package/dist/hooks/useConfirmSwap/index.d.ts.map +1 -0
  118. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +3 -0
  119. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -0
  120. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +16 -0
  121. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -0
  122. package/dist/hooks/{useConfirmSwap.d.ts → useConfirmSwap/useConfirmSwap.types.d.ts} +5 -7
  123. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -0
  124. package/dist/hooks/{useFetchBestRoute.d.ts → useFetchQuote.d.ts} +3 -3
  125. package/dist/hooks/useFetchQuote.d.ts.map +1 -0
  126. package/dist/hooks/useForceAutoConnect.d.ts +2 -0
  127. package/dist/hooks/useForceAutoConnect.d.ts.map +1 -0
  128. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
  129. package/dist/hooks/useSwapInput.d.ts +4 -2
  130. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  131. package/dist/hooks/useSyncStoresWithConfig.d.ts +1 -2
  132. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
  133. package/dist/hooks/useWalletList.d.ts.map +1 -1
  134. package/dist/index.d.ts +11 -4
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +1 -1
  137. package/dist/index.js.map +4 -4
  138. package/dist/pages/ConfirmSwapPage.d.ts +1 -6
  139. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  140. package/dist/pages/Home.d.ts.map +1 -1
  141. package/dist/pages/LiquiditySourcePage.d.ts +1 -2
  142. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  143. package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
  144. package/dist/pages/SettingsPage.d.ts +1 -6
  145. package/dist/pages/SettingsPage.d.ts.map +1 -1
  146. package/dist/pages/WalletsPage.d.ts +1 -8
  147. package/dist/pages/WalletsPage.d.ts.map +1 -1
  148. package/dist/store/AppStore.d.ts +11 -0
  149. package/dist/store/AppStore.d.ts.map +1 -0
  150. package/dist/store/app.d.ts +5 -23
  151. package/dist/store/app.d.ts.map +1 -1
  152. package/dist/store/{bestRoute.d.ts → quote.d.ts} +39 -27
  153. package/dist/store/quote.d.ts.map +1 -0
  154. package/dist/store/settings.d.ts +3 -2
  155. package/dist/store/settings.d.ts.map +1 -1
  156. package/dist/store/slices/config.d.ts +3 -2
  157. package/dist/store/slices/config.d.ts.map +1 -1
  158. package/dist/store/slices/data.d.ts +3 -0
  159. package/dist/store/slices/data.d.ts.map +1 -1
  160. package/dist/store/wallets.d.ts +5 -4
  161. package/dist/store/wallets.d.ts.map +1 -1
  162. package/dist/types/config.d.ts +5 -5
  163. package/dist/types/config.d.ts.map +1 -1
  164. package/dist/types/index.d.ts +1 -1
  165. package/dist/types/index.d.ts.map +1 -1
  166. package/dist/types/quote.d.ts +82 -0
  167. package/dist/types/quote.d.ts.map +1 -0
  168. package/dist/utils/colors.d.ts.map +1 -1
  169. package/dist/utils/numbers.d.ts +1 -1
  170. package/dist/utils/numbers.d.ts.map +1 -1
  171. package/dist/utils/{routing.d.ts → quote.d.ts} +16 -12
  172. package/dist/utils/quote.d.ts.map +1 -0
  173. package/dist/utils/settings.d.ts +3 -2
  174. package/dist/utils/settings.d.ts.map +1 -1
  175. package/dist/utils/swap.d.ts +25 -22
  176. package/dist/utils/swap.d.ts.map +1 -1
  177. package/dist/utils/wallets.d.ts +2 -2
  178. package/dist/utils/wallets.d.ts.map +1 -1
  179. package/package.json +6 -6
  180. package/src/QueueManager.tsx +17 -17
  181. package/src/components/AppRouter.tsx +6 -5
  182. package/src/components/AppRoutes.tsx +6 -39
  183. package/src/components/BlockchainList/BlockchainList.tsx +4 -4
  184. package/src/components/BlockchainsSection/BlockchainsSection.tsx +7 -7
  185. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +2 -64
  186. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +28 -40
  187. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +1 -3
  188. package/src/components/ConfirmWalletsModal/WalletList.tsx +6 -5
  189. package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
  190. package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +3 -3
  191. package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +6 -6
  192. package/src/components/{NoRoutes/NoRoutes.helper.ts → NoResult/NoResult.helpers.ts} +16 -9
  193. package/src/components/{NoRoutes/NoRoutes.styles.ts → NoResult/NoResult.styles.ts} +2 -0
  194. package/src/components/{NoRoutes/NoRoutes.tsx → NoResult/NoResult.tsx} +10 -12
  195. package/src/components/{NoRoutes/NoRoutes.types.ts → NoResult/NoResult.types.ts} +3 -2
  196. package/src/components/NoResult/index.ts +1 -0
  197. package/src/components/NotificationContent/NotificationContent.tsx +3 -2
  198. package/src/components/Quote/Quote.styles.ts +219 -0
  199. package/src/components/Quote/Quote.tsx +345 -0
  200. package/src/components/Quote/Quote.types.ts +16 -0
  201. package/src/components/Quote/QuoteSkeleton.styles.ts +110 -0
  202. package/src/components/Quote/QuoteSkeleton.tsx +108 -0
  203. package/src/components/Quote/QuoteSkeleton.types.ts +5 -0
  204. package/src/components/Quote/QuoteSummary.styles.ts +15 -0
  205. package/src/components/Quote/QuoteSummary.tsx +46 -0
  206. package/src/components/Quote/index.ts +3 -0
  207. package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +107 -0
  208. package/src/components/{RouteErrors/RouteErrorsModalItem.tsx → QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx} +4 -4
  209. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +67 -0
  210. package/src/components/{RouteErrors/RouteErrors.styles.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts} +8 -1
  211. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +103 -0
  212. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +24 -0
  213. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +77 -0
  214. package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +38 -0
  215. package/src/components/QuoteWarningsAndErrors/index.ts +1 -0
  216. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
  217. package/src/components/SwapDetails/SwapDetails.tsx +18 -22
  218. package/src/components/SwapsGroup/SwapsGroup.styles.ts +8 -1
  219. package/src/components/SwapsGroup/SwapsGroup.tsx +0 -2
  220. package/src/components/SwitchFromAndTo.tsx +2 -2
  221. package/src/components/TokenList/TokenList.styles.ts +14 -2
  222. package/src/components/TokenList/TokenList.tsx +6 -7
  223. package/src/components/UpdateUrl.tsx +36 -26
  224. package/src/components/WidgetEvents.tsx +4 -2
  225. package/src/constants/errors.ts +8 -10
  226. package/src/constants/messages.ts +1 -1
  227. package/src/constants/searchParams.ts +1 -0
  228. package/src/constants/warnings.ts +7 -7
  229. package/src/containers/App/App.styles.ts +18 -0
  230. package/src/containers/App/App.tsx +65 -0
  231. package/src/containers/App/index.ts +1 -0
  232. package/src/containers/QuoteInfo/QuoteInfo.styles.ts +15 -0
  233. package/src/containers/QuoteInfo/QuoteInfo.tsx +97 -0
  234. package/src/containers/QuoteInfo/QuoteInfo.types.ts +17 -0
  235. package/src/containers/QuoteInfo/index.ts +1 -0
  236. package/src/{Wallets.tsx → containers/Wallets/Wallets.tsx} +40 -32
  237. package/src/containers/Wallets/Wallets.types.ts +12 -0
  238. package/src/containers/Wallets/index.ts +1 -0
  239. package/src/containers/Widget/Widget.tsx +19 -0
  240. package/src/containers/Widget/Widget.types.ts +5 -0
  241. package/src/containers/Widget/index.ts +2 -0
  242. package/src/containers/WidgetInfo/WidgetInfo.tsx +36 -0
  243. package/src/containers/WidgetInfo/WidgetInfo.types.ts +5 -0
  244. package/src/containers/WidgetInfo/index.ts +1 -0
  245. package/src/containers/WidgetProvider/WidgetProvider.tsx +19 -0
  246. package/src/containers/WidgetProvider/WidgetProvider.types.ts +7 -0
  247. package/src/containers/WidgetProvider/index.ts +1 -0
  248. package/src/hooks/useConfirmSwap/index.ts +1 -0
  249. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +168 -0
  250. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +136 -0
  251. package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +19 -0
  252. package/src/hooks/{useFetchBestRoute.ts → useFetchQuote.ts} +3 -3
  253. package/src/hooks/useForceAutoConnect.ts +27 -0
  254. package/src/hooks/useNavigateBack.ts +3 -3
  255. package/src/hooks/useSwapInput.ts +58 -23
  256. package/src/hooks/useSyncStoresWithConfig.ts +22 -19
  257. package/src/hooks/useWalletList.ts +3 -5
  258. package/src/index.ts +12 -3
  259. package/src/pages/ConfirmSwapPage.tsx +58 -235
  260. package/src/pages/HistoryPage.tsx +1 -1
  261. package/src/pages/Home.tsx +58 -247
  262. package/src/pages/LanguagePage.tsx +1 -1
  263. package/src/pages/LiquiditySourcePage.tsx +23 -32
  264. package/src/pages/SelectBlockchainPage.tsx +6 -7
  265. package/src/pages/SelectSwapItemsPage.tsx +5 -5
  266. package/src/pages/SettingsPage.tsx +9 -13
  267. package/src/pages/SwapDetailsPage.tsx +3 -3
  268. package/src/pages/ThemePage.tsx +1 -1
  269. package/src/pages/WalletsPage.tsx +5 -12
  270. package/src/store/AppStore.tsx +35 -0
  271. package/src/store/app.ts +18 -6
  272. package/src/store/{bestRoute.ts → quote.ts} +68 -60
  273. package/src/store/settings.ts +7 -4
  274. package/src/store/slices/config.ts +25 -15
  275. package/src/store/slices/data.ts +64 -29
  276. package/src/store/wallets.ts +11 -8
  277. package/src/types/config.ts +5 -5
  278. package/src/types/index.ts +1 -1
  279. package/src/types/quote.ts +107 -0
  280. package/src/utils/colors.ts +2 -1
  281. package/src/utils/numbers.ts +1 -1
  282. package/src/utils/quote.ts +338 -0
  283. package/src/utils/settings.ts +8 -7
  284. package/src/utils/swap.ts +113 -85
  285. package/src/utils/wallets.ts +29 -17
  286. package/dist/Wallets.d.ts +0 -17
  287. package/dist/Wallets.d.ts.map +0 -1
  288. package/dist/Widget.d.ts +0 -9
  289. package/dist/Widget.d.ts.map +0 -1
  290. package/dist/components/NoRoutes/NoRoutes.d.ts +0 -4
  291. package/dist/components/NoRoutes/NoRoutes.d.ts.map +0 -1
  292. package/dist/components/NoRoutes/NoRoutes.helper.d.ts +0 -3
  293. package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +0 -1
  294. package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +0 -1
  295. package/dist/components/NoRoutes/index.d.ts +0 -2
  296. package/dist/components/NoRoutes/index.d.ts.map +0 -1
  297. package/dist/components/RouteErrors/RouteErrors.d.ts +0 -4
  298. package/dist/components/RouteErrors/RouteErrors.d.ts.map +0 -1
  299. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +0 -1
  300. package/dist/components/RouteErrors/RouteErrors.types.d.ts +0 -24
  301. package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +0 -1
  302. package/dist/components/RouteErrors/RouteErrorsModal.d.ts +0 -4
  303. package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +0 -1
  304. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +0 -4
  305. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +0 -1
  306. package/dist/components/RouteErrors/index.d.ts +0 -2
  307. package/dist/components/RouteErrors/index.d.ts.map +0 -1
  308. package/dist/hooks/useConfirmSwap.d.ts.map +0 -1
  309. package/dist/hooks/useFetchBestRoute.d.ts.map +0 -1
  310. package/dist/store/bestRoute.d.ts.map +0 -1
  311. package/dist/store/meta.d.ts +0 -23
  312. package/dist/store/meta.d.ts.map +0 -1
  313. package/dist/types/routing.d.ts +0 -65
  314. package/dist/types/routing.d.ts.map +0 -1
  315. package/dist/utils/routing.d.ts.map +0 -1
  316. package/src/Widget.tsx +0 -119
  317. package/src/components/NoRoutes/index.ts +0 -1
  318. package/src/components/RouteErrors/RouteErrors.tsx +0 -79
  319. package/src/components/RouteErrors/RouteErrors.types.ts +0 -29
  320. package/src/components/RouteErrors/RouteErrorsModal.tsx +0 -129
  321. package/src/components/RouteErrors/index.ts +0 -1
  322. package/src/hooks/useConfirmSwap.ts +0 -303
  323. package/src/store/meta.ts +0 -39
  324. package/src/types/routing.ts +0 -77
  325. package/src/utils/routing.ts +0 -321
@@ -1,4 +1,4 @@
1
- import { styled, Typography } from '@rango-dev/ui';
1
+ import { darkTheme, styled, Typography } from '@rango-dev/ui';
2
2
 
3
3
  export const Container = styled('div', {
4
4
  display: 'flex',
@@ -40,7 +40,11 @@ export const List = styled('ul', {
40
40
  '& a': {
41
41
  fontSize: '$12',
42
42
  lineHeight: '$16',
43
- color: '$neutral600',
43
+ $$color: '$colors$neutral600',
44
+ [`.${darkTheme} &`]: {
45
+ $$color: '$colors$neutral700',
46
+ },
47
+ color: '$$color',
44
48
  textDecoration: 'none',
45
49
  },
46
50
  },
@@ -92,6 +96,14 @@ export const TagTitle = styled(Typography, {});
92
96
 
93
97
  export const BalanceContainer = styled('div', {
94
98
  textAlign: 'right',
99
+
100
+ '.usd-value': {
101
+ $$color: '$colors$neutral600',
102
+ [`.${darkTheme} &`]: {
103
+ $$color: '$colors$neutral700',
104
+ },
105
+ color: '$$color',
106
+ },
95
107
  });
96
108
 
97
109
  export const End = styled('ul', {
@@ -21,8 +21,7 @@ import {
21
21
  } from '@rango-dev/ui';
22
22
  import React, { forwardRef, useEffect, useState } from 'react';
23
23
 
24
- import { useAppStore } from '../../store/app';
25
- import { useMetaStore } from '../../store/meta';
24
+ import { useAppStore } from '../../store/AppStore';
26
25
  import { useWalletsStore } from '../../store/wallets';
27
26
  import { generateRangeColors } from '../../utils/colors';
28
27
 
@@ -87,10 +86,10 @@ export function TokenList(props: PropTypes) {
87
86
  const { list, searchedFor = '', onChange, selectedBlockchain } = props;
88
87
 
89
88
  const [tokens, setTokens] = useState<TokenWithBalance[]>(list);
90
- const loadingStatus = useMetaStore.use.loadingStatus();
89
+ const fetchStatus = useAppStore().fetchStatus;
90
+ const blockchains = useAppStore().blockchains();
91
91
  const [hasNextPage, setHasNextPage] = useState<boolean>(true);
92
92
  const loadingWallet = useWalletsStore.use.loading();
93
- const { blockchains } = useMetaStore.use.meta();
94
93
  const { isTokenPinned } = useAppStore();
95
94
 
96
95
  // eslint-disable-next-line react/display-name
@@ -239,7 +238,7 @@ export function TokenList(props: PropTypes) {
239
238
  {token.balance?.usdValue && (
240
239
  <Typography
241
240
  variant="body"
242
- color="neutral600"
241
+ className="usd-value"
243
242
  size="xsmall">
244
243
  {`$${token.balance?.usdValue}`}
245
244
  </Typography>
@@ -268,8 +267,8 @@ export function TokenList(props: PropTypes) {
268
267
  {i18n.t('Select Token')}
269
268
  </Typography>
270
269
  <Divider size={4} />
271
- {loadingStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
272
- {loadingStatus === 'success' && <List>{renderList()}</List>}
270
+ {fetchStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
271
+ {fetchStatus === 'success' && <List>{renderList()}</List>}
273
272
  </Container>
274
273
  );
275
274
  }
@@ -1,5 +1,3 @@
1
- import type { WidgetConfig } from '../types';
2
-
3
1
  import { useEffect, useRef } from 'react';
4
2
  import {
5
3
  createSearchParams,
@@ -10,33 +8,32 @@ import {
10
8
  import { navigationRoutes } from '../constants/navigationRoutes';
11
9
  import { SearchParams } from '../constants/searchParams';
12
10
  import { useSyncStoresWithConfig } from '../hooks/useSyncStoresWithConfig';
13
- import { useBestRouteStore } from '../store/bestRoute';
14
- import { useMetaStore } from '../store/meta';
11
+ import { useAppStore } from '../store/AppStore';
12
+ import { useQuoteStore } from '../store/quote';
15
13
  import { useUiStore } from '../store/ui';
16
- import { searchParamsToToken } from '../utils/routing';
17
-
18
- type Props = { config: WidgetConfig | undefined };
14
+ import { searchParamsToToken } from '../utils/quote';
19
15
 
20
- export function UpdateUrl(props: Props) {
16
+ export function UpdateUrl() {
21
17
  const firstRender = useRef(true);
22
18
  const [searchParams, setSearchParams] = useSearchParams();
23
19
  const location = useLocation();
24
20
  const firstRenderSearchParams = useRef(location.search);
25
21
  const searchParamsRef = useRef<Record<string, string>>({});
26
- const fromBlockchain = useBestRouteStore.use.fromBlockchain();
27
- const toBlockchain = useBestRouteStore.use.toBlockchain();
28
- const fromToken = useBestRouteStore.use.fromToken();
29
- const toToken = useBestRouteStore.use.toToken();
30
- const setFromBlockchain = useBestRouteStore.use.setFromBlockchain();
31
- const setFromToken = useBestRouteStore.use.setFromToken();
32
- const setToBlockchain = useBestRouteStore.use.setToBlockchain();
33
- const setToToken = useBestRouteStore.use.setToToken();
34
- const inputAmount = useBestRouteStore.use.inputAmount();
35
- const setInputAmount = useBestRouteStore.use.setInputAmount();
36
- const loadingStatus = useMetaStore.use.loadingStatus();
37
- const { blockchains, tokens } = useMetaStore.use.meta();
22
+ const fromBlockchain = useQuoteStore.use.fromBlockchain();
23
+ const toBlockchain = useQuoteStore.use.toBlockchain();
24
+ const fromToken = useQuoteStore.use.fromToken();
25
+ const toToken = useQuoteStore.use.toToken();
26
+ const setFromBlockchain = useQuoteStore.use.setFromBlockchain();
27
+ const setFromToken = useQuoteStore.use.setFromToken();
28
+ const setToBlockchain = useQuoteStore.use.setToBlockchain();
29
+ const setToToken = useQuoteStore.use.setToToken();
30
+ const inputAmount = useQuoteStore.use.inputAmount();
31
+ const setInputAmount = useQuoteStore.use.setInputAmount();
32
+ const fetchMetaStatus = useAppStore().fetchStatus;
33
+ const blockchains = useAppStore().blockchains();
34
+ const tokens = useAppStore().tokens();
38
35
  const setSelectedSwap = useUiStore.use.setSelectedSwap();
39
- useSyncStoresWithConfig(props.config);
36
+ useSyncStoresWithConfig();
40
37
 
41
38
  useEffect(() => {
42
39
  const params: Record<string, string> = {};
@@ -60,7 +57,8 @@ export function UpdateUrl(props: Props) {
60
57
  toChainString = '',
61
58
  toTokenString = '',
62
59
  fromAmount = '';
63
- if (loadingStatus !== 'success') {
60
+ const autoConnect = searchParamsRef.current[SearchParams.AUTO_CONNECT];
61
+ if (fetchMetaStatus !== 'success') {
64
62
  fromChainString = searchParamsRef.current[SearchParams.FROM_CHAIN];
65
63
  fromTokenString = searchParamsRef.current[SearchParams.FROM_TOKEN];
66
64
  toChainString = searchParamsRef.current[SearchParams.TO_CHAIN];
@@ -94,6 +92,9 @@ export function UpdateUrl(props: Props) {
94
92
  ...(fromAmount && {
95
93
  [SearchParams.FROM_AMOUNT]: fromAmount.toString(),
96
94
  }),
95
+ ...(autoConnect && {
96
+ [SearchParams.AUTO_CONNECT]: autoConnect,
97
+ }),
97
98
  },
98
99
  { replace: true }
99
100
  );
@@ -109,7 +110,7 @@ export function UpdateUrl(props: Props) {
109
110
  ]);
110
111
 
111
112
  useEffect(() => {
112
- if (loadingStatus === 'success') {
113
+ if (fetchMetaStatus === 'success') {
113
114
  const fromChainString = searchParams.get(SearchParams.FROM_CHAIN);
114
115
  const fromTokenString = searchParams.get(SearchParams.FROM_TOKEN);
115
116
  const toChainString = searchParams.get(SearchParams.TO_CHAIN);
@@ -134,20 +135,29 @@ export function UpdateUrl(props: Props) {
134
135
  if (!!fromBlockchain) {
135
136
  setFromBlockchain(fromBlockchain);
136
137
  if (!!fromToken) {
137
- setFromToken(fromToken);
138
+ setFromToken({
139
+ token: fromToken,
140
+ meta: {
141
+ blockchains: blockchains,
142
+ tokens: tokens,
143
+ },
144
+ });
138
145
  }
139
146
  }
140
147
  if (!!toBlockchain) {
141
148
  setToBlockchain(toBlockchain);
142
149
  if (!!toToken) {
143
- setToToken(toToken);
150
+ setToToken({
151
+ token: toToken,
152
+ meta: { blockchains: blockchains, tokens: tokens },
153
+ });
144
154
  }
145
155
  }
146
156
  if (fromAmount) {
147
157
  setInputAmount(fromAmount);
148
158
  }
149
159
  }
150
- }, [loadingStatus]);
160
+ }, [fetchMetaStatus]);
151
161
 
152
162
  return null;
153
163
  }
@@ -8,11 +8,13 @@ import {
8
8
  } from '@rango-dev/queue-manager-rango-preset';
9
9
  import { useEffect } from 'react';
10
10
 
11
+ import { useAppStore } from '../store/AppStore';
11
12
  import { useNotificationStore } from '../store/notification';
12
13
  import { useWalletsStore } from '../store/wallets';
13
14
  import { validBlockedStatuses } from '../types/notification';
14
15
 
15
16
  export function WidgetEvents() {
17
+ const tokens = useAppStore().tokens();
16
18
  const connectedWallets = useWalletsStore.use.connectedWallets();
17
19
  const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
18
20
  const setNotification = useNotificationStore.use.setNotification();
@@ -38,8 +40,8 @@ export function WidgetEvents() {
38
40
  (wallet) => wallet.chain === step?.toBlockchain
39
41
  );
40
42
 
41
- fromAccount && getWalletsDetails([fromAccount]);
42
- toAccount && getWalletsDetails([toAccount]);
43
+ fromAccount && getWalletsDetails([fromAccount], tokens);
44
+ toAccount && getWalletsDetails([toAccount], tokens);
43
45
  }
44
46
  if (
45
47
  (event.type === StepEventType.TX_EXECUTION_BLOCKED &&
@@ -1,8 +1,8 @@
1
- import type { ConfirmSwapError } from '../types';
1
+ import type { QuoteError } from '../types';
2
2
 
3
3
  import { i18n } from '@lingui/core';
4
4
 
5
- import { ConfirmSwapErrorTypes } from '../types';
5
+ import { QuoteErrorType } from '../types';
6
6
 
7
7
  export const errorMessages = () => {
8
8
  return {
@@ -13,7 +13,7 @@ export const errorMessages = () => {
13
13
  'You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources'
14
14
  ),
15
15
  },
16
- noRoutesError: {
16
+ noResultError: {
17
17
  title: i18n.t('No Routes Found'),
18
18
  description: i18n.t(
19
19
  "Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination."
@@ -31,7 +31,7 @@ export const errorMessages = () => {
31
31
  ),
32
32
  confirmMessage: i18n.t('Confirm High price impact'),
33
33
  },
34
- routeUpdatedWithHighValueLoss: {
34
+ quoteUpdatedWithHighValueLoss: {
35
35
  title: i18n.t(
36
36
  'Route updated and price impact is too high, try again later!'
37
37
  ),
@@ -47,14 +47,12 @@ export const errorMessages = () => {
47
47
  };
48
48
  };
49
49
 
50
- export function getConfirmSwapErrorMessage(error: ConfirmSwapError) {
50
+ export function getQuoteErrorMessage(error: QuoteError) {
51
51
  switch (error.type) {
52
- case ConfirmSwapErrorTypes.NO_ROUTE:
53
- return error.diagnosisMessage ?? errorMessages().noRoutesError.title;
54
- case ConfirmSwapErrorTypes.REQUEST_FAILED:
52
+ case QuoteErrorType.NO_RESULT:
53
+ return error.diagnosisMessage ?? errorMessages().noResultError.title;
54
+ case QuoteErrorType.REQUEST_FAILED:
55
55
  return errorMessages().genericServerError;
56
- case ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS:
57
- return errorMessages().routeUpdatedWithHighValueLoss.title;
58
56
  default:
59
57
  return '';
60
58
  }
@@ -5,6 +5,6 @@ export const swapButtonTitles = () => {
5
5
  connectWallet: i18n.t('Connect Wallet'),
6
6
  swap: i18n.t('Swap'),
7
7
  swapAnyway: i18n.t('Swap anyway'),
8
- ethRouteWarning: i18n.t('The route goes through Ethereum. Continue?'),
8
+ ethWarning: i18n.t('The route goes through Ethereum. Continue?'),
9
9
  };
10
10
  };
@@ -4,4 +4,5 @@ export enum SearchParams {
4
4
  'TO_CHAIN' = 'toBlockchain',
5
5
  'TO_TOKEN' = 'toToken',
6
6
  'FROM_AMOUNT' = 'fromAmount',
7
+ 'AUTO_CONNECT' = 'autoConnect',
7
8
  }
@@ -1,14 +1,14 @@
1
- import type { RouteWarning } from '../types';
1
+ import type { QuoteUpdateWarning } from '../types';
2
2
 
3
3
  import { i18n } from '@lingui/core';
4
4
 
5
- import { RouteWarningType } from '../types';
5
+ import { QuoteUpdateType } from '../types';
6
6
 
7
- export function getRouteWarningMessage(warning: RouteWarning) {
7
+ export function getQuoteUpdateWarningMessage(warning: QuoteUpdateWarning) {
8
8
  switch (warning.type) {
9
- case RouteWarningType.ROUTE_UPDATED:
9
+ case QuoteUpdateType.QUOTE_UPDATED:
10
10
  return i18n.t('Route has been updated.');
11
- case RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED:
11
+ case QuoteUpdateType.QUOTE_AND_OUTPUT_AMOUNT_UPDATED:
12
12
  return i18n.t(
13
13
  'Output amount changed to {newOutputAmount} ({percentageChange}% change).',
14
14
  {
@@ -16,9 +16,9 @@ export function getRouteWarningMessage(warning: RouteWarning) {
16
16
  percentageChange: warning.percentageChange,
17
17
  }
18
18
  );
19
- case RouteWarningType.ROUTE_SWAPPERS_UPDATED:
19
+ case QuoteUpdateType.QUOTE_SWAPPERS_UPDATED:
20
20
  return i18n.t('Route swappers has been updated.');
21
- case RouteWarningType.ROUTE_COINS_UPDATED:
21
+ case QuoteUpdateType.QUOTE_COINS_UPDATED:
22
22
  return i18n.t('Route internal coins has been updated.');
23
23
  default:
24
24
  return '';
@@ -0,0 +1,18 @@
1
+ import { styled } from '@rango-dev/ui';
2
+
3
+ export const MainContainer = styled('div', {
4
+ width: '100%',
5
+ display: 'flex',
6
+ justifyContent: 'center',
7
+ alignItems: 'center',
8
+ fontFamily: '$widget',
9
+ boxSizing: 'border-box',
10
+ '& *, *::before, *::after': {
11
+ boxSizing: 'inherit',
12
+ listStyleType: 'none',
13
+ },
14
+ '& *:focus-visible': {
15
+ outlineColor: '$info500',
16
+ transition: 'none',
17
+ },
18
+ });
@@ -0,0 +1,65 @@
1
+ import type { WalletType } from '@rango-dev/wallets-shared';
2
+
3
+ import { I18nManager } from '@rango-dev/ui';
4
+ import React, { useContext, useEffect, useMemo, useState } from 'react';
5
+
6
+ import { AppRouter } from '../../components/AppRouter';
7
+ import { AppRoutes } from '../../components/AppRoutes';
8
+ import { WidgetEvents } from '../../components/WidgetEvents';
9
+ import { globalFont } from '../../globalStyles';
10
+ import { useLanguage } from '../../hooks/useLanguage';
11
+ import { useTheme } from '../../hooks/useTheme';
12
+ import { useAppStore } from '../../store/AppStore';
13
+ import { useNotificationStore } from '../../store/notification';
14
+ import { useSettingsStore } from '../../store/settings';
15
+ import { initConfig } from '../../utils/configs';
16
+ import { WidgetContext } from '../Wallets';
17
+
18
+ import { MainContainer } from './App.styles';
19
+
20
+ export function Main() {
21
+ globalFont();
22
+
23
+ const { fetch: fetchMeta, config } = useAppStore();
24
+ const { activeTheme } = useTheme(config?.theme || {});
25
+ const { activeLanguage, changeLanguage } = useLanguage();
26
+ const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
27
+ useState<string>('');
28
+ const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
29
+ const widgetContext = useContext(WidgetContext);
30
+
31
+ useMemo(() => {
32
+ if (config?.apiKey) {
33
+ initConfig({
34
+ API_KEY: config?.apiKey,
35
+ });
36
+ }
37
+ }, [config]);
38
+ useEffect(() => {
39
+ void fetchMeta().catch();
40
+ void useSettingsStore.persist.rehydrate();
41
+ void useNotificationStore.persist.rehydrate();
42
+ widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
43
+ }, []);
44
+ useEffect(() => {
45
+ if (config?.language) {
46
+ changeLanguage(config.language);
47
+ }
48
+ }, [config?.language]);
49
+
50
+ return (
51
+ <I18nManager language={activeLanguage}>
52
+ <MainContainer id="swap-container" className={activeTheme()}>
53
+ <WidgetEvents />
54
+ <AppRouter
55
+ lastConnectedWallet={lastConnectedWalletWithNetwork}
56
+ disconnectedWallet={disconnectedWallet}
57
+ clearDisconnectedWallet={() => {
58
+ setDisconnectedWallet(undefined);
59
+ }}>
60
+ <AppRoutes />
61
+ </AppRouter>
62
+ </MainContainer>
63
+ </I18nManager>
64
+ );
65
+ }
@@ -0,0 +1 @@
1
+ export { Main } from './App';
@@ -0,0 +1,15 @@
1
+ import { styled } from '@rango-dev/ui';
2
+
3
+ export const QuoteContainer = styled('div', {
4
+ width: '100%',
5
+ paddingTop: '$2',
6
+ });
7
+
8
+ export const FooterStepAlarm = styled('div', {
9
+ paddingBottom: '$15',
10
+ });
11
+
12
+ export const FooterAlert = styled('div', {
13
+ width: '100%',
14
+ display: 'flex',
15
+ });
@@ -0,0 +1,97 @@
1
+ import type { PropTypes } from './QuoteInfo.types';
2
+
3
+ import { Divider } from '@rango-dev/ui';
4
+ import React from 'react';
5
+
6
+ import { Quote, QuoteSkeleton } from '../../components/Quote';
7
+ import { QuoteWarningsAndErrors } from '../../components/QuoteWarningsAndErrors';
8
+ import {
9
+ TOKEN_AMOUNT_MAX_DECIMALS,
10
+ TOKEN_AMOUNT_MIN_DECIMALS,
11
+ USD_VALUE_MAX_DECIMALS,
12
+ USD_VALUE_MIN_DECIMALS,
13
+ } from '../../constants/routing';
14
+ import { useQuoteStore } from '../../store/quote';
15
+ import { numberToString } from '../../utils/numbers';
16
+
17
+ import { QuoteContainer } from './QuoteInfo.styles';
18
+
19
+ export function QuoteInfo(props: PropTypes) {
20
+ const {
21
+ quote,
22
+ type,
23
+ loading,
24
+ error,
25
+ warning,
26
+ refetchQuote,
27
+ showWarningModal,
28
+ onOpenWarningModal,
29
+ onCloseWarningModal,
30
+ onConfirmWarningModal,
31
+ expanded = false,
32
+ } = props;
33
+ const { inputAmount, inputUsdValue, outputUsdValue, outputAmount } =
34
+ useQuoteStore();
35
+
36
+ const showQuote = quote && quote.result && !loading;
37
+ return (
38
+ <>
39
+ {loading && (
40
+ <QuoteContainer>
41
+ <QuoteSkeleton type={type} expanded={expanded} />
42
+ </QuoteContainer>
43
+ )}
44
+ {showQuote ? (
45
+ <QuoteContainer>
46
+ <Quote
47
+ quote={quote}
48
+ error={error}
49
+ warning={warning}
50
+ type={type}
51
+ expanded={expanded}
52
+ recommended={true}
53
+ input={{
54
+ value: numberToString(
55
+ inputAmount,
56
+ TOKEN_AMOUNT_MIN_DECIMALS,
57
+ TOKEN_AMOUNT_MAX_DECIMALS
58
+ ),
59
+ usdValue: numberToString(
60
+ inputUsdValue,
61
+ USD_VALUE_MIN_DECIMALS,
62
+ USD_VALUE_MAX_DECIMALS
63
+ ),
64
+ }}
65
+ output={{
66
+ value: numberToString(
67
+ outputAmount,
68
+ TOKEN_AMOUNT_MIN_DECIMALS,
69
+ TOKEN_AMOUNT_MAX_DECIMALS
70
+ ),
71
+ usdValue: numberToString(
72
+ outputUsdValue,
73
+ USD_VALUE_MIN_DECIMALS,
74
+ USD_VALUE_MAX_DECIMALS
75
+ ),
76
+ }}
77
+ />
78
+ </QuoteContainer>
79
+ ) : null}
80
+
81
+ {!warning && !error && <Divider size={16} />}
82
+
83
+ {(warning || error) && (
84
+ <QuoteWarningsAndErrors
85
+ warning={warning}
86
+ error={error}
87
+ loading={loading}
88
+ refetchQuote={refetchQuote}
89
+ showWarningModal={showWarningModal}
90
+ onOpenWarningModal={onOpenWarningModal}
91
+ onCloseWarningModal={onCloseWarningModal}
92
+ onConfirmWarningModal={onConfirmWarningModal}
93
+ />
94
+ )}
95
+ </>
96
+ );
97
+ }
@@ -0,0 +1,17 @@
1
+ import type { QuoteProps } from '../../components/Quote/Quote.types';
2
+ import type { QuoteError, QuoteWarning } from '../../types';
3
+ import type { BestRouteResponse } from 'rango-sdk';
4
+
5
+ export type PropTypes = {
6
+ quote: BestRouteResponse | null;
7
+ type: QuoteProps['type'];
8
+ loading: boolean;
9
+ error: QuoteError | null;
10
+ warning: QuoteWarning | null;
11
+ expanded?: boolean;
12
+ refetchQuote: () => void;
13
+ showWarningModal: boolean;
14
+ onOpenWarningModal: () => void;
15
+ onCloseWarningModal: () => void;
16
+ onConfirmWarningModal: () => void;
17
+ };
@@ -0,0 +1 @@
1
+ export { QuoteInfo } from './QuoteInfo';
@@ -1,25 +1,24 @@
1
- import type { WidgetConfig } from './types';
2
- import type { ProvidersOptions } from './utils/providers';
1
+ import type {
2
+ OnConnectHandler,
3
+ PropTypes,
4
+ WidgetContextInterface,
5
+ } from './Wallets.types';
6
+ import type { ProvidersOptions } from '../../utils/providers';
3
7
  import type { EventHandler } from '@rango-dev/wallets-react';
4
8
  import type { Network } from '@rango-dev/wallets-shared';
5
9
  import type { PropsWithChildren } from 'react';
6
10
 
7
11
  import { Events, Provider } from '@rango-dev/wallets-react';
8
12
  import { isEvmBlockchain } from 'rango-sdk';
9
- import React, { createContext, useRef } from 'react';
13
+ import React, { createContext, useEffect, useRef } from 'react';
10
14
 
11
- import { useWalletProviders } from './hooks/useWalletProviders';
12
- import { useMetaStore } from './store/meta';
13
- import { useWalletsStore } from './store/wallets';
15
+ import { useWalletProviders } from '../../hooks/useWalletProviders';
16
+ import { AppStoreProvider, useAppStore } from '../../store/AppStore';
17
+ import { useWalletsStore } from '../../store/wallets';
14
18
  import {
15
19
  prepareAccountsForWalletStore,
16
20
  walletAndSupportedChainsNames,
17
- } from './utils/wallets';
18
-
19
- type OnConnectHandler = (key: string) => void;
20
- interface WidgetContextInterface {
21
- onConnectWallet(handler: OnConnectHandler): void;
22
- }
21
+ } from '../../utils/wallets';
23
22
 
24
23
  export const WidgetContext = createContext<WidgetContextInterface>({
25
24
  onConnectWallet: () => {
@@ -27,41 +26,41 @@ export const WidgetContext = createContext<WidgetContextInterface>({
27
26
  },
28
27
  });
29
28
 
30
- export function WidgetWallets(
31
- props: PropsWithChildren<{
32
- providers: WidgetConfig['wallets'];
33
- options?: ProvidersOptions;
34
- onUpdateState?: EventHandler;
35
- }>
36
- ) {
37
- const { blockchains } = useMetaStore.use.meta();
38
- const { providers } = useWalletProviders(props.providers, props?.options);
29
+ function Main(props: PropsWithChildren<PropTypes>) {
30
+ const updateConfig = useAppStore().updateConfig;
31
+ const blockchains = useAppStore().blockchains();
32
+ const tokens = useAppStore().tokens();
33
+ const walletOptions: ProvidersOptions = {
34
+ walletConnectProjectId: props.config?.walletConnectProjectId,
35
+ };
36
+ const { providers } = useWalletProviders(props.config.wallets, walletOptions);
39
37
  const disconnectWallet = useWalletsStore.use.disconnectWallet();
40
38
  const connectWallet = useWalletsStore.use.connectWallet();
41
39
  const onConnectWalletHandler = useRef<OnConnectHandler>();
42
40
 
41
+ useEffect(() => {
42
+ if (props.config) {
43
+ updateConfig(props.config);
44
+ }
45
+ }, [props.config]);
46
+
43
47
  const evmBasedChainNames = blockchains
44
48
  .filter(isEvmBlockchain)
45
49
  .map((chain) => chain.name);
46
50
 
47
- const onUpdateState: EventHandler = (
48
- type,
49
- event,
50
- value,
51
- state,
52
- supportedBlockchains
53
- ) => {
51
+ const onUpdateState: EventHandler = (type, event, value, state, meta) => {
54
52
  if (event === Events.ACCOUNTS) {
55
53
  if (value) {
56
54
  const supportedChainNames: Network[] | null =
57
- walletAndSupportedChainsNames(supportedBlockchains);
55
+ walletAndSupportedChainsNames(meta.supportedBlockchains);
58
56
  const data = prepareAccountsForWalletStore(
59
57
  type,
60
58
  value,
61
59
  evmBasedChainNames,
62
- supportedChainNames
60
+ supportedChainNames,
61
+ meta.isContractWallet
63
62
  );
64
- connectWallet(data);
63
+ connectWallet(data, tokens);
65
64
  } else {
66
65
  disconnectWallet(type);
67
66
  }
@@ -91,7 +90,7 @@ export function WidgetWallets(
91
90
 
92
91
  // propagate updates for Dapps using external wallets
93
92
  if (props.onUpdateState) {
94
- props.onUpdateState(type, event, value, state, supportedBlockchains);
93
+ props.onUpdateState(type, event, value, state, meta);
95
94
  }
96
95
  };
97
96
  return (
@@ -112,3 +111,12 @@ export function WidgetWallets(
112
111
  </WidgetContext.Provider>
113
112
  );
114
113
  }
114
+
115
+ export function WidgetWallets(props: PropsWithChildren<PropTypes>) {
116
+ const { config, ...otherProps } = props;
117
+ return (
118
+ <AppStoreProvider config={config}>
119
+ <Main {...otherProps} config={config} />
120
+ </AppStoreProvider>
121
+ );
122
+ }
@@ -0,0 +1,12 @@
1
+ import type { WidgetConfig } from '../../types';
2
+ import type { EventHandler } from '@rango-dev/wallets-react';
3
+
4
+ export type OnConnectHandler = (key: string) => void;
5
+ export interface WidgetContextInterface {
6
+ onConnectWallet(handler: OnConnectHandler): void;
7
+ }
8
+
9
+ export interface PropTypes {
10
+ onUpdateState?: EventHandler;
11
+ config: WidgetConfig;
12
+ }