@matchain/matchid-sdk-react 0.1.49 → 0.1.50-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.
- package/dist/{chunk-5JHHHLG4.mjs → chunk-HLUFAIFV.mjs} +8 -4
- package/dist/chunk-HLUFAIFV.mjs.map +1 -0
- package/dist/{chunk-MXDPJRRH.mjs → chunk-P3WHQUXO.mjs} +79 -6
- package/dist/{chunk-MXDPJRRH.mjs.map → chunk-P3WHQUXO.mjs.map} +1 -1
- package/dist/{chunk-IKSPEZ4F.mjs → chunk-ZM2P5GEL.mjs} +2 -2
- package/dist/components/index.js +45 -7
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/hooks/api/index.js +47 -8
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +3 -3
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +67 -29
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/{index-CNzG0MX7.d.mts → index-C_TiXUOB.d.mts} +1 -1
- package/dist/{index-Bg4rqEu2.d.ts → index-Cx2Lx_mh.d.ts} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +93 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -9
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +7 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +3 -1
- package/example/src/App.tsx +12 -8
- package/example/src/pages/Wallet/index.tsx +0 -1
- package/package.json +1 -1
- package/dist/chunk-5JHHHLG4.mjs.map +0 -1
- /package/dist/{chunk-IKSPEZ4F.mjs.map → chunk-ZM2P5GEL.mjs.map} +0 -0
package/dist/hooks/index.mjs
CHANGED
|
@@ -12,12 +12,12 @@ import {
|
|
|
12
12
|
useTransaction,
|
|
13
13
|
useUserInfo,
|
|
14
14
|
useWallet
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-P3WHQUXO.mjs";
|
|
16
16
|
import "../chunk-UA6XHZHX.mjs";
|
|
17
17
|
import {
|
|
18
18
|
useLayout_exports
|
|
19
19
|
} from "../chunk-FB5MHLWX.mjs";
|
|
20
|
-
import "../chunk-
|
|
20
|
+
import "../chunk-HLUFAIFV.mjs";
|
|
21
21
|
import "../chunk-LHNKZISB.mjs";
|
|
22
22
|
import "../chunk-J5LGTIGS.mjs";
|
|
23
23
|
export {
|
|
@@ -62,7 +62,7 @@ declare const LOGIN_METHOD_MAP: {
|
|
|
62
62
|
|
|
63
63
|
declare function useUserInfo(): {
|
|
64
64
|
loginByMethod: (method: ISocialLoginMethod) => Promise<Window | null>;
|
|
65
|
-
loginByTelegram: () => Promise<Window | null>;
|
|
65
|
+
loginByTelegram: () => Promise<Window | null | undefined>;
|
|
66
66
|
loginByTwitter: () => Promise<Window | null>;
|
|
67
67
|
loginByGoogle: () => Promise<Window | null>;
|
|
68
68
|
loginByWallet: () => Promise<Window | null>;
|
|
@@ -62,7 +62,7 @@ declare const LOGIN_METHOD_MAP: {
|
|
|
62
62
|
|
|
63
63
|
declare function useUserInfo(): {
|
|
64
64
|
loginByMethod: (method: ISocialLoginMethod) => Promise<Window | null>;
|
|
65
|
-
loginByTelegram: () => Promise<Window | null>;
|
|
65
|
+
loginByTelegram: () => Promise<Window | null | undefined>;
|
|
66
66
|
loginByTwitter: () => Promise<Window | null>;
|
|
67
67
|
loginByGoogle: () => Promise<Window | null>;
|
|
68
68
|
loginByWallet: () => Promise<Window | null>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { I as IMatchEvents, a as IEnvConfigType, L as LocaleType, W as WalletConfigType } from './types-DzVVzMYU.mjs';
|
|
3
|
-
export { i as Hooks, M as ModalProvider, T as ToastProvider } from './index-
|
|
3
|
+
export { i as Hooks, M as ModalProvider, T as ToastProvider } from './index-C_TiXUOB.mjs';
|
|
4
4
|
export { i as Components } from './index-C9qYyRgt.mjs';
|
|
5
5
|
export { i as UI } from './index-C9F6f2iz.mjs';
|
|
6
6
|
export { i as Api } from './index-D4ju2J_e.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { I as IMatchEvents, a as IEnvConfigType, L as LocaleType, W as WalletConfigType } from './types-DzVVzMYU.js';
|
|
3
|
-
export { i as Hooks, M as ModalProvider, T as ToastProvider } from './index-
|
|
3
|
+
export { i as Hooks, M as ModalProvider, T as ToastProvider } from './index-Cx2Lx_mh.js';
|
|
4
4
|
export { i as Components } from './index-Bvc8cjpN.js';
|
|
5
5
|
export { i as UI } from './index-BMsj8hJv.js';
|
|
6
6
|
export { i as Api } from './index-Cy3K-Yao.js';
|
package/dist/index.js
CHANGED
|
@@ -466,6 +466,19 @@ var getWalletNftListApi = (data) => {
|
|
|
466
466
|
data
|
|
467
467
|
});
|
|
468
468
|
};
|
|
469
|
+
var tgAppLoginInitApi = () => {
|
|
470
|
+
return retryRequest({
|
|
471
|
+
url: `/api/v1/tgapp/login/init`,
|
|
472
|
+
method: "GET"
|
|
473
|
+
});
|
|
474
|
+
};
|
|
475
|
+
var getTgAppLoginStatus = (data) => {
|
|
476
|
+
return retryRequest({
|
|
477
|
+
url: `/api/v1/tgapp/login/status`,
|
|
478
|
+
method: "POST",
|
|
479
|
+
data
|
|
480
|
+
});
|
|
481
|
+
};
|
|
469
482
|
|
|
470
483
|
// src/store/useLocalStore.ts
|
|
471
484
|
var persistedState = (0, import_middleware.persist)(
|
|
@@ -620,7 +633,7 @@ var NumberFormatter = ({
|
|
|
620
633
|
}
|
|
621
634
|
}
|
|
622
635
|
if (zeroCount < tFixNum) {
|
|
623
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className, children: [
|
|
624
637
|
prefix && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: prefixClassName, children: prefix }),
|
|
625
638
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: intClassName, children: intFormat }),
|
|
626
639
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: decimalClassName, children: [
|
|
@@ -630,7 +643,7 @@ var NumberFormatter = ({
|
|
|
630
643
|
suffix
|
|
631
644
|
] });
|
|
632
645
|
}
|
|
633
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
646
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className, children: [
|
|
634
647
|
prefix && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: prefixClassName, children: prefix }),
|
|
635
648
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: intClassName, children: intFormat }),
|
|
636
649
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: decimalClassName, children: [
|
|
@@ -656,6 +669,9 @@ var formatDate = (value, formatString = "YYYY-MM-DD HH:mm:ss") => {
|
|
|
656
669
|
}
|
|
657
670
|
return "--";
|
|
658
671
|
};
|
|
672
|
+
var isInTgApp = () => {
|
|
673
|
+
return !!window.TelegramWebviewProxy;
|
|
674
|
+
};
|
|
659
675
|
|
|
660
676
|
// src/store/useModalStore.ts
|
|
661
677
|
var import_zustand2 = require("zustand");
|
|
@@ -1909,6 +1925,16 @@ var useWalletModalStore = (0, import_zustand2.create)((set) => ({
|
|
|
1909
1925
|
close: () => set({ isOpen: false })
|
|
1910
1926
|
}));
|
|
1911
1927
|
|
|
1928
|
+
// src/store/useStore.ts
|
|
1929
|
+
var import_zustand3 = require("zustand");
|
|
1930
|
+
var useStore = (0, import_zustand3.create)((set) => ({
|
|
1931
|
+
walletReady: false,
|
|
1932
|
+
setWalletReady: (inited) => set({ walletReady: inited }),
|
|
1933
|
+
tgAppAuthCode: "",
|
|
1934
|
+
setTgAppAuthCode: (code) => set({ tgAppAuthCode: code })
|
|
1935
|
+
}));
|
|
1936
|
+
var useStore_default = useStore;
|
|
1937
|
+
|
|
1912
1938
|
// src/hooks/useUserInfo.tsx
|
|
1913
1939
|
function useUserInfo() {
|
|
1914
1940
|
const {
|
|
@@ -1924,6 +1950,7 @@ function useUserInfo() {
|
|
|
1924
1950
|
locale,
|
|
1925
1951
|
refreshOverview
|
|
1926
1952
|
} = useLocalStore_default();
|
|
1953
|
+
const { setTgAppAuthCode } = useStore_default();
|
|
1927
1954
|
const { events, login } = useMatch();
|
|
1928
1955
|
const { open: SOLOpen } = useSOLModalStore();
|
|
1929
1956
|
const { open: TRONOpen } = useTRONModalStore();
|
|
@@ -1962,6 +1989,31 @@ function useUserInfo() {
|
|
|
1962
1989
|
return window.open(`${endpoints.auth}login/wallet?appid=${appid}&locale=${locale}`);
|
|
1963
1990
|
};
|
|
1964
1991
|
const loginByTelegram = async () => {
|
|
1992
|
+
if (isInTgApp()) {
|
|
1993
|
+
try {
|
|
1994
|
+
const res = await tgAppLoginInitApi();
|
|
1995
|
+
if (!isSuccess(res)) {
|
|
1996
|
+
throw new Error(res.message);
|
|
1997
|
+
}
|
|
1998
|
+
setTgAppAuthCode(res.data.code);
|
|
1999
|
+
const link = res.data.login_url + `?startapp=${res.data.code}_${appid}_${locale}`;
|
|
2000
|
+
console.log("tgAppLoginInitLink", link);
|
|
2001
|
+
if (window.TelegramWebviewProxy) {
|
|
2002
|
+
console.log("in telegram webview");
|
|
2003
|
+
if (!window.Telegram) {
|
|
2004
|
+
throw new Error("Please import telegram-web-app.js first");
|
|
2005
|
+
}
|
|
2006
|
+
window.Telegram.WebApp.openTelegramLink(link);
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
console.log("not in telegram webview");
|
|
2010
|
+
window.open(link);
|
|
2011
|
+
return;
|
|
2012
|
+
} catch (e) {
|
|
2013
|
+
console.error("tgAppLoginInitApi", e);
|
|
2014
|
+
throw e;
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
1965
2017
|
return window.open(
|
|
1966
2018
|
`${endpoints.auth}login/telegram?appid=${appid}&locale=${locale}`,
|
|
1967
2019
|
// Replace with the actual authorization URL
|
|
@@ -2184,14 +2236,6 @@ function useMatchEvents(handlers) {
|
|
|
2184
2236
|
// src/hooks/useWallet.tsx
|
|
2185
2237
|
var import_viem2 = require("viem");
|
|
2186
2238
|
|
|
2187
|
-
// src/store/useStore.ts
|
|
2188
|
-
var import_zustand3 = require("zustand");
|
|
2189
|
-
var useStore = (0, import_zustand3.create)((set) => ({
|
|
2190
|
-
walletReady: false,
|
|
2191
|
-
setWalletReady: (inited) => set({ walletReady: inited })
|
|
2192
|
-
}));
|
|
2193
|
-
var useStore_default = useStore;
|
|
2194
|
-
|
|
2195
2239
|
// src/types/mpc.ts
|
|
2196
2240
|
var ChainType = /* @__PURE__ */ ((ChainType2) => {
|
|
2197
2241
|
ChainType2["Ethereum"] = "ethereum";
|
|
@@ -6807,6 +6851,7 @@ function CEXBindModal({
|
|
|
6807
6851
|
}
|
|
6808
6852
|
|
|
6809
6853
|
// src/context/BusinessProvider.tsx
|
|
6854
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
6810
6855
|
var import_jsx_runtime92 = require("react/jsx-runtime");
|
|
6811
6856
|
function BusinessProvider({ children }) {
|
|
6812
6857
|
const { overview, token } = useUserInfo();
|
|
@@ -6816,10 +6861,31 @@ function BusinessProvider({ children }) {
|
|
|
6816
6861
|
const { type: BTCType, isOpen: BTCIsOpen, close: BTCClose } = useBTCModalStore();
|
|
6817
6862
|
const { type: CEXType, isOpen: CEXIsOpen, close: CEXClose } = useCEXBindModalStore();
|
|
6818
6863
|
const WalletModalStore = useWalletModalStore();
|
|
6864
|
+
const { tgAppAuthCode, setTgAppAuthCode } = useStore_default();
|
|
6865
|
+
const { login } = useMatch();
|
|
6819
6866
|
const walletModalClose = (func) => {
|
|
6820
6867
|
WalletModalStore.close();
|
|
6821
6868
|
func();
|
|
6822
6869
|
};
|
|
6870
|
+
(0, import_react_query9.useQuery)({
|
|
6871
|
+
queryKey: ["matchid-tgapp-login", tgAppAuthCode],
|
|
6872
|
+
queryFn: async () => {
|
|
6873
|
+
const res = await getTgAppLoginStatus({
|
|
6874
|
+
code: tgAppAuthCode
|
|
6875
|
+
});
|
|
6876
|
+
if (isSuccess(res)) {
|
|
6877
|
+
setTgAppAuthCode("");
|
|
6878
|
+
await login({
|
|
6879
|
+
mid: "",
|
|
6880
|
+
token: `${res.data.token_type} ${res.data.access_token}`
|
|
6881
|
+
});
|
|
6882
|
+
return true;
|
|
6883
|
+
}
|
|
6884
|
+
return false;
|
|
6885
|
+
},
|
|
6886
|
+
enabled: !!tgAppAuthCode,
|
|
6887
|
+
refetchInterval: 1e3 * 5
|
|
6888
|
+
});
|
|
6823
6889
|
return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [
|
|
6824
6890
|
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
6825
6891
|
SOLModal,
|
|
@@ -7242,7 +7308,7 @@ function useInit({
|
|
|
7242
7308
|
}
|
|
7243
7309
|
|
|
7244
7310
|
// src/MatchContext.tsx
|
|
7245
|
-
var
|
|
7311
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
7246
7312
|
var import_react_intl21 = require("react-intl");
|
|
7247
7313
|
|
|
7248
7314
|
// src/i18n/en.json
|
|
@@ -7980,7 +8046,7 @@ var messages = {
|
|
|
7980
8046
|
|
|
7981
8047
|
// src/MatchContext.tsx
|
|
7982
8048
|
var import_jsx_runtime94 = require("react/jsx-runtime");
|
|
7983
|
-
var queryClient = new
|
|
8049
|
+
var queryClient = new import_react_query10.QueryClient();
|
|
7984
8050
|
var MatchContext = (0, import_react40.createContext)(void 0);
|
|
7985
8051
|
var MatchProvider = ({
|
|
7986
8052
|
children,
|
|
@@ -8001,7 +8067,16 @@ var MatchProvider = ({
|
|
|
8001
8067
|
useWalletInit({
|
|
8002
8068
|
config: wallet
|
|
8003
8069
|
});
|
|
8004
|
-
|
|
8070
|
+
(0, import_react40.useEffect)(() => {
|
|
8071
|
+
const script = document.createElement("script");
|
|
8072
|
+
script.src = "https://telegram.org/js/telegram-web-app.js?56";
|
|
8073
|
+
script.async = true;
|
|
8074
|
+
document.body.appendChild(script);
|
|
8075
|
+
return () => {
|
|
8076
|
+
document.body.removeChild(script);
|
|
8077
|
+
};
|
|
8078
|
+
}, []);
|
|
8079
|
+
return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_react_intl21.IntlProvider, { locale: realLocale, messages: messages[realLocale], children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_react_query10.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
8005
8080
|
MatchContext.Provider,
|
|
8006
8081
|
{
|
|
8007
8082
|
value: {
|
|
@@ -8043,10 +8118,10 @@ __export(bind_exports, {
|
|
|
8043
8118
|
useBindInfo: () => useBindInfo,
|
|
8044
8119
|
useBindList: () => useBindList
|
|
8045
8120
|
});
|
|
8046
|
-
var
|
|
8121
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
8047
8122
|
function useBindList(options) {
|
|
8048
8123
|
const { isLogin } = useUserInfo();
|
|
8049
|
-
return (0,
|
|
8124
|
+
return (0, import_react_query11.useQuery)({
|
|
8050
8125
|
queryKey: ["bindList"],
|
|
8051
8126
|
enabled: isLogin,
|
|
8052
8127
|
queryFn: async () => {
|
|
@@ -8058,7 +8133,7 @@ function useBindList(options) {
|
|
|
8058
8133
|
}
|
|
8059
8134
|
function useBindInfo(options) {
|
|
8060
8135
|
const { isLogin } = useUserInfo();
|
|
8061
|
-
return (0,
|
|
8136
|
+
return (0, import_react_query11.useQuery)({
|
|
8062
8137
|
queryKey: ["bindInfo"],
|
|
8063
8138
|
enabled: isLogin,
|
|
8064
8139
|
queryFn: async () => {
|
|
@@ -8075,10 +8150,10 @@ __export(poh_exports, {
|
|
|
8075
8150
|
usePohList: () => usePohList,
|
|
8076
8151
|
verifyPohApi: () => verifyPohApi
|
|
8077
8152
|
});
|
|
8078
|
-
var
|
|
8153
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
8079
8154
|
function usePohList(options) {
|
|
8080
8155
|
const { isLogin } = useUserInfo();
|
|
8081
|
-
return (0,
|
|
8156
|
+
return (0, import_react_query12.useQuery)({
|
|
8082
8157
|
queryKey: ["pohList"],
|
|
8083
8158
|
enabled: isLogin,
|
|
8084
8159
|
queryFn: async () => {
|