@matchain/matchid-sdk-react 0.1.39 → 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/{chunk-7HVF5LGS.mjs → chunk-75ZLGQV7.mjs} +2 -2
- package/dist/{chunk-RVAWFV2B.mjs → chunk-XMGJLSI2.mjs} +41 -23
- package/dist/{chunk-RVAWFV2B.mjs.map → chunk-XMGJLSI2.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 +37 -19
- 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-75ZLGQV7.mjs.map} +0 -0
|
@@ -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";
|
|
@@ -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,6 +2878,10 @@ 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
2886
|
window.sendMatchWalletMessage = (method, data) => {
|
|
2873
2887
|
const messageId = Date.now().toString() + Math.random().toString().slice(6);
|
|
@@ -2877,32 +2891,36 @@ function useWalletInit({
|
|
|
2877
2891
|
messageId,
|
|
2878
2892
|
source: "matchid"
|
|
2879
2893
|
};
|
|
2894
|
+
if (!iframeLoaded) {
|
|
2895
|
+
throw new Error("Wallet not ready");
|
|
2896
|
+
}
|
|
2897
|
+
if (!walletInited) {
|
|
2898
|
+
throw new Error("Wallet not inited");
|
|
2899
|
+
}
|
|
2880
2900
|
if (document.getElementById("match-wallet")) {
|
|
2881
2901
|
matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.auth);
|
|
2882
2902
|
getWalletIframe()?.contentWindow?.postMessage(message, endpoints.auth);
|
|
2883
2903
|
return messageId;
|
|
2884
2904
|
}
|
|
2885
|
-
|
|
2886
|
-
return false;
|
|
2905
|
+
throw new Error("Wallet not found");
|
|
2887
2906
|
};
|
|
2888
2907
|
window.waitMatchUntilWalletMessage = async (method, data, timeout = 3e4) => {
|
|
2889
2908
|
return new Promise((resolve, reject) => {
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
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);
|
|
2895
2923
|
}
|
|
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
2924
|
});
|
|
2907
2925
|
};
|
|
2908
2926
|
} else {
|
|
@@ -3628,7 +3646,7 @@ function useUserInfo() {
|
|
|
3628
3646
|
const { open: TRONOpen } = useTRONModalStore();
|
|
3629
3647
|
const { open: BTCOpen } = useBTCModalStore();
|
|
3630
3648
|
const { open: CEXBindOpen } = useCEXBindModalStore();
|
|
3631
|
-
const isLogin =
|
|
3649
|
+
const isLogin = useMemo10(() => !!token, [token]);
|
|
3632
3650
|
const logout = async () => {
|
|
3633
3651
|
try {
|
|
3634
3652
|
await toLogoutApi();
|
|
@@ -3894,4 +3912,4 @@ export {
|
|
|
3894
3912
|
MatchProvider,
|
|
3895
3913
|
useMatch
|
|
3896
3914
|
};
|
|
3897
|
-
//# sourceMappingURL=chunk-
|
|
3915
|
+
//# sourceMappingURL=chunk-XMGJLSI2.mjs.map
|