@matchain/matchid-sdk-react 0.1.49 → 0.1.50
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-IKSPEZ4F.mjs → chunk-6KB4RLTC.mjs} +2 -2
- package/dist/{chunk-5JHHHLG4.mjs → chunk-HLUFAIFV.mjs} +8 -4
- package/dist/chunk-HLUFAIFV.mjs.map +1 -0
- package/dist/{chunk-MXDPJRRH.mjs → chunk-JLQVDNWZ.mjs} +84 -9
- package/dist/chunk-JLQVDNWZ.mjs.map +1 -0
- 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 +98 -21
- 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/package.json +2 -1
- package/example/src/App.tsx +19 -8
- package/example/src/main.tsx +2 -0
- package/example/src/pages/TgApp/index.tsx +44 -0
- package/example/src/pages/Wallet/index.tsx +1 -2
- package/example/yarn.lock +5 -0
- package/package.json +1 -1
- package/dist/chunk-5JHHHLG4.mjs.map +0 -1
- package/dist/chunk-MXDPJRRH.mjs.map +0 -1
- /package/dist/{chunk-IKSPEZ4F.mjs.map → chunk-6KB4RLTC.mjs.map} +0 -0
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useUserInfo,
|
|
12
12
|
verifyPohApi,
|
|
13
13
|
wallet_exports
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-JLQVDNWZ.mjs";
|
|
15
15
|
import {
|
|
16
16
|
__export
|
|
17
17
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -94,4 +94,4 @@ export {
|
|
|
94
94
|
user_exports,
|
|
95
95
|
api_exports
|
|
96
96
|
};
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
97
|
+
//# sourceMappingURL=chunk-6KB4RLTC.mjs.map
|
|
@@ -82,7 +82,7 @@ var NumberFormatter = ({
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
if (zeroCount < tFixNum) {
|
|
85
|
-
return /* @__PURE__ */ jsxs("span", { children: [
|
|
85
|
+
return /* @__PURE__ */ jsxs("span", { className, children: [
|
|
86
86
|
prefix && /* @__PURE__ */ jsx("span", { className: prefixClassName, children: prefix }),
|
|
87
87
|
/* @__PURE__ */ jsx("span", { className: intClassName, children: intFormat }),
|
|
88
88
|
/* @__PURE__ */ jsxs("span", { className: decimalClassName, children: [
|
|
@@ -92,7 +92,7 @@ var NumberFormatter = ({
|
|
|
92
92
|
suffix
|
|
93
93
|
] });
|
|
94
94
|
}
|
|
95
|
-
return /* @__PURE__ */ jsxs("span", { children: [
|
|
95
|
+
return /* @__PURE__ */ jsxs("span", { className, children: [
|
|
96
96
|
prefix && /* @__PURE__ */ jsx("span", { className: prefixClassName, children: prefix }),
|
|
97
97
|
/* @__PURE__ */ jsx("span", { className: intClassName, children: intFormat }),
|
|
98
98
|
/* @__PURE__ */ jsxs("span", { className: decimalClassName, children: [
|
|
@@ -118,6 +118,9 @@ var formatDate = (value, formatString = "YYYY-MM-DD HH:mm:ss") => {
|
|
|
118
118
|
}
|
|
119
119
|
return "--";
|
|
120
120
|
};
|
|
121
|
+
var isInTgApp = () => {
|
|
122
|
+
return !!window.TelegramWebviewProxy;
|
|
123
|
+
};
|
|
121
124
|
|
|
122
125
|
export {
|
|
123
126
|
getVersion,
|
|
@@ -131,6 +134,7 @@ export {
|
|
|
131
134
|
getAppClientId,
|
|
132
135
|
NumberFormatter,
|
|
133
136
|
formatAddress,
|
|
134
|
-
formatDate
|
|
137
|
+
formatDate,
|
|
138
|
+
isInTgApp
|
|
135
139
|
};
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
140
|
+
//# sourceMappingURL=chunk-HLUFAIFV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/index.tsx"],"sourcesContent":["import moment from 'moment';\n\nexport const getVersion = (): string => {\n return \"0.0.2\";\n};\n\nexport function encodeBase64(input: string) {\n return btoa(unescape(encodeURIComponent(input)));\n}\n\nexport function decodeBase64(input: string) {\n return decodeURIComponent(escape(atob(input)));\n}\n\nexport const isValidEmail = (email: string) => {\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)\n}\nexport const isValidUsername = (username: string) => {\n //8-32 alpha number - _\n return /^[a-zA-Z0-9_-]+$/.test(username)\n}\n\nexport const deepMerge = (target: any, source: any): any => {\n for (const key in source) {\n if (source[key] instanceof Object && key in target) {\n target[key] = deepMerge(target[key], source[key]);\n } else {\n target[key] = source[key];\n }\n }\n return target;\n};\n\nexport function truncateAddress(address: string): string {\n if (address.length <= 6) {\n return address;\n }\n const start = address.slice(0, 4);\n const end = address.slice(-2);\n return `${start}...${end}`;\n}\n\n\nexport function firstUpperCase(str: string): string {\n return str.toString()[0].toUpperCase() + str.toString().slice(1);\n}\n\nexport function getAppClientId() {\n return \"react-sdk-\" + getVersion()\n}\n\n\nfunction convertScientificToDecimal(num: number) {\n let str = num.toFixed(12)\n str = str.replace(/0+$/, '')\n str = str.replace(/\\.$/, '')\n return str\n}\n\ninterface NumberFormatterProps {\n value: number | string | undefined\n prefix?: string\n suffix?: string\n separator?: boolean\n fixNum?: number //number >= 1 fix num\n tFixNum?: number //number < 1 fix num\n intClassName?: string\n decimalClassName?: string\n prefixClassName?: string\n className?: string\n}\n\nexport const NumberFormatter: React.FC<NumberFormatterProps> = ({\n value,\n prefix = '',\n suffix = '',\n separator = true,\n fixNum = 2,\n tFixNum = 4,\n intClassName = \"\",\n decimalClassName = \"\",\n prefixClassName = \"\",\n className = \"\"\n }) => {\n const numberValue =\n typeof value === 'number'\n ? convertScientificToDecimal(value)\n : value\n ? value\n : '0'\n\n const [intPart, decimalPart] = numberValue.toString().split('.')\n\n const intFormat = separator\n ? intPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n : intPart\n\n if (Math.abs(parseFloat(numberValue)) >= 1) {\n return (\n <span className={className}>\n {prefix && <span className={prefixClassName}>{prefix}</span>}\n <span className={intClassName}>{intFormat}</span>\n {decimalPart ? (\n <span className={decimalClassName}>\n .{decimalPart.substring(0, fixNum)}\n </span>\n ) : (\n ''\n )}\n {suffix}\n </span>\n )\n }\n\n if (decimalPart) {\n let zeroCount = 0\n for (let i = 0; i < decimalPart.length; i++) {\n if (decimalPart[i] === '0') {\n zeroCount++\n } else {\n break\n }\n }\n if (zeroCount < tFixNum) {\n return (\n <span className={className}>\n {prefix && <span className={prefixClassName}>{prefix}</span>}\n <span className={intClassName}>{intFormat}</span>\n <span className={decimalClassName}>\n .{decimalPart.substring(0, tFixNum)}\n </span>\n {suffix}\n </span>\n )\n }\n return (\n <span className={className}>\n {prefix && <span className={prefixClassName}>{prefix}</span>}\n <span className={intClassName}>{intFormat}</span>\n <span className={decimalClassName}>\n .0<sub>{zeroCount}</sub>\n {decimalPart?.substring(zeroCount, zeroCount + tFixNum - 2)}\n </span>\n {suffix}\n </span>\n )\n }\n return (\n <span className={className}>\n {prefix && <span className={prefixClassName}>{prefix}</span>}\n <span className={intClassName}>{intPart}</span>\n {suffix}\n </span>\n )\n}\n\nexport function formatAddress(address: string, pre = 4, after = 5) {\n return `${address.substring(0, pre)}...${address.substring(address.length - after, address.length)}`\n}\n\nexport const formatDate = (value: any, formatString = 'YYYY-MM-DD HH:mm:ss') => {\n if (value) {\n return moment.unix(value).format(formatString)\n }\n return '--'\n}\nexport const isInTgApp = () => {\n return !!(window.TelegramWebviewProxy)\n}"],"mappings":"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","names":[]}
|
|
@@ -24,10 +24,11 @@ import {
|
|
|
24
24
|
formatDate,
|
|
25
25
|
getAppClientId,
|
|
26
26
|
getVersion,
|
|
27
|
+
isInTgApp,
|
|
27
28
|
isValidEmail,
|
|
28
29
|
isValidUsername,
|
|
29
30
|
truncateAddress
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-HLUFAIFV.mjs";
|
|
31
32
|
import {
|
|
32
33
|
ArrowDownIcon,
|
|
33
34
|
ArrowRightIcon,
|
|
@@ -530,6 +531,19 @@ var getWalletNftListApi = (data) => {
|
|
|
530
531
|
data
|
|
531
532
|
});
|
|
532
533
|
};
|
|
534
|
+
var tgAppLoginInitApi = () => {
|
|
535
|
+
return retryRequest({
|
|
536
|
+
url: `/api/v1/tgapp/login/init`,
|
|
537
|
+
method: "GET"
|
|
538
|
+
});
|
|
539
|
+
};
|
|
540
|
+
var getTgAppLoginStatus = (data) => {
|
|
541
|
+
return retryRequest({
|
|
542
|
+
url: `/api/v1/tgapp/login/status`,
|
|
543
|
+
method: "POST",
|
|
544
|
+
data
|
|
545
|
+
});
|
|
546
|
+
};
|
|
533
547
|
|
|
534
548
|
// src/store/useLocalStore.ts
|
|
535
549
|
var persistedState = persist(
|
|
@@ -589,7 +603,7 @@ var useLocalStore_default = useLocalStore;
|
|
|
589
603
|
import { useMemo as useMemo7 } from "react";
|
|
590
604
|
|
|
591
605
|
// src/MatchContext.tsx
|
|
592
|
-
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
606
|
+
import { createContext as createContext3, useContext as useContext3, useEffect as useEffect13 } from "react";
|
|
593
607
|
|
|
594
608
|
// src/hooks/index.tsx
|
|
595
609
|
var hooks_exports = {};
|
|
@@ -668,7 +682,9 @@ import {
|
|
|
668
682
|
import { create as create2 } from "zustand";
|
|
669
683
|
var useStore = create2((set) => ({
|
|
670
684
|
walletReady: false,
|
|
671
|
-
setWalletReady: (inited) => set({ walletReady: inited })
|
|
685
|
+
setWalletReady: (inited) => set({ walletReady: inited }),
|
|
686
|
+
tgAppAuthCode: "",
|
|
687
|
+
setTgAppAuthCode: (code) => set({ tgAppAuthCode: code })
|
|
672
688
|
}));
|
|
673
689
|
var useStore_default = useStore;
|
|
674
690
|
|
|
@@ -2425,6 +2441,7 @@ function CEXBindModal({
|
|
|
2425
2441
|
}
|
|
2426
2442
|
|
|
2427
2443
|
// src/context/BusinessProvider.tsx
|
|
2444
|
+
import { useQuery as useQuery6 } from "@tanstack/react-query";
|
|
2428
2445
|
import { Fragment, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2429
2446
|
function BusinessProvider({ children }) {
|
|
2430
2447
|
const { overview, token } = useUserInfo();
|
|
@@ -2434,10 +2451,31 @@ function BusinessProvider({ children }) {
|
|
|
2434
2451
|
const { type: BTCType, isOpen: BTCIsOpen, close: BTCClose } = useBTCModalStore();
|
|
2435
2452
|
const { type: CEXType, isOpen: CEXIsOpen, close: CEXClose } = useCEXBindModalStore();
|
|
2436
2453
|
const WalletModalStore = useWalletModalStore();
|
|
2454
|
+
const { tgAppAuthCode, setTgAppAuthCode } = useStore_default();
|
|
2455
|
+
const { login } = useMatch();
|
|
2437
2456
|
const walletModalClose = (func) => {
|
|
2438
2457
|
WalletModalStore.close();
|
|
2439
2458
|
func();
|
|
2440
2459
|
};
|
|
2460
|
+
useQuery6({
|
|
2461
|
+
queryKey: ["matchid-tgapp-login", tgAppAuthCode],
|
|
2462
|
+
queryFn: async () => {
|
|
2463
|
+
const res = await getTgAppLoginStatus({
|
|
2464
|
+
code: tgAppAuthCode
|
|
2465
|
+
});
|
|
2466
|
+
if (isSuccess(res)) {
|
|
2467
|
+
setTgAppAuthCode("");
|
|
2468
|
+
await login({
|
|
2469
|
+
mid: "",
|
|
2470
|
+
token: `${res.data.token_type} ${res.data.access_token}`
|
|
2471
|
+
});
|
|
2472
|
+
return true;
|
|
2473
|
+
}
|
|
2474
|
+
return false;
|
|
2475
|
+
},
|
|
2476
|
+
enabled: !!tgAppAuthCode,
|
|
2477
|
+
refetchInterval: 1e3 * 5
|
|
2478
|
+
});
|
|
2441
2479
|
return /* @__PURE__ */ jsxs8(Fragment, { children: [
|
|
2442
2480
|
/* @__PURE__ */ jsx10(
|
|
2443
2481
|
SOLModal,
|
|
@@ -2541,7 +2579,7 @@ var AppClientId2 = getAppClientId();
|
|
|
2541
2579
|
function useWalletInit({
|
|
2542
2580
|
config
|
|
2543
2581
|
}) {
|
|
2544
|
-
const { endpoints, token,
|
|
2582
|
+
const { endpoints, token, setWallet, appid, refreshOverview } = useLocalStore_default();
|
|
2545
2583
|
const { setWalletReady, walletReady } = useStore_default();
|
|
2546
2584
|
const iframeReadyRef = useRef2(walletReady);
|
|
2547
2585
|
useEffect11(() => {
|
|
@@ -2576,7 +2614,6 @@ function useWalletInit({
|
|
|
2576
2614
|
const existingIframe = getWalletIframe();
|
|
2577
2615
|
const query = {
|
|
2578
2616
|
appid,
|
|
2579
|
-
locale,
|
|
2580
2617
|
appClientId: AppClientId2,
|
|
2581
2618
|
initParams: encodeBase64(JSON.stringify({
|
|
2582
2619
|
access_token: token,
|
|
@@ -2615,7 +2652,8 @@ function useWalletInit({
|
|
|
2615
2652
|
data,
|
|
2616
2653
|
messageId,
|
|
2617
2654
|
source: "matchid",
|
|
2618
|
-
version: 1
|
|
2655
|
+
version: 1,
|
|
2656
|
+
locale: getLocale()
|
|
2619
2657
|
};
|
|
2620
2658
|
try {
|
|
2621
2659
|
matchlog_default.log("sdk.mpc.send", message, endpoints.auth);
|
|
@@ -3619,6 +3657,17 @@ var MatchProvider = ({
|
|
|
3619
3657
|
useWalletInit({
|
|
3620
3658
|
config: wallet
|
|
3621
3659
|
});
|
|
3660
|
+
useEffect13(() => {
|
|
3661
|
+
if (!window.Telegram) {
|
|
3662
|
+
const script = document.createElement("script");
|
|
3663
|
+
script.src = "https://telegram.org/js/telegram-web-app.js?56";
|
|
3664
|
+
script.async = true;
|
|
3665
|
+
document.body.appendChild(script);
|
|
3666
|
+
return () => {
|
|
3667
|
+
document.body.removeChild(script);
|
|
3668
|
+
};
|
|
3669
|
+
}
|
|
3670
|
+
}, []);
|
|
3622
3671
|
return /* @__PURE__ */ jsx12(IntlProvider, { locale: realLocale, messages: messages[realLocale], children: /* @__PURE__ */ jsx12(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx12(
|
|
3623
3672
|
MatchContext.Provider,
|
|
3624
3673
|
{
|
|
@@ -3657,6 +3706,7 @@ function useUserInfo() {
|
|
|
3657
3706
|
locale,
|
|
3658
3707
|
refreshOverview
|
|
3659
3708
|
} = useLocalStore_default();
|
|
3709
|
+
const { setTgAppAuthCode } = useStore_default();
|
|
3660
3710
|
const { events, login } = useMatch();
|
|
3661
3711
|
const { open: SOLOpen } = useSOLModalStore();
|
|
3662
3712
|
const { open: TRONOpen } = useTRONModalStore();
|
|
@@ -3695,6 +3745,31 @@ function useUserInfo() {
|
|
|
3695
3745
|
return window.open(`${endpoints.auth}login/wallet?appid=${appid}&locale=${locale}`);
|
|
3696
3746
|
};
|
|
3697
3747
|
const loginByTelegram = async () => {
|
|
3748
|
+
if (isInTgApp()) {
|
|
3749
|
+
try {
|
|
3750
|
+
const res = await tgAppLoginInitApi();
|
|
3751
|
+
if (!isSuccess(res)) {
|
|
3752
|
+
throw new Error(res.message);
|
|
3753
|
+
}
|
|
3754
|
+
setTgAppAuthCode(res.data.code);
|
|
3755
|
+
const link = res.data.login_url + `?startapp=${res.data.code}_${appid}_${locale}`;
|
|
3756
|
+
console.log("tgAppLoginInitLink", link);
|
|
3757
|
+
if (window.TelegramWebviewProxy) {
|
|
3758
|
+
console.log("in telegram webview");
|
|
3759
|
+
if (!window.Telegram) {
|
|
3760
|
+
throw new Error("Please import telegram-web-app.js first");
|
|
3761
|
+
}
|
|
3762
|
+
window.Telegram.WebApp.openTelegramLink(link);
|
|
3763
|
+
return;
|
|
3764
|
+
}
|
|
3765
|
+
console.log("not in telegram webview");
|
|
3766
|
+
window.open(link);
|
|
3767
|
+
return;
|
|
3768
|
+
} catch (e) {
|
|
3769
|
+
console.error("tgAppLoginInitApi", e);
|
|
3770
|
+
throw e;
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3698
3773
|
return window.open(
|
|
3699
3774
|
`${endpoints.auth}login/telegram?appid=${appid}&locale=${locale}`,
|
|
3700
3775
|
// Replace with the actual authorization URL
|
|
@@ -4060,9 +4135,9 @@ import { useMemo as useMemo9, useState as useState15 } from "react";
|
|
|
4060
4135
|
import { FormattedMessage as FormattedMessage6, useIntl as useIntl7 } from "react-intl";
|
|
4061
4136
|
|
|
4062
4137
|
// src/hooks/useAppConfig.ts
|
|
4063
|
-
import { useQuery as
|
|
4138
|
+
import { useQuery as useQuery7 } from "@tanstack/react-query";
|
|
4064
4139
|
function useAppConfig() {
|
|
4065
|
-
const query =
|
|
4140
|
+
const query = useQuery7({
|
|
4066
4141
|
queryKey: ["appConfig"],
|
|
4067
4142
|
queryFn: async () => {
|
|
4068
4143
|
const res = await getAppConfigApi();
|
|
@@ -6385,4 +6460,4 @@ export {
|
|
|
6385
6460
|
MatchProvider,
|
|
6386
6461
|
useMatch
|
|
6387
6462
|
};
|
|
6388
|
-
//# sourceMappingURL=chunk-
|
|
6463
|
+
//# sourceMappingURL=chunk-JLQVDNWZ.mjs.map
|