@matchain/matchid-sdk-react 0.1.26 → 0.1.28

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/index.mjs CHANGED
@@ -996,12 +996,6 @@ function firstUpperCase(str) {
996
996
 
997
997
  // src/store/useModalStore.ts
998
998
  import { create as create2 } from "zustand";
999
- var useEVMModalStore = create2((set) => ({
1000
- isOpen: false,
1001
- type: "",
1002
- open: (type) => set({ isOpen: true, type }),
1003
- close: () => set({ isOpen: false })
1004
- }));
1005
999
  var useSOLModalStore = create2((set) => ({
1006
1000
  isOpen: false,
1007
1001
  type: "",
@@ -1023,7 +1017,6 @@ function useUserInfo() {
1023
1017
  endpoints
1024
1018
  } = useLocalStore_default();
1025
1019
  const { events, login } = useMatch();
1026
- const { open: EVMOpen } = useEVMModalStore();
1027
1020
  const { open: SOLOpen } = useSOLModalStore();
1028
1021
  const isLogin = useMemo(() => !!token, [token]);
1029
1022
  const logout = async () => {
@@ -1053,7 +1046,7 @@ function useUserInfo() {
1053
1046
  return loginByMethod("google");
1054
1047
  };
1055
1048
  const loginByWallet = async () => {
1056
- return EVMOpen("login");
1049
+ return window.open(`${endpoints.auth}login/wallet?appid=${appid}`);
1057
1050
  };
1058
1051
  const loginByTelegram = async () => {
1059
1052
  return window.open(
@@ -1066,7 +1059,7 @@ function useUserInfo() {
1066
1059
  const loginMethod = async (method) => {
1067
1060
  switch (method) {
1068
1061
  case "evm":
1069
- return EVMOpen("login");
1062
+ return window.open(`${endpoints.auth}login/wallet?appid=${appid}`);
1070
1063
  case "sol":
1071
1064
  return SOLOpen("login");
1072
1065
  case "telegram":
@@ -1126,7 +1119,7 @@ function useUserInfo() {
1126
1119
  if (!token) {
1127
1120
  throw new Error("You must login first");
1128
1121
  }
1129
- return EVMOpen("bind");
1122
+ return window.open(`${endpoints.auth}bind/wallet?appid=${appid}&st=` + encodeURIComponent(encodeBase64(token)));
1130
1123
  };
1131
1124
  const bindTelegram = async () => {
1132
1125
  if (!token) {
@@ -1152,7 +1145,7 @@ function useUserInfo() {
1152
1145
  }
1153
1146
  switch (method) {
1154
1147
  case "evm":
1155
- return EVMOpen("bind");
1148
+ return window.open(`${endpoints.auth}bind/wallet?appid=${appid}&st=` + encodeURIComponent(encodeBase64(token)));
1156
1149
  case "sol":
1157
1150
  return SOLOpen("bind");
1158
1151
  case "telegram":
@@ -1162,6 +1155,7 @@ function useUserInfo() {
1162
1155
  case "discord":
1163
1156
  case "github":
1164
1157
  case "linkedin":
1158
+ case "facebook":
1165
1159
  const link = `${endpoints.back}api/v1/auth/${method}?appid=${appid}&provider=${method}&redirect=${encodeURIComponent(endpoints.auth + "bind/" + method)}&authorization=${token.includes("Bearer ") ? token.split(" ")[1] : token}`;
1166
1160
  matchlog_default.log("link", link);
1167
1161
  return window.open(
@@ -1543,243 +1537,13 @@ function RecoveryModal({
1543
1537
  ] }) });
1544
1538
  }
1545
1539
 
1546
- // src/components/EVMModal/index.tsx
1547
- import { getDefaultConfig, RainbowKitProvider, useConnectModal } from "@rainbow-me/rainbowkit";
1548
- import { useAccount, useAccountEffect, useChainId, useConfig, useDisconnect, WagmiProvider } from "wagmi";
1549
- import {
1550
- bitgetWallet,
1551
- injectedWallet,
1552
- metaMaskWallet,
1553
- okxWallet,
1554
- walletConnectWallet
1555
- } from "@rainbow-me/rainbowkit/wallets";
1556
- import { bsc } from "wagmi/chains";
1557
-
1558
- // src/hooks/useEthersSigner.ts
1559
- import * as React from "react";
1560
- import { useWalletClient } from "wagmi";
1561
- import { providers } from "ethers";
1562
-
1563
- // node_modules/@wagmi/core/dist/esm/version.js
1564
- var version = "2.16.3";
1565
-
1566
- // node_modules/@wagmi/core/dist/esm/utils/getVersion.js
1567
- var getVersion2 = () => `@wagmi/core@${version}`;
1568
-
1569
- // node_modules/@wagmi/core/dist/esm/errors/base.js
1570
- var __classPrivateFieldGet = function(receiver, state, kind, f) {
1571
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1572
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1573
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1574
- };
1575
- var _BaseError_instances;
1576
- var _BaseError_walk;
1577
- var BaseError = class _BaseError extends Error {
1578
- get docsBaseUrl() {
1579
- return "https://wagmi.sh/core";
1580
- }
1581
- get version() {
1582
- return getVersion2();
1583
- }
1584
- constructor(shortMessage, options = {}) {
1585
- super();
1586
- _BaseError_instances.add(this);
1587
- Object.defineProperty(this, "details", {
1588
- enumerable: true,
1589
- configurable: true,
1590
- writable: true,
1591
- value: void 0
1592
- });
1593
- Object.defineProperty(this, "docsPath", {
1594
- enumerable: true,
1595
- configurable: true,
1596
- writable: true,
1597
- value: void 0
1598
- });
1599
- Object.defineProperty(this, "metaMessages", {
1600
- enumerable: true,
1601
- configurable: true,
1602
- writable: true,
1603
- value: void 0
1604
- });
1605
- Object.defineProperty(this, "shortMessage", {
1606
- enumerable: true,
1607
- configurable: true,
1608
- writable: true,
1609
- value: void 0
1610
- });
1611
- Object.defineProperty(this, "name", {
1612
- enumerable: true,
1613
- configurable: true,
1614
- writable: true,
1615
- value: "WagmiCoreError"
1616
- });
1617
- const details = options.cause instanceof _BaseError ? options.cause.details : options.cause?.message ? options.cause.message : options.details;
1618
- const docsPath = options.cause instanceof _BaseError ? options.cause.docsPath || options.docsPath : options.docsPath;
1619
- this.message = [
1620
- shortMessage || "An error occurred.",
1621
- "",
1622
- ...options.metaMessages ? [...options.metaMessages, ""] : [],
1623
- ...docsPath ? [
1624
- `Docs: ${this.docsBaseUrl}${docsPath}.html${options.docsSlug ? `#${options.docsSlug}` : ""}`
1625
- ] : [],
1626
- ...details ? [`Details: ${details}`] : [],
1627
- `Version: ${this.version}`
1628
- ].join("\n");
1629
- if (options.cause)
1630
- this.cause = options.cause;
1631
- this.details = details;
1632
- this.docsPath = docsPath;
1633
- this.metaMessages = options.metaMessages;
1634
- this.shortMessage = shortMessage;
1635
- }
1636
- walk(fn) {
1637
- return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk).call(this, this, fn);
1638
- }
1639
- };
1640
- _BaseError_instances = /* @__PURE__ */ new WeakSet(), _BaseError_walk = function _BaseError_walk2(err, fn) {
1641
- if (fn?.(err))
1642
- return err;
1643
- if (err.cause)
1644
- return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk2).call(this, err.cause, fn);
1645
- return err;
1646
- };
1647
-
1648
- // node_modules/@wagmi/core/dist/esm/errors/config.js
1649
- var ConnectorNotConnectedError = class extends BaseError {
1650
- constructor() {
1651
- super("Connector not connected.");
1652
- Object.defineProperty(this, "name", {
1653
- enumerable: true,
1654
- configurable: true,
1655
- writable: true,
1656
- value: "ConnectorNotConnectedError"
1657
- });
1658
- }
1659
- };
1660
- var ConnectorAccountNotFoundError = class extends BaseError {
1661
- constructor({ address, connector }) {
1662
- super(`Account "${address}" not found for connector "${connector.name}".`);
1663
- Object.defineProperty(this, "name", {
1664
- enumerable: true,
1665
- configurable: true,
1666
- writable: true,
1667
- value: "ConnectorAccountNotFoundError"
1668
- });
1669
- }
1670
- };
1671
- var ConnectorChainMismatchError = class extends BaseError {
1672
- constructor({ connectionChainId, connectorChainId }) {
1673
- super(`The current chain of the connector (id: ${connectorChainId}) does not match the connection's chain (id: ${connectionChainId}).`, {
1674
- metaMessages: [
1675
- `Current Chain ID: ${connectorChainId}`,
1676
- `Expected Chain ID: ${connectionChainId}`
1677
- ]
1678
- });
1679
- Object.defineProperty(this, "name", {
1680
- enumerable: true,
1681
- configurable: true,
1682
- writable: true,
1683
- value: "ConnectorChainMismatchError"
1684
- });
1685
- }
1686
- };
1687
- var ConnectorUnavailableReconnectingError = class extends BaseError {
1688
- constructor({ connector }) {
1689
- super(`Connector "${connector.name}" unavailable while reconnecting.`, {
1690
- details: [
1691
- "During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.",
1692
- "All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.",
1693
- "This error commonly occurs for connectors that asynchronously inject after reconnection has already started."
1694
- ].join(" ")
1695
- });
1696
- Object.defineProperty(this, "name", {
1697
- enumerable: true,
1698
- configurable: true,
1699
- writable: true,
1700
- value: "ConnectorUnavailableReconnectingError"
1701
- });
1702
- }
1703
- };
1704
-
1705
- // node_modules/@wagmi/core/dist/esm/actions/getConnectorClient.js
1706
- import { createClient, custom } from "viem";
1707
- import { getAddress, parseAccount } from "viem/utils";
1708
- async function getConnectorClient(config, parameters = {}) {
1709
- let connection;
1710
- if (parameters.connector) {
1711
- const { connector: connector2 } = parameters;
1712
- if (config.state.status === "reconnecting" && !connector2.getAccounts && !connector2.getChainId)
1713
- throw new ConnectorUnavailableReconnectingError({ connector: connector2 });
1714
- const [accounts, chainId2] = await Promise.all([
1715
- connector2.getAccounts(),
1716
- connector2.getChainId()
1717
- ]);
1718
- connection = {
1719
- accounts,
1720
- chainId: chainId2,
1721
- connector: connector2
1722
- };
1723
- } else
1724
- connection = config.state.connections.get(config.state.current);
1725
- if (!connection)
1726
- throw new ConnectorNotConnectedError();
1727
- const chainId = parameters.chainId ?? connection.chainId;
1728
- const connectorChainId = await connection.connector.getChainId();
1729
- if (connectorChainId !== connection.chainId)
1730
- throw new ConnectorChainMismatchError({
1731
- connectionChainId: connection.chainId,
1732
- connectorChainId
1733
- });
1734
- const connector = connection.connector;
1735
- if (connector.getClient)
1736
- return connector.getClient({ chainId });
1737
- const account = parseAccount(parameters.account ?? connection.accounts[0]);
1738
- account.address = getAddress(account.address);
1739
- if (parameters.account && !connection.accounts.some((x) => x.toLowerCase() === account.address.toLowerCase()))
1740
- throw new ConnectorAccountNotFoundError({
1741
- address: account.address,
1742
- connector
1743
- });
1744
- const chain = config.chains.find((chain2) => chain2.id === chainId);
1745
- const provider = await connection.connector.getProvider({ chainId });
1746
- return createClient({
1747
- account,
1748
- chain,
1749
- name: "Connector Client",
1750
- transport: (opts) => custom(provider)({ ...opts, retryCount: 0 })
1751
- });
1752
- }
1753
-
1754
- // node_modules/@wagmi/core/dist/esm/exports/index.js
1755
- import { custom as custom2, http, webSocket } from "viem";
1756
-
1757
- // src/hooks/useEthersSigner.ts
1758
- function clientToSigner(client) {
1759
- const { account, chain, transport } = client;
1760
- const network = {
1761
- chainId: chain.id,
1762
- name: chain.name,
1763
- ensAddress: chain.contracts?.ensRegistry?.address
1764
- };
1765
- const provider = new providers.Web3Provider(transport, network);
1766
- const signer = provider.getSigner(account.address);
1767
- return signer;
1768
- }
1769
- async function getEthersSigner(config, { chainId } = {}) {
1770
- const client = await getConnectorClient(config, { chainId });
1771
- return clientToSigner(client);
1772
- }
1773
-
1774
- // src/components/EVMModal/index.tsx
1775
- import React4, { useEffect as useEffect10, useMemo as useMemo10, useState as useState14 } from "react";
1776
- import { SiweMessage } from "siwe";
1540
+ // src/components/SOLModal/index.tsx
1541
+ import React2, { useEffect as useEffect9, useMemo as useMemo8, useState as useState13 } from "react";
1777
1542
 
1778
1543
  // src/components/index.tsx
1779
1544
  var components_exports = {};
1780
1545
  __export(components_exports, {
1781
1546
  Button: () => Button,
1782
- EVMModal: () => EVMModal,
1783
1547
  EmailModal: () => EmailModal,
1784
1548
  Field: () => Field,
1785
1549
  Input: () => Input,
@@ -1799,7 +1563,7 @@ __export(components_exports, {
1799
1563
  import { useEffect as useEffect7, useState as useState7 } from "react";
1800
1564
 
1801
1565
  // src/components/EmailModal/StepEmail.tsx
1802
- import { useEffect as useEffect5, useMemo as useMemo5, useState as useState5 } from "react";
1566
+ import { useEffect as useEffect5, useMemo as useMemo4, useState as useState5 } from "react";
1803
1567
  import { jsx as jsx32, jsxs as jsxs21 } from "react/jsx-runtime";
1804
1568
  function StepEmail(props) {
1805
1569
  const [emailVal, setEmailVal] = useState5("");
@@ -1808,7 +1572,7 @@ function StepEmail(props) {
1808
1572
  setEmailVal(props.email);
1809
1573
  }
1810
1574
  }, []);
1811
- const canContinue = useMemo5(() => {
1575
+ const canContinue = useMemo4(() => {
1812
1576
  return isValidEmail(emailVal);
1813
1577
  }, [emailVal]);
1814
1578
  const onContinue = async () => {
@@ -1830,7 +1594,7 @@ function StepEmail(props) {
1830
1594
  }
1831
1595
 
1832
1596
  // src/components/EmailModal/StepVerify.tsx
1833
- import { useEffect as useEffect6, useMemo as useMemo6, useRef, useState as useState6 } from "react";
1597
+ import { useEffect as useEffect6, useMemo as useMemo5, useRef, useState as useState6 } from "react";
1834
1598
 
1835
1599
  // src/config/index.tsx
1836
1600
  var EMAIL_INTERVAL = 60;
@@ -1882,7 +1646,7 @@ function StepVerify(props) {
1882
1646
  }
1883
1647
  };
1884
1648
  }, []);
1885
- const canContinue = useMemo6(() => {
1649
+ const canContinue = useMemo5(() => {
1886
1650
  return code.length === codeLength;
1887
1651
  }, [code]);
1888
1652
  const onContinue = async () => {
@@ -2009,7 +1773,7 @@ function Popover({
2009
1773
  }
2010
1774
 
2011
1775
  // src/components/LoginBox/index.tsx
2012
- import { useMemo as useMemo7, useState as useState9 } from "react";
1776
+ import { useMemo as useMemo6, useState as useState9 } from "react";
2013
1777
 
2014
1778
  // src/assets/icon/SOLIcon.tsx
2015
1779
  import { jsx as jsx36, jsxs as jsxs24 } from "react/jsx-runtime";
@@ -2107,7 +1871,7 @@ function LoginBox({
2107
1871
  "twitter"
2108
1872
  // 'facebook',
2109
1873
  ];
2110
- const methodList = useMemo7(() => {
1874
+ const methodList = useMemo6(() => {
2111
1875
  return methods || defaultMethods;
2112
1876
  }, [methods]);
2113
1877
  const LoginItem = ({
@@ -2362,7 +2126,7 @@ function LoginButton({
2362
2126
  }
2363
2127
 
2364
2128
  // src/components/UsernameModal/index.tsx
2365
- import { useEffect as useEffect8, useMemo as useMemo8, useState as useState12 } from "react";
2129
+ import { useEffect as useEffect8, useMemo as useMemo7, useState as useState12 } from "react";
2366
2130
 
2367
2131
  // src/assets/icon/InfoRoundIcon.tsx
2368
2132
  import { jsx as jsx43, jsxs as jsxs30 } from "react/jsx-runtime";
@@ -2412,10 +2176,10 @@ function UsernameModal({
2412
2176
  setError("");
2413
2177
  }
2414
2178
  }, [isOpen]);
2415
- const isValid = useMemo8(() => {
2179
+ const isValid = useMemo7(() => {
2416
2180
  return isValidUsername(val);
2417
2181
  }, [val]);
2418
- const isLength = useMemo8(() => {
2182
+ const isLength = useMemo7(() => {
2419
2183
  return val.length >= 2 && val.length <= 32;
2420
2184
  }, [val]);
2421
2185
  const isSafe = isValid && isLength;
@@ -2471,7 +2235,6 @@ function UsernameModal({
2471
2235
  }
2472
2236
 
2473
2237
  // src/components/SOLModal/index.tsx
2474
- import React3, { useEffect as useEffect9, useMemo as useMemo9, useState as useState13 } from "react";
2475
2238
  import { clusterApiUrl } from "@solana/web3.js";
2476
2239
  import { useWallet as useWallet2, WalletProvider, ConnectionProvider } from "@solana/wallet-adapter-react";
2477
2240
  import { WalletModalProvider, useWalletModal } from "@solana/wallet-adapter-react-ui";
@@ -2540,7 +2303,7 @@ function WalletContent({
2540
2303
  const wallet = useWallet2();
2541
2304
  const { events, login } = useMatch();
2542
2305
  const [status, setStatus] = useState13("");
2543
- const statusRef = React3.useRef(status);
2306
+ const statusRef = React2.useRef(status);
2544
2307
  const [error, setError] = useState13("");
2545
2308
  useEffect9(() => {
2546
2309
  const init = async () => {
@@ -2610,7 +2373,7 @@ function WalletContent({
2610
2373
  statusRef.current = "";
2611
2374
  }
2612
2375
  };
2613
- const pageData = useMemo9(() => {
2376
+ const pageData = useMemo8(() => {
2614
2377
  if (status == "success") {
2615
2378
  return {
2616
2379
  btnText: "Disconnect Wallet",
@@ -2731,217 +2494,15 @@ function SOLModal({
2731
2494
  return /* @__PURE__ */ jsx45(ModalWithHeader, { ...props, title: props.title || firstUpperCase(type + " SOL Wallet"), children: /* @__PURE__ */ jsx45(ConnectionProvider, { endpoint: clusterApiUrl("devnet"), children: /* @__PURE__ */ jsx45(WalletProvider, { wallets, autoConnect: true, children: /* @__PURE__ */ jsx45(WalletModalProvider, { children: /* @__PURE__ */ jsx45(WalletContent, { onSuccess, type }) }) }) }) });
2732
2495
  }
2733
2496
 
2734
- // src/components/EVMModal/index.tsx
2735
- import "@rainbow-me/rainbowkit/styles.css";
2736
- import { jsx as jsx46, jsxs as jsxs33 } from "react/jsx-runtime";
2737
- var wagmiConfig = getDefaultConfig({
2738
- appName: "MatchID",
2739
- projectId: "9ac6ea7e07860f04616fb311b447dee9",
2740
- wallets: [
2741
- {
2742
- groupName: "Recommended",
2743
- wallets: [
2744
- metaMaskWallet,
2745
- walletConnectWallet,
2746
- okxWallet,
2747
- bitgetWallet,
2748
- injectedWallet
2749
- ]
2750
- }
2751
- ],
2752
- chains: [bsc]
2753
- });
2754
- function WalletContent2({
2755
- onSuccess,
2756
- type
2757
- }) {
2758
- const config = useConfig();
2759
- const { openConnectModal, connectModalOpen } = useConnectModal();
2760
- const { address } = useAccount();
2761
- const { disconnect } = useDisconnect({ config });
2762
- const chainId = useChainId();
2763
- const { events, login } = useMatch();
2764
- const [status, setStatus] = useState14("");
2765
- const statusRef = React4.useRef(status);
2766
- const [error, setError] = useState14("");
2767
- useEffect10(() => {
2768
- if (openConnectModal) {
2769
- disconnect();
2770
- openConnectModal && openConnectModal();
2771
- }
2772
- return () => {
2773
- address && disconnect();
2774
- };
2775
- }, [openConnectModal]);
2776
- useAccountEffect({
2777
- onDisconnect() {
2778
- matchlog_default.log("onDisconnect");
2779
- setStatus("");
2780
- statusRef.current = "";
2781
- },
2782
- onConnect(data) {
2783
- matchlog_default.log("onConnect", data, status);
2784
- setStatus("");
2785
- statusRef.current = "";
2786
- toLoginInWallet(data);
2787
- }
2788
- });
2789
- const toLoginInWallet = async (data) => {
2790
- if (statusRef.current) return;
2791
- try {
2792
- const signer = await getEthersSigner(config);
2793
- if (!signer || !chainId || !data.address) return;
2794
- setStatus("nonce");
2795
- statusRef.current = "nonce";
2796
- const res = type == "bind" ? await getWalletInitApi({ address: data.address }) : await getWalletNonceApi({ address: data.address });
2797
- if (!isSuccess(res)) {
2798
- throw new Error(res.message);
2799
- }
2800
- const domain = window.location.host;
2801
- const origin = window.location.origin;
2802
- const nonce = res.code >= 0 ? res.data.nonce : null;
2803
- if (nonce) {
2804
- setStatus("signer");
2805
- statusRef.current = "signer";
2806
- const params = {
2807
- domain,
2808
- address: data.address,
2809
- statement: "By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",
2810
- uri: origin,
2811
- nonce,
2812
- version: "1",
2813
- chainId
2814
- };
2815
- const message = new SiweMessage({ ...params });
2816
- const signature = await signer.signMessage(message.prepareMessage());
2817
- let obj = {
2818
- type: "EVM",
2819
- address: data.address,
2820
- signature,
2821
- message: `${message.prepareMessage()}`,
2822
- connector_type: data.connector.type || "",
2823
- wallet_client_type: data.connector.name || ""
2824
- };
2825
- const res2 = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
2826
- if (res2) {
2827
- if (!isSuccess(res2)) {
2828
- throw new Error(res2.message);
2829
- }
2830
- matchlog_default.log(res2);
2831
- setStatus("success");
2832
- statusRef.current = "success";
2833
- if (type == "bind") {
2834
- events.onBind && events.onBind({
2835
- type: "evm"
2836
- });
2837
- eventManager_default.emit("onBind", {
2838
- type: "evm"
2839
- });
2840
- } else {
2841
- await login({
2842
- mid: res2.data.mid,
2843
- token: `${res2.data.token_type} ${res2.data.access_token}`
2844
- });
2845
- }
2846
- onSuccess && onSuccess();
2847
- }
2848
- }
2849
- } catch (error2) {
2850
- setStatus("error");
2851
- setError(error2.message);
2852
- statusRef.current = "";
2853
- }
2854
- };
2855
- const pageData = useMemo10(() => {
2856
- if (status == "success") {
2857
- return {
2858
- btnText: "Disconnect Wallet",
2859
- btnClick: () => {
2860
- disconnect();
2861
- },
2862
- text: "Wallet connection successful!",
2863
- statusImage: walletConnectedImage
2864
- };
2865
- }
2866
- if (status == "error") {
2867
- return {
2868
- text: error,
2869
- btnText: "Reconnect Wallet",
2870
- btnClick: async () => {
2871
- setError("");
2872
- disconnect();
2873
- openConnectModal && openConnectModal();
2874
- },
2875
- statusImage: walletErrorImage,
2876
- isError: true
2877
- };
2878
- }
2879
- if (status == "nonce") {
2880
- return {
2881
- btnLoading: true,
2882
- text: "Connecting",
2883
- statusImage: walletConnectingImage
2884
- };
2885
- }
2886
- if (status == "signer") {
2887
- return {
2888
- btnLoading: true,
2889
- text: "Signing",
2890
- statusImage: walletSigningImage
2891
- };
2892
- }
2893
- if (connectModalOpen) {
2894
- return {
2895
- btnLoading: true,
2896
- text: "Connecting",
2897
- statusImage: walletConnectingImage
2898
- };
2899
- }
2900
- return {
2901
- btnText: "Connect Wallet",
2902
- btnClick: () => {
2903
- openConnectModal && openConnectModal();
2904
- },
2905
- text: "Please Connect your wallet",
2906
- statusImage: walletConnectImage
2907
- };
2908
- }, [connectModalOpen, status, error, address]);
2909
- return /* @__PURE__ */ jsx46("div", { className: "matchid-wallet-container", children: /* @__PURE__ */ jsxs33("div", { className: `matchid-wallet-box`, children: [
2910
- /* @__PURE__ */ jsxs33("div", { className: `matchid-wallet-content`, children: [
2911
- /* @__PURE__ */ jsx46("img", { src: pageData.statusImage }),
2912
- /* @__PURE__ */ jsx46("div", { className: pageData.isError ? "text-[#F7585E]" : "", children: pageData.text })
2913
- ] }),
2914
- /* @__PURE__ */ jsx46(
2915
- Button,
2916
- {
2917
- block: true,
2918
- size: "lg",
2919
- onClick: pageData.btnClick,
2920
- loading: pageData.btnLoading,
2921
- disabled: pageData.btnDisabled,
2922
- children: pageData.btnText
2923
- }
2924
- )
2925
- ] }) });
2926
- }
2927
- function EVMModal({
2928
- type = "login",
2929
- onSuccess,
2930
- ...props
2931
- }) {
2932
- return /* @__PURE__ */ jsx46(ModalWithHeader, { ...props, title: props.title || firstUpperCase(type + " EVM Wallet"), children: /* @__PURE__ */ jsx46(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx46(RainbowKitProvider, { children: /* @__PURE__ */ jsx46(WalletContent2, { onSuccess, type }) }) }) });
2933
- }
2934
-
2935
2497
  // src/context/BusinessProvider.tsx
2936
- import { Fragment as Fragment4, jsx as jsx47, jsxs as jsxs34 } from "react/jsx-runtime";
2498
+ import { Fragment as Fragment4, jsx as jsx46, jsxs as jsxs33 } from "react/jsx-runtime";
2937
2499
  function BusinessProvider({ children }) {
2938
2500
  const { overview, token } = useUserInfo();
2939
2501
  const { recoveryModal } = useStore_default();
2940
- const { type: EVMType, isOpen: EVMIsOpen, close: EVMClose } = useEVMModalStore();
2941
2502
  const { type: SOLType, isOpen: SOLIsOpen, close: SOLClose } = useSOLModalStore();
2942
- return /* @__PURE__ */ jsxs34(Fragment4, { children: [
2943
- /* @__PURE__ */ jsx47(PasswordModal, { isOpen: !!token && !!overview && !overview.address && !!overview.did, showClose: false }),
2944
- /* @__PURE__ */ jsx47(
2503
+ return /* @__PURE__ */ jsxs33(Fragment4, { children: [
2504
+ /* @__PURE__ */ jsx46(PasswordModal, { isOpen: !!token && !!overview && !overview.address && !!overview.did, showClose: false }),
2505
+ /* @__PURE__ */ jsx46(
2945
2506
  RecoveryModal,
2946
2507
  {
2947
2508
  isOpen: !!token && !!overview && !!overview.address && recoveryModal.open,
@@ -2949,17 +2510,7 @@ function BusinessProvider({ children }) {
2949
2510
  onSuccess: recoveryModal.success
2950
2511
  }
2951
2512
  ),
2952
- /* @__PURE__ */ jsx47(
2953
- EVMModal,
2954
- {
2955
- isOpen: EVMIsOpen && (EVMType == "login" && !overview && !token || EVMType == "bind" && !!token && !!overview),
2956
- onClose: EVMClose,
2957
- type: EVMType,
2958
- onSuccess: EVMClose,
2959
- zIndex: 199
2960
- }
2961
- ),
2962
- /* @__PURE__ */ jsx47(
2513
+ /* @__PURE__ */ jsx46(
2963
2514
  SOLModal,
2964
2515
  {
2965
2516
  isOpen: SOLIsOpen && (SOLType == "login" && !overview && !token || SOLType == "bind" && !!token && !!overview),
@@ -2974,17 +2525,17 @@ function BusinessProvider({ children }) {
2974
2525
  }
2975
2526
 
2976
2527
  // src/context/index.tsx
2977
- import { jsx as jsx48 } from "react/jsx-runtime";
2528
+ import { jsx as jsx47 } from "react/jsx-runtime";
2978
2529
  var Providers = ({ children }) => {
2979
2530
  return (
2980
2531
  // <MpcWalletProvider>
2981
- /* @__PURE__ */ jsx48(BusinessProvider, { children })
2532
+ /* @__PURE__ */ jsx47(BusinessProvider, { children })
2982
2533
  );
2983
2534
  };
2984
2535
  var context_default = Providers;
2985
2536
 
2986
2537
  // src/hooks/useWalletInit.ts
2987
- import { useEffect as useEffect11, useState as useState15 } from "react";
2538
+ import { useEffect as useEffect10, useState as useState14 } from "react";
2988
2539
  var AppClientId2 = "react-sdk-" + getVersion();
2989
2540
  function useWalletInit({
2990
2541
  refreshOverview
@@ -2993,10 +2544,10 @@ function useWalletInit({
2993
2544
  const getWalletIframe = () => {
2994
2545
  return document.getElementById("match-wallet");
2995
2546
  };
2996
- const [walletInited, setWalletInited] = useState15(false);
2547
+ const [walletInited, setWalletInited] = useState14(false);
2997
2548
  const { appid, token, overview } = useLocalStore_default();
2998
2549
  const { initWallet, generateWallet } = useWallet();
2999
- useEffect11(() => {
2550
+ useEffect10(() => {
3000
2551
  if (endpoints.auth) {
3001
2552
  if (!window.matchWalletMessageIdMap) {
3002
2553
  window.matchWalletMessageIdMap = {};
@@ -3054,7 +2605,7 @@ function useWalletInit({
3054
2605
  }
3055
2606
  }
3056
2607
  }, [endpoints.auth]);
3057
- useEffect11(() => {
2608
+ useEffect10(() => {
3058
2609
  const messageHandle = async (e) => {
3059
2610
  if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
3060
2611
  return;
@@ -3087,7 +2638,7 @@ function useWalletInit({
3087
2638
  window.removeEventListener("message", messageHandle);
3088
2639
  };
3089
2640
  }, []);
3090
- useEffect11(() => {
2641
+ useEffect10(() => {
3091
2642
  if (token && overview && overview.did && walletInited) {
3092
2643
  const did = overview.did.split(":")[2];
3093
2644
  const newUserInit = async () => {
@@ -3118,7 +2669,7 @@ function useWalletInit({
3118
2669
  }
3119
2670
 
3120
2671
  // src/hooks/useInit.tsx
3121
- import { useEffect as useEffect12, useRef as useRef2 } from "react";
2672
+ import { useEffect as useEffect11, useRef as useRef2 } from "react";
3122
2673
  function useInit({
3123
2674
  theme,
3124
2675
  appid,
@@ -3138,16 +2689,16 @@ function useInit({
3138
2689
  const searchParams = new URLSearchParams(window.location.search);
3139
2690
  const matchToken = searchParams.get("matchToken");
3140
2691
  const realEndpoints = endpoints || env_default.endpoints;
3141
- useEffect12(() => {
2692
+ useEffect11(() => {
3142
2693
  setTheme(theme);
3143
2694
  }, [theme]);
3144
- useEffect12(() => {
2695
+ useEffect11(() => {
3145
2696
  setAppid(appid);
3146
2697
  }, [appid]);
3147
- useEffect12(() => {
2698
+ useEffect11(() => {
3148
2699
  setEndpoints(realEndpoints);
3149
2700
  }, [realEndpoints]);
3150
- useEffect12(() => {
2701
+ useEffect11(() => {
3151
2702
  if (matchToken) {
3152
2703
  const tokenData = JSON.parse(atob(matchToken));
3153
2704
  if (tokenData && tokenData.mid && tokenData.token) {
@@ -3158,7 +2709,7 @@ function useInit({
3158
2709
  }
3159
2710
  }
3160
2711
  }, [matchToken]);
3161
- useEffect12(() => {
2712
+ useEffect11(() => {
3162
2713
  const onLoginMessage = (event) => {
3163
2714
  const res = event.data;
3164
2715
  if (res.event === "login" && res.data && (res.data.token || res.data.token_type && res.data.access_token)) {
@@ -3194,7 +2745,7 @@ function useInit({
3194
2745
  overviewLoadingRef.current = false;
3195
2746
  }
3196
2747
  };
3197
- useEffect12(() => {
2748
+ useEffect11(() => {
3198
2749
  if (token) {
3199
2750
  loadOverview();
3200
2751
  }
@@ -3225,36 +2776,9 @@ function useInit({
3225
2776
 
3226
2777
  // src/MatchContext.tsx
3227
2778
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
3228
- import { WagmiProvider as WagmiProvider2 } from "wagmi";
3229
- import { getDefaultConfig as getDefaultConfig2 } from "@rainbow-me/rainbowkit";
3230
- import {
3231
- bitgetWallet as bitgetWallet2,
3232
- injectedWallet as injectedWallet2,
3233
- metaMaskWallet as metaMaskWallet2,
3234
- okxWallet as okxWallet2,
3235
- walletConnectWallet as walletConnectWallet2
3236
- } from "@rainbow-me/rainbowkit/wallets";
3237
- import { arbitrum, base, bsc as bsc2, mainnet, optimism, polygon } from "wagmi/chains";
3238
- import { jsx as jsx49 } from "react/jsx-runtime";
2779
+ import { jsx as jsx48 } from "react/jsx-runtime";
3239
2780
  var queryClient = new QueryClient();
3240
2781
  var MatchContext = createContext(void 0);
3241
- var wagmiConfig2 = getDefaultConfig2({
3242
- appName: "Match Mid",
3243
- projectId: "9ac6ea7e07860f04616fb311b447dee9",
3244
- wallets: [
3245
- {
3246
- groupName: "Recommended",
3247
- wallets: [
3248
- metaMaskWallet2,
3249
- walletConnectWallet2,
3250
- okxWallet2,
3251
- bitgetWallet2,
3252
- injectedWallet2
3253
- ]
3254
- }
3255
- ],
3256
- chains: [mainnet, polygon, optimism, arbitrum, base, bsc2]
3257
- });
3258
2782
  var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) => {
3259
2783
  const { loadOverview, login, endpoints: realEndPoints } = useInit({
3260
2784
  theme,
@@ -3265,7 +2789,7 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) =>
3265
2789
  useWalletInit({
3266
2790
  refreshOverview: loadOverview
3267
2791
  });
3268
- return /* @__PURE__ */ jsx49(WagmiProvider2, { config: wagmiConfig2, children: /* @__PURE__ */ jsx49(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx49(
2792
+ return /* @__PURE__ */ jsx48(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx48(
3269
2793
  MatchContext.Provider,
3270
2794
  {
3271
2795
  value: {
@@ -3275,9 +2799,9 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) =>
3275
2799
  login,
3276
2800
  theme
3277
2801
  },
3278
- children: /* @__PURE__ */ jsx49(context_default, { children })
2802
+ children: /* @__PURE__ */ jsx48(context_default, { children })
3279
2803
  }
3280
- ) }) });
2804
+ ) });
3281
2805
  };
3282
2806
  var useMatch = () => {
3283
2807
  const context = useContext(MatchContext);