@lifi/widget 2.0.0-beta.1 → 2.0.0-beta.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 (283) hide show
  1. package/App.d.ts +4 -3
  2. package/AppDrawer.d.ts +1 -1
  3. package/AppDrawer.js +2 -1
  4. package/AppProvider.js +1 -1
  5. package/README.md +11 -12
  6. package/cjs/App.d.ts +4 -3
  7. package/cjs/AppDrawer.d.ts +1 -1
  8. package/cjs/AppDrawer.js +2 -1
  9. package/cjs/AppProvider.js +1 -1
  10. package/cjs/components/ChainSelect/ChainSelect.d.ts +1 -2
  11. package/cjs/components/ChainSelect/ChainSelect.style.js +1 -1
  12. package/cjs/components/ChainSelect/useChainSelect.js +6 -0
  13. package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
  14. package/cjs/components/GasMessage/GasMessage.js +1 -6
  15. package/cjs/components/Header/Header.js +2 -2
  16. package/cjs/components/Header/Header.style.d.ts +10 -3
  17. package/cjs/components/Header/Header.style.js +3 -0
  18. package/cjs/components/Header/NavigationHeader.js +23 -7
  19. package/cjs/components/Header/NavigationTabs.d.ts +1 -0
  20. package/cjs/components/Header/NavigationTabs.js +26 -0
  21. package/cjs/components/Header/NavigationTabs.style.d.ts +34 -0
  22. package/cjs/components/Header/NavigationTabs.style.js +61 -0
  23. package/cjs/components/Header/WalletHeader.d.ts +1 -0
  24. package/cjs/components/Header/WalletHeader.js +16 -9
  25. package/cjs/components/Header/useHeaderActionStore.js +0 -1
  26. package/cjs/components/Insurance/Insurance.js +2 -2
  27. package/cjs/components/Insurance/InsuranceCard.js +34 -12
  28. package/cjs/components/Insurance/InsuranceCollapsed.js +9 -11
  29. package/cjs/components/Insurance/index.d.ts +1 -0
  30. package/cjs/components/Insurance/index.js +1 -0
  31. package/cjs/components/Insurance/types.d.ts +12 -9
  32. package/cjs/components/NFT/NFT.js +2 -2
  33. package/cjs/components/NFT/types.d.ts +1 -1
  34. package/cjs/components/PoweredBy/PoweredBy.js +2 -3
  35. package/cjs/components/SelectChainAndToken.js +8 -7
  36. package/cjs/components/SelectTokenButton/SelectTokenButton.js +6 -3
  37. package/cjs/components/SendToWallet/SendToWallet.js +2 -2
  38. package/cjs/components/SmallAvatar.d.ts +1 -1
  39. package/cjs/components/Step/CircularProgress.d.ts +1 -2
  40. package/cjs/components/Step/Step.js +15 -5
  41. package/cjs/components/Step/StepList.d.ts +1 -2
  42. package/cjs/components/StepActions/StepActions.js +4 -20
  43. package/cjs/components/SwapButton/SwapButton.js +16 -4
  44. package/cjs/components/SwapInput/FormPriceHelperText.js +1 -1
  45. package/cjs/components/SwapInput/SwapInput.js +2 -2
  46. package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
  47. package/cjs/components/SwapInput/SwapInputEndAdornment.js +2 -2
  48. package/cjs/components/SwapRouteCard/SwapRouteCard.js +19 -3
  49. package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  50. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
  51. package/cjs/components/SwapRoutes/SwapRoutes.js +1 -1
  52. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
  53. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
  54. package/cjs/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
  55. package/cjs/components/Token/Token.js +1 -1
  56. package/cjs/components/TokenAvatar/TokenAvatar.d.ts +4 -4
  57. package/cjs/components/TokenList/TokenList.js +9 -4
  58. package/cjs/components/TokenList/TokenList.style.d.ts +5 -2
  59. package/cjs/components/TokenList/TokenList.style.js +20 -1
  60. package/cjs/components/TokenList/TokenListItem.d.ts +1 -1
  61. package/cjs/components/TokenList/TokenListItem.js +28 -5
  62. package/cjs/components/TokenList/VirtualizedTokenList.js +3 -3
  63. package/cjs/components/TokenList/types.d.ts +6 -3
  64. package/cjs/config/theme.js +15 -3
  65. package/cjs/config/version.d.ts +1 -1
  66. package/cjs/config/version.js +1 -1
  67. package/cjs/hooks/index.d.ts +2 -1
  68. package/cjs/hooks/index.js +2 -1
  69. package/cjs/hooks/useContentHeight.js +3 -5
  70. package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
  71. package/cjs/hooks/useFundsSufficiency.js +2 -2
  72. package/cjs/hooks/useGasRefuel.d.ts +1 -1
  73. package/cjs/hooks/useGasRefuel.js +5 -15
  74. package/cjs/hooks/useGasSufficiency.js +12 -3
  75. package/cjs/hooks/useInitializer.js +0 -1
  76. package/cjs/hooks/useProcessMessage.d.ts +2 -1
  77. package/cjs/hooks/useProcessMessage.js +27 -9
  78. package/cjs/hooks/useRouteExecution.js +6 -5
  79. package/cjs/hooks/useSwapOnly.d.ts +1 -0
  80. package/cjs/hooks/useSwapOnly.js +9 -0
  81. package/cjs/hooks/useSwapRoutes.d.ts +1 -2
  82. package/cjs/hooks/useSwapRoutes.js +32 -18
  83. package/cjs/hooks/useToken.d.ts +1 -1
  84. package/cjs/hooks/useTokenAddressBalance.d.ts +2 -2
  85. package/cjs/hooks/useTokenBalance.js +6 -7
  86. package/cjs/hooks/useTokenBalances.d.ts +5 -5
  87. package/cjs/hooks/useTokenBalances.js +4 -19
  88. package/cjs/hooks/useTokenSearch.d.ts +2 -2
  89. package/cjs/hooks/useTokens.d.ts +2 -2
  90. package/cjs/i18n/bn.json +8 -0
  91. package/cjs/i18n/en.json +30 -5
  92. package/cjs/i18n/fr.json +8 -0
  93. package/cjs/i18n/id.json +22 -7
  94. package/cjs/i18n/ko.json +22 -7
  95. package/cjs/i18n/pt.json +32 -7
  96. package/cjs/i18n/th.json +21 -6
  97. package/cjs/i18n/uk.json +43 -18
  98. package/cjs/i18n/zh.json +23 -8
  99. package/cjs/icons/InsuraceLogo.d.ts +1 -1
  100. package/cjs/icons/LiFiFullLogo.d.ts +1 -1
  101. package/cjs/icons/LiFiLogo.d.ts +1 -1
  102. package/cjs/icons/LiFiToolLogo.d.ts +1 -1
  103. package/cjs/index.d.ts +1 -1
  104. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
  105. package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
  106. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +3 -1
  107. package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
  108. package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
  109. package/cjs/pages/SettingsPage/LanguageSelect.js +1 -1
  110. package/cjs/pages/SettingsPage/SettingsPage.d.ts +1 -2
  111. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
  112. package/cjs/pages/SettingsPage/SlippageInput.d.ts +1 -2
  113. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
  114. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -1
  115. package/cjs/pages/SwapPage/StatusBottomSheet.js +15 -9
  116. package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
  117. package/cjs/pages/SwapPage/StatusBottomSheet.style.js +2 -2
  118. package/cjs/pages/SwapPage/SwapPage.js +31 -10
  119. package/cjs/pages/SwapPage/TokenValueBottomSheet.js +7 -12
  120. package/cjs/pages/SwapPage/utils.d.ts +2 -0
  121. package/cjs/pages/SwapPage/utils.js +10 -0
  122. package/cjs/providers/I18nProvider/I18nProvider.js +3 -3
  123. package/cjs/providers/SDKProvider/SDKProvider.js +2 -0
  124. package/cjs/providers/SwapFormProvider/FormUpdater.js +3 -0
  125. package/cjs/providers/WalletProvider/WalletProvider.js +77 -49
  126. package/cjs/providers/WalletProvider/types.d.ts +3 -5
  127. package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -1
  128. package/cjs/stores/StoreProvider.d.ts +2 -2
  129. package/cjs/stores/StoreProvider.js +3 -2
  130. package/cjs/stores/routes/RouteExecutionStore.d.ts +1 -1
  131. package/cjs/stores/routes/RouteExecutionStore.js +0 -1
  132. package/cjs/stores/settings/index.d.ts +1 -0
  133. package/cjs/stores/settings/index.js +1 -0
  134. package/cjs/stores/settings/types.d.ts +11 -0
  135. package/cjs/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  136. package/cjs/stores/settings/useSplitSubvariantStore.js +44 -0
  137. package/cjs/types/events.d.ts +9 -1
  138. package/cjs/types/events.js +1 -0
  139. package/cjs/types/token.d.ts +2 -2
  140. package/cjs/types/widget.d.ts +13 -8
  141. package/cjs/types/widget.js +4 -2
  142. package/cjs/utils/format.d.ts +1 -1
  143. package/cjs/utils/format.js +7 -12
  144. package/cjs/utils/wallet.d.ts +1 -1
  145. package/cjs/utils/wallet.js +3 -3
  146. package/components/ChainSelect/ChainSelect.d.ts +1 -2
  147. package/components/ChainSelect/ChainSelect.style.js +1 -1
  148. package/components/ChainSelect/useChainSelect.js +7 -1
  149. package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
  150. package/components/GasMessage/GasMessage.js +2 -7
  151. package/components/Header/Header.js +3 -3
  152. package/components/Header/Header.style.d.ts +10 -3
  153. package/components/Header/Header.style.js +3 -0
  154. package/components/Header/NavigationHeader.js +23 -7
  155. package/components/Header/NavigationTabs.d.ts +1 -0
  156. package/components/Header/NavigationTabs.js +22 -0
  157. package/components/Header/NavigationTabs.style.d.ts +34 -0
  158. package/components/Header/NavigationTabs.style.js +58 -0
  159. package/components/Header/WalletHeader.d.ts +1 -0
  160. package/components/Header/WalletHeader.js +14 -8
  161. package/components/Header/useHeaderActionStore.js +0 -1
  162. package/components/Insurance/Insurance.js +2 -2
  163. package/components/Insurance/InsuranceCard.js +37 -15
  164. package/components/Insurance/InsuranceCollapsed.js +9 -11
  165. package/components/Insurance/index.d.ts +1 -0
  166. package/components/Insurance/index.js +1 -0
  167. package/components/Insurance/types.d.ts +12 -9
  168. package/components/NFT/NFT.js +2 -2
  169. package/components/NFT/types.d.ts +1 -1
  170. package/components/PoweredBy/PoweredBy.js +2 -3
  171. package/components/SelectChainAndToken.js +9 -8
  172. package/components/SelectTokenButton/SelectTokenButton.js +7 -4
  173. package/components/SendToWallet/SendToWallet.js +2 -2
  174. package/components/SmallAvatar.d.ts +1 -1
  175. package/components/Step/CircularProgress.d.ts +1 -2
  176. package/components/Step/Step.js +16 -6
  177. package/components/Step/StepList.d.ts +1 -2
  178. package/components/StepActions/StepActions.js +4 -20
  179. package/components/SwapButton/SwapButton.js +16 -4
  180. package/components/SwapInput/FormPriceHelperText.js +2 -2
  181. package/components/SwapInput/SwapInput.js +3 -3
  182. package/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
  183. package/components/SwapInput/SwapInputEndAdornment.js +2 -2
  184. package/components/SwapRouteCard/SwapRouteCard.js +21 -5
  185. package/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  186. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
  187. package/components/SwapRoutes/SwapRoutes.js +1 -1
  188. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
  189. package/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
  190. package/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
  191. package/components/Token/Token.js +1 -1
  192. package/components/TokenAvatar/TokenAvatar.d.ts +4 -4
  193. package/components/TokenList/TokenList.js +10 -5
  194. package/components/TokenList/TokenList.style.d.ts +5 -2
  195. package/components/TokenList/TokenList.style.js +21 -2
  196. package/components/TokenList/TokenListItem.d.ts +1 -1
  197. package/components/TokenList/TokenListItem.js +32 -9
  198. package/components/TokenList/VirtualizedTokenList.js +3 -3
  199. package/components/TokenList/types.d.ts +6 -3
  200. package/config/theme.js +15 -3
  201. package/config/version.d.ts +1 -1
  202. package/config/version.js +1 -1
  203. package/hooks/index.d.ts +2 -1
  204. package/hooks/index.js +2 -1
  205. package/hooks/useContentHeight.js +4 -6
  206. package/hooks/useFeaturedTokens.d.ts +1 -1
  207. package/hooks/useFundsSufficiency.js +2 -2
  208. package/hooks/useGasRefuel.d.ts +1 -1
  209. package/hooks/useGasRefuel.js +5 -15
  210. package/hooks/useGasSufficiency.js +13 -4
  211. package/hooks/useInitializer.js +0 -1
  212. package/hooks/useProcessMessage.d.ts +2 -1
  213. package/hooks/useProcessMessage.js +27 -9
  214. package/hooks/useRouteExecution.js +6 -5
  215. package/hooks/useSwapOnly.d.ts +1 -0
  216. package/hooks/useSwapOnly.js +5 -0
  217. package/hooks/useSwapRoutes.d.ts +1 -2
  218. package/hooks/useSwapRoutes.js +32 -18
  219. package/hooks/useToken.d.ts +1 -1
  220. package/hooks/useTokenAddressBalance.d.ts +2 -2
  221. package/hooks/useTokenBalance.js +6 -7
  222. package/hooks/useTokenBalances.d.ts +5 -5
  223. package/hooks/useTokenBalances.js +4 -19
  224. package/hooks/useTokenSearch.d.ts +2 -2
  225. package/hooks/useTokens.d.ts +2 -2
  226. package/i18n/bn.json +8 -0
  227. package/i18n/en.json +30 -5
  228. package/i18n/fr.json +8 -0
  229. package/i18n/id.json +22 -7
  230. package/i18n/ko.json +22 -7
  231. package/i18n/pt.json +32 -7
  232. package/i18n/th.json +21 -6
  233. package/i18n/uk.json +43 -18
  234. package/i18n/zh.json +23 -8
  235. package/icons/InsuraceLogo.d.ts +1 -1
  236. package/icons/LiFiFullLogo.d.ts +1 -1
  237. package/icons/LiFiLogo.d.ts +1 -1
  238. package/icons/LiFiToolLogo.d.ts +1 -1
  239. package/index.d.ts +1 -1
  240. package/package.json +13 -13
  241. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
  242. package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
  243. package/pages/SelectTokenPage/SelectTokenPage.js +4 -2
  244. package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
  245. package/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
  246. package/pages/SettingsPage/LanguageSelect.js +1 -1
  247. package/pages/SettingsPage/SettingsPage.d.ts +1 -2
  248. package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
  249. package/pages/SettingsPage/SlippageInput.d.ts +1 -2
  250. package/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
  251. package/pages/SwapPage/ExchangeRateBottomSheet.js +2 -2
  252. package/pages/SwapPage/StatusBottomSheet.js +18 -12
  253. package/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
  254. package/pages/SwapPage/StatusBottomSheet.style.js +1 -1
  255. package/pages/SwapPage/SwapPage.js +33 -12
  256. package/pages/SwapPage/TokenValueBottomSheet.js +8 -13
  257. package/pages/SwapPage/utils.d.ts +2 -0
  258. package/pages/SwapPage/utils.js +6 -0
  259. package/providers/I18nProvider/I18nProvider.js +3 -3
  260. package/providers/SDKProvider/SDKProvider.js +2 -0
  261. package/providers/SwapFormProvider/FormUpdater.js +3 -0
  262. package/providers/WalletProvider/WalletProvider.js +78 -50
  263. package/providers/WalletProvider/types.d.ts +3 -5
  264. package/providers/WidgetProvider/WidgetProvider.js +2 -2
  265. package/stores/StoreProvider.d.ts +2 -2
  266. package/stores/StoreProvider.js +3 -2
  267. package/stores/routes/RouteExecutionStore.d.ts +1 -1
  268. package/stores/routes/RouteExecutionStore.js +0 -1
  269. package/stores/settings/index.d.ts +1 -0
  270. package/stores/settings/index.js +1 -0
  271. package/stores/settings/types.d.ts +11 -0
  272. package/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  273. package/stores/settings/useSplitSubvariantStore.js +37 -0
  274. package/tsconfig.cjs.tsbuildinfo +1 -1
  275. package/types/events.d.ts +9 -1
  276. package/types/events.js +1 -0
  277. package/types/token.d.ts +2 -2
  278. package/types/widget.d.ts +13 -8
  279. package/types/widget.js +4 -2
  280. package/utils/format.d.ts +1 -1
  281. package/utils/format.js +5 -10
  282. package/utils/wallet.d.ts +1 -1
  283. package/utils/wallet.js +1 -1
