@aurora-is-near/intents-swap-widget 1.3.2 → 1.4.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/config.d.ts +1 -0
- package/dist/config.js +21 -18
- package/dist/config.js.map +1 -1
- package/dist/ext/alchemy/parse.js +1 -1
- package/dist/ext/alchemy/parse.js.map +1 -1
- package/dist/features/TokensModal.d.ts +2 -1
- package/dist/features/TokensModal.js +24 -22
- package/dist/features/TokensModal.js.map +1 -1
- package/package.json +1 -1
- package/src/config.tsx +4 -0
- package/src/ext/alchemy/parse.ts +1 -1
- package/src/features/TokensModal.tsx +4 -1
package/dist/config.d.ts
CHANGED
|
@@ -46,5 +46,6 @@ export declare const useConfig: () => {
|
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
+
export declare const resetConfig: (config: WipgetConfig) => void;
|
|
49
50
|
export declare const WipgetConfigProvider: ({ children, config: userConfig, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
50
51
|
export {};
|
package/dist/config.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { deepClone as
|
|
3
|
-
import { proxy as a, useSnapshot as
|
|
4
|
-
import { createContext as
|
|
5
|
-
import { QueryClient as u, QueryClientProvider as
|
|
6
|
-
import { EVM_CHAINS as
|
|
2
|
+
import { deepClone as i } from "valtio/utils";
|
|
3
|
+
import { proxy as a, useSnapshot as c } from "valtio";
|
|
4
|
+
import { createContext as l, useContext as p, useEffect as f } from "react";
|
|
5
|
+
import { QueryClient as u, QueryClientProvider as g } from "@tanstack/react-query";
|
|
6
|
+
import { EVM_CHAINS as d } from "./constants/chains.js";
|
|
7
7
|
import { useAddClassToPortal as m } from "./hooks/useAddClassToPortal.js";
|
|
8
8
|
const w = new u({
|
|
9
9
|
defaultOptions: {
|
|
@@ -11,7 +11,7 @@ const w = new u({
|
|
|
11
11
|
staleTime: 2e3 * 60
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
}),
|
|
14
|
+
}), r = {
|
|
15
15
|
appName: "Unknown",
|
|
16
16
|
appIcon: "https://wtmcxrwapthiogjpxwfr.supabase.co/storage/v1/object/public/swap-widget/unknown.svg",
|
|
17
17
|
// 74px - height of the header
|
|
@@ -19,7 +19,7 @@ const w = new u({
|
|
|
19
19
|
topScreenOffset: "10vh + 74px",
|
|
20
20
|
defaultMaxSlippage: 0.01,
|
|
21
21
|
intentsAccountType: "evm",
|
|
22
|
-
walletSupportedChains:
|
|
22
|
+
walletSupportedChains: d,
|
|
23
23
|
walletAddress: void 0,
|
|
24
24
|
filterChains: () => !0,
|
|
25
25
|
filterTokens: () => !0,
|
|
@@ -28,21 +28,24 @@ const w = new u({
|
|
|
28
28
|
source: { external: "wallet-supported", intents: "with-balance" },
|
|
29
29
|
target: { external: "all", intents: "all" }
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
config:
|
|
31
|
+
}, s = l(r), n = a({
|
|
32
|
+
config: r
|
|
33
33
|
}), b = () => {
|
|
34
|
-
const e =
|
|
35
|
-
return
|
|
36
|
-
}, k = ({
|
|
34
|
+
const e = p(s);
|
|
35
|
+
return c(e);
|
|
36
|
+
}, k = (e) => {
|
|
37
|
+
n.config = i(e);
|
|
38
|
+
}, A = ({
|
|
37
39
|
children: e,
|
|
38
|
-
config: t =
|
|
40
|
+
config: t = r
|
|
39
41
|
}) => (f(() => {
|
|
40
|
-
|
|
41
|
-
}, [t]), m("headlessui-portal-root", "sw"), /* @__PURE__ */ o(
|
|
42
|
+
n.config = i(t);
|
|
43
|
+
}, [t]), m("headlessui-portal-root", "sw"), /* @__PURE__ */ o(g, { client: w, children: /* @__PURE__ */ o(s.Provider, { value: n.config, children: /* @__PURE__ */ o("div", { className: "sw", children: e }) }) }));
|
|
42
44
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
A as WipgetConfigProvider,
|
|
46
|
+
n as configStore,
|
|
47
|
+
r as defaultConfig,
|
|
48
|
+
k as resetConfig,
|
|
46
49
|
b as useConfig
|
|
47
50
|
};
|
|
48
51
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../src/config.tsx"],"sourcesContent":["import { deepClone } from 'valtio/utils';\nimport { proxy, useSnapshot } from 'valtio';\nimport { createContext, useContext, useEffect } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport type { PropsWithChildren } from 'react';\n\nimport { EVM_CHAINS } from '@/constants/chains';\nimport { useAddClassToPortal } from '@/hooks/useAddClassToPortal';\nimport type { Chain, Chains, DefaultChainsFilter } from '@/types/chain';\nimport type { Token } from '@/types/token';\n\nexport type WipgetConfig = {\n // Application metadata\n appName: string;\n appIcon: string;\n\n // Layout and UI\n topScreenOffset: string;\n\n // Connected wallet\n intentsAccountType: 'evm' | 'near' | 'sol';\n walletSupportedChains: ReadonlyArray<Chains>;\n walletAddress: string | undefined | null;\n\n // Quotes & Transfers\n defaultMaxSlippage: number;\n\n // Chains & Tokens filtering\n showIntentTokens: boolean;\n filterTokens: (token: Token) => boolean;\n filterChains: (chain: Chain) => boolean;\n\n chainsFilter: {\n source: DefaultChainsFilter;\n target: DefaultChainsFilter;\n };\n};\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 2000 * 60,\n },\n },\n});\n\nexport const defaultConfig: WipgetConfig = {\n appName: 'Unknown',\n appIcon:\n 'https://wtmcxrwapthiogjpxwfr.supabase.co/storage/v1/object/public/swap-widget/unknown.svg',\n\n // 74px - height of the header\n // 10vh - desired offset from the top of the screen\n topScreenOffset: '10vh + 74px',\n defaultMaxSlippage: 0.01,\n\n intentsAccountType: 'evm',\n walletSupportedChains: EVM_CHAINS,\n walletAddress: undefined,\n\n filterChains: () => true,\n filterTokens: () => true,\n showIntentTokens: true,\n chainsFilter: {\n source: { external: 'wallet-supported', intents: 'with-balance' },\n target: { external: 'all', intents: 'all' },\n },\n};\n\ntype WipgetConfigContextType = WipgetConfig;\n\nconst WipgetConfigContext =\n createContext<WipgetConfigContextType>(defaultConfig);\n\ntype Props = PropsWithChildren<{ config?: WipgetConfig }>;\n\nexport const configStore = proxy<{ config: WipgetConfig }>({\n config: defaultConfig,\n});\n\nexport const useConfig = () => {\n const configState = useContext(WipgetConfigContext);\n const config = useSnapshot(configState);\n\n return config;\n};\n\nexport const WipgetConfigProvider = ({\n children,\n config: userConfig = defaultConfig,\n}: Props) => {\n useEffect(() => {\n configStore.config = deepClone(userConfig);\n }, [userConfig]);\n\n // add tailwind parent class to portal root\n useAddClassToPortal('headlessui-portal-root', 'sw');\n\n return (\n <QueryClientProvider client={queryClient}>\n <WipgetConfigContext.Provider value={configStore.config}>\n <div className=\"sw\">{children}</div>\n </WipgetConfigContext.Provider>\n </QueryClientProvider>\n );\n};\n"],"names":["queryClient","QueryClient","defaultConfig","EVM_CHAINS","WipgetConfigContext","createContext","configStore","proxy","useConfig","configState","useContext","useSnapshot","WipgetConfigProvider","children","userConfig","useEffect","
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../src/config.tsx"],"sourcesContent":["import { deepClone } from 'valtio/utils';\nimport { proxy, useSnapshot } from 'valtio';\nimport { createContext, useContext, useEffect } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport type { PropsWithChildren } from 'react';\n\nimport { EVM_CHAINS } from '@/constants/chains';\nimport { useAddClassToPortal } from '@/hooks/useAddClassToPortal';\nimport type { Chain, Chains, DefaultChainsFilter } from '@/types/chain';\nimport type { Token } from '@/types/token';\n\nexport type WipgetConfig = {\n // Application metadata\n appName: string;\n appIcon: string;\n\n // Layout and UI\n topScreenOffset: string;\n\n // Connected wallet\n intentsAccountType: 'evm' | 'near' | 'sol';\n walletSupportedChains: ReadonlyArray<Chains>;\n walletAddress: string | undefined | null;\n\n // Quotes & Transfers\n defaultMaxSlippage: number;\n\n // Chains & Tokens filtering\n showIntentTokens: boolean;\n filterTokens: (token: Token) => boolean;\n filterChains: (chain: Chain) => boolean;\n\n chainsFilter: {\n source: DefaultChainsFilter;\n target: DefaultChainsFilter;\n };\n};\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 2000 * 60,\n },\n },\n});\n\nexport const defaultConfig: WipgetConfig = {\n appName: 'Unknown',\n appIcon:\n 'https://wtmcxrwapthiogjpxwfr.supabase.co/storage/v1/object/public/swap-widget/unknown.svg',\n\n // 74px - height of the header\n // 10vh - desired offset from the top of the screen\n topScreenOffset: '10vh + 74px',\n defaultMaxSlippage: 0.01,\n\n intentsAccountType: 'evm',\n walletSupportedChains: EVM_CHAINS,\n walletAddress: undefined,\n\n filterChains: () => true,\n filterTokens: () => true,\n showIntentTokens: true,\n chainsFilter: {\n source: { external: 'wallet-supported', intents: 'with-balance' },\n target: { external: 'all', intents: 'all' },\n },\n};\n\ntype WipgetConfigContextType = WipgetConfig;\n\nconst WipgetConfigContext =\n createContext<WipgetConfigContextType>(defaultConfig);\n\ntype Props = PropsWithChildren<{ config?: WipgetConfig }>;\n\nexport const configStore = proxy<{ config: WipgetConfig }>({\n config: defaultConfig,\n});\n\nexport const useConfig = () => {\n const configState = useContext(WipgetConfigContext);\n const config = useSnapshot(configState);\n\n return config;\n};\n\nexport const resetConfig = (config: WipgetConfig) => {\n configStore.config = deepClone(config);\n};\n\nexport const WipgetConfigProvider = ({\n children,\n config: userConfig = defaultConfig,\n}: Props) => {\n useEffect(() => {\n configStore.config = deepClone(userConfig);\n }, [userConfig]);\n\n // add tailwind parent class to portal root\n useAddClassToPortal('headlessui-portal-root', 'sw');\n\n return (\n <QueryClientProvider client={queryClient}>\n <WipgetConfigContext.Provider value={configStore.config}>\n <div className=\"sw\">{children}</div>\n </WipgetConfigContext.Provider>\n </QueryClientProvider>\n );\n};\n"],"names":["queryClient","QueryClient","defaultConfig","EVM_CHAINS","WipgetConfigContext","createContext","configStore","proxy","useConfig","configState","useContext","useSnapshot","resetConfig","config","deepClone","WipgetConfigProvider","children","userConfig","useEffect","useAddClassToPortal","QueryClientProvider","jsx"],"mappings":";;;;;;;AAsCA,MAAMA,IAAc,IAAIC,EAAY;AAAA,EAClC,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,WAAW,MAAO;AAAA,IAAA;AAAA,EACpB;AAEJ,CAAC,GAEYC,IAA8B;AAAA,EACzC,SAAS;AAAA,EACT,SACE;AAAA;AAAA;AAAA,EAIF,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EAEpB,oBAAoB;AAAA,EACpB,uBAAuBC;AAAA,EACvB,eAAe;AAAA,EAEf,cAAc,MAAM;AAAA,EACpB,cAAc,MAAM;AAAA,EACpB,kBAAkB;AAAA,EAClB,cAAc;AAAA,IACZ,QAAQ,EAAE,UAAU,oBAAoB,SAAS,eAAA;AAAA,IACjD,QAAQ,EAAE,UAAU,OAAO,SAAS,MAAA;AAAA,EAAM;AAE9C,GAIMC,IACJC,EAAuCH,CAAa,GAIzCI,IAAcC,EAAgC;AAAA,EACzD,QAAQL;AACV,CAAC,GAEYM,IAAY,MAAM;AAC7B,QAAMC,IAAcC,EAAWN,CAAmB;AAGlD,SAFeO,EAAYF,CAAW;AAGxC,GAEaG,IAAc,CAACC,MAAyB;AACnD,EAAAP,EAAY,SAASQ,EAAUD,CAAM;AACvC,GAEaE,IAAuB,CAAC;AAAA,EACnC,UAAAC;AAAA,EACA,QAAQC,IAAaf;AACvB,OACEgB,EAAU,MAAM;AACd,EAAAZ,EAAY,SAASQ,EAAUG,CAAU;AAC3C,GAAG,CAACA,CAAU,CAAC,GAGfE,EAAoB,0BAA0B,IAAI,qBAG/CC,GAAA,EAAoB,QAAQpB,GAC3B,UAAA,gBAAAqB,EAACjB,EAAoB,UAApB,EAA6B,OAAOE,EAAY,QAC/C,UAAA,gBAAAe,EAAC,OAAA,EAAI,WAAU,MAAM,UAAAL,EAAA,CAAS,GAChC,GACF;"}
|
|
@@ -11,7 +11,7 @@ const l = (s, i) => {
|
|
|
11
11
|
else {
|
|
12
12
|
const e = a[r.network];
|
|
13
13
|
e && (o = s.find(
|
|
14
|
-
(t) => t.contractAddress == null && t.blockchain.toLowerCase() === e.toLowerCase() && t.symbol.toLowerCase() === (c(e) ? d[e] ?? e :
|
|
14
|
+
(t) => t.contractAddress == null && t.blockchain.toLowerCase() === e.toLowerCase() && t.symbol.toLowerCase() === (c(e) ? d[e] ?? e : e).toLowerCase()
|
|
15
15
|
));
|
|
16
16
|
}
|
|
17
17
|
if (o) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sources":["../../../src/ext/alchemy/parse.ts"],"sourcesContent":["import { isEvmChain } from '@/utils/evm/isEvmChain';\nimport { EVM_CHAIN_BASE_TOKENS } from '@/constants/chains';\nimport type { Token, TokenBalances } from '@/types/token';\n\nimport { CHAINS_MAP } from './types';\nimport { revertAlchemyChainsMap } from './utils';\nimport type { AlchemyBalanceItem } from './types';\n\nexport const parse = (\n tokensList: Token[],\n fetchedBalances: AlchemyBalanceItem[],\n): TokenBalances => {\n const result: Record<string, string> = {};\n const reversedChainsMap = revertAlchemyChainsMap(CHAINS_MAP);\n\n fetchedBalances.forEach((bal) => {\n let match: Token | undefined;\n\n if (bal.tokenAddress) {\n match = tokensList.find((t) => {\n if (!bal.tokenAddress) {\n return false;\n }\n\n return (\n t.contractAddress?.toLowerCase() === bal.tokenAddress.toLowerCase()\n );\n });\n } else {\n const blockchain = reversedChainsMap[bal.network];\n\n if (blockchain) {\n match = tokensList.find(\n (t) =>\n t.contractAddress == null &&\n t.blockchain.toLowerCase() === blockchain.toLowerCase() &&\n t.symbol.toLowerCase() ===\n (isEvmChain(blockchain)\n ? (EVM_CHAIN_BASE_TOKENS[blockchain] ?? blockchain)\n :
|
|
1
|
+
{"version":3,"file":"parse.js","sources":["../../../src/ext/alchemy/parse.ts"],"sourcesContent":["import { isEvmChain } from '@/utils/evm/isEvmChain';\nimport { EVM_CHAIN_BASE_TOKENS } from '@/constants/chains';\nimport type { Token, TokenBalances } from '@/types/token';\n\nimport { CHAINS_MAP } from './types';\nimport { revertAlchemyChainsMap } from './utils';\nimport type { AlchemyBalanceItem } from './types';\n\nexport const parse = (\n tokensList: Token[],\n fetchedBalances: AlchemyBalanceItem[],\n): TokenBalances => {\n const result: Record<string, string> = {};\n const reversedChainsMap = revertAlchemyChainsMap(CHAINS_MAP);\n\n fetchedBalances.forEach((bal) => {\n let match: Token | undefined;\n\n if (bal.tokenAddress) {\n match = tokensList.find((t) => {\n if (!bal.tokenAddress) {\n return false;\n }\n\n return (\n t.contractAddress?.toLowerCase() === bal.tokenAddress.toLowerCase()\n );\n });\n } else {\n const blockchain = reversedChainsMap[bal.network];\n\n if (blockchain) {\n match = tokensList.find(\n (t) =>\n t.contractAddress == null &&\n t.blockchain.toLowerCase() === blockchain.toLowerCase() &&\n t.symbol.toLowerCase() ===\n (isEvmChain(blockchain)\n ? (EVM_CHAIN_BASE_TOKENS[blockchain] ?? blockchain)\n : blockchain\n ).toLowerCase(),\n );\n }\n }\n\n if (match) {\n const bigintStr = BigInt(bal.tokenBalance).toString();\n\n if (bigintStr !== '0') {\n result[match.assetId] = bigintStr;\n }\n }\n });\n\n return result;\n};\n"],"names":["parse","tokensList","fetchedBalances","result","reversedChainsMap","revertAlchemyChainsMap","CHAINS_MAP","bal","match","t","blockchain","isEvmChain","EVM_CHAIN_BASE_TOKENS","bigintStr"],"mappings":";;;;AAQO,MAAMA,IAAQ,CACnBC,GACAC,MACkB;AAClB,QAAMC,IAAiC,CAAA,GACjCC,IAAoBC,EAAuBC,CAAU;AAE3D,SAAAJ,EAAgB,QAAQ,CAACK,MAAQ;AAC/B,QAAIC;AAEJ,QAAID,EAAI;AACN,MAAAC,IAAQP,EAAW,KAAK,CAACQ,MAClBF,EAAI,eAKPE,EAAE,iBAAiB,YAAA,MAAkBF,EAAI,aAAa,YAAA,IAJ/C,EAMV;AAAA,SACI;AACL,YAAMG,IAAaN,EAAkBG,EAAI,OAAO;AAEhD,MAAIG,MACFF,IAAQP,EAAW;AAAA,QACjB,CAAC,MACC,EAAE,mBAAmB,QACrB,EAAE,WAAW,YAAA,MAAkBS,EAAW,YAAA,KAC1C,EAAE,OAAO,YAAA,OACNC,EAAWD,CAAU,IACjBE,EAAsBF,CAAU,KAAKA,IACtCA,GACF,YAAA;AAAA,MAAY;AAAA,IAGxB;AAEA,QAAIF,GAAO;AACT,YAAMK,IAAY,OAAON,EAAI,YAAY,EAAE,SAAA;AAE3C,MAAIM,MAAc,QAChBV,EAAOK,EAAM,OAAO,IAAIK;AAAA,IAE5B;AAAA,EACF,CAAC,GAEMV;AACT;"}
|
|
@@ -11,7 +11,8 @@ type Props = {
|
|
|
11
11
|
showBalances: boolean;
|
|
12
12
|
showChainsSelector: boolean;
|
|
13
13
|
chainsFilter: DefaultChainsFilter;
|
|
14
|
+
className?: string;
|
|
14
15
|
onMsg: (msg: Msg) => void;
|
|
15
16
|
};
|
|
16
|
-
export declare const TokensModal: ({ showBalances, showChainsSelector, chainsFilter, groupTokens, onMsg, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const TokensModal: ({ showBalances, showChainsSelector, chainsFilter, groupTokens, className, onMsg, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
17
18
|
export {};
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { jsxs as o, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useState as d } from "react";
|
|
3
|
-
import * as
|
|
4
|
-
import { Card as
|
|
5
|
-
import { Input as
|
|
6
|
-
import { Banner as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
3
|
+
import * as m from "lucide-react";
|
|
4
|
+
import { Card as k } from "../components/Card.js";
|
|
5
|
+
import { Input as C } from "../components/Input.js";
|
|
6
|
+
import { Banner as S } from "../components/Banner.js";
|
|
7
|
+
import { cn as _ } from "../utils/cn.js";
|
|
8
|
+
import { useConfig as b } from "../config.js";
|
|
9
|
+
import { useUnsafeSnapshot as N } from "../machine/snap.js";
|
|
10
|
+
import { notReachable as p } from "../utils/notReachable.js";
|
|
11
|
+
import { TokensList as g } from "./TokensList/index.js";
|
|
12
|
+
import { ChainsDropdown as v } from "./ChainsDropdown/index.js";
|
|
13
|
+
const U = ({
|
|
13
14
|
showBalances: f,
|
|
14
15
|
showChainsSelector: h,
|
|
15
16
|
chainsFilter: r,
|
|
16
17
|
groupTokens: u,
|
|
18
|
+
className: w,
|
|
17
19
|
onMsg: a
|
|
18
20
|
}) => {
|
|
19
|
-
const { ctx: n } =
|
|
20
|
-
return /* @__PURE__ */ o(
|
|
21
|
+
const { ctx: n } = N(), { walletSupportedChains: x } = b(), [l, c] = d(""), [s, y] = d("all"), i = s !== "all" && s !== "intents" && !x.includes(s);
|
|
22
|
+
return /* @__PURE__ */ o(k, { className: _("gap-sw-2xl flex flex-col", w), children: [
|
|
21
23
|
/* @__PURE__ */ o("header", { className: "py-sw-md flex items-center justify-between", children: [
|
|
22
24
|
/* @__PURE__ */ t("h2", { className: "text-sw-label-l", children: "Select token" }),
|
|
23
25
|
/* @__PURE__ */ t(
|
|
@@ -26,15 +28,15 @@ const D = ({
|
|
|
26
28
|
type: "button",
|
|
27
29
|
className: "flex cursor-pointer items-center justify-center text-sw-gray-100 transition-colors hover:text-sw-gray-50",
|
|
28
30
|
onClick: () => a({ type: "on_dismiss_tokens_modal" }),
|
|
29
|
-
children: /* @__PURE__ */ t(
|
|
31
|
+
children: /* @__PURE__ */ t(m.X, { size: 22 })
|
|
30
32
|
}
|
|
31
33
|
)
|
|
32
34
|
] }),
|
|
33
35
|
/* @__PURE__ */ o("div", { className: "gap-sw-xl flex items-center", children: [
|
|
34
36
|
/* @__PURE__ */ t(
|
|
35
|
-
|
|
37
|
+
C,
|
|
36
38
|
{
|
|
37
|
-
icon:
|
|
39
|
+
icon: m.Search,
|
|
38
40
|
defaultValue: l,
|
|
39
41
|
className: "w-full",
|
|
40
42
|
placeholder: "Search or paste address",
|
|
@@ -42,31 +44,31 @@ const D = ({
|
|
|
42
44
|
}
|
|
43
45
|
),
|
|
44
46
|
h && /* @__PURE__ */ t(
|
|
45
|
-
|
|
47
|
+
v,
|
|
46
48
|
{
|
|
47
49
|
selected: s,
|
|
48
50
|
chainsFilter: r,
|
|
49
51
|
onMsg: (e) => {
|
|
50
52
|
switch (e.type) {
|
|
51
53
|
case "on_click_chain":
|
|
52
|
-
|
|
54
|
+
y(e.chain);
|
|
53
55
|
break;
|
|
54
56
|
default:
|
|
55
|
-
|
|
57
|
+
p(e.type, { throwError: !1 });
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
)
|
|
60
62
|
] }),
|
|
61
63
|
i && !!n.walletAddress && /* @__PURE__ */ t(
|
|
62
|
-
|
|
64
|
+
S,
|
|
63
65
|
{
|
|
64
66
|
variant: "info",
|
|
65
67
|
message: "Your connected wallet doesn't support this chain"
|
|
66
68
|
}
|
|
67
69
|
),
|
|
68
70
|
/* @__PURE__ */ t(
|
|
69
|
-
|
|
71
|
+
g,
|
|
70
72
|
{
|
|
71
73
|
search: l,
|
|
72
74
|
groupTokens: u,
|
|
@@ -83,7 +85,7 @@ const D = ({
|
|
|
83
85
|
a(e);
|
|
84
86
|
break;
|
|
85
87
|
default:
|
|
86
|
-
|
|
88
|
+
p(e, { throwError: !1 });
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
}
|
|
@@ -91,6 +93,6 @@ const D = ({
|
|
|
91
93
|
] });
|
|
92
94
|
};
|
|
93
95
|
export {
|
|
94
|
-
|
|
96
|
+
U as TokensModal
|
|
95
97
|
};
|
|
96
98
|
//# sourceMappingURL=TokensModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokensModal.js","sources":["../../src/features/TokensModal.tsx"],"sourcesContent":["import { useState } from 'react';\nimport * as Icons from 'lucide-react';\n\nimport { Card } from '@/components/Card';\nimport { Input } from '@/components/Input';\nimport { Banner } from '@/components/Banner';\n\nimport { useConfig } from '@/config';\nimport { useUnsafeSnapshot } from '@/machine/snap';\nimport { notReachable } from '@/utils/notReachable';\nimport type { Chains, DefaultChainsFilter } from '@/types/chain';\nimport type { Token } from '@/types/token';\n\nimport { TokensList } from './TokensList';\nimport { ChainsDropdown } from './ChainsDropdown';\n\ntype Msg =\n | { type: 'on_select_token'; token: Token }\n | { type: 'on_dismiss_tokens_modal' };\n\ntype Props = {\n groupTokens: boolean;\n showBalances: boolean;\n showChainsSelector: boolean;\n chainsFilter: DefaultChainsFilter;\n onMsg: (msg: Msg) => void;\n};\n\nexport const TokensModal = ({\n showBalances,\n showChainsSelector,\n chainsFilter,\n groupTokens,\n onMsg,\n}: Props) => {\n const { ctx } = useUnsafeSnapshot();\n const { walletSupportedChains } = useConfig();\n\n const [search, setSearch] = useState('');\n const [selectedChain, setSelectedChain] = useState<\n 'all' | 'intents' | Chains\n >('all');\n\n const selectedChainIsNotSupportedByConnectedWallet =\n selectedChain !== 'all' &&\n selectedChain !== 'intents' &&\n !walletSupportedChains.includes(selectedChain);\n\n return (\n <Card className
|
|
1
|
+
{"version":3,"file":"TokensModal.js","sources":["../../src/features/TokensModal.tsx"],"sourcesContent":["import { useState } from 'react';\nimport * as Icons from 'lucide-react';\n\nimport { Card } from '@/components/Card';\nimport { Input } from '@/components/Input';\nimport { Banner } from '@/components/Banner';\n\nimport { cn } from '@/utils/cn';\nimport { useConfig } from '@/config';\nimport { useUnsafeSnapshot } from '@/machine/snap';\nimport { notReachable } from '@/utils/notReachable';\nimport type { Chains, DefaultChainsFilter } from '@/types/chain';\nimport type { Token } from '@/types/token';\n\nimport { TokensList } from './TokensList';\nimport { ChainsDropdown } from './ChainsDropdown';\n\ntype Msg =\n | { type: 'on_select_token'; token: Token }\n | { type: 'on_dismiss_tokens_modal' };\n\ntype Props = {\n groupTokens: boolean;\n showBalances: boolean;\n showChainsSelector: boolean;\n chainsFilter: DefaultChainsFilter;\n className?: string;\n onMsg: (msg: Msg) => void;\n};\n\nexport const TokensModal = ({\n showBalances,\n showChainsSelector,\n chainsFilter,\n groupTokens,\n className,\n onMsg,\n}: Props) => {\n const { ctx } = useUnsafeSnapshot();\n const { walletSupportedChains } = useConfig();\n\n const [search, setSearch] = useState('');\n const [selectedChain, setSelectedChain] = useState<\n 'all' | 'intents' | Chains\n >('all');\n\n const selectedChainIsNotSupportedByConnectedWallet =\n selectedChain !== 'all' &&\n selectedChain !== 'intents' &&\n !walletSupportedChains.includes(selectedChain);\n\n return (\n <Card className={cn('gap-sw-2xl flex flex-col', className)}>\n <header className=\"py-sw-md flex items-center justify-between\">\n <h2 className=\"text-sw-label-l\">Select token</h2>\n <button\n type=\"button\"\n className=\"flex cursor-pointer items-center justify-center text-sw-gray-100 transition-colors hover:text-sw-gray-50\"\n onClick={() => onMsg({ type: 'on_dismiss_tokens_modal' })}>\n <Icons.X size={22} />\n </button>\n </header>\n\n <div className=\"gap-sw-xl flex items-center\">\n <Input\n icon={Icons.Search}\n defaultValue={search}\n className=\"w-full\"\n placeholder=\"Search or paste address\"\n onChange={(e) => setSearch(e.target.value.trim())}\n />\n {showChainsSelector && (\n <ChainsDropdown\n selected={selectedChain}\n chainsFilter={chainsFilter}\n onMsg={(msg) => {\n switch (msg.type) {\n case 'on_click_chain':\n setSelectedChain(msg.chain);\n break;\n default:\n notReachable(msg.type, { throwError: false });\n }\n }}\n />\n )}\n </div>\n\n {selectedChainIsNotSupportedByConnectedWallet && !!ctx.walletAddress && (\n <Banner\n variant=\"info\"\n message=\"Your connected wallet doesn't support this chain\"\n />\n )}\n\n <TokensList\n search={search}\n groupTokens={groupTokens}\n showBalances={showBalances}\n chainsFilter={chainsFilter}\n selectedChain={selectedChain}\n offset={\n selectedChainIsNotSupportedByConnectedWallet && ctx.walletAddress\n ? '68px'\n : undefined\n }\n onMsg={(msg) => {\n switch (msg.type) {\n case 'on_reset_search':\n setSearch('');\n break;\n case 'on_select_token':\n onMsg(msg);\n break;\n default:\n notReachable(msg, { throwError: false });\n }\n }}\n />\n </Card>\n );\n};\n"],"names":["TokensModal","showBalances","showChainsSelector","chainsFilter","groupTokens","className","onMsg","ctx","useUnsafeSnapshot","walletSupportedChains","useConfig","search","setSearch","useState","selectedChain","setSelectedChain","selectedChainIsNotSupportedByConnectedWallet","Card","cn","jsxs","jsx","Icons","Input","ChainsDropdown","msg","notReachable","Banner","TokensList"],"mappings":";;;;;;;;;;;;AA8BO,MAAMA,IAAc,CAAC;AAAA,EAC1B,cAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AACF,MAAa;AACX,QAAM,EAAE,KAAAC,EAAA,IAAQC,EAAA,GACV,EAAE,uBAAAC,EAAA,IAA0BC,EAAA,GAE5B,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAE,GACjC,CAACC,GAAeC,CAAgB,IAAIF,EAExC,KAAK,GAEDG,IACJF,MAAkB,SAClBA,MAAkB,aAClB,CAACL,EAAsB,SAASK,CAAa;AAE/C,2BACGG,GAAA,EAAK,WAAWC,EAAG,4BAA4Bb,CAAS,GACvD,UAAA;AAAA,IAAA,gBAAAc,EAAC,UAAA,EAAO,WAAU,8CAChB,UAAA;AAAA,MAAA,gBAAAC,EAAC,MAAA,EAAG,WAAU,mBAAkB,UAAA,gBAAY;AAAA,MAC5C,gBAAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAU;AAAA,UACV,SAAS,MAAMd,EAAM,EAAE,MAAM,2BAA2B;AAAA,UACxD,UAAA,gBAAAc,EAACC,EAAM,GAAN,EAAQ,MAAM,GAAA,CAAI;AAAA,QAAA;AAAA,MAAA;AAAA,IACrB,GACF;AAAA,IAEA,gBAAAF,EAAC,OAAA,EAAI,WAAU,+BACb,UAAA;AAAA,MAAA,gBAAAC;AAAA,QAACE;AAAA,QAAA;AAAA,UACC,MAAMD,EAAM;AAAA,UACZ,cAAcV;AAAA,UACd,WAAU;AAAA,UACV,aAAY;AAAA,UACZ,UAAU,CAAC,MAAMC,EAAU,EAAE,OAAO,MAAM,MAAM;AAAA,QAAA;AAAA,MAAA;AAAA,MAEjDV,KACC,gBAAAkB;AAAA,QAACG;AAAA,QAAA;AAAA,UACC,UAAUT;AAAA,UACV,cAAAX;AAAA,UACA,OAAO,CAACqB,MAAQ;AACd,oBAAQA,EAAI,MAAA;AAAA,cACV,KAAK;AACH,gBAAAT,EAAiBS,EAAI,KAAK;AAC1B;AAAA,cACF;AACE,gBAAAC,EAAaD,EAAI,MAAM,EAAE,YAAY,IAAO;AAAA,YAAA;AAAA,UAElD;AAAA,QAAA;AAAA,MAAA;AAAA,IACF,GAEJ;AAAA,IAECR,KAAgD,CAAC,CAACT,EAAI,iBACrD,gBAAAa;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,SAAQ;AAAA,MAAA;AAAA,IAAA;AAAA,IAIZ,gBAAAN;AAAA,MAACO;AAAA,MAAA;AAAA,QACC,QAAAhB;AAAA,QACA,aAAAP;AAAA,QACA,cAAAH;AAAA,QACA,cAAAE;AAAA,QACA,eAAAW;AAAA,QACA,QACEE,KAAgDT,EAAI,gBAChD,SACA;AAAA,QAEN,OAAO,CAACiB,MAAQ;AACd,kBAAQA,EAAI,MAAA;AAAA,YACV,KAAK;AACH,cAAAZ,EAAU,EAAE;AACZ;AAAA,YACF,KAAK;AACH,cAAAN,EAAMkB,CAAG;AACT;AAAA,YACF;AACE,cAAAC,EAAaD,GAAK,EAAE,YAAY,GAAA,CAAO;AAAA,UAAA;AAAA,QAE7C;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
|
package/package.json
CHANGED
package/src/config.tsx
CHANGED
|
@@ -85,6 +85,10 @@ export const useConfig = () => {
|
|
|
85
85
|
return config;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
export const resetConfig = (config: WipgetConfig) => {
|
|
89
|
+
configStore.config = deepClone(config);
|
|
90
|
+
};
|
|
91
|
+
|
|
88
92
|
export const WipgetConfigProvider = ({
|
|
89
93
|
children,
|
|
90
94
|
config: userConfig = defaultConfig,
|
package/src/ext/alchemy/parse.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Card } from '@/components/Card';
|
|
|
5
5
|
import { Input } from '@/components/Input';
|
|
6
6
|
import { Banner } from '@/components/Banner';
|
|
7
7
|
|
|
8
|
+
import { cn } from '@/utils/cn';
|
|
8
9
|
import { useConfig } from '@/config';
|
|
9
10
|
import { useUnsafeSnapshot } from '@/machine/snap';
|
|
10
11
|
import { notReachable } from '@/utils/notReachable';
|
|
@@ -23,6 +24,7 @@ type Props = {
|
|
|
23
24
|
showBalances: boolean;
|
|
24
25
|
showChainsSelector: boolean;
|
|
25
26
|
chainsFilter: DefaultChainsFilter;
|
|
27
|
+
className?: string;
|
|
26
28
|
onMsg: (msg: Msg) => void;
|
|
27
29
|
};
|
|
28
30
|
|
|
@@ -31,6 +33,7 @@ export const TokensModal = ({
|
|
|
31
33
|
showChainsSelector,
|
|
32
34
|
chainsFilter,
|
|
33
35
|
groupTokens,
|
|
36
|
+
className,
|
|
34
37
|
onMsg,
|
|
35
38
|
}: Props) => {
|
|
36
39
|
const { ctx } = useUnsafeSnapshot();
|
|
@@ -47,7 +50,7 @@ export const TokensModal = ({
|
|
|
47
50
|
!walletSupportedChains.includes(selectedChain);
|
|
48
51
|
|
|
49
52
|
return (
|
|
50
|
-
<Card className=
|
|
53
|
+
<Card className={cn('gap-sw-2xl flex flex-col', className)}>
|
|
51
54
|
<header className="py-sw-md flex items-center justify-between">
|
|
52
55
|
<h2 className="text-sw-label-l">Select token</h2>
|
|
53
56
|
<button
|