@matchain/matchid-sdk-react 0.1.48-alpha.6 → 0.1.48-alpha.8

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.
Files changed (61) hide show
  1. package/dist/assets/icon/index.d.mts +5 -3
  2. package/dist/assets/icon/index.d.ts +5 -3
  3. package/dist/assets/icon/index.js +18 -2
  4. package/dist/assets/icon/index.js.map +1 -1
  5. package/dist/assets/icon/index.mjs +3 -1
  6. package/dist/{chunk-YFJI4I5M.mjs → chunk-7UTR37EJ.mjs} +18 -3
  7. package/dist/chunk-7UTR37EJ.mjs.map +1 -0
  8. package/dist/{chunk-BPAPYY5P.mjs → chunk-EY6NPX4M.mjs} +477 -128
  9. package/dist/chunk-EY6NPX4M.mjs.map +1 -0
  10. package/dist/{chunk-55KYW35I.mjs → chunk-J5U7AXYA.mjs} +2 -2
  11. package/dist/{chunk-UHBVYFSP.mjs → chunk-USKUYOYJ.mjs} +2 -2
  12. package/dist/components/index.d.mts +3 -3
  13. package/dist/components/index.d.ts +3 -3
  14. package/dist/components/index.js +314 -304
  15. package/dist/components/index.js.map +1 -1
  16. package/dist/components/index.mjs +3 -3
  17. package/dist/hooks/api/index.d.mts +2 -2
  18. package/dist/hooks/api/index.d.ts +2 -2
  19. package/dist/hooks/api/index.js +94 -54
  20. package/dist/hooks/api/index.js.map +1 -1
  21. package/dist/hooks/api/index.mjs +4 -4
  22. package/dist/hooks/index.d.mts +3 -2
  23. package/dist/hooks/index.d.ts +3 -2
  24. package/dist/hooks/index.js +498 -87
  25. package/dist/hooks/index.js.map +1 -1
  26. package/dist/hooks/index.mjs +5 -3
  27. package/dist/{index-DCeOyAw8.d.ts → index-Bbn2Stvu.d.ts} +2 -2
  28. package/dist/index-Bz53bbI_.d.ts +3268 -0
  29. package/dist/{index-B8DYrhSW.d.mts → index-C-YCr0xJ.d.mts} +12 -4
  30. package/dist/{index-DbG5IjhP.d.mts → index-CB4j_ONH.d.mts} +1 -1
  31. package/dist/{index-B-s1k4Da.d.mts → index-CKyWWkzU.d.mts} +3 -2
  32. package/dist/{index-BZrddrq-.d.mts → index-C_S7k6z2.d.mts} +2 -2
  33. package/dist/{index-BHvCA7F9.d.ts → index-D-uNr-JV.d.ts} +2 -2
  34. package/dist/index-DDV4F9ka.d.mts +3268 -0
  35. package/dist/{index-DG_gyw1q.d.ts → index-DV_mRu4y.d.ts} +3 -2
  36. package/dist/{index-Bzcc-y8m.d.ts → index-DcxdJ0m2.d.ts} +1 -1
  37. package/dist/{index-BvLpvebq.d.mts → index-Dzvj-uGt.d.mts} +2 -2
  38. package/dist/{index-Cwx2p8th.d.ts → index-zRpvDpIK.d.ts} +12 -4
  39. package/dist/index.css +11 -0
  40. package/dist/index.d.mts +8 -7
  41. package/dist/index.d.ts +8 -7
  42. package/dist/index.js +704 -353
  43. package/dist/index.js.map +1 -1
  44. package/dist/index.mjs +4 -4
  45. package/dist/types/index.d.mts +1 -1
  46. package/dist/types/index.d.ts +1 -1
  47. package/dist/{types-CHkU0WHZ.d.mts → types-B4BYNw8B.d.mts} +13 -2
  48. package/dist/{types-CHkU0WHZ.d.ts → types-B4BYNw8B.d.ts} +13 -2
  49. package/dist/ui/index.d.mts +3 -3
  50. package/dist/ui/index.d.ts +3 -3
  51. package/dist/ui/index.js +62 -59
  52. package/dist/ui/index.js.map +1 -1
  53. package/dist/ui/index.mjs +2 -2
  54. package/example/src/pages/Wallet/components/MatchWallet.tsx +2 -1
  55. package/package.json +1 -1
  56. package/dist/chunk-BPAPYY5P.mjs.map +0 -1
  57. package/dist/chunk-YFJI4I5M.mjs.map +0 -1
  58. package/dist/index-DKyt0for.d.mts +0 -181
  59. package/dist/index-TkB89QxX.d.ts +0 -181
  60. /package/dist/{chunk-55KYW35I.mjs.map → chunk-J5U7AXYA.mjs.map} +0 -0
  61. /package/dist/{chunk-UHBVYFSP.mjs.map → chunk-USKUYOYJ.mjs.map} +0 -0
@@ -39,6 +39,7 @@ __export(hooks_exports, {
39
39
  useModal: () => useModal,
40
40
  useReceipt: () => useReceipt,
41
41
  useToast: () => useToast,
42
+ useTransaction: () => useTransaction,
42
43
  useUserInfo: () => useUserInfo,
43
44
  useWallet: () => useWallet2
44
45
  });
@@ -256,6 +257,13 @@ var getUserChainListApi = () => {
256
257
  method: "GET"
257
258
  });
258
259
  };
