@matchain/matchid-sdk-react 0.1.54 → 0.1.55-alpha.0

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 (55) hide show
  1. package/dist/assets/icon/index.d.mts +2 -2
  2. package/dist/assets/icon/index.d.ts +2 -2
  3. package/dist/{chunk-ZPBHHXEE.mjs → chunk-36M5ROJI.mjs} +6543 -6897
  4. package/dist/chunk-36M5ROJI.mjs.map +1 -0
  5. package/dist/chunk-N7NX7Q7M.mjs +97 -0
  6. package/dist/chunk-N7NX7Q7M.mjs.map +1 -0
  7. package/dist/components/index.d.mts +3 -3
  8. package/dist/components/index.d.ts +3 -3
  9. package/dist/components/index.js +0 -354
  10. package/dist/components/index.js.map +1 -1
  11. package/dist/components/index.mjs +2 -6
  12. package/dist/hooks/api/index.d.mts +2 -2
  13. package/dist/hooks/api/index.d.ts +2 -2
  14. package/dist/hooks/api/index.js +45 -215
  15. package/dist/hooks/api/index.js.map +1 -1
  16. package/dist/hooks/api/index.mjs +6 -6
  17. package/dist/hooks/index.d.mts +2 -2
  18. package/dist/hooks/index.d.ts +2 -2
  19. package/dist/hooks/index.js +186 -203
  20. package/dist/hooks/index.js.map +1 -1
  21. package/dist/hooks/index.mjs +2 -2
  22. package/dist/{index-91BdMYDA.d.ts → index-6-oVBXRP.d.mts} +2 -5
  23. package/dist/{index-CkHDxE7B.d.mts → index-CBQXIlWu.d.mts} +1 -1
  24. package/dist/{index-ChHJD4NZ.d.mts → index-CMH6Jesl.d.ts} +2 -5
  25. package/dist/{index-Dj1K-UdZ.d.ts → index-CNH7a3bx.d.ts} +5 -18
  26. package/dist/{index-CZu_8fKl.d.ts → index-CPPDmmz8.d.ts} +1 -1
  27. package/dist/{index-DX1vzCrM.d.mts → index-CqKohtvj.d.mts} +1 -1
  28. package/dist/{index-CPk553v5.d.mts → index-D0Psl8Ue.d.mts} +1 -1
  29. package/dist/{index-DFBrN7dx.d.ts → index-DbQn4z1l.d.ts} +1 -1
  30. package/dist/{index-D5geEbXf.d.ts → index-Es7yJi7T.d.ts} +2 -2
  31. package/dist/{index-DjwwXNp4.d.mts → index-G15A08DI.d.mts} +3 -40
  32. package/dist/{index-DSvRdAyZ.d.mts → index-MsSYZS38.d.mts} +2 -2
  33. package/dist/{index-Vxvd14yW.d.ts → index-Y5WRoqzn.d.ts} +3 -40
  34. package/dist/{index-CPwcm70o.d.mts → index-a_Qt7NXk.d.mts} +5 -18
  35. package/dist/{index-SRHVQn5G.d.ts → index-agAVLGF5.d.ts} +1 -1
  36. package/dist/index.css +0 -120
  37. package/dist/index.d.mts +8 -8
  38. package/dist/index.d.ts +8 -8
  39. package/dist/index.js +570 -853
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +7 -5
  42. package/dist/types/index.d.mts +1 -1
  43. package/dist/types/index.d.ts +1 -1
  44. package/dist/{types-Bi9iq57H.d.mts → types-CXzZS0eM.d.mts} +1 -20
  45. package/dist/{types-Bi9iq57H.d.ts → types-CXzZS0eM.d.ts} +1 -20
  46. package/dist/ui/index.d.mts +3 -3
  47. package/dist/ui/index.d.ts +3 -3
  48. package/dist/ui/index.js +52 -69
  49. package/dist/ui/index.js.map +1 -1
  50. package/dist/ui/index.mjs +2 -2
  51. package/example/src/App.tsx +0 -8
  52. package/example/src/pages/Wallet/index.tsx +1 -1
  53. package/package.json +1 -1
  54. package/dist/chunk-ZPBHHXEE.mjs.map +0 -1
  55. package/example/src/pages/Contact/index.tsx +0 -90
