@lifi/widget 4.7.1 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/AmountInput/AmountInput.style.d.ts.map +1 -1
- package/dist/esm/components/Card/Card.d.ts.map +1 -1
- package/dist/esm/components/Card/CardIconButton.d.ts.map +1 -1
- package/dist/esm/components/ContractComponent/ItemPrice.d.ts.map +1 -1
- package/dist/esm/components/ListItem/ListItemButton.d.ts.map +1 -1
- package/dist/esm/components/ListItemButton.d.ts.map +1 -1
- package/dist/esm/components/Token/Token.d.ts.map +1 -1
- package/dist/esm/components/TokenList/types.d.ts.map +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/config/version.js.map +1 -1
- package/dist/esm/hooks/useAvailableChains.d.ts.map +1 -1
- package/dist/esm/hooks/useAvailableChains.js +21 -38
- package/dist/esm/hooks/useAvailableChains.js.map +1 -1
- package/dist/esm/hooks/useFromTokenSufficiency.js +3 -3
- package/dist/esm/hooks/useFromTokenSufficiency.js.map +1 -1
- package/dist/esm/hooks/useGasRecommendation.js +3 -3
- package/dist/esm/hooks/useGasRecommendation.js.map +1 -1
- package/dist/esm/hooks/useGasSufficiency.js +3 -3
- package/dist/esm/hooks/useGasSufficiency.js.map +1 -1
- package/dist/esm/hooks/useIsBatchingSupported.js +2 -2
- package/dist/esm/hooks/useIsBatchingSupported.js.map +1 -1
- package/dist/esm/hooks/useRouteExecution.js +6 -6
- package/dist/esm/hooks/useRouteExecution.js.map +1 -1
- package/dist/esm/hooks/useRoutes.js +7 -7
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/hooks/useTokenBalance.js +4 -4
- package/dist/esm/hooks/useTokenBalance.js.map +1 -1
- package/dist/esm/hooks/useTokenBalancesQueries.js +3 -3
- package/dist/esm/hooks/useTokenBalancesQueries.js.map +1 -1
- package/dist/esm/hooks/useTokenSearch.js +3 -3
- package/dist/esm/hooks/useTokenSearch.js.map +1 -1
- package/dist/esm/hooks/useTokens.js +14 -14
- package/dist/esm/hooks/useTokens.js.map +1 -1
- package/dist/esm/hooks/useTools.d.ts.map +1 -1
- package/dist/esm/hooks/useTools.js +26 -27
- package/dist/esm/hooks/useTools.js.map +1 -1
- package/dist/esm/hooks/useTransactionDetails.js +2 -2
- package/dist/esm/hooks/useTransactionDetails.js.map +1 -1
- package/dist/esm/hooks/useTransactionHistory.js +3 -3
- package/dist/esm/hooks/useTransactionHistory.js.map +1 -1
- package/dist/esm/index.d.ts +5 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/pages/RoutesPage/RoutesPage.style.d.ts.map +1 -1
- package/dist/esm/providers/I18nProvider/types.d.ts.map +1 -1
- package/dist/esm/providers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
- package/dist/esm/providers/WidgetProvider/WidgetProvider.js +9 -1
- package/dist/esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
- package/dist/esm/providers/WidgetProvider/types.d.ts +2 -0
- package/dist/esm/providers/WidgetProvider/types.d.ts.map +1 -1
- package/dist/esm/queries/getChains.d.ts +38 -0
- package/dist/esm/queries/getChains.d.ts.map +1 -0
- package/dist/esm/queries/getChains.js +51 -0
- package/dist/esm/queries/getChains.js.map +1 -0
- package/dist/esm/queries/getTools.d.ts +26 -0
- package/dist/esm/queries/getTools.d.ts.map +1 -0
- package/dist/esm/queries/getTools.js +30 -0
- package/dist/esm/queries/getTools.js.map +1 -0
- package/dist/esm/queries/index.d.ts +4 -0
- package/dist/esm/queries/index.js +3 -0
- package/dist/esm/queries/types.d.ts +25 -0
- package/dist/esm/queries/types.d.ts.map +1 -0
- package/dist/esm/shared.d.ts +2 -1
- package/dist/esm/shared.js +2 -1
- package/dist/esm/stores/StoreProvider.d.ts.map +1 -1
- package/dist/esm/stores/StoreProvider.js +16 -17
- package/dist/esm/stores/StoreProvider.js.map +1 -1
- package/dist/esm/stores/header/useHeaderStore.d.ts +1 -1
- package/dist/esm/stores/header/useHeaderStore.d.ts.map +1 -1
- package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
- package/dist/esm/themes/createTheme.d.ts.map +1 -1
- package/dist/esm/types/events.d.ts.map +1 -1
- package/dist/esm/types/token.d.ts.map +1 -1
- package/dist/esm/types/widget.d.ts +30 -0
- package/dist/esm/types/widget.d.ts.map +1 -1
- package/dist/esm/types/widget.js.map +1 -1
- package/dist/esm/utils/queries.js.map +1 -1
- package/dist/esm/utils/scopeKeys.d.ts +6 -0
- package/dist/esm/utils/scopeKeys.d.ts.map +1 -0
- package/dist/esm/utils/scopeKeys.js +8 -0
- package/dist/esm/utils/scopeKeys.js.map +1 -0
- package/package.json +12 -4
- package/src/config/version.ts +1 -1
- package/src/hooks/useAvailableChains.test.tsx +170 -0
- package/src/hooks/useAvailableChains.ts +29 -47
- package/src/hooks/useFromTokenSufficiency.ts +2 -2
- package/src/hooks/useGasRecommendation.ts +2 -2
- package/src/hooks/useGasSufficiency.ts +2 -2
- package/src/hooks/useIsBatchingSupported.ts +2 -2
- package/src/hooks/useRouteExecution.ts +5 -5
- package/src/hooks/useRoutes.ts +6 -6
- package/src/hooks/useTokenBalance.ts +4 -4
- package/src/hooks/useTokenBalancesQueries.ts +3 -3
- package/src/hooks/useTokenSearch.ts +7 -3
- package/src/hooks/useTokens.ts +13 -14
- package/src/hooks/useTools.sharedEntry.test.tsx +155 -0
- package/src/hooks/useTools.ts +42 -37
- package/src/hooks/useTransactionDetails.ts +3 -3
- package/src/hooks/useTransactionHistory.ts +2 -2
- package/src/index.ts +2 -1
- package/src/providers/WidgetProvider/WidgetProvider.test.tsx +73 -0
- package/src/providers/WidgetProvider/WidgetProvider.tsx +13 -0
- package/src/providers/WidgetProvider/types.ts +2 -0
- package/src/queries/getChains.ts +93 -0
- package/src/queries/getTools.ts +62 -0
- package/src/queries/index.ts +30 -0
- package/src/queries/sharedCache.test.tsx +223 -0
- package/src/queries/types.ts +38 -0
- package/src/shared.ts +1 -0
- package/src/stores/StoreProvider.test.tsx +107 -0
- package/src/stores/StoreProvider.tsx +8 -6
- package/src/stores/header/useHeaderStore.tsx +3 -4
- package/src/types/widget.ts +30 -0
- package/src/utils/queries.ts +1 -0
- package/src/utils/scopeKeys.ts +18 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransactionHistory.js","names":[],"sources":["../../../src/hooks/useTransactionHistory.ts"],"sourcesContent":["import type { FullStatusData, StatusResponse } from '@lifi/sdk'\nimport { getTransactionHistory } from '@lifi/sdk'\nimport { useAccount } from '@lifi/wallet-management'\nimport type { QueryFunction } from '@tanstack/react-query'\nimport { useQueries } from '@tanstack/react-query'\nimport { useEffect, useMemo } from 'react'\nimport { useSDKClient } from '../providers/SDKClientProvider.js'\nimport { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'\nimport { useRouteExecutionStoreContext } from '../stores/routes/RouteExecutionStore.js'\nimport type {\n RouteExecution,\n RouteExecutionState,\n} from '../stores/routes/types.js'\nimport { getSourceTxHash } from '../stores/routes/utils.js'\nimport { buildRouteFromTxHistory } from '../utils/converters.js'\nimport { getQueryKey } from '../utils/queries.js'\nimport { useTools } from './useTools.js'\n\nexport const useTransactionHistory = (): {\n data: RouteExecution[]\n isLoading: boolean\n} => {\n const store = useRouteExecutionStoreContext()\n const { accounts } = useAccount()\n const {
|
|
1
|
+
{"version":3,"file":"useTransactionHistory.js","names":[],"sources":["../../../src/hooks/useTransactionHistory.ts"],"sourcesContent":["import type { FullStatusData, StatusResponse } from '@lifi/sdk'\nimport { getTransactionHistory } from '@lifi/sdk'\nimport { useAccount } from '@lifi/wallet-management'\nimport type { QueryFunction } from '@tanstack/react-query'\nimport { useQueries } from '@tanstack/react-query'\nimport { useEffect, useMemo } from 'react'\nimport { useSDKClient } from '../providers/SDKClientProvider.js'\nimport { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'\nimport { useRouteExecutionStoreContext } from '../stores/routes/RouteExecutionStore.js'\nimport type {\n RouteExecution,\n RouteExecutionState,\n} from '../stores/routes/types.js'\nimport { getSourceTxHash } from '../stores/routes/utils.js'\nimport { buildRouteFromTxHistory } from '../utils/converters.js'\nimport { getQueryKey } from '../utils/queries.js'\nimport { useTools } from './useTools.js'\n\nexport const useTransactionHistory = (): {\n data: RouteExecution[]\n isLoading: boolean\n} => {\n const store = useRouteExecutionStoreContext()\n const { accounts } = useAccount()\n const { storageScopeKey } = useWidgetConfig()\n const sdkClient = useSDKClient()\n const { tools } = useTools()\n\n const { data: routeExecutions, isLoading } = useQueries({\n queries: accounts.map((account) => ({\n queryKey: [\n getQueryKey('transaction-history', storageScopeKey),\n account.address,\n ],\n queryFn: (async ({ queryKey: [, accountAddress], signal }) => {\n if (!accountAddress) {\n return []\n }\n const date = new Date()\n date.setFullYear(date.getFullYear() - 10)\n\n const response = await getTransactionHistory(\n sdkClient,\n {\n wallet: accountAddress,\n fromTimestamp: Math.floor(date.getTime() / 1000),\n toTimestamp: Math.floor(Date.now() / 1000),\n },\n { signal }\n )\n\n return response.transfers\n }) as QueryFunction<StatusResponse[], (string | undefined)[], never>,\n refetchInterval: 300_000,\n enabled: Boolean(account.address),\n })),\n combine: (results) => {\n const uniqueTransactions = new Map<string, StatusResponse>()\n results.forEach((result) => {\n if (result.data) {\n result.data.forEach((transaction) => {\n if (\n (transaction as FullStatusData)?.transactionId &&\n (transaction as FullStatusData)?.receiving?.chainId &&\n transaction?.sending.chainId\n ) {\n uniqueTransactions.set(\n (transaction as FullStatusData).transactionId,\n transaction\n )\n }\n })\n }\n })\n // Convert raw API transactions into RouteExecution objects.\n const data = Array.from(uniqueTransactions.values()).flatMap(\n (transaction) => {\n const routeExecution = buildRouteFromTxHistory(\n transaction as FullStatusData,\n tools\n )\n return routeExecution ? [routeExecution] : []\n }\n )\n return {\n data,\n isLoading: results.some((result) => result.isLoading),\n }\n },\n })\n\n // Stable Set — only recreated when data actually changes (TanStack Query structural sharing).\n const apiTxHashes = useMemo(\n () => new Set(routeExecutions.map((r) => getSourceTxHash(r.route))),\n [routeExecutions]\n )\n\n // Remove local store routes already indexed by the API to avoid duplicates.\n // Must be in an effect — combine runs during render, so store mutations there\n // would trigger \"Cannot update a component while rendering\" in concurrent mode.\n useEffect(() => {\n if (!apiTxHashes.size) {\n return\n }\n const { routes, deleteRoute } = store.getState() as RouteExecutionState\n for (const [id, routeExecution] of Object.entries(routes)) {\n const txHash = getSourceTxHash(\n (routeExecution as RouteExecution | undefined)?.route\n )\n if (txHash && apiTxHashes.has(txHash)) {\n deleteRoute(id)\n }\n }\n }, [apiTxHashes, store])\n\n return {\n data: routeExecutions,\n isLoading,\n }\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAa,8BAGR;CACH,MAAM,QAAQ,8BAA8B;CAC5C,MAAM,EAAE,aAAa,WAAW;CAChC,MAAM,EAAE,oBAAoB,gBAAgB;CAC5C,MAAM,YAAY,aAAa;CAC/B,MAAM,EAAE,UAAU,SAAS;CAE3B,MAAM,EAAE,MAAM,iBAAiB,cAAc,WAAW;EACtD,SAAS,SAAS,KAAK,aAAa;GAClC,UAAU,CACR,YAAY,uBAAuB,eAAe,GAClD,QAAQ,OACV;GACA,UAAU,OAAO,EAAE,UAAU,GAAG,iBAAiB,aAAa;IAC5D,IAAI,CAAC,gBACH,OAAO,CAAC;IAEV,MAAM,uBAAO,IAAI,KAAK;IACtB,KAAK,YAAY,KAAK,YAAY,IAAI,EAAE;IAYxC,QAAO,MAVgB,sBACrB,WACA;KACE,QAAQ;KACR,eAAe,KAAK,MAAM,KAAK,QAAQ,IAAI,GAAI;KAC/C,aAAa,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI;IAC3C,GACA,EAAE,OAAO,CACX,EAAA,CAEgB;GAClB;GACA,iBAAiB;GACjB,SAAS,QAAQ,QAAQ,OAAO;EAClC,EAAE;EACF,UAAU,YAAY;GACpB,MAAM,qCAAqB,IAAI,IAA4B;GAC3D,QAAQ,SAAS,WAAW;IAC1B,IAAI,OAAO,MACT,OAAO,KAAK,SAAS,gBAAgB;KACnC,IACG,aAAgC,iBAChC,aAAgC,WAAW,WAC5C,aAAa,QAAQ,SAErB,mBAAmB,IAChB,YAA+B,eAChC,WACF;IAEJ,CAAC;GAEL,CAAC;GAWD,OAAO;IACL,MAVW,MAAM,KAAK,mBAAmB,OAAO,CAAC,CAAC,CAAC,SAClD,gBAAgB;KACf,MAAM,iBAAiB,wBACrB,aACA,KACF;KACA,OAAO,iBAAiB,CAAC,cAAc,IAAI,CAAC;IAC9C,CAGG;IACH,WAAW,QAAQ,MAAM,WAAW,OAAO,SAAS;GACtD;EACF;CACF,CAAC;CAGD,MAAM,cAAc,cACZ,IAAI,IAAI,gBAAgB,KAAK,MAAM,gBAAgB,EAAE,KAAK,CAAC,CAAC,GAClE,CAAC,eAAe,CAClB;CAKA,gBAAgB;EACd,IAAI,CAAC,YAAY,MACf;EAEF,MAAM,EAAE,QAAQ,gBAAgB,MAAM,SAAS;EAC/C,KAAK,MAAM,CAAC,IAAI,mBAAmB,OAAO,QAAQ,MAAM,GAAG;GACzD,MAAM,SAAS,gBACZ,gBAA+C,KAClD;GACA,IAAI,UAAU,YAAY,IAAI,MAAM,GAClC,YAAY,EAAE;EAElB;CACF,GAAG,CAAC,aAAa,KAAK,CAAC;CAEvB,OAAO;EACL,MAAM;EACN;CACF;AACF"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ import { useWidgetChains } from "./hooks/useWidgetChains.js";
|
|
|
14
14
|
import { navigationRoutes } from "./utils/navigationRoutes.js";
|
|
15
15
|
import { ChainPinned, ChainTokenSelected, ContactSupport, FormFieldChanged, LowAddressActivityConfirmed, NavigationTabChanged, RouteExecutionUpdate, RouteHighValueLossUpdate, RouteSelected, SettingUpdated, TokenSearch, WidgetEvent, WidgetEvents } from "./types/events.js";
|
|
16
16
|
import { WidgetEventEmitter, useWidgetEvents, widgetEvents } from "./hooks/useWidgetEvents.js";
|
|
17
|
+
import { QueryParameter, ScopeKeyParameter } from "./queries/types.js";
|
|
18
|
+
import { GetChainsOptions, GetChainsQueryFnData, GetChainsQueryKey, GetChainsQueryKeyParameters, GetChainsQueryOptions, getChainsQueryKey, getChainsQueryOptions, supportedChainTypes } from "./queries/getChains.js";
|
|
19
|
+
import { GetToolsOptions, GetToolsQueryFnData, GetToolsQueryKey, GetToolsQueryKeyParameters, GetToolsQueryOptions, getToolsQueryKey, getToolsQueryOptions } from "./queries/getTools.js";
|
|
20
|
+
import "./queries/index.js";
|
|
17
21
|
import { Bookmark, BookmarkActions, BookmarkProps, BookmarkState, BookmarkStore } from "./stores/bookmarks/types.js";
|
|
18
22
|
import { useFieldActions } from "./stores/form/useFieldActions.js";
|
|
19
23
|
import { useFieldValues } from "./stores/form/useFieldValues.js";
|
|
@@ -31,4 +35,4 @@ import { getPriceImpact } from "./utils/getPriceImpact.js";
|
|
|
31
35
|
import { percentFormatter } from "./utils/percentFormatter.js";
|
|
32
36
|
import { ChainId, ChainType, CoinKey } from "@lifi/sdk";
|
|
33
37
|
export type * from "@lifi/sdk";
|
|
34
|
-
export { AllowDeny, AllowDenyItems, AllowDenySet, AllowDenySetItem, AllowDenySets, Appearance, Bookmark, BookmarkActions, BookmarkProps, BookmarkState, BookmarkStore, CalculateFeeParams, ChainId, ChainPinned, ChainTokenSelected, ChainType, CoinKey, ContactSupport, CustomMode, DefaultFieldValues, DefaultUI, DefaultValues, DisabledUIConfig, ExpansionType, ExplorerUrl, ExtractValueType, FieldNames, FieldValues, FormActions, FormFieldArray, FormFieldChanged, FormFieldNames, FormFieldOptions, FormKeyHelper, FormProps, FormRef, FormRefProps, FormState, FormStoreStore, FormType, FormTypeProps, FormValueControl, FormValues, FormValuesState, GenericFormValue, HiddenUIConfig, InternalNavigationTabKey, InternalWidgetMode, ItemPrice, ItemPriceProps, App as LiFiWidget, LowAddressActivityConfirmed, ModeOptions, NFT, NFTBase, NFTBaseProps, NFTOwner, NFTProps, NavigationProps, NavigationTabChanged, NavigationTabKey, PoweredByType, RequiredUIConfig, ResetOptions, RouteExecutionUpdate, RouteHighValueLossUpdate, RouteLabel, RouteLabelRule, RouteSelected, SetFieldValueFunction, SetOptions, SettingUpdated, SplitMode, SplitModeOptions, SplitNavigationTabKey, ToAddress, type TokenAmount, TokenSearch, TouchedFields, ValidationActions, ValidationProps, WidgetChains, WidgetConfig, WidgetConfigPartialProps, WidgetConfigProps, WidgetContractTool, type WidgetDrawer, WidgetDrawerProps, WidgetEvent, type WidgetEventEmitter, WidgetEvents, WidgetFeeConfig, WidgetLanguages, WidgetMode, WidgetProps, WidgetProvider, WidgetSDKConfig, WidgetSkeleton, WidgetTheme, WidgetThemeComponents, WidgetTokens, WidgetVariant, WidgetWalletConfig, azureLightTheme, compactNumberFormatter, createTheme, currencyExtendedFormatter, defaultMaxHeight, formatDuration, formatInputAmount, formatSlippage, formatTokenAmount, formatTokenPrice, getPriceImpact, jumperTheme, name, navigationRoutes, palette, paletteDark, paletteLight, percentFormatter, priceToTokenAmount, usdDecimals, useFieldActions, useFieldValues, useWidgetChains, useWidgetEvents, version, watermelonLightTheme, widgetEvents, windows95Theme, wrapLongWords };
|
|
38
|
+
export { AllowDeny, AllowDenyItems, AllowDenySet, AllowDenySetItem, AllowDenySets, Appearance, Bookmark, BookmarkActions, BookmarkProps, BookmarkState, BookmarkStore, CalculateFeeParams, ChainId, ChainPinned, ChainTokenSelected, ChainType, CoinKey, ContactSupport, CustomMode, DefaultFieldValues, DefaultUI, DefaultValues, DisabledUIConfig, ExpansionType, ExplorerUrl, ExtractValueType, FieldNames, FieldValues, FormActions, FormFieldArray, FormFieldChanged, FormFieldNames, FormFieldOptions, FormKeyHelper, FormProps, FormRef, FormRefProps, FormState, FormStoreStore, FormType, FormTypeProps, FormValueControl, FormValues, FormValuesState, GenericFormValue, type GetChainsOptions, type GetChainsQueryFnData, type GetChainsQueryKey, type GetChainsQueryKeyParameters, type GetChainsQueryOptions, type GetToolsOptions, type GetToolsQueryFnData, type GetToolsQueryKey, type GetToolsQueryKeyParameters, type GetToolsQueryOptions, HiddenUIConfig, InternalNavigationTabKey, InternalWidgetMode, ItemPrice, ItemPriceProps, App as LiFiWidget, LowAddressActivityConfirmed, ModeOptions, NFT, NFTBase, NFTBaseProps, NFTOwner, NFTProps, NavigationProps, NavigationTabChanged, NavigationTabKey, PoweredByType, type QueryParameter, RequiredUIConfig, ResetOptions, RouteExecutionUpdate, RouteHighValueLossUpdate, RouteLabel, RouteLabelRule, RouteSelected, type ScopeKeyParameter, SetFieldValueFunction, SetOptions, SettingUpdated, SplitMode, SplitModeOptions, SplitNavigationTabKey, ToAddress, type TokenAmount, TokenSearch, TouchedFields, ValidationActions, ValidationProps, WidgetChains, WidgetConfig, WidgetConfigPartialProps, WidgetConfigProps, WidgetContractTool, type WidgetDrawer, WidgetDrawerProps, WidgetEvent, type WidgetEventEmitter, WidgetEvents, WidgetFeeConfig, WidgetLanguages, WidgetMode, WidgetProps, WidgetProvider, WidgetSDKConfig, WidgetSkeleton, WidgetTheme, WidgetThemeComponents, WidgetTokens, WidgetVariant, WidgetWalletConfig, azureLightTheme, compactNumberFormatter, createTheme, currencyExtendedFormatter, defaultMaxHeight, formatDuration, formatInputAmount, formatSlippage, formatTokenAmount, formatTokenPrice, getChainsQueryKey, getChainsQueryOptions, getPriceImpact, getToolsQueryKey, getToolsQueryOptions, jumperTheme, name, navigationRoutes, palette, paletteDark, paletteLight, percentFormatter, priceToTokenAmount, supportedChainTypes, usdDecimals, useFieldActions, useFieldValues, useWidgetChains, useWidgetEvents, version, watermelonLightTheme, widgetEvents, windows95Theme, wrapLongWords };
|
package/dist/esm/index.js
CHANGED
|
@@ -4,11 +4,13 @@ import { defaultMaxHeight } from "./config/constants.js";
|
|
|
4
4
|
import { ExpansionType } from "./types/widget.js";
|
|
5
5
|
import { navigationRoutes } from "./utils/navigationRoutes.js";
|
|
6
6
|
import { name, version } from "./config/version.js";
|
|
7
|
+
import { getChainsQueryKey, getChainsQueryOptions, supportedChainTypes } from "./queries/getChains.js";
|
|
7
8
|
import { useFieldActions } from "./stores/form/useFieldActions.js";
|
|
8
9
|
import { formatDuration, formatInputAmount, formatSlippage, formatTokenAmount, formatTokenPrice, priceToTokenAmount, usdDecimals, wrapLongWords } from "./utils/format.js";
|
|
9
10
|
import { FormKeyHelper } from "./stores/form/types.js";
|
|
10
11
|
import { useFieldValues } from "./stores/form/useFieldValues.js";
|
|
11
12
|
import { getPriceImpact } from "./utils/getPriceImpact.js";
|
|
13
|
+
import { getToolsQueryKey, getToolsQueryOptions } from "./queries/getTools.js";
|
|
12
14
|
import { compactNumberFormatter } from "./utils/compactNumberFormatter.js";
|
|
13
15
|
import { currencyExtendedFormatter } from "./utils/currencyExtendedFormatter.js";
|
|
14
16
|
import { percentFormatter } from "./utils/percentFormatter.js";
|
|
@@ -25,4 +27,4 @@ import { jumperTheme } from "./themes/jumper.js";
|
|
|
25
27
|
import { watermelonLightTheme } from "./themes/watermelonLight.js";
|
|
26
28
|
import { windows95Theme } from "./themes/windows95.js";
|
|
27
29
|
import { ChainId, ChainType, CoinKey } from "@lifi/sdk";
|
|
28
|
-
export { ChainId, ChainType, CoinKey, ExpansionType, FormKeyHelper, ItemPrice, App as LiFiWidget, NFT, NFTBase, WidgetEvent, WidgetSkeleton, azureLightTheme, compactNumberFormatter, createTheme, currencyExtendedFormatter, defaultMaxHeight, formatDuration, formatInputAmount, formatSlippage, formatTokenAmount, formatTokenPrice, getPriceImpact, jumperTheme, name, navigationRoutes, palette, paletteDark, paletteLight, percentFormatter, priceToTokenAmount, usdDecimals, useFieldActions, useFieldValues, useWidgetChains, useWidgetEvents, version, watermelonLightTheme, widgetEvents, windows95Theme, wrapLongWords };
|
|
30
|
+
export { ChainId, ChainType, CoinKey, ExpansionType, FormKeyHelper, ItemPrice, App as LiFiWidget, NFT, NFTBase, WidgetEvent, WidgetSkeleton, azureLightTheme, compactNumberFormatter, createTheme, currencyExtendedFormatter, defaultMaxHeight, formatDuration, formatInputAmount, formatSlippage, formatTokenAmount, formatTokenPrice, getChainsQueryKey, getChainsQueryOptions, getPriceImpact, getToolsQueryKey, getToolsQueryOptions, jumperTheme, name, navigationRoutes, palette, paletteDark, paletteLight, percentFormatter, priceToTokenAmount, supportedChainTypes, usdDecimals, useFieldActions, useFieldValues, useWidgetChains, useWidgetEvents, version, watermelonLightTheme, widgetEvents, windows95Theme, wrapLongWords };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutesPage.style.d.ts","names":[],"sources":["../../../../src/pages/RoutesPage/RoutesPage.style.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"RoutesPage.style.d.ts","names":["Stack","MuiStack"],"sources":["../../../../src/pages/RoutesPage/RoutesPage.style.ts"],"mappings":";;;cAGaA,SAAO,MAAM,GAAG,MAAM,sBAAsBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../../src/providers/I18nProvider/types.ts"],"mappings":";;YAEY,gBAAgB,KAAK,sBAE1B,WAAW,KAAK,gBAAgB,EAAE,SAErC;YAEQ;YAmBA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":["enResource"],"sources":["../../../../src/providers/I18nProvider/types.ts"],"mappings":";;YAEY,gBAAgB,KAAK,sBAE1B,WAAW,KAAK,gBAAgB,EAAE,SAErC;YAEQ;YAmBA,0BAA0BA;YAE1B,uBAEL,KAAK,eAAe,gBAAgB;GAGjB,mBAAA,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetProvider.d.ts","names":[],"sources":["../../../../src/providers/WidgetProvider/WidgetProvider.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"WidgetProvider.d.ts","names":[],"sources":["../../../../src/providers/WidgetProvider/WidgetProvider.tsx"],"mappings":";;;qBAmBa,uBAAsB;qBAEtB,gBAAgB,MAAM,GACjC,MAAM,kBAAkB"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { useSettingsActions } from "../../stores/settings/useSettingsActions.js";
|
|
2
|
+
import { defaultQueryScopeKey, resolveQueryScopeKey, resolveStorageScopeKey } from "../../utils/scopeKeys.js";
|
|
2
3
|
import { createContext, use, useId, useMemo } from "react";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
const WidgetContext = createContext({
|
|
5
6
|
elementId: "",
|
|
6
|
-
integrator: ""
|
|
7
|
+
integrator: "",
|
|
8
|
+
queryScopeKey: defaultQueryScopeKey
|
|
7
9
|
});
|
|
8
10
|
const useWidgetConfig = () => use(WidgetContext);
|
|
9
11
|
const WidgetProvider = ({ children, config: widgetConfig }) => {
|
|
@@ -11,9 +13,14 @@ const WidgetProvider = ({ children, config: widgetConfig }) => {
|
|
|
11
13
|
const { setDefaultSettings } = useSettingsActions();
|
|
12
14
|
if (!widgetConfig?.integrator) throw new Error("Required property \"integrator\" is missing.");
|
|
13
15
|
const value = useMemo(() => {
|
|
16
|
+
const scopeKeys = {
|
|
17
|
+
storageScopeKey: resolveStorageScopeKey(widgetConfig),
|
|
18
|
+
queryScopeKey: resolveQueryScopeKey(widgetConfig)
|
|
19
|
+
};
|
|
14
20
|
try {
|
|
15
21
|
const value = {
|
|
16
22
|
...widgetConfig,
|
|
23
|
+
...scopeKeys,
|
|
17
24
|
elementId
|
|
18
25
|
};
|
|
19
26
|
setDefaultSettings(value);
|
|
@@ -22,6 +29,7 @@ const WidgetProvider = ({ children, config: widgetConfig }) => {
|
|
|
22
29
|
console.warn(e);
|
|
23
30
|
return {
|
|
24
31
|
...widgetConfig,
|
|
32
|
+
...scopeKeys,
|
|
25
33
|
elementId,
|
|
26
34
|
integrator: widgetConfig.integrator
|
|
27
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetProvider.js","names":[],"sources":["../../../../src/providers/WidgetProvider/WidgetProvider.tsx"],"sourcesContent":["import type { Context } from 'react'\nimport { createContext, use, useId, useMemo } from 'react'\nimport { useSettingsActions } from '../../stores/settings/useSettingsActions.js'\nimport type { WidgetContextProps, WidgetProviderProps } from './types.js'\n\nconst initialContext: WidgetContextProps = {\n elementId: '',\n integrator: '',\n}\n\nexport const WidgetContext: Context<WidgetContextProps> =\n createContext<WidgetContextProps>(initialContext)\n\nexport const useWidgetConfig = (): WidgetContextProps => use(WidgetContext)\n\nexport const WidgetProvider: React.FC<\n React.PropsWithChildren<WidgetProviderProps>\n> = ({ children, config: widgetConfig }) => {\n const elementId = useId()\n const { setDefaultSettings } = useSettingsActions()\n\n if (!widgetConfig?.integrator) {\n throw new Error('Required property \"integrator\" is missing.')\n }\n\n const value = useMemo((): WidgetContextProps => {\n try {\n // Create widget configuration object\n const value = {\n ...widgetConfig,\n elementId,\n } as WidgetContextProps\n\n // Set default settings for widget settings store\n setDefaultSettings(value)\n\n return value\n } catch (e) {\n console.warn(e)\n return {\n ...widgetConfig,\n elementId,\n integrator: widgetConfig.integrator,\n }\n }\n }, [elementId, widgetConfig, setDefaultSettings])\n return <WidgetContext value={value}>{children}</WidgetContext>\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"WidgetProvider.js","names":[],"sources":["../../../../src/providers/WidgetProvider/WidgetProvider.tsx"],"sourcesContent":["import type { Context } from 'react'\nimport { createContext, use, useId, useMemo } from 'react'\nimport { useSettingsActions } from '../../stores/settings/useSettingsActions.js'\nimport {\n defaultQueryScopeKey,\n resolveQueryScopeKey,\n resolveStorageScopeKey,\n} from '../../utils/scopeKeys.js'\nimport type { WidgetContextProps, WidgetProviderProps } from './types.js'\n\nconst initialContext: WidgetContextProps = {\n elementId: '',\n integrator: '',\n queryScopeKey: defaultQueryScopeKey,\n}\n\nexport const WidgetContext: Context<WidgetContextProps> =\n createContext<WidgetContextProps>(initialContext)\n\nexport const useWidgetConfig = (): WidgetContextProps => use(WidgetContext)\n\nexport const WidgetProvider: React.FC<\n React.PropsWithChildren<WidgetProviderProps>\n> = ({ children, config: widgetConfig }) => {\n const elementId = useId()\n const { setDefaultSettings } = useSettingsActions()\n\n if (!widgetConfig?.integrator) {\n throw new Error('Required property \"integrator\" is missing.')\n }\n\n const value = useMemo((): WidgetContextProps => {\n // Resolved once, so nothing below reads the deprecated keyPrefix.\n const scopeKeys = {\n storageScopeKey: resolveStorageScopeKey(widgetConfig),\n queryScopeKey: resolveQueryScopeKey(widgetConfig),\n }\n try {\n // Create widget configuration object\n const value = {\n ...widgetConfig,\n ...scopeKeys,\n elementId,\n } as WidgetContextProps\n\n // Set default settings for widget settings store\n setDefaultSettings(value)\n\n return value\n } catch (e) {\n console.warn(e)\n return {\n ...widgetConfig,\n ...scopeKeys,\n elementId,\n integrator: widgetConfig.integrator,\n }\n }\n }, [elementId, widgetConfig, setDefaultSettings])\n return <WidgetContext value={value}>{children}</WidgetContext>\n}\n"],"mappings":";;;;AAgBA,MAAa,gBACX,cAAkC;CANlC,WAAW;CACX,YAAY;CACZ,eAAe;AAImB,CAAc;AAElD,MAAa,wBAA4C,IAAI,aAAa;AAE1E,MAAa,kBAER,EAAE,UAAU,QAAQ,mBAAmB;CAC1C,MAAM,YAAY,MAAM;CACxB,MAAM,EAAE,uBAAuB,mBAAmB;CAElD,IAAI,CAAC,cAAc,YACjB,MAAM,IAAI,MAAM,8CAA4C;CAG9D,MAAM,QAAQ,cAAkC;EAE9C,MAAM,YAAY;GAChB,iBAAiB,uBAAuB,YAAY;GACpD,eAAe,qBAAqB,YAAY;EAClD;EACA,IAAI;GAEF,MAAM,QAAQ;IACZ,GAAG;IACH,GAAG;IACH;GACF;GAGA,mBAAmB,KAAK;GAExB,OAAO;EACT,SAAS,GAAG;GACV,QAAQ,KAAK,CAAC;GACd,OAAO;IACL,GAAG;IACH,GAAG;IACH;IACA,YAAY,aAAa;GAC3B;EACF;CACF,GAAG;EAAC;EAAW;EAAc;CAAkB,CAAC;CAChD,OAAO,oBAAC,eAAD;EAAsB;EAAQ;CAAwB,CAAA;AAC/D"}
|
|
@@ -2,6 +2,8 @@ import { WidgetConfig } from "../../types/widget.js";
|
|
|
2
2
|
//#region src/providers/WidgetProvider/types.d.ts
|
|
3
3
|
export type WidgetContextProps = WidgetConfig & {
|
|
4
4
|
elementId: string;
|
|
5
|
+
/** Always resolved by `WidgetProvider` — see `resolveQueryScopeKey`. */
|
|
6
|
+
queryScopeKey: string;
|
|
5
7
|
};
|
|
6
8
|
export interface WidgetProviderProps {
|
|
7
9
|
config?: WidgetConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../../src/providers/WidgetProvider/types.ts"],"mappings":";;YAEY,qBAAqB;EAC/B;;iBAGe;EACf,SAAS"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../../src/providers/WidgetProvider/types.ts"],"mappings":";;YAEY,qBAAqB;EAC/B;;EAEA;;iBAGe;EACf,SAAS"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FactoryQueryOptions, QueryParameter, ScopeKeyParameter } from "./types.js";
|
|
2
|
+
import { ChainType, ExtendedChain, SDKClient } from "@lifi/sdk";
|
|
3
|
+
//#region src/queries/getChains.d.ts
|
|
4
|
+
/** Every chain type the widget supports, in the order keys are built in. */
|
|
5
|
+
export declare const supportedChainTypes: readonly ChainType[];
|
|
6
|
+
export type GetChainsQueryFnData = ExtendedChain[];
|
|
7
|
+
export type GetChainsQueryKeyParameters = {
|
|
8
|
+
/** API base the client talks to. Different bases return different chains. */
|
|
9
|
+
apiUrl: string;
|
|
10
|
+
chainTypes: readonly ChainType[];
|
|
11
|
+
} & ScopeKeyParameter;
|
|
12
|
+
export type GetChainsQueryKey = readonly ["chains", {
|
|
13
|
+
apiUrl: string;
|
|
14
|
+
chainTypes: ChainType[];
|
|
15
|
+
scopeKey?: string;
|
|
16
|
+
}];
|
|
17
|
+
/** The key alone — to read, set or invalidate the entry. */
|
|
18
|
+
export declare function getChainsQueryKey(parameters: GetChainsQueryKeyParameters): GetChainsQueryKey;
|
|
19
|
+
export type GetChainsOptions<selectData = GetChainsQueryFnData> = {
|
|
20
|
+
/** Chain types to request, in any order. Defaults to every supported type. */
|
|
21
|
+
chainTypes?: readonly ChainType[] | undefined;
|
|
22
|
+
} & ScopeKeyParameter & QueryParameter<GetChainsQueryFnData, selectData, GetChainsQueryKey>;
|
|
23
|
+
export type GetChainsQueryOptions<selectData = GetChainsQueryFnData> = FactoryQueryOptions<GetChainsQueryFnData, selectData, GetChainsQueryKey>;
|
|
24
|
+
/**
|
|
25
|
+
* Query options for the chain list of one API base.
|
|
26
|
+
*
|
|
27
|
+
* The key is `['chains', { apiUrl, chainTypes, scopeKey }]`: the API base and
|
|
28
|
+
* the requested types decide the response, the scope isolates integrations.
|
|
29
|
+
* The widget and a host app that build their options here, with the same
|
|
30
|
+
* scope, therefore share one cache entry and one request.
|
|
31
|
+
*
|
|
32
|
+
* The query has no side effects. A caller that needs the chains in its SDK
|
|
33
|
+
* client's storage calls `client.setChains` on the data — the entry may have
|
|
34
|
+
* been filled by another caller, so a `queryFn` cannot be relied on to run.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getChainsQueryOptions<selectData = GetChainsQueryFnData>(client: SDKClient, options?: GetChainsOptions<selectData>): GetChainsQueryOptions<selectData>;
|
|
37
|
+
//#endregion
|
|
38
|
+
//# sourceMappingURL=getChains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getChains.d.ts","names":[],"sources":["../../../src/queries/getChains.ts"],"mappings":";;;;qBASa,8BAA8B;YAS/B,uBAAuB;YAEvB;;EAEV;EACA,qBAAqB;IACnB;YAEQ;EAER;EAAgB,YAAY;EAAa;;;wBAS7B,kBACd,YAAY,8BACX;YAiBS,iBAAiB,aAAa;;EAExC,sBAAsB;IACpB,oBACF,eAAe,sBAAsB,YAAY;YAEvC,sBAAsB,aAAa,wBAC7C,oBAAoB,sBAAsB,YAAY;;;;;;;;;;;;;wBAcxC,sBAAsB,aAAa,sBACjD,QAAQ,WACR,UAAS,iBAAiB,cACzB,sBAAsB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ChainType, getChains } from "@lifi/sdk";
|
|
2
|
+
//#region src/queries/getChains.ts
|
|
3
|
+
/** Every chain type the widget supports, in the order keys are built in. */
|
|
4
|
+
const supportedChainTypes = [
|
|
5
|
+
ChainType.EVM,
|
|
6
|
+
ChainType.SVM,
|
|
7
|
+
ChainType.UTXO,
|
|
8
|
+
ChainType.MVM,
|
|
9
|
+
ChainType.TVM,
|
|
10
|
+
ChainType.STL
|
|
11
|
+
];
|
|
12
|
+
const rank = (type) => {
|
|
13
|
+
const index = supportedChainTypes.indexOf(type);
|
|
14
|
+
return index === -1 ? supportedChainTypes.length : index;
|
|
15
|
+
};
|
|
16
|
+
/** The key alone — to read, set or invalidate the entry. */
|
|
17
|
+
function getChainsQueryKey(parameters) {
|
|
18
|
+
const chainTypes = [...new Set(parameters.chainTypes)].sort((a, b) => rank(a) - rank(b) || a.localeCompare(b));
|
|
19
|
+
return ["chains", {
|
|
20
|
+
apiUrl: parameters.apiUrl,
|
|
21
|
+
chainTypes,
|
|
22
|
+
...parameters.scopeKey === void 0 ? {} : { scopeKey: parameters.scopeKey }
|
|
23
|
+
}];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Query options for the chain list of one API base.
|
|
27
|
+
*
|
|
28
|
+
* The key is `['chains', { apiUrl, chainTypes, scopeKey }]`: the API base and
|
|
29
|
+
* the requested types decide the response, the scope isolates integrations.
|
|
30
|
+
* The widget and a host app that build their options here, with the same
|
|
31
|
+
* scope, therefore share one cache entry and one request.
|
|
32
|
+
*
|
|
33
|
+
* The query has no side effects. A caller that needs the chains in its SDK
|
|
34
|
+
* client's storage calls `client.setChains` on the data — the entry may have
|
|
35
|
+
* been filled by another caller, so a `queryFn` cannot be relied on to run.
|
|
36
|
+
*/
|
|
37
|
+
function getChainsQueryOptions(client, options = {}) {
|
|
38
|
+
return {
|
|
39
|
+
...options.query,
|
|
40
|
+
queryKey: getChainsQueryKey({
|
|
41
|
+
apiUrl: client.config.apiUrl,
|
|
42
|
+
chainTypes: options.chainTypes ?? supportedChainTypes,
|
|
43
|
+
scopeKey: options.scopeKey
|
|
44
|
+
}),
|
|
45
|
+
queryFn: ({ queryKey: [, { chainTypes }] }) => getChains(client, { chainTypes })
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { getChainsQueryKey, getChainsQueryOptions, supportedChainTypes };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=getChains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getChains.js","names":[],"sources":["../../../src/queries/getChains.ts"],"sourcesContent":["import type { ExtendedChain, SDKClient } from '@lifi/sdk'\nimport { ChainType, getChains } from '@lifi/sdk'\nimport type {\n FactoryQueryOptions,\n QueryParameter,\n ScopeKeyParameter,\n} from './types.js'\n\n/** Every chain type the widget supports, in the order keys are built in. */\nexport const supportedChainTypes: readonly ChainType[] = [\n ChainType.EVM,\n ChainType.SVM,\n ChainType.UTXO,\n ChainType.MVM,\n ChainType.TVM,\n ChainType.STL,\n]\n\nexport type GetChainsQueryFnData = ExtendedChain[]\n\nexport type GetChainsQueryKeyParameters = {\n /** API base the client talks to. Different bases return different chains. */\n apiUrl: string\n chainTypes: readonly ChainType[]\n} & ScopeKeyParameter\n\nexport type GetChainsQueryKey = readonly [\n 'chains',\n { apiUrl: string; chainTypes: ChainType[]; scopeKey?: string },\n]\n\nconst rank = (type: ChainType): number => {\n const index = supportedChainTypes.indexOf(type)\n return index === -1 ? supportedChainTypes.length : index\n}\n\n/** The key alone — to read, set or invalidate the entry. */\nexport function getChainsQueryKey(\n parameters: GetChainsQueryKeyParameters\n): GetChainsQueryKey {\n // Array order is part of the query hash, so sort into one canonical order.\n const chainTypes = [...new Set(parameters.chainTypes)].sort(\n (a, b) => rank(a) - rank(b) || a.localeCompare(b)\n )\n return [\n 'chains',\n {\n apiUrl: parameters.apiUrl,\n chainTypes,\n ...(parameters.scopeKey === undefined\n ? {}\n : { scopeKey: parameters.scopeKey }),\n },\n ]\n}\n\nexport type GetChainsOptions<selectData = GetChainsQueryFnData> = {\n /** Chain types to request, in any order. Defaults to every supported type. */\n chainTypes?: readonly ChainType[] | undefined\n} & ScopeKeyParameter &\n QueryParameter<GetChainsQueryFnData, selectData, GetChainsQueryKey>\n\nexport type GetChainsQueryOptions<selectData = GetChainsQueryFnData> =\n FactoryQueryOptions<GetChainsQueryFnData, selectData, GetChainsQueryKey>\n\n/**\n * Query options for the chain list of one API base.\n *\n * The key is `['chains', { apiUrl, chainTypes, scopeKey }]`: the API base and\n * the requested types decide the response, the scope isolates integrations.\n * The widget and a host app that build their options here, with the same\n * scope, therefore share one cache entry and one request.\n *\n * The query has no side effects. A caller that needs the chains in its SDK\n * client's storage calls `client.setChains` on the data — the entry may have\n * been filled by another caller, so a `queryFn` cannot be relied on to run.\n */\nexport function getChainsQueryOptions<selectData = GetChainsQueryFnData>(\n client: SDKClient,\n options: GetChainsOptions<selectData> = {}\n): GetChainsQueryOptions<selectData> {\n return {\n ...options.query,\n queryKey: getChainsQueryKey({\n apiUrl: client.config.apiUrl,\n chainTypes: options.chainTypes ?? supportedChainTypes,\n scopeKey: options.scopeKey,\n }),\n // No signal: the data still fills the cache if all observers leave.\n queryFn: ({ queryKey: [, { chainTypes }] }) =>\n getChains(client, { chainTypes }),\n }\n}\n"],"mappings":";;;AASA,MAAa,sBAA4C;CACvD,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;AACZ;AAeA,MAAM,QAAQ,SAA4B;CACxC,MAAM,QAAQ,oBAAoB,QAAQ,IAAI;CAC9C,OAAO,UAAU,KAAK,oBAAoB,SAAS;AACrD;;AAGA,SAAgB,kBACd,YACmB;CAEnB,MAAM,aAAa,CAAC,GAAG,IAAI,IAAI,WAAW,UAAU,CAAC,CAAC,CAAC,MACpD,GAAG,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,CAClD;CACA,OAAO,CACL,UACA;EACE,QAAQ,WAAW;EACnB;EACA,GAAI,WAAW,aAAa,KAAA,IACxB,CAAC,IACD,EAAE,UAAU,WAAW,SAAS;CACtC,CACF;AACF;;;;;;;;;;;;;AAuBA,SAAgB,sBACd,QACA,UAAwC,CAAC,GACN;CACnC,OAAO;EACL,GAAG,QAAQ;EACX,UAAU,kBAAkB;GAC1B,QAAQ,OAAO,OAAO;GACtB,YAAY,QAAQ,cAAc;GAClC,UAAU,QAAQ;EACpB,CAAC;EAED,UAAU,EAAE,UAAU,GAAG,EAAE,oBACzB,UAAU,QAAQ,EAAE,WAAW,CAAC;CACpC;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FactoryQueryOptions, QueryParameter, ScopeKeyParameter } from "./types.js";
|
|
2
|
+
import { SDKClient, ToolsResponse } from "@lifi/sdk";
|
|
3
|
+
//#region src/queries/getTools.d.ts
|
|
4
|
+
export type GetToolsQueryFnData = ToolsResponse;
|
|
5
|
+
export type GetToolsQueryKeyParameters = {
|
|
6
|
+
/** API base the client talks to. Different bases return different tools. */
|
|
7
|
+
apiUrl: string;
|
|
8
|
+
} & ScopeKeyParameter;
|
|
9
|
+
export type GetToolsQueryKey = readonly ["tools", {
|
|
10
|
+
apiUrl: string;
|
|
11
|
+
scopeKey?: string;
|
|
12
|
+
}];
|
|
13
|
+
/** The key alone — to read, set or invalidate the entry. */
|
|
14
|
+
export declare function getToolsQueryKey(parameters: GetToolsQueryKeyParameters): GetToolsQueryKey;
|
|
15
|
+
export type GetToolsOptions<selectData = GetToolsQueryFnData> = ScopeKeyParameter & QueryParameter<GetToolsQueryFnData, selectData, GetToolsQueryKey>;
|
|
16
|
+
export type GetToolsQueryOptions<selectData = GetToolsQueryFnData> = FactoryQueryOptions<GetToolsQueryFnData, selectData, GetToolsQueryKey>;
|
|
17
|
+
/**
|
|
18
|
+
* Query options for the bridges and exchanges of one API base.
|
|
19
|
+
*
|
|
20
|
+
* The key is `['tools', { apiUrl, scopeKey }]`. The cache holds the raw,
|
|
21
|
+
* unfiltered response so every caller can share it; narrow it per caller with
|
|
22
|
+
* `query.select`, never in the `queryFn`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getToolsQueryOptions<selectData = GetToolsQueryFnData>(client: SDKClient, options?: GetToolsOptions<selectData>): GetToolsQueryOptions<selectData>;
|
|
25
|
+
//#endregion
|
|
26
|
+
//# sourceMappingURL=getTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTools.d.ts","names":[],"sources":["../../../src/queries/getTools.ts"],"mappings":";;;YAQY,sBAAsB;YAEtB;;EAEV;IACE;YAEQ;EAER;EAAgB;;;wBAIJ,iBACd,YAAY,6BACX;YAYS,gBAAgB,aAAa,uBACvC,oBACE,eAAe,qBAAqB,YAAY;YAExC,qBAAqB,aAAa,uBAC5C,oBAAoB,qBAAqB,YAAY;;;;;;;;wBASvC,qBAAqB,aAAa,qBAChD,QAAQ,WACR,UAAS,gBAAgB,cACxB,qBAAqB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getTools } from "@lifi/sdk";
|
|
2
|
+
//#region src/queries/getTools.ts
|
|
3
|
+
/** The key alone — to read, set or invalidate the entry. */
|
|
4
|
+
function getToolsQueryKey(parameters) {
|
|
5
|
+
return ["tools", {
|
|
6
|
+
apiUrl: parameters.apiUrl,
|
|
7
|
+
...parameters.scopeKey === void 0 ? {} : { scopeKey: parameters.scopeKey }
|
|
8
|
+
}];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Query options for the bridges and exchanges of one API base.
|
|
12
|
+
*
|
|
13
|
+
* The key is `['tools', { apiUrl, scopeKey }]`. The cache holds the raw,
|
|
14
|
+
* unfiltered response so every caller can share it; narrow it per caller with
|
|
15
|
+
* `query.select`, never in the `queryFn`.
|
|
16
|
+
*/
|
|
17
|
+
function getToolsQueryOptions(client, options = {}) {
|
|
18
|
+
return {
|
|
19
|
+
...options.query,
|
|
20
|
+
queryKey: getToolsQueryKey({
|
|
21
|
+
apiUrl: client.config.apiUrl,
|
|
22
|
+
scopeKey: options.scopeKey
|
|
23
|
+
}),
|
|
24
|
+
queryFn: ({ signal }) => getTools(client, void 0, { signal })
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { getToolsQueryKey, getToolsQueryOptions };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=getTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTools.js","names":[],"sources":["../../../src/queries/getTools.ts"],"sourcesContent":["import type { SDKClient, ToolsResponse } from '@lifi/sdk'\nimport { getTools } from '@lifi/sdk'\nimport type {\n FactoryQueryOptions,\n QueryParameter,\n ScopeKeyParameter,\n} from './types.js'\n\nexport type GetToolsQueryFnData = ToolsResponse\n\nexport type GetToolsQueryKeyParameters = {\n /** API base the client talks to. Different bases return different tools. */\n apiUrl: string\n} & ScopeKeyParameter\n\nexport type GetToolsQueryKey = readonly [\n 'tools',\n { apiUrl: string; scopeKey?: string },\n]\n\n/** The key alone — to read, set or invalidate the entry. */\nexport function getToolsQueryKey(\n parameters: GetToolsQueryKeyParameters\n): GetToolsQueryKey {\n return [\n 'tools',\n {\n apiUrl: parameters.apiUrl,\n ...(parameters.scopeKey === undefined\n ? {}\n : { scopeKey: parameters.scopeKey }),\n },\n ]\n}\n\nexport type GetToolsOptions<selectData = GetToolsQueryFnData> =\n ScopeKeyParameter &\n QueryParameter<GetToolsQueryFnData, selectData, GetToolsQueryKey>\n\nexport type GetToolsQueryOptions<selectData = GetToolsQueryFnData> =\n FactoryQueryOptions<GetToolsQueryFnData, selectData, GetToolsQueryKey>\n\n/**\n * Query options for the bridges and exchanges of one API base.\n *\n * The key is `['tools', { apiUrl, scopeKey }]`. The cache holds the raw,\n * unfiltered response so every caller can share it; narrow it per caller with\n * `query.select`, never in the `queryFn`.\n */\nexport function getToolsQueryOptions<selectData = GetToolsQueryFnData>(\n client: SDKClient,\n options: GetToolsOptions<selectData> = {}\n): GetToolsQueryOptions<selectData> {\n return {\n ...options.query,\n queryKey: getToolsQueryKey({\n apiUrl: client.config.apiUrl,\n scopeKey: options.scopeKey,\n }),\n queryFn: ({ signal }) => getTools(client, undefined, { signal }),\n }\n}\n"],"mappings":";;;AAqBA,SAAgB,iBACd,YACkB;CAClB,OAAO,CACL,SACA;EACE,QAAQ,WAAW;EACnB,GAAI,WAAW,aAAa,KAAA,IACxB,CAAC,IACD,EAAE,UAAU,WAAW,SAAS;CACtC,CACF;AACF;;;;;;;;AAgBA,SAAgB,qBACd,QACA,UAAuC,CAAC,GACN;CAClC,OAAO;EACL,GAAG,QAAQ;EACX,UAAU,iBAAiB;GACzB,QAAQ,OAAO,OAAO;GACtB,UAAU,QAAQ;EACpB,CAAC;EACD,UAAU,EAAE,aAAa,SAAS,QAAQ,KAAA,GAAW,EAAE,OAAO,CAAC;CACjE;AACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { QueryParameter, ScopeKeyParameter } from "./types.js";
|
|
2
|
+
import { GetChainsOptions, GetChainsQueryFnData, GetChainsQueryKey, GetChainsQueryKeyParameters, GetChainsQueryOptions, getChainsQueryKey, getChainsQueryOptions, supportedChainTypes } from "./getChains.js";
|
|
3
|
+
import { GetToolsOptions, GetToolsQueryFnData, GetToolsQueryKey, GetToolsQueryKeyParameters, GetToolsQueryOptions, getToolsQueryKey, getToolsQueryOptions } from "./getTools.js";
|
|
4
|
+
export { type GetChainsOptions, type GetChainsQueryFnData, type GetChainsQueryKey, type GetChainsQueryKeyParameters, type GetChainsQueryOptions, type GetToolsOptions, type GetToolsQueryFnData, type GetToolsQueryKey, type GetToolsQueryKeyParameters, type GetToolsQueryOptions, type QueryParameter, type ScopeKeyParameter, getChainsQueryKey, getChainsQueryOptions, getToolsQueryKey, getToolsQueryOptions, supportedChainTypes };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { getChainsQueryKey, getChainsQueryOptions, supportedChainTypes } from "./getChains.js";
|
|
2
|
+
import { getToolsQueryKey, getToolsQueryOptions } from "./getTools.js";
|
|
3
|
+
export { getChainsQueryKey, getChainsQueryOptions, getToolsQueryKey, getToolsQueryOptions, supportedChainTypes };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { QueryFunction, QueryKey, UseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
//#region src/queries/types.d.ts
|
|
3
|
+
export type ScopeKeyParameter = {
|
|
4
|
+
/**
|
|
5
|
+
* Scopes the entry inside a shared `QueryClient`, like wagmi's `scopeKey`.
|
|
6
|
+
* Callers that pass the same value share the cached data; a widget passes
|
|
7
|
+
* its `queryScopeKey`.
|
|
8
|
+
*/
|
|
9
|
+
scopeKey?: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Behaviour the caller owns — `staleTime`, `refetchInterval`, `select`,
|
|
13
|
+
* `enabled`, … It is spread into the options and never becomes part of the
|
|
14
|
+
* key, so callers with different behaviour still share one entry.
|
|
15
|
+
*/
|
|
16
|
+
export type QueryParameter<queryFnData, data, queryKey extends QueryKey> = {
|
|
17
|
+
query?: Omit<UseQueryOptions<queryFnData, Error, data, queryKey>, "queryKey" | "queryFn"> | undefined;
|
|
18
|
+
};
|
|
19
|
+
/** Options ready for `useQuery`, `fetchQuery` or `prefetchQuery`. */
|
|
20
|
+
export type FactoryQueryOptions<queryFnData, data, queryKey extends QueryKey> = UseQueryOptions<queryFnData, Error, data, queryKey> & {
|
|
21
|
+
queryKey: queryKey;
|
|
22
|
+
queryFn: QueryFunction<queryFnData, queryKey>;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/queries/types.ts"],"mappings":";;YAMY;;;;;;EAMV;;;;;;;YAQU,eAAe,aAAa,MAAM,iBAAiB;EAC7D,QACI,KACE,gBAAgB,aAAa,OAAO,MAAM;;;YAOtC,oBACV,aACA,MACA,iBAAiB,YACf,gBAAgB,aAAa,OAAO,MAAM;EAC5C,UAAU;EACV,SAAS,cAAc,aAAa"}
|
package/dist/esm/shared.d.ts
CHANGED
|
@@ -103,6 +103,7 @@ import { buildRouteFromTxHistory } from "./utils/converters.js";
|
|
|
103
103
|
import { ElementId, createElementId } from "./utils/elements.js";
|
|
104
104
|
import { hasEnumFlag } from "./utils/enum.js";
|
|
105
105
|
import { fitInputText } from "./utils/input.js";
|
|
106
|
+
import { resolveStorageScopeKey } from "./utils/scopeKeys.js";
|
|
106
107
|
import { isHttpUrl, openInNewTab } from "./utils/url.js";
|
|
107
108
|
import { shortenAddress } from "./utils/wallet.js";
|
|
108
|
-
export { ActionRow, AddressType, AmountInputEndAdornment, AvatarBadgedDefault, BaseTransactionButton, BookmarkStoreProvider, type BottomSheetBase, ButtonTertiary, Card, CardIconButton, CardTitle, ChainAvatar, ChainSelect, ConfirmToAddressSheet, ContactSupportButton, ContractComponent, DateLabelContainer, DateLabelText, DetailInfoIcon, DetailLabel, DetailLabelContainer, DetailRow, DetailValue, ElementId, ExchangeRateBottomSheet, type ExchangeRateBottomSheetBase, ExecutionDoneCard, type ExecutionRow, ExecutionStatusCard, ExternalLink, FeeBreakdownTooltip, FormControl, FormKeyHelper, type FormRef, type FormType, type FormTypeProps, I18nProvider, IconCircle, IconTypography, Input, InputCard, InputPriceButton, ListItemButton, MainWarningMessages, PageContainer, PoweredBy, ProgressToNextUpdate, QueryClientProvider, RouteCard, RouteCardSkeleton, RouteDetails, RouteExecutionStatus, RouteNotFoundCard, RouteTokens, RouteTracker, SDKClientProvider, SearchInput, SearchTokenInput, SelectChainPage, SendToWalletButton, SentToWalletRow, SettingsStoreProvider, Stack, StartTransactionButton, StatusIcon, StepActionsList, StoreProvider, Token, TokenAvatar, TokenNotFound, TokenRate, TokenValueBottomSheet, TransactionDoneButtons, VirtualizedTokenList, WalletProvider, WarningMessages, type WidgetConfig, WidgetEvent, WidgetProvider, type WidgetTheme, buildRouteFromTxHistory, calculateValueLossPercentage, createElementId, createTheme, fitInputText, formatDuration, formatInputAmount, formatTokenAmount, formatTokenPrice, getAccumulatedFeeCostsBreakdown, getPriceImpact, getSourceTxHash, getTokenValueLossThreshold, hasEnumFlag, isHttpUrl, isRouteActive, isRouteDone, isRouteFailed, navigationRoutes, openInNewTab, priceToTokenAmount, shortenAddress, usdDecimals, useAddressActivity, useAddressValidation, useAvailableChains, useChain, useChainOrderStore, useContactSupport, useDebouncedWatch, useExecutionRows, useExplorer, useFieldActions, useFieldValues, useHeader, useHeaderStore, useInputModeStore, useListHeight, useNavigateBack, useRouteExecution, useRouteExecutionMessage, useRouteExecutionStore, useRouteExecutionStoreContext, useRoutes, useSDKClient, useSetHeaderHeight, useSettingsStoreContext, useToAddressRequirements, useToken, useTokenAddressBalance, useTokenBalances, useTokenList, useTokenSelect, useTools, useWidgetConfig, useWidgetEvents };
|
|
109
|
+
export { ActionRow, AddressType, AmountInputEndAdornment, AvatarBadgedDefault, BaseTransactionButton, BookmarkStoreProvider, type BottomSheetBase, ButtonTertiary, Card, CardIconButton, CardTitle, ChainAvatar, ChainSelect, ConfirmToAddressSheet, ContactSupportButton, ContractComponent, DateLabelContainer, DateLabelText, DetailInfoIcon, DetailLabel, DetailLabelContainer, DetailRow, DetailValue, ElementId, ExchangeRateBottomSheet, type ExchangeRateBottomSheetBase, ExecutionDoneCard, type ExecutionRow, ExecutionStatusCard, ExternalLink, FeeBreakdownTooltip, FormControl, FormKeyHelper, type FormRef, type FormType, type FormTypeProps, I18nProvider, IconCircle, IconTypography, Input, InputCard, InputPriceButton, ListItemButton, MainWarningMessages, PageContainer, PoweredBy, ProgressToNextUpdate, QueryClientProvider, RouteCard, RouteCardSkeleton, RouteDetails, RouteExecutionStatus, RouteNotFoundCard, RouteTokens, RouteTracker, SDKClientProvider, SearchInput, SearchTokenInput, SelectChainPage, SendToWalletButton, SentToWalletRow, SettingsStoreProvider, Stack, StartTransactionButton, StatusIcon, StepActionsList, StoreProvider, Token, TokenAvatar, TokenNotFound, TokenRate, TokenValueBottomSheet, TransactionDoneButtons, VirtualizedTokenList, WalletProvider, WarningMessages, type WidgetConfig, WidgetEvent, WidgetProvider, type WidgetTheme, buildRouteFromTxHistory, calculateValueLossPercentage, createElementId, createTheme, fitInputText, formatDuration, formatInputAmount, formatTokenAmount, formatTokenPrice, getAccumulatedFeeCostsBreakdown, getPriceImpact, getSourceTxHash, getTokenValueLossThreshold, hasEnumFlag, isHttpUrl, isRouteActive, isRouteDone, isRouteFailed, navigationRoutes, openInNewTab, priceToTokenAmount, resolveStorageScopeKey, shortenAddress, usdDecimals, useAddressActivity, useAddressValidation, useAvailableChains, useChain, useChainOrderStore, useContactSupport, useDebouncedWatch, useExecutionRows, useExplorer, useFieldActions, useFieldValues, useHeader, useHeaderStore, useInputModeStore, useListHeight, useNavigateBack, useRouteExecution, useRouteExecutionMessage, useRouteExecutionStore, useRouteExecutionStoreContext, useRoutes, useSDKClient, useSetHeaderHeight, useSettingsStoreContext, useToAddressRequirements, useToken, useTokenAddressBalance, useTokenBalances, useTokenList, useTokenSelect, useTools, useWidgetConfig, useWidgetEvents };
|
package/dist/esm/shared.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useWidgetEvents } from "./hooks/useWidgetEvents.js";
|
|
2
2
|
import { WidgetEvent } from "./types/events.js";
|
|
3
3
|
import { SettingsStoreProvider, useSettingsStoreContext } from "./stores/settings/SettingsStore.js";
|
|
4
|
+
import { resolveStorageScopeKey } from "./utils/scopeKeys.js";
|
|
4
5
|
import { WidgetProvider, useWidgetConfig } from "./providers/WidgetProvider/WidgetProvider.js";
|
|
5
6
|
import { useHeaderStore, useSetHeaderHeight } from "./stores/header/useHeaderStore.js";
|
|
6
7
|
import { ElementId, createElementId } from "./utils/elements.js";
|
|
@@ -103,4 +104,4 @@ import { createTheme } from "./themes/createTheme.js";
|
|
|
103
104
|
import { WalletProvider } from "./providers/WalletProvider/WalletProvider.js";
|
|
104
105
|
import { StoreProvider } from "./stores/StoreProvider.js";
|
|
105
106
|
import { useTokenList } from "./hooks/useTokenList.js";
|
|
106
|
-
export { ActionRow, AddressType, AmountInputEndAdornment, AvatarBadgedDefault, BaseTransactionButton, BookmarkStoreProvider, ButtonTertiary, Card, CardIconButton, CardTitle, ChainAvatar, ChainSelect, ConfirmToAddressSheet, ContactSupportButton, ContractComponent, DateLabelContainer, DateLabelText, DetailInfoIcon, DetailLabel, DetailLabelContainer, DetailRow, DetailValue, ElementId, ExchangeRateBottomSheet, ExecutionDoneCard, ExecutionStatusCard, ExternalLink, FeeBreakdownTooltip, FormControl, FormKeyHelper, I18nProvider, IconCircle, IconTypography, Input, InputCard, InputPriceButton, ListItemButton, MainWarningMessages, PageContainer, PoweredBy, ProgressToNextUpdate, QueryClientProvider, RouteCard, RouteCardSkeleton, RouteDetails, RouteExecutionStatus, RouteNotFoundCard, RouteTokens, RouteTracker, SDKClientProvider, SearchInput, SearchTokenInput, SelectChainPage, SendToWalletButton, SentToWalletRow, SettingsStoreProvider, Stack, StartTransactionButton, StatusIcon, StepActionsList, StoreProvider, Token, TokenAvatar, TokenNotFound, TokenRate, TokenValueBottomSheet, TransactionDoneButtons, VirtualizedTokenList, WalletProvider, WarningMessages, WidgetEvent, WidgetProvider, buildRouteFromTxHistory, calculateValueLossPercentage, createElementId, createTheme, fitInputText, formatDuration, formatInputAmount, formatTokenAmount, formatTokenPrice, getAccumulatedFeeCostsBreakdown, getPriceImpact, getSourceTxHash, getTokenValueLossThreshold, hasEnumFlag, isHttpUrl, isRouteActive, isRouteDone, isRouteFailed, navigationRoutes, openInNewTab, priceToTokenAmount, shortenAddress, usdDecimals, useAddressActivity, useAddressValidation, useAvailableChains, useChain, useChainOrderStore, useContactSupport, useDebouncedWatch, useExecutionRows, useExplorer, useFieldActions, useFieldValues, useHeader, useHeaderStore, useInputModeStore, useListHeight, useNavigateBack, useRouteExecution, useRouteExecutionMessage, useRouteExecutionStore, useRouteExecutionStoreContext, useRoutes, useSDKClient, useSetHeaderHeight, useSettingsStoreContext, useToAddressRequirements, useToken, useTokenAddressBalance, useTokenBalances, useTokenList, useTokenSelect, useTools, useWidgetConfig, useWidgetEvents };
|
|
107
|
+
export { ActionRow, AddressType, AmountInputEndAdornment, AvatarBadgedDefault, BaseTransactionButton, BookmarkStoreProvider, ButtonTertiary, Card, CardIconButton, CardTitle, ChainAvatar, ChainSelect, ConfirmToAddressSheet, ContactSupportButton, ContractComponent, DateLabelContainer, DateLabelText, DetailInfoIcon, DetailLabel, DetailLabelContainer, DetailRow, DetailValue, ElementId, ExchangeRateBottomSheet, ExecutionDoneCard, ExecutionStatusCard, ExternalLink, FeeBreakdownTooltip, FormControl, FormKeyHelper, I18nProvider, IconCircle, IconTypography, Input, InputCard, InputPriceButton, ListItemButton, MainWarningMessages, PageContainer, PoweredBy, ProgressToNextUpdate, QueryClientProvider, RouteCard, RouteCardSkeleton, RouteDetails, RouteExecutionStatus, RouteNotFoundCard, RouteTokens, RouteTracker, SDKClientProvider, SearchInput, SearchTokenInput, SelectChainPage, SendToWalletButton, SentToWalletRow, SettingsStoreProvider, Stack, StartTransactionButton, StatusIcon, StepActionsList, StoreProvider, Token, TokenAvatar, TokenNotFound, TokenRate, TokenValueBottomSheet, TransactionDoneButtons, VirtualizedTokenList, WalletProvider, WarningMessages, WidgetEvent, WidgetProvider, buildRouteFromTxHistory, calculateValueLossPercentage, createElementId, createTheme, fitInputText, formatDuration, formatInputAmount, formatTokenAmount, formatTokenPrice, getAccumulatedFeeCostsBreakdown, getPriceImpact, getSourceTxHash, getTokenValueLossThreshold, hasEnumFlag, isHttpUrl, isRouteActive, isRouteDone, isRouteFailed, navigationRoutes, openInNewTab, priceToTokenAmount, resolveStorageScopeKey, shortenAddress, usdDecimals, useAddressActivity, useAddressValidation, useAvailableChains, useChain, useChainOrderStore, useContactSupport, useDebouncedWatch, useExecutionRows, useExplorer, useFieldActions, useFieldValues, useHeader, useHeaderStore, useInputModeStore, useListHeight, useNavigateBack, useRouteExecution, useRouteExecutionMessage, useRouteExecutionStore, useRouteExecutionStoreContext, useRoutes, useSDKClient, useSetHeaderHeight, useSettingsStoreContext, useToAddressRequirements, useToken, useTokenAddressBalance, useTokenBalances, useTokenList, useTokenSelect, useTools, useWidgetConfig, useWidgetEvents };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoreProvider.d.ts","names":[],"sources":["../../../src/stores/StoreProvider.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"StoreProvider.d.ts","names":[],"sources":["../../../src/stores/StoreProvider.tsx"],"mappings":";;;qBAYa,eAAe,MAAM,GAAG,kBAAkB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveStorageScopeKey } from "../utils/scopeKeys.js";
|
|
1
2
|
import { HeaderStoreProvider } from "./header/useHeaderStore.js";
|
|
2
3
|
import { NavigationTabsStoreProvider } from "./navigationTabs/useNavigationTabsStore.js";
|
|
3
4
|
import { BookmarkStoreProvider } from "./bookmarks/BookmarkStore.js";
|
|
@@ -9,30 +10,28 @@ import { FormStoreProvider } from "./form/FormStore.js";
|
|
|
9
10
|
import { jsx } from "react/jsx-runtime";
|
|
10
11
|
//#region src/stores/StoreProvider.tsx
|
|
11
12
|
const StoreProvider = ({ children, config, formRef }) => {
|
|
13
|
+
const storageScopeKey = resolveStorageScopeKey(config);
|
|
12
14
|
return /* @__PURE__ */ jsx(NavigationTabsStoreProvider, {
|
|
13
15
|
config,
|
|
14
|
-
children: /* @__PURE__ */ jsx(HeaderStoreProvider, {
|
|
15
|
-
namePrefix:
|
|
16
|
-
children: /* @__PURE__ */ jsx(
|
|
17
|
-
namePrefix:
|
|
18
|
-
children: /* @__PURE__ */ jsx(
|
|
19
|
-
namePrefix:
|
|
20
|
-
children: /* @__PURE__ */ jsx(
|
|
21
|
-
|
|
22
|
-
children: /* @__PURE__ */ jsx(
|
|
23
|
-
|
|
24
|
-
children: /* @__PURE__ */ jsx(
|
|
25
|
-
namePrefix:
|
|
26
|
-
children
|
|
27
|
-
namePrefix: config?.keyPrefix,
|
|
28
|
-
children
|
|
29
|
-
})
|
|
16
|
+
children: /* @__PURE__ */ jsx(HeaderStoreProvider, { children: /* @__PURE__ */ jsx(BookmarkStoreProvider, {
|
|
17
|
+
namePrefix: storageScopeKey,
|
|
18
|
+
children: /* @__PURE__ */ jsx(PinnedTokensStoreProvider, {
|
|
19
|
+
namePrefix: storageScopeKey,
|
|
20
|
+
children: /* @__PURE__ */ jsx(RecentTokensStoreProvider, {
|
|
21
|
+
namePrefix: storageScopeKey,
|
|
22
|
+
children: /* @__PURE__ */ jsx(FormStoreProvider, {
|
|
23
|
+
formRef,
|
|
24
|
+
children: /* @__PURE__ */ jsx(ChainOrderStoreProvider, {
|
|
25
|
+
namePrefix: storageScopeKey,
|
|
26
|
+
children: /* @__PURE__ */ jsx(RouteExecutionStoreProvider, {
|
|
27
|
+
namePrefix: storageScopeKey,
|
|
28
|
+
children
|
|
30
29
|
})
|
|
31
30
|
})
|
|
32
31
|
})
|
|
33
32
|
})
|
|
34
33
|
})
|
|
35
|
-
})
|
|
34
|
+
}) })
|
|
36
35
|
});
|
|
37
36
|
};
|
|
38
37
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoreProvider.js","names":[],"sources":["../../../src/stores/StoreProvider.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react'\nimport type { WidgetConfigProps } from '../types/widget.js'\nimport { BookmarkStoreProvider } from './bookmarks/BookmarkStore.js'\nimport { ChainOrderStoreProvider } from './chains/ChainOrderStore.js'\nimport { FormStoreProvider } from './form/FormStore.js'\nimport { HeaderStoreProvider } from './header/useHeaderStore.js'\nimport { NavigationTabsStoreProvider } from './navigationTabs/useNavigationTabsStore.js'\nimport { PinnedTokensStoreProvider } from './pinnedTokens/PinnedTokensStore.js'\nimport { RecentTokensStoreProvider } from './recentTokens/RecentTokensStore.js'\nimport { RouteExecutionStoreProvider } from './routes/RouteExecutionStore.js'\n\nexport const StoreProvider: React.FC<PropsWithChildren<WidgetConfigProps>> = ({\n children,\n config,\n formRef,\n}) => {\n return (\n <NavigationTabsStoreProvider config={config}>\n <HeaderStoreProvider
|
|
1
|
+
{"version":3,"file":"StoreProvider.js","names":[],"sources":["../../../src/stores/StoreProvider.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react'\nimport type { WidgetConfigProps } from '../types/widget.js'\nimport { resolveStorageScopeKey } from '../utils/scopeKeys.js'\nimport { BookmarkStoreProvider } from './bookmarks/BookmarkStore.js'\nimport { ChainOrderStoreProvider } from './chains/ChainOrderStore.js'\nimport { FormStoreProvider } from './form/FormStore.js'\nimport { HeaderStoreProvider } from './header/useHeaderStore.js'\nimport { NavigationTabsStoreProvider } from './navigationTabs/useNavigationTabsStore.js'\nimport { PinnedTokensStoreProvider } from './pinnedTokens/PinnedTokensStore.js'\nimport { RecentTokensStoreProvider } from './recentTokens/RecentTokensStore.js'\nimport { RouteExecutionStoreProvider } from './routes/RouteExecutionStore.js'\n\nexport const StoreProvider: React.FC<PropsWithChildren<WidgetConfigProps>> = ({\n children,\n config,\n formRef,\n}) => {\n const storageScopeKey = resolveStorageScopeKey(config)\n return (\n <NavigationTabsStoreProvider config={config}>\n <HeaderStoreProvider>\n <BookmarkStoreProvider namePrefix={storageScopeKey}>\n <PinnedTokensStoreProvider namePrefix={storageScopeKey}>\n <RecentTokensStoreProvider namePrefix={storageScopeKey}>\n <FormStoreProvider formRef={formRef}>\n <ChainOrderStoreProvider namePrefix={storageScopeKey}>\n <RouteExecutionStoreProvider namePrefix={storageScopeKey}>\n {children}\n </RouteExecutionStoreProvider>\n </ChainOrderStoreProvider>\n </FormStoreProvider>\n </RecentTokensStoreProvider>\n </PinnedTokensStoreProvider>\n </BookmarkStoreProvider>\n </HeaderStoreProvider>\n </NavigationTabsStoreProvider>\n )\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,iBAAiE,EAC5E,UACA,QACA,cACI;CACJ,MAAM,kBAAkB,uBAAuB,MAAM;CACrD,OACE,oBAAC,6BAAD;EAAqC;EACnC,UAAA,oBAAC,qBAAD,EAAA,UACE,oBAAC,uBAAD;GAAuB,YAAY;GACjC,UAAA,oBAAC,2BAAD;IAA2B,YAAY;IACrC,UAAA,oBAAC,2BAAD;KAA2B,YAAY;KACrC,UAAA,oBAAC,mBAAD;MAA4B;MAC1B,UAAA,oBAAC,yBAAD;OAAyB,YAAY;OACnC,UAAA,oBAAC,6BAAD;QAA6B,YAAY;QACtC;OAC0B,CAAA;MACN,CAAA;KACR,CAAA;IACM,CAAA;GACF,CAAA;EACN,CAAA,EACJ,CAAA;CACM,CAAA;AAEjC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../types.js";
|
|
2
1
|
import { HeaderState } from "./types.js";
|
|
2
|
+
import { PropsWithChildren } from "react";
|
|
3
3
|
//#region src/stores/header/useHeaderStore.d.ts
|
|
4
4
|
export declare function useHeaderStore<T>(selector: (state: HeaderState) => T): T;
|
|
5
5
|
export declare function useSetHeaderHeight(): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHeaderStore.d.ts","names":[],"sources":["../../../../src/stores/header/useHeaderStore.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"useHeaderStore.d.ts","names":[],"sources":["../../../../src/stores/header/useHeaderStore.tsx"],"mappings":";;;wBA6BgB,eAAe,GAAG,WAAW,OAAO,gBAAgB,IAAI;wBAkBxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHeaderStore.js","names":[],"sources":["../../../../src/stores/header/useHeaderStore.tsx"],"sourcesContent":["import { createContext, use, useRef } from 'react'\nimport { create } from 'zustand'\nimport { useShallow } from 'zustand/shallow'\nimport type {
|
|
1
|
+
{"version":3,"file":"useHeaderStore.js","names":[],"sources":["../../../../src/stores/header/useHeaderStore.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react'\nimport { createContext, use, useRef } from 'react'\nimport { create } from 'zustand'\nimport { useShallow } from 'zustand/shallow'\nimport type { HeaderState, HeaderStore } from './types.js'\n\nconst HeaderStoreContext = createContext<HeaderStore | null>(null)\n\n// Not persisted, so it takes no storage scope.\nexport function HeaderStoreProvider({ children }: PropsWithChildren): any {\n const storeRef = useRef<HeaderStore>(null)\n if (!storeRef.current) {\n storeRef.current = createHeaderStore()\n }\n return (\n <HeaderStoreContext value={storeRef.current}>{children}</HeaderStoreContext>\n )\n}\n\nfunction useHeaderStoreContext() {\n const useStore = use(HeaderStoreContext)\n if (!useStore) {\n throw new Error(\n `You forgot to wrap your component in <${HeaderStoreProvider.name}>.`\n )\n }\n return useStore\n}\n\nexport function useHeaderStore<T>(selector: (state: HeaderState) => T): T {\n const useStore = useHeaderStoreContext()\n return useStore(useShallow(selector))\n}\n\n// We use fixed position on the header when Widget is in Full Height layout.\n// We do this to get it to work like the sticky header does in the other layout modes.\n// As the header is position fixed its not in the document flow anymore.\n// To prevent the remaining page content from appearing behind the header we need to\n// pass the headers height so that the position of the page content can be adjusted\nexport function useHeaderHeight(): any {\n const headerHeight = useHeaderStore((state) => state.headerHeight)\n\n return {\n headerHeight,\n }\n}\n\nexport function useSetHeaderHeight(): any {\n const setHeaderHeight = useHeaderStore((state) => state.setHeaderHeight)\n\n return {\n setHeaderHeight,\n }\n}\n\nconst createHeaderStore = () =>\n create<HeaderState>((set, get) => ({\n headerHeight: 108, // default header height\n setAction: (element) => {\n set(() => ({\n element,\n }))\n return get().removeAction\n },\n setTitle: (title) => {\n set(() => ({\n title,\n }))\n return get().removeTitle\n },\n removeAction: () => {\n set(() => ({\n element: null,\n }))\n },\n removeTitle: () => {\n set(() => ({\n title: undefined,\n }))\n },\n setHeaderHeight: (headerHeight) => {\n set(() => ({\n headerHeight,\n }))\n },\n setBackAction: (action) => {\n set(() => ({\n backAction: action,\n }))\n },\n executeBackAction: () => {\n const { backAction } = get()\n if (backAction) {\n backAction()\n set(() => ({\n backAction: undefined,\n }))\n }\n },\n }))\n"],"mappings":";;;;;AAMA,MAAM,qBAAqB,cAAkC,IAAI;AAGjE,SAAgB,oBAAoB,EAAE,YAAoC;CACxE,MAAM,WAAW,OAAoB,IAAI;CACzC,IAAI,CAAC,SAAS,SACZ,SAAS,UAAU,kBAAkB;CAEvC,OACE,oBAAC,oBAAD;EAAoB,OAAO,SAAS;EAAU;CAA6B,CAAA;AAE/E;AAEA,SAAS,wBAAwB;CAC/B,MAAM,WAAW,IAAI,kBAAkB;CACvC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,yCAAyC,oBAAoB,KAAK,GACpE;CAEF,OAAO;AACT;AAEA,SAAgB,eAAkB,UAAwC;CAExE,OADiB,sBACH,CAAC,CAAC,WAAW,QAAQ,CAAC;AACtC;AAOA,SAAgB,kBAAuB;CAGrC,OAAO,EACL,cAHmB,gBAAgB,UAAU,MAAM,YAGxC,EACb;AACF;AAEA,SAAgB,qBAA0B;CAGxC,OAAO,EACL,iBAHsB,gBAAgB,UAAU,MAAM,eAGxC,EAChB;AACF;AAEA,MAAM,0BACJ,QAAqB,KAAK,SAAS;CACjC,cAAc;CACd,YAAY,YAAY;EACtB,WAAW,EACT,QACF,EAAE;EACF,OAAO,IAAI,CAAC,CAAC;CACf;CACA,WAAW,UAAU;EACnB,WAAW,EACT,MACF,EAAE;EACF,OAAO,IAAI,CAAC,CAAC;CACf;CACA,oBAAoB;EAClB,WAAW,EACT,SAAS,KACX,EAAE;CACJ;CACA,mBAAmB;EACjB,WAAW,EACT,OAAO,KAAA,EACT,EAAE;CACJ;CACA,kBAAkB,iBAAiB;EACjC,WAAW,EACT,aACF,EAAE;CACJ;CACA,gBAAgB,WAAW;EACzB,WAAW,EACT,YAAY,OACd,EAAE;CACJ;CACA,yBAAyB;EACvB,MAAM,EAAE,eAAe,IAAI;EAC3B,IAAI,YAAY;GACd,WAAW;GACX,WAAW,EACT,YAAY,KAAA,EACd,EAAE;EACJ;CACF;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.d.ts","names":[],"sources":["../../../src/themes/createTheme.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"createTheme.d.ts","names":["createTheme"],"sources":["../../../src/themes/createTheme.ts"],"mappings":";;;cAuCaA,gBAAe,cAAa,gBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","names":[],"sources":["../../../src/types/events.ts"],"mappings":";;;;;;;oBAOY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU;EACV,oBAAoB,MAAM;EAC1B,kBAAkB,MAAM;EACxB,cAAc,MAAM;EACpB,iBAAiB,MAAM;EACvB,gCAAgC,MAAM;EACtC,mBAAmB,MAAM;EACzB,8BAA8B,MAAM;EACpC,uBAAuB,MAAM;EAC7B,cAAc,MAAM;EACpB,0BAA0B,MAAM;EAChC,uBAAuB,MAAM;EAC7B,wBAAwB,MAAM;EAC9B,wBAAwB,MAAM;EAC9B,qBAAqB,MAAM;EAC3B,gBAAgB,MAAM;EACtB,sBAAsB;EACtB,iBAAiB,MAAM;EACvB,2BAA2B,MAAM;EACjC,cAAc,MAAM;EACpB,iBAAiB;;YAUP;EACV;;YAGU;EACV;EACA;EACA;EACA;EACA;;YAGU;EACV,OAAO;EACP,QAAQ;;YAGE;EACV,OAAO;EACP,QAAQ;;YAGE;EACV;EACA,
|
|
1
|
+
{"version":3,"file":"events.d.ts","names":["TokenAmount"],"sources":["../../../src/types/events.ts"],"mappings":";;;;;;;oBAOY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU;EACV,oBAAoB,MAAM;EAC1B,kBAAkB,MAAM;EACxB,cAAc,MAAM;EACpB,iBAAiB,MAAM;EACvB,gCAAgC,MAAM;EACtC,mBAAmB,MAAM;EACzB,8BAA8B,MAAM;EACpC,uBAAuB,MAAM;EAC7B,cAAc,MAAM;EACpB,0BAA0B,MAAM;EAChC,uBAAuB,MAAM;EAC7B,wBAAwB,MAAM;EAC9B,wBAAwB,MAAM;EAC9B,qBAAqB,MAAM;EAC3B,gBAAgB,MAAM;EACtB,sBAAsB;EACtB,iBAAiB,MAAM;EACvB,2BAA2B,MAAM;EACjC,cAAc,MAAM;EACpB,iBAAiB;;YAUP;EACV;;YAGU;EACV;EACA;EACA;EACA;EACA;;YAGU;EACV,OAAO;EACP,QAAQ;;YAGE;EACV,OAAO;EACP,QAAQ;;YAGE;EACV;EACA,QAAQA;;YAGE;EACV,SAAS;EACT;;YAGU,sBACT,WAAW;EACV,WAAW;EACX,UAAU,cAAc;EACxB,UAAU,cAAc;WAEpB;YAEI,eACV,gBAAgB,sBAAsB;EAEtC,SAAS;EACT,UAAU,cAAc;EACxB,UAAU,cAAc;EACxB,aAAa;EACb,aAAa;;YAGH;EACV;EACA;;YAGU;EACV;EACA;;YAGU;;EAEV,KAAK;;EAEL,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","names":[],"sources":["../../../src/types/token.ts"],"mappings":";;iBAMiB;EACf;EACA;EACA;;EAEA;EACA;EACA;;EAEA;;
|
|
1
|
+
{"version":3,"file":"token.d.ts","names":["TokenAmount","SDKTokenAmount"],"sources":["../../../src/types/token.ts"],"mappings":";;iBAMiB;EACf;EACA;EACA;;EAEA;EACA;EACA;;EAEA;;UAGeA,sBAAoBC,aAAgB"}
|
|
@@ -307,7 +307,37 @@ export interface WidgetConfig {
|
|
|
307
307
|
walletConfig?: WidgetWalletConfig;
|
|
308
308
|
sdkConfig?: WidgetSDKConfig;
|
|
309
309
|
buildUrl?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* @deprecated Use `storageScopeKey` for persisted state and `queryScopeKey`
|
|
312
|
+
* for the query cache. Still honoured as the fallback for both.
|
|
313
|
+
*/
|
|
310
314
|
keyPrefix?: string;
|
|
315
|
+
/**
|
|
316
|
+
* Namespaces the widget's persisted state in `localStorage`: bookmarks,
|
|
317
|
+
* pinned tokens, recent tokens, chain order and route history, as
|
|
318
|
+
* `keyPrefix` does. Use a different value per widget instance that should
|
|
319
|
+
* keep its own state. Settings keep one shared name.
|
|
320
|
+
*
|
|
321
|
+
* It also scopes the widget's other queries (routes, tokens, balances, …),
|
|
322
|
+
* so instances with different values keep their data apart.
|
|
323
|
+
*
|
|
324
|
+
* Falls back to `keyPrefix`, then to the historical `li.fi-*` names.
|
|
325
|
+
*/
|
|
326
|
+
storageScopeKey?: string;
|
|
327
|
+
/**
|
|
328
|
+
* Scopes the widget's chains and tools queries inside the host's react-query
|
|
329
|
+
* `QueryClient`. Widget instances - and a host app using the
|
|
330
|
+
* `@lifi/widget/queries` factories - that pass the same value
|
|
331
|
+
* share those entries. The other widget queries are scoped by
|
|
332
|
+
* `storageScopeKey`.
|
|
333
|
+
*
|
|
334
|
+
* The keys start with a plain `'chains'` / `'tools'`, as in wagmi, so a host
|
|
335
|
+
* that matches on those roots (for example `setQueriesData({ queryKey:
|
|
336
|
+
* ['chains'] })`) also reaches the widget's entries.
|
|
337
|
+
*
|
|
338
|
+
* Falls back to `keyPrefix`, then to `'li.fi'`.
|
|
339
|
+
*/
|
|
340
|
+
queryScopeKey?: string;
|
|
311
341
|
bridges?: AllowDeny<string>;
|
|
312
342
|
exchanges?: AllowDeny<string>;
|
|
313
343
|
chains?: WidgetChains;
|