From 9933ecaf79d1ce5a6ea3072fcd957ea2cc3eeccf Mon Sep 17 00:00:00 2001 From: corbanbrook Date: Wed, 22 May 2024 17:40:13 +0000 Subject: [PATCH] Build: (aa1db28) Cleanup (#59) * examples/next: move config.ts to src root so its easier to find * Remove wallet options * packages/kit: removing unneccessary dependency to connectors * Fixing self referential imports in package/kit * remove old react-waas demo * Rename Web3Provider to Providers --------- Co-authored-by: samuelea --- ...owser-external_commonjs-proxy-B-cSWyK0.js} | 2 +- assets/{ccip-BoUAqsGL.js => ccip-XVd28I1a.js} | 2 +- .../{index-CMU5YblP.js => index-Bf2oTxTI.js} | 4 +- .../{index-Bn68Ze9l.js => index-BkIGJbIT.js} | 738 +++++++++--------- .../{index-Dw77FWPI.js => index-DIUle0En.js} | 6 +- .../{index-CO4t4qDX.js => index-KoV3ZGCG.js} | 4 +- ...ex.es-gzdlT0Xp.js => index.es-pmuHIzee.js} | 8 +- index.html | 2 +- 8 files changed, 383 insertions(+), 383 deletions(-) rename assets/{___vite-browser-external_commonjs-proxy-BWPtq7er.js => ___vite-browser-external_commonjs-proxy-B-cSWyK0.js} (99%) rename assets/{ccip-BoUAqsGL.js => ccip-XVd28I1a.js} (99%) rename assets/{index-CMU5YblP.js => index-Bf2oTxTI.js} (99%) rename assets/{index-Bn68Ze9l.js => index-BkIGJbIT.js} (99%) rename assets/{index-Dw77FWPI.js => index-DIUle0En.js} (99%) rename assets/{index-CO4t4qDX.js => index-KoV3ZGCG.js} (99%) rename assets/{index.es-gzdlT0Xp.js => index.es-pmuHIzee.js} (99%) diff --git a/assets/___vite-browser-external_commonjs-proxy-BWPtq7er.js b/assets/___vite-browser-external_commonjs-proxy-B-cSWyK0.js similarity index 99% rename from assets/___vite-browser-external_commonjs-proxy-BWPtq7er.js rename to assets/___vite-browser-external_commonjs-proxy-B-cSWyK0.js index 34a259db..0a6147f9 100644 --- a/assets/___vite-browser-external_commonjs-proxy-BWPtq7er.js +++ b/assets/___vite-browser-external_commonjs-proxy-B-cSWyK0.js @@ -1,4 +1,4 @@ -import { b as getDefaultExportFromCjs, a as getAugmentedNamespace } from "./index-Bn68Ze9l.js"; +import { b as getDefaultExportFromCjs, a as getAugmentedNamespace } from "./index-BkIGJbIT.js"; var events = { exports: {} }; var R = typeof Reflect === "object" ? Reflect : null; var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply2(target, receiver, args) { diff --git a/assets/ccip-BoUAqsGL.js b/assets/ccip-XVd28I1a.js similarity index 99% rename from assets/ccip-BoUAqsGL.js rename to assets/ccip-XVd28I1a.js index dde8f789..ddce9afe 100644 --- a/assets/ccip-BoUAqsGL.js +++ b/assets/ccip-XVd28I1a.js @@ -1,4 +1,4 @@ -import { h as BaseError, j as getUrl, s as stringify, k as isAddress, I as InvalidAddressError, l as decodeErrorResult, m as call, n as concat, o as encodeAbiParameters, H as HttpRequestError, q as isHex } from "./index-Bn68Ze9l.js"; +import { h as BaseError, j as getUrl, s as stringify, k as isAddress, I as InvalidAddressError, l as decodeErrorResult, m as call, n as concat, o as encodeAbiParameters, H as HttpRequestError, q as isHex } from "./index-BkIGJbIT.js"; class OffchainLookupError extends BaseError { constructor({ callbackSelector, cause, data, extraData, sender, urls }) { var _a; diff --git a/assets/index-CMU5YblP.js b/assets/index-Bf2oTxTI.js similarity index 99% rename from assets/index-CMU5YblP.js rename to assets/index-Bf2oTxTI.js index 17d168c2..361c89f1 100644 --- a/assets/index-CMU5YblP.js +++ b/assets/index-Bf2oTxTI.js @@ -1,5 +1,5 @@ -import { n as ne$1, s as se$1, T as T$2, t as te$1, a as a$2, o as oe$1, R as R$1, p as p$1, y as y$1 } from "./index-Dw77FWPI.js"; -import "./index-Bn68Ze9l.js"; +import { n as ne$1, s as se$1, T as T$2, t as te$1, a as a$2, o as oe$1, R as R$1, p as p$1, y as y$1 } from "./index-DIUle0En.js"; +import "./index-BkIGJbIT.js"; function addUniqueItem(array, item) { array.indexOf(item) === -1 && array.push(item); } diff --git a/assets/index-Bn68Ze9l.js b/assets/index-BkIGJbIT.js similarity index 99% rename from assets/index-Bn68Ze9l.js rename to assets/index-BkIGJbIT.js index 4033e1b4..820e3eee 100644 --- a/assets/index-Bn68Ze9l.js +++ b/assets/index-BkIGJbIT.js @@ -1,4 +1,4 @@ -const __vite__fileDeps=["./index-CO4t4qDX.js","./___vite-browser-external_commonjs-proxy-BWPtq7er.js","./index.es-gzdlT0Xp.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]); +const __vite__fileDeps=["./index-KoV3ZGCG.js","./___vite-browser-external_commonjs-proxy-B-cSWyK0.js","./index.es-pmuHIzee.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]); var __defProp = Object.defineProperty; var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value; var __publicField = (obj, key2, value) => { @@ -71826,7 +71826,7 @@ async function call(client2, args) { return { data: response }; } catch (err) { const data2 = getRevertErrorData(err); - const { offchainLookup, offchainLookupSignature } = await __vitePreload(() => import("./ccip-BoUAqsGL.js"), true ? [] : void 0, import.meta.url); + const { offchainLookup, offchainLookupSignature } = await __vitePreload(() => import("./ccip-XVd28I1a.js"), true ? [] : void 0, import.meta.url); if (client2.ccipRead !== false && (data2 == null ? void 0 : data2.slice(0, 10)) === offchainLookupSignature && to) return { data: await offchainLookup(client2, { data: data2, to }) }; throw getCallError(err, { @@ -83047,6 +83047,63 @@ const AppleWaasConnectButton = (props) => { }) : null; }; const getLogo = (theme, walletProps) => theme === "dark" ? walletProps.logoDark || walletProps.monochromeLogoDark : walletProps.logoLight || walletProps.monochromeLogoLight; +const getNetworkColor = (chainId, mode = "light") => { + switch (chainId) { + case ChainId.MAINNET: + return mode === "light" ? "#abf" : "#abf"; + case ChainId.POLYGON: + return mode === "light" ? "#c7a6ff" : "#c7a6ff"; + case ChainId.ARBITRUM: + return mode === "light" ? "#52A7E6" : "#52A7E6"; + case ChainId.OPTIMISM: + return mode === "light" ? "#DB3132" : "#DB3132"; + case ChainId.BSC: + return mode === "light" ? "#CB9C1D" : "#EEB445"; + case ChainId.AVALANCHE: + return mode === "light" ? "#E84142" : "#E84142"; + case ChainId.GNOSIS: + return mode === "light" ? "#00193C" : "#D8E8FF"; + case ChainId.GOERLI: + return mode === "light" ? "#A77A00" : "#FFA700"; + case ChainId.POLYGON_MUMBAI: + case ChainId.POLYGON_AMOY: + return mode === "light" ? "#D68828" : "#FFA700"; + default: + return mode === "light" ? "#abf" : "#abf"; + } +}; +const getNetworkBackgroundColor = (chainId, mode = "light") => { + switch (chainId) { + case ChainId.MAINNET: + return mode === "light" ? "#132362" : "#132362"; + case ChainId.POLYGON: + return mode === "light" ? "#350881" : "#350881"; + case ChainId.ARBITRUM: + return mode === "light" ? "#EDF7FF" : "#0C3754"; + case ChainId.OPTIMISM: + return mode === "light" ? "#FFEAE9" : "#390B0C"; + case ChainId.BSC: + return mode === "light" ? "#FFE8AB" : "#554018"; + case ChainId.AVALANCHE: + return mode === "light" ? "#FBDFDF" : "#390B0C"; + case ChainId.GNOSIS: + return mode === "light" ? "#D8E8FF" : "#00193C"; + case ChainId.GOERLI: + return mode === "light" ? "#FFD871" : "#554018"; + case ChainId.POLYGON_MUMBAI: + case ChainId.POLYGON_AMOY: + return mode === "light" ? "#FFE8CD" : "#554018"; + default: + return mode === "light" ? "#132362" : "#132362"; + } +}; +const getNetwork = (chainId) => { + const network2 = networks[chainId]; + if (!network2) { + throw new Error(`Unknown network chainId: ${chainId}`); + } + return network2; +}; const NetworkBadge$1 = ({ chainId }) => { @@ -83332,6 +83389,19 @@ const SequenceLogo$1 = (_ref) => { width: "396" }))))); }; +function _objectWithoutPropertiesLoose$3(source, excluded) { + if (source == null) + return {}; + var target = {}; + for (var key2 in source) { + if (Object.prototype.hasOwnProperty.call(source, key2)) { + if (excluded.indexOf(key2) >= 0) + continue; + target[key2] = source[key2]; + } + } + return target; +} const useProjectAccessKey = () => { const { projectAccessKey: projectAccessKey2 @@ -83345,6 +83415,299 @@ const useAPIClient = () => { }, [projectAccessKey2]); return apiClient; }; +const useIndexerClient = (chainId) => { + const projectAccessKey2 = useProjectAccessKey(); + const indexerClients = reactExports.useMemo(() => { + return /* @__PURE__ */ new Map(); + }, [projectAccessKey2]); + const network2 = networks[chainId]; + if (!indexerClients.has(chainId)) { + indexerClients.set(chainId, new SequenceIndexer(indexerURL(network2.name), projectAccessKey2)); + } + const indexerClient = indexerClients.get(chainId); + if (!indexerClient) { + throw new Error("Indexer client not found"); + } + return indexerClient; +}; +const useIndexerClients = (chainIds) => { + const projectAccessKey2 = useProjectAccessKey(); + const indexerClients = reactExports.useMemo(() => { + return /* @__PURE__ */ new Map(); + }, [projectAccessKey2]); + const result = /* @__PURE__ */ new Map(); + for (const chainId of chainIds) { + const network2 = networks[chainId]; + if (!indexerClients.has(chainId)) { + indexerClients.set(chainId, new SequenceIndexer(indexerURL(network2.name), projectAccessKey2)); + } + const indexerClient = indexerClients.get(chainId); + if (!indexerClient) { + throw new Error("Indexer client not found"); + } + result.set(chainId, indexerClient); + } + return result; +}; +const useMetadataClient = () => { + const projectAccessKey2 = useProjectAccessKey(); + const metadataClient = reactExports.useMemo(() => { + return new SequenceMetadata("https://metadata.sequence.app", projectAccessKey2); + }, [projectAccessKey2]); + return metadataClient; +}; +const _excluded$1$2 = ["chainIds"]; +const time$1 = { + oneSecond: 1 * 1e3, + oneMinute: 60 * 1e3, + oneHour: 60 * 60 * 1e3 +}; +const getNativeTokenBalance = async (indexerClient, chainId, accountAddress) => { + const res = await indexerClient.getEtherBalance({ + accountAddress + }); + const tokenBalance = { + chainId, + contractAddress: zeroAddress, + accountAddress, + balance: (res == null ? void 0 : res.balance.balanceWei) || "0", + contractType: ContractType$1.UNKNOWN, + blockHash: "", + blockNumber: 0, + tokenID: "" + }; + return tokenBalance; +}; +const getTokenBalances = async (indexerClient, args) => { + var _args$includeMetadata, _args$verifiedOnly; + const res = await indexerClient.getTokenBalances(_extends$5({ + accountAddress: args.accountAddress, + includeMetadata: (_args$includeMetadata = args.includeMetadata) != null ? _args$includeMetadata : true, + metadataOptions: { + verifiedOnly: (_args$verifiedOnly = args.verifiedOnly) != null ? _args$verifiedOnly : true + } + }, args.contractAddress && { + contractAddress: args.contractAddress + })); + return (res == null ? void 0 : res.balances) || []; +}; +const getBalances = async (indexerClient, chainId, args) => { + if (!args.accountAddress) { + return []; + } + const balances = (await Promise.allSettled([getNativeTokenBalance(indexerClient, chainId, args.accountAddress), getTokenBalances(indexerClient, args)])).map((res) => res.status === "fulfilled" ? res.value : []).flat(); + return balances; +}; +const useBalances = (_ref) => { + let { + chainIds + } = _ref, args = _objectWithoutPropertiesLoose$3(_ref, _excluded$1$2); + const indexerClients = useIndexerClients(chainIds); + return useQuery$1({ + queryKey: ["balances", chainIds, args], + queryFn: async () => { + const res = (await Promise.all(Array.from(indexerClients.entries()).map(([chainId, indexerClient]) => getBalances(indexerClient, chainId, args)))).flat(); + return res; + }, + retry: true, + staleTime: time$1.oneSecond * 30, + enabled: chainIds.length > 0 && !!args.accountAddress + }); +}; +const useCoinBalance = (args) => { + const indexerClient = useIndexerClient(args.chainId); + return useQuery$1({ + queryKey: ["coinBalance", args], + queryFn: async () => { + if (compareAddress$2((args == null ? void 0 : args.contractAddress) || "", zeroAddress)) { + const res = await getNativeTokenBalance(indexerClient, args.chainId, args.accountAddress); + return res; + } else { + const res = await getTokenBalances(indexerClient, args); + return res[0]; + } + }, + retry: true, + staleTime: time$1.oneSecond * 30, + enabled: !!args.chainId && !!args.accountAddress + }); +}; +const useCollectibleBalance = (args) => { + const indexerClient = useIndexerClient(args.chainId); + return useQuery$1({ + queryKey: ["collectibleBalance", args], + queryFn: async () => { + var _args$verifiedOnly2; + const res = await indexerClient.getTokenBalances({ + accountAddress: args.accountAddress, + contractAddress: args.contractAddress, + tokenID: args.tokenId, + includeMetadata: true, + metadataOptions: { + verifiedOnly: (_args$verifiedOnly2 = args.verifiedOnly) != null ? _args$verifiedOnly2 : true + } + }); + return res.balances[0]; + }, + retry: true, + staleTime: time$1.oneSecond * 30, + enabled: !!args.chainId && !!args.accountAddress && !!args.contractAddress && !!args.tokenId + }); +}; +const getCollectionBalance = async (indexerClient, args) => { + var _args$includeMetadata2, _args$verifiedOnly3; + const res = await indexerClient.getTokenBalances({ + accountAddress: args.accountAddress, + contractAddress: args.contractAddress, + includeMetadata: (_args$includeMetadata2 = args.includeMetadata) != null ? _args$includeMetadata2 : true, + metadataOptions: { + verifiedOnly: (_args$verifiedOnly3 = args.verifiedOnly) != null ? _args$verifiedOnly3 : true + } + }); + return (res == null ? void 0 : res.balances) || []; +}; +const useCollectionBalance = (args) => { + const indexerClient = useIndexerClient(args.chainId); + return useQuery$1({ + queryKey: ["collectionBalance", args], + queryFn: () => getCollectionBalance(indexerClient, args), + retry: true, + staleTime: time$1.oneSecond * 30, + enabled: !!args.chainId && !!args.accountAddress && !!args.contractAddress + }); +}; +const useExchangeRate = (toCurrency) => { + const apiClient = useAPIClient(); + return useQuery$1({ + queryKey: ["exchangeRate", toCurrency], + queryFn: async () => { + if (toCurrency === "USD") { + return 1; + } + const res = await apiClient.getExchangeRate({ + toCurrency + }); + return res.exchangeRate.value; + }, + retry: true, + staleTime: time$1.oneMinute * 10 + }); +}; +const getCoinPrices = async (apiClient, tokens) => { + if (tokens.length === 0) { + return []; + } + const res = await apiClient.getCoinPrices({ + tokens + }); + return (res == null ? void 0 : res.tokenPrices) || []; +}; +const useCoinPrices = (tokens) => { + const apiClient = useAPIClient(); + return useQuery$1({ + queryKey: ["coinPrices", tokens], + queryFn: () => getCoinPrices(apiClient, tokens), + retry: true, + staleTime: time$1.oneMinute, + enabled: tokens.length > 0 + }); +}; +const getCollectiblePrices = async (apiClient, tokens) => { + if (tokens.length === 0) { + return []; + } + const res = await apiClient.getCollectiblePrices({ + tokens + }); + return (res == null ? void 0 : res.tokenPrices) || []; +}; +const useCollectiblePrices = (tokens) => { + const apiClient = useAPIClient(); + return useQuery$1({ + queryKey: ["useCollectiblePrices", tokens], + queryFn: () => getCollectiblePrices(apiClient, tokens), + retry: true, + staleTime: time$1.oneMinute, + enabled: tokens.length > 0 + }); +}; +const useTokenMetadata = (chainId, contractAddress, tokenIds) => { + const metadataClient = useMetadataClient(); + return useQuery$1({ + queryKey: ["tokenMetadata", chainId, contractAddress, tokenIds], + queryFn: async () => { + const res = await metadataClient.getTokenMetadata({ + chainID: String(chainId), + contractAddress, + tokenIDs: tokenIds + }); + return res.tokenMetadata; + }, + retry: true, + staleTime: time$1.oneMinute * 10, + enabled: !!chainId && !!contractAddress + }); +}; +const useContractInfo = (chainId, contractAddress) => { + const metadataClient = useMetadataClient(); + return useQuery$1({ + queryKey: ["contractInfo", chainId, contractAddress], + queryFn: async () => { + const res = await metadataClient.getContractInfo({ + chainID: String(chainId), + contractAddress + }); + return res.contractInfo; + }, + retry: true, + staleTime: time$1.oneMinute * 10, + enabled: !!chainId && !!contractAddress + }); +}; +const getTransactionHistory = async (indexerClient, { + contractAddress, + accountAddress, + tokenId, + page +}) => { + const res = indexerClient.getTransactionHistory({ + includeMetadata: true, + page, + filter: { + accountAddress, + contractAddress, + tokenID: tokenId + } + }); + return res; +}; +const useTransactionHistory = (args) => { + const indexerClient = useIndexerClient(args.chainId); + return useInfiniteQuery({ + queryKey: ["transactionHistory", args], + queryFn: ({ + pageParam + }) => { + return getTransactionHistory(indexerClient, _extends$5({}, args, { + page: { + page: pageParam + } + })); + }, + getNextPageParam: ({ + page + }) => { + if (!page.more) { + return void 0; + } + return (page == null ? void 0 : page.page) || 1; + }, + initialPageParam: 1, + retry: true, + staleTime: time$1.oneSecond * 30, + enabled: !!args.chainId && !!args.accountAddress + }); +}; const nativeTokenInfos = { [ChainId.MAINNET]: { name: "Ethereum", @@ -84343,26 +84706,13 @@ const KitProvider = (props) => { marginTop: "1" }, /* @__PURE__ */ React.createElement(SequenceLogo$1, null)))))))), children)))))); }; -function _objectWithoutPropertiesLoose$3(source, excluded) { - if (source == null) - return {}; - var target = {}; - for (var key2 in source) { - if (Object.prototype.hasOwnProperty.call(source, key2)) { - if (excluded.indexOf(key2) >= 0) - continue; - target[key2] = source[key2]; - } - } - return target; -} -const _excluded$1$2 = ["createConnector"]; +const _excluded$5 = ["createConnector"]; const getKitConnectWallets = (projectAccessKey2, wallets) => { const connectors = []; wallets.forEach((wallet) => { const { createConnector: createConnector2 - } = wallet, metaProperties = _objectWithoutPropertiesLoose$3(wallet, _excluded$1$2); + } = wallet, metaProperties = _objectWithoutPropertiesLoose$3(wallet, _excluded$5); const walletProperties = _extends$5({}, metaProperties); const createConnectorOverride = (config2) => { const connector = createConnector2(projectAccessKey2); @@ -84374,63 +84724,6 @@ const getKitConnectWallets = (projectAccessKey2, wallets) => { }); return connectors; }; -const getNetworkColor = (chainId, mode = "light") => { - switch (chainId) { - case ChainId.MAINNET: - return mode === "light" ? "#abf" : "#abf"; - case ChainId.POLYGON: - return mode === "light" ? "#c7a6ff" : "#c7a6ff"; - case ChainId.ARBITRUM: - return mode === "light" ? "#52A7E6" : "#52A7E6"; - case ChainId.OPTIMISM: - return mode === "light" ? "#DB3132" : "#DB3132"; - case ChainId.BSC: - return mode === "light" ? "#CB9C1D" : "#EEB445"; - case ChainId.AVALANCHE: - return mode === "light" ? "#E84142" : "#E84142"; - case ChainId.GNOSIS: - return mode === "light" ? "#00193C" : "#D8E8FF"; - case ChainId.GOERLI: - return mode === "light" ? "#A77A00" : "#FFA700"; - case ChainId.POLYGON_MUMBAI: - case ChainId.POLYGON_AMOY: - return mode === "light" ? "#D68828" : "#FFA700"; - default: - return mode === "light" ? "#abf" : "#abf"; - } -}; -const getNetworkBackgroundColor = (chainId, mode = "light") => { - switch (chainId) { - case ChainId.MAINNET: - return mode === "light" ? "#132362" : "#132362"; - case ChainId.POLYGON: - return mode === "light" ? "#350881" : "#350881"; - case ChainId.ARBITRUM: - return mode === "light" ? "#EDF7FF" : "#0C3754"; - case ChainId.OPTIMISM: - return mode === "light" ? "#FFEAE9" : "#390B0C"; - case ChainId.BSC: - return mode === "light" ? "#FFE8AB" : "#554018"; - case ChainId.AVALANCHE: - return mode === "light" ? "#FBDFDF" : "#390B0C"; - case ChainId.GNOSIS: - return mode === "light" ? "#D8E8FF" : "#00193C"; - case ChainId.GOERLI: - return mode === "light" ? "#FFD871" : "#554018"; - case ChainId.POLYGON_MUMBAI: - case ChainId.POLYGON_AMOY: - return mode === "light" ? "#FFE8CD" : "#554018"; - default: - return mode === "light" ? "#132362" : "#132362"; - } -}; -const getNetwork = (chainId) => { - const network2 = networks[chainId]; - if (!network2) { - throw new Error(`Unknown network chainId: ${chainId}`); - } - return network2; -}; function walletClientToSigner(walletClient) { var _chain$contracts; const { @@ -84534,299 +84827,6 @@ const useWalletSettings = () => { setDisplayedAssets }; }; -const useMetadataClient = () => { - const projectAccessKey2 = useProjectAccessKey(); - const metadataClient = reactExports.useMemo(() => { - return new SequenceMetadata("https://metadata.sequence.app", projectAccessKey2); - }, [projectAccessKey2]); - return metadataClient; -}; -const useIndexerClient = (chainId) => { - const projectAccessKey2 = useProjectAccessKey(); - const indexerClients = reactExports.useMemo(() => { - return /* @__PURE__ */ new Map(); - }, [projectAccessKey2]); - const network2 = networks[chainId]; - if (!indexerClients.has(chainId)) { - indexerClients.set(chainId, new SequenceIndexer(indexerURL(network2.name), projectAccessKey2)); - } - const indexerClient = indexerClients.get(chainId); - if (!indexerClient) { - throw new Error("Indexer client not found"); - } - return indexerClient; -}; -const useIndexerClients = (chainIds) => { - const projectAccessKey2 = useProjectAccessKey(); - const indexerClients = reactExports.useMemo(() => { - return /* @__PURE__ */ new Map(); - }, [projectAccessKey2]); - const result = /* @__PURE__ */ new Map(); - for (const chainId of chainIds) { - const network2 = networks[chainId]; - if (!indexerClients.has(chainId)) { - indexerClients.set(chainId, new SequenceIndexer(indexerURL(network2.name), projectAccessKey2)); - } - const indexerClient = indexerClients.get(chainId); - if (!indexerClient) { - throw new Error("Indexer client not found"); - } - result.set(chainId, indexerClient); - } - return result; -}; -const _excluded$5 = ["chainIds"]; -const time$1 = { - oneSecond: 1 * 1e3, - oneMinute: 60 * 1e3, - oneHour: 60 * 60 * 1e3 -}; -const getNativeTokenBalance = async (indexerClient, chainId, accountAddress) => { - const res = await indexerClient.getEtherBalance({ - accountAddress - }); - const tokenBalance = { - chainId, - contractAddress: zeroAddress, - accountAddress, - balance: (res == null ? void 0 : res.balance.balanceWei) || "0", - contractType: ContractType$1.UNKNOWN, - blockHash: "", - blockNumber: 0, - tokenID: "" - }; - return tokenBalance; -}; -const getTokenBalances = async (indexerClient, args) => { - var _args$includeMetadata, _args$verifiedOnly; - const res = await indexerClient.getTokenBalances(_extends$5({ - accountAddress: args.accountAddress, - includeMetadata: (_args$includeMetadata = args.includeMetadata) != null ? _args$includeMetadata : true, - metadataOptions: { - verifiedOnly: (_args$verifiedOnly = args.verifiedOnly) != null ? _args$verifiedOnly : true - } - }, args.contractAddress && { - contractAddress: args.contractAddress - })); - return (res == null ? void 0 : res.balances) || []; -}; -const getBalances = async (indexerClient, chainId, args) => { - if (!args.accountAddress) { - return []; - } - const balances = (await Promise.allSettled([getNativeTokenBalance(indexerClient, chainId, args.accountAddress), getTokenBalances(indexerClient, args)])).map((res) => res.status === "fulfilled" ? res.value : []).flat(); - return balances; -}; -const useBalances = (_ref) => { - let { - chainIds - } = _ref, args = _objectWithoutPropertiesLoose$3(_ref, _excluded$5); - const indexerClients = useIndexerClients(chainIds); - return useQuery$1({ - queryKey: ["balances", chainIds, args], - queryFn: async () => { - const res = (await Promise.all(Array.from(indexerClients.entries()).map(([chainId, indexerClient]) => getBalances(indexerClient, chainId, args)))).flat(); - return res; - }, - retry: true, - staleTime: time$1.oneSecond * 30, - enabled: chainIds.length > 0 && !!args.accountAddress - }); -}; -const useCoinBalance = (args) => { - const indexerClient = useIndexerClient(args.chainId); - return useQuery$1({ - queryKey: ["coinBalance", args], - queryFn: async () => { - if (compareAddress$2((args == null ? void 0 : args.contractAddress) || "", zeroAddress)) { - const res = await getNativeTokenBalance(indexerClient, args.chainId, args.accountAddress); - return res; - } else { - const res = await getTokenBalances(indexerClient, args); - return res[0]; - } - }, - retry: true, - staleTime: time$1.oneSecond * 30, - enabled: !!args.chainId && !!args.accountAddress - }); -}; -const useCollectibleBalance = (args) => { - const indexerClient = useIndexerClient(args.chainId); - return useQuery$1({ - queryKey: ["collectibleBalance", args], - queryFn: async () => { - var _args$verifiedOnly2; - const res = await indexerClient.getTokenBalances({ - accountAddress: args.accountAddress, - contractAddress: args.contractAddress, - tokenID: args.tokenId, - includeMetadata: true, - metadataOptions: { - verifiedOnly: (_args$verifiedOnly2 = args.verifiedOnly) != null ? _args$verifiedOnly2 : true - } - }); - return res.balances[0]; - }, - retry: true, - staleTime: time$1.oneSecond * 30, - enabled: !!args.chainId && !!args.accountAddress && !!args.contractAddress && !!args.tokenId - }); -}; -const getCollectionBalance = async (indexerClient, args) => { - var _args$includeMetadata2, _args$verifiedOnly3; - const res = await indexerClient.getTokenBalances({ - accountAddress: args.accountAddress, - contractAddress: args.contractAddress, - includeMetadata: (_args$includeMetadata2 = args.includeMetadata) != null ? _args$includeMetadata2 : true, - metadataOptions: { - verifiedOnly: (_args$verifiedOnly3 = args.verifiedOnly) != null ? _args$verifiedOnly3 : true - } - }); - return (res == null ? void 0 : res.balances) || []; -}; -const useCollectionBalance = (args) => { - const indexerClient = useIndexerClient(args.chainId); - return useQuery$1({ - queryKey: ["collectionBalance", args], - queryFn: () => getCollectionBalance(indexerClient, args), - retry: true, - staleTime: time$1.oneSecond * 30, - enabled: !!args.chainId && !!args.accountAddress && !!args.contractAddress - }); -}; -const useExchangeRate = (toCurrency) => { - const apiClient = useAPIClient(); - return useQuery$1({ - queryKey: ["exchangeRate", toCurrency], - queryFn: async () => { - if (toCurrency === "USD") { - return 1; - } - const res = await apiClient.getExchangeRate({ - toCurrency - }); - return res.exchangeRate.value; - }, - retry: true, - staleTime: time$1.oneMinute * 10 - }); -}; -const getCoinPrices = async (apiClient, tokens) => { - if (tokens.length === 0) { - return []; - } - const res = await apiClient.getCoinPrices({ - tokens - }); - return (res == null ? void 0 : res.tokenPrices) || []; -}; -const useCoinPrices = (tokens) => { - const apiClient = useAPIClient(); - return useQuery$1({ - queryKey: ["coinPrices", tokens], - queryFn: () => getCoinPrices(apiClient, tokens), - retry: true, - staleTime: time$1.oneMinute, - enabled: tokens.length > 0 - }); -}; -const getCollectiblePrices = async (apiClient, tokens) => { - if (tokens.length === 0) { - return []; - } - const res = await apiClient.getCollectiblePrices({ - tokens - }); - return (res == null ? void 0 : res.tokenPrices) || []; -}; -const useCollectiblePrices = (tokens) => { - const apiClient = useAPIClient(); - return useQuery$1({ - queryKey: ["useCollectiblePrices", tokens], - queryFn: () => getCollectiblePrices(apiClient, tokens), - retry: true, - staleTime: time$1.oneMinute, - enabled: tokens.length > 0 - }); -}; -const useTokenMetadata = (chainId, contractAddress, tokenIds) => { - const metadataClient = useMetadataClient(); - return useQuery$1({ - queryKey: ["tokenMetadata", chainId, contractAddress, tokenIds], - queryFn: async () => { - const res = await metadataClient.getTokenMetadata({ - chainID: String(chainId), - contractAddress, - tokenIDs: tokenIds - }); - return res.tokenMetadata; - }, - retry: true, - staleTime: time$1.oneMinute * 10, - enabled: !!chainId && !!contractAddress - }); -}; -const useContractInfo = (chainId, contractAddress) => { - const metadataClient = useMetadataClient(); - return useQuery$1({ - queryKey: ["contractInfo", chainId, contractAddress], - queryFn: async () => { - const res = await metadataClient.getContractInfo({ - chainID: String(chainId), - contractAddress - }); - return res.contractInfo; - }, - retry: true, - staleTime: time$1.oneMinute * 10, - enabled: !!chainId && !!contractAddress - }); -}; -const getTransactionHistory = async (indexerClient, { - contractAddress, - accountAddress, - tokenId, - page -}) => { - const res = indexerClient.getTransactionHistory({ - includeMetadata: true, - page, - filter: { - accountAddress, - contractAddress, - tokenID: tokenId - } - }); - return res; -}; -const useTransactionHistory = (args) => { - const indexerClient = useIndexerClient(args.chainId); - return useInfiniteQuery({ - queryKey: ["transactionHistory", args], - queryFn: ({ - pageParam - }) => { - return getTransactionHistory(indexerClient, _extends$5({}, args, { - page: { - page: pageParam - } - })); - }, - getNextPageParam: ({ - page - }) => { - if (!page.more) { - return void 0; - } - return (page == null ? void 0 : page.page) || 1; - }, - initialPageParam: 1, - retry: true, - staleTime: time$1.oneSecond * 30, - enabled: !!args.chainId && !!args.accountAddress - }); -}; function _extends$4() { _extends$4 = Object.assign ? Object.assign.bind() : function(target) { for (var i2 = 1; i2 < arguments.length; i2++) { @@ -108041,7 +108041,7 @@ function coinbaseWallet$1(parameters) { async getProvider() { var _a2; if (!walletProvider) { - const { default: CoinbaseWalletSDK } = await __vitePreload(() => import("./index-CO4t4qDX.js").then((n2) => n2.i), true ? __vite__mapDeps([0,1]) : void 0, import.meta.url); + const { default: CoinbaseWalletSDK } = await __vitePreload(() => import("./index-KoV3ZGCG.js").then((n2) => n2.i), true ? __vite__mapDeps([0,1]) : void 0, import.meta.url); let SDK; if (typeof CoinbaseWalletSDK !== "function" && typeof CoinbaseWalletSDK.default === "function") SDK = CoinbaseWalletSDK.default; @@ -108227,7 +108227,7 @@ function walletConnect$1(parameters) { const optionalChains = config2.chains.map((x) => x.id); if (!optionalChains.length) return; - const { EthereumProvider } = await __vitePreload(() => import("./index.es-gzdlT0Xp.js"), true ? __vite__mapDeps([2,1]) : void 0, import.meta.url); + const { EthereumProvider } = await __vitePreload(() => import("./index.es-pmuHIzee.js"), true ? __vite__mapDeps([2,1]) : void 0, import.meta.url); return await EthereumProvider.init({ ...parameters, disableProviderPing: true, diff --git a/assets/index-Dw77FWPI.js b/assets/index-DIUle0En.js similarity index 99% rename from assets/index-Dw77FWPI.js rename to assets/index-DIUle0En.js index 44e7d443..074a9a9f 100644 --- a/assets/index-Dw77FWPI.js +++ b/assets/index-DIUle0En.js @@ -1,5 +1,5 @@ -const __vite__fileDeps=["./index-CMU5YblP.js","./index-Bn68Ze9l.js","./index-Dso1Hl_w.css"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]); -import { _ as __vitePreload } from "./index-Bn68Ze9l.js"; +const __vite__fileDeps=["./index-Bf2oTxTI.js","./index-BkIGJbIT.js","./index-Dso1Hl_w.css"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]); +import { _ as __vitePreload } from "./index-BkIGJbIT.js"; const t = Symbol(); const s = Object.getPrototypeOf, c$1 = /* @__PURE__ */ new WeakMap(), l = (e) => e && (c$1.has(e) ? c$1.get(e) : s(e) === Object.prototype || s(e) === Array.prototype), y$1 = (e) => l(e) && e[t] || null, h = (e, t2 = true) => { c$1.set(e, t2); @@ -487,7 +487,7 @@ class d { } async initUi() { if (typeof window < "u") { - await __vitePreload(() => import("./index-CMU5YblP.js"), true ? __vite__mapDeps([0,1,2]) : void 0, import.meta.url); + await __vitePreload(() => import("./index-Bf2oTxTI.js"), true ? __vite__mapDeps([0,1,2]) : void 0, import.meta.url); const e = document.createElement("wcm-modal"); document.body.insertAdjacentElement("beforeend", e), p.setIsUiLoaded(true); } diff --git a/assets/index-CO4t4qDX.js b/assets/index-KoV3ZGCG.js similarity index 99% rename from assets/index-CO4t4qDX.js rename to assets/index-KoV3ZGCG.js index a0a65de0..e2ca5237 100644 --- a/assets/index-CO4t4qDX.js +++ b/assets/index-KoV3ZGCG.js @@ -1,5 +1,5 @@ -import { c as commonjsGlobal, d as bnExports, B as Buffer$7, e as require$$2$1, i as inherits_browserExports, a as getAugmentedNamespace, p as process$1, t as tslib_es6, f as eventemitter3Exports, b as getDefaultExportFromCjs } from "./index-Bn68Ze9l.js"; -import { e as eventsExports, r as require$$1$2 } from "./___vite-browser-external_commonjs-proxy-BWPtq7er.js"; +import { c as commonjsGlobal, d as bnExports, B as Buffer$7, e as require$$2$1, i as inherits_browserExports, a as getAugmentedNamespace, p as process$1, t as tslib_es6, f as eventemitter3Exports, b as getDefaultExportFromCjs } from "./index-BkIGJbIT.js"; +import { e as eventsExports, r as require$$1$2 } from "./___vite-browser-external_commonjs-proxy-B-cSWyK0.js"; function _mergeNamespaces(n2, m2) { for (var i = 0; i < m2.length; i++) { const e2 = m2[i]; diff --git a/assets/index.es-gzdlT0Xp.js b/assets/index.es-pmuHIzee.js similarity index 99% rename from assets/index.es-gzdlT0Xp.js rename to assets/index.es-pmuHIzee.js index 5fd8d656..ca4a072a 100644 --- a/assets/index.es-gzdlT0Xp.js +++ b/assets/index.es-pmuHIzee.js @@ -1,6 +1,6 @@ -const __vite__fileDeps=["./index-Dw77FWPI.js","./index-Bn68Ze9l.js","./index-Dso1Hl_w.css"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]); -import { p as process$1, r as require$$0$2, g as global, B as Buffer, a as getAugmentedNamespace, b as getDefaultExportFromCjs, c as commonjsGlobal, _ as __vitePreload } from "./index-Bn68Ze9l.js"; -import { r as require$$1, e as eventsExports, U as Ug } from "./___vite-browser-external_commonjs-proxy-BWPtq7er.js"; +const __vite__fileDeps=["./index-DIUle0En.js","./index-BkIGJbIT.js","./index-Dso1Hl_w.css"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]); +import { p as process$1, r as require$$0$2, g as global, B as Buffer, a as getAugmentedNamespace, b as getDefaultExportFromCjs, c as commonjsGlobal, _ as __vitePreload } from "./index-BkIGJbIT.js"; +import { r as require$$1, e as eventsExports, U as Ug } from "./___vite-browser-external_commonjs-proxy-B-cSWyK0.js"; var chacha20poly1305 = {}; var chacha = {}; var binary = {}; @@ -15731,7 +15731,7 @@ class v2 { if (this.rpc = this.getRpcConfig(t), this.chainId = this.rpc.chains.length ? g2(this.rpc.chains) : g2(this.rpc.optionalChains), this.signer = await hv.init({ projectId: this.rpc.projectId, metadata: this.rpc.metadata, disableProviderPing: t.disableProviderPing, relayUrl: t.relayUrl, storageOptions: t.storageOptions }), this.registerEventListeners(), await this.loadPersistedSession(), this.rpc.showQrModal) { let s; try { - const { WalletConnectModal: i2 } = await __vitePreload(() => import("./index-Dw77FWPI.js").then((n3) => n3.i), true ? __vite__mapDeps([0,1,2]) : void 0, import.meta.url); + const { WalletConnectModal: i2 } = await __vitePreload(() => import("./index-DIUle0En.js").then((n3) => n3.i), true ? __vite__mapDeps([0,1,2]) : void 0, import.meta.url); s = i2; } catch { throw new Error("To use QR modal, please install @walletconnect/modal package"); diff --git a/index.html b/index.html index 9fc45c89..43d32bb2 100644 --- a/index.html +++ b/index.html @@ -24,7 +24,7 @@ Learn how to configure a non-root public URL by running `npm run build`. --> Sequence Kit Demo - +