@matchain/matchid-sdk-react 0.1.44-alpha.4 → 0.1.44-alpha.6

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 (65) hide show
  1. package/dist/assets/icon/index.d.mts +1 -1
  2. package/dist/assets/icon/index.d.ts +1 -1
  3. package/dist/{chunk-24AMOG53.mjs → chunk-WNLUMXC7.mjs} +2 -2
  4. package/dist/{chunk-RAX4G26O.mjs → chunk-XN7LSOI7.mjs} +138 -47
  5. package/dist/chunk-XN7LSOI7.mjs.map +1 -0
  6. package/dist/components/index.d.mts +2 -2
  7. package/dist/components/index.d.ts +2 -2
  8. package/dist/components/index.js +107 -28
  9. package/dist/components/index.js.map +1 -1
  10. package/dist/components/index.mjs +2 -2
  11. package/dist/hooks/api/index.d.mts +2 -2
  12. package/dist/hooks/api/index.d.ts +2 -2
  13. package/dist/hooks/api/index.js +24 -18
  14. package/dist/hooks/api/index.js.map +1 -1
  15. package/dist/hooks/api/index.mjs +3 -3
  16. package/dist/hooks/index.d.mts +2 -2
  17. package/dist/hooks/index.d.ts +2 -2
  18. package/dist/hooks/index.js +45 -32
  19. package/dist/hooks/index.js.map +1 -1
  20. package/dist/hooks/index.mjs +2 -2
  21. package/dist/{index-x432SkFJ.d.ts → index-BlEZbcLQ.d.ts} +1 -1
  22. package/dist/{index-DzVjb4K-.d.ts → index-C3jFoWRx.d.ts} +3 -2
  23. package/dist/{index-DnK10Gz7.d.mts → index-CI39w5wj.d.mts} +4 -1
  24. package/dist/{index-DAj3aVo6.d.mts → index-CYmxvLZ0.d.mts} +3 -2
  25. package/dist/{index-ivTptZeo.d.ts → index-DS7SWbPe.d.ts} +4 -1
  26. package/dist/{index-BQDL8XkC.d.ts → index-DYJIwNhC.d.ts} +1 -1
  27. package/dist/{index-C1NfMaCm.d.mts → index-RwnmlYR_.d.mts} +1 -1
  28. package/dist/{index-Rb-jdkzE.d.mts → index-rWzOcTWj.d.mts} +1 -1
  29. package/dist/index.css +5 -4
  30. package/dist/index.d.mts +5 -5
  31. package/dist/index.d.ts +5 -5
  32. package/dist/index.js +161 -70
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.mjs +6 -6
  35. package/dist/types/index.d.mts +1 -1
  36. package/dist/types/index.d.ts +1 -1
  37. package/dist/{types-E2MeOwmE.d.mts → types-cM1c-GDc.d.mts} +7 -1
  38. package/dist/{types-E2MeOwmE.d.ts → types-cM1c-GDc.d.ts} +7 -1
  39. package/example/dist/assets/TransportWebHID-B92GXP0w.js +1 -0
  40. package/example/dist/assets/bignumber-Bn3E8wYl.js +10 -0
  41. package/example/dist/assets/ccip-CBHFCdkU.js +1 -0
  42. package/example/dist/assets/draggabilly-CLvmxSn-.js +14 -0
  43. package/example/dist/assets/index-2f4kBMap.js +1 -0
  44. package/example/dist/assets/index-8uKm8vlV.js +303 -0
  45. package/example/dist/assets/index-B628P4Pl.js +1 -0
  46. package/example/dist/assets/index-BHE8v9OY.js +3 -0
  47. package/example/dist/assets/index-CWt0Kxp-.js +3 -0
  48. package/example/dist/assets/index-CvZtcbs0.js +1283 -0
  49. package/example/dist/assets/index-Dp__7a7R.js +179 -0
  50. package/example/dist/assets/index-DvlQmnc9.js +1 -0
  51. package/example/dist/assets/index-g0UHhCzn.css +1 -0
  52. package/example/dist/assets/index-lJxfSkQk.js +569 -0
  53. package/example/dist/assets/inherits_browser-BlmhoU4v.js +1 -0
  54. package/example/dist/assets/solanaEmbed.esm-D8OwJWHg.js +38 -0
  55. package/example/dist/index.html +14 -0
  56. package/example/src/App.tsx +65 -54
  57. package/example/src/config/chains/matchMain.ts +1 -1
  58. package/example/src/config/chains/matchTest.ts +1 -1
  59. package/example/src/pages/User/components/BindListModal.tsx +1 -1
  60. package/example/src/pages/User/components/PohListModal.tsx +1 -1
  61. package/example/src/pages/User/index.tsx +1 -17
  62. package/example/src/pages/Wallet.tsx +122 -49
  63. package/package.json +1 -1
  64. package/dist/chunk-RAX4G26O.mjs.map +0 -1
  65. /package/dist/{chunk-24AMOG53.mjs.map → chunk-WNLUMXC7.mjs.map} +0 -0