260
+ var userImportTokenApi = (data) => {
261
+ return request_default({
262
+ url: `/api/v1/user/import/token`,
263
+ method: "POST",
264
+ data
265
+ });
266
+ };
259
267
  var getUserWalletTransactionsApi = (data) => {
260
268
  return request_default({
261
269
  url: `/api/v1/user/wallet/transactions`,
@@ -394,12 +402,43 @@ var import_jsx_runtime15 = require("react/jsx-runtime");
394
402
 
395
403
  // src/assets/icon/CloseEyeIcon.tsx
396
404
  var import_jsx_runtime16 = require("react/jsx-runtime");
405
+ function CloseEyeIcon({
406
+ size = 20,
407
+ color = "#6E6E6E"
408
+ }) {
409
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("svg", { width: size, height: size, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
410
+ "path",
411
+ {
412
+ d: "M9.15132 12.5568V11.5464C8.21031 11.4949 7.28023 11.3193 6.38524 11.024L6.04233 11.9579C6.00626 12.0669 5.94867 12.1676 5.87299 12.2539C5.79731 12.3403 5.70508 12.4106 5.60174 12.4607C5.4984 12.5108 5.38607 12.5396 5.27139 12.5455C5.15671 12.5514 5.04201 12.5342 4.93409 12.4949C4.82617 12.4557 4.72722 12.3952 4.6431 12.317C4.55898 12.2389 4.49139 12.1446 4.44435 12.0399C4.3973 11.9351 4.37175 11.822 4.36921 11.7072C4.36667 11.5924 4.38719 11.4783 4.42955 11.3715L4.80788 10.3268C4.04603 9.88461 3.32634 9.37345 2.65789 8.79975C2.54358 8.70488 2.42928 8.61687 2.32184 8.52772C2.1442 8.38554 2.03031 8.17862 2.00523 7.95247C1.98015 7.72633 2.04593 7.49948 2.18811 7.32184C2.33028 7.1442 2.5372 7.03031 2.76335 7.00523C2.98949 6.98015 3.21634 7.04593 3.39398 7.18811C3.50828 7.27955 3.62258 7.37099 3.73689 7.47043C5.46065 9.00826 7.68996 9.85815 10 9.85815C12.31 9.85815 14.5393 9.00826 16.2631 7.47043C16.3774 7.37099 16.4917 7.27955 16.606 7.18811C16.694 7.11771 16.7949 7.06533 16.9031 7.03395C17.0114 7.00257 17.1247 6.99281 17.2367 7.00523C17.3486 7.01765 17.4571 7.052 17.5558 7.10632C17.6545 7.16065 17.7415 7.23388 17.8119 7.32184C17.8823 7.4098 17.9347 7.51077 17.9661 7.61897C17.9974 7.72717 18.0072 7.8405 17.9948 7.95247C17.9824 8.06445 17.948 8.17288 17.8937 8.27158C17.8394 8.37028 17.7661 8.45732 17.6782 8.52772L17.3421 8.79975C16.6737 9.37354 15.954 9.88471 15.1921 10.3268L15.5705 11.3715C15.6128 11.4783 15.6333 11.5924 15.6308 11.7072C15.6283 11.822 15.6027 11.9351 15.5557 12.0399C15.5086 12.1446 15.441 12.2389 15.3569 12.317C15.2728 12.3952 15.1738 12.4557 15.0659 12.4949C14.958 12.5342 14.8433 12.5514 14.7286 12.5455C14.6139 12.5396 14.5016 12.5108 14.3983 12.4607C14.2949 12.4106 14.2027 12.3403 14.127 12.2539C14.0513 12.1676 13.9937 12.0669 13.9577 11.9579L13.6148 11.024C12.7198 11.3193 11.7897 11.4949 10.8487 11.5464V12.5568C10.8487 12.7842 10.7584 13.0022 10.5976 13.163C10.4368 13.3238 10.2188 13.4141 9.99143 13.4141C9.76407 13.4141 9.54602 13.3238 9.38526 13.163C9.22449 13.0022 9.13417 12.7842 9.13417 12.5568H9.15132Z",
413
+ fill: color
414
+ }
415
+ ) });
416
+ }
397
417
 
398
418
  // src/assets/icon/OpenEyeIcon.tsx
399
419
  var import_jsx_runtime17 = require("react/jsx-runtime");
420
+ function OpenEyeIcon({
421
+ size = 20,
422
+ color = "#6E6E6E"
423
+ }) {
424
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("svg", { width: size, height: size, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
425
+ "path",
426
+ {
427
+ d: "M10 6.4543C11.3373 6.44986 12.6486 6.82287 13.7834 7.53047C14.9181 8.23806 15.8301 9.25151 16.4145 10.4543C15.2145 12.9052 12.7564 14.4543 10 14.4543C7.24364 14.4543 4.78545 12.9052 3.58545 10.4543C4.1699 9.25151 5.08191 8.23806 6.21664 7.53047C7.35136 6.82287 8.66274 6.44986 10 6.4543ZM10 4.99976C6.36364 4.99976 3.25818 7.26157 2 10.4543C3.25818 13.647 6.36364 15.9088 10 15.9088C13.6364 15.9088 16.7418 13.647 18 10.4543C16.7418 7.26157 13.6364 4.99976 10 4.99976ZM10 8.63612C10.4822 8.63617 10.9446 8.82774 11.2855 9.16871C11.6265 9.50968 11.818 9.97212 11.818 10.4543C11.818 10.9365 11.6265 11.3989 11.2855 11.7399C10.9446 12.0809 10.4822 12.2724 10 12.2725C9.51782 12.2724 9.0554 12.0809 8.71447 11.7399C8.37353 11.3989 8.18199 10.9365 8.18199 10.4543C8.18199 9.97212 8.37353 9.50968 8.71447 9.16871C9.0554 8.82774 9.51782 8.63617 10 8.63612ZM10 7.18157C8.19636 7.18157 6.72727 8.65066 6.72727 10.4543C6.72727 12.2579 8.19636 13.727 10 13.727C11.8036 13.727 13.2727 12.2579 13.2727 10.4543C13.2727 8.65066 11.8036 7.18157 10 7.18157Z",
428
+ fill: color
429
+ }
430
+ ) });
431
+ }
400
432
 
401
433
  // src/assets/icon/DeleteRoundIcon.tsx
402
434
  var import_jsx_runtime18 = require("react/jsx-runtime");
435
+ function DeleteRoundIcon({ height = 21, width = 20, color = "var(--matchid-error-color)", ...props }) {
436
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("svg", { width, height, viewBox: "0 0 20 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
437
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("rect", { y: "0.5", width: "20", height: "20", rx: "10", fill: color }),
438
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M7.17139 7.67188L12.8282 13.3287", stroke: "white", strokeLinecap: "round" }),
439
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M12.8286 7.67188L7.17176 13.3287", stroke: "white", strokeLinecap: "round" })
440
+ ] });
441
+ }
403
442
 
404
443
  // src/assets/icon/FacebookIcon.tsx
405
444
  var import_jsx_runtime19 = require("react/jsx-runtime");
@@ -479,9 +518,12 @@ var import_jsx_runtime43 = require("react/jsx-runtime");
479
518
  // src/assets/icon/ErrorRoundIcon.tsx