@@ -0,0 +1,97 @@
1
+ import {
2
+ bindCexApi,
3
+ chooseIdentityApi,
4
+ getBindInfoApi,
5
+ getBindListApi,
6
+ getPohListApi,
7
+ isSuccess,
8
+ mintPassportNftApi,
9
+ unBindApi,
10
+ unBindWalletApi,
11
+ useUserInfo,
12
+ verifyPohApi,
13
+ wallet_exports
14
+ } from "./chunk-36M5ROJI.mjs";
15
+ import {
16
+ __export
17
+ } from "./chunk-J5LGTIGS.mjs";
18
+
19
+ // src/hooks/api/index.ts
20
+ var api_exports = {};
21
+ __export(api_exports, {
22
+ bind: () => bind_exports,
23
+ isSuccess: () => isSuccess,
24
+ poh: () => poh_exports,
25
+ user: () => user_exports,
26
+ wallet: () => wallet_exports
27
+ });
28
+
29
+ // src/hooks/api/bind.ts
30
+ var bind_exports = {};
31
+ __export(bind_exports, {
32
+ bindCexApi: () => bindCexApi,
33
+ unBindApi: () => unBindApi,
34
+ unBindWalletApi: () => unBindWalletApi,
35
+ useBindInfo: () => useBindInfo,
36
+ useBindList: () => useBindList
37
+ });
38
+ import { useQuery } from "@tanstack/react-query";
39
+ function useBindList(options) {
40
+ const { isLogin } = useUserInfo();
41
+ return useQuery({
42
+ queryKey: ["bindList"],
43
+ enabled: isLogin,
44
+ queryFn: async () => {
45
+ let res = await getBindListApi();
46
+ return res.data;
47
+ },
48
+ ...options
49
+ });
50
+ }
51
+ function useBindInfo(options) {
52
+ const { isLogin } = useUserInfo();
53
+ return useQuery({
54
+ queryKey: ["bindInfo"],
55
+ enabled: isLogin,
56
+ queryFn: async () => {
57
+ let res = await getBindInfoApi();
58
+ return res.data;
59
+ },
60
+ ...options
61
+ });
62
+ }
63
+
64
+ // src/hooks/api/poh.ts
65
+ var poh_exports = {};
66
+ __export(poh_exports, {
67
+ usePohList: () => usePohList,
68
+ verifyPohApi: () => verifyPohApi
69
+ });
70
+ import { useQuery as useQuery2 } from "@tanstack/react-query";
71
+ function usePohList(options) {
72
+ const { isLogin } = useUserInfo();
73
+ return useQuery2({
74
+ queryKey: ["pohList"],
75
+ enabled: isLogin,
76
+ queryFn: async () => {
77
+ let res = await getPohListApi();
78
+ return res.data;
79
+ },
80
+ ...options
81
+ });
82
+ }
83
+
84
+ // src/hooks/api/user.ts
85
+ var user_exports = {};
86
+ __export(user_exports, {
87
+ chooseIdentityApi: () => chooseIdentityApi,
88
+ mintPassportNftApi: () => mintPassportNftApi
89
+ });
90
+
91
+ export {
92
+ bind_exports,
93
+ poh_exports,
94
+ user_exports,
95
+ api_exports
96
+ };
97
+ //# sourceMappingURL=chunk-N7NX7Q7M.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/api/index.ts","../src/hooks/api/bind.ts","../src/hooks/api/poh.ts","../src/hooks/api/user.ts"],"sourcesContent":["export * as bind from \"./bind\";\nexport * as poh from \"./poh\";\nexport * as user from \"./user\";\nexport * as wallet from \"./wallet\";\nexport {isSuccess} from \"../../api/request\"","import {useQuery} from \"@tanstack/react-query\";\nimport useUserInfo from \"../useUserInfo\";\nimport type {UseQueryOptions} from \"@tanstack/react-query/src/types\";\nimport {BindInfoType, BindItemType} from \"../../types/types\";\nimport {getBindInfoApi, getBindListApi} from \"../../api\";\n\nexport {bindCexApi, unBindApi, unBindWalletApi} from \"../../api\";\n\nexport function useBindList(options?: Partial<Omit<UseQueryOptions<BindItemType[]>, 'queryKey' | 'queryFn'>>) {\n const {isLogin} = useUserInfo()\n return useQuery<BindItemType[]>({\n queryKey: ['bindList'],\n enabled: isLogin,\n queryFn: async () => {\n let res = await getBindListApi()\n return res.data\n },\n ...options\n })\n}\n\nexport function useBindInfo(options?: Partial<Omit<UseQueryOptions<BindInfoType>, 'queryKey' | 'queryFn'>>) {\n const {isLogin} = useUserInfo()\n return useQuery<BindInfoType>({\n queryKey: ['bindInfo'],\n enabled: isLogin,\n queryFn: async () => {\n let res = await getBindInfoApi()\n return res.data\n },\n ...options\n })\n}\n","import {useQuery} from \"@tanstack/react-query\";\nimport useUserInfo from \"../useUserInfo\";\nimport type {UseQueryOptions} from \"@tanstack/react-query/src/types\";\nimport {PohItemType} from \"types/types\";\nimport {getPohListApi} from \"api\";\nexport {verifyPohApi} from \"api\";\n\nexport function usePohList(options?: Partial<Omit<UseQueryOptions<PohItemType[]>, 'queryKey' | 'queryFn'>>) {\n const {isLogin} = useUserInfo()\n return useQuery<PohItemType[]>({\n queryKey: ['pohList'],\n enabled: isLogin,\n queryFn: async () => {\n let res = await getPohListApi()\n return res.data\n },\n ...options\n })\n}","export {mintPassportNftApi,chooseIdentityApi} from \"api\""],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAQ,gBAAe;AAQhB,SAAS,YAAY,SAAkF;AAC1G,QAAM,EAAC,QAAO,IAAI,YAAY;AAC9B,SAAO,SAAyB;AAAA,IAC5B,UAAU,CAAC,UAAU;AAAA,IACrB,SAAS;AAAA,IACT,SAAS,YAAY;AACjB,UAAI,MAAM,MAAM,eAAe;AAC/B,aAAO,IAAI;AAAA,IACf;AAAA,IACA,GAAG;AAAA,EACP,CAAC;AACL;AAEO,SAAS,YAAY,SAAgF;AACxG,QAAM,EAAC,QAAO,IAAI,YAAY;AAC9B,SAAO,SAAuB;AAAA,IAC1B,UAAU,CAAC,UAAU;AAAA,IACrB,SAAS;AAAA,IACT,SAAS,YAAY;AACjB,UAAI,MAAM,MAAM,eAAe;AAC/B,aAAO,IAAI;AAAA,IACf;AAAA,IACA,GAAG;AAAA,EACP,CAAC;AACL;;;AChCA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAQ,YAAAA,iBAAe;AAOhB,SAAS,WAAW,SAAiF;AACxG,QAAM,EAAC,QAAO,IAAI,YAAY;AAC9B,SAAOC,UAAwB;AAAA,IAC3B,UAAU,CAAC,SAAS;AAAA,IACpB,SAAS;AAAA,IACT,SAAS,YAAY;AACjB,UAAI,MAAM,MAAM,cAAc;AAC9B,aAAO,IAAI;AAAA,IACf;AAAA,IACA,GAAG;AAAA,EACP,CAAC;AACL;;;AClBA;AAAA;AAAA;AAAA;AAAA;","names":["useQuery","useQuery"]}
@@ -1,6 +1,6 @@
1
- export { B as BTCModal, l as ContactCard, C as ContactList, d as EVMModal, E as EmailModal, L as LoginBox, a as LoginButton, c as LoginModal, b as LoginPanel, e as TONModal, T as TRONModal, g as TokenDetail, h as TokenSend, j as TokenSendList, k as TransactionList, U as UsernameModal, f as WalletAsset, W as WalletModal } from '../index-CPwcm70o.mjs';
2
- export { B as Button, F as Field, I as Input, M as Modal, a as ModalWithHeader, O as Overlay, P as Popover } from '../index-CkHDxE7B.mjs';
1
+ export { B as BTCModal, d as EVMModal, E as EmailModal, L as LoginBox, a as LoginButton, c as LoginModal, b as LoginPanel, e as TONModal, T as TRONModal, g as TokenDetail, h as TokenSend, j as TokenSendList, k as TransactionList, U as UsernameModal, f as WalletAsset, W as WalletModal } from '../index-a_Qt7NXk.mjs';
2
+ export { B as Button, F as Field, I as Input, M as Modal, a as ModalWithHeader, O as Overlay, P as Popover } from '../index-CBQXIlWu.mjs';
3
3
  import 'react/jsx-runtime';
