@matchain/matchid-sdk-react 0.1.48-alpha.1 → 0.1.48-alpha.2

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.js CHANGED
@@ -42,7 +42,7 @@ __export(src_exports, {
42
42
  module.exports = __toCommonJS(src_exports);
43
43
 
44
44
  // src/MatchContext.tsx
45
- var import_react32 = require("react");
45
+ var import_react34 = require("react");
46
46
 
47
47
  // src/hooks/index.tsx
48
48
  var hooks_exports = {};
@@ -53,6 +53,7 @@ __export(hooks_exports, {
53
53
  useMatchEvents: () => useMatchEvents,
54
54
  useMatchWallet: () => useMatchWallet,
55
55
  useModal: () => useModal,
56
+ useReceipt: () => useReceipt,
56
57
  useToast: () => useToast,
57
58
  useUserInfo: () => useUserInfo,
58
59
  useWallet: () => useWallet
@@ -297,11 +298,11 @@ var unBindApi = ({ type }) => {
297
298
  data: { type }
298
299
  });
299
300
  };
300
- var unBindWalletApi = ({ address }) => {
301
+ var unBindWalletApi = ({ address: address2 }) => {
301
302
  return request_default({
302
303
  url: `/api/v1/wallet/unbind`,
303
304
  method: "POST",
304
- data: { address }
305
+ data: { address: address2 }
305
306
  });
306
307
  };
307
308
  var verifyPohApi = ({
@@ -359,7 +360,7 @@ var getWalletNonceApi = (data) => {
359
360
  };
360
361
  var loginByWalletApi = ({
361
362
  type,
362
- address,
363
+ address: address2,
363
364
  signature,
364
365
  message,
365
366
  connector_type,
@@ -368,7 +369,7 @@ var loginByWalletApi = ({
368
369
  return request_default({
369
370
  url: `/api/v1/login/wallet`,
370
371
  method: "POST",
371
- data: { type, address, signature, message, connector_type, wallet_client_type }
372
+ data: { type, address: address2, signature, message, connector_type, wallet_client_type }
372
373
  });
373
374
  };
374
375
  var getWalletInitApi = (data) => {
@@ -380,7 +381,7 @@ var getWalletInitApi = (data) => {
380
381
  };
381
382
  var toBindWalletApi = ({
382
383
  type,
383
- address,
384
+ address: address2,
384
385
  signature,
385
386
  message,
386
387
  connector_type,
@@ -389,7 +390,7 @@ var toBindWalletApi = ({
389
390
  return request_default({
390
391
  url: `/api/v1/wallet/bind`,
391
392
  method: "POST",
392
- data: { type, address, signature, message, connector_type, wallet_client_type }
393
+ data: { type, address: address2, signature, message, connector_type, wallet_client_type }
393
394
  });
394
395
  };
395
396
  var getAppConfigApi = () => {
@@ -489,7 +490,7 @@ var persistedState = (0, import_middleware.persist)(
489
490
  setTheme: (theme) => set({ theme }),
490
491
  setEndpoints: (endpoints) => set({ endpoints }),
491
492
  address: "",
492
- setAddress: (address) => set({ address }),
493
+ setAddress: (address2) => set({ address: address2 }),
493
494
  locale: "en",
494
495
  setLocale: (locale) => set({ locale }),
495
496
  wallet: {
@@ -549,12 +550,12 @@ var isValidEmail = (email) => {
549
550
  var isValidUsername = (username) => {
550
551
  return /^[a-zA-Z0-9_-]+$/.test(username);
551
552
  };
552
- function truncateAddress(address) {
553
- if (address.length <= 6) {
554
- return address;
553
+ function truncateAddress(address2) {
554
+ if (address2.length <= 6) {
555
+ return address2;
555
556
  }
556
- const start = address.slice(0, 4);
557
- const end = address.slice(-2);
557
+ const start = address2.slice(0, 4);
558
+ const end = address2.slice(-2);
558
559
  return `${start}...${end}`;
559
560
  }
560
561
  function getAppClientId() {
@@ -1751,7 +1752,7 @@ function useUserInfo() {
1751
1752
  logout: logoutStore,
1752
1753
  setOverview,
1753
1754
  overview,
1754
- address,
1755
+ address: address2,
1755
1756
  endpoints,
1756
1757
  locale,
1757
1758
  refreshOverview
@@ -1979,7 +1980,7 @@ function useUserInfo() {
1979
1980
  token,
1980
1981
  mid,
1981
1982
  did,
1982
- address,
1983
+ address: address2,
1983
1984
  isLogin,
1984
1985
  logout,
1985
1986
  getLoginEmailCode,
@@ -2043,7 +2044,7 @@ var import_react4 = require("react");
2043
2044
  var import_viem3 = require("viem");
2044
2045
  var AppClientId = "react-sdk-" + getVersion();
2045
2046
  function useWallet() {
2046
- const { address, wallet: walletConfig } = useLocalStore_default();
2047
+ const { address: address2, wallet: walletConfig } = useLocalStore_default();
2047
2048
  const { walletReady } = useStore_default();
2048
2049
  const { open: openHashPanel } = useHashPanelStore();
2049
2050
  const isRecovered = async () => {
@@ -2091,8 +2092,8 @@ function useWallet() {
2091
2092
  }
2092
2093
  };
2093
2094
  const evmAccount = (0, import_react4.useMemo)(() => {
2094
- return address ? (0, import_accounts.toAccount)({
2095
- address,
2095
+ return address2 ? (0, import_accounts.toAccount)({
2096
+ address: address2,
2096
2097
  async signMessage({ message }) {
2097
2098
  return await signMessage2({
2098
2099
  message,
@@ -2123,7 +2124,7 @@ function useWallet() {
2123
2124
  return "0x";
2124
2125
  }
2125
2126
  }) : void 0;
2126
- }, [address]);
2127
+ }, [address2]);
2127
2128
  (0, import_react4.useEffect)(() => {
2128
2129
  matchlog_default.log("qwe-evmAccount", evmAccount);
2129
2130
  }, [evmAccount]);
@@ -2216,7 +2217,7 @@ function useWallet() {
2216
2217
  });
2217
2218
  };
2218
2219
  const writeContract = async (parameters2) => {
2219
- const { abi, address: address2, args, dataSuffix, functionName, ...request3 } = parameters2;
2220
+ const { abi, address: address3, args, dataSuffix, functionName, ...request3 } = parameters2;
2220
2221
  const data = (0, import_viem.encodeFunctionData)({
2221
2222
  abi,
2222
2223
  args,
@@ -2224,7 +2225,7 @@ function useWallet() {
2224
2225
  });
2225
2226
  return await sendTransaction({
2226
2227
  data: `${data}${dataSuffix ? dataSuffix.replace("0x", "") : ""}`,
2227
- to: address2,
2228
+ to: address3,
2228
2229
  ...request3
2229
2230
  });
2230
2231
  };
@@ -2238,7 +2239,7 @@ function useWallet() {
2238
2239
  return {
2239
2240
  walletReady,
2240
2241
  evmAccount,
2241
- address,
2242
+ address: address2,
2242
2243
  signMessage: signMessage2,
2243
2244
  signTransaction,
2244
2245
  isRecovered,
@@ -3520,7 +3521,7 @@ function ProfileIcon({ size = 24, color = "black", ...props }) {
3520
3521
  var import_react_intl6 = require("react-intl");
3521
3522
  var import_jsx_runtime68 = require("react/jsx-runtime");
3522
3523
  function UserContent() {
3523
- const { logout, address, username } = useUserInfo();
3524
+ const { logout, address: address2, username } = useUserInfo();
3524
3525
  const [logouting, setLogouting] = (0, import_react18.useState)(false);
3525
3526
  const onLogout = async () => {
3526
3527
  if (logouting) return;
@@ -3556,8 +3557,8 @@ function UserContent() {
3556
3557
  return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "matchid-user-popover-content", children: [
3557
3558
  /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "matchid-user-popover-list", children: [
3558
3559
  /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(UserItem, { onClick: () => {
3559
- setCopied(address);
3560
- }, icon: copied ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(CheckIcon, { size: 20, color: "#0ecb81" }) : /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(CopyIcon, { size: 20, color: "var(--icon-color)" }), rightIcon: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(CheckIcon, { size: 20, color: "var(--icon-color)" }), children: truncateAddress(address) }),
3560
+ setCopied(address2);
3561
+ }, icon: copied ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(CheckIcon, { size: 20, color: "#0ecb81" }) : /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(CopyIcon, { size: 20, color: "var(--icon-color)" }), rightIcon: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(CheckIcon, { size: 20, color: "var(--icon-color)" }), children: truncateAddress(address2) }),
3561
3562
  /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(UserDivider, {}),
3562
3563
  /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(UserItem, { onClick: () => {
3563
3564
  setUsernameOpen(true);
@@ -3784,7 +3785,7 @@ function WalletModalContent({
3784
3785
  setError,
3785
3786
  setVisible,
3786
3787
  visible,
3787
- address,
3788
+ address: address2,
3788
3789
  connected
3789
3790
  }) {
3790
3791
  const pageData = (0, import_react21.useMemo)(() => {
@@ -3845,7 +3846,7 @@ function WalletModalContent({
3845
3846
  text: "Please Connect your wallet",
3846
3847
  statusImage: walletConnectImage
3847
3848
  };
3848
- }, [visible, connected, status, error, address]);
3849
+ }, [visible, connected, status, error, address2]);
3849
3850
  return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "matchid-wallet-container", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: `matchid-wallet-box`, children: [
3850
3851
  /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: `matchid-wallet-content`, children: [
3851
3852
  /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("img", { src: pageData.statusImage }),
@@ -3892,14 +3893,14 @@ function WalletContent({
3892
3893
  }, [wallet.connected]);
3893
3894
  const toLoginInWallet = async () => {
3894
3895
  if (statusRef.current) return;
3895
- const address = wallet.publicKey?.toBase58() || "";
3896
+ const address2 = wallet.publicKey?.toBase58() || "";
3896
3897
  try {
3897
3898
  setStatus("nonce");
3898
3899
  statusRef.current = "nonce";
3899
3900
  const res = type == "bind" ? await getWalletInitApi({
3900
- address,
3901
+ address: address2,
3901
3902
  type: "SOL"
3902
- }) : await getWalletNonceApi({ address, type: "SOL" });
3903
+ }) : await getWalletNonceApi({ address: address2, type: "SOL" });
3903
3904
  if (!isSuccess(res)) {
3904
3905
  throw new Error(res.message);
3905
3906
  }
@@ -3912,7 +3913,7 @@ function WalletContent({
3912
3913
  const signedMessage = await wallet.signMessage(encodedMessage);
3913
3914
  let obj = {
3914
3915
  type: "SOL",
3915
- address,
3916
+ address: address2,
3916
3917
  signature: Buffer.from(signedMessage).toString("base64"),
3917
3918
  message,
3918
3919
  connector_type: "SOL",
@@ -4100,7 +4101,7 @@ var OKXAdapter = class {
4100
4101
  var useTRONWallet = () => {
4101
4102
  const wallets2 = [new TronLinkAdapter(), new BitgetAdapter(), new OKXAdapter()];
4102
4103
  const [installedWallets, setInstalledWallets] = (0, import_react23.useState)([]);
4103
- const [address, setAddress] = (0, import_react23.useState)(null);
4104
+ const [address2, setAddress] = (0, import_react23.useState)(null);
4104
4105
  (0, import_react23.useEffect)(() => {
4105
4106
  const getInstalled = async () => {
4106
4107
  const installed = await Promise.all(wallets2.map((wallet2) => wallet2.isInstalled().then((isInstalled) => ({
@@ -4125,7 +4126,7 @@ var useTRONWallet = () => {
4125
4126
  wallets: wallets2,
4126
4127
  chooseWallet,
4127
4128
  wallet,
4128
- address,
4129
+ address: address2,
4129
4130
  onConnect
4130
4131
  };
4131
4132
  };
@@ -4139,7 +4140,7 @@ function TRONConnectModal({
4139
4140
  }) {
4140
4141
  const isDownMd = useDownMd();
4141
4142
  const intl = (0, import_react_intl10.useIntl)();
4142
- const { wallets: wallets2, installedWallets, chooseWallet, wallet, address, onConnect } = useTRONWallet();
4143
+ const { wallets: wallets2, installedWallets, chooseWallet, wallet, address: address2, onConnect } = useTRONWallet();
4143
4144
  const iconMaps = {
4144
4145
  tronlink: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(TronLinkIcon, { size: isDownMd ? 36 : 40 }),
4145
4146
  bitget: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(BitgetIcon, { size: isDownMd ? 36 : 40 }),
@@ -4150,8 +4151,8 @@ function TRONConnectModal({
4150
4151
  const statusRef = import_react24.default.useRef(status);
4151
4152
  const [error, setError] = (0, import_react24.useState)("");
4152
4153
  const connected = (0, import_react24.useMemo)(() => {
4153
- return !!address;
4154
- }, [address]);
4154
+ return !!address2;
4155
+ }, [address2]);
4155
4156
  const disconnect = async () => {
4156
4157
  setStatus("");
4157
4158
  chooseWallet(null);
@@ -4165,11 +4166,11 @@ function TRONConnectModal({
4165
4166
  setError("");
4166
4167
  };
4167
4168
  const toLoginInWallet = async () => {
4168
- if (statusRef.current || !address || !wallet) return;
4169
+ if (statusRef.current || !address2 || !wallet) return;
4169
4170
  try {
4170
4171
  setStatus("nonce");
4171
4172
  statusRef.current = "nonce";
4172
- const res = type == "bind" ? await getWalletInitApi({ address, type: "TRON" }) : await getWalletNonceApi({ address, type: "TRON" });
4173
+ const res = type == "bind" ? await getWalletInitApi({ address: address2, type: "TRON" }) : await getWalletNonceApi({ address: address2, type: "TRON" });
4173
4174
  if (!isSuccess(res)) {
4174
4175
  throw new Error(res.message);
4175
4176
  }
@@ -4181,7 +4182,7 @@ function TRONConnectModal({
4181
4182
  const signedMessage = await wallet.signMessage(message);
4182
4183
  let obj = {
4183
4184
  type: "TRON",
4184
- address,
4185
+ address: address2,
4185
4186
  signature: signedMessage,
4186
4187
  message,
4187
4188
  connector_type: "TRON",
@@ -4226,10 +4227,10 @@ function TRONConnectModal({
4226
4227
  }
4227
4228
  }, [wallet]);
4228
4229
  (0, import_react24.useEffect)(() => {
4229
- if (address) {
4230
+ if (address2) {
4230
4231
  toLoginInWallet();
4231
4232
  }
4232
- }, [address]);
4233
+ }, [address2]);
4233
4234
  (0, import_react24.useEffect)(() => {
4234
4235
  if (!props.isOpen) {
4235
4236
  disconnect();
@@ -4246,7 +4247,7 @@ function TRONConnectModal({
4246
4247
  setError,
4247
4248
  status,
4248
4249
  disconnect,
4249
- address: address || "",
4250
+ address: address2 || "",
4250
4251
  connected,
4251
4252
  visible: true,
4252
4253
  setVisible: () => {
@@ -4555,7 +4556,7 @@ var XverseAdapter = class {
4555
4556
  matchlog_default.log("getAccounts ~ response:", response);
4556
4557
  if (response.status === "success") {
4557
4558
  const ordinalsAddressItem = response.result.find(
4558
- (address) => address.purpose === import_sats_connect.AddressPurpose.Ordinals
4559
+ (address2) => address2.purpose === import_sats_connect.AddressPurpose.Ordinals
4559
4560
  );
4560
4561
  this.address = ordinalsAddressItem?.address || "";
4561
4562
  return ordinalsAddressItem?.address || "";
@@ -4622,7 +4623,7 @@ var import_react26 = require("react");
4622
4623
  var useBTCWallet = () => {
4623
4624
  const wallets2 = [new UnisatAdapter(), new XverseAdapter(), new LeatherAdapter()];
4624
4625
  const [installedWallets, setInstalledWallets] = (0, import_react26.useState)([]);
4625
- const [address, setAddress] = (0, import_react26.useState)(null);
4626
+ const [address2, setAddress] = (0, import_react26.useState)(null);
4626
4627
  (0, import_react26.useEffect)(() => {
4627
4628
  const getInstalled = async () => {
4628
4629
  const installed = await Promise.all(wallets2.map((wallet2) => wallet2.isInstalled().then((isInstalled) => ({
@@ -4647,7 +4648,7 @@ var useBTCWallet = () => {
4647
4648
  wallets: wallets2,
4648
4649
  chooseWallet,
4649
4650
  wallet,
4650
- address,
4651
+ address: address2,
4651
4652
  onConnect
4652
4653
  };
4653
4654
  };
@@ -4661,7 +4662,7 @@ function BTCConnectModal({
4661
4662
  }) {
4662
4663
  const isDownMd = useDownMd();
4663
4664
  const intl = (0, import_react_intl12.useIntl)();
4664
- const { wallets: wallets2, installedWallets, chooseWallet, wallet, address, onConnect } = useBTCWallet();
4665
+ const { wallets: wallets2, installedWallets, chooseWallet, wallet, address: address2, onConnect } = useBTCWallet();
4665
4666
  const iconMaps = {
4666
4667
  leather: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(LeatherIcon, { size: isDownMd ? 36 : 40 }),
4667
4668
  unisat: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(UnisatIcon, { size: isDownMd ? 36 : 40 }),
@@ -4672,8 +4673,8 @@ function BTCConnectModal({
4672
4673
  const statusRef = import_react27.default.useRef(status);
4673
4674
  const [error, setError] = (0, import_react27.useState)("");
4674
4675
  const connected = (0, import_react27.useMemo)(() => {
4675
- return !!address;
4676
- }, [address]);
4676
+ return !!address2;
4677
+ }, [address2]);
4677
4678
  const disconnect = async () => {
4678
4679
  wallet && wallet.disconnet && wallet.disconnet();
4679
4680
  setStatus("");
@@ -4682,11 +4683,11 @@ function BTCConnectModal({
4682
4683
  setError("");
4683
4684
  };
4684
4685
  const toLoginInWallet = async () => {
4685
- if (statusRef.current || !address || !wallet) return;
4686
+ if (statusRef.current || !address2 || !wallet) return;
4686
4687
  try {
4687
4688
  setStatus("nonce");
4688
4689
  statusRef.current = "nonce";
4689
- const res = type == "bind" ? await getWalletInitApi({ address, type: "BTC" }) : await getWalletNonceApi({ address, type: "BTC" });
4690
+ const res = type == "bind" ? await getWalletInitApi({ address: address2, type: "BTC" }) : await getWalletNonceApi({ address: address2, type: "BTC" });
4690
4691
  if (!isSuccess(res)) {
4691
4692
  throw new Error(res.message);
4692
4693
  }
@@ -4698,7 +4699,7 @@ function BTCConnectModal({
4698
4699
  const signedMessage = await wallet.signMessage(message);
4699
4700
  let obj = {
4700
4701
  type: "BTC",
4701
- address,
4702
+ address: address2,
4702
4703
  signature: signedMessage,
4703
4704
  message,
4704
4705
  connector_type: "BTC",
@@ -4749,10 +4750,10 @@ function BTCConnectModal({
4749
4750
  }
4750
4751
  }, [wallet]);
4751
4752
  (0, import_react27.useEffect)(() => {
4752
- if (address) {
4753
+ if (address2) {
4753
4754
  toLoginInWallet();
4754
4755
  }
4755
- }, [address]);
4756
+ }, [address2]);
4756
4757
  (0, import_react27.useEffect)(() => {
4757
4758
  if (!props.isOpen) {
4758
4759
  disconnect();
@@ -4776,7 +4777,7 @@ function BTCConnectModal({
4776
4777
  setError,
4777
4778
  status,
4778
4779
  disconnect,
4779
- address: address || "",
4780
+ address: address2 || "",
4780
4781
  connected,
4781
4782
  visible: true,
4782
4783
  setVisible: () => {
@@ -4863,19 +4864,20 @@ function WalletModal(props) {
4863
4864
 
4864
4865
  // src/hooks/useMatchWallet.tsx
4865
4866
  var import_react_qrcode = require("react-qrcode");
4867
+ var import_react29 = require("react");
4866
4868
  var import_jsx_runtime78 = require("react/jsx-runtime");
4867
4869
  function useMatchWallet() {
4868
4870
  const modal = useModal();
4869
- const { address } = useWallet();
4871
+ const { address: address2 } = useWallet();
4870
4872
  const chain = useMatchChain();
4871
4873
  const [copied, setCopied] = useCopyClipboard();
4872
4874
  const toast = useToast();
4873
4875
  const onCopy = () => {
4874
- setCopied(address);
4876
+ setCopied(address2);
4875
4877
  toast.success("Copied!");
4876
4878
  };
4877
4879
  const showReceiveModal = () => {
4878
- const chainLink = chain.explorerLink("address/" + address);
4880
+ const chainLink = chain.explorerLink("address/" + address2);
4879
4881
  const ReceiveModal = () => {
4880
4882
  return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: `matchid-receive-modal`, children: [
4881
4883
  /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "matchid-receive-container", children: [
@@ -4885,7 +4887,7 @@ function useMatchWallet() {
4885
4887
  {
4886
4888
  margin: "0",
4887
4889
  className: `matchid-qr-code`,
4888
- value: address
4890
+ value: address2
4889
4891
  }
4890
4892
  ) }),
4891
4893
  /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
@@ -4894,7 +4896,7 @@ function useMatchWallet() {
4894
4896
  href: chainLink,
4895
4897
  target: "_blank",
4896
4898
  className: `matchid-receive-link`,
4897
- children: address
4899
+ children: address2
4898
4900
  }
4899
4901
  )
4900
4902
  ] }),
@@ -4911,8 +4913,153 @@ function useMatchWallet() {
4911
4913
  };
4912
4914
  }
4913
4915
 
4916
+ // src/hooks/useReceipt.tsx
4917
+ var import_react30 = require("react");
4918
+ var import_react_query4 = require("@tanstack/react-query");
4919
+ var import_viem5 = require("viem");
4920
+ var CACHE_TTL = 86400 * 30 * 1e3;
4921
+ var MAX_CACHE_SIZE = 500;
4922
+ var STORAGE_KEY = "match_receipt_logs";
4923
+ function useReceiptCache() {
4924
+ const [cache, setCache] = (0, import_react30.useState)(/* @__PURE__ */ new Map());
4925
+ const isLocalStorageAvailable = (() => {
4926
+ try {
4927
+ const testKey = "__test__";
4928
+ localStorage.setItem(testKey, "1");
4929
+ localStorage.removeItem(testKey);
4930
+ return true;
4931
+ } catch (e) {
4932
+ return false;
4933
+ }
4934
+ })();
4935
+ (0, import_react30.useEffect)(() => {
4936
+ if (isLocalStorageAvailable) {
4937
+ try {
4938
+ const storedData = localStorage.getItem(STORAGE_KEY);
4939
+ if (storedData) {
4940
+ try {
4941
+ const parsed = JSON.parse(storedData);
4942
+ const now = Date.now();
4943
+ const validEntries = Object.entries(parsed).filter(([_, entry]) => typeof entry === "object" && entry !== null && "timestamp" in entry && now - entry.timestamp <= CACHE_TTL).map(([key, entry]) => [key, entry]);
4944
+ setCache(new Map(validEntries));
4945
+ } catch (e) {
4946
+ console.error("Failed to parse cache from localStorage:", e);
4947
+ }
4948
+ }
4949
+ } catch (e) {
4950
+ console.error("Failed to load cache from localStorage:", e);
4951
+ }
4952
+ }
4953
+ }, []);
4954
+ const updateLocalStorage = (0, import_react30.useCallback)((updatedCache) => {
4955
+ if (isLocalStorageAvailable) {
4956
+ try {
4957
+ const storedData = localStorage.getItem(STORAGE_KEY);
4958
+ let parsed = {};
4959
+ if (storedData) {
4960
+ parsed = JSON.parse(storedData);
4961
+ }
4962
+ updatedCache.forEach((entry, key) => {
4963
+ parsed[key] = entry;
4964
+ });
4965
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(parsed));
4966
+ } catch (e) {
4967
+ console.error("Failed to update localStorage:", e);
4968
+ }
4969
+ }
4970
+ }, []);
4971
+ const set = (0, import_react30.useCallback)((key, value) => {
4972
+ const now = Date.now();
4973
+ const newCache = new Map(cache);
4974
+ newCache.forEach((entry, k) => {
4975
+ if (now - entry.timestamp > CACHE_TTL) {
4976
+ newCache.delete(k);
4977
+ }
4978
+ });
4979
+ if (newCache.size >= MAX_CACHE_SIZE) {
4980
+ const firstKey = newCache.keys().next().value;
4981
+ if (firstKey !== void 0) {
4982
+ newCache.delete(firstKey);
4983
+ }
4984
+ }
4985
+ newCache.set(key, { value, timestamp: now });
4986
+ setCache(newCache);
4987
+ updateLocalStorage(newCache);
4988
+ }, [cache, updateLocalStorage]);
4989
+ const get = (0, import_react30.useCallback)((key) => {
4990
+ const entry = cache.get(key);
4991
+ if (entry) {
4992
+ if (Date.now() - entry.timestamp > CACHE_TTL) {
4993
+ const newCache = new Map(cache);
4994
+ newCache.delete(key);
4995
+ setCache(newCache);
4996
+ updateLocalStorage(newCache);
4997
+ return void 0;
4998
+ }
4999
+ return entry.value;
5000
+ }
5001
+ return void 0;
5002
+ }, [cache, updateLocalStorage]);
5003
+ const del = (0, import_react30.useCallback)((key) => {
5004
+ if (cache.has(key)) {
5005
+ const newCache = new Map(cache);
5006
+ newCache.delete(key);
5007
+ setCache(newCache);
5008
+ updateLocalStorage(newCache);
5009
+ }
5010
+ }, [cache, updateLocalStorage]);
5011
+ const clear = (0, import_react30.useCallback)(() => {
5012
+ setCache(/* @__PURE__ */ new Map());
5013
+ if (isLocalStorageAvailable) {
5014
+ localStorage.removeItem(STORAGE_KEY);
5015
+ }
5016
+ }, [isLocalStorageAvailable]);
5017
+ return { set, get, del, clear };
5018
+ }
5019
+ function useReceipt({
5020
+ chainId,
5021
+ hash
5022
+ }) {
5023
+ const { list } = useMatchChain();
5024
+ const cache = useReceiptCache();
5025
+ const chain = list?.find((item) => item.id === chainId);
5026
+ const [shouldRefetch, setShouldRefetch] = (0, import_react30.useState)(true);
5027
+ const query = (0, import_react_query4.useQuery)({
5028
+ queryKey: ["match-tx-receipt", hash, chain],
5029
+ queryFn: async () => {
5030
+ if (!chain || !hash) return false;
5031
+ const cacheKey = `${chain.id}-${hash}`;
5032
+ if (cache.get(cacheKey)) {
5033
+ return cache.get(cacheKey);
5034
+ }
5035
+ try {
5036
+ const publicClient = (0, import_viem5.createPublicClient)({
5037
+ //@ts-ignore
5038
+ chain: (0, import_viem5.defineChain)(chain),
5039
+ transport: (0, import_viem5.http)()
5040
+ });
5041
+ const receipt = await publicClient.getTransaction({ hash });
5042
+ if (!receipt) {
5043
+ return false;
5044
+ }
5045
+ cache.set(cacheKey, receipt);
5046
+ return receipt;
5047
+ } catch (e) {
5048
+ return false;
5049
+ }
5050
+ },
5051
+ refetchInterval: shouldRefetch ? 1e4 : false
5052
+ });
5053
+ (0, import_react30.useEffect)(() => {
5054
+ if (query.data) {
5055
+ setShouldRefetch(false);
5056
+ }
5057
+ }, [query.data]);
5058
+ return query;
5059
+ }
5060
+
4914
5061
  // src/components/CEXBindModal/index.tsx
4915
- var import_react29 = require("react");
5062
+ var import_react31 = require("react");
4916
5063
  var import_react_intl14 = require("react-intl");
4917
5064
  var import_jsx_runtime79 = require("react/jsx-runtime");
4918
5065
  function CEXBindModal({
@@ -4923,16 +5070,16 @@ function CEXBindModal({
4923
5070
  }) {
4924
5071
  const intl = (0, import_react_intl14.useIntl)();
4925
5072
  const { events } = useMatch();
4926
- const [APIPassphrase, setAPIPassphrase] = (0, import_react29.useState)("");
5073
+ const [APIPassphrase, setAPIPassphrase] = (0, import_react31.useState)("");
4927
5074
  const { refreshOverview } = useUserInfo();
4928
- const [loading, setLoading] = (0, import_react29.useState)(false);
4929
- const [key, setKey] = (0, import_react29.useState)("");
4930
- const [secret, setSecret] = (0, import_react29.useState)("");
4931
- const [error, setError] = (0, import_react29.useState)("");
4932
- const needPassphrase = (0, import_react29.useMemo)(() => {
5075
+ const [loading, setLoading] = (0, import_react31.useState)(false);
5076
+ const [key, setKey] = (0, import_react31.useState)("");
5077
+ const [secret, setSecret] = (0, import_react31.useState)("");
5078
+ const [error, setError] = (0, import_react31.useState)("");
5079
+ const needPassphrase = (0, import_react31.useMemo)(() => {
4933
5080
  return ["bitget", "okx"].includes(type.toLowerCase());
4934
5081
  }, [type]);
4935
- (0, import_react29.useEffect)(() => {
5082
+ (0, import_react31.useEffect)(() => {
4936
5083
  if (isOpen) {
4937
5084
  setSecret("");
4938
5085
  setKey("");
@@ -5112,7 +5259,7 @@ var Providers = ({ children }) => {
5112
5259
  var context_default = Providers;
5113
5260
 
5114
5261
  // src/hooks/useWalletInit.ts
5115
- var import_react30 = require("react");
5262
+ var import_react32 = require("react");
5116
5263
 
5117
5264
  // src/utils/wallet.ts
5118
5265
  var sendMessage = ({ method, data, resolve, reject, timeout }) => {
@@ -5145,11 +5292,11 @@ function useWalletInit({
5145
5292
  }) {
5146
5293
  const { endpoints, token, overview, setWallet, wallet, appid, locale, refreshOverview } = useLocalStore_default();
5147
5294
  const { setWalletReady, walletReady } = useStore_default();
5148
- const iframeReadyRef = (0, import_react30.useRef)(walletReady);
5149
- (0, import_react30.useEffect)(() => {
5295
+ const iframeReadyRef = (0, import_react32.useRef)(walletReady);
5296
+ (0, import_react32.useEffect)(() => {
5150
5297
  setWallet(config);
5151
5298
  }, [config]);
5152
- (0, import_react30.useEffect)(() => {
5299
+ (0, import_react32.useEffect)(() => {
5153
5300
  matchlog_default.log("sdk.mpc.status", walletReady, iframeReadyRef.current);
5154
5301
  iframeReadyRef.current = walletReady;
5155
5302
  if (iframeReadyRef.current) {
@@ -5166,7 +5313,7 @@ function useWalletInit({
5166
5313
  onReady();
5167
5314
  }
5168
5315
  }, [walletReady]);
5169
- (0, import_react30.useEffect)(() => {
5316
+ (0, import_react32.useEffect)(() => {
5170
5317
  if (!endpoints.auth || !appid || !token || !config) {
5171
5318
  const existingIframe = getWalletIframe();
5172
5319
  if (existingIframe) {
@@ -5266,7 +5413,7 @@ function useWalletInit({
5266
5413
  }
5267
5414
  }
5268
5415
  }, [endpoints.auth, appid, token, config]);
5269
- (0, import_react30.useEffect)(() => {
5416
+ (0, import_react32.useEffect)(() => {
5270
5417
  const messageHandle = async (e) => {
5271
5418
  if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
5272
5419
  return;
@@ -5347,7 +5494,7 @@ function useWalletInit({
5347
5494
  }
5348
5495
 
5349
5496
  // src/hooks/useInit.tsx
5350
- var import_react31 = require("react");
5497
+ var import_react33 = require("react");
5351
5498
  function useInit({
5352
5499
  theme,
5353
5500
  appid,
@@ -5367,23 +5514,23 @@ function useInit({
5367
5514
  locale: realLocale
5368
5515
  } = useLocalStore_default();
5369
5516
  const walletModalStore = useWalletModalStore();
5370
- const overviewLoadingRef = (0, import_react31.useRef)(false);
5517
+ const overviewLoadingRef = (0, import_react33.useRef)(false);
5371
5518
  const searchParams = new URLSearchParams(window.location.search);
5372
5519
  const matchToken = searchParams.get("matchToken");
5373
5520
  const realEndpoints = endpoints || env_default.endpoints;
5374
- (0, import_react31.useEffect)(() => {
5521
+ (0, import_react33.useEffect)(() => {
5375
5522
  setTheme(theme);
5376
5523
  }, [theme]);
5377
- (0, import_react31.useEffect)(() => {
5524
+ (0, import_react33.useEffect)(() => {
5378
5525
  setAppid(appid);
5379
5526
  }, [appid]);
5380
- (0, import_react31.useEffect)(() => {
5527
+ (0, import_react33.useEffect)(() => {
5381
5528
  setEndpoints(realEndpoints);
5382
5529
  }, [realEndpoints]);
5383
- (0, import_react31.useEffect)(() => {
5530
+ (0, import_react33.useEffect)(() => {
5384
5531
  setLocale(locale || "en");
5385
5532
  }, [locale]);
5386
- (0, import_react31.useEffect)(() => {
5533
+ (0, import_react33.useEffect)(() => {
5387
5534
  if (matchToken) {
5388
5535
  const tokenData = JSON.parse(atob(matchToken));
5389
5536
  if (tokenData && tokenData.mid && tokenData.token) {
@@ -5394,7 +5541,7 @@ function useInit({
5394
5541
  }
5395
5542
  }
5396
5543
  }, [matchToken]);
5397
- (0, import_react31.useEffect)(() => {
5544
+ (0, import_react33.useEffect)(() => {
5398
5545
  const onLoginMessage = (event) => {
5399
5546
  const res = event.data;
5400
5547
  if (res.event === "login" && res.data && (res.data.token || res.data.token_type && res.data.access_token)) {
@@ -5431,7 +5578,7 @@ function useInit({
5431
5578
  overviewLoadingRef.current = false;
5432
5579
  }
5433
5580
  };
5434
- (0, import_react31.useEffect)(() => {
5581
+ (0, import_react33.useEffect)(() => {
5435
5582
  if (token) {
5436
5583
  loadOverview();
5437
5584
  }
@@ -5462,7 +5609,7 @@ function useInit({
5462
5609
  }
5463
5610
 
5464
5611
  // src/MatchContext.tsx
5465
- var import_react_query4 = require("@tanstack/react-query");
5612
+ var import_react_query5 = require("@tanstack/react-query");
5466
5613
  var import_react_intl15 = require("react-intl");
5467
5614
 
5468
5615
  // src/i18n/en.json
@@ -5948,8 +6095,8 @@ var messages = {
5948
6095
 
5949
6096
  // src/MatchContext.tsx
5950
6097
  var import_jsx_runtime82 = require("react/jsx-runtime");
5951
- var queryClient = new import_react_query4.QueryClient();
5952
- var MatchContext = (0, import_react32.createContext)(void 0);
6098
+ var queryClient = new import_react_query5.QueryClient();
6099
+ var MatchContext = (0, import_react34.createContext)(void 0);
5953
6100
  var MatchProvider = ({
5954
6101
  children,
5955
6102
  appid,
@@ -5969,7 +6116,7 @@ var MatchProvider = ({
5969
6116
  useWalletInit({
5970
6117
  config: wallet
5971
6118
  });
5972
- return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_react_intl15.IntlProvider, { locale: realLocale, messages: messages[realLocale], children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_react_query4.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
6119
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_react_intl15.IntlProvider, { locale: realLocale, messages: messages[realLocale], children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_react_query5.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
5973
6120
  MatchContext.Provider,
5974
6121
  {
5975
6122
  value: {
@@ -5985,7 +6132,7 @@ var MatchProvider = ({
5985
6132
  ) }) });
5986
6133
  };
5987
6134
  var useMatch = () => {
5988
- const context = (0, import_react32.useContext)(MatchContext);
6135
+ const context = (0, import_react34.useContext)(MatchContext);
5989
6136
  if (context === void 0) {
5990
6137
  throw new Error("useMatch must be used within a MatchProvider");
5991
6138
  }
@@ -6011,10 +6158,10 @@ __export(bind_exports, {
6011
6158
  useBindInfo: () => useBindInfo,
6012
6159
  useBindList: () => useBindList
6013
6160
  });
6014
- var import_react_query5 = require("@tanstack/react-query");
6161
+ var import_react_query6 = require("@tanstack/react-query");
6015
6162
  function useBindList(options) {
6016
6163
  const { isLogin } = useUserInfo();
6017
- return (0, import_react_query5.useQuery)({
6164
+ return (0, import_react_query6.useQuery)({
6018
6165
  queryKey: ["bindList"],
6019
6166
  enabled: isLogin,
6020
6167
  queryFn: async () => {
@@ -6026,7 +6173,7 @@ function useBindList(options) {
6026
6173
  }
6027
6174
  function useBindInfo(options) {
6028
6175
  const { isLogin } = useUserInfo();
6029
- return (0, import_react_query5.useQuery)({
6176
+ return (0, import_react_query6.useQuery)({
6030
6177
  queryKey: ["bindInfo"],
6031
6178
  enabled: isLogin,
6032
6179
  queryFn: async () => {
@@ -6043,10 +6190,10 @@ __export(poh_exports, {
6043
6190
  usePohList: () => usePohList,
6044
6191
  verifyPohApi: () => verifyPohApi
6045
6192
  });
6046
- var import_react_query6 = require("@tanstack/react-query");
6193
+ var import_react_query7 = require("@tanstack/react-query");
6047
6194
  function usePohList(options) {
6048
6195
  const { isLogin } = useUserInfo();
6049
- return (0, import_react_query6.useQuery)({
6196
+ return (0, import_react_query7.useQuery)({
6050
6197
  queryKey: ["pohList"],
6051
6198
  enabled: isLogin,
6052
6199
  queryFn: async () => {
@@ -6072,8 +6219,8 @@ __export(chains_exports, {
6072
6219
  });
6073
6220
 
6074
6221
  // src/config/chains/MatchMain.ts
6075
- var import_viem5 = require("viem");
6076
- var matchMain = /* @__PURE__ */ (0, import_viem5.defineChain)({
6222
+ var import_viem6 = require("viem");
6223
+ var matchMain = /* @__PURE__ */ (0, import_viem6.defineChain)({
6077
6224
  //定义match链
6078
6225
  id: 698,
6079
6226
  name: "Matchain",
@@ -6100,8 +6247,8 @@ var matchMain = /* @__PURE__ */ (0, import_viem5.defineChain)({
6100
6247
  });
6101
6248
 
6102
6249
  // src/config/chains/MatchTest.ts
6103
- var import_viem6 = require("viem");
6104
- var matchTest = /* @__PURE__ */ (0, import_viem6.defineChain)({
6250
+ var import_viem7 = require("viem");
6251
+ var matchTest = /* @__PURE__ */ (0, import_viem7.defineChain)({
6105
6252
  //定义matchTest链
6106
6253
  id: 699,
6107
6254
  name: "MatchTest",