@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.js
CHANGED
|
@@ -40,7 +40,7 @@ __export(src_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(src_exports);
|
|
41
41
|
|
|
42
42
|
// src/MatchContext.tsx
|
|
43
|
-
var
|
|
43
|
+
var import_react18 = require("react");
|
|
44
44
|
|
|
45
45
|
// src/assets/icon/ArrowLeftIcon.tsx
|
|
46
46
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -1031,12 +1031,6 @@ function firstUpperCase(str) {
|
|
|
1031
1031
|
|
|
1032
1032
|
// src/store/useModalStore.ts
|
|
1033
1033
|
var import_zustand2 = require("zustand");
|
|
1034
|
-
var useEVMModalStore = (0, import_zustand2.create)((set) => ({
|
|
1035
|
-
isOpen: false,
|
|
1036
|
-
type: "",
|
|
1037
|
-
open: (type) => set({ isOpen: true, type }),
|
|
1038
|
-
close: () => set({ isOpen: false })
|
|
1039
|
-
}));
|
|
1040
1034
|
var useSOLModalStore = (0, import_zustand2.create)((set) => ({
|
|
1041
1035
|
isOpen: false,
|
|
1042
1036
|
type: "",
|
|
@@ -1058,7 +1052,6 @@ function useUserInfo() {
|
|
|
1058
1052
|
endpoints
|
|
1059
1053
|
} = useLocalStore_default();
|
|
1060
1054
|
const { events, login } = useMatch();
|
|
1061
|
-
const { open: EVMOpen } = useEVMModalStore();
|
|
1062
1055
|
const { open: SOLOpen } = useSOLModalStore();
|
|
1063
1056
|
const isLogin = (0, import_react2.useMemo)(() => !!token, [token]);
|
|
1064
1057
|
const logout = async () => {
|
|
@@ -1088,7 +1081,7 @@ function useUserInfo() {
|
|
|
1088
1081
|
return loginByMethod("google");
|
|
1089
1082
|
};
|
|
1090
1083
|
const loginByWallet = async () => {
|
|
1091
|
-
return
|
|
1084
|
+
return window.open(`${endpoints.auth}login/wallet?appid=${appid}`);
|
|
1092
1085
|
};
|
|
1093
1086
|
const loginByTelegram = async () => {
|
|
1094
1087
|
return window.open(
|
|
@@ -1101,7 +1094,7 @@ function useUserInfo() {
|
|
|
1101
1094
|
const loginMethod = async (method) => {
|
|
1102
1095
|
switch (method) {
|
|
1103
1096
|
case "evm":
|
|
1104
|
-
return
|
|
1097
|
+
return window.open(`${endpoints.auth}login/wallet?appid=${appid}`);
|
|
1105
1098
|
case "sol":
|
|
1106
1099
|
return SOLOpen("login");
|
|
1107
1100
|
case "telegram":
|
|
@@ -1161,7 +1154,7 @@ function useUserInfo() {
|
|
|
1161
1154
|
if (!token) {
|
|
1162
1155
|
throw new Error("You must login first");
|
|
1163
1156
|
}
|
|
1164
|
-
return
|
|
1157
|
+
return window.open(`${endpoints.auth}bind/wallet?appid=${appid}&st=` + encodeURIComponent(encodeBase64(token)));
|
|
1165
1158
|
};
|
|
1166
1159
|
const bindTelegram = async () => {
|
|
1167
1160
|
if (!token) {
|
|
@@ -1187,7 +1180,7 @@ function useUserInfo() {
|
|
|
1187
1180
|
}
|
|
1188
1181
|
switch (method) {
|
|
1189
1182
|
case "evm":
|
|
1190
|
-
return
|
|
1183
|
+
return window.open(`${endpoints.auth}bind/wallet?appid=${appid}&st=` + encodeURIComponent(encodeBase64(token)));
|
|
1191
1184
|
case "sol":
|
|
1192
1185
|
return SOLOpen("bind");
|
|
1193
1186
|
case "telegram":
|
|
@@ -1578,237 +1571,13 @@ function RecoveryModal({
|
|
|
1578
1571
|
] }) });
|
|
1579
1572
|
}
|
|
1580
1573
|
|
|
1581
|
-
// src/components/
|
|
1582
|
-
var
|
|
1583
|
-
var import_wagmi2 = require("wagmi");
|
|
1584
|
-
var import_wallets = require("@rainbow-me/rainbowkit/wallets");
|
|
1585
|
-
var import_chains = require("wagmi/chains");
|
|
1586
|
-
|
|
1587
|
-
// src/hooks/useEthersSigner.ts
|
|
1588
|
-
var React = __toESM(require("react"));
|
|
1589
|
-
var import_wagmi = require("wagmi");
|
|
1590
|
-
var import_ethers = require("ethers");
|
|
1591
|
-
|
|
1592
|
-
// node_modules/@wagmi/core/dist/esm/version.js
|
|
1593
|
-
var version = "2.16.3";
|
|
1594
|
-
|
|
1595
|
-
// node_modules/@wagmi/core/dist/esm/utils/getVersion.js
|
|
1596
|
-
var getVersion2 = () => `@wagmi/core@${version}`;
|
|
1597
|
-
|
|
1598
|
-
// node_modules/@wagmi/core/dist/esm/errors/base.js
|
|
1599
|
-
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
1600
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1601
|
-
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");
|
|
1602
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1603
|
-
};
|
|
1604
|
-
var _BaseError_instances;
|
|
1605
|
-
var _BaseError_walk;
|
|
1606
|
-
var BaseError = class _BaseError extends Error {
|
|
1607
|
-
get docsBaseUrl() {
|
|
1608
|
-
return "https://wagmi.sh/core";
|
|
1609
|
-
}
|
|
1610
|
-
get version() {
|
|
1611
|
-
return getVersion2();
|
|
1612
|
-
}
|
|
1613
|
-
constructor(shortMessage, options = {}) {
|
|
1614
|
-
super();
|
|
1615
|
-
_BaseError_instances.add(this);
|
|
1616
|
-
Object.defineProperty(this, "details", {
|
|
1617
|
-
enumerable: true,
|
|
1618
|
-
configurable: true,
|
|
1619
|
-
writable: true,
|
|
1620
|
-
value: void 0
|
|
1621
|
-
});
|
|
1622
|
-
Object.defineProperty(this, "docsPath", {
|
|
1623
|
-
enumerable: true,
|
|
1624
|
-
configurable: true,
|
|
1625
|
-
writable: true,
|
|
1626
|
-
value: void 0
|
|
1627
|
-
});
|
|
1628
|
-
Object.defineProperty(this, "metaMessages", {
|
|
1629
|
-
enumerable: true,
|
|
1630
|
-
configurable: true,
|
|
1631
|
-
writable: true,
|
|
1632
|
-
value: void 0
|
|
1633
|
-
});
|
|
1634
|
-
Object.defineProperty(this, "shortMessage", {
|
|
1635
|
-
enumerable: true,
|
|
1636
|
-
configurable: true,
|
|
1637
|
-
writable: true,
|
|
1638
|
-
value: void 0
|
|
1639
|
-
});
|
|
1640
|
-
Object.defineProperty(this, "name", {
|
|
1641
|
-
enumerable: true,
|
|
1642
|
-
configurable: true,
|
|
1643
|
-
writable: true,
|
|
1644
|
-
value: "WagmiCoreError"
|
|
1645
|
-
});
|
|
1646
|
-
const details = options.cause instanceof _BaseError ? options.cause.details : options.cause?.message ? options.cause.message : options.details;
|
|
1647
|
-
const docsPath = options.cause instanceof _BaseError ? options.cause.docsPath || options.docsPath : options.docsPath;
|
|
1648
|
-
this.message = [
|
|
1649
|
-
shortMessage || "An error occurred.",
|
|
1650
|
-
"",
|
|
1651
|
-
...options.metaMessages ? [...options.metaMessages, ""] : [],
|
|
1652
|
-
...docsPath ? [
|
|
1653
|
-
`Docs: ${this.docsBaseUrl}${docsPath}.html${options.docsSlug ? `#${options.docsSlug}` : ""}`
|
|
1654
|
-
] : [],
|
|
1655
|
-
...details ? [`Details: ${details}`] : [],
|
|
1656
|
-
`Version: ${this.version}`
|
|
1657
|
-
].join("\n");
|
|
1658
|
-
if (options.cause)
|
|
1659
|
-
this.cause = options.cause;
|
|
1660
|
-
this.details = details;
|
|
1661
|
-
this.docsPath = docsPath;
|
|
1662
|
-
this.metaMessages = options.metaMessages;
|
|
1663
|
-
this.shortMessage = shortMessage;
|
|
1664
|
-
}
|
|
1665
|
-
walk(fn) {
|
|
1666
|
-
return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk).call(this, this, fn);
|
|
1667
|
-
}
|
|
1668
|
-
};
|
|
1669
|
-
_BaseError_instances = /* @__PURE__ */ new WeakSet(), _BaseError_walk = function _BaseError_walk2(err, fn) {
|
|
1670
|
-
if (fn?.(err))
|
|
1671
|
-
return err;
|
|
1672
|
-
if (err.cause)
|
|
1673
|
-
return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk2).call(this, err.cause, fn);
|
|
1674
|
-
return err;
|
|
1675
|
-
};
|
|
1676
|
-
|
|
1677
|
-
// node_modules/@wagmi/core/dist/esm/errors/config.js
|
|
1678
|
-
var ConnectorNotConnectedError = class extends BaseError {
|
|
1679
|
-
constructor() {
|
|
1680
|
-
super("Connector not connected.");
|
|
1681
|
-
Object.defineProperty(this, "name", {
|
|
1682
|
-
enumerable: true,
|
|
1683
|
-
configurable: true,
|
|
1684
|
-
writable: true,
|
|
1685
|
-
value: "ConnectorNotConnectedError"
|
|
1686
|
-
});
|
|
1687
|
-
}
|
|
1688
|
-
};
|
|
1689
|
-
var ConnectorAccountNotFoundError = class extends BaseError {
|
|
1690
|
-
constructor({ address, connector }) {
|
|
1691
|
-
super(`Account "${address}" not found for connector "${connector.name}".`);
|
|
1692
|
-
Object.defineProperty(this, "name", {
|
|
1693
|
-
enumerable: true,
|
|
1694
|
-
configurable: true,
|
|
1695
|
-
writable: true,
|
|
1696
|
-
value: "ConnectorAccountNotFoundError"
|
|
1697
|
-
});
|
|
1698
|
-
}
|
|
1699
|
-
};
|
|
1700
|
-
var ConnectorChainMismatchError = class extends BaseError {
|
|
1701
|
-
constructor({ connectionChainId, connectorChainId }) {
|
|
1702
|
-
super(`The current chain of the connector (id: ${connectorChainId}) does not match the connection's chain (id: ${connectionChainId}).`, {
|
|
1703
|
-
metaMessages: [
|
|
1704
|
-
`Current Chain ID: ${connectorChainId}`,
|
|
1705
|
-
`Expected Chain ID: ${connectionChainId}`
|
|
1706
|
-
]
|
|
1707
|
-
});
|
|
1708
|
-
Object.defineProperty(this, "name", {
|
|
1709
|
-
enumerable: true,
|
|
1710
|
-
configurable: true,
|
|
1711
|
-
writable: true,
|
|
1712
|
-
value: "ConnectorChainMismatchError"
|
|
1713
|
-
});
|
|
1714
|
-
}
|
|
1715
|
-
};
|
|
1716
|
-
var ConnectorUnavailableReconnectingError = class extends BaseError {
|
|
1717
|
-
constructor({ connector }) {
|
|
1718
|
-
super(`Connector "${connector.name}" unavailable while reconnecting.`, {
|
|
1719
|
-
details: [
|
|
1720
|
-
"During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.",
|
|
1721
|
-
"All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.",
|
|
1722
|
-
"This error commonly occurs for connectors that asynchronously inject after reconnection has already started."
|
|
1723
|
-
].join(" ")
|
|
1724
|
-
});
|
|
1725
|
-
Object.defineProperty(this, "name", {
|
|
1726
|
-
enumerable: true,
|
|
1727
|
-
configurable: true,
|
|
1728
|
-
writable: true,
|
|
1729
|
-
value: "ConnectorUnavailableReconnectingError"
|
|
1730
|
-
});
|
|
1731
|
-
}
|
|
1732
|
-
};
|
|
1733
|
-
|
|
1734
|
-
// node_modules/@wagmi/core/dist/esm/actions/getConnectorClient.js
|
|
1735
|
-
var import_viem = require("viem");
|
|
1736
|
-
var import_utils3 = require("viem/utils");
|
|
1737
|
-
async function getConnectorClient(config, parameters = {}) {
|
|
1738
|
-
let connection;
|
|
1739
|
-
if (parameters.connector) {
|
|
1740
|
-
const { connector: connector2 } = parameters;
|
|
1741
|
-
if (config.state.status === "reconnecting" && !connector2.getAccounts && !connector2.getChainId)
|
|
1742
|
-
throw new ConnectorUnavailableReconnectingError({ connector: connector2 });
|
|
1743
|
-
const [accounts, chainId2] = await Promise.all([
|
|
1744
|
-
connector2.getAccounts(),
|
|
1745
|
-
connector2.getChainId()
|
|
1746
|
-
]);
|
|
1747
|
-
connection = {
|
|
1748
|
-
accounts,
|
|
1749
|
-
chainId: chainId2,
|
|
1750
|
-
connector: connector2
|
|
1751
|
-
};
|
|
1752
|
-
} else
|
|
1753
|
-
connection = config.state.connections.get(config.state.current);
|
|
1754
|
-
if (!connection)
|
|
1755
|
-
throw new ConnectorNotConnectedError();
|
|
1756
|
-
const chainId = parameters.chainId ?? connection.chainId;
|
|
1757
|
-
const connectorChainId = await connection.connector.getChainId();
|
|
1758
|
-
if (connectorChainId !== connection.chainId)
|
|
1759
|
-
throw new ConnectorChainMismatchError({
|
|
1760
|
-
connectionChainId: connection.chainId,
|
|
1761
|
-
connectorChainId
|
|
1762
|
-
});
|
|
1763
|
-
const connector = connection.connector;
|
|
1764
|
-
if (connector.getClient)
|
|
1765
|
-
return connector.getClient({ chainId });
|
|
1766
|
-
const account = (0, import_utils3.parseAccount)(parameters.account ?? connection.accounts[0]);
|
|
1767
|
-
account.address = (0, import_utils3.getAddress)(account.address);
|
|
1768
|
-
if (parameters.account && !connection.accounts.some((x) => x.toLowerCase() === account.address.toLowerCase()))
|
|
1769
|
-
throw new ConnectorAccountNotFoundError({
|
|
1770
|
-
address: account.address,
|
|
1771
|
-
connector
|
|
1772
|
-
});
|
|
1773
|
-
const chain = config.chains.find((chain2) => chain2.id === chainId);
|
|
1774
|
-
const provider = await connection.connector.getProvider({ chainId });
|
|
1775
|
-
return (0, import_viem.createClient)({
|
|
1776
|
-
account,
|
|
1777
|
-
chain,
|
|
1778
|
-
name: "Connector Client",
|
|
1779
|
-
transport: (opts) => (0, import_viem.custom)(provider)({ ...opts, retryCount: 0 })
|
|
1780
|
-
});
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
// node_modules/@wagmi/core/dist/esm/exports/index.js
|
|
1784
|
-
var import_viem2 = require("viem");
|
|
1785
|
-
|
|
1786
|
-
// src/hooks/useEthersSigner.ts
|
|
1787
|
-
function clientToSigner(client) {
|
|
1788
|
-
const { account, chain, transport } = client;
|
|
1789
|
-
const network = {
|
|
1790
|
-
chainId: chain.id,
|
|
1791
|
-
name: chain.name,
|
|
1792
|
-
ensAddress: chain.contracts?.ensRegistry?.address
|
|
1793
|
-
};
|
|
1794
|
-
const provider = new import_ethers.providers.Web3Provider(transport, network);
|
|
1795
|
-
const signer = provider.getSigner(account.address);
|
|
1796
|
-
return signer;
|
|
1797
|
-
}
|
|
1798
|
-
async function getEthersSigner(config, { chainId } = {}) {
|
|
1799
|
-
const client = await getConnectorClient(config, { chainId });
|
|
1800
|
-
return clientToSigner(client);
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
// src/components/EVMModal/index.tsx
|
|
1804
|
-
var import_react16 = __toESM(require("react"));
|
|
1805
|
-
var import_siwe = require("siwe");
|
|
1574
|
+
// src/components/SOLModal/index.tsx
|
|
1575
|
+
var import_react15 = __toESM(require("react"));
|
|
1806
1576
|
|
|
1807
1577
|
// src/components/index.tsx
|
|
1808
1578
|
var components_exports = {};
|
|
1809
1579
|
__export(components_exports, {
|
|
1810
1580
|
Button: () => Button,
|
|
1811
|
-
EVMModal: () => EVMModal,
|
|
1812
1581
|
EmailModal: () => EmailModal,
|
|
1813
1582
|
Field: () => Field,
|
|
1814
1583
|
Input: () => Input,
|
|
@@ -2500,7 +2269,6 @@ function UsernameModal({
|
|
|
2500
2269
|
}
|
|
2501
2270
|
|
|
2502
2271
|
// src/components/SOLModal/index.tsx
|
|
2503
|
-
var import_react15 = __toESM(require("react"));
|
|
2504
2272
|
var import_web3 = require("@solana/web3.js");
|
|
2505
2273
|
var import_wallet_adapter_react = require("@solana/wallet-adapter-react");
|
|
2506
2274
|
var import_wallet_adapter_react_ui = require("@solana/wallet-adapter-react-ui");
|
|
@@ -2725,217 +2493,15 @@ function SOLModal({
|
|
|
2725
2493
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ModalWithHeader, { ...props, title: props.title || firstUpperCase(type + " SOL Wallet"), children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_wallet_adapter_react.ConnectionProvider, { endpoint: (0, import_web3.clusterApiUrl)("devnet"), children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_wallet_adapter_react.WalletProvider, { wallets, autoConnect: true, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_wallet_adapter_react_ui.WalletModalProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(WalletContent, { onSuccess, type }) }) }) }) });
|
|
2726
2494
|
}
|
|
2727
2495
|
|
|
2728
|
-
// src/components/EVMModal/index.tsx
|
|
2729
|
-
var import_styles2 = require("@rainbow-me/rainbowkit/styles.css");
|
|
2730
|
-
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
2731
|
-
var wagmiConfig = (0, import_rainbowkit.getDefaultConfig)({
|
|
2732
|
-
appName: "MatchID",
|
|
2733
|
-
projectId: "9ac6ea7e07860f04616fb311b447dee9",
|
|
2734
|
-
wallets: [
|
|
2735
|
-
{
|
|
2736
|
-
groupName: "Recommended",
|
|
2737
|
-
wallets: [
|
|
2738
|
-
import_wallets.metaMaskWallet,
|
|
2739
|
-
import_wallets.walletConnectWallet,
|
|
2740
|
-
import_wallets.okxWallet,
|
|
2741
|
-
import_wallets.bitgetWallet,
|
|
2742
|
-
import_wallets.injectedWallet
|
|
2743
|
-
]
|
|
2744
|
-
}
|
|
2745
|
-
],
|
|
2746
|
-
chains: [import_chains.bsc]
|
|
2747
|
-
});
|
|
2748
|
-
function WalletContent2({
|
|
2749
|
-
onSuccess,
|
|
2750
|
-
type
|
|
2751
|
-
}) {
|
|
2752
|
-
const config = (0, import_wagmi2.useConfig)();
|
|
2753
|
-
const { openConnectModal, connectModalOpen } = (0, import_rainbowkit.useConnectModal)();
|
|
2754
|
-
const { address } = (0, import_wagmi2.useAccount)();
|
|
2755
|
-
const { disconnect } = (0, import_wagmi2.useDisconnect)({ config });
|
|
2756
|
-
const chainId = (0, import_wagmi2.useChainId)();
|
|
2757
|
-
const { events, login } = useMatch();
|
|
2758
|
-
const [status, setStatus] = (0, import_react16.useState)("");
|
|
2759
|
-
const statusRef = import_react16.default.useRef(status);
|
|
2760
|
-
const [error, setError] = (0, import_react16.useState)("");
|
|
2761
|
-
(0, import_react16.useEffect)(() => {
|
|
2762
|
-
if (openConnectModal) {
|
|
2763
|
-
disconnect();
|
|
2764
|
-
openConnectModal && openConnectModal();
|
|
2765
|
-
}
|
|
2766
|
-
return () => {
|
|
2767
|
-
address && disconnect();
|
|
2768
|
-
};
|
|
2769
|
-
}, [openConnectModal]);
|
|
2770
|
-
(0, import_wagmi2.useAccountEffect)({
|
|
2771
|
-
onDisconnect() {
|
|
2772
|
-
matchlog_default.log("onDisconnect");
|
|
2773
|
-
setStatus("");
|
|
2774
|
-
statusRef.current = "";
|
|
2775
|
-
},
|
|
2776
|
-
onConnect(data) {
|
|
2777
|
-
matchlog_default.log("onConnect", data, status);
|
|
2778
|
-
setStatus("");
|
|
2779
|
-
statusRef.current = "";
|
|
2780
|
-
toLoginInWallet(data);
|
|
2781
|
-
}
|
|
2782
|
-
});
|
|
2783
|
-
const toLoginInWallet = async (data) => {
|
|
2784
|
-
if (statusRef.current) return;
|
|
2785
|
-
try {
|
|
2786
|
-
const signer = await getEthersSigner(config);
|
|
2787
|
-
if (!signer || !chainId || !data.address) return;
|
|
2788
|
-
setStatus("nonce");
|
|
2789
|
-
statusRef.current = "nonce";
|
|
2790
|
-
const res = type == "bind" ? await getWalletInitApi({ address: data.address }) : await getWalletNonceApi({ address: data.address });
|
|
2791
|
-
if (!isSuccess(res)) {
|
|
2792
|
-
throw new Error(res.message);
|
|
2793
|
-
}
|
|
2794
|
-
const domain = window.location.host;
|
|
2795
|
-
const origin = window.location.origin;
|
|
2796
|
-
const nonce = res.code >= 0 ? res.data.nonce : null;
|
|
2797
|
-
if (nonce) {
|
|
2798
|
-
setStatus("signer");
|
|
2799
|
-
statusRef.current = "signer";
|
|
2800
|
-
const params = {
|
|
2801
|
-
domain,
|
|
2802
|
-
address: data.address,
|
|
2803
|
-
statement: "By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",
|
|
2804
|
-
uri: origin,
|
|
2805
|
-
nonce,
|
|
2806
|
-
version: "1",
|
|
2807
|
-
chainId
|
|
2808
|
-
};
|
|
2809
|
-
const message = new import_siwe.SiweMessage({ ...params });
|
|
2810
|
-
const signature = await signer.signMessage(message.prepareMessage());
|
|
2811
|
-
let obj = {
|
|
2812
|
-
type: "EVM",
|
|
2813
|
-
address: data.address,
|
|
2814
|
-
signature,
|
|
2815
|
-
message: `${message.prepareMessage()}`,
|
|
2816
|
-
connector_type: data.connector.type || "",
|
|
2817
|
-
wallet_client_type: data.connector.name || ""
|
|
2818
|
-
};
|
|
2819
|
-
const res2 = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
|
|
2820
|
-
if (res2) {
|
|
2821
|
-
if (!isSuccess(res2)) {
|
|
2822
|
-
throw new Error(res2.message);
|
|
2823
|
-
}
|
|
2824
|
-
matchlog_default.log(res2);
|
|
2825
|
-
setStatus("success");
|
|
2826
|
-
statusRef.current = "success";
|
|
2827
|
-
if (type == "bind") {
|
|
2828
|
-
events.onBind && events.onBind({
|
|
2829
|
-
type: "evm"
|
|
2830
|
-
});
|
|
2831
|
-
eventManager_default.emit("onBind", {
|
|
2832
|
-
type: "evm"
|
|
2833
|
-
});
|
|
2834
|
-
} else {
|
|
2835
|
-
await login({
|
|
2836
|
-
mid: res2.data.mid,
|
|
2837
|
-
token: `${res2.data.token_type} ${res2.data.access_token}`
|
|
2838
|
-
});
|
|
2839
|
-
}
|
|
2840
|
-
onSuccess && onSuccess();
|
|
2841
|
-
}
|
|
2842
|
-
}
|
|
2843
|
-
} catch (error2) {
|
|
2844
|
-
setStatus("error");
|
|
2845
|
-
setError(error2.message);
|
|
2846
|
-
statusRef.current = "";
|
|
2847
|
-
}
|
|
2848
|
-
};
|
|
2849
|
-
const pageData = (0, import_react16.useMemo)(() => {
|
|
2850
|
-
if (status == "success") {
|
|
2851
|
-
return {
|
|
2852
|
-
btnText: "Disconnect Wallet",
|
|
2853
|
-
btnClick: () => {
|
|
2854
|
-
disconnect();
|
|
2855
|
-
},
|
|
2856
|
-
text: "Wallet connection successful!",
|
|
2857
|
-
statusImage: walletConnectedImage
|
|
2858
|
-
};
|
|
2859
|
-
}
|
|
2860
|
-
if (status == "error") {
|
|
2861
|
-
return {
|
|
2862
|
-
text: error,
|
|
2863
|
-
btnText: "Reconnect Wallet",
|
|
2864
|
-
btnClick: async () => {
|
|
2865
|
-
setError("");
|
|
2866
|
-
disconnect();
|
|
2867
|
-
openConnectModal && openConnectModal();
|
|
2868
|
-
},
|
|
2869
|
-
statusImage: walletErrorImage,
|
|
2870
|
-
isError: true
|
|
2871
|
-
};
|
|
2872
|
-
}
|
|
2873
|
-
if (status == "nonce") {
|
|
2874
|
-
return {
|
|
2875
|
-
btnLoading: true,
|
|
2876
|
-
text: "Connecting",
|
|
2877
|
-
statusImage: walletConnectingImage
|
|
2878
|
-
};
|
|
2879
|
-
}
|
|
2880
|
-
if (status == "signer") {
|
|
2881
|
-
return {
|
|
2882
|
-
btnLoading: true,
|
|
2883
|
-
text: "Signing",
|
|
2884
|
-
statusImage: walletSigningImage
|
|
2885
|
-
};
|
|
2886
|
-
}
|
|
2887
|
-
if (connectModalOpen) {
|
|
2888
|
-
return {
|
|
2889
|
-
btnLoading: true,
|
|
2890
|
-
text: "Connecting",
|
|
2891
|
-
statusImage: walletConnectingImage
|
|
2892
|
-
};
|
|
2893
|
-
}
|
|
2894
|
-
return {
|
|
2895
|
-
btnText: "Connect Wallet",
|
|
2896
|
-
btnClick: () => {
|
|
2897
|
-
openConnectModal && openConnectModal();
|
|
2898
|
-
},
|
|
2899
|
-
text: "Please Connect your wallet",
|
|
2900
|
-
statusImage: walletConnectImage
|
|
2901
|
-
};
|
|
2902
|
-
}, [connectModalOpen, status, error, address]);
|
|
2903
|
-
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "matchid-wallet-container", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: `matchid-wallet-box`, children: [
|
|
2904
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: `matchid-wallet-content`, children: [
|
|
2905
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("img", { src: pageData.statusImage }),
|
|
2906
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: pageData.isError ? "text-[#F7585E]" : "", children: pageData.text })
|
|
2907
|
-
] }),
|
|
2908
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
2909
|
-
Button,
|
|
2910
|
-
{
|
|
2911
|
-
block: true,
|
|
2912
|
-
size: "lg",
|
|
2913
|
-
onClick: pageData.btnClick,
|
|
2914
|
-
loading: pageData.btnLoading,
|
|
2915
|
-
disabled: pageData.btnDisabled,
|
|
2916
|
-
children: pageData.btnText
|
|
2917
|
-
}
|
|
2918
|
-
)
|
|
2919
|
-
] }) });
|
|
2920
|
-
}
|
|
2921
|
-
function EVMModal({
|
|
2922
|
-
type = "login",
|
|
2923
|
-
onSuccess,
|
|
2924
|
-
...props
|
|
2925
|
-
}) {
|
|
2926
|
-
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(ModalWithHeader, { ...props, title: props.title || firstUpperCase(type + " EVM Wallet"), children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_wagmi2.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_rainbowkit.RainbowKitProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(WalletContent2, { onSuccess, type }) }) }) });
|
|
2927
|
-
}
|
|
2928
|
-
|
|
2929
2496
|
// src/context/BusinessProvider.tsx
|
|
2930
|
-
var
|
|
2497
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
2931
2498
|
function BusinessProvider({ children }) {
|
|
2932
2499
|
const { overview, token } = useUserInfo();
|
|
2933
2500
|
const { recoveryModal } = useStore_default();
|
|
2934
|
-
const { type: EVMType, isOpen: EVMIsOpen, close: EVMClose } = useEVMModalStore();
|
|
2935
2501
|
const { type: SOLType, isOpen: SOLIsOpen, close: SOLClose } = useSOLModalStore();
|
|
2936
|
-
return /* @__PURE__ */ (0,
|
|
2937
|
-
/* @__PURE__ */ (0,
|
|
2938
|
-
/* @__PURE__ */ (0,
|
|
2502
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
|
|
2503
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PasswordModal, { isOpen: !!token && !!overview && !overview.address && !!overview.did, showClose: false }),
|
|
2504
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
2939
2505
|
RecoveryModal,
|
|
2940
2506
|
{
|
|
2941
2507
|
isOpen: !!token && !!overview && !!overview.address && recoveryModal.open,
|
|
@@ -2943,17 +2509,7 @@ function BusinessProvider({ children }) {
|
|
|
2943
2509
|
onSuccess: recoveryModal.success
|
|
2944
2510
|
}
|
|
2945
2511
|
),
|
|
2946
|
-
/* @__PURE__ */ (0,
|
|
2947
|
-
EVMModal,
|
|
2948
|
-
{
|
|
2949
|
-
isOpen: EVMIsOpen && (EVMType == "login" && !overview && !token || EVMType == "bind" && !!token && !!overview),
|
|
2950
|
-
onClose: EVMClose,
|
|
2951
|
-
type: EVMType,
|
|
2952
|
-
onSuccess: EVMClose,
|
|
2953
|
-
zIndex: 199
|
|
2954
|
-
}
|
|
2955
|
-
),
|
|
2956
|
-
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
2512
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
2957
2513
|
SOLModal,
|
|
2958
2514
|
{
|
|
2959
2515
|
isOpen: SOLIsOpen && (SOLType == "login" && !overview && !token || SOLType == "bind" && !!token && !!overview),
|
|
@@ -2968,17 +2524,17 @@ function BusinessProvider({ children }) {
|
|
|
2968
2524
|
}
|
|
2969
2525
|
|
|
2970
2526
|
// src/context/index.tsx
|
|
2971
|
-
var
|
|
2527
|
+
var import_jsx_runtime47 = (
|
|
2972
2528
|
// <MpcWalletProvider>
|
|
2973
2529
|
require("react/jsx-runtime")
|
|
2974
2530
|
);
|
|
2975
2531
|
var Providers = ({ children }) => {
|
|
2976
|
-
return /* @__PURE__ */ (0,
|
|
2532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(BusinessProvider, { children });
|
|
2977
2533
|
};
|
|
2978
2534
|
var context_default = Providers;
|
|
2979
2535
|
|
|
2980
2536
|
// src/hooks/useWalletInit.ts
|
|
2981
|
-
var
|
|
2537
|
+
var import_react16 = require("react");
|
|
2982
2538
|
var AppClientId2 = "react-sdk-" + getVersion();
|
|
2983
2539
|
function useWalletInit({
|
|
2984
2540
|
refreshOverview
|
|
@@ -2987,10 +2543,10 @@ function useWalletInit({
|
|
|
2987
2543
|
const getWalletIframe = () => {
|
|
2988
2544
|
return document.getElementById("match-wallet");
|
|
2989
2545
|
};
|
|
2990
|
-
const [walletInited, setWalletInited] = (0,
|
|
2546
|
+
const [walletInited, setWalletInited] = (0, import_react16.useState)(false);
|
|
2991
2547
|
const { appid, token, overview } = useLocalStore_default();
|
|
2992
2548
|
const { initWallet, generateWallet } = useWallet();
|
|
2993
|
-
(0,
|
|
2549
|
+
(0, import_react16.useEffect)(() => {
|
|
2994
2550
|
if (endpoints.auth) {
|
|
2995
2551
|
if (!window.matchWalletMessageIdMap) {
|
|
2996
2552
|
window.matchWalletMessageIdMap = {};
|
|
@@ -3048,7 +2604,7 @@ function useWalletInit({
|
|
|
3048
2604
|
}
|
|
3049
2605
|
}
|
|
3050
2606
|
}, [endpoints.auth]);
|
|
3051
|
-
(0,
|
|
2607
|
+
(0, import_react16.useEffect)(() => {
|
|
3052
2608
|
const messageHandle = async (e) => {
|
|
3053
2609
|
if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
|
|
3054
2610
|
return;
|
|
@@ -3081,7 +2637,7 @@ function useWalletInit({
|
|
|
3081
2637
|
window.removeEventListener("message", messageHandle);
|
|
3082
2638
|
};
|
|
3083
2639
|
}, []);
|
|
3084
|
-
(0,
|
|
2640
|
+
(0, import_react16.useEffect)(() => {
|
|
3085
2641
|
if (token && overview && overview.did && walletInited) {
|
|
3086
2642
|
const did = overview.did.split(":")[2];
|
|
3087
2643
|
const newUserInit = async () => {
|
|
@@ -3112,7 +2668,7 @@ function useWalletInit({
|
|
|
3112
2668
|
}
|
|
3113
2669
|
|
|
3114
2670
|
// src/hooks/useInit.tsx
|
|
3115
|
-
var
|
|
2671
|
+
var import_react17 = require("react");
|
|
3116
2672
|
function useInit({
|
|
3117
2673
|
theme,
|
|
3118
2674
|
appid,
|
|
@@ -3128,20 +2684,20 @@ function useInit({
|
|
|
3128
2684
|
setOverview,
|
|
3129
2685
|
setTheme
|
|
3130
2686
|
} = useLocalStore_default();
|
|
3131
|
-
const overviewLoadingRef = (0,
|
|
2687
|
+
const overviewLoadingRef = (0, import_react17.useRef)(false);
|
|
3132
2688
|
const searchParams = new URLSearchParams(window.location.search);
|
|
3133
2689
|
const matchToken = searchParams.get("matchToken");
|
|
3134
2690
|
const realEndpoints = endpoints || env_default.endpoints;
|
|
3135
|
-
(0,
|
|
2691
|
+
(0, import_react17.useEffect)(() => {
|
|
3136
2692
|
setTheme(theme);
|
|
3137
2693
|
}, [theme]);
|
|
3138
|
-
(0,
|
|
2694
|
+
(0, import_react17.useEffect)(() => {
|
|
3139
2695
|
setAppid(appid);
|
|
3140
2696
|
}, [appid]);
|
|
3141
|
-
(0,
|
|
2697
|
+
(0, import_react17.useEffect)(() => {
|
|
3142
2698
|
setEndpoints(realEndpoints);
|
|
3143
2699
|
}, [realEndpoints]);
|
|
3144
|
-
(0,
|
|
2700
|
+
(0, import_react17.useEffect)(() => {
|
|
3145
2701
|
if (matchToken) {
|
|
3146
2702
|
const tokenData = JSON.parse(atob(matchToken));
|
|
3147
2703
|
if (tokenData && tokenData.mid && tokenData.token) {
|
|
@@ -3152,7 +2708,7 @@ function useInit({
|
|
|
3152
2708
|
}
|
|
3153
2709
|
}
|
|
3154
2710
|
}, [matchToken]);
|
|
3155
|
-
(0,
|
|
2711
|
+
(0, import_react17.useEffect)(() => {
|
|
3156
2712
|
const onLoginMessage = (event) => {
|
|
3157
2713
|
const res = event.data;
|
|
3158
2714
|
if (res.event === "login" && res.data && (res.data.token || res.data.token_type && res.data.access_token)) {
|
|
@@ -3188,7 +2744,7 @@ function useInit({
|
|
|
3188
2744
|
overviewLoadingRef.current = false;
|
|
3189
2745
|
}
|
|
3190
2746
|
};
|
|
3191
|
-
(0,
|
|
2747
|
+
(0, import_react17.useEffect)(() => {
|
|
3192
2748
|
if (token) {
|
|
3193
2749
|
loadOverview();
|
|
3194
2750
|
}
|
|
@@ -3219,30 +2775,9 @@ function useInit({
|
|
|
3219
2775
|
|
|
3220
2776
|
// src/MatchContext.tsx
|
|
3221
2777
|
var import_react_query = require("@tanstack/react-query");
|
|
3222
|
-
var
|
|
3223
|
-
var import_rainbowkit2 = require("@rainbow-me/rainbowkit");
|
|
3224
|
-
var import_wallets2 = require("@rainbow-me/rainbowkit/wallets");
|
|
3225
|
-
var import_chains2 = require("wagmi/chains");
|
|
3226
|
-
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
2778
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
3227
2779
|
var queryClient = new import_react_query.QueryClient();
|
|
3228
|
-
var MatchContext = (0,
|
|
3229
|
-
var wagmiConfig2 = (0, import_rainbowkit2.getDefaultConfig)({
|
|
3230
|
-
appName: "Match Mid",
|
|
3231
|
-
projectId: "9ac6ea7e07860f04616fb311b447dee9",
|
|
3232
|
-
wallets: [
|
|
3233
|
-
{
|
|
3234
|
-
groupName: "Recommended",
|
|
3235
|
-
wallets: [
|
|
3236
|
-
import_wallets2.metaMaskWallet,
|
|
3237
|
-
import_wallets2.walletConnectWallet,
|
|
3238
|
-
import_wallets2.okxWallet,
|
|
3239
|
-
import_wallets2.bitgetWallet,
|
|
3240
|
-
import_wallets2.injectedWallet
|
|
3241
|
-
]
|
|
3242
|
-
}
|
|
3243
|
-
],
|
|
3244
|
-
chains: [import_chains2.mainnet, import_chains2.polygon, import_chains2.optimism, import_chains2.arbitrum, import_chains2.base, import_chains2.bsc]
|
|
3245
|
-
});
|
|
2780
|
+
var MatchContext = (0, import_react18.createContext)(void 0);
|
|
3246
2781
|
var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) => {
|
|
3247
2782
|
const { loadOverview, login, endpoints: realEndPoints } = useInit({
|
|
3248
2783
|
theme,
|
|
@@ -3253,7 +2788,7 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) =>
|
|
|
3253
2788
|
useWalletInit({
|
|
3254
2789
|
refreshOverview: loadOverview
|
|
3255
2790
|
});
|
|
3256
|
-
return /* @__PURE__ */ (0,
|
|
2791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
3257
2792
|
MatchContext.Provider,
|
|
3258
2793
|
{
|
|
3259
2794
|
value: {
|
|
@@ -3263,12 +2798,12 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) =>
|
|
|
3263
2798
|
login,
|
|
3264
2799
|
theme
|
|
3265
2800
|
},
|
|
3266
|
-
children: /* @__PURE__ */ (0,
|
|
2801
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(context_default, { children })
|
|
3267
2802
|
}
|
|
3268
|
-
) })
|
|
2803
|
+
) });
|
|
3269
2804
|
};
|
|
3270
2805
|
var useMatch = () => {
|
|
3271
|
-
const context = (0,
|
|
2806
|
+
const context = (0, import_react18.useContext)(MatchContext);
|
|
3272
2807
|
if (context === void 0) {
|
|
3273
2808
|
throw new Error("useMatch must be used within a MatchProvider");
|
|
3274
2809
|
}
|
|
@@ -3353,8 +2888,8 @@ __export(chains_exports, {
|
|
|
3353
2888
|
});
|
|
3354
2889
|
|
|
3355
2890
|
// src/config/chains/MatchMain.ts
|
|
3356
|
-
var
|
|
3357
|
-
var matchMain = /* @__PURE__ */ (0,
|
|
2891
|
+
var import_viem = require("viem");
|
|
2892
|
+
var matchMain = /* @__PURE__ */ (0, import_viem.defineChain)({
|
|
3358
2893
|
//定义match链
|
|
3359
2894
|
id: 698,
|
|
3360
2895
|
name: "Matchain",
|
|
@@ -3381,8 +2916,8 @@ var matchMain = /* @__PURE__ */ (0, import_viem3.defineChain)({
|
|
|
3381
2916
|
});
|
|
3382
2917
|
|
|
3383
2918
|
// src/config/chains/MatchTest.ts
|
|
3384
|
-
var
|
|
3385
|
-
var matchTest = /* @__PURE__ */ (0,
|
|
2919
|
+
var import_viem2 = require("viem");
|
|
2920
|
+
var matchTest = /* @__PURE__ */ (0, import_viem2.defineChain)({
|
|
3386
2921
|
//定义matchTest链
|
|
3387
2922
|
id: 699,
|
|
3388
2923
|
name: "MatchTest",
|