@@ -24,19 +24,6 @@ const WalletProvider = ({ children }) => {
24
24
  const { walletManagement } = (0, WidgetProvider_1.useWidgetConfig)();
25
25
  const [account, setAccount] = (0, react_1.useState)({});
26
26
  const [currentWallet, setCurrentWallet] = (0, react_1.useState)();
27
- (0, react_1.useEffect)(() => {
28
- const autoConnect = async () => {
29
- const persistedActiveWallets = (0, wallet_management_1.readActiveWallets)();
30
- const activeWallets = wallet_management_1.supportedWallets.filter((wallet) => persistedActiveWallets.some((perstistedWallet) => perstistedWallet.name === wallet.name));
31
- if (!activeWallets.length) {
32
- return;
33
- }
34
- await liFiWalletManagement.autoConnect(activeWallets);
35
- activeWallets[0].on('walletAccountChanged', handleWalletUpdate);
36
- handleWalletUpdate(activeWallets[0]);
37
- };
38
- autoConnect();
39
- }, []);
40
27
  const handleWalletUpdate = async (wallet) => {
41
28
  setCurrentWallet(wallet);
42
29
  const account = await (0, exports.extractAccountFromSigner)(wallet?.account?.signer);
@@ -64,54 +51,104 @@ const WalletProvider = ({ children }) => {
64
51
  currentWallet.removeAllListeners();
65
52
  handleWalletUpdate(undefined);
66
53
  }
67
- }, [walletManagement, currentWallet]);
54
+ }, [currentWallet, walletManagement]);
68
55
  const switchChain = (0, react_1.useCallback)(async (chainId) => {
69
- if (walletManagement?.switchChain) {
70
- const signer = await walletManagement.switchChain(chainId);
71
- const account = await (0, exports.extractAccountFromSigner)(signer);
72
- setAccount(account);
73
- return true;
74
- }
75
56
  try {
76
- await currentWallet?.switchChain(chainId);
77
- handleWalletUpdate(currentWallet);
78
- return true;
57
+ if (walletManagement?.switchChain) {
58
+ const signer = await walletManagement.switchChain(chainId);
59
+ const account = await (0, exports.extractAccountFromSigner)(signer);
60
+ setAccount(account);
61
+ return signer;
62
+ }
63
+ else if (!currentWallet) {
64
+ const provider = account.signer?.provider;
65
+ if (!provider) {
66
+ throw new Error(`Switch chain: No provider available`);
67
+ }
68
+ await (0, wallet_management_1.switchChain)(provider, chainId);
69
+ }
70
+ else {
71
+ await currentWallet?.switchChain(chainId);
72
+ handleWalletUpdate(currentWallet);
73
+ }
74
+ // TODO: this will fail if it's not created with ethers 'any' network, replace with the new signer when possible
75
+ return account.signer;
79
76
  }
80
77
  catch {
81
- return false;
78
+ return account.signer;
82
79
  }
83
- }, [walletManagement, currentWallet]);
80
+ }, [account.signer, currentWallet, walletManagement]);
84
81
  const addChain = (0, react_1.useCallback)(async (chainId) => {
85
- if (walletManagement?.addChain) {
86
- return walletManagement.addChain(chainId);
87
- }
88
82
  try {
89
- await currentWallet?.addChain(chainId);
90
- handleWalletUpdate(currentWallet);
83
+ if (walletManagement?.addChain) {
84
+ return walletManagement.addChain(chainId);
85
+ }
86
+ else if (!currentWallet) {
87
+ const provider = account.signer?.provider;
88
+ if (!provider) {
89
+ throw new Error(`Add chain: No provider available`);
90
+ }
91
+ await (0, wallet_management_1.addChain)(provider, chainId);
92
+ }
93
+ else {
94
+ await currentWallet?.addChain(chainId);
95
+ handleWalletUpdate(currentWallet);
96
+ }
91
97
  return true;
92
98
  }
93
99
  catch {
94
100
  return false;
95
101
  }
96
- }, [walletManagement, currentWallet]);
102
+ }, [account.signer?.provider, currentWallet, walletManagement]);
97
103
  const addToken = (0, react_1.useCallback)(async (chainId, token) => {
98
- if (walletManagement?.addToken) {
99
- return walletManagement.addToken(token, chainId);
104
+ try {
105
+ if (walletManagement?.addToken) {
106
+ return walletManagement.addToken(token, chainId);
107
+ }
108
+ else if (!currentWallet) {
109
+ const provider = account.signer?.provider;
110
+ if (!provider) {
111
+ throw new Error(`Add token: No provider available`);
112
+ }
113
+ await (0, wallet_management_1.switchChainAndAddToken)(provider, chainId, token);
114
+ }
115
+ else {
116
+ await currentWallet?.addToken(chainId, token);
117
+ handleWalletUpdate(currentWallet);
118
+ }
100
119
  }
101
- await currentWallet?.addToken(chainId, token);
102
- handleWalletUpdate(currentWallet);
103
- return;
104
- }, [walletManagement, currentWallet]);
120
+ catch { }
121
+ }, [account.signer?.provider, currentWallet, walletManagement]);
122
+ (0, react_1.useEffect)(() => {
123
+ const autoConnect = async () => {
124
+ const persistedActiveWallets = (0, wallet_management_1.readActiveWallets)();
125
+ const activeWallets = wallet_management_1.supportedWallets.filter((wallet) => persistedActiveWallets.some((perstistedWallet) => perstistedWallet.name === wallet.name));
126
+ if (!activeWallets.length) {
127
+ return;
128
+ }
129
+ await liFiWalletManagement.autoConnect(activeWallets);
130
+ activeWallets[0].on('walletAccountChanged', handleWalletUpdate);
131
+ handleWalletUpdate(activeWallets[0]);
132
+ };
133
+ autoConnect();
134
+ }, []);
105
135
  // keep widget in sync with changing external signer object