@@ -1,5 +1,5 @@
1
- export { g as BTCModal, B as Button, E as EmailModal, F as Field, I as Input, L as LoginBox, b as LoginButton, d as LoginModal, c as LoginPanel, M as Modal, a as ModalWithHeader, O as Overlay, e as PasswordModal, P as Popover, S as SOLModal, f as TONModal, T as TRONModal, U as UsernameModal, W as WalletModal } from '../index-C1NfMaCm.mjs';
1
+ export { g as BTCModal, B as Button, E as EmailModal, F as Field, I as Input, L as LoginBox, b as LoginButton, d as LoginModal, c as LoginPanel, M as Modal, a as ModalWithHeader, O as Overlay, e as PasswordModal, P as Popover, S as SOLModal, f as TONModal, T as TRONModal, U as UsernameModal, W as WalletModal } from '../index-RwnmlYR_.mjs';
2
2
  import 'react/jsx-runtime';
3
- import '../types-E2MeOwmE.mjs';
3
+ import '../types-cM1c-GDc.mjs';
4
4
  import 'react';
5
5
  import '../mpc-CTbBWHld.mjs';
@@ -1,5 +1,5 @@
1
- export { g as BTCModal, B as Button, E as EmailModal, F as Field, I as Input, L as LoginBox, b as LoginButton, d as LoginModal, c as LoginPanel, M as Modal, a as ModalWithHeader, O as Overlay, e as PasswordModal, P as Popover, S as SOLModal, f as TONModal, T as TRONModal, U as UsernameModal, W as WalletModal } from '../index-x432SkFJ.js';
1
+ export { g as BTCModal, B as Button, E as EmailModal, F as Field, I as Input, L as LoginBox, b as LoginButton, d as LoginModal, c as LoginPanel, M as Modal, a as ModalWithHeader, O as Overlay, e as PasswordModal, P as Popover, S as SOLModal, f as TONModal, T as TRONModal, U as UsernameModal, W as WalletModal } from '../index-BlEZbcLQ.js';
2
2
  import 'react/jsx-runtime';
3
- import '../types-E2MeOwmE.js';
3
+ import '../types-cM1c-GDc.js';
4
4
  import 'react';
5
5
  import '../mpc-CTbBWHld.js';
@@ -1647,6 +1647,12 @@ var toBindWalletApi = ({
1647
1647
  data: { type, address, signature, message, connector_type, wallet_client_type }
1648
1648
  });
1649
1649
  };
1650
+ var getAppConfigApi = () => {
1651
+ return retryRequest({
1652
+ url: `/api/v1/app/config`,
1653
+ method: "GET"
1654
+ });
1655
+ };
1650
1656
 
1651
1657
  // src/MatchContext.tsx
1652
1658
  var import_react15 = require("react");
@@ -1720,6 +1726,7 @@ var import_zustand3 = require("zustand");
1720
1726
  // src/hooks/useConfig.tsx
1721
1727
  var import_jsx_runtime50 = require("react/jsx-runtime");
1722
1728
  var DEFAULT_WALLET_METHODS = ["evm", "sol", "btc", "tron", "ton"];
1729
+ var WALLET_METHODS = ["evm", "sol", "btc", "tron", "ton"];
1723
1730
  function useWalletConfig() {
1724
1731
  const isDownMd = useDownMd();
1725
1732
  const walletMap = {
@@ -1956,7 +1963,8 @@ function useWallet() {
1956
1963
  name: chain?.nativeCurrency?.name || "ETH",
1957
1964
  symbol: chain?.nativeCurrency?.symbol || "ETH",
1958
1965
  decimals: chain?.nativeCurrency?.decimals || 18
1959
- }
1966
+ },
1967
+ rpcUrls: chain?.rpcUrls
1960
1968
  }
1961
1969
  });
1962
1970
  },
