@elizaos/plugin-wallet-ui 2.0.3-beta.6 → 2.0.3-beta.7
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/InventoryView.d.ts +19 -0
- package/dist/InventoryView.d.ts.map +1 -0
- package/dist/InventoryView.helpers.d.ts +32 -0
- package/dist/InventoryView.helpers.d.ts.map +1 -0
- package/dist/InventoryView.helpers.js +104 -0
- package/dist/InventoryView.helpers.js.map +1 -0
- package/dist/InventoryView.interact.d.ts +2 -0
- package/dist/InventoryView.interact.d.ts.map +1 -0
- package/dist/InventoryView.interact.js +47 -0
- package/dist/InventoryView.interact.js.map +1 -0
- package/dist/InventoryView.js +242 -0
- package/dist/InventoryView.js.map +1 -0
- package/dist/components/InventoryAppView.d.ts +2 -0
- package/dist/components/InventoryAppView.d.ts.map +1 -0
- package/dist/components/InventoryAppView.js +1744 -0
- package/dist/components/InventoryAppView.js.map +1 -0
- package/dist/components/InventorySpatialView.d.ts +86 -0
- package/dist/components/InventorySpatialView.d.ts.map +1 -0
- package/dist/components/InventorySpatialView.js +218 -0
- package/dist/components/InventorySpatialView.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory/ChainIcon.d.ts +9 -0
- package/dist/inventory/ChainIcon.d.ts.map +1 -0
- package/dist/inventory/ChainIcon.js +71 -0
- package/dist/inventory/ChainIcon.js.map +1 -0
- package/dist/inventory/TokenLogo.d.ts +8 -0
- package/dist/inventory/TokenLogo.d.ts.map +1 -0
- package/dist/inventory/TokenLogo.js +52 -0
- package/dist/inventory/TokenLogo.js.map +1 -0
- package/dist/inventory/chainConfig.d.ts +89 -0
- package/dist/inventory/chainConfig.d.ts.map +1 -0
- package/dist/inventory/chainConfig.js +252 -0
- package/dist/inventory/chainConfig.js.map +1 -0
- package/dist/inventory/constants.d.ts +31 -0
- package/dist/inventory/constants.d.ts.map +1 -0
- package/dist/inventory/constants.js +59 -0
- package/dist/inventory/constants.js.map +1 -0
- package/dist/inventory/index.d.ts +5 -0
- package/dist/inventory/index.d.ts.map +1 -0
- package/dist/inventory/index.js +43 -0
- package/dist/inventory/index.js.map +1 -0
- package/dist/inventory/inventory-chain-filters.d.ts +11 -0
- package/dist/inventory/inventory-chain-filters.d.ts.map +1 -0
- package/dist/inventory/inventory-chain-filters.js +49 -0
- package/dist/inventory/inventory-chain-filters.js.map +1 -0
- package/dist/inventory/media-url.d.ts +6 -0
- package/dist/inventory/media-url.d.ts.map +1 -0
- package/dist/inventory/media-url.js +32 -0
- package/dist/inventory/media-url.js.map +1 -0
- package/dist/inventory/useInventoryData.d.ts +38 -0
- package/dist/inventory/useInventoryData.d.ts.map +1 -0
- package/dist/inventory/useInventoryData.js +311 -0
- package/dist/inventory/useInventoryData.js.map +1 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +55 -0
- package/dist/plugin.js.map +1 -0
- package/dist/register-routes.d.ts +9 -0
- package/dist/register-routes.d.ts.map +1 -0
- package/dist/register-routes.js +22 -0
- package/dist/register-routes.js.map +1 -0
- package/dist/register-terminal-view.d.ts +15 -0
- package/dist/register-terminal-view.d.ts.map +1 -0
- package/dist/register-terminal-view.js +33 -0
- package/dist/register-terminal-view.js.map +1 -0
- package/dist/register.d.ts +4 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +20 -0
- package/dist/register.js.map +1 -0
- package/dist/ui.d.ts +13 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +62 -0
- package/dist/ui.js.map +1 -0
- package/dist/views/bundle.js +1072 -0
- package/dist/views/bundle.js.map +1 -0
- package/dist/wallet-rpc.d.ts +2 -0
- package/dist/wallet-rpc.d.ts.map +1 -0
- package/dist/wallet-rpc.js +9 -0
- package/dist/wallet-rpc.js.map +1 -0
- package/dist/wallet-view-bundle.d.ts +3 -0
- package/dist/wallet-view-bundle.d.ts.map +1 -0
- package/dist/wallet-view-bundle.js +7 -0
- package/dist/wallet-view-bundle.js.map +1 -0
- package/dist/widgets/wallet-status.d.ts +3 -0
- package/dist/widgets/wallet-status.d.ts.map +1 -0
- package/dist/widgets/wallet-status.helpers.d.ts +3 -0
- package/dist/widgets/wallet-status.helpers.d.ts.map +1 -0
- package/dist/widgets/wallet-status.helpers.js +12 -0
- package/dist/widgets/wallet-status.helpers.js.map +1 -0
- package/dist/widgets/wallet-status.js +291 -0
- package/dist/widgets/wallet-status.js.map +1 -0
- package/package.json +7 -7
package/dist/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useWalletState } from "@elizaos/ui/state";
|
|
2
|
+
import { InventoryView } from "./InventoryView.js";
|
|
3
|
+
import { InventoryAppView } from "./components/InventoryAppView.js";
|
|
4
|
+
import { ChainIcon } from "./inventory/ChainIcon.js";
|
|
5
|
+
import {
|
|
6
|
+
CHAIN_CONFIGS,
|
|
7
|
+
chainKeyToWalletRpcChain,
|
|
8
|
+
getChainConfig,
|
|
9
|
+
getContractLogoUrl,
|
|
10
|
+
getExplorerTokenUrl,
|
|
11
|
+
getExplorerTxUrl,
|
|
12
|
+
getNativeLogoUrl,
|
|
13
|
+
getStablecoinAddress,
|
|
14
|
+
PRIMARY_CHAIN_KEYS,
|
|
15
|
+
resolveChainKey
|
|
16
|
+
} from "./inventory/chainConfig.js";
|
|
17
|
+
import {
|
|
18
|
+
BSC_GAS_READY_THRESHOLD,
|
|
19
|
+
BSC_GAS_THRESHOLD,
|
|
20
|
+
HEX_ADDRESS_RE,
|
|
21
|
+
isAvaxChainName,
|
|
22
|
+
isBscChainName,
|
|
23
|
+
toNormalizedAddress
|
|
24
|
+
} from "./inventory/constants.js";
|
|
25
|
+
import { TokenLogo } from "./inventory/TokenLogo.js";
|
|
26
|
+
import { useInventoryData } from "./inventory/useInventoryData.js";
|
|
27
|
+
import { walletAppPlugin } from "./plugin.js";
|
|
28
|
+
export * from "./register.js";
|
|
29
|
+
export * from "./ui.js";
|
|
30
|
+
import {
|
|
31
|
+
buildWalletRpcUpdateRequest,
|
|
32
|
+
resolveInitialWalletRpcSelections
|
|
33
|
+
} from "./wallet-rpc.js";
|
|
34
|
+
import { WALLET_STATUS_WIDGET } from "./widgets/wallet-status.helpers.js";
|
|
35
|
+
import { WalletStatusSidebarWidget } from "./widgets/wallet-status.js";
|
|
36
|
+
export {
|
|
37
|
+
BSC_GAS_READY_THRESHOLD,
|
|
38
|
+
BSC_GAS_THRESHOLD,
|
|
39
|
+
CHAIN_CONFIGS,
|
|
40
|
+
ChainIcon,
|
|
41
|
+
HEX_ADDRESS_RE,
|
|
42
|
+
InventoryAppView,
|
|
43
|
+
InventoryView,
|
|
44
|
+
PRIMARY_CHAIN_KEYS,
|
|
45
|
+
TokenLogo,
|
|
46
|
+
WALLET_STATUS_WIDGET,
|
|
47
|
+
WalletStatusSidebarWidget,
|
|
48
|
+
buildWalletRpcUpdateRequest,
|
|
49
|
+
chainKeyToWalletRpcChain,
|
|
50
|
+
getChainConfig,
|
|
51
|
+
getContractLogoUrl,
|
|
52
|
+
getExplorerTokenUrl,
|
|
53
|
+
getExplorerTxUrl,
|
|
54
|
+
getNativeLogoUrl,
|
|
55
|
+
getStablecoinAddress,
|
|
56
|
+
isAvaxChainName,
|
|
57
|
+
isBscChainName,
|
|
58
|
+
resolveChainKey,
|
|
59
|
+
resolveInitialWalletRpcSelections,
|
|
60
|
+
toNormalizedAddress,
|
|
61
|
+
useInventoryData,
|
|
62
|
+
useWalletState,
|
|
63
|
+
walletAppPlugin
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Re-exports for hosts that import directly from \"@elizaos/plugin-wallet-ui\".\n\nexport { useWalletState } from \"@elizaos/ui/state\";\nexport { InventoryView } from \"./InventoryView.js\";\nexport { InventoryAppView } from \"./components/InventoryAppView.js\";\nexport { ChainIcon } from \"./inventory/ChainIcon.js\";\nexport {\n CHAIN_CONFIGS,\n type ChainConfig,\n type ChainKey,\n chainKeyToWalletRpcChain,\n getChainConfig,\n getContractLogoUrl,\n getExplorerTokenUrl,\n getExplorerTxUrl,\n getNativeLogoUrl,\n getStablecoinAddress,\n PRIMARY_CHAIN_KEYS,\n resolveChainKey,\n} from \"./inventory/chainConfig.js\";\nexport {\n BSC_GAS_READY_THRESHOLD,\n BSC_GAS_THRESHOLD,\n HEX_ADDRESS_RE,\n isAvaxChainName,\n isBscChainName,\n type NftItem,\n type TokenRow,\n toNormalizedAddress,\n} from \"./inventory/constants.js\";\nexport { TokenLogo } from \"./inventory/TokenLogo.js\";\nexport { useInventoryData } from \"./inventory/useInventoryData.js\";\nexport { walletAppPlugin } from \"./plugin.js\";\nexport * from \"./register.js\";\nexport * from \"./ui.js\";\nexport {\n buildWalletRpcUpdateRequest,\n resolveInitialWalletRpcSelections,\n} from \"./wallet-rpc.js\";\nexport { WALLET_STATUS_WIDGET } from \"./widgets/wallet-status.helpers.js\";\nexport { WalletStatusSidebarWidget } from \"./widgets/wallet-status.js\";\n"],"mappings":"AAEA,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,cAAc;AACd,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,iCAAiC;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
export type ChainIconSize = "sm" | "md" | "lg";
|
|
3
|
+
export interface ChainIconProps {
|
|
4
|
+
chain: string;
|
|
5
|
+
size?: ChainIconSize;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function ChainIcon({ chain, size, className, }: ChainIconProps): React.ReactElement | null;
|
|
9
|
+
//# sourceMappingURL=ChainIcon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChainIcon.d.ts","sourceRoot":"","sources":["../../src/inventory/ChainIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAGpC,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA0DD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,IAAW,EACX,SAAc,GACf,EAAE,cAAc,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAoB5C"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { resolveChainKey } from "./chainConfig.js";
|
|
3
|
+
const SIZE_CLASSES = {
|
|
4
|
+
sm: "h-4 w-4",
|
|
5
|
+
md: "h-5 w-5",
|
|
6
|
+
lg: "h-6 w-6"
|
|
7
|
+
};
|
|
8
|
+
const SIZE_OVERRIDES = {
|
|
9
|
+
bsc: { sm: "h-5 w-5", md: "h-6 w-6", lg: "h-7 w-7" },
|
|
10
|
+
ethereum: { lg: "h-7 w-7" },
|
|
11
|
+
base: { lg: "h-7 w-7" }
|
|
12
|
+
};
|
|
13
|
+
const CHAIN_SVGS = {
|
|
14
|
+
ethereum: {
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
paths: [
|
|
17
|
+
"M12 1.5l-7 10.167L12 15.5l7-3.833L12 1.5zM5 13.5L12 22.5l7-9-7 3.833L5 13.5z"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
base: {
|
|
21
|
+
viewBox: "0 0 146 146",
|
|
22
|
+
paths: [
|
|
23
|
+
"M73.323 123.729C101.617 123.729 124.553 100.832 124.553 72.5875C124.553 44.343 101.617 21.4463 73.323 21.4463C46.4795 21.4463 24.4581 42.0558 22.271 68.2887H89.9859V76.8864H22.271C24.4581 103.119 46.4795 123.729 73.323 123.729Z"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
bsc: {
|
|
27
|
+
viewBox: "0 0 2496 2496",
|
|
28
|
+
paths: [
|
|
29
|
+
"M685.9 1248l0.9 330 280.4 165v193.2l-444.5-260.7v-524L685.9 1248zM685.9 918v192.3l-163.3-96.6V821.4l163.3-96.6 164.1 96.6L685.9 918zM1084.3 821.4l163.3-96.6 164.1 96.6-164.1 96.6-163.3-96.6z",
|
|
30
|
+
"M803.9 1509.6v-193.2l163.3 96.6v192.3L803.9 1509.6zM1084.3 1812.2l163.3 96.6 164.1-96.6v192.3l-164.1 96.6-163.3-96.6v-192.3zM1645.9 821.4l163.3-96.6 164.1 96.6v192.3l-164.1 96.6V918L1645.9 821.4zM1809.2 1578l0.9-330 163.3-96.6v524l-444.5 260.7v-193.2L1809.2 1578z",
|
|
31
|
+
"M1692.1 986.4l0.9 193.2-281.2 165v330.8l-163.3 95.7-163.3-95.7v-330.8l-281.2-165V986.4L968 889.8l279.5 165.8 281.2-165.8 164.1 96.6h-0.7zM803.9 656.5l443.7-261.6 444.5 261.6-163.3 96.6-281.2-165.8-280.4 165.8-163.3-96.6z"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
avax: {
|
|
35
|
+
viewBox: "0 0 24 24",
|
|
36
|
+
paths: ["M12 3L2 21h6l4-7 4 7h6L12 3z"]
|
|
37
|
+
},
|
|
38
|
+
solana: {
|
|
39
|
+
viewBox: "0 0 397.7 311.7",
|
|
40
|
+
paths: [
|
|
41
|
+
"M64.6 237.9c2.4-2.4 5.7-3.8 9.2-3.8h317.4c5.8 0 8.7 7 4.6 11.1l-62.7 62.7c-2.4 2.4-5.7 3.8-9.2 3.8H6.5c-5.8 0-8.7-7-4.6-11.1L64.6 237.9z",
|
|
42
|
+
"M64.6 3.8C67.1 1.4 70.4 0 73.8 0h317.4c5.8 0 8.7 7 4.6 11.1l-62.7 62.7c-2.4 2.4-5.7 3.8-9.2 3.8H6.5c-5.8 0-8.7-7-4.6-11.1L64.6 3.8z",
|
|
43
|
+
"M333.1 120.1c-2.4-2.4-5.7-3.8-9.2-3.8H6.5c-5.8 0-8.7 7-4.6 11.1l62.7 62.7c2.4 2.4 5.7 3.8 9.2 3.8h317.4c5.8 0 8.7-7 4.6-11.1L333.1 120.1z"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function ChainIcon({
|
|
48
|
+
chain,
|
|
49
|
+
size = "md",
|
|
50
|
+
className = ""
|
|
51
|
+
}) {
|
|
52
|
+
const key = resolveChainKey(chain);
|
|
53
|
+
if (!key) return null;
|
|
54
|
+
const def = CHAIN_SVGS[key];
|
|
55
|
+
if (!def) return null;
|
|
56
|
+
const sizeClass = SIZE_OVERRIDES[key]?.[size] ?? SIZE_CLASSES[size];
|
|
57
|
+
return /* @__PURE__ */ jsx(
|
|
58
|
+
"svg",
|
|
59
|
+
{
|
|
60
|
+
viewBox: def.viewBox,
|
|
61
|
+
fill: "currentColor",
|
|
62
|
+
className: `${sizeClass} ${className}`.trim(),
|
|
63
|
+
"aria-hidden": "true",
|
|
64
|
+
children: def.paths.map((d) => /* @__PURE__ */ jsx("path", { d }, d))
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
ChainIcon
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=ChainIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/inventory/ChainIcon.tsx"],"sourcesContent":["import type * as React from \"react\";\nimport { resolveChainKey } from \"./chainConfig.js\";\n\nexport type ChainIconSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface ChainIconProps {\n chain: string;\n size?: ChainIconSize;\n className?: string;\n}\n\nconst SIZE_CLASSES: Record<ChainIconSize, string> = {\n sm: \"h-4 w-4\",\n md: \"h-5 w-5\",\n lg: \"h-6 w-6\",\n};\n\n/* Per-chain size overrides for visual balance.\n * Some SVGs appear smaller at the same pixel size due to viewBox proportions. */\nconst SIZE_OVERRIDES: Partial<\n Record<string, Partial<Record<ChainIconSize, string>>>\n> = {\n bsc: { sm: \"h-5 w-5\", md: \"h-6 w-6\", lg: \"h-7 w-7\" },\n ethereum: { lg: \"h-7 w-7\" },\n base: { lg: \"h-7 w-7\" },\n};\n\ninterface ChainSvgDef {\n viewBox: string;\n paths: string[];\n}\n\nconst CHAIN_SVGS: Record<string, ChainSvgDef> = {\n ethereum: {\n viewBox: \"0 0 24 24\",\n paths: [\n \"M12 1.5l-7 10.167L12 15.5l7-3.833L12 1.5zM5 13.5L12 22.5l7-9-7 3.833L5 13.5z\",\n ],\n },\n base: {\n viewBox: \"0 0 146 146\",\n paths: [\n \"M73.323 123.729C101.617 123.729 124.553 100.832 124.553 72.5875C124.553 44.343 101.617 21.4463 73.323 21.4463C46.4795 21.4463 24.4581 42.0558 22.271 68.2887H89.9859V76.8864H22.271C24.4581 103.119 46.4795 123.729 73.323 123.729Z\",\n ],\n },\n bsc: {\n viewBox: \"0 0 2496 2496\",\n paths: [\n \"M685.9 1248l0.9 330 280.4 165v193.2l-444.5-260.7v-524L685.9 1248zM685.9 918v192.3l-163.3-96.6V821.4l163.3-96.6 164.1 96.6L685.9 918zM1084.3 821.4l163.3-96.6 164.1 96.6-164.1 96.6-163.3-96.6z\",\n \"M803.9 1509.6v-193.2l163.3 96.6v192.3L803.9 1509.6zM1084.3 1812.2l163.3 96.6 164.1-96.6v192.3l-164.1 96.6-163.3-96.6v-192.3zM1645.9 821.4l163.3-96.6 164.1 96.6v192.3l-164.1 96.6V918L1645.9 821.4zM1809.2 1578l0.9-330 163.3-96.6v524l-444.5 260.7v-193.2L1809.2 1578z\",\n \"M1692.1 986.4l0.9 193.2-281.2 165v330.8l-163.3 95.7-163.3-95.7v-330.8l-281.2-165V986.4L968 889.8l279.5 165.8 281.2-165.8 164.1 96.6h-0.7zM803.9 656.5l443.7-261.6 444.5 261.6-163.3 96.6-281.2-165.8-280.4 165.8-163.3-96.6z\",\n ],\n },\n avax: {\n viewBox: \"0 0 24 24\",\n paths: [\"M12 3L2 21h6l4-7 4 7h6L12 3z\"],\n },\n solana: {\n viewBox: \"0 0 397.7 311.7\",\n paths: [\n \"M64.6 237.9c2.4-2.4 5.7-3.8 9.2-3.8h317.4c5.8 0 8.7 7 4.6 11.1l-62.7 62.7c-2.4 2.4-5.7 3.8-9.2 3.8H6.5c-5.8 0-8.7-7-4.6-11.1L64.6 237.9z\",\n \"M64.6 3.8C67.1 1.4 70.4 0 73.8 0h317.4c5.8 0 8.7 7 4.6 11.1l-62.7 62.7c-2.4 2.4-5.7 3.8-9.2 3.8H6.5c-5.8 0-8.7-7-4.6-11.1L64.6 3.8z\",\n \"M333.1 120.1c-2.4-2.4-5.7-3.8-9.2-3.8H6.5c-5.8 0-8.7 7-4.6 11.1l62.7 62.7c2.4 2.4 5.7 3.8 9.2 3.8h317.4c5.8 0 8.7-7 4.6-11.1L333.1 120.1z\",\n ],\n },\n};\n\nexport function ChainIcon({\n chain,\n size = \"md\",\n className = \"\",\n}: ChainIconProps): React.ReactElement | null {\n const key = resolveChainKey(chain);\n if (!key) return null;\n const def = CHAIN_SVGS[key];\n if (!def) return null;\n\n const sizeClass = SIZE_OVERRIDES[key]?.[size] ?? SIZE_CLASSES[size];\n\n return (\n <svg\n viewBox={def.viewBox}\n fill=\"currentColor\"\n className={`${sizeClass} ${className}`.trim()}\n aria-hidden=\"true\"\n >\n {def.paths.map((d) => (\n <path key={d} d={d} />\n ))}\n </svg>\n );\n}\n"],"mappings":"AAuFQ;AAtFR,SAAS,uBAAuB;AAUhC,MAAM,eAA8C;AAAA,EAClD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAIA,MAAM,iBAEF;AAAA,EACF,KAAK,EAAE,IAAI,WAAW,IAAI,WAAW,IAAI,UAAU;AAAA,EACnD,UAAU,EAAE,IAAI,UAAU;AAAA,EAC1B,MAAM,EAAE,IAAI,UAAU;AACxB;AAOA,MAAM,aAA0C;AAAA,EAC9C,UAAU;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,OAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH,SAAS;AAAA,IACT,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,OAAO,CAAC,8BAA8B;AAAA,EACxC;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA,OAAO;AAAA,EACP,YAAY;AACd,GAA8C;AAC5C,QAAM,MAAM,gBAAgB,KAAK;AACjC,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,MAAM,WAAW,GAAG;AAC1B,MAAI,CAAC,IAAK,QAAO;AAEjB,QAAM,YAAY,eAAe,GAAG,IAAI,IAAI,KAAK,aAAa,IAAI;AAElE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,IAAI;AAAA,MACb,MAAK;AAAA,MACL,WAAW,GAAG,SAAS,IAAI,SAAS,GAAG,KAAK;AAAA,MAC5C,eAAY;AAAA,MAEX,cAAI,MAAM,IAAI,CAAC,MACd,oBAAC,UAAa,KAAH,CAAS,CACrB;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function TokenLogo({ symbol, chain, contractAddress, preferredLogoUrl, size, }: {
|
|
2
|
+
symbol: string;
|
|
3
|
+
chain: string;
|
|
4
|
+
contractAddress: string | null;
|
|
5
|
+
preferredLogoUrl?: string | null;
|
|
6
|
+
size?: number;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=TokenLogo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenLogo.d.ts","sourceRoot":"","sources":["../../src/inventory/TokenLogo.tsx"],"names":[],"mappings":"AAeA,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,KAAK,EACL,eAAe,EACf,gBAAuB,EACvB,IAAS,GACV,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,2CAkCA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { getContractLogoUrl, getNativeLogoUrl } from "./chainConfig.js";
|
|
4
|
+
import { chainIcon } from "./constants.js";
|
|
5
|
+
import { normalizeInventoryImageUrl } from "./media-url.js";
|
|
6
|
+
function tokenLogoUrl(chain, contractAddress) {
|
|
7
|
+
if (!contractAddress) {
|
|
8
|
+
return getNativeLogoUrl(chain);
|
|
9
|
+
}
|
|
10
|
+
return getContractLogoUrl(chain, contractAddress);
|
|
11
|
+
}
|
|
12
|
+
function TokenLogo({
|
|
13
|
+
symbol,
|
|
14
|
+
chain,
|
|
15
|
+
contractAddress,
|
|
16
|
+
preferredLogoUrl = null,
|
|
17
|
+
size = 32
|
|
18
|
+
}) {
|
|
19
|
+
const [errored, setErrored] = useState(false);
|
|
20
|
+
const preferredResolved = normalizeInventoryImageUrl(preferredLogoUrl);
|
|
21
|
+
const defaultResolved = normalizeInventoryImageUrl(
|
|
22
|
+
tokenLogoUrl(chain, contractAddress)
|
|
23
|
+
);
|
|
24
|
+
const url = errored ? null : preferredResolved ? preferredResolved : defaultResolved;
|
|
25
|
+
const icon = chainIcon(chain);
|
|
26
|
+
if (url) {
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
"img",
|
|
29
|
+
{
|
|
30
|
+
src: url,
|
|
31
|
+
alt: symbol,
|
|
32
|
+
width: size,
|
|
33
|
+
height: size,
|
|
34
|
+
className: "inline-flex shrink-0 items-center justify-center rounded-full object-cover font-mono font-bold text-white",
|
|
35
|
+
style: { width: size, height: size },
|
|
36
|
+
onError: () => setErrored(true)
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
"span",
|
|
42
|
+
{
|
|
43
|
+
className: `inline-flex items-center justify-center shrink-0 rounded-full font-mono font-bold bg-bg-muted ${icon.cls}`,
|
|
44
|
+
style: { width: size, height: size, fontSize: size * 0.38 },
|
|
45
|
+
children: symbol.charAt(0).toUpperCase()
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
TokenLogo
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=TokenLogo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/inventory/TokenLogo.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { getContractLogoUrl, getNativeLogoUrl } from \"./chainConfig.js\";\nimport { chainIcon } from \"./constants.js\";\nimport { normalizeInventoryImageUrl } from \"./media-url.js\";\n\nfunction tokenLogoUrl(\n chain: string,\n contractAddress: string | null,\n): string | null {\n if (!contractAddress) {\n return getNativeLogoUrl(chain);\n }\n return getContractLogoUrl(chain, contractAddress);\n}\n\nexport function TokenLogo({\n symbol,\n chain,\n contractAddress,\n preferredLogoUrl = null,\n size = 32,\n}: {\n symbol: string;\n chain: string;\n contractAddress: string | null;\n preferredLogoUrl?: string | null;\n size?: number;\n}) {\n const [errored, setErrored] = useState(false);\n const preferredResolved = normalizeInventoryImageUrl(preferredLogoUrl);\n const defaultResolved = normalizeInventoryImageUrl(\n tokenLogoUrl(chain, contractAddress),\n );\n const url = errored\n ? null\n : preferredResolved\n ? preferredResolved\n : defaultResolved;\n const icon = chainIcon(chain);\n\n if (url) {\n return (\n <img\n src={url}\n alt={symbol}\n width={size}\n height={size}\n className=\"inline-flex shrink-0 items-center justify-center rounded-full object-cover font-mono font-bold text-white\"\n style={{ width: size, height: size }}\n onError={() => setErrored(true)}\n />\n );\n }\n return (\n <span\n className={`inline-flex items-center justify-center shrink-0 rounded-full font-mono font-bold bg-bg-muted ${icon.cls}`}\n style={{ width: size, height: size, fontSize: size * 0.38 }}\n >\n {symbol.charAt(0).toUpperCase()}\n </span>\n );\n}\n"],"mappings":"AA0CM;AA1CN,SAAS,gBAAgB;AACzB,SAAS,oBAAoB,wBAAwB;AACrD,SAAS,iBAAiB;AAC1B,SAAS,kCAAkC;AAE3C,SAAS,aACP,OACA,iBACe;AACf,MAAI,CAAC,iBAAiB;AACpB,WAAO,iBAAiB,KAAK;AAAA,EAC/B;AACA,SAAO,mBAAmB,OAAO,eAAe;AAClD;AAEO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB,OAAO;AACT,GAMG;AACD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,oBAAoB,2BAA2B,gBAAgB;AACrE,QAAM,kBAAkB;AAAA,IACtB,aAAa,OAAO,eAAe;AAAA,EACrC;AACA,QAAM,MAAM,UACR,OACA,oBACE,oBACA;AACN,QAAM,OAAO,UAAU,KAAK;AAE5B,MAAI,KAAK;AACP,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,KAAK;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,WAAU;AAAA,QACV,OAAO,EAAE,OAAO,MAAM,QAAQ,KAAK;AAAA,QACnC,SAAS,MAAM,WAAW,IAAI;AAAA;AAAA,IAChC;AAAA,EAEJ;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,iGAAiG,KAAK,GAAG;AAAA,MACpH,OAAO,EAAE,OAAO,MAAM,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAEzD,iBAAO,OAAO,CAAC,EAAE,YAAY;AAAA;AAAA,EAChC;AAEJ;","names":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central chain configuration registry.
|
|
3
|
+
*
|
|
4
|
+
* Every chain-specific constant (explorer URLs, native token details,
|
|
5
|
+
* gas thresholds, stablecoin addresses, logo URLs, address validation)
|
|
6
|
+
* lives here so that UI components and hooks can derive values from
|
|
7
|
+
* a single source of truth rather than scattering inline constants.
|
|
8
|
+
*/
|
|
9
|
+
export type ChainKey = "bsc" | "avax" | "solana" | "ethereum" | "base" | "arbitrum" | "optimism" | "polygon";
|
|
10
|
+
export interface Stablecoin {
|
|
11
|
+
symbol: string;
|
|
12
|
+
address: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ChainConfig {
|
|
15
|
+
/** Unique identifier used as filter key and in storage keys. */
|
|
16
|
+
chainKey: ChainKey;
|
|
17
|
+
/** Human-readable chain name. */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Native gas-token symbol (e.g. BNB, AVAX, SOL). */
|
|
20
|
+
nativeSymbol: string;
|
|
21
|
+
/** Native token decimals. */
|
|
22
|
+
nativeDecimals: number;
|
|
23
|
+
/** Whether this is an EVM-compatible chain. */
|
|
24
|
+
isEvm: boolean;
|
|
25
|
+
/** Base URL of the chain's block explorer. */
|
|
26
|
+
explorerBaseUrl: string;
|
|
27
|
+
/** Path template for token pages; `{address}` is replaced. */
|
|
28
|
+
explorerTokenPath: string;
|
|
29
|
+
/** Path template for transaction pages; `{hash}` is replaced. */
|
|
30
|
+
explorerTxPath: string;
|
|
31
|
+
/** URL for the native gas-token logo. */
|
|
32
|
+
nativeLogoUrl: string;
|
|
33
|
+
/** TrustWallet assets CDN slug (e.g. `smartchain`, `avalanchec`). */
|
|
34
|
+
trustWalletSlug: string | null;
|
|
35
|
+
/** Minimum native balance to consider the wallet "trade-ready". */
|
|
36
|
+
gasReadyThreshold: number;
|
|
37
|
+
/** Reserve kept aside from max-balance swaps. */
|
|
38
|
+
swapGasReserve: number;
|
|
39
|
+
/** Well-known stablecoin contract addresses on this chain. */
|
|
40
|
+
stablecoins: Stablecoin[];
|
|
41
|
+
/** Regex to validate an address on this chain. */
|
|
42
|
+
addressRegex: RegExp;
|
|
43
|
+
/** Chain ID used by the DexScreener API. */
|
|
44
|
+
dexScreenerChainId: string;
|
|
45
|
+
/** Alternative chain name strings that resolve to this config. */
|
|
46
|
+
nameVariants: string[];
|
|
47
|
+
/** Brand color for the chain. CSS variable reference (e.g. `"var(--color-chain-eth)"`). */
|
|
48
|
+
color: string;
|
|
49
|
+
}
|
|
50
|
+
export declare const CHAIN_CONFIGS: Record<ChainKey, ChainConfig>;
|
|
51
|
+
/** Resolve a chain name (case-insensitive, trimmed) to its config. */
|
|
52
|
+
export declare function getChainConfig(chainName: string): ChainConfig | null;
|
|
53
|
+
/**
|
|
54
|
+
* Resolve a chain name string to a `ChainKey`.
|
|
55
|
+
* Returns `null` for unrecognised chains.
|
|
56
|
+
*/
|
|
57
|
+
export declare function resolveChainKey(chainName: string): ChainKey | null;
|
|
58
|
+
/**
|
|
59
|
+
* Build the explorer URL for a token on the given chain.
|
|
60
|
+
* Returns `null` if the chain is unknown or the address is invalid.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getExplorerTokenUrl(chainName: string, address: string): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Build the explorer URL for a transaction on the given chain.
|
|
65
|
+
* Returns `null` if the chain is unknown.
|
|
66
|
+
*/
|
|
67
|
+
export declare function getExplorerTxUrl(chainName: string, hash: string): string | null;
|
|
68
|
+
/**
|
|
69
|
+
* Get the native token logo URL for a chain, or `null` if unknown.
|
|
70
|
+
*/
|
|
71
|
+
export declare function getNativeLogoUrl(chainName: string): string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Get the TrustWallet CDN logo URL for a contract token on the given chain.
|
|
74
|
+
* Returns `null` if the chain has no TrustWallet slug or no contract address.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getContractLogoUrl(chainName: string, contractAddress: string | null): string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Resolve a stablecoin address on a given chain by symbol.
|
|
79
|
+
* Returns `null` if not found.
|
|
80
|
+
*/
|
|
81
|
+
export declare function getStablecoinAddress(chainName: string, symbol: string): string | null;
|
|
82
|
+
/** The primary chains we want to support prominently. */
|
|
83
|
+
export declare const PRIMARY_CHAIN_KEYS: ChainKey[];
|
|
84
|
+
/**
|
|
85
|
+
* Map a chain focus key (ChainKey or "all") to the legacy WalletRpcChain used
|
|
86
|
+
* by legacyCustomChains. Returns null for "all" or unknown chains.
|
|
87
|
+
*/
|
|
88
|
+
export declare function chainKeyToWalletRpcChain(chainFocus: string): "evm" | "bsc" | "solana" | null;
|
|
89
|
+
//# sourceMappingURL=chainConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chainConfig.d.ts","sourceRoot":"","sources":["../../src/inventory/chainConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,QAAQ,GAChB,KAAK,GACL,MAAM,GACN,QAAQ,GACR,UAAU,GACV,MAAM,GACN,UAAU,GACV,UAAU,GACV,SAAS,CAA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AE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CAMf;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,IAAI,CAIf;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEjE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GAAG,IAAI,GAC7B,MAAM,GAAG,IAAI,CAKf;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,IAAI,CAKf;AAED,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,EAAE,QAAQ,EAMxC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,GACjB,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,IAAI,CAYjC"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
const HEX_ADDRESS_RE = /^0x[a-fA-F0-9]{40}$/;
|
|
2
|
+
const SOLANA_ADDRESS_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
3
|
+
const CHAIN_CONFIGS = {
|
|
4
|
+
bsc: {
|
|
5
|
+
chainKey: "bsc",
|
|
6
|
+
name: "BSC",
|
|
7
|
+
nativeSymbol: "BNB",
|
|
8
|
+
nativeDecimals: 18,
|
|
9
|
+
isEvm: true,
|
|
10
|
+
explorerBaseUrl: "https://bscscan.com",
|
|
11
|
+
explorerTokenPath: "/token/{address}",
|
|
12
|
+
explorerTxPath: "/tx/{hash}",
|
|
13
|
+
nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/smartchain/info/logo.png",
|
|
14
|
+
trustWalletSlug: "smartchain",
|
|
15
|
+
gasReadyThreshold: 5e-3,
|
|
16
|
+
swapGasReserve: 2e-3,
|
|
17
|
+
stablecoins: [
|
|
18
|
+
{ symbol: "USDT", address: "0x55d398326f99059fF775485246999027B3197955" },
|
|
19
|
+
{ symbol: "USDC", address: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d" }
|
|
20
|
+
],
|
|
21
|
+
addressRegex: HEX_ADDRESS_RE,
|
|
22
|
+
dexScreenerChainId: "bsc",
|
|
23
|
+
nameVariants: ["bsc", "bnb chain", "bnb smart chain"],
|
|
24
|
+
color: "var(--color-chain-bsc)"
|
|
25
|
+
},
|
|
26
|
+
avax: {
|
|
27
|
+
chainKey: "avax",
|
|
28
|
+
name: "Avalanche",
|
|
29
|
+
nativeSymbol: "AVAX",
|
|
30
|
+
nativeDecimals: 18,
|
|
31
|
+
isEvm: true,
|
|
32
|
+
explorerBaseUrl: "https://snowtrace.io",
|
|
33
|
+
explorerTokenPath: "/token/{address}",
|
|
34
|
+
explorerTxPath: "/tx/{hash}",
|
|
35
|
+
nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/info/logo.png",
|
|
36
|
+
trustWalletSlug: "avalanchec",
|
|
37
|
+
gasReadyThreshold: 0.01,
|
|
38
|
+
swapGasReserve: 5e-3,
|
|
39
|
+
stablecoins: [
|
|
40
|
+
{ symbol: "USDT", address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7" },
|
|
41
|
+
{ symbol: "USDC", address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E" }
|
|
42
|
+
],
|
|
43
|
+
addressRegex: HEX_ADDRESS_RE,
|
|
44
|
+
dexScreenerChainId: "avalanche",
|
|
45
|
+
nameVariants: ["avax", "avalanche", "c-chain", "avalanche c-chain"],
|
|
46
|
+
color: "#e84142"
|
|
47
|
+
},
|
|
48
|
+
solana: {
|
|
49
|
+
chainKey: "solana",
|
|
50
|
+
name: "Solana",
|
|
51
|
+
nativeSymbol: "SOL",
|
|
52
|
+
nativeDecimals: 9,
|
|
53
|
+
isEvm: false,
|
|
54
|
+
explorerBaseUrl: "https://solscan.io",
|
|
55
|
+
explorerTokenPath: "/token/{address}",
|
|
56
|
+
explorerTxPath: "/tx/{hash}",
|
|
57
|
+
nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png",
|
|
58
|
+
trustWalletSlug: "solana",
|
|
59
|
+
gasReadyThreshold: 0.01,
|
|
60
|
+
swapGasReserve: 5e-3,
|
|
61
|
+
stablecoins: [
|
|
62
|
+
{
|
|
63
|
+
symbol: "USDC",
|
|
64
|
+
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
addressRegex: SOLANA_ADDRESS_RE,
|
|
68
|
+
dexScreenerChainId: "solana",
|
|
69
|
+
nameVariants: ["solana", "sol"],
|
|
70
|
+
color: "var(--color-chain-sol)"
|
|
71
|
+
},
|
|
72
|
+
ethereum: {
|
|
73
|
+
chainKey: "ethereum",
|
|
74
|
+
name: "Ethereum",
|
|
75
|
+
nativeSymbol: "ETH",
|
|
76
|
+
nativeDecimals: 18,
|
|
77
|
+
isEvm: true,
|
|
78
|
+
explorerBaseUrl: "https://etherscan.io",
|
|
79
|
+
explorerTokenPath: "/token/{address}",
|
|
80
|
+
explorerTxPath: "/tx/{hash}",
|
|
81
|
+
nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
|
|
82
|
+
trustWalletSlug: "ethereum",
|
|
83
|
+
gasReadyThreshold: 5e-3,
|
|
84
|
+
swapGasReserve: 2e-3,
|
|
85
|
+
stablecoins: [
|
|
86
|
+
{ symbol: "USDT", address: "0xdAC17F958D2ee523a2206206994597C13D831ec7" },
|
|
87
|
+
{ symbol: "USDC", address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" }
|
|
88
|
+
],
|
|
89
|
+
addressRegex: HEX_ADDRESS_RE,
|
|
90
|
+
dexScreenerChainId: "ethereum",
|
|
91
|
+
nameVariants: ["ethereum", "mainnet", "eth"],
|
|
92
|
+
color: "var(--color-chain-eth)"
|
|
93
|
+
},
|
|
94
|
+
base: {
|
|
95
|
+
chainKey: "base",
|
|
96
|
+
name: "Base",
|
|
97
|
+
nativeSymbol: "ETH",
|
|
98
|
+
nativeDecimals: 18,
|
|
99
|
+
isEvm: true,
|
|
100
|
+
explorerBaseUrl: "https://basescan.org",
|
|
101
|
+
explorerTokenPath: "/token/{address}",
|
|
102
|
+
explorerTxPath: "/tx/{hash}",
|
|
103
|
+
nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png",
|
|
104
|
+
trustWalletSlug: "base",
|
|
105
|
+
gasReadyThreshold: 5e-3,
|
|
106
|
+
swapGasReserve: 1e-3,
|
|
107
|
+
stablecoins: [
|
|
108
|
+
{ symbol: "USDC", address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" }
|
|
109
|
+
],
|
|
110
|
+
addressRegex: HEX_ADDRESS_RE,
|
|
111
|
+
dexScreenerChainId: "base",
|
|
112
|
+
nameVariants: ["base"],
|
|
113
|
+
color: "var(--color-chain-base)"
|
|
114
|
+
},
|
|
115
|
+
arbitrum: {
|
|
116
|
+
chainKey: "arbitrum",
|
|
117
|
+
name: "Arbitrum",
|
|
118
|
+
nativeSymbol: "ETH",
|
|
119
|
+
nativeDecimals: 18,
|
|
120
|
+
isEvm: true,
|
|
121
|
+
explorerBaseUrl: "https://arbiscan.io",
|
|
122
|
+
explorerTokenPath: "/token/{address}",
|
|
123
|
+
explorerTxPath: "/tx/{hash}",
|
|
124
|
+
nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
|
|
125
|
+
trustWalletSlug: null,
|
|
126
|
+
gasReadyThreshold: 5e-3,
|
|
127
|
+
swapGasReserve: 1e-3,
|
|
128
|
+
stablecoins: [
|
|
129
|
+
{ symbol: "USDC", address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831" }
|
|
130
|
+
],
|
|
131
|
+
addressRegex: HEX_ADDRESS_RE,
|
|
132
|
+
dexScreenerChainId: "arbitrum",
|
|
133
|
+
nameVariants: ["arbitrum"],
|
|
134
|
+
color: "var(--color-chain-arb)"
|
|
135
|
+
},
|
|
136
|
+
optimism: {
|
|
137
|
+
chainKey: "optimism",
|
|
138
|
+
name: "Optimism",
|
|
139
|
+
nativeSymbol: "ETH",
|
|
140
|
+
nativeDecimals: 18,
|
|
141
|
+
isEvm: true,
|
|
142
|
+
explorerBaseUrl: "https://optimistic.etherscan.io",
|
|
143
|
+
explorerTokenPath: "/token/{address}",
|
|
144
|
+
explorerTxPath: "/tx/{hash}",
|
|
145
|
+
nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
|
|
146
|
+
trustWalletSlug: null,
|
|
147
|
+
gasReadyThreshold: 5e-3,
|
|
148
|
+
swapGasReserve: 1e-3,
|
|
149
|
+
stablecoins: [
|
|
150
|
+
{ symbol: "USDC", address: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85" }
|
|
151
|
+
],
|
|
152
|
+
addressRegex: HEX_ADDRESS_RE,
|
|
153
|
+
dexScreenerChainId: "optimism",
|
|
154
|
+
nameVariants: ["optimism"],
|
|
155
|
+
color: "var(--color-chain-op)"
|
|
156
|
+
},
|
|
157
|
+
polygon: {
|
|
158
|
+
chainKey: "polygon",
|
|
159
|
+
name: "Polygon",
|
|
160
|
+
nativeSymbol: "MATIC",
|
|
161
|
+
nativeDecimals: 18,
|
|
162
|
+
isEvm: true,
|
|
163
|
+
explorerBaseUrl: "https://polygonscan.com",
|
|
164
|
+
explorerTokenPath: "/token/{address}",
|
|
165
|
+
explorerTxPath: "/tx/{hash}",
|
|
166
|
+
nativeLogoUrl: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png",
|
|
167
|
+
trustWalletSlug: "polygon",
|
|
168
|
+
gasReadyThreshold: 0.5,
|
|
169
|
+
swapGasReserve: 0.1,
|
|
170
|
+
stablecoins: [
|
|
171
|
+
{ symbol: "USDT", address: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F" },
|
|
172
|
+
{ symbol: "USDC", address: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359" }
|
|
173
|
+
],
|
|
174
|
+
addressRegex: HEX_ADDRESS_RE,
|
|
175
|
+
dexScreenerChainId: "polygon",
|
|
176
|
+
nameVariants: ["polygon"],
|
|
177
|
+
color: "var(--color-chain-pol)"
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const _variantMap = /* @__PURE__ */ new Map();
|
|
181
|
+
for (const config of Object.values(CHAIN_CONFIGS)) {
|
|
182
|
+
for (const variant of config.nameVariants) {
|
|
183
|
+
_variantMap.set(variant.toLowerCase(), config);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function getChainConfig(chainName) {
|
|
187
|
+
return _variantMap.get(chainName.trim().toLowerCase()) ?? null;
|
|
188
|
+
}
|
|
189
|
+
function resolveChainKey(chainName) {
|
|
190
|
+
const config = getChainConfig(chainName);
|
|
191
|
+
return config?.chainKey ?? null;
|
|
192
|
+
}
|
|
193
|
+
function getExplorerTokenUrl(chainName, address) {
|
|
194
|
+
const config = getChainConfig(chainName);
|
|
195
|
+
if (!config) return null;
|
|
196
|
+
const trimmed = address.trim();
|
|
197
|
+
if (!config.addressRegex.test(trimmed)) return null;
|
|
198
|
+
return `${config.explorerBaseUrl}${config.explorerTokenPath.replace("{address}", trimmed)}`;
|
|
199
|
+
}
|
|
200
|
+
function getExplorerTxUrl(chainName, hash) {
|
|
201
|
+
const config = getChainConfig(chainName);
|
|
202
|
+
if (!config) return null;
|
|
203
|
+
return `${config.explorerBaseUrl}${config.explorerTxPath.replace("{hash}", hash.trim())}`;
|
|
204
|
+
}
|
|
205
|
+
function getNativeLogoUrl(chainName) {
|
|
206
|
+
return getChainConfig(chainName)?.nativeLogoUrl ?? null;
|
|
207
|
+
}
|
|
208
|
+
function getContractLogoUrl(chainName, contractAddress) {
|
|
209
|
+
if (!contractAddress) return null;
|
|
210
|
+
const config = getChainConfig(chainName);
|
|
211
|
+
if (!config?.trustWalletSlug) return null;
|
|
212
|
+
return `https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${config.trustWalletSlug}/assets/${contractAddress}/logo.png`;
|
|
213
|
+
}
|
|
214
|
+
function getStablecoinAddress(chainName, symbol) {
|
|
215
|
+
const config = getChainConfig(chainName);
|
|
216
|
+
if (!config) return null;
|
|
217
|
+
const upper = symbol.trim().toUpperCase();
|
|
218
|
+
return config.stablecoins.find((s) => s.symbol === upper)?.address ?? null;
|
|
219
|
+
}
|
|
220
|
+
const PRIMARY_CHAIN_KEYS = [
|
|
221
|
+
"ethereum",
|
|
222
|
+
"base",
|
|
223
|
+
"bsc",
|
|
224
|
+
"avax",
|
|
225
|
+
"solana"
|
|
226
|
+
];
|
|
227
|
+
function chainKeyToWalletRpcChain(chainFocus) {
|
|
228
|
+
if (chainFocus === "all" || chainFocus === "multi") return null;
|
|
229
|
+
if (chainFocus === "bsc" || chainFocus === "solana") return chainFocus;
|
|
230
|
+
const evmKeys = [
|
|
231
|
+
"ethereum",
|
|
232
|
+
"base",
|
|
233
|
+
"avax",
|
|
234
|
+
"arbitrum",
|
|
235
|
+
"optimism",
|
|
236
|
+
"polygon"
|
|
237
|
+
];
|
|
238
|
+
return evmKeys.includes(chainFocus) ? "evm" : null;
|
|
239
|
+
}
|
|
240
|
+
export {
|
|
241
|
+
CHAIN_CONFIGS,
|
|
242
|
+
PRIMARY_CHAIN_KEYS,
|
|
243
|
+
chainKeyToWalletRpcChain,
|
|
244
|
+
getChainConfig,
|
|
245
|
+
getContractLogoUrl,
|
|
246
|
+
getExplorerTokenUrl,
|
|
247
|
+
getExplorerTxUrl,
|
|
248
|
+
getNativeLogoUrl,
|
|
249
|
+
getStablecoinAddress,
|
|
250
|
+
resolveChainKey
|
|
251
|
+
};
|
|
252
|
+
//# sourceMappingURL=chainConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/inventory/chainConfig.ts"],"sourcesContent":["/**\n * Central chain configuration registry.\n *\n * Every chain-specific constant (explorer URLs, native token details,\n * gas thresholds, stablecoin addresses, logo URLs, address validation)\n * lives here so that UI components and hooks can derive values from\n * a single source of truth rather than scattering inline constants.\n */\n\nexport type ChainKey =\n | \"bsc\"\n | \"avax\"\n | \"solana\"\n | \"ethereum\"\n | \"base\"\n | \"arbitrum\"\n | \"optimism\"\n | \"polygon\";\n\nexport interface Stablecoin {\n symbol: string;\n address: string;\n}\n\nexport interface ChainConfig {\n /** Unique identifier used as filter key and in storage keys. */\n chainKey: ChainKey;\n /** Human-readable chain name. */\n name: string;\n /** Native gas-token symbol (e.g. BNB, AVAX, SOL). */\n nativeSymbol: string;\n /** Native token decimals. */\n nativeDecimals: number;\n /** Whether this is an EVM-compatible chain. */\n isEvm: boolean;\n\n /** Base URL of the chain's block explorer. */\n explorerBaseUrl: string;\n /** Path template for token pages; `{address}` is replaced. */\n explorerTokenPath: string;\n /** Path template for transaction pages; `{hash}` is replaced. */\n explorerTxPath: string;\n\n /** URL for the native gas-token logo. */\n nativeLogoUrl: string;\n /** TrustWallet assets CDN slug (e.g. `smartchain`, `avalanchec`). */\n trustWalletSlug: string | null;\n\n /** Minimum native balance to consider the wallet \"trade-ready\". */\n gasReadyThreshold: number;\n /** Reserve kept aside from max-balance swaps. */\n swapGasReserve: number;\n\n /** Well-known stablecoin contract addresses on this chain. */\n stablecoins: Stablecoin[];\n\n /** Regex to validate an address on this chain. */\n addressRegex: RegExp;\n\n /** Chain ID used by the DexScreener API. */\n dexScreenerChainId: string;\n\n /** Alternative chain name strings that resolve to this config. */\n nameVariants: string[];\n\n /** Brand color for the chain. CSS variable reference (e.g. `\"var(--color-chain-eth)\"`). */\n color: string;\n}\n\nconst HEX_ADDRESS_RE = /^0x[a-fA-F0-9]{40}$/;\nconst SOLANA_ADDRESS_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;\n\nexport const CHAIN_CONFIGS: Record<ChainKey, ChainConfig> = {\n bsc: {\n chainKey: \"bsc\",\n name: \"BSC\",\n nativeSymbol: \"BNB\",\n nativeDecimals: 18,\n isEvm: true,\n explorerBaseUrl: \"https://bscscan.com\",\n explorerTokenPath: \"/token/{address}\",\n explorerTxPath: \"/tx/{hash}\",\n nativeLogoUrl:\n \"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/smartchain/info/logo.png\",\n trustWalletSlug: \"smartchain\",\n gasReadyThreshold: 0.005,\n swapGasReserve: 0.002,\n stablecoins: [\n { symbol: \"USDT\", address: \"0x55d398326f99059fF775485246999027B3197955\" },\n { symbol: \"USDC\", address: \"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d\" },\n ],\n addressRegex: HEX_ADDRESS_RE,\n dexScreenerChainId: \"bsc\",\n nameVariants: [\"bsc\", \"bnb chain\", \"bnb smart chain\"],\n color: \"var(--color-chain-bsc)\",\n },\n\n avax: {\n chainKey: \"avax\",\n name: \"Avalanche\",\n nativeSymbol: \"AVAX\",\n nativeDecimals: 18,\n isEvm: true,\n explorerBaseUrl: \"https://snowtrace.io\",\n explorerTokenPath: \"/token/{address}\",\n explorerTxPath: \"/tx/{hash}\",\n nativeLogoUrl:\n \"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/info/logo.png\",\n trustWalletSlug: \"avalanchec\",\n gasReadyThreshold: 0.01,\n swapGasReserve: 0.005,\n stablecoins: [\n { symbol: \"USDT\", address: \"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7\" },\n { symbol: \"USDC\", address: \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\" },\n ],\n addressRegex: HEX_ADDRESS_RE,\n dexScreenerChainId: \"avalanche\",\n nameVariants: [\"avax\", \"avalanche\", \"c-chain\", \"avalanche c-chain\"],\n color: \"#e84142\",\n },\n\n solana: {\n chainKey: \"solana\",\n name: \"Solana\",\n nativeSymbol: \"SOL\",\n nativeDecimals: 9,\n isEvm: false,\n explorerBaseUrl: \"https://solscan.io\",\n explorerTokenPath: \"/token/{address}\",\n explorerTxPath: \"/tx/{hash}\",\n nativeLogoUrl:\n \"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png\",\n trustWalletSlug: \"solana\",\n gasReadyThreshold: 0.01,\n swapGasReserve: 0.005,\n stablecoins: [\n {\n symbol: \"USDC\",\n address: \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n },\n ],\n addressRegex: SOLANA_ADDRESS_RE,\n dexScreenerChainId: \"solana\",\n nameVariants: [\"solana\", \"sol\"],\n color: \"var(--color-chain-sol)\",\n },\n\n ethereum: {\n chainKey: \"ethereum\",\n name: \"Ethereum\",\n nativeSymbol: \"ETH\",\n nativeDecimals: 18,\n isEvm: true,\n explorerBaseUrl: \"https://etherscan.io\",\n explorerTokenPath: \"/token/{address}\",\n explorerTxPath: \"/tx/{hash}\",\n nativeLogoUrl:\n \"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png\",\n trustWalletSlug: \"ethereum\",\n gasReadyThreshold: 0.005,\n swapGasReserve: 0.002,\n stablecoins: [\n { symbol: \"USDT\", address: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\" },\n { symbol: \"USDC\", address: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\" },\n ],\n addressRegex: HEX_ADDRESS_RE,\n dexScreenerChainId: \"ethereum\",\n nameVariants: [\"ethereum\", \"mainnet\", \"eth\"],\n color: \"var(--color-chain-eth)\",\n },\n\n base: {\n chainKey: \"base\",\n name: \"Base\",\n nativeSymbol: \"ETH\",\n nativeDecimals: 18,\n isEvm: true,\n explorerBaseUrl: \"https://basescan.org\",\n explorerTokenPath: \"/token/{address}\",\n explorerTxPath: \"/tx/{hash}\",\n nativeLogoUrl:\n \"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png\",\n trustWalletSlug: \"base\",\n gasReadyThreshold: 0.005,\n swapGasReserve: 0.001,\n stablecoins: [\n { symbol: \"USDC\", address: \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\" },\n ],\n addressRegex: HEX_ADDRESS_RE,\n dexScreenerChainId: \"base\",\n nameVariants: [\"base\"],\n color: \"var(--color-chain-base)\",\n },\n\n arbitrum: {\n chainKey: \"arbitrum\",\n name: \"Arbitrum\",\n nativeSymbol: \"ETH\",\n nativeDecimals: 18,\n isEvm: true,\n explorerBaseUrl: \"https://arbiscan.io\",\n explorerTokenPath: \"/token/{address}\",\n explorerTxPath: \"/tx/{hash}\",\n nativeLogoUrl:\n \"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png\",\n trustWalletSlug: null,\n gasReadyThreshold: 0.005,\n swapGasReserve: 0.001,\n stablecoins: [\n { symbol: \"USDC\", address: \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\" },\n ],\n addressRegex: HEX_ADDRESS_RE,\n dexScreenerChainId: \"arbitrum\",\n nameVariants: [\"arbitrum\"],\n color: \"var(--color-chain-arb)\",\n },\n\n optimism: {\n chainKey: \"optimism\",\n name: \"Optimism\",\n nativeSymbol: \"ETH\",\n nativeDecimals: 18,\n isEvm: true,\n explorerBaseUrl: \"https://optimistic.etherscan.io\",\n explorerTokenPath: \"/token/{address}\",\n explorerTxPath: \"/tx/{hash}\",\n nativeLogoUrl:\n \"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png\",\n trustWalletSlug: null,\n gasReadyThreshold: 0.005,\n swapGasReserve: 0.001,\n stablecoins: [\n { symbol: \"USDC\", address: \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\" },\n ],\n addressRegex: HEX_ADDRESS_RE,\n dexScreenerChainId: \"optimism\",\n nameVariants: [\"optimism\"],\n color: \"var(--color-chain-op)\",\n },\n\n polygon: {\n chainKey: \"polygon\",\n name: \"Polygon\",\n nativeSymbol: \"MATIC\",\n nativeDecimals: 18,\n isEvm: true,\n explorerBaseUrl: \"https://polygonscan.com\",\n explorerTokenPath: \"/token/{address}\",\n explorerTxPath: \"/tx/{hash}\",\n nativeLogoUrl:\n \"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png\",\n trustWalletSlug: \"polygon\",\n gasReadyThreshold: 0.5,\n swapGasReserve: 0.1,\n stablecoins: [\n { symbol: \"USDT\", address: \"0xc2132D05D31c914a87C6611C10748AEb04B58e8F\" },\n { symbol: \"USDC\", address: \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\" },\n ],\n addressRegex: HEX_ADDRESS_RE,\n dexScreenerChainId: \"polygon\",\n nameVariants: [\"polygon\"],\n color: \"var(--color-chain-pol)\",\n },\n};\n\n/** Pre-built lookup table from lowercase variant to ChainConfig. */\nconst _variantMap = new Map<string, ChainConfig>();\nfor (const config of Object.values(CHAIN_CONFIGS)) {\n for (const variant of config.nameVariants) {\n _variantMap.set(variant.toLowerCase(), config);\n }\n}\n\n/** Resolve a chain name (case-insensitive, trimmed) to its config. */\nexport function getChainConfig(chainName: string): ChainConfig | null {\n return _variantMap.get(chainName.trim().toLowerCase()) ?? null;\n}\n\n/**\n * Resolve a chain name string to a `ChainKey`.\n * Returns `null` for unrecognised chains.\n */\nexport function resolveChainKey(chainName: string): ChainKey | null {\n const config = getChainConfig(chainName);\n return config?.chainKey ?? null;\n}\n\n/**\n * Build the explorer URL for a token on the given chain.\n * Returns `null` if the chain is unknown or the address is invalid.\n */\nexport function getExplorerTokenUrl(\n chainName: string,\n address: string,\n): string | null {\n const config = getChainConfig(chainName);\n if (!config) return null;\n const trimmed = address.trim();\n if (!config.addressRegex.test(trimmed)) return null;\n return `${config.explorerBaseUrl}${config.explorerTokenPath.replace(\"{address}\", trimmed)}`;\n}\n\n/**\n * Build the explorer URL for a transaction on the given chain.\n * Returns `null` if the chain is unknown.\n */\nexport function getExplorerTxUrl(\n chainName: string,\n hash: string,\n): string | null {\n const config = getChainConfig(chainName);\n if (!config) return null;\n return `${config.explorerBaseUrl}${config.explorerTxPath.replace(\"{hash}\", hash.trim())}`;\n}\n\n/**\n * Get the native token logo URL for a chain, or `null` if unknown.\n */\nexport function getNativeLogoUrl(chainName: string): string | null {\n return getChainConfig(chainName)?.nativeLogoUrl ?? null;\n}\n\n/**\n * Get the TrustWallet CDN logo URL for a contract token on the given chain.\n * Returns `null` if the chain has no TrustWallet slug or no contract address.\n */\nexport function getContractLogoUrl(\n chainName: string,\n contractAddress: string | null,\n): string | null {\n if (!contractAddress) return null;\n const config = getChainConfig(chainName);\n if (!config?.trustWalletSlug) return null;\n return `https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${config.trustWalletSlug}/assets/${contractAddress}/logo.png`;\n}\n\n/**\n * Resolve a stablecoin address on a given chain by symbol.\n * Returns `null` if not found.\n */\nexport function getStablecoinAddress(\n chainName: string,\n symbol: string,\n): string | null {\n const config = getChainConfig(chainName);\n if (!config) return null;\n const upper = symbol.trim().toUpperCase();\n return config.stablecoins.find((s) => s.symbol === upper)?.address ?? null;\n}\n\n/** The primary chains we want to support prominently. */\nexport const PRIMARY_CHAIN_KEYS: ChainKey[] = [\n \"ethereum\",\n \"base\",\n \"bsc\",\n \"avax\",\n \"solana\",\n];\n\n/**\n * Map a chain focus key (ChainKey or \"all\") to the legacy WalletRpcChain used\n * by legacyCustomChains. Returns null for \"all\" or unknown chains.\n */\nexport function chainKeyToWalletRpcChain(\n chainFocus: string,\n): \"evm\" | \"bsc\" | \"solana\" | null {\n if (chainFocus === \"all\" || chainFocus === \"multi\") return null;\n if (chainFocus === \"bsc\" || chainFocus === \"solana\") return chainFocus;\n const evmKeys: ChainKey[] = [\n \"ethereum\",\n \"base\",\n \"avax\",\n \"arbitrum\",\n \"optimism\",\n \"polygon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