480
519
  var import_jsx_runtime44 = require("react/jsx-runtime");
481
520
 
482
- // src/assets/icon/InfoRoundIcon.tsx
521
+ // src/assets/icon/InfoLineIcon.tsx
483
522
  var import_jsx_runtime45 = require("react/jsx-runtime");
484
523
 
524
+ // src/assets/icon/InfoRoundIcon.tsx
525
+ var import_jsx_runtime46 = require("react/jsx-runtime");
526
+
485
527
  // src/hooks/useLayout.tsx
486
528
  var useLayout_exports = {};
487
529
  __export(useLayout_exports, {
@@ -503,7 +545,7 @@ function useDownMd() {
503
545
  }
504
546
 
505
547
  // src/hooks/useConfig.tsx
506
- var import_jsx_runtime46 = require("react/jsx-runtime");
548
+ var import_jsx_runtime47 = require("react/jsx-runtime");
507
549
  var DEFAULT_WALLET_METHODS = ["evm", "sol", "btc", "tron", "ton"];
508
550
 
509
551
  // src/store/useModalStore.ts
@@ -561,10 +603,10 @@ var import_react6 = require("react");
561
603
 
562
604
  // src/ui/Overlay/index.tsx
563
605
  var import_react2 = require("react");
564
- var import_jsx_runtime47 = require("react/jsx-runtime");
606
+ var import_jsx_runtime48 = require("react/jsx-runtime");
565
607
 
566
608
  // src/ui/Modal/index.tsx
567
- var import_jsx_runtime48 = require("react/jsx-runtime");
609
+ var import_jsx_runtime49 = require("react/jsx-runtime");
568
610
 
569
611
  // src/components/EmailModal/StepEmail.tsx
570
612
  var import_react4 = require("react");
@@ -581,7 +623,7 @@ function getAppClientId() {
581
623
  }
582
624
 
583
625
  // src/ui/Button/index.tsx
584
- var import_jsx_runtime49 = require("react/jsx-runtime");
626
+ var import_jsx_runtime50 = require("react/jsx-runtime");
585
627
  function Button({
586
628
  size = "df",
587
629
  disabled = false,
@@ -600,7 +642,7 @@ function Button({
600
642
  onClick && onClick();
601
643
  }
602
644
  };
603
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
645
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
604
646
  "button",
605
647
  {
606
648
  type,
@@ -610,34 +652,85 @@ function Button({
610
652
  ...style
611
653
  },
612
654
  onClick: onAction,
613
- children: loading ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(LoadingIcon_default, { className: "matchid-btn-loading-icon", color: "var(--matchid-btn-loading-color)" }) : children
655
+ children: loading ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(LoadingIcon_default, { className: "matchid-btn-loading-icon", color: "var(--matchid-btn-loading-color)" }) : children
614
656
  }
615
657
  );
616
658
  }
617
659
 
618
660
  // src/ui/Input/index.tsx
619
661
  var import_react3 = require("react");
620
- var import_jsx_runtime50 = require("react/jsx-runtime");
662
+ var import_jsx_runtime51 = require("react/jsx-runtime");
663
+ function Input({
664
+ onChange,
665
+ type,
666
+ after,
667
+ className = "",
668
+ ...props
669
+ }) {
670
+ const [inputType, setInputType] = (0, import_react3.useState)(type);
671
+ const isDownMd = useDownMd();
672
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
673
+ "div",
674
+ {
675
+ className: `matchid-input-box ${props.value && props.value.length > 0 ? "matchid-input-has-content" : ""} ${className}`,
676
+ children: [
677
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("input", { type: inputType, onChange, ...props, className: "matchid-input-field" }),
678
+ props.value && props.value.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "matchid-input-delete-icon", onClick: (e) => {
679
+ if (onChange) {
680
+ onChange({ target: { value: "" } });
681
+ }
682
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
683
+ DeleteRoundIcon,
684
+ {
685
+ height: isDownMd ? 16 : 21,
686
+ width: isDownMd ? 16 : 20,
687
+ color: "var(--matchid-input-delete-icon-color)"
688
+ }
689
+ ) }),
690
+ type === "password" && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "matchid-input-eye-icon", onClick: () => {
691
+ setInputType(inputType === "password" ? "text" : "password");
692
+ }, children: inputType === "password" ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(CloseEyeIcon, { size: isDownMd ? 16 : 20 }) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(OpenEyeIcon, { size: isDownMd ? 16 : 20 }) }),
693
+ after
694
+ ]
695
+ }
696
+ );
697
+ }
621
698
 
622
699
  // src/ui/Field/index.tsx
623
- var import_jsx_runtime51 = require("react/jsx-runtime");
700
+ var import_jsx_runtime52 = require("react/jsx-runtime");
701
+ function Field({
702
+ label,
703
+ children,
704
+ error,
705
+ required,
706
+ className = ""
707
+ }) {
708
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: `matchid-field-box ${className}`, children: [
709
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "matchid-field-label", children: [
710
+ required && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "matchid-field-required", children: "*" }),
711
+ label
712
+ ] }),
713
+ children,
714
+ error && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "matchid-field-error", children: error })
715
+ ] });
716
+ }
624
717
 
625
718
  // src/components/EmailModal/StepEmail.tsx
626
719
  var import_react_intl = require("react-intl");
627
- var import_jsx_runtime52 = require("react/jsx-runtime");
720
+ var import_jsx_runtime53 = require("react/jsx-runtime");
628
721
 
629
722
  // src/components/EmailModal/StepVerify.tsx
630
723
  var import_react5 = require("react");
631
724
  var import_react_intl2 = require("react-intl");
632
- var import_jsx_runtime53 = require("react/jsx-runtime");
725
+ var import_jsx_runtime54 = require("react/jsx-runtime");
633
726
 
634
727
  // src/components/EmailModal/index.tsx
635
728
  var import_react_intl3 = require("react-intl");
636
- var import_jsx_runtime54 = require("react/jsx-runtime");
729
+ var import_jsx_runtime55 = require("react/jsx-runtime");
637
730
 
638
731
  // src/ui/Popover/index.tsx
639
732
  var import_react7 = require("react");
640
- var import_jsx_runtime55 = require("react/jsx-runtime");
733
+ var import_jsx_runtime56 = require("react/jsx-runtime");
641
734
 