106
136
  (0, react_1.useEffect)(() => {
107
137
  if (walletManagement) {
138
+ let ignore = false;
108
139
  const updateAccount = async () => {
109
140
  const account = await (0, exports.extractAccountFromSigner)(walletManagement?.signer);
110
- setAccount(account);
141
+ // we should ignore the update if there is a newer one
142
+ if (!ignore) {
143
+ setAccount(account);
144
+ }
111
145
  };
112
146
  updateAccount();
147
+ return () => {
148
+ ignore = true;
149
+ };
113
150
  }
114
- }, [walletManagement, walletManagement?.signer]);
151
+ }, [walletManagement]);
115
152
  const value = (0, react_1.useMemo)(() => ({
116
153
  connect,
117
154
  disconnect,
@@ -119,16 +156,7 @@ const WalletProvider = ({ children }) => {
119
156
  addChain,
120
157
  addToken,
121
158
  account,
122
- provider: currentWallet?.account?.provider,
123
- }), [
124
- account,
125
- addChain,
126
- addToken,
127
- connect,
128
- disconnect,
129
- currentWallet,
130
- switchChain,
131
- ]);
159
+ }), [account, addChain, addToken, connect, disconnect, switchChain]);
132
160
  return ((0, jsx_runtime_1.jsx)(WalletContext.Provider, { value: value, children: children }));