4
- import '../types-Bi9iq57H.mjs';
4
+ import '../types-CXzZS0eM.mjs';
5
5
  import 'react';
6
6
  import '@tanstack/react-query/src/types';
@@ -1,6 +1,6 @@
1
- export { B as BTCModal, l as ContactCard, C as ContactList, d as EVMModal, E as EmailModal, L as LoginBox, a as LoginButton, c as LoginModal, b as LoginPanel, e as TONModal, T as TRONModal, g as TokenDetail, h as TokenSend, j as TokenSendList, k as TransactionList, U as UsernameModal, f as WalletAsset, W as WalletModal } from '../index-Dj1K-UdZ.js';
2
- export { B as Button, F as Field, I as Input, M as Modal, a as ModalWithHeader, O as Overlay, P as Popover } from '../index-SRHVQn5G.js';
1
+ export { B as BTCModal, d as EVMModal, E as EmailModal, L as LoginBox, a as LoginButton, c as LoginModal, b as LoginPanel, e as TONModal, T as TRONModal, g as TokenDetail, h as TokenSend, j as TokenSendList, k as TransactionList, U as UsernameModal, f as WalletAsset, W as WalletModal } from '../index-CNH7a3bx.js';
2
+ export { B as Button, F as Field, I as Input, M as Modal, a as ModalWithHeader, O as Overlay, P as Popover } from '../index-agAVLGF5.js';
3
3
  import 'react/jsx-runtime';