642
735
  // src/components/LoginBox/index.tsx
643
736
  var import_react8 = require("react");
@@ -647,36 +740,36 @@ var import_react_intl4 = require("react-intl");
647
740
  var import_react_query = require("@tanstack/react-query");
648
741
 
649
742
  // src/components/LoginBox/index.tsx
650
- var import_jsx_runtime56 = require("react/jsx-runtime");
743
+ var import_jsx_runtime57 = require("react/jsx-runtime");
651
744
 
652
745
  // src/components/LoginButton/index.tsx
653
746
  var import_react10 = require("react");
654
747
 
655
748
  // src/components/LoginPanel/index.tsx
656
749
  var import_react_intl5 = require("react-intl");
657
- var import_jsx_runtime57 = require("react/jsx-runtime");
750
+ var import_jsx_runtime58 = require("react/jsx-runtime");
658
751
 
659
752
  // src/components/LoginModal/index.tsx
660
- var import_jsx_runtime58 = require("react/jsx-runtime");
753
+ var import_jsx_runtime59 = require("react/jsx-runtime");
661
754
 
662
755
  // src/components/UserPopover/index.tsx
663
756
  var import_react9 = require("react");
664
757
 
665
758
  // src/assets/icon/ProfileIcon.tsx
666
- var import_jsx_runtime59 = require("react/jsx-runtime");
759
+ var import_jsx_runtime60 = require("react/jsx-runtime");
667
760
 
668
761
  // src/components/UserPopover/index.tsx
669
762
  var import_react_intl6 = require("react-intl");
670
- var import_jsx_runtime60 = require("react/jsx-runtime");
763
+ var import_jsx_runtime61 = require("react/jsx-runtime");
671
764
 
672
765
  // src/components/LoginButton/index.tsx
673
766
  var import_react_intl7 = require("react-intl");
674
- var import_jsx_runtime61 = require("react/jsx-runtime");
767
+ var import_jsx_runtime62 = require("react/jsx-runtime");
675
768
 
676
769
  // src/components/UsernameModal/index.tsx
677
770
  var import_react11 = require("react");
678
771
  var import_react_intl8 = require("react-intl");
679
- var import_jsx_runtime62 = require("react/jsx-runtime");
772
+ var import_jsx_runtime63 = require("react/jsx-runtime");
680
773
 
681
774
  // src/components/SOLModal/index.tsx
682
775
  var import_react13 = __toESM(require("react"));
@@ -729,10 +822,10 @@ var import_react_intl9 = require("react-intl");
729
822
 
730
823
  // src/components/WalletModalContent/index.tsx
731
824
  var import_react12 = require("react");
732
- var import_jsx_runtime63 = require("react/jsx-runtime");
825
+ var import_jsx_runtime64 = require("react/jsx-runtime");
733
826
 
734
827
  // src/components/SOLModal/index.tsx