@@ -1993,15 +2001,16 @@ function useWallet() {
1993
2001
  const chainId = chain ? chain.id : await obj.getChainId();
1994
2002
  const _chain = chain || obj.chain;
1995
2003
  const transactionId = Date.now().toString() + Math.random().toString().slice(6);
1996
- let interval = setInterval(() => {
1997
- const sendPrepareTransactionRequest = async () => {
2004
+ window.matchProvider.transactionMessageIntervalMap[transactionId] = {
2005
+ transaction,
2006
+ func: async () => {
1998
2007
  try {
1999
2008
  const {
2000
2009
  chain: chain2,
2001
2010
  account,
2002
2011
  ...prepareTransactionRequest
2003
2012
  // @ts-ignore
2004
- } = await obj.prepareTransactionRequest(transaction);
2013
+ } = await obj.prepareTransactionRequest(window.matchProvider.transactionMessageIntervalMap[transactionId].transaction);
2005
2014
  window.matchProvider.sendWalletMessage({
2006
2015
  method: "prepareTransactionRequest",
2007
2016
  data: {
@@ -2012,9 +2021,11 @@ function useWallet() {
2012
2021
  } catch (error) {
2013
2022
  console.error(error);
2014
2023
  }
2015
- };
2016
- sendPrepareTransactionRequest();
2017
- }, 1e4);
2024
+ },
2025
+ interval: setInterval(() => {
2026
+ window.matchProvider.transactionMessageIntervalMap[transactionId].func();
2027
+ }, 1e4)
2028
+ };
2018
2029
  try {
2019
2030
  const {
2020
2031
  chain: chain2,
@@ -2033,7 +2044,8 @@ function useWallet() {
2033
2044
  chain: {
2034
2045
  id: chainId,
2035
2046
  name: _chain?.name,
2036
- nativeCurrency: _chain?.nativeCurrency
2047
+ nativeCurrency: _chain?.nativeCurrency,
2048
+ rpcUrls: _chain?.rpcUrls
2037
2049
  },
2038
2050
  prepareTransactionRequest
2039
2051
  }
@@ -2046,11 +2058,13 @@ function useWallet() {
2046
2058
  hash: txHash,
2047
2059
  chain: _chain
2048
2060
  });
2049
- clearInterval(interval);
2061
+ clearInterval(window.matchProvider.transactionMessageIntervalMap[transactionId].interval);
2062
+ delete window.matchProvider.transactionMessageIntervalMap[transactionId];
2050
2063
  resolve(txHash);
2051
2064
  } catch (error) {
2052
2065
  console.error("qwe-sign-error", error);
2053
- clearInterval(interval);
2066
+ clearInterval(window.matchProvider.transactionMessageIntervalMap[transactionId].interval);
2067
+ delete window.matchProvider.transactionMessageIntervalMap[transactionId];
2054
2068
  reject(error);
2055
2069
  }
2056
2070
  };
@@ -2736,6 +2750,28 @@ function Popover({
2736
2750
  // src/components/LoginBox/index.tsx
2737
2751
  var import_react20 = require("react");
2738
2752
  var import_react_intl8 = require("react-intl");
2753
+
2754
+ // src/hooks/useAppConfig.ts
2755
+ var import_react_query3 = require("@tanstack/react-query");
2756
+ function useAppConfig() {
2757
+ const query = (0, import_react_query3.useQuery)({
2758
+ queryKey: ["appConfig"],
2759
+ queryFn: async () => {
2760
+ const res = await getAppConfigApi();
2761
+ if (!isSuccess(res)) {
2762
+ return null;
2763
+ }
2764
+ return res.data;
2765
+ }
2766
+ });
2767
+ return {
2768
+ isFetched: query.isFetched,
2769
+ isLoading: query.isLoading,
2770
+ ...query.data
2771
+ };
2772
+ }
2773
+
2774
+ // src/components/LoginBox/index.tsx
2739
2775
  var import_jsx_runtime63 = require("react/jsx-runtime");
2740
2776
  var RecommendItem = ({
2741
2777
  icon,
@@ -2777,21 +2813,54 @@ var RecommendItem = ({
2777
2813
  ] });
2778
2814
  };
2779
2815
  function LoginBox({
2780
- recommendMethods = [
2781
- "wallet",
2782
- "email",
2783
- "google"
2784
- ],
2785
- methods = [
2786
- "telegram",
2787
- "twitter",
2788
- "github",
2789
- "linkedin",
2790
- "discord"
2791
- ],
2792
- walletMethods = DEFAULT_WALLET_METHODS,
2816
+ recommendMethods,
2817
+ methods,
2818
+ walletMethods,
2793
2819
  inModal = false
2794
2820
  }) {
2821
+ const config = useAppConfig();
2822
+ const methodConfig = (0, import_react20.useMemo)(() => {
2823
+ if (recommendMethods || methods || walletMethods) {
2824
+ return {
2825
+ recommendMethods: recommendMethods || [],
2826
+ methods: methods || [],
2827
+ walletMethods: walletMethods || []
2828
+ };
2829
+ }
2830
+ if (!config.platform) {
2831
+ return {
2832
+ recommendMethods: [],
2833
+ methods: [],
2834
+ walletMethods: []
2835
+ };
2836
+ }
2837
+ const platform = config.platform.map((p) => {
2838
+ if (p == "x" || p == "X") {
2839
+ return "twitter";
2840
+ }
2841
+ return p.toLowerCase();
2842
+ });
2843
+ console.log("platform", platform);
2844
+ const walletMethodList = WALLET_METHODS.filter((m) => platform.includes(m));
2845
+ let recommendMethodList = walletMethodList.length > 0 ? ["wallet"] : [];
2846
+ let methodList = [];
2847
+ const otherMethodList = platform.filter((m) => !walletMethodList.includes(m));
2848
+ if (otherMethodList.length > 0) {
2849
+ const recommendMethodListLength = recommendMethodList.length;
2850
+ const maxRecommendMethodListLength = 3;
2851
+ if (recommendMethodListLength < maxRecommendMethodListLength) {
2852
+ recommendMethodList = recommendMethodList.concat(otherMethodList.slice(0, Math.min(maxRecommendMethodListLength - recommendMethodListLength, otherMethodList.length)));
2853
+ methodList = otherMethodList.slice(maxRecommendMethodListLength - recommendMethodListLength);
2854
+ } else {
2855
+ methodList = otherMethodList;
2856
+ }
2857
+ }
2858
+ return {
2859
+ recommendMethods: recommendMethodList,
2860
+ methods: methodList,
2861
+ walletMethods: walletMethodList
2862
+ };
2863
+ }, [config.platform, recommendMethods, methods, walletMethods]);
2795
2864
  const [emailOpen, setEmailOpen] = (0, import_react20.useState)(false);
2796
2865
  const { login } = useUserInfo();
2797
2866
  const [showWallet, setShowWallet] = (0, import_react20.useState)(false);
@@ -2855,7 +2924,7 @@ function LoginBox({
2855
2924
  const { walletMap } = useWalletConfig();
2856
2925
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
2857
2926
  (!inModal || !emailOpen) && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "matchid-login-box", children: [
2858
- /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "matchid-login-recommend-list", children: recommendMethods.map((m) => {
2927
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "matchid-login-recommend-list", children: methodConfig.recommendMethods.map((m) => {
2859
2928
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
2860
2929
  RecommendItem,
2861
2930
  {
@@ -2865,7 +2934,7 @@ function LoginBox({
2865
2934
  showChildren: m == "wallet" && showWallet,
2866
2935
  children: m == "wallet" && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
2867
2936
  /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "matchid-login-recommend-wallet-divider" }),
2868
- /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "matchid-login-recommend-wallet-list", children: walletMethods.map((n) => {
2937
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "matchid-login-recommend-wallet-list", children: methodConfig.walletMethods.map((n) => {
2869
2938
  const m2 = walletMap[n];
2870
2939
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
2871
2940
  "div",
@@ -2910,9 +2979,9 @@ function LoginBox({
2910
2979
  m
2911
2980
  );
2912
2981
  }) }),
2913
- methods.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "matchid-login-other", children: [
2982
+ methodConfig.methods.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "matchid-login-other", children: [
2914
2983
  /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "matchid-login-other-text", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react_intl8.FormattedMessage, { id: "otherLoginMethods" }) }),
2915
- /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "matchid-login-method-box", children: methods.map((m) => {
2984
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "matchid-login-method-box", children: methodConfig.methods.map((m) => {
2916
2985
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
2917
2986
  "div",
2918
2987
  {
@@ -4314,16 +4383,26 @@ function BTCModal(props) {
4314
4383
  }
4315
4384
 
4316
4385
  // src/components/WalletModal/index.tsx
4386
+ var import_react31 = require("react");
4317
4387
  var import_react_intl17 = require("react-intl");
4318
4388
  var import_jsx_runtime76 = require("react/jsx-runtime");
4319
4389
  function WalletConnectModal({
4320
4390
  type,
4321
- methods = DEFAULT_WALLET_METHODS,
4391
+ methods: _methods,
4322
4392
  ...props
4323
4393
  }) {
4324
4394
  const intl = (0, import_react_intl17.useIntl)();
4325
4395
  const { walletMap } = useWalletConfig();
4326
4396
  const { bind, login } = useUserInfo();
4397
+ const config = useAppConfig();
4398
+ const methods = (0, import_react31.useMemo)(() => {
4399
+ if (_methods) return _methods;
4400
+ if (!config.platform) {
4401
+ return [];
4402
+ }
4403
+ const platform = config.platform.map((p) => p.toLowerCase());
4404
+ return WALLET_METHODS.filter((m) => platform.includes(m));
4405
+ }, [config.platform, _methods]);
4327
4406
  return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
4328
4407
  id: type == "bind" ? "bindWith" : "loginWith"
4329
4408
  }, {