@matchain/matchid-sdk-react 0.1.11 → 0.1.13
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/index.d.mts +127 -32
- package/dist/index.d.ts +127 -32
- package/dist/index.js +217 -144
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +216 -144
- package/dist/index.mjs.map +1 -1
- package/example/package.json +1 -0
- package/example/src/App.tsx +23 -15
- package/example/src/components/Login/index.tsx +73 -0
- package/example/src/components/RoutePrivate/index.tsx +9 -0
- package/example/src/pages/{Login.tsx → User.tsx} +19 -85
- package/example/src/pages/Wallet.tsx +130 -0
- package/example/tsconfig.json +5 -1
- package/example/vite.config.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
Api: () => api_exports,
|
|
34
|
+
Chains: () => chains_exports,
|
|
34
35
|
Components: () => components_exports,
|
|
35
36
|
Hooks: () => hooks_exports,
|
|
36
37
|
MatchProvider: () => MatchProvider,
|
|
@@ -520,7 +521,6 @@ var persistedState = (0, import_middleware.persist)(
|
|
|
520
521
|
appid: "",
|
|
521
522
|
token: "",
|
|
522
523
|
did: "",
|
|
523
|
-
env: "main",
|
|
524
524
|
mid: "",
|
|
525
525
|
overview: null,
|
|
526
526
|
theme: "light",
|
|
@@ -530,13 +530,17 @@ var persistedState = (0, import_middleware.persist)(
|
|
|
530
530
|
did: overview.did,
|
|
531
531
|
mid: overview.mid
|
|
532
532
|
}),
|
|
533
|
-
|
|
533
|
+
endpoints: {
|
|
534
|
+
back: "https://api.matchid.ai/",
|
|
535
|
+
auth: "https://auth.matchid.ai/"
|
|
536
|
+
},
|
|
534
537
|
setDid: (did) => set({ did }),
|
|
535
538
|
setToken: (token) => set({ token }),
|
|
536
539
|
setAppid: (appid) => set({ appid }),
|
|
537
540
|
setMid: (mid) => set({ mid }),
|
|
538
541
|
logout: () => set({ token: "", did: "", mid: "", address: "", overview: null }),
|
|
539
542
|
setTheme: (theme) => set({ theme }),
|
|
543
|
+
setEndpoints: (endpoints) => set({ endpoints }),
|
|
540
544
|
address: "",
|
|
541
545
|
setAddress: (address) => set({ address })
|
|
542
546
|
}),
|
|
@@ -552,57 +556,28 @@ var import_react2 = require("react");
|
|
|
552
556
|
// src/api/request.ts
|
|
553
557
|
var import_axios = __toESM(require("axios"));
|
|
554
558
|
|
|
555
|
-
// src/config/env/main.ts
|
|
556
|
-
var main_default = {
|
|
557
|
-
endpoints: {
|
|
558
|
-
back: "https://api.matchid.ai/api/v1/",
|
|
559
|
-
login: "https://auth.matchid.ai/"
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
|
|
563
|
-
// src/config/env/dev.ts
|
|
564
|
-
var dev_default = {
|
|
565
|
-
endpoints: {
|
|
566
|
-
back: "https://mid-test-api.matchain.io/mid/api/v1/",
|
|
567
|
-
login: "https://calm-hare-roughly.ngrok-free.app/"
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
// src/config/env/test.ts
|
|
572
|
-
var test_default = {
|
|
573
|
-
endpoints: {
|
|
574
|
-
back: "https://mid-test-api.matchain.io/mid/api/v1/",
|
|
575
|
-
login: "https://mid-sso-test.vercel.app/"
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
|
|
579
559
|
// src/config/env/index.ts
|
|
580
560
|
var env_default = {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
561
|
+
endpoints: {
|
|
562
|
+
back: "https://api.matchid.ai/",
|
|
563
|
+
auth: "https://auth.matchid.ai/"
|
|
564
|
+
}
|
|
584
565
|
};
|
|
585
566
|
|
|
586
567
|
// src/store/index.ts
|
|
587
|
-
var
|
|
568
|
+
var getEndpoints = () => {
|
|
588
569
|
try {
|
|
589
570
|
const store = localStore.getState();
|
|
590
|
-
const env = store?.
|
|
571
|
+
const env = store?.endpoints;
|
|
591
572
|
if (env) {
|
|
592
573
|
return env;
|
|
593
574
|
} else {
|
|
594
|
-
return
|
|
575
|
+
return env_default.endpoints;
|
|
595
576
|
}
|
|
596
577
|
} catch (e) {
|
|
597
|
-
return
|
|
578
|
+
return env_default.endpoints;
|
|
598
579
|
}
|
|
599
580
|
};
|
|
600
|
-
var getEnvConfig = () => {
|
|
601
|
-
return env_default[getEnv()];
|
|
602
|
-
};
|
|
603
|
-
var getEndpoints = () => {
|
|
604
|
-
return getEnvConfig().endpoints;
|
|
605
|
-
};
|
|
606
581
|
var getAppid = () => {
|
|
607
582
|
try {
|
|
608
583
|
const store = localStore.getState();
|
|
@@ -690,72 +665,72 @@ var request_default = request;
|
|
|
690
665
|
// src/api/index.ts
|
|
691
666
|
var getEmailCodeApi = (email) => {
|
|
692
667
|
return request_default({
|
|
693
|
-
url: `/email/code`,
|
|
668
|
+
url: `/api/v1/email/code`,
|
|
694
669
|
method: "POST",
|
|
695
670
|
data: { email }
|
|
696
671
|
});
|
|
697
672
|
};
|
|
698
673
|
var verifyEmailCodeApi = ({ email, verification_key, verification_code }) => {
|
|
699
674
|
return request_default({
|
|
700
|
-
url: `/user/email/login`,
|
|
675
|
+
url: `/api/v1/user/email/login`,
|
|
701
676
|
method: "POST",
|
|
702
677
|
data: { email, verification_key, verification_code }
|
|
703
678
|
});
|
|
704
679
|
};
|
|
705
680
|
var getOverviewInfoApi = () => {
|
|
706
681
|
return request_default({
|
|
707
|
-
url: `/user/overview`,
|
|
682
|
+
url: `/api/v1/user/overview`,
|
|
708
683
|
method: "GET"
|
|
709
684
|
});
|
|
710
685
|
};
|
|
711
686
|
var toLogoutApi = () => {
|
|
712
687
|
return request_default({
|
|
713
|
-
url: `/user/logout`,
|
|
688
|
+
url: `/api/v1/user/logout`,
|
|
714
689
|
method: "POST"
|
|
715
690
|
});
|
|
716
691
|
};
|
|
717
692
|
var setUserNameApi = (data) => {
|
|
718
693
|
return request_default({
|
|
719
|
-
url: `/user/name`,
|
|
694
|
+
url: `/api/v1/user/name`,
|
|
720
695
|
method: "POSt",
|
|
721
696
|
data
|
|
722
697
|
});
|
|
723
698
|
};
|
|
724
699
|
var getBindListApi = () => {
|
|
725
700
|
return request_default({
|
|
726
|
-
url: `/bind/list`,
|
|
701
|
+
url: `/api/v1/bind/list`,
|
|
727
702
|
method: "GET"
|
|
728
703
|
});
|
|
729
704
|
};
|
|
730
705
|
var getPohListApi = () => {
|
|
731
706
|
return request_default({
|
|
732
|
-
url: `/poh/list`,
|
|
707
|
+
url: `/api/v1/poh/list`,
|
|
733
708
|
method: "GET"
|
|
734
709
|
});
|
|
735
710
|
};
|
|
736
711
|
var getBindInfoApi = () => {
|
|
737
712
|
return request_default({
|
|
738
|
-
url: `/bind`,
|
|
713
|
+
url: `/api/v1/bind`,
|
|
739
714
|
method: "GET"
|
|
740
715
|
});
|
|
741
716
|
};
|
|
742
717
|
var bindCexApi = ({ cex, api_key, api_secret }) => {
|
|
743
718
|
return request_default({
|
|
744
|
-
url: `/cex/subscribe`,
|
|
719
|
+
url: `/api/v1/cex/subscribe`,
|
|
745
720
|
method: "POST",
|
|
746
721
|
data: { cex, api_key, api_secret }
|
|
747
722
|
});
|
|
748
723
|
};
|
|
749
724
|
var unBindApi = ({ type }) => {
|
|
750
725
|
return request_default({
|
|
751
|
-
url: `/unbind`,
|
|
726
|
+
url: `/api/v1/unbind`,
|
|
752
727
|
method: "POST",
|
|
753
728
|
data: { type }
|
|
754
729
|
});
|
|
755
730
|
};
|
|
756
731
|
var unBindWalletApi = ({ address }) => {
|
|
757
732
|
return request_default({
|
|
758
|
-
url: `/wallet/unbind`,
|
|
733
|
+
url: `/api/v1/wallet/unbind`,
|
|
759
734
|
method: "POST",
|
|
760
735
|
data: { address }
|
|
761
736
|
});
|
|
@@ -772,7 +747,7 @@ var verifyPohApi = ({
|
|
|
772
747
|
validatorSignature
|
|
773
748
|
}) => {
|
|
774
749
|
return request_default({
|
|
775
|
-
url: `/poh/zkpass`,
|
|
750
|
+
url: `/api/v1/poh/zkpass`,
|
|
776
751
|
method: "POST",
|
|
777
752
|
data: {
|
|
778
753
|
taskId,
|
|
@@ -787,6 +762,25 @@ var verifyPohApi = ({
|
|
|
787
762
|
}
|
|
788
763
|
});
|
|
789
764
|
};
|
|
765
|
+
var chooseIdentityApi = ({ identity }) => {
|
|
766
|
+
return request_default({
|
|
767
|
+
url: `/api/v1/user/choose/identity`,
|
|
768
|
+
method: "POST",
|
|
769
|
+
data: { identity }
|
|
770
|
+
});
|
|
771
|
+
};
|
|
772
|
+
var mintPassportNftApi = () => {
|
|
773
|
+
return request_default({
|
|
774
|
+
url: `/api/v1/mint/passport/nft`,
|
|
775
|
+
method: "POST"
|
|
776
|
+
});
|
|
777
|
+
};
|
|
778
|
+
var getAuthInfoApi = () => {
|
|
779
|
+
return request_default({
|
|
780
|
+
url: `/api/v1/user/auth`,
|
|
781
|
+
method: "GET"
|
|
782
|
+
});
|
|
783
|
+
};
|
|
790
784
|
|
|
791
785
|
// src/hooks/eventManager.ts
|
|
792
786
|
var EventManager = class {
|
|
@@ -845,16 +839,13 @@ function useUserInfo() {
|
|
|
845
839
|
token,
|
|
846
840
|
mid,
|
|
847
841
|
did,
|
|
848
|
-
env,
|
|
849
842
|
logout: logoutStore,
|
|
850
843
|
setOverview,
|
|
851
844
|
overview,
|
|
852
|
-
address
|
|
845
|
+
address,
|
|
846
|
+
endpoints
|
|
853
847
|
} = useLocalStore_default();
|
|
854
848
|
const { events, login } = useMatch();
|
|
855
|
-
const endpoints = (0, import_react2.useMemo)(() => {
|
|
856
|
-
return getEndpoints();
|
|
857
|
-
}, [env]);
|
|
858
849
|
const isLogin = (0, import_react2.useMemo)(() => !!token, [token]);
|
|
859
850
|
const logout = async () => {
|
|
860
851
|
try {
|
|
@@ -867,7 +858,7 @@ function useUserInfo() {
|
|
|
867
858
|
eventManager_default.emit("onLogout");
|
|
868
859
|
};
|
|
869
860
|
const loginByMethod = (method) => {
|
|
870
|
-
const link = `${endpoints.back}auth/${method}?appid=${appid}&provider=${method}&redirect=${encodeURIComponent(endpoints.
|
|
861
|
+
const link = `${endpoints.back}auth/${method}?appid=${appid}&provider=${method}&redirect=${encodeURIComponent(endpoints.auth + "login/" + method)}&authorization=${(/* @__PURE__ */ new Date()).getTime()}`;
|
|
871
862
|
matchlog_default.log("link", link);
|
|
872
863
|
const authWindow = window.open(
|
|
873
864
|
link,
|
|
@@ -918,7 +909,7 @@ function useUserInfo() {
|
|
|
918
909
|
};
|
|
919
910
|
const loginByWallet = () => {
|
|
920
911
|
const authWindow = window.open(
|
|
921
|
-
`${endpoints.
|
|
912
|
+
`${endpoints.auth}login/wallet?appid=${appid}`,
|
|
922
913
|
// Replace with the actual authorization URL
|
|
923
914
|
"_blank"
|
|
924
915
|
// 'width=800,height=600'
|
|
@@ -926,7 +917,7 @@ function useUserInfo() {
|
|
|
926
917
|
};
|
|
927
918
|
const loginByTelegram = () => {
|
|
928
919
|
const authWindow = window.open(
|
|
929
|
-
`${endpoints.
|
|
920
|
+
`${endpoints.auth}login/telegram?appid=${appid}`,
|
|
930
921
|
// Replace with the actual authorization URL
|
|
931
922
|
"authWindow",
|
|
932
923
|
"width=800,height=600"
|
|
@@ -943,7 +934,7 @@ function useUserInfo() {
|
|
|
943
934
|
throw new Error("You must login first");
|
|
944
935
|
}
|
|
945
936
|
const authWindow = window.open(
|
|
946
|
-
`${endpoints.
|
|
937
|
+
`${endpoints.auth}bind/wallet?appid=${appid}&st=` + encodeURIComponent(encodeBase64(token)),
|
|
947
938
|
// Replace with the actual authorization URL
|
|
948
939
|
"_blank"
|
|
949
940
|
);
|
|
@@ -953,12 +944,19 @@ function useUserInfo() {
|
|
|
953
944
|
throw new Error("You must login first");
|
|
954
945
|
}
|
|
955
946
|
const authWindow = window.open(
|
|
956
|
-
`${endpoints.
|
|
947
|
+
`${endpoints.auth}bind/telegram?appid=${appid}&st=` + encodeURIComponent(encodeBase64(token)),
|
|
957
948
|
// Replace with the actual authorization URL
|
|
958
949
|
"authWindow",
|
|
959
950
|
"width=800,height=600"
|
|
960
951
|
);
|
|
961
952
|
};
|
|
953
|
+
const auth = async () => {
|
|
954
|
+
const res = await getAuthInfoApi();
|
|
955
|
+
if (isSuccess(res)) {
|
|
956
|
+
return res.data;
|
|
957
|
+
}
|
|
958
|
+
throw new Error(res.message);
|
|
959
|
+
};
|
|
962
960
|
return {
|
|
963
961
|
loginByTelegram,
|
|
964
962
|
loginByTwitter,
|
|
@@ -976,7 +974,8 @@ function useUserInfo() {
|
|
|
976
974
|
overview,
|
|
977
975
|
bindWallet,
|
|
978
976
|
bindTelegram,
|
|
979
|
-
username: overview?.username || ""
|
|
977
|
+
username: overview?.username || "",
|
|
978
|
+
auth
|
|
980
979
|
};
|
|
981
980
|
}
|
|
982
981
|
|
|
@@ -1017,13 +1016,14 @@ var useStore = (0, import_zustand2.create)((set) => ({
|
|
|
1017
1016
|
var useStore_default = useStore;
|
|
1018
1017
|
|
|
1019
1018
|
// src/hooks/useWallet.tsx
|
|
1019
|
+
var import_accounts = require("viem/accounts");
|
|
1020
1020
|
var AppClientId = "react-sdk-" + getVersion();
|
|
1021
1021
|
function useWallet() {
|
|
1022
|
-
const { appid, token, overview } = useLocalStore_default();
|
|
1022
|
+
const { appid, token, overview, address } = useLocalStore_default();
|
|
1023
1023
|
const { setRecoveryModal, closeRecoveryModal } = useStore_default();
|
|
1024
1024
|
const initWallet = ({
|
|
1025
1025
|
did,
|
|
1026
|
-
address
|
|
1026
|
+
address: address2
|
|
1027
1027
|
}) => {
|
|
1028
1028
|
return window.waitMatchUntilWalletMessage(
|
|
1029
1029
|
"initCore",
|
|
@@ -1032,7 +1032,7 @@ function useWallet() {
|
|
|
1032
1032
|
AppClientId,
|
|
1033
1033
|
UserId: did,
|
|
1034
1034
|
AccessToken: token,
|
|
1035
|
-
Address:
|
|
1035
|
+
Address: address2
|
|
1036
1036
|
}
|
|
1037
1037
|
);
|
|
1038
1038
|
};
|
|
@@ -1045,33 +1045,21 @@ function useWallet() {
|
|
|
1045
1045
|
userPasscode
|
|
1046
1046
|
}) => {
|
|
1047
1047
|
return await window.waitMatchUntilWalletMessage("generateWallet", {
|
|
1048
|
+
chainType: "ethereum",
|
|
1048
1049
|
recoveryType: "user_passcode_recovery_key",
|
|
1049
1050
|
userPasscode
|
|
1050
1051
|
});
|
|
1051
1052
|
};
|
|
1052
|
-
const
|
|
1053
|
+
const recoverAfter = async (func) => {
|
|
1053
1054
|
return new Promise(async (resolve, reject) => {
|
|
1054
1055
|
const res = await isRecovered();
|
|
1055
1056
|
matchlog_default.log("isRecovered", res);
|
|
1056
|
-
const getSign = async () => {
|
|
1057
|
-
try {
|
|
1058
|
-
const recoverRes = await window.waitMatchUntilWalletMessage("signMessage", {
|
|
1059
|
-
message,
|
|
1060
|
-
chainType: type
|
|
1061
|
-
});
|
|
1062
|
-
closeRecoveryModal();
|
|
1063
|
-
resolve(recoverRes);
|
|
1064
|
-
} catch (error) {
|
|
1065
|
-
console.error("qwe-sign-error", error);
|
|
1066
|
-
reject(error);
|
|
1067
|
-
}
|
|
1068
|
-
};
|
|
1069
1057
|
if (!res) {
|
|
1070
1058
|
setRecoveryModal({
|
|
1071
1059
|
open: true,
|
|
1072
1060
|
success: async () => {
|
|
1073
1061
|
matchlog_default.log("recover Success");
|
|
1074
|
-
await
|
|
1062
|
+
await func(resolve, reject);
|
|
1075
1063
|
},
|
|
1076
1064
|
close: async () => {
|
|
1077
1065
|
closeRecoveryModal();
|
|
@@ -1084,48 +1072,41 @@ function useWallet() {
|
|
|
1084
1072
|
});
|
|
1085
1073
|
} else {
|
|
1086
1074
|
await recoveryWallet("ethereum", "user_passcode_recovery_key");
|
|
1087
|
-
await
|
|
1075
|
+
await func(resolve, reject);
|
|
1088
1076
|
}
|
|
1089
1077
|
});
|
|
1090
1078
|
};
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
const recoverRes = await window.waitMatchUntilWalletMessage("signTransaction", {
|
|
1098
|
-
transaction,
|
|
1099
|
-
chainType: type
|
|
1100
|
-
});
|
|
1101
|
-
closeRecoveryModal();
|
|
1102
|
-
resolve(recoverRes);
|
|
1103
|
-
} catch (error) {
|
|
1104
|
-
console.error("qwe-sign-error", error);
|
|
1105
|
-
reject(error);
|
|
1106
|
-
}
|
|
1107
|
-
};
|
|
1108
|
-
if (!res) {
|
|
1109
|
-
setRecoveryModal({
|
|
1110
|
-
open: true,
|
|
1111
|
-
success: async () => {
|
|
1112
|
-
matchlog_default.log("recover Success");
|
|
1113
|
-
await getSign();
|
|
1114
|
-
},
|
|
1115
|
-
close: async () => {
|
|
1116
|
-
closeRecoveryModal();
|
|
1117
|
-
reject(new Error("recover modal close"));
|
|
1118
|
-
}
|
|
1079
|
+
const signMessage = async (message, type) => {
|
|
1080
|
+
const getSign = async (resolve, reject) => {
|
|
1081
|
+
try {
|
|
1082
|
+
const recoverRes = await window.waitMatchUntilWalletMessage("signMessage", {
|
|
1083
|
+
message,
|
|
1084
|
+
chainType: type
|
|
1119
1085
|
});
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1086
|
+
closeRecoveryModal();
|
|
1087
|
+
resolve(recoverRes);
|
|
1088
|
+
} catch (error) {
|
|
1089
|
+
console.error("qwe-sign-error", error);
|
|
1090
|
+
reject(error);
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
return await recoverAfter(getSign);
|
|
1094
|
+
};
|
|
1095
|
+
const signTransaction = async (transaction, type) => {
|
|
1096
|
+
const getSign = async (resolve, reject) => {
|
|
1097
|
+
try {
|
|
1098
|
+
const recoverRes = await window.waitMatchUntilWalletMessage("signTransaction", {
|
|
1099
|
+
transaction,
|
|
1100
|
+
chainType: type
|
|
1123
1101
|
});
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1102
|
+
closeRecoveryModal();
|
|
1103
|
+
resolve(recoverRes);
|
|
1104
|
+
} catch (error) {
|
|
1105
|
+
console.error("qwe-sign-error", error);
|
|
1106
|
+
reject(error);
|
|
1127
1107
|
}
|
|
1128
|
-
}
|
|
1108
|
+
};
|
|
1109
|
+
return await recoverAfter(getSign);
|
|
1129
1110
|
};
|
|
1130
1111
|
const recoveryWallet = async (chainType, recoveryType, userPasscode) => {
|
|
1131
1112
|
return await window.waitMatchUntilWalletMessage("recoveryWallet", {
|
|
@@ -1134,13 +1115,32 @@ function useWallet() {
|
|
|
1134
1115
|
userPasscode
|
|
1135
1116
|
});
|
|
1136
1117
|
};
|
|
1118
|
+
const evmAccount = address ? (0, import_accounts.toAccount)({
|
|
1119
|
+
address,
|
|
1120
|
+
async signMessage({ message }) {
|
|
1121
|
+
return await signMessage(message);
|
|
1122
|
+
},
|
|
1123
|
+
async signTransaction(transaction, options) {
|
|
1124
|
+
const { account, ...restTransaction } = transaction;
|
|
1125
|
+
const sign = await signTransaction({
|
|
1126
|
+
...restTransaction
|
|
1127
|
+
});
|
|
1128
|
+
return sign;
|
|
1129
|
+
},
|
|
1130
|
+
async signTypedData(typedData) {
|
|
1131
|
+
return "0x";
|
|
1132
|
+
}
|
|
1133
|
+
}) : void 0;
|
|
1137
1134
|
return {
|
|
1135
|
+
evmAccount,
|
|
1136
|
+
address,
|
|
1138
1137
|
recoveryWallet,
|
|
1139
1138
|
initWallet,
|
|
1140
1139
|
generateWallet,
|
|
1141
1140
|
signMessage,
|
|
1142
1141
|
signTransaction,
|
|
1143
|
-
isRecovered
|
|
1142
|
+
isRecovered,
|
|
1143
|
+
recoverAfter
|
|
1144
1144
|
};
|
|
1145
1145
|
}
|
|
1146
1146
|
|
|
@@ -1336,7 +1336,7 @@ var AppClientId2 = "react-sdk-" + getVersion();
|
|
|
1336
1336
|
function useWalletInit({
|
|
1337
1337
|
refreshOverview
|
|
1338
1338
|
}) {
|
|
1339
|
-
const {
|
|
1339
|
+
const { endpoints } = useLocalStore_default();
|
|
1340
1340
|
const getWalletIframe = () => {
|
|
1341
1341
|
return document.getElementById("match-wallet");
|
|
1342
1342
|
};
|
|
@@ -1344,17 +1344,15 @@ function useWalletInit({
|
|
|
1344
1344
|
const { appid, token, overview } = useLocalStore_default();
|
|
1345
1345
|
const { initWallet, generateWallet } = useWallet();
|
|
1346
1346
|
(0, import_react6.useEffect)(() => {
|
|
1347
|
-
if (
|
|
1347
|
+
if (endpoints.auth) {
|
|
1348
1348
|
if (!window.matchWalletMessageIdMap) {
|
|
1349
1349
|
window.matchWalletMessageIdMap = {};
|
|
1350
1350
|
}
|
|
1351
|
-
const config = env_default[env];
|
|
1352
|
-
const endpoints = config.endpoints;
|
|
1353
1351
|
const existingIframe = getWalletIframe();
|
|
1354
1352
|
if (!existingIframe) {
|
|
1355
1353
|
const iframe = document.createElement("iframe");
|
|
1356
1354
|
iframe.id = "match-wallet";
|
|
1357
|
-
iframe.src = endpoints.
|
|
1355
|
+
iframe.src = endpoints.auth + "wallet";
|
|
1358
1356
|
iframe.style.display = "none";
|
|
1359
1357
|
iframe.style.width = "0";
|
|
1360
1358
|
iframe.style.height = "0";
|
|
@@ -1368,8 +1366,8 @@ function useWalletInit({
|
|
|
1368
1366
|
source: "matchid"
|
|
1369
1367
|
};
|
|
1370
1368
|
if (document.getElementById("match-wallet")) {
|
|
1371
|
-
matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.
|
|
1372
|
-
getWalletIframe()?.contentWindow?.postMessage(message, endpoints.
|
|
1369
|
+
matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.auth);
|
|
1370
|
+
getWalletIframe()?.contentWindow?.postMessage(message, endpoints.auth);
|
|
1373
1371
|
return messageId;
|
|
1374
1372
|
}
|
|
1375
1373
|
console.error("not found iframe");
|
|
@@ -1396,16 +1394,16 @@ function useWalletInit({
|
|
|
1396
1394
|
});
|
|
1397
1395
|
};
|
|
1398
1396
|
} else {
|
|
1399
|
-
if (existingIframe.src !== endpoints.
|
|
1397
|
+
if (existingIframe.src !== endpoints.auth + "wallet") {
|
|
1400
1398
|
setWalletInited(false);
|
|
1401
|
-
existingIframe.src = endpoints.
|
|
1399
|
+
existingIframe.src = endpoints.auth + "wallet";
|
|
1402
1400
|
}
|
|
1403
1401
|
}
|
|
1404
1402
|
}
|
|
1405
|
-
}, [
|
|
1403
|
+
}, [endpoints.auth]);
|
|
1406
1404
|
(0, import_react6.useEffect)(() => {
|
|
1407
1405
|
const messageHandle = async (e) => {
|
|
1408
|
-
if (e.origin !==
|
|
1406
|
+
if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
|
|
1409
1407
|
return;
|
|
1410
1408
|
}
|
|
1411
1409
|
const res = e.data;
|
|
@@ -1471,12 +1469,12 @@ var import_react7 = require("react");
|
|
|
1471
1469
|
function useInit({
|
|
1472
1470
|
theme,
|
|
1473
1471
|
appid,
|
|
1474
|
-
|
|
1475
|
-
|
|
1472
|
+
events,
|
|
1473
|
+
endpoints
|
|
1476
1474
|
}) {
|
|
1477
1475
|
const {
|
|
1478
1476
|
setAppid,
|
|
1479
|
-
|
|
1477
|
+
setEndpoints,
|
|
1480
1478
|
setToken,
|
|
1481
1479
|
setMid,
|
|
1482
1480
|
token,
|
|
@@ -1486,8 +1484,7 @@ function useInit({
|
|
|
1486
1484
|
const overviewLoadingRef = (0, import_react7.useRef)(false);
|
|
1487
1485
|
const searchParams = new URLSearchParams(window.location.search);
|
|
1488
1486
|
const matchToken = searchParams.get("matchToken");
|
|
1489
|
-
const
|
|
1490
|
-
const endpoints = config.endpoints;
|
|
1487
|
+
const realEndpoints = endpoints || env_default.endpoints;
|
|
1491
1488
|
(0, import_react7.useEffect)(() => {
|
|
1492
1489
|
setTheme(theme);
|
|
1493
1490
|
}, [theme]);
|
|
@@ -1495,8 +1492,8 @@ function useInit({
|
|
|
1495
1492
|
setAppid(appid);
|
|
1496
1493
|
}, [appid]);
|
|
1497
1494
|
(0, import_react7.useEffect)(() => {
|
|
1498
|
-
|
|
1499
|
-
}, [
|
|
1495
|
+
setEndpoints(realEndpoints);
|
|
1496
|
+
}, [realEndpoints]);
|
|
1500
1497
|
(0, import_react7.useEffect)(() => {
|
|
1501
1498
|
if (matchToken) {
|
|
1502
1499
|
const tokenData = JSON.parse(atob(matchToken));
|
|
@@ -1569,8 +1566,7 @@ function useInit({
|
|
|
1569
1566
|
return {
|
|
1570
1567
|
loadOverview,
|
|
1571
1568
|
login,
|
|
1572
|
-
|
|
1573
|
-
endpoints
|
|
1569
|
+
endpoints: realEndpoints
|
|
1574
1570
|
};
|
|
1575
1571
|
}
|
|
1576
1572
|
|
|
@@ -1579,12 +1575,12 @@ var import_react_query = require("@tanstack/react-query");
|
|
|
1579
1575
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1580
1576
|
var queryClient = new import_react_query.QueryClient();
|
|
1581
1577
|
var MatchContext = (0, import_react8.createContext)(void 0);
|
|
1582
|
-
var MatchProvider = ({ children, appid,
|
|
1583
|
-
const { loadOverview, login,
|
|
1578
|
+
var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) => {
|
|
1579
|
+
const { loadOverview, login, endpoints: realEndPoints } = useInit({
|
|
1584
1580
|
theme,
|
|
1585
1581
|
appid,
|
|
1586
|
-
|
|
1587
|
-
|
|
1582
|
+
events,
|
|
1583
|
+
endpoints
|
|
1588
1584
|
});
|
|
1589
1585
|
useWalletInit({
|
|
1590
1586
|
refreshOverview: loadOverview
|
|
@@ -1594,8 +1590,7 @@ var MatchProvider = ({ children, appid, env = "main", events, theme = "light" })
|
|
|
1594
1590
|
{
|
|
1595
1591
|
value: {
|
|
1596
1592
|
appid,
|
|
1597
|
-
|
|
1598
|
-
endpoints,
|
|
1593
|
+
endpoints: realEndPoints,
|
|
1599
1594
|
events,
|
|
1600
1595
|
login,
|
|
1601
1596
|
theme
|
|
@@ -2078,7 +2073,8 @@ function UsernameModal({
|
|
|
2078
2073
|
var api_exports = {};
|
|
2079
2074
|
__export(api_exports, {
|
|
2080
2075
|
bind: () => bind_exports,
|
|
2081
|
-
poh: () => poh_exports
|
|
2076
|
+
poh: () => poh_exports,
|
|
2077
|
+
user: () => user_exports
|
|
2082
2078
|
});
|
|
2083
2079
|
|
|
2084
2080
|
// src/hooks/api/bind.ts
|
|
@@ -2135,9 +2131,86 @@ function usePohList(options) {
|
|
|
2135
2131
|
...options
|
|
2136
2132
|
});
|
|
2137
2133
|
}
|
|
2134
|
+
|
|
2135
|
+
// src/hooks/api/user.ts
|
|
2136
|
+
var user_exports = {};
|
|
2137
|
+
__export(user_exports, {
|
|
2138
|
+
chooseIdentityApi: () => chooseIdentityApi,
|
|
2139
|
+
mintPassportNftApi: () => mintPassportNftApi
|
|
2140
|
+
});
|
|
2141
|
+
|
|
2142
|
+
// src/config/chains/index.ts
|
|
2143
|
+
var chains_exports = {};
|
|
2144
|
+
__export(chains_exports, {
|
|
2145
|
+
MatchMain: () => matchMain,
|
|
2146
|
+
MatchTest: () => matchTest
|
|
2147
|
+
});
|
|
2148
|
+
|
|
2149
|
+
// src/config/chains/MatchMain.ts
|
|
2150
|
+
var import_viem = require("viem");
|
|
2151
|
+
var matchMain = /* @__PURE__ */ (0, import_viem.defineChain)({
|
|
2152
|
+
//定义match链
|
|
2153
|
+
id: 698,
|
|
2154
|
+
name: "Matchain",
|
|
2155
|
+
nativeCurrency: { name: "Match Coin", symbol: "BNB", decimals: 18 },
|
|
2156
|
+
rpcUrls: {
|
|
2157
|
+
default: {
|
|
2158
|
+
http: ["https://rpc.matchain.io"]
|
|
2159
|
+
}
|
|
2160
|
+
},
|
|
2161
|
+
blockExplorers: {
|
|
2162
|
+
default: {
|
|
2163
|
+
name: "Matchscan",
|
|
2164
|
+
url: "https://matchscan.io/",
|
|
2165
|
+
apiUrl: "https://matchscan.io/api"
|
|
2166
|
+
}
|
|
2167
|
+
},
|
|
2168
|
+
iconUrl: "https://matchscan.io/static/identicon_logos/blockies.png",
|
|
2169
|
+
contracts: {
|
|
2170
|
+
multicall3: {
|
|
2171
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11"
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
// testnet: true,
|
|
2175
|
+
});
|
|
2176
|
+
|
|
2177
|
+
// src/config/chains/MatchTest.ts
|
|
2178
|
+
var import_viem2 = require("viem");
|
|
2179
|
+
var matchTest = /* @__PURE__ */ (0, import_viem2.defineChain)({
|
|
2180
|
+
//定义matchTest链
|
|
2181
|
+
id: 699,
|
|
2182
|
+
name: "MatchTest",
|
|
2183
|
+
nativeCurrency: { name: "Match Coin", symbol: "BNB", decimals: 18 },
|
|
2184
|
+
rpcUrls: {
|
|
2185
|
+
default: {
|
|
2186
|
+
http: ["https://testnet-rpc.matchain.io"]
|
|
2187
|
+
}
|
|
2188
|
+
},
|
|
2189
|
+
blockExplorers: {
|
|
2190
|
+
default: {
|
|
2191
|
+
name: "Matchscan",
|
|
2192
|
+
url: "https://testnet.matchscan.io/",
|
|
2193
|
+
apiUrl: "https://testnet.matchscan.io/api"
|
|
2194
|
+
}
|
|
2195
|
+
},
|
|
2196
|
+
iconUrl: "https://testnet.matchscan.io/static/identicon_logos/blockies.png",
|
|
2197
|
+
contracts: {
|
|
2198
|
+
multicall3: {
|
|
2199
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
2200
|
+
blockCreated: 751532
|
|
2201
|
+
},
|
|
2202
|
+
ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" },
|
|
2203
|
+
ensUniversalResolver: {
|
|
2204
|
+
address: "0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",
|
|
2205
|
+
blockCreated: 5317080
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
// testnet: true,
|
|
2209
|
+
});
|
|
2138
2210
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2139
2211
|
0 && (module.exports = {
|
|
2140
2212
|
Api,
|
|
2213
|
+
Chains,
|
|
2141
2214
|
Components,
|
|
2142
2215
|
Hooks,
|
|
2143
2216
|
MatchProvider,
|