735
- var import_jsx_runtime64 = require("react/jsx-runtime");
828
+ var import_jsx_runtime65 = require("react/jsx-runtime");
736
829
  var wallets = [
737
830
  new import_wallet_adapter_wallets.PhantomWalletAdapter(),
738
831
  new import_wallet_adapter_wallets.SolflareWalletAdapter(),
@@ -783,13 +876,13 @@ var import_react_intl10 = require("react-intl");
783
876
  var import_react14 = require("react");
784
877
 
785
878
  // src/components/TRONModal/index.tsx
786
- var import_jsx_runtime65 = require("react/jsx-runtime");
879
+ var import_jsx_runtime66 = require("react/jsx-runtime");
787
880
 
788
881
  // src/components/TONModal/index.tsx
789
882
  var import_react16 = __toESM(require("react"));
790
883
  var import_react_intl11 = require("react-intl");
791
884
  var import_ui_react = require("@tonconnect/ui-react");
792
- var import_jsx_runtime66 = require("react/jsx-runtime");
885
+ var import_jsx_runtime67 = require("react/jsx-runtime");
793
886
 
794
887
  // src/components/BTCModal/index.tsx
795
888
  var import_react18 = __toESM(require("react"));
@@ -802,17 +895,17 @@ var import_sats_connect = require("sats-connect");
802
895
  var import_react17 = require("react");
803
896
 
804
897
  // src/components/BTCModal/index.tsx
805
- var import_jsx_runtime67 = require("react/jsx-runtime");
898
+ var import_jsx_runtime68 = require("react/jsx-runtime");
806
899
 
807
900
  // src/components/WalletModal/index.tsx
808
901
  var import_react19 = require("react");
809
902
  var import_react_intl13 = require("react-intl");
810
- var import_jsx_runtime68 = require("react/jsx-runtime");
903
+ var import_jsx_runtime69 = require("react/jsx-runtime");
811
904
 
812
905
  // src/components/CEXBindModal/index.tsx
813
906
  var import_react20 = require("react");
814
907
  var import_react_intl14 = require("react-intl");
815
- var import_jsx_runtime69 = require("react/jsx-runtime");
908
+ var import_jsx_runtime70 = require("react/jsx-runtime");
816
909
 
817
910
  // src/ui/HashPanel/index.tsx
818
911
  var import_viem = require("viem");
@@ -820,30 +913,30 @@ var import_react21 = require("react");
820
913
  var import_react_query2 = require("@tanstack/react-query");
821
914
 
822
915
  // src/ui/Drawer/index.tsx
823
- var import_jsx_runtime70 = require("react/jsx-runtime");
916
+ var import_jsx_runtime71 = require("react/jsx-runtime");
824
917
 
825
918
  // src/ui/ModalDrawer/index.tsx
826
- var import_jsx_runtime71 = require("react/jsx-runtime");
919
+ var import_jsx_runtime72 = require("react/jsx-runtime");
827
920
 
828
921
  // src/ui/HashPanel/index.tsx
829
- var import_jsx_runtime72 = require("react/jsx-runtime");
922
+ var import_jsx_runtime73 = require("react/jsx-runtime");
830
923
 
831
924
  // src/context/BusinessProvider.tsx
832
- var import_jsx_runtime73 = require("react/jsx-runtime");
925
+ var import_jsx_runtime74 = require("react/jsx-runtime");
833
926
 
834
927
  // src/context/ModalContext.tsx
835
928
  var import_react23 = require("react");
836
929
  var import_react_dom = require("react-dom");
837
930
 
838
931
  // src/ui/Switch/index.tsx
839
- var import_jsx_runtime74 = require("react/jsx-runtime");
932
+ var import_jsx_runtime75 = require("react/jsx-runtime");
840
933
 
841
934
  // src/ui/AlphaAvatar/index.tsx
842
935
  var import_react22 = require("react");
843
- var import_jsx_runtime75 = require("react/jsx-runtime");
936
+ var import_jsx_runtime76 = require("react/jsx-runtime");
844
937
 
845
938
  // src/ui/Radio/index.tsx
846
- var import_jsx_runtime76 = require("react/jsx-runtime");
939
+ var import_jsx_runtime77 = require("react/jsx-runtime");
847
940
  function Radio({
848
941
  checked = false,
849
942
  onChange,
@@ -852,20 +945,20 @@ function Radio({
852
945
  className = "",
853
946
  style = {}
854
947
  }) {
855
- return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { onClick: onChange, className: `matchid-radio ${className} ${checked ? "matchid-radio-checked" : ""}`, style: {
948
+ return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { onClick: onChange, className: `matchid-radio ${className} ${checked ? "matchid-radio-checked" : ""}`, style: {
856
949
  width: size,
857
950
  height: size,
858
951
  ...style,
859
952
  // @ts-ignore
860
953
  "--matchid-radio-checked": color
861
- }, children: checked && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: `matchid-radio-content`, style: {
954
+ }, children: checked && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: `matchid-radio-content`, style: {
862
955
  width: Math.floor(size * 0.7),
863
956
  height: Math.floor(size * 0.7)
864
957
  } }) });
865
958
  }
866
959
 
867
960
  // src/context/ModalContext.tsx
868
- var import_jsx_runtime77 = require("react/jsx-runtime");
961
+ var import_jsx_runtime78 = require("react/jsx-runtime");
869
962
  var ModalContext = (0, import_react23.createContext)(null);
870
963
  function useModal() {
871
964
  const context = (0, import_react23.useContext)(ModalContext);
@@ -878,7 +971,7 @@ function useModal() {
878
971
  // src/context/ToastContext.tsx
879
972
  var import_react24 = require("react");
880
973
  var import_react_dom2 = require("react-dom");
881
- var import_jsx_runtime78 = require("react/jsx-runtime");
974
+ var import_jsx_runtime79 = require("react/jsx-runtime");
882
975
  var ToastContext = (0, import_react24.createContext)(null);
883
976
  function useToast() {
884
977
  const context = (0, import_react24.useContext)(ToastContext);
@@ -889,7 +982,7 @@ function useToast() {
889
982
  }
890
983
 
891
984
  // src/context/index.tsx
892
- var import_jsx_runtime79 = require("react/jsx-runtime");
985
+ var import_jsx_runtime80 = require("react/jsx-runtime");
893
986
 
894
987
  // src/hooks/useWalletInit.ts
895
988
  var import_react25 = require("react");
@@ -911,7 +1004,7 @@ var import_react26 = require("react");
911
1004
  // src/MatchContext.tsx
912
1005
  var import_react_query3 = require("@tanstack/react-query");
913
1006
  var import_react_intl15 = require("react-intl");
914
- var import_jsx_runtime80 = require("react/jsx-runtime");
1007
+ var import_jsx_runtime81 = require("react/jsx-runtime");
915
1008
  var queryClient = new import_react_query3.QueryClient();
916
1009
  var MatchContext = (0, import_react27.createContext)(void 0);
917
1010
  var useMatch = () => {
@@ -1448,7 +1541,8 @@ function useChainListQuery(options) {
1448
1541
 
1449
1542
  // src/hooks/useMatchChain.tsx
1450
1543
  var import_react32 = require("react");
1451
- var import_jsx_runtime81 = require("react/jsx-runtime");
1544
+ var import_viem5 = require("viem");
1545
+ var import_jsx_runtime82 = require("react/jsx-runtime");
1452
1546
  function useMatchChain() {
1453
1547
  const chainListQuery = useChainListQuery();
1454
1548
  const modal = useModal();
@@ -1477,25 +1571,25 @@ function useMatchChain() {
1477
1571
  }) {
1478
1572
  const { chainId: storeChainId2, setChainId: setChainId2 } = useLocalStore_default();
1479
1573
  const [selectedChainId, setSelectedChainId] = (0, import_react32.useState)(storeChainId2);
1480
- return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: `matchid-change-network-box`, children: [
1481
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: `matchid-change-network-list`, children: chainListQuery.data?.map((item, index) => {
1482
- return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
1574
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: `matchid-change-network-box`, children: [
1575
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: `matchid-change-network-list`, children: chainListQuery.data?.map((item, index) => {
1576
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
1483
1577
  "div",
1484
1578
  {
1485
1579
  onClick: () => setSelectedChainId(item.id),
1486
1580
  className: `matchid-change-network-item ${selectedChainId == item.id ? "matchid-change-network-selected" : ""}`,
1487
1581
  children: [
1488
- /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: `matchid-change-network-item-content`, children: [
1489
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("img", { src: item.iconUrl, className: `matchid-change-network-item-icon` }),
1490
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "matchid-change-network-item-name", children: item.name })
1582
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: `matchid-change-network-item-content`, children: [
1583
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("img", { src: item.iconUrl, className: `matchid-change-network-item-icon` }),
1584
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "matchid-change-network-item-name", children: item.name })
1491
1585
  ] }),
1492
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(Radio, { checked: selectedChainId === item.id })
1586
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Radio, { checked: selectedChainId === item.id })
1493
1587
  ]
1494
1588
  },
1495
1589
  index
1496
1590
  );
1497
1591
  }) }),
1498
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(Button, { size: "lg", highlight: true, onClick: () => {
1592
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Button, { size: "lg", highlight: true, onClick: () => {
1499
1593
  setChainId2(selectedChainId || 0);
1500
1594
  close();
1501
1595
  }, block: true, children: "Confirm" })
@@ -1507,13 +1601,23 @@ function useMatchChain() {
1507
1601
  content: ChangeNetwork
1508
1602
  });
1509
1603
  };
1604
+ const publicClient = (0, import_react32.useMemo)(() => {
1605
+ if (!chain) {
1606
+ return null;
1607
+ }
1608
+ return (0, import_viem5.createPublicClient)({
1609
+ chain,
1610
+ transport: (0, import_viem5.http)()
1611
+ });
1612
+ }, [chain]);
1510
1613
  return {
1511
1614
  list: chainListQuery.data,
1512
1615
  chainId,
1513
1616
  setChainId,
1514
1617
  chain,
1515
1618
  explorerLink,
1516
- showChangeNetwork
1619
+ showChangeNetwork,
1620
+ publicClient
1517
1621
  };
1518
1622
  }
1519
1623
 
@@ -1525,51 +1629,211 @@ var import_react33 = require("react");
1525
1629
  var address = "0x4143e29770fd63e24bb1f32d50bf8a590e34de4b";
1526
1630
 
1527
1631
  // src/hooks/useMatchWallet.tsx
1528
- var import_jsx_runtime82 = require("react/jsx-runtime");
1529
- function useMatchWallet() {
1530
- const modal = useModal();
1531
- const { address: address2 } = useWallet2();
1632
+ var import_jsx_runtime83 = require("react/jsx-runtime");
1633
+ var ReceiveModal = () => {
1532
1634
  const chain = useMatchChain();
1635
+ const { address: address2 } = useWallet2();
1533
1636
  const [copied, setCopied] = useCopyClipboard();
1534
1637
  const toast = useToast();
1535
1638
  const onCopy = () => {
1536
1639
  setCopied(address2);
1537
1640
  toast.success("Copied!");
1538
1641
  };
1642
+ const chainLink = chain.explorerLink("address/" + address2);
1643
+ return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: `matchid-receive-modal`, children: [
1644
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "matchid-receive-container", children: [
1645
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: `matchid-receive-text`, children: "Receive by scanning the QR code" }),
1646
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: `matchid-qr-container`, children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
1647
+ import_react_qrcode.QRCode,
1648
+ {
1649
+ margin: "0",
1650
+ className: `matchid-qr-code`,
1651
+ value: address2
1652
+ }
1653
+ ) }),
1654
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
1655
+ "a",
1656
+ {
1657
+ href: chainLink,
1658
+ target: "_blank",
1659
+ className: `matchid-receive-link`,
1660
+ children: address2
1661
+ }
1662
+ )
1663
+ ] }),
1664
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Button, { size: "lg", onClick: onCopy, block: true, highlight: true, disabled: copied, children: "Copy Address" })
1665
+ ] });
1666
+ };
1667
+ var ImportTokenModal = ({ close }) => {
1668
+ const [address2, setAddress] = (0, import_react33.useState)("");
1669
+ const [symbol, setSymbol] = (0, import_react33.useState)("");
1670
+ const [decimals, setDecimals] = (0, import_react33.useState)("");
1671
+ const [error, setError] = (0, import_react33.useState)({});
1672
+ const { publicClient, chainId } = useMatchChain();
1673
+ const getContractInfo = async () => {
1674
+ if (!publicClient) return;
1675
+ const erc20Abi = [
1676
+ {
1677
+ name: "decimals",
1678
+ type: "function",
1679
+ stateMutability: "view",
1680
+ inputs: [],
1681
+ outputs: [{ name: "decimals", type: "uint8" }]
1682
+ },
1683
+ {
1684
+ name: "symbol",
1685
+ type: "function",
1686
+ stateMutability: "view",
1687
+ inputs: [],
1688
+ outputs: [{ name: "symbol", type: "string" }]
1689
+ }
1690
+ ];
1691
+ const calls = [
1692
+ {
1693
+ address: address2,
1694
+ abi: erc20Abi,
1695
+ functionName: "symbol",
1696
+ args: []
1697
+ },
1698
+ {
1699
+ address: address2,
1700
+ abi: erc20Abi,
1701
+ functionName: "decimals",
1702
+ args: []
1703
+ }
1704
+ ];
1705
+ try {
1706
+ const results = await publicClient.multicall({ contracts: calls });
1707
+ console.log("results", results);
1708
+ if (!symbol && results[0]?.status == "success") {
1709
+ setSymbol(results[0]?.result);
1710
+ }
1711
+ if (!decimals && results[1]?.status == "success") {
1712
+ setDecimals((results[1]?.result).toString());
1713
+ }
1714
+ } catch (error2) {
1715
+ setError({
1716
+ address: error2.message
1717
+ });
1718
+ }
1719
+ };
1720
+ (0, import_react33.useEffect)(() => {
1721
+ if (address2.length === 42) {
1722
+ const reg = /^0x[0-9a-fA-F]{40}$/;
1723
+ if (!reg.test(address2)) {
1724
+ setError({
1725
+ ...error,
1726
+ address: "Invalid address"
1727
+ });
1728
+ } else {
1729
+ setError({
1730
+ ...error,
1731
+ address: ""
1732
+ });
1733
+ publicClient && getContractInfo();
1734
+ }
1735
+ }
1736
+ }, [address2, publicClient]);
1737
+ const [loading, setLoading] = (0, import_react33.useState)(false);
1738
+ const toast = useToast();
1739
+ const onImport = async () => {
1740
+ setLoading(true);
1741
+ try {
1742
+ const res = await userImportTokenApi({
1743
+ chain_id: chainId?.toString() || "",
1744
+ symbol,
1745
+ address: address2,
1746
+ decimals
1747
+ });
1748
+ if (isSuccess(res)) {
1749
+ toast.success("Imported successfully");
1750
+ close();
1751
+ } else {
1752
+ toast.error(res.message);
1753
+ }
1754
+ } catch (error2) {
1755
+ toast.error(error2.message);
1756
+ } finally {
1757
+ setLoading(false);
1758
+ }
1759
+ };
1760
+ const canImport = (0, import_react33.useMemo)(() => {
1761
+ if (!address2) {
1762
+ return false;
1763
+ }
1764
+ if (!symbol) {
1765
+ return false;
1766
+ }
1767
+ if (decimals.length === 0) {
1768
+ return false;
1769
+ }
1770
+ const reg = /^0x[0-9a-fA-F]{40}$/;
1771
+ if (!reg.test(address2)) {
1772
+ return false;
1773
+ }
1774
+ return true;
1775
+ }, [error, address2, symbol, decimals]);
1776
+ return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: `matchid-import-token`, children: [
1777
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "matchid-import-token-form", children: [
1778
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Field, { label: "Token Smart Contract", error: error.address, children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
1779
+ Input,
1780
+ {
1781
+ placeholder: "Enter the Token Smart Contract",
1782
+ value: address2,
1783
+ onChange: (e) => setAddress(e.target.value),
1784
+ maxLength: 42
1785
+ }
1786
+ ) }),
1787
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Field, { label: "Token Symbol", error: error.symbol, children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
1788
+ Input,
1789
+ {
1790
+ placeholder: "Enter the Token Symbol",
1791
+ value: symbol,
1792
+ onChange: (e) => setSymbol(e.target.value),
1793
+ maxLength: 16
1794
+ }
1795
+ ) }),
1796
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Field, { label: "Decimals", error: error.decimals, children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
1797
+ Input,
1798
+ {
1799
+ placeholder: "Enter the Decimals",
1800
+ type: "number",
1801
+ value: decimals,
1802
+ onChange: (e) => setDecimals(e.target.value)
1803
+ }
1804
+ ) })
1805
+ ] }),
1806
+ /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
1807
+ Button,
1808
+ {
1809
+ size: "lg",
1810
+ onClick: onImport,
1811
+ block: true,
1812
+ loading,
1813
+ disabled: !canImport,
1814
+ highlight: true,
1815
+ children: "Import"
1816
+ }
1817
+ )
1818
+ ] });
1819
+ };
1820
+ function useMatchWallet() {
1821
+ const modal = useModal();
1539
1822
  const showReceiveModal = () => {
1540
- const chainLink = chain.explorerLink("address/" + address2);
1541
- const ReceiveModal = () => {
1542
- return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: `matchid-receive-modal`, children: [
1543
- /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "matchid-receive-container", children: [
1544
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: `matchid-receive-text`, children: "Receive by scanning the QR code" }),
1545
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: `matchid-qr-container`, children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
1546
- import_react_qrcode.QRCode,
1547
- {
1548
- margin: "0",
1549
- className: `matchid-qr-code`,
1550
- value: address2
1551
- }
1552
- ) }),
1553
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
1554
- "a",
1555
- {
1556
- href: chainLink,
1557
- target: "_blank",
1558
- className: `matchid-receive-link`,
1559
- children: address2
1560
- }
1561
- )
1562
- ] }),
1563
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Button, { size: "lg", onClick: onCopy, block: true, highlight: true, disabled: copied, children: "Copy Address" })
1564
- ] });
1565
- };
1566
1823
  modal.open({
1567
1824
  title: "Receive",
1568
1825
  content: ReceiveModal
1569
1826
  });