4
- import '../types-Bi9iq57H.js';
4
+ import '../types-CXzZS0eM.js';
5
5
  import 'react';
6
6
  import '@tanstack/react-query/src/types';
@@ -32,8 +32,6 @@ var components_exports = {};
32
32
  __export(components_exports, {
33
33
  BTCModal: () => BTCModal,
34
34
  Button: () => Button,
35
- ContactCard: () => ContactCard,
36
- ContactList: () => ContactList,
37
35
  EVMModal: () => EVMModal,
38
36
  EmailModal: () => EmailModal,
39
37
  Field: () => Field,
@@ -1208,36 +1206,6 @@ function PhantomIcon({
1208
1206
 
1209
1207
  // src/assets/icon/MoreIcon.tsx
1210
1208
  var import_jsx_runtime50 = require("react/jsx-runtime");
1211
- function MoreIcon({
1212
- width = "11",
1213
- height = "3",
1214
- color = "black",
1215
- ...props
1216
- }) {
1217
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width, height, viewBox: "0 0 11 3", fill: "none", ...props, children: [
1218
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
1219
- "path",
1220
- {
1221
- d: "M2.3335 1.33325C2.3335 1.88554 1.88578 2.33325 1.3335 2.33325C0.781211 2.33325 0.333496 1.88554 0.333496 1.33325C0.333496 0.780967 0.781211 0.333252 1.3335 0.333252C1.88578 0.333252 2.3335 0.780967 2.3335 1.33325Z",
1222
- fill: color
1223
- }
1224
- ),
1225
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
1226
- "path",
1227
- {
1228
- d: "M6.3335 1.33325C6.3335 1.88554 5.88578 2.33325 5.3335 2.33325C4.78121 2.33325 4.3335 1.88554 4.3335 1.33325C4.3335 0.780967 4.78121 0.333252 5.3335 0.333252C5.88578 0.333252 6.3335 0.780967 6.3335 1.33325Z",
1229
- fill: color
1230
- }
1231
- ),
1232
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
1233
- "path",
1234
- {
1235
- d: "M10.3335 1.33325C10.3335 1.88554 9.88578 2.33325 9.3335 2.33325C8.78121 2.33325 8.3335 1.88554 8.3335 1.33325C8.3335 0.780967 8.78121 0.333252 9.3335 0.333252C9.88578 0.333252 10.3335 0.780967 10.3335 1.33325Z",
1236
- fill: color
1237
- }
1238
- )
1239
- ] });
1240
- }
1241
1209
 
