@lifi/widget 3.6.0-alpha.5 → 3.6.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 (193) hide show
  1. package/App.tsx +3 -3
  2. package/AppProvider.tsx +2 -1
  3. package/CHANGELOG.md +23 -0
  4. package/_esm/App.d.ts +1 -1
  5. package/_esm/App.js +3 -3
  6. package/_esm/App.js.map +1 -1
  7. package/_esm/AppProvider.js +2 -2
  8. package/_esm/AppProvider.js.map +1 -1
  9. package/_esm/components/Card/InputCard.d.ts +1 -1
  10. package/_esm/components/ChainSelect/useChainSelect.js +1 -5
  11. package/_esm/components/ChainSelect/useChainSelect.js.map +1 -1
  12. package/_esm/components/FeeBreakdownTooltip.js +1 -4
  13. package/_esm/components/FeeBreakdownTooltip.js.map +1 -1
  14. package/_esm/components/Header/EVMDisconnectIconButton.js +4 -5
  15. package/_esm/components/Header/EVMDisconnectIconButton.js.map +1 -1
  16. package/_esm/components/Header/Header.style.d.ts +0 -3
  17. package/_esm/components/Header/Header.style.js +0 -5
  18. package/_esm/components/Header/Header.style.js.map +1 -1
  19. package/_esm/components/Header/WalletMenu.js +6 -5
  20. package/_esm/components/Header/WalletMenu.js.map +1 -1
  21. package/_esm/components/Header/WalletMenu.style.js +1 -5
  22. package/_esm/components/Header/WalletMenu.style.js.map +1 -1
  23. package/_esm/components/SendToWallet/SendToWalletButton.js +16 -6
  24. package/_esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
  25. package/_esm/components/SendToWallet/SendToWalletExpandButton.js +8 -6
  26. package/_esm/components/SendToWallet/SendToWalletExpandButton.js.map +1 -1
  27. package/_esm/components/Skeleton/WidgetSkeleton.style.d.ts +1 -1
  28. package/_esm/components/Step/StepProcess.js +9 -1
  29. package/_esm/components/Step/StepProcess.js.map +1 -1
  30. package/_esm/components/TokenList/TokenListItem.js +5 -11
  31. package/_esm/components/TokenList/TokenListItem.js.map +1 -1
  32. package/_esm/components/TokenList/VirtualizedTokenList.js +1 -1
  33. package/_esm/components/TokenList/VirtualizedTokenList.js.map +1 -1
  34. package/_esm/components/TokenList/types.d.ts +2 -2
  35. package/_esm/components/TokenRate/TokenRate.js +2 -2
  36. package/_esm/components/TokenRate/TokenRate.js.map +1 -1
  37. package/_esm/components/TransactionDetails.js +2 -1
  38. package/_esm/components/TransactionDetails.js.map +1 -1
  39. package/_esm/config/version.d.ts +1 -1
  40. package/_esm/config/version.js +1 -1
  41. package/_esm/config/version.js.map +1 -1
  42. package/_esm/hooks/useAccount.d.ts +15 -15
  43. package/_esm/hooks/useAccount.js +13 -50
  44. package/_esm/hooks/useAccount.js.map +1 -1
  45. package/_esm/hooks/useAvailableChains.d.ts +1 -2
  46. package/_esm/hooks/useAvailableChains.js +8 -9
  47. package/_esm/hooks/useAvailableChains.js.map +1 -1
  48. package/_esm/hooks/useChains.d.ts +3 -4
  49. package/_esm/hooks/useChains.js +3 -5
  50. package/_esm/hooks/useChains.js.map +1 -1
  51. package/_esm/hooks/useExplorer.d.ts +10 -1
  52. package/_esm/hooks/useExplorer.js +4 -1
  53. package/_esm/hooks/useExplorer.js.map +1 -1
  54. package/_esm/hooks/useGasSufficiency.js +2 -2
  55. package/_esm/hooks/useGasSufficiency.js.map +1 -1
  56. package/_esm/hooks/useHeaderHeight.js +8 -1
  57. package/_esm/hooks/useHeaderHeight.js.map +1 -1
  58. package/_esm/hooks/useTokens.js +1 -1
  59. package/_esm/hooks/useTokens.js.map +1 -1
  60. package/_esm/hooks/useWallets.d.ts +1 -1
  61. package/_esm/hooks/useWallets.js +15 -36
  62. package/_esm/hooks/useWallets.js.map +1 -1
  63. package/_esm/i18n/en.json +1 -1
  64. package/_esm/pages/SelectWalletPage/EVMListItemButton.d.ts +2 -1
  65. package/_esm/pages/SelectWalletPage/EVMListItemButton.js +14 -15
  66. package/_esm/pages/SelectWalletPage/EVMListItemButton.js.map +1 -1
  67. package/_esm/pages/SelectWalletPage/SVMListItemButton.js +0 -3
  68. package/_esm/pages/SelectWalletPage/SVMListItemButton.js.map +1 -1
  69. package/_esm/pages/SelectWalletPage/SelectWalletPage.js +3 -3
  70. package/_esm/pages/SelectWalletPage/SelectWalletPage.js.map +1 -1
  71. package/_esm/pages/SendToWallet/SendToWalletPage.style.d.ts +1 -1
  72. package/_esm/pages/TransactionDetailsPage/TransferIdCard.js +1 -1
  73. package/_esm/pages/TransactionDetailsPage/TransferIdCard.js.map +1 -1
  74. package/_esm/pages/TransactionPage/StatusBottomSheet.js +3 -2
  75. package/_esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
  76. package/_esm/providers/I18nProvider/types.d.ts +2 -2
  77. package/_esm/providers/WalletProvider/SDKProviders.js +7 -15
  78. package/_esm/providers/WalletProvider/SDKProviders.js.map +1 -1
  79. package/_esm/providers/WalletProvider/WalletProvider.js +1 -2
  80. package/_esm/providers/WalletProvider/WalletProvider.js.map +1 -1
  81. package/_esm/providers/WalletProvider/useHasExternalWalletProvider.d.ts +1 -1
  82. package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js +3 -8
  83. package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js.map +1 -1
  84. package/_esm/providers/WidgetProvider/WidgetProvider.js +1 -31
  85. package/_esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
  86. package/_esm/stores/StoreProvider.js +2 -2
  87. package/_esm/stores/StoreProvider.js.map +1 -1
  88. package/_esm/stores/form/FormStore.d.ts +6 -1
  89. package/_esm/stores/form/FormStore.js +69 -18
  90. package/_esm/stores/form/FormStore.js.map +1 -1
  91. package/_esm/stores/form/FormUpdater.d.ts +1 -1
  92. package/_esm/stores/form/FormUpdater.js +36 -18
  93. package/_esm/stores/form/FormUpdater.js.map +1 -1
  94. package/_esm/stores/form/URLSearchParamsBuilder.js +44 -4
  95. package/_esm/stores/form/URLSearchParamsBuilder.js.map +1 -1
  96. package/_esm/stores/form/createFormStore.js +9 -0
  97. package/_esm/stores/form/createFormStore.js.map +1 -1
  98. package/_esm/stores/form/types.d.ts +13 -10
  99. package/_esm/stores/form/types.js.map +1 -1
  100. package/_esm/stores/form/useFieldActions.js +1 -0
  101. package/_esm/stores/form/useFieldActions.js.map +1 -1
  102. package/_esm/stores/form/useFormRef.d.ts +3 -0
  103. package/_esm/stores/form/useFormRef.js +51 -0
  104. package/_esm/stores/form/useFormRef.js.map +1 -0
  105. package/_esm/stores/form/useTouchedFields.d.ts +6 -6
  106. package/_esm/stores/settings/types.d.ts +0 -2
  107. package/_esm/stores/settings/useSendToWalletStore.d.ts +0 -1
  108. package/_esm/stores/settings/useSendToWalletStore.js +0 -7
  109. package/_esm/stores/settings/useSendToWalletStore.js.map +1 -1
  110. package/_esm/themes/createTheme.js +1 -2
  111. package/_esm/themes/createTheme.js.map +1 -1
  112. package/_esm/types/widget.d.ts +29 -4
  113. package/_esm/types/widget.js.map +1 -1
  114. package/_esm/utils/chainType.js +3 -2
  115. package/_esm/utils/chainType.js.map +1 -1
  116. package/_esm/utils/fees.js +5 -9
  117. package/_esm/utils/fees.js.map +1 -1
  118. package/_esm/utils/format.js +1 -1
  119. package/_esm/utils/format.js.map +1 -1
  120. package/_esm/utils/svm.d.ts +1 -0
  121. package/_esm/utils/svm.js +11 -0
  122. package/_esm/utils/svm.js.map +1 -0
  123. package/components/ChainSelect/useChainSelect.ts +1 -10
  124. package/components/FeeBreakdownTooltip.tsx +1 -4
  125. package/components/Header/EVMDisconnectIconButton.tsx +5 -5
  126. package/components/Header/Header.style.ts +0 -6
  127. package/components/Header/WalletMenu.style.tsx +1 -5
  128. package/components/Header/WalletMenu.tsx +5 -6
  129. package/components/SendToWallet/SendToWalletButton.tsx +23 -13
  130. package/components/SendToWallet/SendToWalletExpandButton.tsx +10 -10
  131. package/components/Step/StepProcess.tsx +12 -2
  132. package/components/TokenList/TokenListItem.tsx +7 -15
  133. package/components/TokenList/VirtualizedTokenList.tsx +1 -1
  134. package/components/TokenList/types.ts +2 -2
  135. package/components/TokenRate/TokenRate.tsx +2 -2
  136. package/components/TransactionDetails.tsx +4 -1
  137. package/config/version.ts +1 -1
  138. package/hooks/useAccount.ts +35 -82
  139. package/hooks/useAvailableChains.ts +10 -9
  140. package/hooks/useChains.ts +3 -6
  141. package/hooks/useExplorer.ts +19 -2
  142. package/hooks/useGasSufficiency.ts +2 -4
  143. package/hooks/useHeaderHeight.ts +8 -1
  144. package/hooks/useTokens.ts +1 -2
  145. package/hooks/useWallets.ts +20 -41
  146. package/i18n/en.json +1 -1
  147. package/package.json +8 -8
  148. package/pages/SelectWalletPage/EVMListItemButton.tsx +19 -15
  149. package/pages/SelectWalletPage/SVMListItemButton.tsx +0 -3
  150. package/pages/SelectWalletPage/SelectWalletPage.tsx +4 -9
  151. package/pages/TransactionDetailsPage/TransferIdCard.tsx +1 -1
  152. package/pages/TransactionPage/StatusBottomSheet.tsx +5 -0
  153. package/providers/I18nProvider/types.ts +2 -2
  154. package/providers/WalletProvider/SDKProviders.tsx +7 -25
  155. package/providers/WalletProvider/WalletProvider.tsx +2 -5
  156. package/providers/WalletProvider/useHasExternalWalletProvider.ts +5 -11
  157. package/providers/WidgetProvider/WidgetProvider.tsx +1 -39
  158. package/stores/StoreProvider.tsx +5 -4
  159. package/stores/form/FormStore.tsx +100 -20
  160. package/stores/form/FormUpdater.tsx +52 -22
  161. package/stores/form/URLSearchParamsBuilder.tsx +55 -5
  162. package/stores/form/createFormStore.ts +9 -0
  163. package/stores/form/types.ts +14 -10
  164. package/stores/form/useFieldActions.ts +1 -0
  165. package/stores/form/useFormRef.ts +69 -0
  166. package/stores/settings/types.ts +0 -2
  167. package/stores/settings/useSendToWalletStore.ts +0 -8
  168. package/themes/createTheme.ts +1 -3
  169. package/types/widget.ts +46 -3
  170. package/utils/chainType.ts +3 -2
  171. package/utils/fees.ts +13 -15
  172. package/utils/format.ts +1 -1
  173. package/utils/svm.ts +10 -0
  174. package/_esm/components/Header/UTXODisconnectIconButton.d.ts +0 -4
  175. package/_esm/components/Header/UTXODisconnectIconButton.js +0 -13
  176. package/_esm/components/Header/UTXODisconnectIconButton.js.map +0 -1
  177. package/_esm/pages/SelectWalletPage/UTXOListItemButton.d.ts +0 -8
  178. package/_esm/pages/SelectWalletPage/UTXOListItemButton.js +0 -39
  179. package/_esm/pages/SelectWalletPage/UTXOListItemButton.js.map +0 -1
  180. package/_esm/providers/WalletProvider/UTXOBaseProvider.d.ts +0 -2
  181. package/_esm/providers/WalletProvider/UTXOBaseProvider.js +0 -17
  182. package/_esm/providers/WalletProvider/UTXOBaseProvider.js.map +0 -1
  183. package/_esm/providers/WalletProvider/UTXOExternalContext.d.ts +0 -1
  184. package/_esm/providers/WalletProvider/UTXOExternalContext.js +0 -3
  185. package/_esm/providers/WalletProvider/UTXOExternalContext.js.map +0 -1
  186. package/_esm/providers/WalletProvider/UTXOProvider.d.ts +0 -3
  187. package/_esm/providers/WalletProvider/UTXOProvider.js +0 -18
  188. package/_esm/providers/WalletProvider/UTXOProvider.js.map +0 -1
  189. package/components/Header/UTXODisconnectIconButton.tsx +0 -24
  190. package/pages/SelectWalletPage/UTXOListItemButton.tsx +0 -70
  191. package/providers/WalletProvider/UTXOBaseProvider.tsx +0 -28
  192. package/providers/WalletProvider/UTXOExternalContext.ts +0 -3
  193. package/providers/WalletProvider/UTXOProvider.tsx +0 -26