1570
1827
  };
1828
+ const showImportTokenModal = () => {
1829
+ modal.open({
1830
+ title: "Customized Token",
1831
+ content: ImportTokenModal
1832
+ });
1833
+ };
1571
1834
  return {
1572
- showReceiveModal
1835
+ showReceiveModal,
1836
+ showImportTokenModal
1573
1837
  };
1574
1838
  }
1575
1839
  function useMatchWalletRecords({
@@ -1578,8 +1842,9 @@ function useMatchWalletRecords({
1578
1842
  const [hasMore, setHasMore] = (0, import_react33.useState)(true);
1579
1843
  const [items, setItems] = (0, import_react33.useState)([]);
1580
1844
  const { chainId } = useMatchChain();
1845
+ const hasMoreRef = (0, import_react33.useRef)(hasMore);
1581
1846
  const fetchMoreData = async () => {
1582
- if (!hasMore) {
1847
+ if (!hasMoreRef.current) {
1583
1848
  return;
1584
1849
  }
1585
1850
  const chainIdStr = chainId ? chainId.toString() : "";
@@ -1592,12 +1857,14 @@ function useMatchWalletRecords({
1592
1857
  if (res.data && res.data.transactions.length > 0) {
1593
1858
  setItems(items.concat(res.data.transactions));
1594
1859
  }
1860
+ hasMoreRef.current = res.data && res.data.transactions.length >= pageSize;
1595
1861
  setHasMore(res.data && res.data.transactions.length >= pageSize);
1596
1862
  }
1597
1863
  };
1598
1864
  const onInit = async () => {
1599
1865
  setItems([]);
1600
1866
  setHasMore(true);
1867
+ hasMoreRef.current = true;
1601
1868
  fetchMoreData();
1602
1869
  };
1603
1870
  (0, import_react33.useEffect)(() => {
@@ -1615,7 +1882,7 @@ function useMatchWalletRecords({
1615
1882
  // src/hooks/useReceipt.tsx
1616
1883
  var import_react34 = require("react");
1617
1884
  var import_react_query5 = require("@tanstack/react-query");
1618
- var import_viem5 = require("viem");
1885
+ var import_viem6 = require("viem");
1619
1886
  var CACHE_TTL = 86400 * 30 * 1e3;
1620
1887
  var MAX_CACHE_SIZE = 500;
1621
1888
  var STORAGE_KEY = "match_receipt_logs";
@@ -1732,10 +1999,9 @@ function useReceipt({
1732
1999
  return cache.get(cacheKey);
1733
2000
  }
1734
2001
  try {
1735
- const publicClient = (0, import_viem5.createPublicClient)({
1736
- //@ts-ignore
1737
- chain: (0, import_viem5.defineChain)(chain),
1738
- transport: (0, import_viem5.http)()
2002
+ const publicClient = (0, import_viem6.createPublicClient)({
2003
+ chain: (0, import_viem6.defineChain)(chain),
2004
+ transport: (0, import_viem6.http)()
1739
2005
  });
1740
2006
  const receipt = await publicClient.getTransactionReceipt({ hash });
1741
2007
  if (!receipt) {
@@ -1756,6 +2022,150 @@ function useReceipt({
1756
2022
  }, [query.data]);
1757
2023
  return query;
1758
2024
  }
2025
+
2026
+ // src/hooks/useTransaction.tsx
2027
+ var import_react35 = require("react");
2028
+ var import_react_query6 = require("@tanstack/react-query");
2029
+ var import_viem7 = require("viem");
2030
+ var CACHE_TTL2 = 86400 * 30 * 1e3;
2031
+ var MAX_CACHE_SIZE2 = 500;
2032
+ var STORAGE_KEY2 = "match_transaction_logs";
2033
+ function useTransactionCache() {
2034
+ const [cache, setCache] = (0, import_react35.useState)(/* @__PURE__ */ new Map());
2035
+ const isLocalStorageAvailable = (() => {
2036
+ try {
2037
+ const testKey = "__test__";
2038
+ localStorage.setItem(testKey, "1");
2039
+ localStorage.removeItem(testKey);
2040
+ return true;
2041
+ } catch (e) {
2042
+ return false;
2043
+ }
2044
+ })();
2045
+ (0, import_react35.useEffect)(() => {
2046
+ if (isLocalStorageAvailable) {
2047
+ try {
2048
+ const storedData = localStorage.getItem(STORAGE_KEY2);
2049
+ if (storedData) {
2050
+ try {
2051
+ const parsed = JSON.parse(storedData);
2052
+ const now = Date.now();
2053
+ const validEntries = Object.entries(parsed).filter(([_, entry]) => typeof entry === "object" && entry !== null && "timestamp" in entry && now - entry.timestamp <= CACHE_TTL2).map(([key, entry]) => [key, entry]);
2054
+ setCache(new Map(validEntries));
2055
+ } catch (e) {
2056
+ console.error("Failed to parse cache from localStorage:", e);
2057
+ }
2058
+ }
2059
+ } catch (e) {
2060
+ console.error("Failed to load cache from localStorage:", e);
2061
+ }
2062
+ }
2063
+ }, []);
2064
+ const updateLocalStorage = (0, import_react35.useCallback)((updatedCache) => {
2065
+ if (isLocalStorageAvailable) {
2066
+ try {
2067
+ const storedData = localStorage.getItem(STORAGE_KEY2);
2068
+ let parsed = {};
2069
+ if (storedData) {
2070
+ parsed = JSON.parse(storedData);
2071
+ }
2072
+ updatedCache.forEach((entry, key) => {
2073
+ parsed[key] = entry;
2074
+ });
2075
+ localStorage.setItem(STORAGE_KEY2, JSON.stringify(parsed));
2076
+ } catch (e) {
2077
+ console.error("Failed to update localStorage:", e);
2078
+ }
2079
+ }
2080
+ }, []);
2081
+ const set = (0, import_react35.useCallback)((key, value) => {
2082
+ const now = Date.now();
2083
+ const newCache = new Map(cache);
2084
+ newCache.forEach((entry, k) => {
2085
+ if (now - entry.timestamp > CACHE_TTL2) {
2086
+ newCache.delete(k);
2087
+ }
2088
+ });
2089
+ if (newCache.size >= MAX_CACHE_SIZE2) {
2090
+ const firstKey = newCache.keys().next().value;
2091
+ if (firstKey !== void 0) {
2092
+ newCache.delete(firstKey);
2093
+ }
2094
+ }
2095
+ newCache.set(key, { value, timestamp: now });
2096
+ setCache(newCache);
2097
+ updateLocalStorage(newCache);
2098
+ }, [cache, updateLocalStorage]);
2099
+ const get = (0, import_react35.useCallback)((key) => {
2100
+ const entry = cache.get(key);
2101
+ if (entry) {
2102
+ if (Date.now() - entry.timestamp > CACHE_TTL2) {
2103
+ const newCache = new Map(cache);
2104
+ newCache.delete(key);
2105
+ setCache(newCache);
2106
+ updateLocalStorage(newCache);
2107
+ return void 0;
2108
+ }
2109
+ return entry.value;
2110
+ }
2111
+ return void 0;
2112
+ }, [cache, updateLocalStorage]);
2113
+ const del = (0, import_react35.useCallback)((key) => {
2114
+ if (cache.has(key)) {
2115
+ const newCache = new Map(cache);
2116
+ newCache.delete(key);
2117
+ setCache(newCache);
2118
+ updateLocalStorage(newCache);
2119
+ }
2120
+ }, [cache, updateLocalStorage]);
2121
+ const clear = (0, import_react35.useCallback)(() => {
2122
+ setCache(/* @__PURE__ */ new Map());
2123
+ if (isLocalStorageAvailable) {
2124
+ localStorage.removeItem(STORAGE_KEY2);
2125
+ }
2126
+ }, [isLocalStorageAvailable]);
2127
+ return { set, get, del, clear };
2128
+ }
2129
+ function useTransaction({
2130
+ chainId,
2131
+ hash
2132
+ }) {
2133
+ const { list } = useMatchChain();
2134
+ const cache = useTransactionCache();
2135
+ const chain = list?.find((item) => item.id === chainId);
2136
+ const [shouldRefetch, setShouldRefetch] = (0, import_react35.useState)(true);
2137
+ const query = (0, import_react_query6.useQuery)({
2138
+ queryKey: ["match-tx-transaction", hash, chain],
2139
+ queryFn: async () => {
2140
+ if (!chain || !hash) return false;
2141
+ const cacheKey = `${chain.id}-${hash}`;
2142
+ if (cache.get(cacheKey)) {
2143
+ return cache.get(cacheKey);
2144
+ }
2145
+ try {
2146
+ const publicClient = (0, import_viem7.createPublicClient)({
2147
+ chain: (0, import_viem7.defineChain)(chain),
2148
+ transport: (0, import_viem7.http)()
2149
+ });
2150
+ const transaction = await publicClient.getTransaction({ hash });
2151
+ if (!transaction) {
2152
+ return false;
2153
+ }
2154
+ cache.set(cacheKey, transaction);
2155
+ return transaction;
2156
+ } catch (e) {
2157
+ return false;
2158
+ }
2159
+ },
2160
+ refetchInterval: shouldRefetch ? 1e4 : false
2161
+ });
2162
+ (0, import_react35.useEffect)(() => {
2163
+ if (query.data) {
2164
+ setShouldRefetch(false);
2165
+ }
2166
+ }, [query.data]);
2167
+ return query;
2168
+ }
1759
2169
  // Annotate the CommonJS export names for ESM import in node:
1760
2170
  0 && (module.exports = {
1761
2171
  useCopyClipboard,
@@ -1767,6 +2177,7 @@ function useReceipt({
1767
2177
  useModal,
1768
2178
  useReceipt,
1769
2179
  useToast,
2180
+ useTransaction,
1770
2181
  useUserInfo,
1771
2182
  useWallet
1772
2183
  });