@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
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ __export(src_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(src_exports);
|
|
41
41
|
|
|
42
42
|
// src/MatchContext.tsx
|
|
43
|
-
var
|
|
43
|
+
var import_react26 = require("react");
|
|
44
44
|
|
|
45
45
|
// src/assets/icon/ArrowLeftIcon.tsx
|
|
46
46
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -1501,28 +1501,42 @@ var getAuthInfoApi = () => {
|
|
|
1501
1501
|
method: "GET"
|
|
1502
1502
|
});
|
|
1503
1503
|
};
|
|
1504
|
-
var getWalletNonceApi = (
|
|
1504
|
+
var getWalletNonceApi = (data) => {
|
|
1505
1505
|
return request_default({
|
|
1506
1506
|
url: `/api/v1/login/wallet/init`,
|
|
1507
1507
|
method: "POST",
|
|
1508
|
-
data
|
|
1508
|
+
data
|
|
1509
1509
|
});
|
|
1510
1510
|
};
|
|
1511
|
-
var loginByWalletApi = ({
|
|
1511
|
+
var loginByWalletApi = ({
|
|
1512
|
+
type,
|
|
1513
|
+
address,
|
|
1514
|
+
signature,
|
|
1515
|
+
message,
|
|
1516
|
+
connector_type,
|
|
1517
|
+
wallet_client_type
|
|
1518
|
+
}) => {
|
|
1512
1519
|
return request_default({
|
|
1513
1520
|
url: `/api/v1/login/wallet`,
|
|
1514
1521
|
method: "POST",
|
|
1515
1522
|
data: { type, address, signature, message, connector_type, wallet_client_type }
|
|
1516
1523
|
});
|
|
1517
1524
|
};
|
|
1518
|
-
var getWalletInitApi = (
|
|
1525
|
+
var getWalletInitApi = (data) => {
|
|
1519
1526
|
return request_default({
|
|
1520
1527
|
url: `/api/v1/wallet/init`,
|
|
1521
1528
|
method: "POST",
|
|
1522
|
-
data
|
|
1529
|
+
data
|
|
1523
1530
|
});
|
|
1524
1531
|
};
|
|
1525
|
-
var toBindWalletApi = ({
|
|
1532
|
+
var toBindWalletApi = ({
|
|
1533
|
+
type,
|
|
1534
|
+
address,
|
|
1535
|
+
signature,
|
|
1536
|
+
message,
|
|
1537
|
+
connector_type,
|
|
1538
|
+
wallet_client_type
|
|
1539
|
+
}) => {
|
|
1526
1540
|
return request_default({
|
|
1527
1541
|
url: `/api/v1/wallet/bind`,
|
|
1528
1542
|
method: "POST",
|
|
@@ -1597,6 +1611,12 @@ var useTRONModalStore = (0, import_zustand2.create)((set) => ({
|
|
|
1597
1611
|
open: (type) => set({ isOpen: true, type }),
|
|
1598
1612
|
close: () => set({ isOpen: false })
|
|
1599
1613
|
}));
|
|
1614
|
+
var useTONModalStore = (0, import_zustand2.create)((set) => ({
|
|
1615
|
+
isOpen: false,
|
|
1616
|
+
type: "",
|
|
1617
|
+
open: (type) => set({ isOpen: true, type }),
|
|
1618
|
+
close: () => set({ isOpen: false })
|
|
1619
|
+
}));
|
|
1600
1620
|
var useBTCModalStore = (0, import_zustand2.create)((set) => ({
|
|
1601
1621
|
isOpen: false,
|
|
1602
1622
|
type: "",
|
|
@@ -1626,6 +1646,7 @@ function useUserInfo() {
|
|
|
1626
1646
|
const { events, login } = useMatch();
|
|
1627
1647
|
const { open: SOLOpen } = useSOLModalStore();
|
|
1628
1648
|
const { open: TRONOpen } = useTRONModalStore();
|
|
1649
|
+
const { open: TONOpen } = useTONModalStore();
|
|
1629
1650
|
const { open: BTCOpen } = useBTCModalStore();
|
|
1630
1651
|
const { open: CEXBindOpen } = useCEXBindModalStore();
|
|
1631
1652
|
const isLogin = (0, import_react3.useMemo)(() => !!token, [token]);
|
|
@@ -1674,6 +1695,8 @@ function useUserInfo() {
|
|
|
1674
1695
|
return SOLOpen("login");
|
|
1675
1696
|
case "tron":
|
|
1676
1697
|
return TRONOpen("login");
|
|
1698
|
+
case "ton":
|
|
1699
|
+
return TONOpen("login");
|
|
1677
1700
|
case "btc":
|
|
1678
1701
|
return BTCOpen("login");
|
|
1679
1702
|
case "telegram":
|
|
@@ -1765,6 +1788,8 @@ function useUserInfo() {
|
|
|
1765
1788
|
return SOLOpen("bind");
|
|
1766
1789
|
case "tron":
|
|
1767
1790
|
return TRONOpen("bind");
|
|
1791
|
+
case "ton":
|
|
1792
|
+
return TONOpen("bind");
|
|
1768
1793
|
case "btc":
|
|
1769
1794
|
return BTCOpen("bind");
|
|
1770
1795
|
case "telegram":
|
|
@@ -2210,6 +2235,7 @@ __export(components_exports, {
|
|
|
2210
2235
|
PasswordModal: () => PasswordModal,
|
|
2211
2236
|
Popover: () => Popover,
|
|
2212
2237
|
SOLModal: () => SOLModal,
|
|
2238
|
+
TONModal: () => TONModal,
|
|
2213
2239
|
TRONModal: () => TRONModal,
|
|
2214
2240
|
UsernameModal: () => UsernameModal
|
|
2215
2241
|
});
|
|
@@ -2594,6 +2620,12 @@ function LoginBox({
|
|
|
2594
2620
|
activeIcon: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(TRXLightIcon, { size: isDownMd ? 36 : 40 }),
|
|
2595
2621
|
name: "TRON",
|
|
2596
2622
|
onClick: () => login("tron")
|
|
2623
|
+
},
|
|
2624
|
+
ton: {
|
|
2625
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(TRXDarkIcon, { size: isDownMd ? 36 : 40 }),
|
|
2626
|
+
activeIcon: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(TRXLightIcon, { size: isDownMd ? 36 : 40 }),
|
|
2627
|
+
name: "TON",
|
|
2628
|
+
onClick: () => login("ton")
|
|
2597
2629
|
}
|
|
2598
2630
|
};
|
|
2599
2631
|
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
|
|
@@ -3040,8 +3072,13 @@ function WalletModalContent({
|
|
|
3040
3072
|
text: error,
|
|
3041
3073
|
btnText: "Reconnect Wallet",
|
|
3042
3074
|
btnClick: async () => {
|
|
3075
|
+
console.log("click error");
|
|
3043
3076
|
setError("");
|
|
3044
|
-
|
|
3077
|
+
try {
|
|
3078
|
+
await disconnect();
|
|
3079
|
+
} catch (error2) {
|
|
3080
|
+
console.error(error2);
|
|
3081
|
+
}
|
|
3045
3082
|
setVisible(true);
|
|
3046
3083
|
},
|
|
3047
3084
|
statusImage: walletErrorImage,
|
|
@@ -3128,7 +3165,7 @@ function WalletContent({
|
|
|
3128
3165
|
try {
|
|
3129
3166
|
setStatus("nonce");
|
|
3130
3167
|
statusRef.current = "nonce";
|
|
3131
|
-
const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
|
|
3168
|
+
const res = type == "bind" ? await getWalletInitApi({ address, type: "SOL" }) : await getWalletNonceApi({ address, type: "SOL" });
|
|
3132
3169
|
if (!isSuccess(res)) {
|
|
3133
3170
|
throw new Error(res.message);
|
|
3134
3171
|
}
|
|
@@ -3395,7 +3432,7 @@ function TRONModal({
|
|
|
3395
3432
|
try {
|
|
3396
3433
|
setStatus("nonce");
|
|
3397
3434
|
statusRef.current = "nonce";
|
|
3398
|
-
const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
|
|
3435
|
+
const res = type == "bind" ? await getWalletInitApi({ address, type: "TRON" }) : await getWalletNonceApi({ address, type: "TRON" });
|
|
3399
3436
|
if (!isSuccess(res)) {
|
|
3400
3437
|
throw new Error(res.message);
|
|
3401
3438
|
}
|
|
@@ -3510,9 +3547,184 @@ function TRONModal({
|
|
|
3510
3547
|
] }) }) });
|
|
3511
3548
|
}
|
|
3512
3549
|
|
|
3513
|
-
// src/components/
|
|
3514
|
-
var
|
|
3550
|
+
// src/components/TONModal/index.tsx
|
|
3551
|
+
var import_react20 = __toESM(require("react"));
|
|
3515
3552
|
var import_react_intl13 = require("react-intl");
|
|
3553
|
+
var import_ui_react = require("@tonconnect/ui-react");
|
|
3554
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
3555
|
+
function WalletContent2({
|
|
3556
|
+
onSuccess,
|
|
3557
|
+
type
|
|
3558
|
+
}) {
|
|
3559
|
+
const { events, login } = useMatch();
|
|
3560
|
+
const [connected, setConnected] = (0, import_react20.useState)(false);
|
|
3561
|
+
const wallet = (0, import_ui_react.useTonWallet)();
|
|
3562
|
+
const userFriendlyAddress = (0, import_ui_react.useTonAddress)();
|
|
3563
|
+
const [tonConnectUI] = (0, import_ui_react.useTonConnectUI)();
|
|
3564
|
+
const { state, open, close } = (0, import_ui_react.useTonConnectModal)();
|
|
3565
|
+
const [status, setStatus] = (0, import_react20.useState)("");
|
|
3566
|
+
const statusRef = import_react20.default.useRef(status);
|
|
3567
|
+
const [error, setError] = (0, import_react20.useState)("");
|
|
3568
|
+
(0, import_react20.useEffect)(() => {
|
|
3569
|
+
const init = async () => {
|
|
3570
|
+
if (wallet) {
|
|
3571
|
+
await tonConnectUI.disconnect();
|
|
3572
|
+
}
|
|
3573
|
+
open();
|
|
3574
|
+
};
|
|
3575
|
+
init();
|
|
3576
|
+
tonConnectUI.onStatusChange((wallet2) => {
|
|
3577
|
+
matchlog_default.log("onStatusChange:", wallet2, wallet2?.connectItems?.tonProof, JSON.stringify(wallet2?.connectItems?.tonProof));
|
|
3578
|
+
if (wallet2?.connectItems?.tonProof && "proof" in wallet2.connectItems.tonProof) {
|
|
3579
|
+
matchlog_default.log(wallet2?.connectItems.tonProof.proof, wallet2?.account);
|
|
3580
|
+
const toLoginInWallet = async () => {
|
|
3581
|
+
if (statusRef.current || !wallet2) return;
|
|
3582
|
+
setStatus("signer");
|
|
3583
|
+
statusRef.current = "signer";
|
|
3584
|
+
try {
|
|
3585
|
+
const signature = {
|
|
3586
|
+
"address": wallet2?.account?.address,
|
|
3587
|
+
"network": wallet2?.account?.chain,
|
|
3588
|
+
"public_key": wallet2?.account?.publicKey,
|
|
3589
|
+
"proof": {
|
|
3590
|
+
//@ts-ignore
|
|
3591
|
+
...wallet2?.connectItems?.tonProof?.proof,
|
|
3592
|
+
"state_init": wallet2?.account?.walletStateInit
|
|
3593
|
+
}
|
|
3594
|
+
};
|
|
3595
|
+
let obj = {
|
|
3596
|
+
type: "TON",
|
|
3597
|
+
address: wallet2?.account?.publicKey,
|
|
3598
|
+
signature: JSON.stringify(signature),
|
|
3599
|
+
//@ts-ignore
|
|
3600
|
+
message: wallet2?.connectItems?.tonProof?.proof.payload,
|
|
3601
|
+
connector_type: "TON",
|
|
3602
|
+
wallet_client_type: wallet2?.name
|
|
3603
|
+
};
|
|
3604
|
+
console.log("signature", {
|
|
3605
|
+
signature,
|
|
3606
|
+
obj
|
|
3607
|
+
});
|
|
3608
|
+
const res1 = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
|
|
3609
|
+
if (res1) {
|
|
3610
|
+
if (!isSuccess(res1)) {
|
|
3611
|
+
throw new Error(res1.message);
|
|
3612
|
+
}
|
|
3613
|
+
matchlog_default.log(res1);
|
|
3614
|
+
setStatus("success");
|
|
3615
|
+
statusRef.current = "success";
|
|
3616
|
+
if (type == "bind") {
|
|
3617
|
+
events.onBind && events.onBind({
|
|
3618
|
+
type: "ton"
|
|
3619
|
+
});
|
|
3620
|
+
eventManager_default.emit("onBind", {
|
|
3621
|
+
type: "ton"
|
|
3622
|
+
});
|
|
3623
|
+
} else {
|
|
3624
|
+
await login({
|
|
3625
|
+
mid: res1.data.mid,
|
|
3626
|
+
token: `${res1.data.token_type} ${res1.data.access_token}`
|
|
3627
|
+
});
|
|
3628
|
+
}
|
|
3629
|
+
onSuccess && onSuccess();
|
|
3630
|
+
}
|
|
3631
|
+
} catch (error2) {
|
|
3632
|
+
setStatus("error");
|
|
3633
|
+
setError(error2.message);
|
|
3634
|
+
statusRef.current = "";
|
|
3635
|
+
}
|
|
3636
|
+
};
|
|
3637
|
+
toLoginInWallet();
|
|
3638
|
+
}
|
|
3639
|
+
});
|
|
3640
|
+
}, []);
|
|
3641
|
+
(0, import_react20.useEffect)(() => {
|
|
3642
|
+
if (wallet) {
|
|
3643
|
+
setConnected(true);
|
|
3644
|
+
console.log("Wallet connected:", wallet);
|
|
3645
|
+
} else {
|
|
3646
|
+
setConnected(false);
|
|
3647
|
+
open();
|
|
3648
|
+
statusRef.current = "";
|
|
3649
|
+
setStatus("");
|
|
3650
|
+
}
|
|
3651
|
+
}, [wallet]);
|
|
3652
|
+
(0, import_react20.useEffect)(() => {
|
|
3653
|
+
console.log({
|
|
3654
|
+
state,
|
|
3655
|
+
wallet
|
|
3656
|
+
});
|
|
3657
|
+
if (state.status == "opened") {
|
|
3658
|
+
const init = async () => {
|
|
3659
|
+
tonConnectUI.setConnectRequestParameters({ state: "loading" });
|
|
3660
|
+
const res = type == "bind" ? await getWalletInitApi({
|
|
3661
|
+
address: "tonconnect",
|
|
3662
|
+
type: "TON"
|
|
3663
|
+
}) : await getWalletNonceApi({ address: "tonconnect", type: "TON" });
|
|
3664
|
+
if (!isSuccess(res)) {
|
|
3665
|
+
tonConnectUI.setConnectRequestParameters(null);
|
|
3666
|
+
throw new Error(res.message);
|
|
3667
|
+
}
|
|
3668
|
+
tonConnectUI.setConnectRequestParameters({
|
|
3669
|
+
state: "ready",
|
|
3670
|
+
value: { tonProof: res.data.nonce }
|
|
3671
|
+
});
|
|
3672
|
+
};
|
|
3673
|
+
init();
|
|
3674
|
+
} else {
|
|
3675
|
+
if (!wallet) {
|
|
3676
|
+
setStatus("");
|
|
3677
|
+
statusRef.current = "";
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
}, [state]);
|
|
3681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
3682
|
+
WalletModalContent,
|
|
3683
|
+
{
|
|
3684
|
+
connected,
|
|
3685
|
+
disconnect: tonConnectUI.disconnect,
|
|
3686
|
+
address: userFriendlyAddress,
|
|
3687
|
+
visible: state.status == "opened",
|
|
3688
|
+
setVisible: (v) => {
|
|
3689
|
+
console.log("setVisible", v);
|
|
3690
|
+
if (v) {
|
|
3691
|
+
setStatus("");
|
|
3692
|
+
statusRef.current = "";
|
|
3693
|
+
open();
|
|
3694
|
+
} else {
|
|
3695
|
+
close();
|
|
3696
|
+
}
|
|
3697
|
+
},
|
|
3698
|
+
error,
|
|
3699
|
+
setError,
|
|
3700
|
+
status
|
|
3701
|
+
}
|
|
3702
|
+
);
|
|
3703
|
+
}
|
|
3704
|
+
function TONModal({
|
|
3705
|
+
type = "login",
|
|
3706
|
+
onSuccess,
|
|
3707
|
+
...props
|
|
3708
|
+
}) {
|
|
3709
|
+
const intl = (0, import_react_intl13.useIntl)();
|
|
3710
|
+
const { endpoints, appid } = useLocalStore_default();
|
|
3711
|
+
const manifestUrl = `${endpoints.back}api/v1/wallet/ton?appid=${appid}&url=` + encodeURIComponent(window.location.origin);
|
|
3712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
|
|
3713
|
+
id: type == "bind" ? "bindWith" : "loginWith"
|
|
3714
|
+
}, {
|
|
3715
|
+
name: "TON"
|
|
3716
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
3717
|
+
import_ui_react.TonConnectUIProvider,
|
|
3718
|
+
{
|
|
3719
|
+
manifestUrl,
|
|
3720
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(WalletContent2, { onSuccess, type })
|
|
3721
|
+
}
|
|
3722
|
+
) });
|
|
3723
|
+
}
|
|
3724
|
+
|
|
3725
|
+
// src/components/BTCModal/index.tsx
|
|
3726
|
+
var import_react22 = __toESM(require("react"));
|
|
3727
|
+
var import_react_intl14 = require("react-intl");
|
|
3516
3728
|
|
|
3517
3729
|
// src/lib/btc/UnisatAdapter.ts
|
|
3518
3730
|
var UnisatAdapter = class {
|
|
@@ -3660,12 +3872,12 @@ var LeatherAdapter = class {
|
|
|
3660
3872
|
};
|
|
3661
3873
|
|
|
3662
3874
|
// src/hooks/useBTCWallet.ts
|
|
3663
|
-
var
|
|
3875
|
+
var import_react21 = require("react");
|
|
3664
3876
|
var useBTCWallet = () => {
|
|
3665
3877
|
const wallets2 = [new UnisatAdapter(), new XverseAdapter(), new LeatherAdapter()];
|
|
3666
|
-
const [installedWallets, setInstalledWallets] = (0,
|
|
3667
|
-
const [address, setAddress] = (0,
|
|
3668
|
-
(0,
|
|
3878
|
+
const [installedWallets, setInstalledWallets] = (0, import_react21.useState)([]);
|
|
3879
|
+
const [address, setAddress] = (0, import_react21.useState)(null);
|
|
3880
|
+
(0, import_react21.useEffect)(() => {
|
|
3669
3881
|
const getInstalled = async () => {
|
|
3670
3882
|
const installed = await Promise.all(wallets2.map((wallet2) => wallet2.isInstalled().then((isInstalled) => ({
|
|
3671
3883
|
wallet: wallet2,
|
|
@@ -3675,11 +3887,11 @@ var useBTCWallet = () => {
|
|
|
3675
3887
|
};
|
|
3676
3888
|
getInstalled();
|
|
3677
3889
|
}, []);
|
|
3678
|
-
const [wallet, chooseWallet] = (0,
|
|
3890
|
+
const [wallet, chooseWallet] = (0, import_react21.useState)(null);
|
|
3679
3891
|
const onConnect = async () => {
|
|
3680
3892
|
setAddress(await wallet.connect());
|
|
3681
3893
|
};
|
|
3682
|
-
(0,
|
|
3894
|
+
(0, import_react21.useEffect)(() => {
|
|
3683
3895
|
if (!wallet) {
|
|
3684
3896
|
setAddress(null);
|
|
3685
3897
|
}
|
|
@@ -3695,25 +3907,25 @@ var useBTCWallet = () => {
|
|
|
3695
3907
|
};
|
|
3696
3908
|
|
|
3697
3909
|
// src/components/BTCModal/index.tsx
|
|
3698
|
-
var
|
|
3910
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
3699
3911
|
function BTCModal({
|
|
3700
3912
|
type = "login",
|
|
3701
3913
|
onSuccess,
|
|
3702
3914
|
...props
|
|
3703
3915
|
}) {
|
|
3704
3916
|
const isDownMd = useDownMd();
|
|
3705
|
-
const intl = (0,
|
|
3917
|
+
const intl = (0, import_react_intl14.useIntl)();
|
|
3706
3918
|
const { wallets: wallets2, installedWallets, chooseWallet, wallet, address, onConnect } = useBTCWallet();
|
|
3707
3919
|
const iconMaps = {
|
|
3708
|
-
leather: /* @__PURE__ */ (0,
|
|
3709
|
-
unisat: /* @__PURE__ */ (0,
|
|
3710
|
-
xverse: /* @__PURE__ */ (0,
|
|
3920
|
+
leather: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(LeatherIcon, { size: isDownMd ? 36 : 40 }),
|
|
3921
|
+
unisat: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(UnisatIcon, { size: isDownMd ? 36 : 40 }),
|
|
3922
|
+
xverse: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(XverseIcon, { size: isDownMd ? 36 : 40 })
|
|
3711
3923
|
};
|
|
3712
3924
|
const { events, login } = useMatch();
|
|
3713
|
-
const [status, setStatus] = (0,
|
|
3714
|
-
const statusRef =
|
|
3715
|
-
const [error, setError] = (0,
|
|
3716
|
-
const connected = (0,
|
|
3925
|
+
const [status, setStatus] = (0, import_react22.useState)("");
|
|
3926
|
+
const statusRef = import_react22.default.useRef(status);
|
|
3927
|
+
const [error, setError] = (0, import_react22.useState)("");
|
|
3928
|
+
const connected = (0, import_react22.useMemo)(() => {
|
|
3717
3929
|
return !!address;
|
|
3718
3930
|
}, [address]);
|
|
3719
3931
|
const disconnect = async () => {
|
|
@@ -3728,7 +3940,7 @@ function BTCModal({
|
|
|
3728
3940
|
try {
|
|
3729
3941
|
setStatus("nonce");
|
|
3730
3942
|
statusRef.current = "nonce";
|
|
3731
|
-
const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
|
|
3943
|
+
const res = type == "bind" ? await getWalletInitApi({ address, type: "BTC" }) : await getWalletNonceApi({ address, type: "BTC" });
|
|
3732
3944
|
if (!isSuccess(res)) {
|
|
3733
3945
|
throw new Error(res.message);
|
|
3734
3946
|
}
|
|
@@ -3777,7 +3989,7 @@ function BTCModal({
|
|
|
3777
3989
|
statusRef.current = "";
|
|
3778
3990
|
}
|
|
3779
3991
|
};
|
|
3780
|
-
(0,
|
|
3992
|
+
(0, import_react22.useEffect)(() => {
|
|
3781
3993
|
if (wallet) {
|
|
3782
3994
|
console.log("onConnect");
|
|
3783
3995
|
try {
|
|
@@ -3790,12 +4002,12 @@ function BTCModal({
|
|
|
3790
4002
|
setStatus("");
|
|
3791
4003
|
}
|
|
3792
4004
|
}, [wallet]);
|
|
3793
|
-
(0,
|
|
4005
|
+
(0, import_react22.useEffect)(() => {
|
|
3794
4006
|
if (address) {
|
|
3795
4007
|
toLoginInWallet();
|
|
3796
4008
|
}
|
|
3797
4009
|
}, [address]);
|
|
3798
|
-
(0,
|
|
4010
|
+
(0, import_react22.useEffect)(() => {
|
|
3799
4011
|
if (!props.isOpen) {
|
|
3800
4012
|
disconnect();
|
|
3801
4013
|
}
|
|
@@ -3807,11 +4019,11 @@ function BTCModal({
|
|
|
3807
4019
|
statusRef.current = "";
|
|
3808
4020
|
setError("");
|
|
3809
4021
|
};
|
|
3810
|
-
return /* @__PURE__ */ (0,
|
|
4022
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
|
|
3811
4023
|
id: type == "bind" ? "bindWith" : "loginWith"
|
|
3812
4024
|
}, {
|
|
3813
4025
|
name: "BTC"
|
|
3814
|
-
}), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ (0,
|
|
4026
|
+
}), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
3815
4027
|
WalletModalContent,
|
|
3816
4028
|
{
|
|
3817
4029
|
error,
|
|
@@ -3824,9 +4036,9 @@ function BTCModal({
|
|
|
3824
4036
|
setVisible: () => {
|
|
3825
4037
|
}
|
|
3826
4038
|
}
|
|
3827
|
-
) : /* @__PURE__ */ (0,
|
|
4039
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "matchid-login-box", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "matchid-login-recommend-list", children: [
|
|
3828
4040
|
installedWallets.map((wallet2) => {
|
|
3829
|
-
return /* @__PURE__ */ (0,
|
|
4041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
3830
4042
|
RecommendItem,
|
|
3831
4043
|
{
|
|
3832
4044
|
icon: iconMaps[wallet2.walletKey],
|
|
@@ -3839,14 +4051,14 @@ function BTCModal({
|
|
|
3839
4051
|
);
|
|
3840
4052
|
}),
|
|
3841
4053
|
wallets2.filter((wallet2) => !installedWallets.find((installedWallet) => installedWallet.walletKey == wallet2.walletKey)).map((wallet2) => {
|
|
3842
|
-
return /* @__PURE__ */ (0,
|
|
4054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
3843
4055
|
RecommendItem,
|
|
3844
4056
|
{
|
|
3845
4057
|
icon: iconMaps[wallet2.walletKey],
|
|
3846
4058
|
name: wallet2.name,
|
|
3847
4059
|
onClick: () => {
|
|
3848
4060
|
},
|
|
3849
|
-
footer: /* @__PURE__ */ (0,
|
|
4061
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Button, { size: "sm", onClick: () => {
|
|
3850
4062
|
window.open(wallet2.website);
|
|
3851
4063
|
}, children: "Install" })
|
|
3852
4064
|
},
|
|
@@ -3857,27 +4069,27 @@ function BTCModal({
|
|
|
3857
4069
|
}
|
|
3858
4070
|
|
|
3859
4071
|
// src/components/CEXBindModal/index.tsx
|
|
3860
|
-
var
|
|
3861
|
-
var
|
|
3862
|
-
var
|
|
4072
|
+
var import_react23 = require("react");
|
|
4073
|
+
var import_react_intl15 = require("react-intl");
|
|
4074
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
3863
4075
|
function CEXBindModal({
|
|
3864
4076
|
onClose,
|
|
3865
4077
|
type,
|
|
3866
4078
|
isOpen = false,
|
|
3867
4079
|
...props
|
|
3868
4080
|
}) {
|
|
3869
|
-
const intl = (0,
|
|
4081
|
+
const intl = (0, import_react_intl15.useIntl)();
|
|
3870
4082
|
const { events } = useMatch();
|
|
3871
|
-
const [APIPassphrase, setAPIPassphrase] = (0,
|
|
4083
|
+
const [APIPassphrase, setAPIPassphrase] = (0, import_react23.useState)("");
|
|
3872
4084
|
const { refreshOverview } = useUserInfo();
|
|
3873
|
-
const [loading, setLoading] = (0,
|
|
3874
|
-
const [key, setKey] = (0,
|
|
3875
|
-
const [secret, setSecret] = (0,
|
|
3876
|
-
const [error, setError] = (0,
|
|
3877
|
-
const needPassphrase = (0,
|
|
4085
|
+
const [loading, setLoading] = (0, import_react23.useState)(false);
|
|
4086
|
+
const [key, setKey] = (0, import_react23.useState)("");
|
|
4087
|
+
const [secret, setSecret] = (0, import_react23.useState)("");
|
|
4088
|
+
const [error, setError] = (0, import_react23.useState)("");
|
|
4089
|
+
const needPassphrase = (0, import_react23.useMemo)(() => {
|
|
3878
4090
|
return ["bitget", "okx"].includes(type.toLowerCase());
|
|
3879
4091
|
}, [type]);
|
|
3880
|
-
(0,
|
|
4092
|
+
(0, import_react23.useEffect)(() => {
|
|
3881
4093
|
if (isOpen) {
|
|
3882
4094
|
setSecret("");
|
|
3883
4095
|
setKey("");
|
|
@@ -3914,20 +4126,20 @@ function CEXBindModal({
|
|
|
3914
4126
|
setLoading(false);
|
|
3915
4127
|
}
|
|
3916
4128
|
};
|
|
3917
|
-
return /* @__PURE__ */ (0,
|
|
4129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ModalWithHeader, { showClose: true, isOpen, onClose, title: intl.formatMessage({
|
|
3918
4130
|
id: "CEXBindTitle"
|
|
3919
4131
|
}, {
|
|
3920
4132
|
type
|
|
3921
|
-
}), ...props, children: /* @__PURE__ */ (0,
|
|
3922
|
-
/* @__PURE__ */ (0,
|
|
3923
|
-
/* @__PURE__ */ (0,
|
|
3924
|
-
/* @__PURE__ */ (0,
|
|
3925
|
-
/* @__PURE__ */ (0,
|
|
3926
|
-
/* @__PURE__ */ (0,
|
|
4133
|
+
}), ...props, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "matchid-cex-modal", children: [
|
|
4134
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { children: [
|
|
4135
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_react_intl15.FormattedMessage, { id: "CEXBindAttention" }) }),
|
|
4136
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_react_intl15.FormattedMessage, { id: "CEXBindTips1" }) }),
|
|
4137
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_react_intl15.FormattedMessage, { id: "CEXBindTips2" }) }),
|
|
4138
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_react_intl15.FormattedMessage, { id: "CEXBindTips3" }) })
|
|
3927
4139
|
] }),
|
|
3928
|
-
/* @__PURE__ */ (0,
|
|
4140
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Field, { label: intl.formatMessage({
|
|
3929
4141
|
id: "CEXBindApiKey"
|
|
3930
|
-
}), children: /* @__PURE__ */ (0,
|
|
4142
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
3931
4143
|
Input,
|
|
3932
4144
|
{
|
|
3933
4145
|
value: key,
|
|
@@ -3935,9 +4147,9 @@ function CEXBindModal({
|
|
|
3935
4147
|
placeholder: "**** **** ****"
|
|
3936
4148
|
}
|
|
3937
4149
|
) }),
|
|
3938
|
-
/* @__PURE__ */ (0,
|
|
4150
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Field, { label: intl.formatMessage({
|
|
3939
4151
|
id: "CEXBindApiSecretKey"
|
|
3940
|
-
}), error: !needPassphrase && error, children: /* @__PURE__ */ (0,
|
|
4152
|
+
}), error: !needPassphrase && error, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
3941
4153
|
Input,
|
|
3942
4154
|
{
|
|
3943
4155
|
value: secret,
|
|
@@ -3945,9 +4157,9 @@ function CEXBindModal({
|
|
|
3945
4157
|
placeholder: "**** **** ****"
|
|
3946
4158
|
}
|
|
3947
4159
|
) }),
|
|
3948
|
-
needPassphrase && /* @__PURE__ */ (0,
|
|
4160
|
+
needPassphrase && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Field, { error, label: intl.formatMessage({
|
|
3949
4161
|
id: "CEXBindApiPassphrase"
|
|
3950
|
-
}), children: /* @__PURE__ */ (0,
|
|
4162
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
3951
4163
|
Input,
|
|
3952
4164
|
{
|
|
3953
4165
|
value: APIPassphrase,
|
|
@@ -3955,7 +4167,7 @@ function CEXBindModal({
|
|
|
3955
4167
|
placeholder: "**** **** ****"
|
|
3956
4168
|
}
|
|
3957
4169
|
) }),
|
|
3958
|
-
/* @__PURE__ */ (0,
|
|
4170
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
3959
4171
|
Button,
|
|
3960
4172
|
{
|
|
3961
4173
|
onClick: SubmitApi,
|
|
@@ -3963,24 +4175,25 @@ function CEXBindModal({
|
|
|
3963
4175
|
block: true,
|
|
3964
4176
|
loading,
|
|
3965
4177
|
disabled: !key || !secret,
|
|
3966
|
-
children: /* @__PURE__ */ (0,
|
|
4178
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_react_intl15.FormattedMessage, { id: "continue" })
|
|
3967
4179
|
}
|
|
3968
4180
|
)
|
|
3969
4181
|
] }) });
|
|
3970
4182
|
}
|
|
3971
4183
|
|
|
3972
4184
|
// src/context/BusinessProvider.tsx
|
|
3973
|
-
var
|
|
4185
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
3974
4186
|
function BusinessProvider({ children }) {
|
|
3975
4187
|
const { overview, token } = useUserInfo();
|
|
3976
4188
|
const { recoveryModal } = useStore_default();
|
|
3977
4189
|
const { type: SOLType, isOpen: SOLIsOpen, close: SOLClose } = useSOLModalStore();
|
|
4190
|
+
const { type: TONType, isOpen: TONIsOpen, close: TONClose } = useTONModalStore();
|
|
3978
4191
|
const { type: TRONType, isOpen: TRONIsOpen, close: TRONClose } = useTRONModalStore();
|
|
3979
4192
|
const { type: BTCType, isOpen: BTCIsOpen, close: BTCClose } = useBTCModalStore();
|
|
3980
4193
|
const { type: CEXType, isOpen: CEXIsOpen, close: CEXClose } = useCEXBindModalStore();
|
|
3981
|
-
return /* @__PURE__ */ (0,
|
|
3982
|
-
/* @__PURE__ */ (0,
|
|
3983
|
-
/* @__PURE__ */ (0,
|
|
4194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
|
|
4195
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(PasswordModal, { isOpen: !!token && !!overview && !overview.address && !!overview.did, showClose: false }),
|
|
4196
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
3984
4197
|
RecoveryModal,
|
|
3985
4198
|
{
|
|
3986
4199
|
isOpen: !!token && !!overview && !!overview.address && recoveryModal.open,
|
|
@@ -3988,7 +4201,7 @@ function BusinessProvider({ children }) {
|
|
|
3988
4201
|
onSuccess: recoveryModal.success
|
|
3989
4202
|
}
|
|
3990
4203
|
),
|
|
3991
|
-
/* @__PURE__ */ (0,
|
|
4204
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
3992
4205
|
SOLModal,
|
|
3993
4206
|
{
|
|
3994
4207
|
isOpen: SOLIsOpen && (SOLType == "login" && !overview && !token || SOLType == "bind" && !!token && !!overview),
|
|
@@ -3998,7 +4211,7 @@ function BusinessProvider({ children }) {
|
|
|
3998
4211
|
zIndex: 199
|
|
3999
4212
|
}
|
|
4000
4213
|
),
|
|
4001
|
-
/* @__PURE__ */ (0,
|
|
4214
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
4002
4215
|
TRONModal,
|
|
4003
4216
|
{
|
|
4004
4217
|
isOpen: TRONIsOpen && (TRONType == "login" && !overview && !token || TRONType == "bind" && !!token && !!overview),
|
|
@@ -4008,7 +4221,17 @@ function BusinessProvider({ children }) {
|
|
|
4008
4221
|
zIndex: 199
|
|
4009
4222
|
}
|
|
4010
4223
|
),
|
|
4011
|
-
/* @__PURE__ */ (0,
|
|
4224
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
4225
|
+
TONModal,
|
|
4226
|
+
{
|
|
4227
|
+
isOpen: TONIsOpen && (TONType == "login" && !overview && !token || TONType == "bind" && !!token && !!overview),
|
|
4228
|
+
onClose: TONClose,
|
|
4229
|
+
type: TONType,
|
|
4230
|
+
onSuccess: TONClose,
|
|
4231
|
+
zIndex: 199
|
|
4232
|
+
}
|
|
4233
|
+
),
|
|
4234
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
4012
4235
|
BTCModal,
|
|
4013
4236
|
{
|
|
4014
4237
|
isOpen: BTCIsOpen && (BTCType == "login" && !overview && !token || BTCType == "bind" && !!token && !!overview),
|
|
@@ -4018,7 +4241,7 @@ function BusinessProvider({ children }) {
|
|
|
4018
4241
|
zIndex: 199
|
|
4019
4242
|
}
|
|
4020
4243
|
),
|
|
4021
|
-
/* @__PURE__ */ (0,
|
|
4244
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
4022
4245
|
CEXBindModal,
|
|
4023
4246
|
{
|
|
4024
4247
|
isOpen: CEXIsOpen && (!!token && !!overview),
|
|
@@ -4032,17 +4255,17 @@ function BusinessProvider({ children }) {
|
|
|
4032
4255
|
}
|
|
4033
4256
|
|
|
4034
4257
|
// src/context/index.tsx
|
|
4035
|
-
var
|
|
4258
|
+
var import_jsx_runtime67 = (
|
|
4036
4259
|
// <MpcWalletProvider>
|
|
4037
4260
|
require("react/jsx-runtime")
|
|
4038
4261
|
);
|
|
4039
4262
|
var Providers = ({ children }) => {
|
|
4040
|
-
return /* @__PURE__ */ (0,
|
|
4263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(BusinessProvider, { children });
|
|
4041
4264
|
};
|
|
4042
4265
|
var context_default = Providers;
|
|
4043
4266
|
|
|
4044
4267
|
// src/hooks/useWalletInit.ts
|
|
4045
|
-
var
|
|
4268
|
+
var import_react24 = require("react");
|
|
4046
4269
|
var AppClientId2 = getAppClientId();
|
|
4047
4270
|
function useWalletInit({
|
|
4048
4271
|
refreshOverview
|
|
@@ -4051,17 +4274,17 @@ function useWalletInit({
|
|
|
4051
4274
|
const getWalletIframe = () => {
|
|
4052
4275
|
return document.getElementById("match-wallet");
|
|
4053
4276
|
};
|
|
4054
|
-
const [walletInited, setWalletInited] = (0,
|
|
4277
|
+
const [walletInited, setWalletInited] = (0, import_react24.useState)(false);
|
|
4055
4278
|
const { appid, token, overview } = useLocalStore_default();
|
|
4056
4279
|
const { initWallet, generateWallet } = useWallet();
|
|
4057
|
-
const [iframeLoaded, setIframeLoaded] = (0,
|
|
4058
|
-
(0,
|
|
4280
|
+
const [iframeLoaded, setIframeLoaded] = (0, import_react24.useState)(false);
|
|
4281
|
+
(0, import_react24.useEffect)(() => {
|
|
4059
4282
|
console.log("wallet status", {
|
|
4060
4283
|
iframeLoaded,
|
|
4061
4284
|
walletInited
|
|
4062
4285
|
});
|
|
4063
4286
|
}, [iframeLoaded, walletInited]);
|
|
4064
|
-
(0,
|
|
4287
|
+
(0, import_react24.useEffect)(() => {
|
|
4065
4288
|
if (endpoints.auth) {
|
|
4066
4289
|
if (!window.matchWalletMessageIdMap) {
|
|
4067
4290
|
window.matchWalletMessageIdMap = {};
|
|
@@ -4135,7 +4358,7 @@ function useWalletInit({
|
|
|
4135
4358
|
}
|
|
4136
4359
|
}
|
|
4137
4360
|
}, [endpoints.auth]);
|
|
4138
|
-
(0,
|
|
4361
|
+
(0, import_react24.useEffect)(() => {
|
|
4139
4362
|
const messageHandle = async (e) => {
|
|
4140
4363
|
if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
|
|
4141
4364
|
return;
|
|
@@ -4168,7 +4391,7 @@ function useWalletInit({
|
|
|
4168
4391
|
window.removeEventListener("message", messageHandle);
|
|
4169
4392
|
};
|
|
4170
4393
|
}, []);
|
|
4171
|
-
(0,
|
|
4394
|
+
(0, import_react24.useEffect)(() => {
|
|
4172
4395
|
if (token && overview && overview.did && walletInited) {
|
|
4173
4396
|
const did = overview.did.split(":")[2];
|
|
4174
4397
|
const newUserInit = async () => {
|
|
@@ -4199,7 +4422,7 @@ function useWalletInit({
|
|
|
4199
4422
|
}
|
|
4200
4423
|
|
|
4201
4424
|
// src/hooks/useInit.tsx
|
|
4202
|
-
var
|
|
4425
|
+
var import_react25 = require("react");
|
|
4203
4426
|
function useInit({
|
|
4204
4427
|
theme,
|
|
4205
4428
|
appid,
|
|
@@ -4218,23 +4441,23 @@ function useInit({
|
|
|
4218
4441
|
setLocale,
|
|
4219
4442
|
locale: realLocale
|
|
4220
4443
|
} = useLocalStore_default();
|
|
4221
|
-
const overviewLoadingRef = (0,
|
|
4444
|
+
const overviewLoadingRef = (0, import_react25.useRef)(false);
|
|
4222
4445
|
const searchParams = new URLSearchParams(window.location.search);
|
|
4223
4446
|
const matchToken = searchParams.get("matchToken");
|
|
4224
4447
|
const realEndpoints = endpoints || env_default.endpoints;
|
|
4225
|
-
(0,
|
|
4448
|
+
(0, import_react25.useEffect)(() => {
|
|
4226
4449
|
setTheme(theme);
|
|
4227
4450
|
}, [theme]);
|
|
4228
|
-
(0,
|
|
4451
|
+
(0, import_react25.useEffect)(() => {
|
|
4229
4452
|
setAppid(appid);
|
|
4230
4453
|
}, [appid]);
|
|
4231
|
-
(0,
|
|
4454
|
+
(0, import_react25.useEffect)(() => {
|
|
4232
4455
|
setEndpoints(realEndpoints);
|
|
4233
4456
|
}, [realEndpoints]);
|
|
4234
|
-
(0,
|
|
4457
|
+
(0, import_react25.useEffect)(() => {
|
|
4235
4458
|
setLocale(locale || "en");
|
|
4236
4459
|
}, [locale]);
|
|
4237
|
-
(0,
|
|
4460
|
+
(0, import_react25.useEffect)(() => {
|
|
4238
4461
|
if (matchToken) {
|
|
4239
4462
|
const tokenData = JSON.parse(atob(matchToken));
|
|
4240
4463
|
if (tokenData && tokenData.mid && tokenData.token) {
|
|
@@ -4245,7 +4468,7 @@ function useInit({
|
|
|
4245
4468
|
}
|
|
4246
4469
|
}
|
|
4247
4470
|
}, [matchToken]);
|
|
4248
|
-
(0,
|
|
4471
|
+
(0, import_react25.useEffect)(() => {
|
|
4249
4472
|
const onLoginMessage = (event) => {
|
|
4250
4473
|
const res = event.data;
|
|
4251
4474
|
if (res.event === "login" && res.data && (res.data.token || res.data.token_type && res.data.access_token)) {
|
|
@@ -4281,7 +4504,7 @@ function useInit({
|
|
|
4281
4504
|
overviewLoadingRef.current = false;
|
|
4282
4505
|
}
|
|
4283
4506
|
};
|
|
4284
|
-
(0,
|
|
4507
|
+
(0, import_react25.useEffect)(() => {
|
|
4285
4508
|
if (token) {
|
|
4286
4509
|
loadOverview();
|
|
4287
4510
|
}
|
|
@@ -4313,7 +4536,7 @@ function useInit({
|
|
|
4313
4536
|
|
|
4314
4537
|
// src/MatchContext.tsx
|
|
4315
4538
|
var import_react_query = require("@tanstack/react-query");
|
|
4316
|
-
var
|
|
4539
|
+
var import_react_intl16 = require("react-intl");
|
|
4317
4540
|
|
|
4318
4541
|
// src/i18n/en.json
|
|
4319
4542
|
var en_default = {
|
|
@@ -4788,9 +5011,9 @@ var messages = {
|
|
|
4788
5011
|
};
|
|
4789
5012
|
|
|
4790
5013
|
// src/MatchContext.tsx
|
|
4791
|
-
var
|
|
5014
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
4792
5015
|
var queryClient = new import_react_query.QueryClient();
|
|
4793
|
-
var MatchContext = (0,
|
|
5016
|
+
var MatchContext = (0, import_react26.createContext)(void 0);
|
|
4794
5017
|
var MatchProvider = ({ children, appid, events, theme = "light", endpoints, locale }) => {
|
|
4795
5018
|
const { loadOverview, login, endpoints: realEndPoints, locale: realLocale } = useInit({
|
|
4796
5019
|
theme,
|
|
@@ -4809,7 +5032,7 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints, loca
|
|
|
4809
5032
|
useWalletInit({
|
|
4810
5033
|
refreshOverview: loadOverview
|
|
4811
5034
|
});
|
|
4812
|
-
return /* @__PURE__ */ (0,
|
|
5035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_react_intl16.IntlProvider, { locale: realLocale, messages: messages[realLocale], children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
4813
5036
|
MatchContext.Provider,
|
|
4814
5037
|
{
|
|
4815
5038
|
value: {
|
|
@@ -4820,12 +5043,12 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints, loca
|
|
|
4820
5043
|
theme,
|
|
4821
5044
|
locale: realLocale
|
|
4822
5045
|
},
|
|
4823
|
-
children: /* @__PURE__ */ (0,
|
|
5046
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(context_default, { children })
|
|
4824
5047
|
}
|
|
4825
5048
|
) }) });
|
|
4826
5049
|
};
|
|
4827
5050
|
var useMatch = () => {
|
|
4828
|
-
const context = (0,
|
|
5051
|
+
const context = (0, import_react26.useContext)(MatchContext);
|
|
4829
5052
|
if (context === void 0) {
|
|
4830
5053
|
throw new Error("useMatch must be used within a MatchProvider");
|
|
4831
5054
|
}
|