@matchain/matchid-sdk-react 0.1.26 → 0.1.27
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.d.mts +3 -9
- package/dist/index.d.ts +3 -9
- package/dist/index.js +37 -502
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -517
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
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
|
|
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
|
|
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
|
|
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
|
|
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":
|
|
@@ -1543,243 +1536,13 @@ function RecoveryModal({
|
|
|
1543
1536
|
] }) });
|
|
1544
1537
|
}
|
|
1545
1538
|
|
|
1546
|
-
// src/components/
|
|
1547
|
-
import {
|
|
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";
|
|
1539
|
+
// src/components/SOLModal/index.tsx
|
|
1540
|
+
import React2, { useEffect as useEffect9, useMemo as useMemo8, useState as useState13 } from "react";
|
|
1777
1541
|
|
|
1778
1542
|
// src/components/index.tsx
|
|
1779
1543
|
var components_exports = {};
|
|
1780
1544
|
__export(components_exports, {
|
|
1781
1545
|
Button: () => Button,
|
|
1782
|
-
EVMModal: () => EVMModal,
|
|
1783
1546
|
EmailModal: () => EmailModal,
|
|
1784
1547
|
Field: () => Field,
|
|
1785
1548
|
Input: () => Input,
|
|
@@ -1799,7 +1562,7 @@ __export(components_exports, {
|
|
|
1799
1562
|
import { useEffect as useEffect7, useState as useState7 } from "react";
|
|
1800
1563
|
|
|
1801
1564
|
// src/components/EmailModal/StepEmail.tsx
|
|
1802
|
-
import { useEffect as useEffect5, useMemo as
|
|
1565
|
+
import { useEffect as useEffect5, useMemo as useMemo4, useState as useState5 } from "react";
|
|
1803
1566
|
import { jsx as jsx32, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
1804
1567
|
function StepEmail(props) {
|
|
1805
1568
|
const [emailVal, setEmailVal] = useState5("");
|
|
@@ -1808,7 +1571,7 @@ function StepEmail(props) {
|
|
|
1808
1571
|
setEmailVal(props.email);
|
|
1809
1572
|
}
|
|
1810
1573
|
}, []);
|
|
1811
|
-
const canContinue =
|
|
1574
|
+
const canContinue = useMemo4(() => {
|
|
1812
1575
|
return isValidEmail(emailVal);
|
|
1813
1576
|
}, [emailVal]);
|
|
1814
1577
|
const onContinue = async () => {
|
|
@@ -1830,7 +1593,7 @@ function StepEmail(props) {
|
|
|
1830
1593
|
}
|
|
1831
1594
|
|
|
1832
1595
|
// src/components/EmailModal/StepVerify.tsx
|
|
1833
|
-
import { useEffect as useEffect6, useMemo as
|
|
1596
|
+
import { useEffect as useEffect6, useMemo as useMemo5, useRef, useState as useState6 } from "react";
|
|
1834
1597
|
|
|
1835
1598
|
// src/config/index.tsx
|
|
1836
1599
|
var EMAIL_INTERVAL = 60;
|
|
@@ -1882,7 +1645,7 @@ function StepVerify(props) {
|
|
|
1882
1645
|
}
|
|
1883
1646
|
};
|
|
1884
1647
|
}, []);
|
|
1885
|
-
const canContinue =
|
|
1648
|
+
const canContinue = useMemo5(() => {
|
|
1886
1649
|
return code.length === codeLength;
|
|
1887
1650
|
}, [code]);
|
|
1888
1651
|
const onContinue = async () => {
|
|
@@ -2009,7 +1772,7 @@ function Popover({
|
|
|
2009
1772
|
}
|
|
2010
1773
|
|
|
2011
1774
|
// src/components/LoginBox/index.tsx
|
|
2012
|
-
import { useMemo as
|
|
1775
|
+
import { useMemo as useMemo6, useState as useState9 } from "react";
|
|
2013
1776
|
|
|
2014
1777
|
// src/assets/icon/SOLIcon.tsx
|
|
2015
1778
|
import { jsx as jsx36, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
@@ -2107,7 +1870,7 @@ function LoginBox({
|
|
|
2107
1870
|
"twitter"
|
|
2108
1871
|
// 'facebook',
|
|
2109
1872
|
];
|
|
2110
|
-
const methodList =
|
|
1873
|
+
const methodList = useMemo6(() => {
|
|
2111
1874
|
return methods || defaultMethods;
|
|
2112
1875
|
}, [methods]);
|
|
2113
1876
|
const LoginItem = ({
|
|
@@ -2362,7 +2125,7 @@ function LoginButton({
|
|
|
2362
2125
|
}
|
|
2363
2126
|
|
|
2364
2127
|
// src/components/UsernameModal/index.tsx
|
|
2365
|
-
import { useEffect as useEffect8, useMemo as
|
|
2128
|
+
import { useEffect as useEffect8, useMemo as useMemo7, useState as useState12 } from "react";
|
|
2366
2129
|
|
|
2367
2130
|
// src/assets/icon/InfoRoundIcon.tsx
|
|
2368
2131
|
import { jsx as jsx43, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
@@ -2412,10 +2175,10 @@ function UsernameModal({
|
|
|
2412
2175
|
setError("");
|
|
2413
2176
|
}
|
|
2414
2177
|
}, [isOpen]);
|
|
2415
|
-
const isValid =
|
|
2178
|
+
const isValid = useMemo7(() => {
|
|
2416
2179
|
return isValidUsername(val);
|
|
2417
2180
|
}, [val]);
|
|
2418
|
-
const isLength =
|
|
2181
|
+
const isLength = useMemo7(() => {
|
|
2419
2182
|
return val.length >= 2 && val.length <= 32;
|
|
2420
2183
|
}, [val]);
|
|
2421
2184
|
const isSafe = isValid && isLength;
|
|
@@ -2471,7 +2234,6 @@ function UsernameModal({
|
|
|
2471
2234
|
}
|
|
2472
2235
|
|
|
2473
2236
|
// src/components/SOLModal/index.tsx
|
|
2474
|
-
import React3, { useEffect as useEffect9, useMemo as useMemo9, useState as useState13 } from "react";
|
|
2475
2237
|
import { clusterApiUrl } from "@solana/web3.js";
|
|
2476
2238
|
import { useWallet as useWallet2, WalletProvider, ConnectionProvider } from "@solana/wallet-adapter-react";
|
|
2477
2239
|
import { WalletModalProvider, useWalletModal } from "@solana/wallet-adapter-react-ui";
|
|
@@ -2540,7 +2302,7 @@ function WalletContent({
|
|
|
2540
2302
|
const wallet = useWallet2();
|
|
2541
2303
|
const { events, login } = useMatch();
|
|
2542
2304
|
const [status, setStatus] = useState13("");
|
|
2543
|
-
const statusRef =
|
|
2305
|
+
const statusRef = React2.useRef(status);
|
|
2544
2306
|
const [error, setError] = useState13("");
|
|
2545
2307
|
useEffect9(() => {
|
|
2546
2308
|
const init = async () => {
|
|
@@ -2610,7 +2372,7 @@ function WalletContent({
|
|
|
2610
2372
|
statusRef.current = "";
|
|
2611
2373
|
}
|
|
2612
2374
|
};
|
|
2613
|
-
const pageData =
|
|
2375
|
+
const pageData = useMemo8(() => {
|
|
2614
2376
|
if (status == "success") {
|
|
2615
2377
|
return {
|
|
2616
2378
|
btnText: "Disconnect Wallet",
|
|
@@ -2731,217 +2493,15 @@ function SOLModal({
|
|
|
2731
2493
|
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
2494
|
}
|
|
2733
2495
|
|
|
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
2496
|
// src/context/BusinessProvider.tsx
|
|
2936
|
-
import { Fragment as Fragment4, jsx as
|
|
2497
|
+
import { Fragment as Fragment4, jsx as jsx46, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
2937
2498
|
function BusinessProvider({ children }) {
|
|
2938
2499
|
const { overview, token } = useUserInfo();
|
|
2939
2500
|
const { recoveryModal } = useStore_default();
|
|
2940
|
-
const { type: EVMType, isOpen: EVMIsOpen, close: EVMClose } = useEVMModalStore();
|
|
2941
2501
|
const { type: SOLType, isOpen: SOLIsOpen, close: SOLClose } = useSOLModalStore();
|
|
2942
|
-
return /* @__PURE__ */
|
|
2943
|
-
/* @__PURE__ */
|
|
2944
|
-
/* @__PURE__ */
|
|
2502
|
+
return /* @__PURE__ */ jsxs33(Fragment4, { children: [
|
|
2503
|
+
/* @__PURE__ */ jsx46(PasswordModal, { isOpen: !!token && !!overview && !overview.address && !!overview.did, showClose: false }),
|
|
2504
|
+
/* @__PURE__ */ jsx46(
|
|
2945
2505
|
RecoveryModal,
|
|
2946
2506
|
{
|
|
2947
2507
|
isOpen: !!token && !!overview && !!overview.address && recoveryModal.open,
|
|
@@ -2949,17 +2509,7 @@ function BusinessProvider({ children }) {
|
|
|
2949
2509
|
onSuccess: recoveryModal.success
|
|
2950
2510
|
}
|
|
2951
2511
|
),
|
|
2952
|
-
/* @__PURE__ */
|
|
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(
|
|
2512
|
+
/* @__PURE__ */ jsx46(
|
|
2963
2513
|
SOLModal,
|
|
2964
2514
|
{
|
|
2965
2515
|
isOpen: SOLIsOpen && (SOLType == "login" && !overview && !token || SOLType == "bind" && !!token && !!overview),
|
|
@@ -2974,17 +2524,17 @@ function BusinessProvider({ children }) {
|
|
|
2974
2524
|
}
|
|
2975
2525
|
|
|
2976
2526
|
// src/context/index.tsx
|
|
2977
|
-
import { jsx as
|
|
2527
|
+
import { jsx as jsx47 } from "react/jsx-runtime";
|
|
2978
2528
|
var Providers = ({ children }) => {
|
|
2979
2529
|
return (
|
|
2980
2530
|
// <MpcWalletProvider>
|
|
2981
|
-
/* @__PURE__ */
|
|
2531
|
+
/* @__PURE__ */ jsx47(BusinessProvider, { children })
|
|
2982
2532
|
);
|
|
2983
2533
|
};
|
|
2984
2534
|
var context_default = Providers;
|
|
2985
2535
|
|
|
2986
2536
|
// src/hooks/useWalletInit.ts
|
|
2987
|
-
import { useEffect as
|
|
2537
|
+
import { useEffect as useEffect10, useState as useState14 } from "react";
|
|
2988
2538
|
var AppClientId2 = "react-sdk-" + getVersion();
|
|
2989
2539
|
function useWalletInit({
|
|
2990
2540
|
refreshOverview
|
|
@@ -2993,10 +2543,10 @@ function useWalletInit({
|
|
|
2993
2543
|
const getWalletIframe = () => {
|
|
2994
2544
|
return document.getElementById("match-wallet");
|
|
2995
2545
|
};
|
|
2996
|
-
const [walletInited, setWalletInited] =
|
|
2546
|
+
const [walletInited, setWalletInited] = useState14(false);
|
|
2997
2547
|
const { appid, token, overview } = useLocalStore_default();
|
|
2998
2548
|
const { initWallet, generateWallet } = useWallet();
|
|
2999
|
-
|
|
2549
|
+
useEffect10(() => {
|
|
3000
2550
|
if (endpoints.auth) {
|
|
3001
2551
|
if (!window.matchWalletMessageIdMap) {
|
|
3002
2552
|
window.matchWalletMessageIdMap = {};
|
|
@@ -3054,7 +2604,7 @@ function useWalletInit({
|
|
|
3054
2604
|
}
|
|
3055
2605
|
}
|
|
3056
2606
|
}, [endpoints.auth]);
|
|
3057
|
-
|
|
2607
|
+
useEffect10(() => {
|
|
3058
2608
|
const messageHandle = async (e) => {
|
|
3059
2609
|
if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
|
|
3060
2610
|
return;
|
|
@@ -3087,7 +2637,7 @@ function useWalletInit({
|
|
|
3087
2637
|
window.removeEventListener("message", messageHandle);
|
|
3088
2638
|
};
|
|
3089
2639
|
}, []);
|
|
3090
|
-
|
|
2640
|
+
useEffect10(() => {
|
|
3091
2641
|
if (token && overview && overview.did && walletInited) {
|
|
3092
2642
|
const did = overview.did.split(":")[2];
|
|
3093
2643
|
const newUserInit = async () => {
|
|
@@ -3118,7 +2668,7 @@ function useWalletInit({
|
|
|
3118
2668
|
}
|
|
3119
2669
|
|
|
3120
2670
|
// src/hooks/useInit.tsx
|
|
3121
|
-
import { useEffect as
|
|
2671
|
+
import { useEffect as useEffect11, useRef as useRef2 } from "react";
|
|
3122
2672
|
function useInit({
|
|
3123
2673
|
theme,
|
|
3124
2674
|
appid,
|
|
@@ -3138,16 +2688,16 @@ function useInit({
|
|
|
3138
2688
|
const searchParams = new URLSearchParams(window.location.search);
|
|
3139
2689
|
const matchToken = searchParams.get("matchToken");
|
|
3140
2690
|
const realEndpoints = endpoints || env_default.endpoints;
|
|
3141
|
-
|
|
2691
|
+
useEffect11(() => {
|
|
3142
2692
|
setTheme(theme);
|
|
3143
2693
|
}, [theme]);
|
|
3144
|
-
|
|
2694
|
+
useEffect11(() => {
|
|
3145
2695
|
setAppid(appid);
|
|
3146
2696
|
}, [appid]);
|
|
3147
|
-
|
|
2697
|
+
useEffect11(() => {
|
|
3148
2698
|
setEndpoints(realEndpoints);
|
|
3149
2699
|
}, [realEndpoints]);
|
|
3150
|
-
|
|
2700
|
+
useEffect11(() => {
|
|
3151
2701
|
if (matchToken) {
|
|
3152
2702
|
const tokenData = JSON.parse(atob(matchToken));
|
|
3153
2703
|
if (tokenData && tokenData.mid && tokenData.token) {
|
|
@@ -3158,7 +2708,7 @@ function useInit({
|
|
|
3158
2708
|
}
|
|
3159
2709
|
}
|
|
3160
2710
|
}, [matchToken]);
|
|
3161
|
-
|
|
2711
|
+
useEffect11(() => {
|
|
3162
2712
|
const onLoginMessage = (event) => {
|
|
3163
2713
|
const res = event.data;
|
|
3164
2714
|
if (res.event === "login" && res.data && (res.data.token || res.data.token_type && res.data.access_token)) {
|
|
@@ -3194,7 +2744,7 @@ function useInit({
|
|
|
3194
2744
|
overviewLoadingRef.current = false;
|
|
3195
2745
|
}
|
|
3196
2746
|
};
|
|
3197
|
-
|
|
2747
|
+
useEffect11(() => {
|
|
3198
2748
|
if (token) {
|
|
3199
2749
|
loadOverview();
|
|
3200
2750
|
}
|
|
@@ -3225,36 +2775,9 @@ function useInit({
|
|
|
3225
2775
|
|
|
3226
2776
|
// src/MatchContext.tsx
|
|
3227
2777
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3228
|
-
import {
|
|
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";
|
|
2778
|
+
import { jsx as jsx48 } from "react/jsx-runtime";
|
|
3239
2779
|
var queryClient = new QueryClient();
|
|
3240
2780
|
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
2781
|
var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) => {
|
|
3259
2782
|
const { loadOverview, login, endpoints: realEndPoints } = useInit({
|
|
3260
2783
|
theme,
|
|
@@ -3265,7 +2788,7 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) =>
|
|
|
3265
2788
|
useWalletInit({
|
|
3266
2789
|
refreshOverview: loadOverview
|
|
3267
2790
|
});
|
|
3268
|
-
return /* @__PURE__ */
|
|
2791
|
+
return /* @__PURE__ */ jsx48(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx48(
|
|
3269
2792
|
MatchContext.Provider,
|
|
3270
2793
|
{
|
|
3271
2794
|
value: {
|
|
@@ -3275,9 +2798,9 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) =>
|
|
|
3275
2798
|
login,
|
|
3276
2799
|
theme
|
|
3277
2800
|
},
|
|
3278
|
-
children: /* @__PURE__ */
|
|
2801
|
+
children: /* @__PURE__ */ jsx48(context_default, { children })
|
|
3279
2802
|
}
|
|
3280
|
-
) })
|
|
2803
|
+
) });
|
|
3281
2804
|
};
|
|
3282
2805
|
var useMatch = () => {
|
|
3283
2806
|
const context = useContext(MatchContext);
|