@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/api/index.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
bind_exports,
|
|
3
3
|
poh_exports,
|
|
4
4
|
user_exports
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-ZM2P5GEL.mjs";
|
|
6
6
|
import {
|
|
7
7
|
isSuccess,
|
|
8
8
|
wallet_exports
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-P3WHQUXO.mjs";
|
|
10
10
|
import "../../chunk-UA6XHZHX.mjs";
|
|
11
11
|
import "../../chunk-FB5MHLWX.mjs";
|
|
12
|
-
import "../../chunk-
|
|
12
|
+
import "../../chunk-HLUFAIFV.mjs";
|
|
13
13
|
import "../../chunk-LHNKZISB.mjs";
|
|
14
14
|
import "../../chunk-J5LGTIGS.mjs";
|
|
15
15
|
export {
|
package/dist/hooks/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as useCopyClipboard, n as useLayout, f as useMatchChain, a as useMatchEvents, g as useMatchWallet, k as useMatchWalletAssetList, j as useMatchWalletAssets, h as useMatchWalletRecords, d as useModal, l as useReceipt, e as useToast, m as useTransaction, u as useUserInfo, b as useWallet } from '../index-
|
|
1
|
+
export { c as useCopyClipboard, n as useLayout, f as useMatchChain, a as useMatchEvents, g as useMatchWallet, k as useMatchWalletAssetList, j as useMatchWalletAssets, h as useMatchWalletRecords, d as useModal, l as useReceipt, e as useToast, m as useTransaction, u as useUserInfo, b as useWallet } from '../index-C_TiXUOB.mjs';
|
|
2
2
|
import '../types-DzVVzMYU.mjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@tanstack/react-query/src/types';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as useCopyClipboard, n as useLayout, f as useMatchChain, a as useMatchEvents, g as useMatchWallet, k as useMatchWalletAssetList, j as useMatchWalletAssets, h as useMatchWalletRecords, d as useModal, l as useReceipt, e as useToast, m as useTransaction, u as useUserInfo, b as useWallet } from '../index-
|
|
1
|
+
export { c as useCopyClipboard, n as useLayout, f as useMatchChain, a as useMatchEvents, g as useMatchWallet, k as useMatchWalletAssetList, j as useMatchWalletAssets, h as useMatchWalletRecords, d as useModal, l as useReceipt, e as useToast, m as useTransaction, u as useUserInfo, b as useWallet } from '../index-Cx2Lx_mh.js';
|
|
2
2
|
import '../types-DzVVzMYU.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@tanstack/react-query/src/types';
|
package/dist/hooks/index.js
CHANGED
|
@@ -287,6 +287,12 @@ var getUserWalletTransactionsApi = (data) => {
|
|
|
287
287
|
data
|
|
288
288
|
});
|
|
289
289
|
};
|
|
290
|
+
var tgAppLoginInitApi = () => {
|
|
291
|
+
return retryRequest({
|
|
292
|
+
url: `/api/v1/tgapp/login/init`,
|
|
293
|
+
method: "GET"
|
|
294
|
+
});
|
|
295
|
+
};
|
|
290
296
|
|
|
291
297
|
// src/store/useLocalStore.ts
|
|
292
298
|
var persistedState = (0, import_middleware.persist)(
|
|
@@ -799,7 +805,7 @@ var NumberFormatter = ({
|
|
|
799
805
|
}
|
|
800
806
|
}
|
|
801
807
|
if (zeroCount < tFixNum) {
|
|
802
|
-
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { children: [
|
|
808
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className, children: [
|
|
803
809
|
prefix && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: prefixClassName, children: prefix }),
|
|
804
810
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: intClassName, children: intFormat }),
|
|
805
811
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: decimalClassName, children: [
|
|
@@ -809,7 +815,7 @@ var NumberFormatter = ({
|
|
|
809
815
|
suffix
|
|
810
816
|
] });
|
|
811
817
|
}
|
|
812
|
-
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { children: [
|
|
818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className, children: [
|
|
813
819
|
prefix && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: prefixClassName, children: prefix }),
|
|
814
820
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: intClassName, children: intFormat }),
|
|
815
821
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: decimalClassName, children: [
|
|
@@ -826,6 +832,9 @@ var NumberFormatter = ({
|
|
|
826
832
|
suffix
|
|
827
833
|
] });
|
|
828
834
|
};
|
|
835
|
+
var isInTgApp = () => {
|
|
836
|
+
return !!window.TelegramWebviewProxy;
|
|
837
|
+
};
|
|
829
838
|
|
|
830
839
|
// src/ui/Button/index.tsx
|
|
831
840
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
@@ -1743,6 +1752,19 @@ var import_react26 = require("react");
|
|
|
1743
1752
|
var import_react_intl18 = require("react-intl");
|
|
1744
1753
|
var import_jsx_runtime85 = require("react/jsx-runtime");
|
|
1745
1754
|
|
|
1755
|
+
// src/context/BusinessProvider.tsx
|
|
1756
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
1757
|
+
|
|
1758
|
+
// src/store/useStore.ts
|
|
1759
|
+
var import_zustand4 = require("zustand");
|
|
1760
|
+
var useStore = (0, import_zustand4.create)((set) => ({
|
|
1761
|
+
walletReady: false,
|
|
1762
|
+
setWalletReady: (inited) => set({ walletReady: inited }),
|
|
1763
|
+
tgAppAuthCode: "",
|
|
1764
|
+
setTgAppAuthCode: (code) => set({ tgAppAuthCode: code })
|
|
1765
|
+
}));
|
|
1766
|
+
var useStore_default = useStore;
|
|
1767
|
+
|
|
1746
1768
|
// src/context/BusinessProvider.tsx
|
|
1747
1769
|
var import_jsx_runtime86 = require("react/jsx-runtime");
|
|
1748
1770
|
|
|
@@ -1777,26 +1799,16 @@ var import_jsx_runtime89 = require("react/jsx-runtime");
|
|
|
1777
1799
|
|
|
1778
1800
|
// src/hooks/useWalletInit.ts
|
|
1779
1801
|
var import_react29 = require("react");
|
|
1780
|
-
|
|
1781
|
-
// src/store/useStore.ts
|
|
1782
|
-
var import_zustand4 = require("zustand");
|
|
1783
|
-
var useStore = (0, import_zustand4.create)((set) => ({
|
|
1784
|
-
walletReady: false,
|
|
1785
|
-
setWalletReady: (inited) => set({ walletReady: inited })
|
|
1786
|
-
}));
|
|
1787
|
-
var useStore_default = useStore;
|
|
1788
|
-
|
|
1789
|
-
// src/hooks/useWalletInit.ts
|
|
1790
1802
|
var AppClientId = getAppClientId();
|
|
1791
1803
|
|
|
1792
1804
|
// src/hooks/useInit.tsx
|
|
1793
1805
|
var import_react30 = require("react");
|
|
1794
1806
|
|
|
1795
1807
|
// src/MatchContext.tsx
|
|
1796
|
-
var
|
|
1808
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
1797
1809
|
var import_react_intl19 = require("react-intl");
|
|
1798
1810
|
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
1799
|
-
var queryClient = new
|
|
1811
|
+
var queryClient = new import_react_query4.QueryClient();
|
|
1800
1812
|
var MatchContext = (0, import_react31.createContext)(void 0);
|
|
1801
1813
|
var useMatch = () => {
|
|
1802
1814
|
const context = (0, import_react31.useContext)(MatchContext);
|
|
@@ -1821,6 +1833,7 @@ function useUserInfo() {
|
|
|
1821
1833
|
locale,
|
|
1822
1834
|
refreshOverview
|
|
1823
1835
|
} = useLocalStore_default();
|
|
1836
|
+
const { setTgAppAuthCode } = useStore_default();
|
|
1824
1837
|
const { events, login } = useMatch();
|
|
1825
1838
|
const { open: SOLOpen } = useSOLModalStore();
|
|
1826
1839
|
const { open: TRONOpen } = useTRONModalStore();
|
|
@@ -1859,6 +1872,31 @@ function useUserInfo() {
|
|
|
1859
1872
|
return window.open(`${endpoints.auth}login/wallet?appid=${appid}&locale=${locale}`);
|
|
1860
1873
|
};
|
|
1861
1874
|
const loginByTelegram = async () => {
|
|
1875
|
+
if (isInTgApp()) {
|
|
1876
|
+
try {
|
|
1877
|
+
const res = await tgAppLoginInitApi();
|
|
1878
|
+
if (!isSuccess(res)) {
|
|
1879
|
+
throw new Error(res.message);
|
|
1880
|
+
}
|
|
1881
|
+
setTgAppAuthCode(res.data.code);
|
|
1882
|
+
const link = res.data.login_url + `?startapp=${res.data.code}_${appid}_${locale}`;
|
|
1883
|
+
console.log("tgAppLoginInitLink", link);
|
|
1884
|
+
if (window.TelegramWebviewProxy) {
|
|
1885
|
+
console.log("in telegram webview");
|
|
1886
|
+
if (!window.Telegram) {
|
|
1887
|
+
throw new Error("Please import telegram-web-app.js first");
|
|
1888
|
+
}
|
|
1889
|
+
window.Telegram.WebApp.openTelegramLink(link);
|
|
1890
|
+
return;
|
|
1891
|
+
}
|
|
1892
|
+
console.log("not in telegram webview");
|
|
1893
|
+
window.open(link);
|
|
1894
|
+
return;
|
|
1895
|
+
} catch (e) {
|
|
1896
|
+
console.error("tgAppLoginInitApi", e);
|
|
1897
|
+
throw e;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1862
1900
|
return window.open(
|
|
1863
1901
|
`${endpoints.auth}login/telegram?appid=${appid}&locale=${locale}`,
|
|
1864
1902
|
// Replace with the actual authorization URL
|
|
@@ -2364,10 +2402,10 @@ function useCopyClipboard(timeout = 500) {
|
|
|
2364
2402
|
}
|
|
2365
2403
|
|
|
2366
2404
|
// src/hooks/api/wallet.ts
|
|
2367
|
-
var
|
|
2405
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
2368
2406
|
function useChainListQuery(options) {
|
|
2369
2407
|
const { isLogin, token } = useUserInfo();
|
|
2370
|
-
return (0,
|
|
2408
|
+
return (0, import_react_query5.useQuery)({
|
|
2371
2409
|
queryKey: ["match-user-chain-list", token],
|
|
2372
2410
|
queryFn: async () => {
|
|
2373
2411
|
const res = await getUserChainListApi();
|
|
@@ -2385,7 +2423,7 @@ function useAssetListQuery({
|
|
|
2385
2423
|
...options
|
|
2386
2424
|
}) {
|
|
2387
2425
|
const { isLogin, token } = useUserInfo();
|
|
2388
|
-
return (0,
|
|
2426
|
+
return (0, import_react_query5.useQuery)({
|
|
2389
2427
|
queryKey: ["match-user-asset-list", token, chainId],
|
|
2390
2428
|
queryFn: async () => {
|
|
2391
2429
|
const res = await getUserWalletAssetApi({ chain_id: chainId.toString() });
|
|
@@ -2404,7 +2442,7 @@ function useImportTokenListQuery({
|
|
|
2404
2442
|
...options
|
|
2405
2443
|
}) {
|
|
2406
2444
|
const { isLogin, token } = useUserInfo();
|
|
2407
|
-
return (0,
|
|
2445
|
+
return (0, import_react_query5.useQuery)({
|
|
2408
2446
|
queryKey: [USER_IMPORT_TOKEN_LIST_KEY, token, chainId],
|
|
2409
2447
|
queryFn: async () => {
|
|
2410
2448
|
const res = await getUserImportTokenListApi({ chain_id: chainId.toString() });
|
|
@@ -2509,25 +2547,25 @@ function useMatchChain() {
|
|
|
2509
2547
|
// src/hooks/useMatchWallet.tsx
|
|
2510
2548
|
var import_react_qrcode = require("react-qrcode");
|
|
2511
2549
|
var import_react38 = require("react");
|
|
2512
|
-
var
|
|
2550
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
2513
2551
|
var import_viem11 = require("viem");
|
|
2514
2552
|
var import_react_intl21 = require("react-intl");
|
|
2515
2553
|
|
|
2516
2554
|
// src/components/ImportToken/index.tsx
|
|
2517
2555
|
var import_react37 = require("react");
|
|
2518
2556
|
var import_react_intl20 = require("react-intl");
|
|
2519
|
-
var
|
|
2557
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
2520
2558
|
var import_viem10 = require("viem");
|
|
2521
2559
|
|
|
2522
2560
|
// src/hooks/useIsContract.ts
|
|
2523
2561
|
var import_viem9 = require("viem");
|
|
2524
|
-
var
|
|
2562
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
2525
2563
|
function useIsContract({
|
|
2526
2564
|
address,
|
|
2527
2565
|
chain,
|
|
2528
2566
|
enabled
|
|
2529
2567
|
}) {
|
|
2530
|
-
return (0,
|
|
2568
|
+
return (0, import_react_query6.useQuery)({
|
|
2531
2569
|
queryKey: ["is_contract", chain?.id, address],
|
|
2532
2570
|
queryFn: async () => {
|
|
2533
2571
|
if (!chain) return false;
|
|
@@ -2606,7 +2644,7 @@ function ImportToken({ close }) {
|
|
|
2606
2644
|
}, [address, publicClient]);
|
|
2607
2645
|
const [loading, setLoading] = (0, import_react37.useState)(false);
|
|
2608
2646
|
const toast = useToast();
|
|
2609
|
-
const queryClient2 = (0,
|
|
2647
|
+
const queryClient2 = (0, import_react_query7.useQueryClient)();
|
|
2610
2648
|
const onImport = async () => {
|
|
2611
2649
|
setLoading(true);
|
|
2612
2650
|
try {
|
|
@@ -2996,7 +3034,7 @@ function useMatchWalletAssetList({
|
|
|
2996
3034
|
name: chain?.nativeCurrency.name,
|
|
2997
3035
|
balance: 0
|
|
2998
3036
|
};
|
|
2999
|
-
const nativeBalanceQuery = (0,
|
|
3037
|
+
const nativeBalanceQuery = (0, import_react_query8.useQuery)({
|
|
3000
3038
|
queryKey: ["nativeBalance", nativeToken?.chain_id],
|
|
3001
3039
|
queryFn: async () => {
|
|
3002
3040
|
if (!nativeToken || !publicClient) return null;
|
|
@@ -3016,7 +3054,7 @@ function useMatchWalletAssetList({
|
|
|
3016
3054
|
// Retry up to 3 times if failed
|
|
3017
3055
|
});
|
|
3018
3056
|
const erc20Tokens = (0, import_react38.useMemo)(() => list.filter((asset) => asset.address !== NATIVE_TOKEN_ADDRESS), [list]);
|
|
3019
|
-
const erc20BalanceQuery = (0,
|
|
3057
|
+
const erc20BalanceQuery = (0, import_react_query8.useQuery)({
|
|
3020
3058
|
queryKey: ["erc20Balances", erc20Tokens.map((token) => token.address)],
|
|
3021
3059
|
queryFn: async () => {
|
|
3022
3060
|
if (!erc20Tokens.length || !publicClient) return [];
|
|
@@ -3091,7 +3129,7 @@ function useMatchWalletAssetList({
|
|
|
3091
3129
|
|
|
3092
3130
|
// src/hooks/useReceipt.tsx
|
|
3093
3131
|
var import_react39 = require("react");
|
|
3094
|
-
var
|
|
3132
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
3095
3133
|
var import_viem12 = require("viem");
|
|
3096
3134
|
var CACHE_TTL = 86400 * 30 * 1e3;
|
|
3097
3135
|
var MAX_CACHE_SIZE = 500;
|
|
@@ -3200,7 +3238,7 @@ function useReceipt2({
|
|
|
3200
3238
|
const cache = useReceiptCache();
|
|
3201
3239
|
const chain = list?.find((item) => item.id === chainId);
|
|
3202
3240
|
const [shouldRefetch, setShouldRefetch] = (0, import_react39.useState)(true);
|
|
3203
|
-
const query = (0,
|
|
3241
|
+
const query = (0, import_react_query9.useQuery)({
|
|
3204
3242
|
queryKey: ["match-tx-receipt", hash, chain],
|
|
3205
3243
|
queryFn: async () => {
|
|
3206
3244
|
if (!chain || !hash) return false;
|
|
@@ -3235,7 +3273,7 @@ function useReceipt2({
|
|
|
3235
3273
|
|
|
3236
3274
|
// src/hooks/useTransaction.tsx
|
|
3237
3275
|
var import_react40 = require("react");
|
|
3238
|
-
var
|
|
3276
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
3239
3277
|
var import_viem13 = require("viem");
|
|
3240
3278
|
var CACHE_TTL2 = 86400 * 30 * 1e3;
|
|
3241
3279
|
var MAX_CACHE_SIZE2 = 500;
|
|
@@ -3344,7 +3382,7 @@ function useTransaction({
|
|
|
3344
3382
|
const cache = useTransactionCache();
|
|
3345
3383
|
const chain = list?.find((item) => item.id === chainId);
|
|
3346
3384
|
const [shouldRefetch, setShouldRefetch] = (0, import_react40.useState)(true);
|
|
3347
|
-
const query = (0,
|
|
3385
|
+
const query = (0, import_react_query10.useQuery)({
|
|
3348
3386
|
queryKey: ["match-tx-transaction", hash, chain],
|
|
3349
3387
|
queryFn: async () => {
|
|
3350
3388
|
if (!chain || !hash) return false;
|