@matchain/matchid-sdk-react 0.1.39 → 0.1.40-alpha.1
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-7HVF5LGS.mjs → chunk-OG7AO57N.mjs} +2 -2
- package/dist/{chunk-RVAWFV2B.mjs → chunk-R3JJJMNQ.mjs} +57 -29
- package/dist/{chunk-RVAWFV2B.mjs.map → chunk-R3JJJMNQ.mjs.map} +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +2 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/index.js +53 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
- /package/dist/{chunk-7HVF5LGS.mjs.map → chunk-OG7AO57N.mjs.map} +0 -0
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
unBindWalletApi,
|
|
10
10
|
useUserInfo,
|
|
11
11
|
verifyPohApi
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-R3JJJMNQ.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-OG7AO57N.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";
|
|
@@ -2527,7 +2527,7 @@ function BTCModal({
|
|
|
2527
2527
|
}
|
|
2528
2528
|
|
|
2529
2529
|
// src/components/CEXBindModal/index.tsx
|
|
2530
|
-
import { useEffect as useEffect13, useState as useState18 } from "react";
|
|
2530
|
+
import { useEffect as useEffect13, useMemo as useMemo9, useState as useState18 } from "react";
|
|
2531
2531
|
import { FormattedMessage as FormattedMessage10, useIntl as useIntl13 } from "react-intl";
|
|
2532
2532
|
import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2533
2533
|
function CEXBindModal({
|
|
@@ -2544,6 +2544,9 @@ function CEXBindModal({
|
|
|
2544
2544
|
const [key, setKey] = useState18("");
|
|
2545
2545
|
const [secret, setSecret] = useState18("");
|
|
2546
2546
|
const [error, setError] = useState18("");
|
|
2547
|
+
const needPassphrase = useMemo9(() => {
|
|
2548
|
+
return ["bitget", "okx"].includes(type.toLowerCase());
|
|
2549
|
+
}, [type]);
|
|
2547
2550
|
useEffect13(() => {
|
|
2548
2551
|
if (isOpen) {
|
|
2549
2552
|
setSecret("");
|
|
@@ -2560,7 +2563,7 @@ function CEXBindModal({
|
|
|
2560
2563
|
cex: type,
|
|
2561
2564
|
api_key: key,
|
|
2562
2565
|
api_secret: secret,
|
|
2563
|
-
...
|
|
2566
|
+
...needPassphrase ? { api_passphrase: APIPassphrase } : {}
|
|
2564
2567
|
});
|
|
2565
2568
|
if (isSuccess(res)) {
|
|
2566
2569
|
await refreshOverview();
|
|
@@ -2612,7 +2615,7 @@ function CEXBindModal({
|
|
|
2612
2615
|
placeholder: "**** **** ****"
|
|
2613
2616
|
}
|
|
2614
2617
|
) }),
|
|
2615
|
-
|
|
2618
|
+
needPassphrase && /* @__PURE__ */ jsx23(Field, { error, label: intl.formatMessage({
|
|
2616
2619
|
id: "CEXBindApiPassphrase"
|
|
2617
2620
|
}), children: /* @__PURE__ */ jsx23(
|
|
2618
2621
|
Input,
|
|
@@ -2852,6 +2855,13 @@ function useWalletInit({
|
|
|
2852
2855
|
const [walletInited, setWalletInited] = useState19(false);
|
|
2853
2856
|
const { appid, token, overview } = useLocalStore_default();
|
|
2854
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]);
|
|
2855
2865
|
useEffect14(() => {
|
|
2856
2866
|
if (endpoints.auth) {
|
|
2857
2867
|
if (!window.matchWalletMessageIdMap) {
|
|
@@ -2868,8 +2878,31 @@ function useWalletInit({
|
|
|
2868
2878
|
iframe.onerror = (e) => {
|
|
2869
2879
|
console.error("iframe error", e);
|
|
2870
2880
|
};
|
|
2881
|
+
iframe.addEventListener("load", () => {
|
|
2882
|
+
console.log("Iframe has loaded.");
|
|
2883
|
+
setIframeLoaded(true);
|
|
2884
|
+
});
|
|
2871
2885
|
document.body.insertBefore(iframe, document.body.firstChild);
|
|
2872
|
-
window.sendMatchWalletMessage = (method, data) => {
|
|
2886
|
+
window.sendMatchWalletMessage = (method, data, retry = 5, times = 0) => {
|
|
2887
|
+
try {
|
|
2888
|
+
if (!iframeLoaded) {
|
|
2889
|
+
throw new Error("Wallet not ready");
|
|
2890
|
+
}
|
|
2891
|
+
if (!walletInited) {
|
|
2892
|
+
throw new Error("Wallet not inited");
|
|
2893
|
+
}
|
|
2894
|
+
if (!document.getElementById("match-wallet")) {
|
|
2895
|
+
throw new Error("Wallet not found");
|
|
2896
|
+
}
|
|
2897
|
+
} catch (error) {
|
|
2898
|
+
if (times < retry) {
|
|
2899
|
+
setTimeout(() => {
|
|
2900
|
+
window.sendMatchWalletMessage(method, data, retry, times + 1);
|
|
2901
|
+
}, 1e3);
|
|
2902
|
+
} else {
|
|
2903
|
+
throw error;
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2873
2906
|
const messageId = Date.now().toString() + Math.random().toString().slice(6);
|
|
2874
2907
|
const message = {
|
|
2875
2908
|
method,
|
|
@@ -2877,32 +2910,27 @@ function useWalletInit({
|
|
|
2877
2910
|
messageId,
|
|
2878
2911
|
source: "matchid"
|
|
2879
2912
|
};
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
return messageId;
|
|
2884
|
-
}
|
|
2885
|
-
console.error("not found iframe");
|
|
2886
|
-
return false;
|
|
2913
|
+
matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.auth);
|
|
2914
|
+
getWalletIframe()?.contentWindow?.postMessage(message, endpoints.auth);
|
|
2915
|
+
return messageId;
|
|
2887
2916
|
};
|
|
2888
2917
|
window.waitMatchUntilWalletMessage = async (method, data, timeout = 3e4) => {
|
|
2889
2918
|
return new Promise((resolve, reject) => {
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2919
|
+
try {
|
|
2920
|
+
const messageId = window.sendMatchWalletMessage(method, data);
|
|
2921
|
+
window.matchWalletMessageIdMap[messageId] = { resolve, reject };
|
|
2922
|
+
window.matchWalletMessageIdMap[messageId].timeout = setTimeout(() => {
|
|
2923
|
+
console.error("Get wallet result timeout", {
|
|
2924
|
+
messageId,
|
|
2925
|
+
method,
|
|
2926
|
+
data
|
|
2927
|
+
});
|
|
2928
|
+
delete window.matchWalletMessageIdMap[messageId];
|
|
2929
|
+
reject(new Error("Get wallet result timeout"));
|
|
2930
|
+
}, timeout);
|
|
2931
|
+
} catch (error) {
|
|
2932
|
+
reject(error);
|
|
2895
2933
|
}
|
|
2896
|
-
window.matchWalletMessageIdMap[messageId] = { resolve, reject };
|
|
2897
|
-
window.matchWalletMessageIdMap[messageId].timeout = setTimeout(() => {
|
|
2898
|
-
console.error("Get wallet result timeout", {
|
|
2899
|
-
messageId,
|
|
2900
|
-
method,
|
|
2901
|
-
data
|
|
2902
|
-
});
|
|
2903
|
-
delete window.matchWalletMessageIdMap[messageId];
|
|
2904
|
-
reject(new Error("Get wallet result timeout"));
|
|
2905
|
-
}, timeout);
|
|
2906
2934
|
});
|
|
2907
2935
|
};
|
|
2908
2936
|
} else {
|
|
@@ -3628,7 +3656,7 @@ function useUserInfo() {
|
|
|
3628
3656
|
const { open: TRONOpen } = useTRONModalStore();
|
|
3629
3657
|
const { open: BTCOpen } = useBTCModalStore();
|
|
3630
3658
|
const { open: CEXBindOpen } = useCEXBindModalStore();
|
|
3631
|
-
const isLogin =
|
|
3659
|
+
const isLogin = useMemo10(() => !!token, [token]);
|
|
3632
3660
|
const logout = async () => {
|
|
3633
3661
|
try {
|
|
3634
3662
|
await toLogoutApi();
|
|
@@ -3894,4 +3922,4 @@ export {
|
|
|
3894
3922
|
MatchProvider,
|
|
3895
3923
|
useMatch
|
|
3896
3924
|
};
|
|
3897
|
-
//# sourceMappingURL=chunk-
|
|
3925
|
+
//# sourceMappingURL=chunk-R3JJJMNQ.mjs.map
|