package/utils/fees.ts CHANGED
@@ -104,22 +104,20 @@ export const getFeeCostsBreakdown = (
104
104
  export const getStepFeeCostsBreakdown = (
105
105
  feeCosts: FeeCost[] | GasCost[],
106
106
  ): FeesBreakdown => {
107
- const { token } = feeCosts[0];
108
-
109
- const { amount, amountUSD } = feeCosts.reduce(
110
- (acc, feeCost) => {
111
- const feeAmount = BigInt(Number(feeCost.amount).toFixed(0) || 0);
112
- const amountUSD =
113
- parseFloat(feeCost.token.priceUSD || '0') *
114
- parseFloat(formatUnits(feeAmount, feeCost.token.decimals));
115
-
116
- acc.amount += feeAmount;
117
- acc.amountUSD += amountUSD;
118
- return acc;
119
- },
120
- { amount: 0n, amountUSD: 0 },
107
+ const token = feeCosts[0].token;
108
+ const amount = feeCosts.reduce(
109
+ (amount, feeCost) => amount + BigInt(feeCost.amount || 0),
110
+ 0n,
111
+ );
112
+ const amountUSD = feeCosts.reduce(
113
+ (amount, feeCost) =>
114
+ amount +
115
+ parseFloat(feeCost.token.priceUSD || '0') *
116
+ parseFloat(
117
+ formatUnits(BigInt(feeCost.amount || 0), feeCost.token.decimals),
118
+ ),
119
+ 0,
121
120
  );
122
-
123
121
  return {
124
122
  amount,
125
123
  amountUSD,
package/utils/format.ts CHANGED
@@ -60,7 +60,7 @@ export function formatInputAmount(
60
60
  if (!amount) {
61
61
  return amount;
62
62
  }
63
- let formattedAmount = amount.replaceAll(',', '.');
63
+ let formattedAmount = amount.trim().replaceAll(',', '.');
64
64
  if (formattedAmount.startsWith('.')) {
65
65
  formattedAmount = '0' + formattedAmount;
66
66
  }
package/utils/svm.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+
3
+ export const isSVMAddress = (address: string) => {
4
+ try {
5
+ new PublicKey(address);
6
+ return true;
7
+ } catch {
8
+ return false;
9
+ }
10
+ };
@@ -1,4 +0,0 @@
1
- import type { Connector } from 'wagmi';
2
- export declare const UTXODisconnectIconButton: ({ connector, }: {
3
- connector?: Connector;
4
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,13 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useConfig } from '@lifi/wallet-management';
3
- import { PowerSettingsNewRounded } from '@mui/icons-material';
4
- import { IconButton } from '@mui/material';
5
- import { disconnect } from 'wagmi/actions';
6
- export const UTXODisconnectIconButton = ({ connector, }) => {
7
- const config = useConfig();
8
- return (_jsx(IconButton, { size: "medium", onClick: async (e) => {
9
- e.stopPropagation();
10
- await disconnect(config, { connector });
11
- }, children: _jsx(PowerSettingsNewRounded, {}) }));
12
- };
13
- //# sourceMappingURL=UTXODisconnectIconButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UTXODisconnectIconButton.js","sourceRoot":"","sources":["../../../components/Header/UTXODisconnectIconButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACvC,SAAS,GAGV,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,CACL,KAAC,UAAU,IACT,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YACnB,CAAC,CAAC,eAAe,EAAE,CAAC;YACpB,MAAM,UAAU,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QAC1C,CAAC,YAED,KAAC,uBAAuB,KAAG,GAChB,CACd,CAAC;AACJ,CAAC,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { CreateConnectorFnExtended } from '@lifi/wallet-management';
2
- import type { Connector } from 'wagmi';
3
- interface UTXOListItemButtonProps {
4
- connector: CreateConnectorFnExtended | Connector;
5
- onNotInstalled(connector: Connector): void;
6
- }
7
- export declare const UTXOListItemButton: ({ connector, onNotInstalled, }: UTXOListItemButtonProps) => import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -1,39 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ChainType } from '@lifi/sdk';
3
- import { getConnectorIcon, isWalletInstalledAsync, useConfig, } from '@lifi/wallet-management';
4
- import { Avatar, ListItemAvatar } from '@mui/material';
5
- import { connect, disconnect, getAccount } from 'wagmi/actions';
6
- import { ListItemButton } from '../../components/ListItemButton.js';
7
- import { ListItemText } from '../../components/ListItemText.js';
8
- import { useLastConnectedAccount } from '../../hooks/useAccount.js';
9
- import { useNavigateBack } from '../../hooks/useNavigateBack.js';
10
- import { useWidgetEvents } from '../../hooks/useWidgetEvents.js';
11
- import { WidgetEvent } from '../../types/events.js';
12
- export const UTXOListItemButton = ({ connector, onNotInstalled, }) => {
13
- const { navigateBack } = useNavigateBack();
14
- const emitter = useWidgetEvents();
15
- const config = useConfig();
16
- const { setLastConnectedAccount } = useLastConnectedAccount();
17
- const handleUTXOConnect = async () => {
18
- const identityCheckPassed = await isWalletInstalledAsync(connector.id);
19
- if (!identityCheckPassed) {
20
- onNotInstalled(connector);
21
- return;
22
- }
23
- const connectedAccount = getAccount(config);
24
- if (connectedAccount.connector) {
25
- await disconnect(config, { connector: connectedAccount.connector });
26
- }
27
- const data = await connect(config, { connector });
28
- setLastConnectedAccount(connector);
29
- emitter.emit(WidgetEvent.WalletConnected, {
30
- address: data.accounts[0],
31
- chainId: data.chainId,
32
- chainType: ChainType.UTXO,
33
- });
34
- navigateBack();
35
- };
36
- const connectorName = connector.displayName || connector.name;
37
- return (_jsxs(ListItemButton, { onClick: handleUTXOConnect, children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, { src: getConnectorIcon(connector), alt: connectorName, children: connectorName?.[0] }) }), _jsx(ListItemText, { primary: `${connectorName} (Bitcoin)` })] }, connector.id));
38
- };
39
- //# sourceMappingURL=UTXOListItemButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UTXOListItemButton.js","sourceRoot":"","sources":["../../../pages/SelectWalletPage/UTXOListItemButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAOpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,SAAS,EACT,cAAc,GACU,EAAE,EAAE;IAC5B,MAAM,EAAE,YAAY,EAAE,GAAG,eAAe,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,EAAE,uBAAuB,EAAE,GAAG,uBAAuB,EAAE,CAAC;IAE9D,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;QACnC,MAAM,mBAAmB,GAAG,MAAM,sBAAsB,CACrD,SAAuB,CAAC,EAAE,CAC5B,CAAC;QACF,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,cAAc,CAAC,SAAsB,CAAC,CAAC;YACvC,OAAO;QACT,CAAC;QACD,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,gBAAgB,CAAC,SAAS,EAAE,CAAC;YAC/B,MAAM,UAAU,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAC;QACtE,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QAClD,uBAAuB,CAAC,SAAS,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE;YACxC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,SAAS,CAAC,IAAI;SAC1B,CAAC,CAAC;QACH,YAAY,EAAE,CAAC;IACjB,CAAC,CAAC;IAEF,MAAM,aAAa,GAChB,SAAuC,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,CAAC;IAEzE,OAAO,CACL,MAAC,cAAc,IAAoB,OAAO,EAAE,iBAAiB,aAC3D,KAAC,cAAc,cACb,KAAC,MAAM,IACL,GAAG,EAAE,gBAAgB,CAAC,SAAsB,CAAC,EAC7C,GAAG,EAAE,aAAa,YAEjB,aAAa,EAAE,CAAC,CAAC,CAAC,GACZ,GACM,EACjB,KAAC,YAAY,IAAC,OAAO,EAAE,GAAG,aAAa,YAAY,GAAI,KATpC,SAAS,CAAC,EAAE,CAUhB,CAClB,CAAC;AACJ,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- import { type FC, type PropsWithChildren } from 'react';
2
- export declare const UTXOBaseProvider: FC<PropsWithChildren>;
@@ -1,17 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { BigmiProvider, createDefaultBigmiConfig, useReconnect, } from '@lifi/wallet-management';
3
- import { useRef } from 'react';
4
- export const UTXOBaseProvider = ({ children }) => {
5
- const bigmi = useRef();
6
- if (!bigmi.current) {
7
- bigmi.current = createDefaultBigmiConfig({
8
- bigmiConfig: {
9
- ssr: true,
10
- multiInjectedProviderDiscovery: false,
11
- },
12
- });
13
- }
14
- useReconnect(bigmi.current.config);
15
- return (_jsx(BigmiProvider, { config: bigmi.current.config, reconnectOnMount: false, children: children }));
16
- };
17
- //# sourceMappingURL=UTXOBaseProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UTXOBaseProvider.js","sourceRoot":"","sources":["../../../providers/WalletProvider/UTXOBaseProvider.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAmC,MAAM,OAAO,CAAC;AAEhE,MAAM,CAAC,MAAM,gBAAgB,GAA0B,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IACtE,MAAM,KAAK,GAAG,MAAM,EAA4B,CAAC;IAEjD,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACnB,KAAK,CAAC,OAAO,GAAG,wBAAwB,CAAC;YACvC,WAAW,EAAE;gBACX,GAAG,EAAE,IAAI;gBACT,8BAA8B,EAAE,KAAK;aACtC;SACF,CAAC,CAAC;IACL,CAAC;IAED,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnC,OAAO,CACL,KAAC,aAAa,IAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,YACjE,QAAQ,GACK,CACjB,CAAC;AACJ,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export declare const UTXOExternalContext: import("react").Context<boolean>;
@@ -1,3 +0,0 @@
1
- import { createContext } from 'react';
2
- export const UTXOExternalContext = createContext(false);
3
- //# sourceMappingURL=UTXOExternalContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UTXOExternalContext.js","sourceRoot":"","sources":["../../../providers/WalletProvider/UTXOExternalContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAU,KAAK,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type FC, type PropsWithChildren } from 'react';
2
- export declare function useInBigmiContext(): boolean;
3
- export declare const UTXOProvider: FC<PropsWithChildren>;
@@ -1,18 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ChainType } from '@lifi/sdk';
3
- import { BigmiContext } from '@lifi/wallet-management';
4
- import { useContext } from 'react';
5
- import { isItemAllowed } from '../../utils/item.js';
6
- import { useWidgetConfig } from '../WidgetProvider/WidgetProvider.js';
7
- import { UTXOBaseProvider } from './UTXOBaseProvider.js';
8
- import { UTXOExternalContext } from './UTXOExternalContext.js';
9
- export function useInBigmiContext() {
10
- const { chains } = useWidgetConfig();
11
- const context = useContext(BigmiContext);
12
- return Boolean(context) && isItemAllowed(ChainType.UTXO, chains?.types);
13
- }
14
- export const UTXOProvider = ({ children }) => {
15
- const inBigmiContext = useInBigmiContext();
16
- return inBigmiContext ? (_jsx(UTXOExternalContext.Provider, { value: inBigmiContext, children: children })) : (_jsx(UTXOBaseProvider, { children: children }));
17
- };
18
- //# sourceMappingURL=UTXOProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UTXOProvider.js","sourceRoot":"","sources":["../../../providers/WalletProvider/UTXOProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAmC,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,UAAU,iBAAiB;IAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAEzC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,aAAa,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAClE,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAE3C,OAAO,cAAc,CAAC,CAAC,CAAC,CACtB,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,cAAc,YAChD,QAAQ,GACoB,CAChC,CAAC,CAAC,CAAC,CACF,KAAC,gBAAgB,cAAE,QAAQ,GAAoB,CAChD,CAAC;AACJ,CAAC,CAAC"}
@@ -1,24 +0,0 @@
1
- import { useConfig } from '@lifi/wallet-management';
2
- import { PowerSettingsNewRounded } from '@mui/icons-material';
3
- import { IconButton } from '@mui/material';
4
- import type { Connector } from 'wagmi';
5
- import { disconnect } from 'wagmi/actions';
6
-
7
- export const UTXODisconnectIconButton = ({
8
- connector,
9
- }: {
10
- connector?: Connector;
11
- }) => {
12
- const config = useConfig();
13
- return (
14
- <IconButton
15
- size="medium"
16
- onClick={async (e) => {
17
- e.stopPropagation();
18
- await disconnect(config, { connector });
19
- }}
20
- >
21
- <PowerSettingsNewRounded />
22
- </IconButton>
23
- );
24
- };
@@ -1,70 +0,0 @@
1
- import { ChainType } from '@lifi/sdk';
2
- import type { CreateConnectorFnExtended } from '@lifi/wallet-management';
3
- import {
4
- getConnectorIcon,
5
- isWalletInstalledAsync,
6
- useConfig,
7
- } from '@lifi/wallet-management';
8
- import { Avatar, ListItemAvatar } from '@mui/material';
9
- import type { Connector } from 'wagmi';
10
- import { connect, disconnect, getAccount } from 'wagmi/actions';
11
- import { ListItemButton } from '../../components/ListItemButton.js';
12
- import { ListItemText } from '../../components/ListItemText.js';
13
- import { useLastConnectedAccount } from '../../hooks/useAccount.js';
14
- import { useNavigateBack } from '../../hooks/useNavigateBack.js';
15
- import { useWidgetEvents } from '../../hooks/useWidgetEvents.js';
16
- import { WidgetEvent } from '../../types/events.js';
17
-
18
- interface UTXOListItemButtonProps {
19
- connector: CreateConnectorFnExtended | Connector;
20
- onNotInstalled(connector: Connector): void;
21
- }
22
-
23
- export const UTXOListItemButton = ({
24
- connector,
25
- onNotInstalled,
26
- }: UTXOListItemButtonProps) => {
27
- const { navigateBack } = useNavigateBack();
28
- const emitter = useWidgetEvents();
29
- const config = useConfig();
30
- const { setLastConnectedAccount } = useLastConnectedAccount();
31
-
32
- const handleUTXOConnect = async () => {
33
- const identityCheckPassed = await isWalletInstalledAsync(
34
- (connector as Connector).id,
35
- );
36
- if (!identityCheckPassed) {
37
- onNotInstalled(connector as Connector);
38
- return;
39
- }
40
- const connectedAccount = getAccount(config);
41
- if (connectedAccount.connector) {
42
- await disconnect(config, { connector: connectedAccount.connector });
43
- }
44
- const data = await connect(config, { connector });
45
- setLastConnectedAccount(connector);
46
- emitter.emit(WidgetEvent.WalletConnected, {
47
- address: data.accounts[0],
48
- chainId: data.chainId,
49
- chainType: ChainType.UTXO,
50
- });
51
- navigateBack();
52
- };
53
-
54
- const connectorName: string =
55
- (connector as CreateConnectorFnExtended).displayName || connector.name;
56
-
57
- return (
58
- <ListItemButton key={connector.id} onClick={handleUTXOConnect}>
59
- <ListItemAvatar>
60
- <Avatar
61
- src={getConnectorIcon(connector as Connector)}
62
- alt={connectorName}
63
- >
64
- {connectorName?.[0]}
65
- </Avatar>
66
- </ListItemAvatar>
67
- <ListItemText primary={`${connectorName} (Bitcoin)`} />
68
- </ListItemButton>
69
- );
70
- };
@@ -1,28 +0,0 @@
1
- import type { DefaultWagmiConfigResult } from '@lifi/wallet-management';
2
- import {
3
- BigmiProvider,
4
- createDefaultBigmiConfig,
5
- useReconnect,
6
- } from '@lifi/wallet-management';
7
- import { useRef, type FC, type PropsWithChildren } from 'react';
8
-
9
- export const UTXOBaseProvider: FC<PropsWithChildren> = ({ children }) => {
10
- const bigmi = useRef<DefaultWagmiConfigResult>();
11
-
12
- if (!bigmi.current) {
13
- bigmi.current = createDefaultBigmiConfig({
14
- bigmiConfig: {
15
- ssr: true,
16
- multiInjectedProviderDiscovery: false,
17
- },
18
- });
19
- }
20
-
21
- useReconnect(bigmi.current.config);
22
-
23
- return (
24
- <BigmiProvider config={bigmi.current.config} reconnectOnMount={false}>
25
- {children}
26
- </BigmiProvider>
27
- );
28
- };
@@ -1,3 +0,0 @@
1
- import { createContext } from 'react';
2
-
3
- export const UTXOExternalContext = createContext<boolean>(false);
@@ -1,26 +0,0 @@
1
- import { ChainType } from '@lifi/sdk';
2
- import { BigmiContext } from '@lifi/wallet-management';
3
- import { useContext, type FC, type PropsWithChildren } from 'react';
4
- import { isItemAllowed } from '../../utils/item.js';
5
- import { useWidgetConfig } from '../WidgetProvider/WidgetProvider.js';
6
- import { UTXOBaseProvider } from './UTXOBaseProvider.js';
7
- import { UTXOExternalContext } from './UTXOExternalContext.js';
8
-
9
- export function useInBigmiContext(): boolean {
10
- const { chains } = useWidgetConfig();
11
- const context = useContext(BigmiContext);
12
-
13
- return Boolean(context) && isItemAllowed(ChainType.UTXO, chains?.types);
14
- }
15
-
16
- export const UTXOProvider: FC<PropsWithChildren> = ({ children }) => {
17
- const inBigmiContext = useInBigmiContext();
18
-
19
- return inBigmiContext ? (
20
- <UTXOExternalContext.Provider value={inBigmiContext}>
21
- {children}
22
- </UTXOExternalContext.Provider>
23
- ) : (
24
- <UTXOBaseProvider>{children}</UTXOBaseProvider>
25
- );
26
- };