1242
1210
  // src/hooks/useLayout.tsx
1243
1211
  var import_react = require("react");
@@ -1864,47 +1832,6 @@ var tgAppLoginInitApi = () => {
1864
1832
  method: "GET"
1865
1833
  });
1866
1834
  };
1867
- var getContactListApi = (data) => {
1868
- return request_default({
1869
- url: `/api/v1/contacts/list`,
1870
- method: "POST",
1871
- data
1872
- });
1873
- };
1874
- var searchContactsApi = (data) => {
1875
- return request_default({
1876
- url: `/api/v1/contacts/search`,
1877
- method: "POST",
1878
- data
1879
- });
1880
- };
1881
- var addContactsApi = (data) => {
1882
- return request_default({
1883
- url: `/api/v1/contacts/add`,
1884
- method: "POST",
1885
- data
1886
- });
1887
- };
1888
- var acceptContactsApi = (data) => {
1889
- return request_default({
1890
- url: `/api/v1/contacts/accept`,
1891
- method: "POST",
1892
- data
1893
- });
1894
- };
1895
- var delContactsApi = (data) => {
1896
- return request_default({
1897
- url: `/api/v1/contacts/del`,
1898
- method: "POST",
1899
- data
1900
- });
1901
- };
1902
- var getContractsInfoApi = () => {
1903
- return retryRequest({
1904
- url: `/api/v1/contacts/info`,
1905
- method: "GET"
1906
- });
1907
- };
1908
1835
  var userInviteApi = (data) => {
1909
1836
  return request_default({
1910
1837
  url: `/api/v1/user/invite`,
@@ -2306,33 +2233,6 @@ function Radio({
2306
2233
 
2307
2234
  // src/ui/Skeleton/index.tsx
2308
2235
  var import_jsx_runtime65 = require("react/jsx-runtime");
2309
- var Skeleton = ({
2310
- style = {},
2311
- className = "",
2312
- width = 40,
2313
- height = 40,
2314
- radius = 5,
2315
- loading = true,
2316
- children
2317
- }) => {
2318
- if (!loading) {
2319
- return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_jsx_runtime65.Fragment, { children });
2320
- }
2321
- const skeletonStyle = {
2322
- width,
2323
- height,
2324
- borderRadius: radius,
2325
- ...style
2326
- };
2327
- return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
2328
- "div",
2329
- {
2330
- className: "matchid-skeleton " + className,
2331
- style: skeletonStyle
2332
- }
2333
- );
2334
- };
2335
- var Skeleton_default = Skeleton;
2336
2236
 
2337
2237
  // src/ui/Tabs/index.tsx
2338
2238
  var import_jsx_runtime66 = require("react/jsx-runtime");
@@ -2631,13 +2531,6 @@ var import_react13 = require("react");
2631
2531
  var import_react_dom2 = require("react-dom");
2632
2532
  var import_jsx_runtime69 = require("react/jsx-runtime");
2633
2533
  var ToastContext = (0, import_react13.createContext)(null);
2634
- function useToast() {
2635
- const context = (0, import_react13.useContext)(ToastContext);
2636
- if (!context) {
2637
- throw new Error("useToast must be used within a ToastProvider");
2638
- }
2639
- return context;
2640
- }
2641
2534
 
2642
2535
  // src/hooks/api/wallet.ts
2643
2536
  var import_react_query2 = require("@tanstack/react-query");
@@ -6468,257 +6361,10 @@ function TransactionList({
6468
6361
  }
6469
6362
  );
6470
6363
  }
6471
-
6472
- // src/hooks/api/bind.ts
6473
- var import_react_query11 = require("@tanstack/react-query");
6474
-
6475
- // src/hooks/api/poh.ts
6476
- var import_react_query12 = require("@tanstack/react-query");
6477
-
6478
- // src/hooks/api/contact.ts
6479
- var contact_exports = {};
6480
- __export(contact_exports, {
6481
- acceptContact: () => acceptContact,
6482
- addContact: () => addContact,
6483
- delContact: () => delContact,
6484
- useContactInfo: () => useContactInfo,
6485
- useContactList: () => useContactList,
6486
- useContactSearch: () => useContactSearch
6487
- });
6488
- var import_react_query13 = require("@tanstack/react-query");
6489
- var import_last = __toESM(require("lodash/last"));
6490
- var import_react43 = require("react");
6491
- function useContactList(page_size = 10, type = "Friend") {
6492
- const { address } = useUserInfo();
6493
- const limitIdRef = (0, import_react43.useRef)(0);
6494
- const contactQuery = (0, import_react_query13.useInfiniteQuery)({
6495
- queryKey: ["matchid-contacts-list", type, address],
6496
- initialPageParam: 1,
6497
- queryFn: async (args) => {
6498
- console.log(args);
6499
- if (args.pageParam <= 1) {
6500
- limitIdRef.current = 0;
6501
- }
6502
- return (await getContactListApi({
6503
- limit: page_size,
6504
- limit_id: limitIdRef.current,
6505
- type
6506
- })).data;
6507
- },
6508
- getNextPageParam: (lastPage, allPages) => {
6509
- if (!lastPage) return void 0;
6510
- const lastPageNum = Math.ceil(lastPage.meta.total / page_size);
6511
- return allPages.length >= lastPageNum ? void 0 : allPages.length + 1;
6512
- }
6513
- });
6514
- (0, import_react43.useEffect)(() => {
6515
- if (!contactQuery.data?.pages || contactQuery.data?.pages.length == 0) {
6516
- limitIdRef.current = 0;
6517
- } else {
6518
- const lastPage = (0, import_last.default)(contactQuery.data?.pages);
6519
- const items = lastPage?.items;
6520
- if (!items || items.length == 0) {
6521
- limitIdRef.current = 0;
6522
- return;
6523
- }
6524
- const lastItem = (0, import_last.default)(items);
6525
- limitIdRef.current = lastItem?.limit_id || 0;
6526
- }
6527
- }, [contactQuery.data?.pages]);
6528
- (0, import_react43.useEffect)(() => {
6529
- console.log("contactQuery.data", contactQuery.data);
6530
- }, [contactQuery.data]);
6531
- const data = (0, import_react43.useMemo)(() => {
6532
- return (contactQuery.data?.pages ?? []).reduce(
6533
- (a, b) => {
6534
- return a.concat(b?.items ?? []);
6535
- },
6536
- []
6537
- );
6538
- }, [contactQuery.data]);
6539
- return {
6540
- data,
6541
- totalCount: contactQuery.hasNextPage ? ((0, import_last.default)(contactQuery.data?.pages ?? [])?.meta.total ?? 0) + 1 : (0, import_last.default)(contactQuery.data?.pages ?? [])?.meta.total ?? 0,
6542
- loading: contactQuery.isLoading,
6543
- loadingNextPage: contactQuery.isFetchingNextPage,
6544
- hasNextPage: contactQuery.hasNextPage,
6545
- onLoadMore: contactQuery.fetchNextPage
6546
- };
6547
- }
6548
- function useContactSearch(keyword, options) {
6549
- return (0, import_react_query13.useQuery)({
6550
- queryKey: ["matchid-contacts-search", keyword],
6551
- enabled: !!keyword,
6552
- queryFn: async () => {
6553
- return (await searchContactsApi({
6554
- address: keyword
6555
- })).data;
6556
- },
6557
- ...options
6558
- });
6559
- }
6560
- function useContactInfo(options) {
6561
- const { address } = useUserInfo();
6562
- return (0, import_react_query13.useQuery)({
6563
- queryKey: ["matchid-contacts-info", address],
6564
- enabled: !!address,
6565
- queryFn: async () => {
6566
- return (await getContractsInfoApi()).data;
6567
- },
6568
- ...options
6569
- });
6570
- }
6571
- var addContact = async (friend_id) => {
6572
- const res = await addContactsApi({
6573
- friend_id: typeof friend_id === "string" ? friend_id : friend_id.did
6574
- });
6575
- if (isSuccess(res)) {
6576
- return true;
6577
- }
6578
- throw new Error(res.message);
6579
- };
6580
- var acceptContact = async (friend_id) => {
6581
- const res = await acceptContactsApi({
6582
- friend_id: typeof friend_id === "string" ? friend_id : friend_id.did
6583
- });
6584
- if (isSuccess(res)) {
6585
- return true;
6586
- }
6587
- throw new Error(res.message);
6588
- };
6589
- var delContact = async (friend_id) => {
6590
- const res = await delContactsApi({
6591
- friend_id: typeof friend_id === "string" ? friend_id : friend_id.did
6592
- });
6593
- if (isSuccess(res)) {
6594
- return true;
6595
- }
6596
- throw new Error(res.message);
6597
- };
6598
-
6599
- // src/components/ContactList/index.tsx
6600
- var import_react_virtuoso = require("react-virtuoso");
6601
- var import_react44 = require("react");
6602
- var import_react_intl24 = require("react-intl");
6603
- var import_jsx_runtime99 = require("react/jsx-runtime");
6604
- function ContactCard({
6605
- loading = false,
6606
- data,
6607
- action
6608
- }) {
6609
- const isDownMd = useDownMd();
6610
- return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: "matchid-flex matchid-contact-item", children: [
6611
- /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: "matchid-contact-item-content", children: [
6612
- /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Skeleton_default, { width: isDownMd ? 36 : 48, height: isDownMd ? 36 : 48, radius: 100, loading, children: data?.avatar ? /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("img", { src: data?.avatar, className: "matchid-contact-item-avatar" }) : /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(AlphaAvatar, { size: isDownMd ? 36 : 48, name: data?.name || data?.username || "MatchID" }) }),
6613
- /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: "matchid-contact-item-info", children: [
6614
- /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "matchid-contact-item-name", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Skeleton_default, { width: 80, height: isDownMd ? 16 : 20, loading, children: data?.name || data?.username || "MatchID User" }) }),
6615
- /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "matchid-contact-item-address", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Skeleton_default, { width: 80, height: isDownMd ? 12 : 16, loading, children: truncateAddress(data?.address || "", 6, 6) }) })
6616
- ] })
6617
- ] }),
6618
- action && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "matchid-contact-item-action", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Skeleton_default, { width: 20, height: 20, loading, children: action() }) })
6619
- ] });
6620
- }
6621
- function RequestAction({ data, onSuccess }) {
6622
- const [loading, setLoading] = (0, import_react44.useState)(false);
6623
- const toast = useToast();
6624
- const intl = (0, import_react_intl24.useIntl)();
6625
- const onApprove = async () => {
6626
- setLoading(true);
6627
- try {
6628
- await contact_exports.acceptContact(data);
6629
- toast.success(intl.formatMessage({
6630
- id: "approveSuccess"
6631
- }));
6632
- onSuccess && onSuccess(data);
6633
- } catch (e) {
6634
- console.error(e);
6635
- toast.error(e.message);
6636
- } finally {
6637
- setLoading(false);
6638
- }
6639
- };
6640
- return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Button, { size: "sm", onClick: onApprove, loading, children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_react_intl24.FormattedMessage, { id: "Approve" }) });
6641
- }
6642
- function FriendsAction({
6643
- data,
6644
- onSuccess
6645
- }) {
6646
- const [loading, setLoading] = (0, import_react44.useState)(false);
6647
- const toast = useToast();
6648
- const intl = (0, import_react_intl24.useIntl)();
6649
- const onRemove = async () => {
6650
- setLoading(true);
6651
- try {
6652
- await contact_exports.delContact(data);
6653
- toast.success(intl.formatMessage({
6654
- id: "removeSuccess"
6655
- }));
6656
- onSuccess && onSuccess(data);
6657
- } catch (e) {
6658
- console.error(e);
6659
- toast.error(e.message);
6660
- } finally {
6661
- setLoading(false);
6662
- }
6663
- };
6664
- return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Popover, { content: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "matchid-remove-box", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Button, { size: "sm", loading, onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_react_intl24.FormattedMessage, { id: "Remove" }) }) }), children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(MoreIcon, { className: "matchid-cursor-pointer" }) });
6665
- }
6666
- function ContactList({
6667
- limit = 10,
6668
- height = 660,
6669
- type = "Friend"
6670
- }) {
6671
- const { loading, totalCount, data, onLoadMore } = contact_exports.useContactList(limit, type);
6672
- const [hiddenList, setHiddenList] = (0, import_react44.useState)([]);
6673
- const { address } = useWallet();
6674
- (0, import_react44.useEffect)(() => {
6675
- setHiddenList([]);
6676
- }, [type]);
6677
- return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
6678
- import_react_virtuoso.Virtuoso,
6679
- {
6680
- style: {
6681
- height
6682
- },
6683
- totalCount: loading ? 10 : totalCount,
6684
- itemContent: (index) => {
6685
- if (loading || !data[index]) {
6686
- return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(ContactCard, { loading: true });
6687
- }
6688
- if (hiddenList.includes(data[index].limit_id || 0)) {
6689
- return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_jsx_runtime99.Fragment, {});
6690
- }
6691
- const item = data[index];
6692
- return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(ContactCard, { data: item, action: () => {
6693
- if (address == item.address) {
6694
- return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_jsx_runtime99.Fragment, {});
6695
- }
6696
- if (type == "Requests") {
6697
- return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(RequestAction, { data: item, onSuccess: (data2) => {
6698
- setHiddenList([...hiddenList, data2.limit_id || 0]);
6699
- } });
6700
- }
6701
- return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(FriendsAction, { data: item, onSuccess: (data2) => {
6702
- setHiddenList([...hiddenList, data2.limit_id || 0]);
6703
- } });
6704
- } });
6705
- },
6706
- endReached: () => {
6707
- onLoadMore();
6708
- },
6709
- components: {
6710
- EmptyPlaceholder: () => /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "matchid-nomore", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_react_intl24.FormattedMessage, { id: type == "Friend" ? "noFriends" : "noRequests" }) }),
6711
- Footer: data.length > 0 ? () => /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "matchid-nomore", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_react_intl24.FormattedMessage, { id: "noMore" }) }) : void 0
6712
- }
6713
- }
6714
- );
6715
- }
6716
6364
  // Annotate the CommonJS export names for ESM import in node:
6717
6365
  0 && (module.exports = {
6718
6366
  BTCModal,
6719
6367
  Button,
6720
- ContactCard,
6721
- ContactList,
6722
6368
  EVMModal,
6723
6369
  EmailModal,
6724
6370
  Field,