@matchain/matchid-sdk-react 0.1.40-alpha.4 → 0.1.40-alpha.6
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-GYHBGOEC.mjs → chunk-QEOWZ3EN.mjs} +2 -2
- package/dist/{chunk-HL5ODTAH.mjs → chunk-ZLARXHQ5.mjs} +321 -91
- package/dist/chunk-ZLARXHQ5.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 +249 -36
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +3 -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 +35 -18
- 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 +41 -24
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/{index-CiM5L42f.d.mts → index-C3KZYrtu.d.mts} +1 -1
- package/dist/{index-CvCSpU8m.d.ts → index-COlsBC-b.d.mts} +9 -3
- package/dist/{index-BPveUnst.d.ts → index-DoF5jRoi.d.ts} +1 -1
- package/dist/{index-DBscX8i6.d.ts → index-Dq9Swg8r.d.ts} +1 -1
- package/dist/{index-ClQl2MMF.d.mts → index-fS75Swm8.d.ts} +9 -3
- package/dist/{index-Dm5o2w2J.d.mts → index-fl6SNIZC.d.mts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +318 -95
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{types.d-IS3DBl3p.d.mts → types.d-CLO_WLka.d.mts} +1 -1
- package/dist/{types.d-IS3DBl3p.d.ts → types.d-CLO_WLka.d.ts} +1 -1
- package/example/src/components/Login/index.tsx +2 -2
- package/example/src/config/index.ts +6 -1
- package/example/src/pages/User.tsx +4 -4
- package/package.json +2 -2
- package/dist/chunk-HL5ODTAH.mjs.map +0 -1
- /package/dist/{chunk-GYHBGOEC.mjs.map → chunk-QEOWZ3EN.mjs.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { g as BTCModal, B as Button, E as EmailModal, F as Field, I as Input, L as LoginBox, b as LoginButton, d as LoginModal, c as LoginPanel, M as Modal, a as ModalWithHeader, e as PasswordModal, P as Popover, S as SOLModal, f as TONModal, T as TRONModal, U as UsernameModal } from '../index-COlsBC-b.mjs';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
|
-
import '../types.d-
|
|
3
|
+
import '../types.d-CLO_WLka.mjs';
|
|
4
4
|
import 'react';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { g as BTCModal, B as Button, E as EmailModal, F as Field, I as Input, L as LoginBox, b as LoginButton, d as LoginModal, c as LoginPanel, M as Modal, a as ModalWithHeader, e as PasswordModal, P as Popover, S as SOLModal, f as TONModal, T as TRONModal, U as UsernameModal } from '../index-fS75Swm8.js';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
|
-
import '../types.d-
|
|
3
|
+
import '../types.d-CLO_WLka.js';
|
|
4
4
|
import 'react';
|
package/dist/components/index.js
CHANGED
|
@@ -44,6 +44,7 @@ __export(components_exports, {
|
|
|
44
44
|
PasswordModal: () => PasswordModal,
|
|
45
45
|
Popover: () => Popover,
|
|
46
46
|
SOLModal: () => SOLModal,
|
|
47
|
+
TONModal: () => TONModal,
|
|
47
48
|
TRONModal: () => TRONModal,
|
|
48
49
|
UsernameModal: () => UsernameModal
|
|
49
50
|
});
|
|
@@ -1479,28 +1480,42 @@ var getAuthInfoApi = () => {
|
|
|
1479
1480
|
method: "GET"
|
|
1480
1481
|
});
|
|
1481
1482
|
};
|
|
1482
|
-
var getWalletNonceApi = (
|
|
1483
|
+
var getWalletNonceApi = (data) => {
|
|
1483
1484
|
return request_default({
|
|
1484
1485
|
url: `/api/v1/login/wallet/init`,
|
|
1485
1486
|
method: "POST",
|
|
1486
|
-
data
|
|
1487
|
+
data
|
|
1487
1488
|
});
|
|
1488
1489
|
};
|
|
1489
|
-
var loginByWalletApi = ({
|
|
1490
|
+
var loginByWalletApi = ({
|
|
1491
|
+
type,
|
|
1492
|
+
address,
|
|
1493
|
+
signature,
|
|
1494
|
+
message,
|
|
1495
|
+
connector_type,
|
|
1496
|
+
wallet_client_type
|
|
1497
|
+
}) => {
|
|
1490
1498
|
return request_default({
|
|
1491
1499
|
url: `/api/v1/login/wallet`,
|
|
1492
1500
|
method: "POST",
|
|
1493
1501
|
data: { type, address, signature, message, connector_type, wallet_client_type }
|
|
1494
1502
|
});
|
|
1495
1503
|
};
|
|
1496
|
-
var getWalletInitApi = (
|
|
1504
|
+
var getWalletInitApi = (data) => {
|
|
1497
1505
|
return request_default({
|
|
1498
1506
|
url: `/api/v1/wallet/init`,
|
|
1499
1507
|
method: "POST",
|
|
1500
|
-
data
|
|
1508
|
+
data
|
|
1501
1509
|
});
|
|
1502
1510
|
};
|
|
1503
|
-
var toBindWalletApi = ({
|
|
1511
|
+
var toBindWalletApi = ({
|
|
1512
|
+
type,
|
|
1513
|
+
address,
|
|
1514
|
+
signature,
|
|
1515
|
+
message,
|
|
1516
|
+
connector_type,
|
|
1517
|
+
wallet_client_type
|
|
1518
|
+
}) => {
|
|
1504
1519
|
return request_default({
|
|
1505
1520
|
url: `/api/v1/wallet/bind`,
|
|
1506
1521
|
method: "POST",
|
|
@@ -1841,6 +1856,12 @@ var useTRONModalStore = (0, import_zustand3.create)((set) => ({
|
|
|
1841
1856
|
open: (type) => set({ isOpen: true, type }),
|
|
1842
1857
|
close: () => set({ isOpen: false })
|
|
1843
1858
|
}));
|
|
1859
|
+
var useTONModalStore = (0, import_zustand3.create)((set) => ({
|
|
1860
|
+
isOpen: false,
|
|
1861
|
+
type: "",
|
|
1862
|
+
open: (type) => set({ isOpen: true, type }),
|
|
1863
|
+
close: () => set({ isOpen: false })
|
|
1864
|
+
}));
|
|
1844
1865
|
var useBTCModalStore = (0, import_zustand3.create)((set) => ({
|
|
1845
1866
|
isOpen: false,
|
|
1846
1867
|
type: "",
|
|
@@ -1905,6 +1926,7 @@ function useUserInfo() {
|
|
|
1905
1926
|
const { events, login } = useMatch();
|
|
1906
1927
|
const { open: SOLOpen } = useSOLModalStore();
|
|
1907
1928
|
const { open: TRONOpen } = useTRONModalStore();
|
|
1929
|
+
const { open: TONOpen } = useTONModalStore();
|
|
1908
1930
|
const { open: BTCOpen } = useBTCModalStore();
|
|
1909
1931
|
const { open: CEXBindOpen } = useCEXBindModalStore();
|
|
1910
1932
|
const isLogin = (0, import_react12.useMemo)(() => !!token, [token]);
|
|
@@ -1953,6 +1975,8 @@ function useUserInfo() {
|
|
|
1953
1975
|
return SOLOpen("login");
|
|
1954
1976
|
case "tron":
|
|
1955
1977
|
return TRONOpen("login");
|
|
1978
|
+
case "ton":
|
|
1979
|
+
return TONOpen("login");
|
|
1956
1980
|
case "btc":
|
|
1957
1981
|
return BTCOpen("login");
|
|
1958
1982
|
case "telegram":
|
|
@@ -2044,6 +2068,8 @@ function useUserInfo() {
|
|
|
2044
2068
|
return SOLOpen("bind");
|
|
2045
2069
|
case "tron":
|
|
2046
2070
|
return TRONOpen("bind");
|
|
2071
|
+
case "ton":
|
|
2072
|
+
return TONOpen("bind");
|
|
2047
2073
|
case "btc":
|
|
2048
2074
|
return BTCOpen("bind");
|
|
2049
2075
|
case "telegram":
|
|
@@ -2435,6 +2461,12 @@ function LoginBox({
|
|
|
2435
2461
|
activeIcon: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(TRXLightIcon, { size: isDownMd ? 36 : 40 }),
|
|
2436
2462
|
name: "TRON",
|
|
2437
2463
|
onClick: () => login("tron")
|
|
2464
|
+
},
|
|
2465
|
+
ton: {
|
|
2466
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(TRXDarkIcon, { size: isDownMd ? 36 : 40 }),
|
|
2467
|
+
activeIcon: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(TRXLightIcon, { size: isDownMd ? 36 : 40 }),
|
|
2468
|
+
name: "TON",
|
|
2469
|
+
onClick: () => login("ton")
|
|
2438
2470
|
}
|
|
2439
2471
|
};
|
|
2440
2472
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_jsx_runtime56.Fragment, { children: [
|
|
@@ -2881,8 +2913,13 @@ function WalletModalContent({
|
|
|
2881
2913
|
text: error,
|
|
2882
2914
|
btnText: "Reconnect Wallet",
|
|
2883
2915
|
btnClick: async () => {
|
|
2916
|
+
console.log("click error");
|
|
2884
2917
|
setError("");
|
|
2885
|
-
|
|
2918
|
+
try {
|
|
2919
|
+
await disconnect();
|
|
2920
|
+
} catch (error2) {
|
|
2921
|
+
console.error(error2);
|
|
2922
|
+
}
|
|
2886
2923
|
setVisible(true);
|
|
2887
2924
|
},
|
|
2888
2925
|
statusImage: walletErrorImage,
|
|
@@ -2969,7 +3006,7 @@ function WalletContent({
|
|
|
2969
3006
|
try {
|
|
2970
3007
|
setStatus("nonce");
|
|
2971
3008
|
statusRef.current = "nonce";
|
|
2972
|
-
const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
|
|
3009
|
+
const res = type == "bind" ? await getWalletInitApi({ address, type: "SOL" }) : await getWalletNonceApi({ address, type: "SOL" });
|
|
2973
3010
|
if (!isSuccess(res)) {
|
|
2974
3011
|
throw new Error(res.message);
|
|
2975
3012
|
}
|
|
@@ -3236,7 +3273,7 @@ function TRONModal({
|
|
|
3236
3273
|
try {
|
|
3237
3274
|
setStatus("nonce");
|
|
3238
3275
|
statusRef.current = "nonce";
|
|
3239
|
-
const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
|
|
3276
|
+
const res = type == "bind" ? await getWalletInitApi({ address, type: "TRON" }) : await getWalletNonceApi({ address, type: "TRON" });
|
|
3240
3277
|
if (!isSuccess(res)) {
|
|
3241
3278
|
throw new Error(res.message);
|
|
3242
3279
|
}
|
|
@@ -3351,9 +3388,184 @@ function TRONModal({
|
|
|
3351
3388
|
] }) }) });
|
|
3352
3389
|
}
|
|
3353
3390
|
|
|
3354
|
-
// src/components/
|
|
3355
|
-
var
|
|
3391
|
+
// src/components/TONModal/index.tsx
|
|
3392
|
+
var import_react24 = __toESM(require("react"));
|
|
3356
3393
|
var import_react_intl15 = require("react-intl");
|
|
3394
|
+
var import_ui_react = require("@tonconnect/ui-react");
|
|
3395
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
3396
|
+
function WalletContent2({
|
|
3397
|
+
onSuccess,
|
|
3398
|
+
type
|
|
3399
|
+
}) {
|
|
3400
|
+
const { events, login } = useMatch();
|
|
3401
|
+
const [connected, setConnected] = (0, import_react24.useState)(false);
|
|
3402
|
+
const wallet = (0, import_ui_react.useTonWallet)();
|
|
3403
|
+
const userFriendlyAddress = (0, import_ui_react.useTonAddress)();
|
|
3404
|
+
const [tonConnectUI] = (0, import_ui_react.useTonConnectUI)();
|
|
3405
|
+
const { state, open, close } = (0, import_ui_react.useTonConnectModal)();
|
|
3406
|
+
const [status, setStatus] = (0, import_react24.useState)("");
|
|
3407
|
+
const statusRef = import_react24.default.useRef(status);
|
|
3408
|
+
const [error, setError] = (0, import_react24.useState)("");
|
|
3409
|
+
(0, import_react24.useEffect)(() => {
|
|
3410
|
+
const init = async () => {
|
|
3411
|
+
if (wallet) {
|
|
3412
|
+
await tonConnectUI.disconnect();
|
|
3413
|
+
}
|
|
3414
|
+
open();
|
|
3415
|
+
};
|
|
3416
|
+
init();
|
|
3417
|
+
tonConnectUI.onStatusChange((wallet2) => {
|
|
3418
|
+
matchlog_default.log("onStatusChange:", wallet2, wallet2?.connectItems?.tonProof, JSON.stringify(wallet2?.connectItems?.tonProof));
|
|
3419
|
+
if (wallet2?.connectItems?.tonProof && "proof" in wallet2.connectItems.tonProof) {
|
|
3420
|
+
matchlog_default.log(wallet2?.connectItems.tonProof.proof, wallet2?.account);
|
|
3421
|
+
const toLoginInWallet = async () => {
|
|
3422
|
+
if (statusRef.current || !wallet2) return;
|
|
3423
|
+
setStatus("signer");
|
|
3424
|
+
statusRef.current = "signer";
|
|
3425
|
+
try {
|
|
3426
|
+
const signature = {
|
|
3427
|
+
"address": wallet2?.account?.address,
|
|
3428
|
+
"network": wallet2?.account?.chain,
|
|
3429
|
+
"public_key": wallet2?.account?.publicKey,
|
|
3430
|
+
"proof": {
|
|
3431
|
+
//@ts-ignore
|
|
3432
|
+
...wallet2?.connectItems?.tonProof?.proof,
|
|
3433
|
+
"state_init": wallet2?.account?.walletStateInit
|
|
3434
|
+
}
|
|
3435
|
+
};
|
|
3436
|
+
let obj = {
|
|
3437
|
+
type: "TON",
|
|
3438
|
+
address: wallet2?.account?.publicKey,
|
|
3439
|
+
signature: JSON.stringify(signature),
|
|
3440
|
+
//@ts-ignore
|
|
3441
|
+
message: wallet2?.connectItems?.tonProof?.proof.payload,
|
|
3442
|
+
connector_type: "TON",
|
|
3443
|
+
wallet_client_type: wallet2?.name
|
|
3444
|
+
};
|
|
3445
|
+
console.log("signature", {
|
|
3446
|
+
signature,
|
|
3447
|
+
obj
|
|
3448
|
+
});
|
|
3449
|
+
const res1 = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
|
|
3450
|
+
if (res1) {
|
|
3451
|
+
if (!isSuccess(res1)) {
|
|
3452
|
+
throw new Error(res1.message);
|
|
3453
|
+
}
|
|
3454
|
+
matchlog_default.log(res1);
|
|
3455
|
+
setStatus("success");
|
|
3456
|
+
statusRef.current = "success";
|
|
3457
|
+
if (type == "bind") {
|
|
3458
|
+
events.onBind && events.onBind({
|
|
3459
|
+
type: "ton"
|
|
3460
|
+
});
|
|
3461
|
+
eventManager_default.emit("onBind", {
|
|
3462
|
+
type: "ton"
|
|
3463
|
+
});
|
|
3464
|
+
} else {
|
|
3465
|
+
await login({
|
|
3466
|
+
mid: res1.data.mid,
|
|
3467
|
+
token: `${res1.data.token_type} ${res1.data.access_token}`
|
|
3468
|
+
});
|
|
3469
|
+
}
|
|
3470
|
+
onSuccess && onSuccess();
|
|
3471
|
+
}
|
|
3472
|
+
} catch (error2) {
|
|
3473
|
+
setStatus("error");
|
|
3474
|
+
setError(error2.message);
|
|
3475
|
+
statusRef.current = "";
|
|
3476
|
+
}
|
|
3477
|
+
};
|
|
3478
|
+
toLoginInWallet();
|
|
3479
|
+
}
|
|
3480
|
+
});
|
|
3481
|
+
}, []);
|
|
3482
|
+
(0, import_react24.useEffect)(() => {
|
|
3483
|
+
if (wallet) {
|
|
3484
|
+
setConnected(true);
|
|
3485
|
+
console.log("Wallet connected:", wallet);
|
|
3486
|
+
} else {
|
|
3487
|
+
setConnected(false);
|
|
3488
|
+
open();
|
|
3489
|
+
statusRef.current = "";
|
|
3490
|
+
setStatus("");
|
|
3491
|
+
}
|
|
3492
|
+
}, [wallet]);
|
|
3493
|
+
(0, import_react24.useEffect)(() => {
|
|
3494
|
+
console.log({
|
|
3495
|
+
state,
|
|
3496
|
+
wallet
|
|
3497
|
+
});
|
|
3498
|
+
if (state.status == "opened") {
|
|
3499
|
+
const init = async () => {
|
|
3500
|
+
tonConnectUI.setConnectRequestParameters({ state: "loading" });
|
|
3501
|
+
const res = type == "bind" ? await getWalletInitApi({
|
|
3502
|
+
address: "tonconnect",
|
|
3503
|
+
type: "TON"
|
|
3504
|
+
}) : await getWalletNonceApi({ address: "tonconnect", type: "TON" });
|
|
3505
|
+
if (!isSuccess(res)) {
|
|
3506
|
+
tonConnectUI.setConnectRequestParameters(null);
|
|
3507
|
+
throw new Error(res.message);
|
|
3508
|
+
}
|
|
3509
|
+
tonConnectUI.setConnectRequestParameters({
|
|
3510
|
+
state: "ready",
|
|
3511
|
+
value: { tonProof: res.data.nonce }
|
|
3512
|
+
});
|
|
3513
|
+
};
|
|
3514
|
+
init();
|
|
3515
|
+
} else {
|
|
3516
|
+
if (!wallet) {
|
|
3517
|
+
setStatus("");
|
|
3518
|
+
statusRef.current = "";
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
}, [state]);
|
|
3522
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
3523
|
+
WalletModalContent,
|
|
3524
|
+
{
|
|
3525
|
+
connected,
|
|
3526
|
+
disconnect: tonConnectUI.disconnect,
|
|
3527
|
+
address: userFriendlyAddress,
|
|
3528
|
+
visible: state.status == "opened",
|
|
3529
|
+
setVisible: (v) => {
|
|
3530
|
+
console.log("setVisible", v);
|
|
3531
|
+
if (v) {
|
|
3532
|
+
setStatus("");
|
|
3533
|
+
statusRef.current = "";
|
|
3534
|
+
open();
|
|
3535
|
+
} else {
|
|
3536
|
+
close();
|
|
3537
|
+
}
|
|
3538
|
+
},
|
|
3539
|
+
error,
|
|
3540
|
+
setError,
|
|
3541
|
+
status
|
|
3542
|
+
}
|
|
3543
|
+
);
|
|
3544
|
+
}
|
|
3545
|
+
function TONModal({
|
|
3546
|
+
type = "login",
|
|
3547
|
+
onSuccess,
|
|
3548
|
+
...props
|
|
3549
|
+
}) {
|
|
3550
|
+
const intl = (0, import_react_intl15.useIntl)();
|
|
3551
|
+
const { endpoints, appid } = useLocalStore_default();
|
|
3552
|
+
const manifestUrl = `${endpoints.back}api/v1/wallet/ton?appid=${appid}&url=` + encodeURIComponent(window.location.origin);
|
|
3553
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
|
|
3554
|
+
id: type == "bind" ? "bindWith" : "loginWith"
|
|
3555
|
+
}, {
|
|
3556
|
+
name: "TON"
|
|
3557
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
3558
|
+
import_ui_react.TonConnectUIProvider,
|
|
3559
|
+
{
|
|
3560
|
+
manifestUrl,
|
|
3561
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(WalletContent2, { onSuccess, type })
|
|
3562
|
+
}
|
|
3563
|
+
) });
|
|
3564
|
+
}
|
|
3565
|
+
|
|
3566
|
+
// src/components/BTCModal/index.tsx
|
|
3567
|
+
var import_react26 = __toESM(require("react"));
|
|
3568
|
+
var import_react_intl16 = require("react-intl");
|
|
3357
3569
|
|
|
3358
3570
|
// src/lib/btc/UnisatAdapter.ts
|
|
3359
3571
|
var UnisatAdapter = class {
|
|
@@ -3501,12 +3713,12 @@ var LeatherAdapter = class {
|
|
|
3501
3713
|
};
|
|
3502
3714
|
|
|
3503
3715
|
// src/hooks/useBTCWallet.ts
|
|
3504
|
-
var
|
|
3716
|
+
var import_react25 = require("react");
|
|
3505
3717
|
var useBTCWallet = () => {
|
|
3506
3718
|
const wallets2 = [new UnisatAdapter(), new XverseAdapter(), new LeatherAdapter()];
|
|
3507
|
-
const [installedWallets, setInstalledWallets] = (0,
|
|
3508
|
-
const [address, setAddress] = (0,
|
|
3509
|
-
(0,
|
|
3719
|
+
const [installedWallets, setInstalledWallets] = (0, import_react25.useState)([]);
|
|
3720
|
+
const [address, setAddress] = (0, import_react25.useState)(null);
|
|
3721
|
+
(0, import_react25.useEffect)(() => {
|
|
3510
3722
|
const getInstalled = async () => {
|
|
3511
3723
|
const installed = await Promise.all(wallets2.map((wallet2) => wallet2.isInstalled().then((isInstalled) => ({
|
|
3512
3724
|
wallet: wallet2,
|
|
@@ -3516,11 +3728,11 @@ var useBTCWallet = () => {
|
|
|
3516
3728
|
};
|
|
3517
3729
|
getInstalled();
|
|
3518
3730
|
}, []);
|
|
3519
|
-
const [wallet, chooseWallet] = (0,
|
|
3731
|
+
const [wallet, chooseWallet] = (0, import_react25.useState)(null);
|
|
3520
3732
|
const onConnect = async () => {
|
|
3521
3733
|
setAddress(await wallet.connect());
|
|
3522
3734
|
};
|
|
3523
|
-
(0,
|
|
3735
|
+
(0, import_react25.useEffect)(() => {
|
|
3524
3736
|
if (!wallet) {
|
|
3525
3737
|
setAddress(null);
|
|
3526
3738
|
}
|
|
@@ -3536,25 +3748,25 @@ var useBTCWallet = () => {
|
|
|
3536
3748
|
};
|
|
3537
3749
|
|
|
3538
3750
|
// src/components/BTCModal/index.tsx
|
|
3539
|
-
var
|
|
3751
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
3540
3752
|
function BTCModal({
|
|
3541
3753
|
type = "login",
|
|
3542
3754
|
onSuccess,
|
|
3543
3755
|
...props
|
|
3544
3756
|
}) {
|
|
3545
3757
|
const isDownMd = useDownMd();
|
|
3546
|
-
const intl = (0,
|
|
3758
|
+
const intl = (0, import_react_intl16.useIntl)();
|
|
3547
3759
|
const { wallets: wallets2, installedWallets, chooseWallet, wallet, address, onConnect } = useBTCWallet();
|
|
3548
3760
|
const iconMaps = {
|
|
3549
|
-
leather: /* @__PURE__ */ (0,
|
|
3550
|
-
unisat: /* @__PURE__ */ (0,
|
|
3551
|
-
xverse: /* @__PURE__ */ (0,
|
|
3761
|
+
leather: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(LeatherIcon, { size: isDownMd ? 36 : 40 }),
|
|
3762
|
+
unisat: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(UnisatIcon, { size: isDownMd ? 36 : 40 }),
|
|
3763
|
+
xverse: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(XverseIcon, { size: isDownMd ? 36 : 40 })
|
|
3552
3764
|
};
|
|
3553
3765
|
const { events, login } = useMatch();
|
|
3554
|
-
const [status, setStatus] = (0,
|
|
3555
|
-
const statusRef =
|
|
3556
|
-
const [error, setError] = (0,
|
|
3557
|
-
const connected = (0,
|
|
3766
|
+
const [status, setStatus] = (0, import_react26.useState)("");
|
|
3767
|
+
const statusRef = import_react26.default.useRef(status);
|
|
3768
|
+
const [error, setError] = (0, import_react26.useState)("");
|
|
3769
|
+
const connected = (0, import_react26.useMemo)(() => {
|
|
3558
3770
|
return !!address;
|
|
3559
3771
|
}, [address]);
|
|
3560
3772
|
const disconnect = async () => {
|
|
@@ -3569,7 +3781,7 @@ function BTCModal({
|
|
|
3569
3781
|
try {
|
|
3570
3782
|
setStatus("nonce");
|
|
3571
3783
|
statusRef.current = "nonce";
|
|
3572
|
-
const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
|
|
3784
|
+
const res = type == "bind" ? await getWalletInitApi({ address, type: "BTC" }) : await getWalletNonceApi({ address, type: "BTC" });
|
|
3573
3785
|
if (!isSuccess(res)) {
|
|
3574
3786
|
throw new Error(res.message);
|
|
3575
3787
|
}
|
|
@@ -3618,7 +3830,7 @@ function BTCModal({
|
|
|
3618
3830
|
statusRef.current = "";
|
|
3619
3831
|
}
|
|
3620
3832
|
};
|
|
3621
|
-
(0,
|
|
3833
|
+
(0, import_react26.useEffect)(() => {
|
|
3622
3834
|
if (wallet) {
|
|
3623
3835
|
console.log("onConnect");
|
|
3624
3836
|
try {
|
|
@@ -3631,12 +3843,12 @@ function BTCModal({
|
|
|
3631
3843
|
setStatus("");
|
|
3632
3844
|
}
|
|
3633
3845
|
}, [wallet]);
|
|
3634
|
-
(0,
|
|
3846
|
+
(0, import_react26.useEffect)(() => {
|
|
3635
3847
|
if (address) {
|
|
3636
3848
|
toLoginInWallet();
|
|
3637
3849
|
}
|
|
3638
3850
|
}, [address]);
|
|
3639
|
-
(0,
|
|
3851
|
+
(0, import_react26.useEffect)(() => {
|
|
3640
3852
|
if (!props.isOpen) {
|
|
3641
3853
|
disconnect();
|
|
3642
3854
|
}
|
|
@@ -3648,11 +3860,11 @@ function BTCModal({
|
|
|
3648
3860
|
statusRef.current = "";
|
|
3649
3861
|
setError("");
|
|
3650
3862
|
};
|
|
3651
|
-
return /* @__PURE__ */ (0,
|
|
3863
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
|
|
3652
3864
|
id: type == "bind" ? "bindWith" : "loginWith"
|
|
3653
3865
|
}, {
|
|
3654
3866
|
name: "BTC"
|
|
3655
|
-
}), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ (0,
|
|
3867
|
+
}), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
3656
3868
|
WalletModalContent,
|
|
3657
3869
|
{
|
|
3658
3870
|
error,
|
|
@@ -3665,9 +3877,9 @@ function BTCModal({
|
|
|
3665
3877
|
setVisible: () => {
|
|
3666
3878
|
}
|
|
3667
3879
|
}
|
|
3668
|
-
) : /* @__PURE__ */ (0,
|
|
3880
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "matchid-login-box", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "matchid-login-recommend-list", children: [
|
|
3669
3881
|
installedWallets.map((wallet2) => {
|
|
3670
|
-
return /* @__PURE__ */ (0,
|
|
3882
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
3671
3883
|
RecommendItem,
|
|
3672
3884
|
{
|
|
3673
3885
|
icon: iconMaps[wallet2.walletKey],
|
|
@@ -3680,14 +3892,14 @@ function BTCModal({
|
|
|
3680
3892
|
);
|
|
3681
3893
|
}),
|
|
3682
3894
|
wallets2.filter((wallet2) => !installedWallets.find((installedWallet) => installedWallet.walletKey == wallet2.walletKey)).map((wallet2) => {
|
|
3683
|
-
return /* @__PURE__ */ (0,
|
|
3895
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
3684
3896
|
RecommendItem,
|
|
3685
3897
|
{
|
|
3686
3898
|
icon: iconMaps[wallet2.walletKey],
|
|
3687
3899
|
name: wallet2.name,
|
|
3688
3900
|
onClick: () => {
|
|
3689
3901
|
},
|
|
3690
|
-
footer: /* @__PURE__ */ (0,
|
|
3902
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Button, { size: "sm", onClick: () => {
|
|
3691
3903
|
window.open(wallet2.website);
|
|
3692
3904
|
}, children: "Install" })
|
|
3693
3905
|
},
|
|
@@ -3712,6 +3924,7 @@ function BTCModal({
|
|
|
3712
3924
|
PasswordModal,
|
|
3713
3925
|
Popover,
|
|
3714
3926
|
SOLModal,
|
|
3927
|
+
TONModal,
|
|
3715
3928
|
TRONModal,
|
|
3716
3929
|
UsernameModal
|
|
3717
3930
|
});
|