133
161
  };
134
162
  exports.WalletProvider = WalletProvider;
@@ -1,14 +1,12 @@
1
1
  import type { Signer } from '@ethersproject/abstract-signer';
2
- import type { Provider } from '@ethersproject/providers';
3
- import type { Token } from '@lifi/sdk';
2
+ import type { StaticToken } from '@lifi/sdk';
4
3
  import type { Wallet } from '@lifi/wallet-management';
5
4
  export interface WalletContextProps {
6
5
  account: WalletAccount;
7
- provider?: Provider;
8
6
  addChain(chainId: number): Promise<boolean>;
9
- addToken(chainId: number, token: Token): Promise<void>;
7
+ addToken(chainId: number, token: StaticToken): Promise<void>;
10
8
  disconnect(wallet?: Wallet): void;
11
- switchChain(chainId: number): Promise<boolean>;
9
+ switchChain(chainId: number): Promise<Signer | undefined>;
12
10
  connect(wallet?: Wallet | undefined): Promise<void>;
13
11
  }
14
12
  export interface WalletAccount {
@@ -50,7 +50,7 @@ const WidgetProvider = ({ children, config: { fromChain, fromToken, toChain, toT
50
50
  toToken: searchParams.toToken?.toLowerCase() || toToken?.toLowerCase(),
51
51
  fromAmount: typeof searchParams.fromAmount === 'string' &&
52
52
  !isNaN(parseFloat(searchParams.fromAmount))
53
- ? (0, utils_1.formatAmount)(searchParams.fromAmount)
53
+ ? (0, utils_1.formatInputAmount)(searchParams.fromAmount)
54
54
  : fromAmount,
55
55
  elementId,
56
56
  integrator,
@@ -1,3 +1,3 @@
1
1
  import type { PropsWithChildren } from 'react';
2
- import type { PersistStoreProviderProps } from './types';
3
- export declare const StoreProvider: React.FC<PropsWithChildren<PersistStoreProviderProps>>;
2
+ import type { WidgetConfigProps } from '../types';
3
+ export declare const StoreProvider: React.FC<PropsWithChildren<WidgetConfigProps>>;
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StoreProvider = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const routes_1 = require("./routes");
6
- const StoreProvider = ({ children, namePrefix }) => {
7
- return ((0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, { namePrefix: namePrefix, children: children }));
6
+ const settings_1 = require("./settings");
7
+ const StoreProvider = ({ children, config, }) => {
8
+ return ((0, jsx_runtime_1.jsx)(settings_1.SplitSubvariantStoreProvider, { state: config.subvariant === 'split' ? 'swap' : undefined, children: (0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, { namePrefix: config?.localStorageKeyPrefix, children: children }) }));
8
9
  };
9
10
  exports.StoreProvider = StoreProvider;
@@ -4,6 +4,6 @@ import type { PersistStoreProviderProps } from '../types';
4
4
  import type { RouteExecutionState } from './types';
5
5
  export type RouteExecutionStore = UseBoundStore<StoreApi<RouteExecutionState>>;
6
6
  export declare const RouteExecutionStoreContext: import("react").Context<RouteExecutionStore | null>;
7
- export declare function RouteExecutionStoreProvider({ children, ...props }: PersistStoreProviderProps): JSX.Element;
7
+ export declare function RouteExecutionStoreProvider({ children, ...props }: PersistStoreProviderProps): import("react/jsx-runtime").JSX.Element;
8
8
  export declare function useRouteExecutionStore<T>(selector: (state: RouteExecutionState) => T, equalityFn?: (left: T, right: T) => boolean): T;
9
9
  export declare function useRouteExecutionStoreContext(): RouteExecutionStore;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useRouteExecutionStoreContext = exports.useRouteExecutionStore = exports.RouteExecutionStoreProvider = exports.RouteExecutionStoreContext = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- /* eslint-disable no-underscore-dangle */
6
5
  const react_1 = require("react");
7
6
  const createRouteExecutionStore_1 = require("./createRouteExecutionStore");
8
7
  exports.RouteExecutionStoreContext = (0, react_1.createContext)(null);
@@ -3,3 +3,4 @@ export * from './useAppearance';
3
3
  export * from './useSendToWalletStore';
4
4
  export * from './useSettings';
5
5
  export * from './useSettingsStore';
6
+ export * from './useSplitSubvariantStore';
@@ -19,3 +19,4 @@ __exportStar(require("./useAppearance"), exports);
19
19
  __exportStar(require("./useSendToWalletStore"), exports);
20
20
  __exportStar(require("./useSettings"), exports);
21
21
  __exportStar(require("./useSettingsStore"), exports);
22
+ __exportStar(require("./useSplitSubvariantStore"), exports);
@@ -1,4 +1,6 @@
1
1
  import type { Order } from '@lifi/sdk';
2
+ import type { PropsWithChildren } from 'react';
3
+ import type { StoreApi, UseBoundStore } from 'zustand';
2
4
  import type { Appearance, WidgetConfig } from '../../types';
3
5
  export type ValueSetter<S> = <K extends keyof S>(key: K, value: S[Extract<K, string>]) => void;
4
6
  export type ValuesSetter<S> = <K extends keyof S>(values: Record<K, S[Extract<K, string>]>) => void;
@@ -32,3 +34,12 @@ export interface SendToWalletStore extends SendToWalletState {
32
34
  toggleSendToWallet(): void;
33
35
  setSendToWallet(value: boolean): void;
34
36
  }
37
+ export interface SplitSubvariantState {
38
+ state?: 'swap' | 'bridge';
39
+ setState(state: 'swap' | 'bridge'): void;
40
+ }
41
+ export type SplitSubvariantStore = UseBoundStore<StoreApi<SplitSubvariantState>>;
42
+ export interface SplitSubvariantProps {
43
+ state?: 'swap' | 'bridge';
44
+ }
45
+ export type SplitSubvariantProviderProps = PropsWithChildren<SplitSubvariantProps>;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { SplitSubvariantProps, SplitSubvariantProviderProps, SplitSubvariantState, SplitSubvariantStore } from './types';
3
+ export declare const SplitSubvariantStoreContext: import("react").Context<SplitSubvariantStore | null>;
4
+ export declare function SplitSubvariantStoreProvider({ children, ...props }: SplitSubvariantProviderProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function useSplitSubvariantStore<T>(selector: (state: SplitSubvariantState) => T, equalityFn?: (left: T, right: T) => boolean): T;
6
+ export declare function useSplitSubvariantStoreContext(): SplitSubvariantStore;
7
+ export declare const createSplitSubvariantStore: ({ state }: SplitSubvariantProps) => import("zustand").UseBoundStore<import("zustand").StoreApi<SplitSubvariantState>>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSplitSubvariantStore = exports.useSplitSubvariantStoreContext = exports.useSplitSubvariantStore = exports.SplitSubvariantStoreProvider = exports.SplitSubvariantStoreContext = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const zustand_1 = require("zustand");
7
+ exports.SplitSubvariantStoreContext = (0, react_1.createContext)(null);
8
+ const shouldRecreateStore = (store, props) => {
9
+ const { state } = store.getState();
10
+ return (!state && props.state) || (state && !props.state);
11
+ };
12
+ function SplitSubvariantStoreProvider({ children, ...props }) {
13
+ const storeRef = (0, react_1.useRef)();
14
+ if (!storeRef.current || shouldRecreateStore(storeRef.current, props)) {
15
+ storeRef.current = (0, exports.createSplitSubvariantStore)(props);
16
+ }
17
+ return ((0, jsx_runtime_1.jsx)(exports.SplitSubvariantStoreContext.Provider, { value: storeRef.current, children: children }));
18
+ }
19
+ exports.SplitSubvariantStoreProvider = SplitSubvariantStoreProvider;
20
+ function useSplitSubvariantStore(selector, equalityFn) {
21
+ const useStore = (0, react_1.useContext)(exports.SplitSubvariantStoreContext);
22
+ if (!useStore) {
23
+ throw new Error(`You forgot to wrap your component in <${SplitSubvariantStoreProvider.name}>.`);
24
+ }
25
+ return useStore(selector, equalityFn);
26
+ }
27
+ exports.useSplitSubvariantStore = useSplitSubvariantStore;
28
+ function useSplitSubvariantStoreContext() {
29
+ const useStore = (0, react_1.useContext)(exports.SplitSubvariantStoreContext);
30
+ if (!useStore) {
31
+ throw new Error(`You forgot to wrap your component in <${SplitSubvariantStoreProvider.name}>.`);
32
+ }
33
+ return useStore;
34
+ }
35
+ exports.useSplitSubvariantStoreContext = useSplitSubvariantStoreContext;
36
+ const createSplitSubvariantStore = ({ state }) => (0, zustand_1.create)((set) => ({
37
+ state,
38
+ setState(state) {
39
+ set(() => ({
40
+ state,
41
+ }));
42
+ },
43
+ }));
44
+ exports.createSplitSubvariantStore = createSplitSubvariantStore;
@@ -3,13 +3,21 @@ export declare enum WidgetEvent {
3
3
  RouteExecutionStarted = "routeExecutionStarted",
4
4
  RouteExecutionUpdated = "routeExecutionUpdated",
5
5
  RouteExecutionCompleted = "routeExecutionCompleted",
6
- RouteExecutionFailed = "routeExecutionFailed"
6
+ RouteExecutionFailed = "routeExecutionFailed",
7
+ RouteHighValueLoss = "routeHighValueLoss"
8
+ }
9
+ export interface RouteHighValueLossUpdate {
10
+ fromAmountUsd: string;
11
+ gasCostUSD: string | undefined;
12
+ toAmountUSD: string;
13
+ valueLoss: string;
7
14
  }
8
15
  export type WidgetEvents = {
9
16
  routeExecutionStarted: Route;
10
17
  routeExecutionUpdated: RouteExecutionUpdate;
11
18
  routeExecutionCompleted: Route;
12
19
  routeExecutionFailed: RouteExecutionUpdate;
20
+ routeHighValueLoss: RouteHighValueLossUpdate;
13
21
  };
14
22
  export interface RouteExecutionUpdate {
15
23
  route: Route;
@@ -7,4 +7,5 @@ var WidgetEvent;
7
7
  WidgetEvent["RouteExecutionUpdated"] = "routeExecutionUpdated";
8
8
  WidgetEvent["RouteExecutionCompleted"] = "routeExecutionCompleted";
9
9
  WidgetEvent["RouteExecutionFailed"] = "routeExecutionFailed";
10
+ WidgetEvent["RouteHighValueLoss"] = "routeHighValueLoss";
10
11
  })(WidgetEvent = exports.WidgetEvent || (exports.WidgetEvent = {}));
@@ -1,4 +1,4 @@
1
- import type { TokenAmount } from '@lifi/sdk';
2
- export interface Token extends TokenAmount {
1
+ import type { TokenAmount as SDKTokenAmount } from '@lifi/sdk';
2
+ export interface TokenAmount extends SDKTokenAmount {
3
3
  featured?: boolean;
4
4
  }
@@ -1,10 +1,11 @@
1
1
  import type { Signer } from '@ethersproject/abstract-signer';
2
- import type { ChainKey, ConfigUpdate, Order, RouteOptions, Token } from '@lifi/sdk';
2
+ import type { BaseToken, ChainKey, ConfigUpdate, Order, RouteOptions, StaticToken } from '@lifi/sdk';
3
3
  import type { Components, PaletteMode, PaletteOptions, Shape, Theme } from '@mui/material';
4
4
  import type { TypographyOptions } from '@mui/material/styles/createTypography';
5
5
  import type { CSSProperties, ReactNode, RefObject } from 'react';
6
6
  import type { LanguageKey, LanguageResources } from '../providers';
7
7
  export type WidgetVariant = 'default' | 'expandable' | 'drawer' | 'refuel' | 'nft';
8
+ export type WidgetSubvariant = 'default' | 'split';
8
9
  export declare enum DisabledUI {
9
10
  FromAmount = "fromAmount",
10
11
  FromToken = "fromToken",
@@ -14,9 +15,13 @@ export declare enum DisabledUI {
14
15
  export type DisabledUIType = `${DisabledUI}`;
15
16
  export declare enum HiddenUI {
16
17
  Appearance = "appearance",
18
+ DrawerButton = "drawerButton",
19
+ History = "history",
17
20
  Language = "language",
18
21
  PoweredBy = "poweredBy",
19
- ToAddress = "toAddress"
22
+ ToAddress = "toAddress",
23
+ ToToken = "toToken",
24
+ WalletMenu = "walletMenu"
20
25
  }
21
26
  export type HiddenUIType = `${HiddenUI}`;
22
27
  export declare enum RequiredUI {
@@ -34,7 +39,7 @@ export interface WidgetWalletManagement {
34
39
  connect(): Promise<Signer>;
35
40
  disconnect(): Promise<void>;
36
41
  switchChain?(chainId: number): Promise<Signer>;
37
- addToken?(token: Token, chainId: number): Promise<void>;
42
+ addToken?(token: StaticToken, chainId: number): Promise<void>;
38
43
  addChain?(chainId: number): Promise<boolean>;
39
44
  signer?: Signer;
40
45
  }
@@ -72,10 +77,10 @@ export interface WidgetConfig {
72
77
  slippage?: number;
73
78
  insurance?: boolean;
74
79
  variant?: WidgetVariant;
80
+ subvariant?: WidgetSubvariant;
75
81
  appearance?: Appearance;
76
82
  theme?: ThemeConfig;
77
83
  containerStyle?: CSSProperties;
78
- disableTelemetry?: boolean;
79
84
  disabledUI?: DisabledUIType[];
80
85
  hiddenUI?: HiddenUIType[];
81
86
  requiredUI?: RequiredUIType[];
@@ -97,9 +102,9 @@ export interface WidgetConfig {
97
102
  deny?: number[];
98
103
  };
99
104
  tokens?: {
100
- featured?: Token[];
101
- allow?: Token[];
102
- deny?: (Partial<Token> & Pick<Token, 'address' | 'chainId'>)[];
105
+ featured?: StaticToken[];
106
+ allow?: BaseToken[];
107
+ deny?: BaseToken[];
103
108
  };
104
109
  languages?: {
105
110
  default?: LanguageKey;
@@ -107,7 +112,7 @@ export interface WidgetConfig {
107
112
  deny?: LanguageKey[];
108
113
  };
109
114
  languageResources?: LanguageResources;
110
- disableI18n?: boolean;
115
+ disableLanguageDetector?: boolean;
111
116
  }
112
117
  export type WidgetDrawerProps = {
113
118
  elementRef?: RefObject<HTMLDivElement>;
@@ -11,11 +11,13 @@ var DisabledUI;
11
11
  var HiddenUI;
12
12
  (function (HiddenUI) {
13
13
  HiddenUI["Appearance"] = "appearance";
14
- // FromAmount = 'fromAmount',
14
+ HiddenUI["DrawerButton"] = "drawerButton";
15
+ HiddenUI["History"] = "history";
15
16
  HiddenUI["Language"] = "language";
16
17
  HiddenUI["PoweredBy"] = "poweredBy";
17
18
  HiddenUI["ToAddress"] = "toAddress";
18
- // ToToken = 'toToken',
19
+ HiddenUI["ToToken"] = "toToken";
20
+ HiddenUI["WalletMenu"] = "walletMenu";
19
21
  })(HiddenUI = exports.HiddenUI || (exports.HiddenUI = {}));
20
22
  var RequiredUI;
21
23
  (function (RequiredUI) {
@@ -5,5 +5,5 @@
5
5
  */
6
6
  export declare const formatTokenAmount: (amount?: string, decimals?: number, decimalPlaces?: number) => string;
7
7
  export declare const formatSlippage: (slippage?: string, defaultValue?: string, returnInitial?: boolean) => string;
8
- export declare const formatAmount: (amount?: string, returnInitial?: boolean) => string;
8
+ export declare const formatInputAmount: (amount: string, returnInitial?: boolean) => string;
9
9
  export declare const formatTokenPrice: (amount?: string, price?: string) => number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatTokenPrice = exports.formatAmount = exports.formatSlippage = exports.formatTokenAmount = void 0;
3
+ exports.formatTokenPrice = exports.formatInputAmount = exports.formatSlippage = exports.formatTokenAmount = void 0;
4
4
  const big_js_1 = require("big.js");
5
5
  // JavaScript numbers use exponential notation for positive exponents of 21 and above. We need more.
6
6
  big_js_1.default.PE = 42;
@@ -24,7 +24,7 @@ const formatTokenAmount = (amount = '0', decimals = 0, decimalPlaces = 3) => {
24
24
  while (absAmount < 1 / 10 ** decimalPlaces) {
25
25
  decimalPlaces++;
26
26
  }
27
- return (0, big_js_1.default)(parseFloat((0, big_js_1.default)(parsedAmount).toFixed(decimalPlaces + 1, 0))).toString();
27
+ return (0, big_js_1.default)(parsedAmount).toFixed(decimalPlaces + 1, 0);
28
28
  };
29
29
  exports.formatTokenAmount = formatTokenAmount;
30
30
  const formatSlippage = (slippage = '', defaultValue = '', returnInitial = false) => {
@@ -50,7 +50,7 @@ const formatSlippage = (slippage = '', defaultValue = '', returnInitial = false)
50
50
  return parsedSlippage.toString();
51
51
  };
52
52
  exports.formatSlippage = formatSlippage;
53
- const formatAmount = (amount = '', returnInitial = false) => {
53
+ const formatInputAmount = (amount, returnInitial = false) => {
54
54
  if (!amount) {
55
55
  return amount;
56
56
  }
@@ -62,23 +62,18 @@ const formatAmount = (amount = '', returnInitial = false) => {
62
62
  if (isNaN(Number(formattedAmount)) && !isNaN(parsedAmount)) {
63
63
  return parsedAmount.toString();
64
64
  }
65
- if (isNaN(parsedAmount)) {
66
- return '';
67
- }
68
- if (parsedAmount < 0) {
69
- return Math.abs(parsedAmount).toString();
70
- }
71
65
  try {
72
- if (returnInitial && (0, big_js_1.default)(formattedAmount)) {
66
+ const absFormattedAmount = (0, big_js_1.default)(formattedAmount).abs();
67
+ if (returnInitial) {
73
68
  return formattedAmount;
74
69
  }
70
+ return absFormattedAmount.toString();
75
71
  }
76
72
  catch {
77
73
  return '';
78
74
  }
79
- return (0, big_js_1.default)(parsedAmount).toString();
80
75
  };
81
- exports.formatAmount = formatAmount;
76
+ exports.formatInputAmount = formatInputAmount;
82
77
  const formatTokenPrice = (amount, price) => {
83
78
  if (!amount || !price) {
84
79
  return 0;
@@ -1 +1 @@
1
- export declare const shortenWalletAddress: (address?: string) => string | null;
1
+ export declare const shortenAddress: (address?: string) => string | null;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shortenWalletAddress = void 0;
4
- const shortenWalletAddress = (address) => address
3
+ exports.shortenAddress = void 0;
4
+ const shortenAddress = (address) => address
5
5
  ? `${address.substring(0, 5)}...${address.substring(address.length - 4)}`
6
6
  : null;
7
- exports.shortenWalletAddress = shortenWalletAddress;
7
+ exports.shortenAddress = shortenAddress;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { SwapFormTypeProps } from '../../providers';
3
- export declare const ChainSelect: ({ formType }: SwapFormTypeProps) => JSX.Element;
2
+ export declare const ChainSelect: ({ formType }: SwapFormTypeProps) => import("react/jsx-runtime").JSX.Element;
@@ -9,7 +9,7 @@ export const ChainCard = styled(Card)({
9
9
  });
10
10
  export const ChainContainer = styled(Box)(({ theme }) => ({
11
11
  display: 'grid',
12
- gridTemplateColumns: 'repeat(5, 1fr)',
12
+ gridTemplateColumns: 'repeat(auto-fit, minmax(52px, 1fr))',
13
13
  gridAutoRows: '56px',
14
14
  justifyContent: 'space-between',
15
15
  gap: theme.spacing(1.5),
@@ -1,5 +1,5 @@
1
1
  import { useController, useFormContext } from 'react-hook-form';
2
- import { useChains } from '../../hooks';
2
+ import { useChains, useSwapOnly } from '../../hooks';
3
3
  import { SwapFormKey, SwapFormKeyHelper } from '../../providers';
4
4
  import { useChainOrder } from '../../stores';
5
5
  export const useChainSelect = (formType) => {
@@ -8,6 +8,7 @@ export const useChainSelect = (formType) => {
8
8
  const { setValue } = useFormContext();
9
9
  const { chains, isLoading } = useChains();
10
10
  const [chainOrder, setChainOrder] = useChainOrder();
11
+ const swapOnly = useSwapOnly();
11
12
  const getChains = () => {
12
13
  if (!chains) {
13
14
  return [];
@@ -20,6 +21,11 @@ export const useChainSelect = (formType) => {
20
21
  const setCurrentChain = (chainId) => {
21
22
  onChange(chainId);
22
23
  onBlur();
24
+ if (swapOnly) {
25
+ setValue(SwapFormKeyHelper.getChainKey('to'), chainId, {
26
+ shouldTouch: true,
27
+ });
28
+ }
23
29
  setValue(SwapFormKeyHelper.getTokenKey(formType), '');
24
30
  setValue(SwapFormKeyHelper.getAmountKey(formType), '');
25
31
  setValue(SwapFormKey.TokenSearchFilter, '');
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
- export declare const FundsSufficiencyMessage: () => JSX.Element;
1
+ export declare const FundsSufficiencyMessage: () => import("react/jsx-runtime").JSX.Element;
@@ -1,15 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Box, Collapse } from '@mui/material';
3
- import { useFundsSufficiency, useGasRefuel, useGasSufficiency, } from '../../hooks';
4
- import { useSettings } from '../../stores';
3
+ import { useFundsSufficiency, useGasSufficiency } from '../../hooks';
5
4
  import { FundsSufficiencyMessage } from './FundsSufficiencyMessage';
6
5
  import { GasSufficiencyMessage } from './GasSufficiencyMessage';
7
6
  export const GasMessage = ({ route, ...props }) => {
8
7
  const { insufficientGas } = useGasSufficiency(route);
9
8
  const { insufficientFunds } = useFundsSufficiency(route);
10
- const { enabledAutoRefuel } = useSettings(['enabledAutoRefuel']);
11
- const { enabled, isLoading: isRefuelLoading } = useGasRefuel();
12
- const enabledRefuel = enabled && enabledAutoRefuel;
13
- const showGasSufficiencyMessage = insufficientGas?.length && !isRefuelLoading && !enabledRefuel;
14
- return (_jsx(Collapse, { timeout: 225, in: Boolean(insufficientFunds || showGasSufficiencyMessage), unmountOnExit: true, mountOnEnter: true, children: _jsx(Box, { ...props, children: insufficientFunds ? (_jsx(FundsSufficiencyMessage, {})) : showGasSufficiencyMessage ? (_jsx(GasSufficiencyMessage, { insufficientGas: insufficientGas })) : null }) }));
9
+ return (_jsx(Collapse, { timeout: 225, in: Boolean(insufficientFunds || insufficientGas?.length), unmountOnExit: true, mountOnEnter: true, children: _jsx(Box, { ...props, children: insufficientFunds ? (_jsx(FundsSufficiencyMessage, {})) : insufficientGas?.length ? (_jsx(GasSufficiencyMessage, { insufficientGas: insufficientGas })) : null }) }));
15
10
  };
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useLocation } from 'react-router-dom';
3
3
  import { useDefaultElementId } from '../../hooks';
4
4
  import { useWidgetConfig } from '../../providers';
5
- import { createElementId, ElementId, stickyHeaderRoutes } from '../../utils';
5
+ import { ElementId, createElementId, stickyHeaderRoutes } from '../../utils';
6
6
  import { Container } from './Header.style';
7
7
  import { NavigationHeader } from './NavigationHeader';
8
8
  import { WalletHeader } from './WalletHeader';
@@ -12,6 +12,6 @@ export const HeaderContainer = ({ children }) => {
12
12
  return (_jsx(Container, { id: createElementId(ElementId.Header, elementId), sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)), children: children }));
13
13
  };
14
14
  export const Header = () => {
15
- const { walletManagement } = useWidgetConfig();
16
- return (_jsxs(HeaderContainer, { children: [!walletManagement ? _jsx(WalletHeader, {}) : null, _jsx(NavigationHeader, {})] }));
15
+ const { walletManagement, subvariant } = useWidgetConfig();
16
+ return (_jsxs(HeaderContainer, { children: [!walletManagement && subvariant !== 'split' ? _jsx(WalletHeader, {}) : null, _jsx(NavigationHeader, {})] }));
17
17
  };