@matchain/matchid-sdk-react 0.1.38 → 0.1.40-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/assets/icon/index.d.mts +1 -1
- package/dist/assets/icon/index.d.ts +1 -1
- package/dist/{chunk-IHRQKSSO.mjs → chunk-75ZLGQV7.mjs} +2 -2
- package/dist/{chunk-F5CJROWH.mjs → chunk-XMGJLSI2.mjs} +46 -25
- package/dist/chunk-XMGJLSI2.mjs.map +1 -0
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +5 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/hooks/api/index.d.mts +2 -2
- package/dist/hooks/api/index.d.ts +2 -2
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +2 -2
- package/dist/hooks/index.d.mts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/{index-DUCRzr-P.d.ts → index-BPveUnst.d.ts} +1 -1
- package/dist/{index-CAvsdgJw.d.mts → index-ClQl2MMF.d.mts} +1 -1
- package/dist/{index-B89X65ox.d.ts → index-CvCSpU8m.d.ts} +1 -1
- package/dist/{index-BICt0DjJ.d.ts → index-DlrDrTMk.d.ts} +1 -1
- package/dist/{index-BTTka3Uo.d.mts → index-Dm5o2w2J.d.mts} +1 -1
- package/dist/{index-CzAaZV-2.d.mts → index-mEK7Lcps.d.mts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +42 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{types.d-Cqt8ifXa.d.mts → types.d-IS3DBl3p.d.mts} +1 -1
- package/dist/{types.d-Cqt8ifXa.d.ts → types.d-IS3DBl3p.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-F5CJROWH.mjs.map +0 -1
- /package/dist/{chunk-IHRQKSSO.mjs.map → chunk-75ZLGQV7.mjs.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { CSSProperties } from 'react';
|
|
3
|
-
import { l as IconProps$1 } from '../../types.d-
|
|
3
|
+
import { l as IconProps$1 } from '../../types.d-IS3DBl3p.mjs';
|
|
4
4
|
|
|
5
5
|
declare function BackIcon({ color, size, className, style }: {
|
|
6
6
|
color?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { CSSProperties } from 'react';
|
|
3
|
-
import { l as IconProps$1 } from '../../types.d-
|
|
3
|
+
import { l as IconProps$1 } from '../../types.d-IS3DBl3p.js';
|
|
4
4
|
|
|
5
5
|
declare function BackIcon({ color, size, className, style }: {
|
|
6
6
|
color?: string;
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
unBindWalletApi,
|
|
10
10
|
useUserInfo,
|
|
11
11
|
verifyPohApi
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-XMGJLSI2.mjs";
|
|
13
13
|
import {
|
|
14
14
|
__export
|
|
15
15
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -90,4 +90,4 @@ export {
|
|
|
90
90
|
user_exports,
|
|
91
91
|
api_exports
|
|
92
92
|
};
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
//# sourceMappingURL=chunk-75ZLGQV7.mjs.map
|
|
@@ -93,7 +93,7 @@ var localStore = useLocalStore;
|
|
|
93
93
|
var useLocalStore_default = useLocalStore;
|
|
94
94
|
|
|
95
95
|
// src/hooks/useUserInfo.tsx
|
|
96
|
-
import { useMemo as
|
|
96
|
+
import { useMemo as useMemo10 } from "react";
|
|
97
97
|
|
|
98
98
|
// src/api/request.ts
|
|
99
99
|
import axios from "axios";
|
|
@@ -1101,9 +1101,12 @@ function LoginBox({
|
|
|
1101
1101
|
],
|
|
1102
1102
|
methods = [
|
|
1103
1103
|
"telegram",
|
|
1104
|
-
"twitter"
|
|
1104
|
+
"twitter",
|
|
1105
|
+
"github",
|
|
1106
|
+
"linkedin",
|
|
1107
|
+
"discord"
|
|
1105
1108
|
],
|
|
1106
|
-
walletMethods = ["evm", "sol"],
|
|
1109
|
+
walletMethods = ["evm", "sol", "btc", "tron"],
|
|
1107
1110
|
inModal = false
|
|
1108
1111
|
}) {
|
|
1109
1112
|
const [emailOpen, setEmailOpen] = useState9(false);
|
|
@@ -2524,7 +2527,7 @@ function BTCModal({
|
|
|
2524
2527
|
}
|
|
2525
2528
|
|
|
2526
2529
|
// src/components/CEXBindModal/index.tsx
|
|
2527
|
-
import { useEffect as useEffect13, useState as useState18 } from "react";
|
|
2530
|
+
import { useEffect as useEffect13, useMemo as useMemo9, useState as useState18 } from "react";
|
|
2528
2531
|
import { FormattedMessage as FormattedMessage10, useIntl as useIntl13 } from "react-intl";
|
|
2529
2532
|
import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2530
2533
|
function CEXBindModal({
|
|
@@ -2541,6 +2544,9 @@ function CEXBindModal({
|
|
|
2541
2544
|
const [key, setKey] = useState18("");
|
|
2542
2545
|
const [secret, setSecret] = useState18("");
|
|
2543
2546
|
const [error, setError] = useState18("");
|
|
2547
|
+
const needPassphrase = useMemo9(() => {
|
|
2548
|
+
return ["bitget", "okx"].includes(type.toLowerCase());
|
|
2549
|
+
}, [type]);
|
|
2544
2550
|
useEffect13(() => {
|
|
2545
2551
|
if (isOpen) {
|
|
2546
2552
|
setSecret("");
|
|
@@ -2557,7 +2563,7 @@ function CEXBindModal({
|
|
|
2557
2563
|
cex: type,
|
|
2558
2564
|
api_key: key,
|
|
2559
2565
|
api_secret: secret,
|
|
2560
|
-
...
|
|
2566
|
+
...needPassphrase ? { api_passphrase: APIPassphrase } : {}
|
|
2561
2567
|
});
|
|
2562
2568
|
if (isSuccess(res)) {
|
|
2563
2569
|
await refreshOverview();
|
|
@@ -2609,7 +2615,7 @@ function CEXBindModal({
|
|
|
2609
2615
|
placeholder: "**** **** ****"
|
|
2610
2616
|
}
|
|
2611
2617
|
) }),
|
|
2612
|
-
|
|
2618
|
+
needPassphrase && /* @__PURE__ */ jsx23(Field, { error, label: intl.formatMessage({
|
|
2613
2619
|
id: "CEXBindApiPassphrase"
|
|
2614
2620
|
}), children: /* @__PURE__ */ jsx23(
|
|
2615
2621
|
Input,
|
|
@@ -2849,6 +2855,13 @@ function useWalletInit({
|
|
|
2849
2855
|
const [walletInited, setWalletInited] = useState19(false);
|
|
2850
2856
|
const { appid, token, overview } = useLocalStore_default();
|
|
2851
2857
|
const { initWallet, generateWallet } = useWallet();
|
|
2858
|
+
const [iframeLoaded, setIframeLoaded] = useState19(false);
|
|
2859
|
+
useEffect14(() => {
|
|
2860
|
+
console.log("wallet status", {
|
|
2861
|
+
iframeLoaded,
|
|
2862
|
+
walletInited
|
|
2863
|
+
});
|
|
2864
|
+
}, [iframeLoaded, walletInited]);
|
|
2852
2865
|
useEffect14(() => {
|
|
2853
2866
|
if (endpoints.auth) {
|
|
2854
2867
|
if (!window.matchWalletMessageIdMap) {
|
|
@@ -2865,6 +2878,10 @@ function useWalletInit({
|
|
|
2865
2878
|
iframe.onerror = (e) => {
|
|
2866
2879
|
console.error("iframe error", e);
|
|
2867
2880
|
};
|
|
2881
|
+
iframe.addEventListener("load", () => {
|
|
2882
|
+
console.log("Iframe has loaded.");
|
|
2883
|
+
setIframeLoaded(true);
|
|
2884
|
+
});
|
|
2868
2885
|
document.body.insertBefore(iframe, document.body.firstChild);
|
|
2869
2886
|
window.sendMatchWalletMessage = (method, data) => {
|
|
2870
2887
|
const messageId = Date.now().toString() + Math.random().toString().slice(6);
|
|
@@ -2874,32 +2891,36 @@ function useWalletInit({
|
|
|
2874
2891
|
messageId,
|
|
2875
2892
|
source: "matchid"
|
|
2876
2893
|
};
|
|
2894
|
+
if (!iframeLoaded) {
|
|
2895
|
+
throw new Error("Wallet not ready");
|
|
2896
|
+
}
|
|
2897
|
+
if (!walletInited) {
|
|
2898
|
+
throw new Error("Wallet not inited");
|
|
2899
|
+
}
|
|
2877
2900
|
if (document.getElementById("match-wallet")) {
|
|
2878
2901
|
matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.auth);
|
|
2879
2902
|
getWalletIframe()?.contentWindow?.postMessage(message, endpoints.auth);
|
|
2880
2903
|
return messageId;
|
|
2881
2904
|
}
|
|
2882
|
-
|
|
2883
|
-
return false;
|
|
2905
|
+
throw new Error("Wallet not found");
|
|
2884
2906
|
};
|
|
2885
2907
|
window.waitMatchUntilWalletMessage = async (method, data, timeout = 3e4) => {
|
|
2886
2908
|
return new Promise((resolve, reject) => {
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2909
|
+
try {
|
|
2910
|
+
const messageId = window.sendMatchWalletMessage(method, data);
|
|
2911
|
+
window.matchWalletMessageIdMap[messageId] = { resolve, reject };
|
|
2912
|
+
window.matchWalletMessageIdMap[messageId].timeout = setTimeout(() => {
|
|
2913
|
+
console.error("Get wallet result timeout", {
|
|
2914
|
+
messageId,
|
|
2915
|
+
method,
|
|
2916
|
+
data
|
|
2917
|
+
});
|
|
2918
|
+
delete window.matchWalletMessageIdMap[messageId];
|
|
2919
|
+
reject(new Error("Get wallet result timeout"));
|
|
2920
|
+
}, timeout);
|
|
2921
|
+
} catch (error) {
|
|
2922
|
+
reject(error);
|
|
2892
2923
|
}
|
|
2893
|
-
window.matchWalletMessageIdMap[messageId] = { resolve, reject };
|
|
2894
|
-
window.matchWalletMessageIdMap[messageId].timeout = setTimeout(() => {
|
|
2895
|
-
console.error("Get wallet result timeout", {
|
|
2896
|
-
messageId,
|
|
2897
|
-
method,
|
|
2898
|
-
data
|
|
2899
|
-
});
|
|
2900
|
-
delete window.matchWalletMessageIdMap[messageId];
|
|
2901
|
-
reject(new Error("Get wallet result timeout"));
|
|
2902
|
-
}, timeout);
|
|
2903
2924
|
});
|
|
2904
2925
|
};
|
|
2905
2926
|
} else {
|
|
@@ -3625,7 +3646,7 @@ function useUserInfo() {
|
|
|
3625
3646
|
const { open: TRONOpen } = useTRONModalStore();
|
|
3626
3647
|
const { open: BTCOpen } = useBTCModalStore();
|
|
3627
3648
|
const { open: CEXBindOpen } = useCEXBindModalStore();
|
|
3628
|
-
const isLogin =
|
|
3649
|
+
const isLogin = useMemo10(() => !!token, [token]);
|
|
3629
3650
|
const logout = async () => {
|
|
3630
3651
|
try {
|
|
3631
3652
|
await toLogoutApi();
|
|
@@ -3891,4 +3912,4 @@ export {
|
|
|
3891
3912
|
MatchProvider,
|
|
3892
3913
|
useMatch
|
|
3893
3914
|
};
|
|
3894
|
-
//# sourceMappingURL=chunk-
|
|
3915
|
+
//# sourceMappingURL=chunk-XMGJLSI2.mjs.map
|