@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.mjs
CHANGED
|
@@ -486,7 +486,6 @@ var persistedState = persist(
|
|
|
486
486
|
appid: "",
|
|
487
487
|
token: "",
|
|
488
488
|
did: "",
|
|
489
|
-
env: "main",
|
|
490
489
|
mid: "",
|
|
491
490
|
overview: null,
|
|
492
491
|
theme: "light",
|
|
@@ -496,13 +495,17 @@ var persistedState = persist(
|
|
|
496
495
|
did: overview.did,
|
|
497
496
|
mid: overview.mid
|
|
498
497
|
}),
|
|
499
|
-
|
|
498
|
+
endpoints: {
|
|
499
|
+
back: "https://api.matchid.ai/",
|
|
500
|
+
auth: "https://auth.matchid.ai/"
|
|
501
|
+
},
|
|
500
502
|
setDid: (did) => set({ did }),
|
|
501
503
|
setToken: (token) => set({ token }),
|
|
502
504
|
setAppid: (appid) => set({ appid }),
|
|
503
505
|
setMid: (mid) => set({ mid }),
|
|
504
506
|
logout: () => set({ token: "", did: "", mid: "", address: "", overview: null }),
|
|
505
507
|
setTheme: (theme) => set({ theme }),
|
|
508
|
+
setEndpoints: (endpoints) => set({ endpoints }),
|
|
506
509
|
address: "",
|
|
507
510
|
setAddress: (address) => set({ address })
|
|
508
511
|
}),
|
|
@@ -518,57 +521,28 @@ import { useMemo } from "react";
|
|
|
518
521
|
// src/api/request.ts
|
|
519
522
|
import axios from "axios";
|
|
520
523
|
|
|
521
|
-
// src/config/env/main.ts
|
|
522
|
-
var main_default = {
|
|
523
|
-
endpoints: {
|
|
524
|
-
back: "https://api.matchid.ai/api/v1/",
|
|
525
|
-
login: "https://auth.matchid.ai/"
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
|
|
529
|
-
// src/config/env/dev.ts
|
|
530
|
-
var dev_default = {
|
|
531
|
-
endpoints: {
|
|
532
|
-
back: "https://mid-test-api.matchain.io/mid/api/v1/",
|
|
533
|
-
login: "https://calm-hare-roughly.ngrok-free.app/"
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
// src/config/env/test.ts
|
|
538
|
-
var test_default = {
|
|
539
|
-
endpoints: {
|
|
540
|
-
back: "https://mid-test-api.matchain.io/mid/api/v1/",
|
|
541
|
-
login: "https://mid-sso-test.vercel.app/"
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
|
|
545
524
|
// src/config/env/index.ts
|
|
546
525
|
var env_default = {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
526
|
+
endpoints: {
|
|
527
|
+
back: "https://api.matchid.ai/",
|
|
528
|
+
auth: "https://auth.matchid.ai/"
|
|
529
|
+
}
|
|
550
530
|
};
|
|
551
531
|
|
|
552
532
|
// src/store/index.ts
|
|
553
|
-
var
|
|
533
|
+
var getEndpoints = () => {
|
|
554
534
|
try {
|
|
555
535
|
const store = localStore.getState();
|
|
556
|
-
const env = store?.
|
|
536
|
+
const env = store?.endpoints;
|
|
557
537
|
if (env) {
|
|
558
538
|
return env;
|
|
559
539
|
} else {
|
|
560
|
-
return
|
|
540
|
+
return env_default.endpoints;
|
|
561
541
|
}
|
|
562
542
|
} catch (e) {
|
|
563
|
-
return
|
|
543
|
+
return env_default.endpoints;
|
|
564
544
|
}
|
|
565
545
|
};
|
|
566
|
-
var getEnvConfig = () => {
|
|
567
|
-
return env_default[getEnv()];
|
|
568
|
-
};
|
|
569
|
-
var getEndpoints = () => {
|
|
570
|
-
return getEnvConfig().endpoints;
|
|
571
|
-
};
|
|
572
546
|
var getAppid = () => {
|
|
573
547
|
try {
|
|
574
548
|
const store = localStore.getState();
|
|
@@ -656,72 +630,72 @@ var request_default = request;
|
|
|
656
630
|
// src/api/index.ts
|
|
657
631
|
var getEmailCodeApi = (email) => {
|
|
658
632
|
return request_default({
|
|
659
|
-
url: `/email/code`,
|
|
633
|
+
url: `/api/v1/email/code`,
|
|
660
634
|
method: "POST",
|
|
661
635
|
data: { email }
|
|
662
636
|
});
|
|
663
637
|
};
|
|
664
638
|
var verifyEmailCodeApi = ({ email, verification_key, verification_code }) => {
|
|
665
639
|
return request_default({
|
|
666
|
-
url: `/user/email/login`,
|
|
640
|
+
url: `/api/v1/user/email/login`,
|
|
667
641
|
method: "POST",
|
|
668
642
|
data: { email, verification_key, verification_code }
|
|
669
643
|
});
|
|
670
644
|
};
|
|
671
645
|
var getOverviewInfoApi = () => {
|
|
672
646
|
return request_default({
|
|
673
|
-
url: `/user/overview`,
|
|
647
|
+
url: `/api/v1/user/overview`,
|
|
674
648
|
method: "GET"
|
|
675
649
|
});
|
|
676
650
|
};
|
|
677
651
|
var toLogoutApi = () => {
|
|
678
652
|
return request_default({
|
|
679
|
-
url: `/user/logout`,
|
|
653
|
+
url: `/api/v1/user/logout`,
|
|
680
654
|
method: "POST"
|
|
681
655
|
});
|
|
682
656
|
};
|
|
683
657
|
var setUserNameApi = (data) => {
|
|
684
658
|
return request_default({
|
|
685
|
-
url: `/user/name`,
|
|
659
|
+
url: `/api/v1/user/name`,
|
|
686
660
|
method: "POSt",
|
|
687
661
|
data
|
|
688
662
|
});
|
|
689
663
|
};
|
|
690
664
|
var getBindListApi = () => {
|
|
691
665
|
return request_default({
|
|
692
|
-
url: `/bind/list`,
|
|
666
|
+
url: `/api/v1/bind/list`,
|
|
693
667
|
method: "GET"
|
|
694
668
|
});
|
|
695
669
|
};
|
|
696
670
|
var getPohListApi = () => {
|
|
697
671
|
return request_default({
|
|
698
|
-
url: `/poh/list`,
|
|
672
|
+
url: `/api/v1/poh/list`,
|
|
699
673
|
method: "GET"
|
|
700
674
|
});
|
|
701
675
|
};
|
|
702
676
|
var getBindInfoApi = () => {
|
|
703
677
|
return request_default({
|
|
704
|
-
url: `/bind`,
|
|
678
|
+
url: `/api/v1/bind`,
|
|
705
679
|
method: "GET"
|
|
706
680
|
});
|
|
707
681
|
};
|
|
708
682
|
var bindCexApi = ({ cex, api_key, api_secret }) => {
|
|
709
683
|
return request_default({
|
|
710
|
-
url: `/cex/subscribe`,
|
|
684
|
+
url: `/api/v1/cex/subscribe`,
|
|
711
685
|
method: "POST",
|
|
712
686
|
data: { cex, api_key, api_secret }
|
|
713
687
|
});
|
|
714
688
|
};
|
|
715
689
|
var unBindApi = ({ type }) => {
|
|
716
690
|
return request_default({
|
|
717
|
-
url: `/unbind`,
|
|
691
|
+
url: `/api/v1/unbind`,
|
|
718
692
|
method: "POST",
|
|
719
693
|
data: { type }
|
|
720
694
|
});
|
|
721
695
|
};
|
|
722
696
|
var unBindWalletApi = ({ address }) => {
|
|
723
697
|
return request_default({
|
|
724
|
-
url: `/wallet/unbind`,
|
|
698
|
+
url: `/api/v1/wallet/unbind`,
|
|
725
699
|
method: "POST",
|
|
726
700
|
data: { address }
|
|
727
701
|
});
|
|
@@ -738,7 +712,7 @@ var verifyPohApi = ({
|
|
|
738
712
|
validatorSignature
|
|
739
713
|
}) => {
|
|
740
714
|
return request_default({
|
|
741
|
-
url: `/poh/zkpass`,
|
|
715
|
+
url: `/api/v1/poh/zkpass`,
|
|
742
716
|
method: "POST",
|
|
743
717
|
data: {
|
|
744
718
|
taskId,
|
|
@@ -753,6 +727,25 @@ var verifyPohApi = ({
|
|
|
753
727
|
}
|
|
754
728
|
});
|
|
755
729
|
};
|
|
730
|
+
var chooseIdentityApi = ({ identity }) => {
|
|
731
|
+
return request_default({
|
|
732
|
+
url: `/api/v1/user/choose/identity`,
|
|
733
|
+
method: "POST",
|
|
734
|
+
data: { identity }
|
|
735
|
+
});
|
|
736
|
+
};
|
|
737
|
+
var mintPassportNftApi = () => {
|
|
738
|
+
return request_default({
|
|
739
|
+
url: `/api/v1/mint/passport/nft`,
|
|
740
|
+
method: "POST"
|
|
741
|
+
});
|
|
742
|
+
};
|
|
743
|
+
var getAuthInfoApi = () => {
|
|
744
|
+
return request_default({
|
|
745
|
+
url: `/api/v1/user/auth`,
|
|
746
|
+
method: "GET"
|
|
747
|
+
});
|
|
748
|
+
};
|
|
756
749
|
|
|
757
750
|
// src/hooks/eventManager.ts
|
|
758
751
|
var EventManager = class {
|
|
@@ -811,16 +804,13 @@ function useUserInfo() {
|
|
|
811
804
|
token,
|
|
812
805
|
mid,
|
|
813
806
|
did,
|
|
814
|
-
env,
|
|
815
807
|
logout: logoutStore,
|
|
816
808
|
setOverview,
|
|
817
809
|
overview,
|
|
818
|
-
address
|
|
810
|
+
address,
|
|
811
|
+
endpoints
|
|
819
812
|
} = useLocalStore_default();
|
|
820
813
|
const { events, login } = useMatch();
|
|
821
|
-
const endpoints = useMemo(() => {
|
|
822
|
-
return getEndpoints();
|
|
823
|
-
}, [env]);
|
|
824
814
|
const isLogin = useMemo(() => !!token, [token]);
|
|
825
815
|
const logout = async () => {
|
|
826
816
|
try {
|
|
@@ -833,7 +823,7 @@ function useUserInfo() {
|
|
|
833
823
|
eventManager_default.emit("onLogout");
|
|
834
824
|
};
|
|
835
825
|
const loginByMethod = (method) => {
|
|
836
|
-
const link = `${endpoints.back}auth/${method}?appid=${appid}&provider=${method}&redirect=${encodeURIComponent(endpoints.
|
|
826
|
+
const link = `${endpoints.back}auth/${method}?appid=${appid}&provider=${method}&redirect=${encodeURIComponent(endpoints.auth + "login/" + method)}&authorization=${(/* @__PURE__ */ new Date()).getTime()}`;
|
|
837
827
|
matchlog_default.log("link", link);
|
|
838
828
|
const authWindow = window.open(
|
|
839
829
|
link,
|
|
@@ -884,7 +874,7 @@ function useUserInfo() {
|
|
|
884
874
|
};
|
|
885
875
|
const loginByWallet = () => {
|
|
886
876
|
const authWindow = window.open(
|
|
887
|
-
`${endpoints.
|
|
877
|
+
`${endpoints.auth}login/wallet?appid=${appid}`,
|
|
888
878
|
// Replace with the actual authorization URL
|
|
889
879
|
"_blank"
|
|
890
880
|
// 'width=800,height=600'
|
|
@@ -892,7 +882,7 @@ function useUserInfo() {
|
|
|
892
882
|
};
|
|
893
883
|
const loginByTelegram = () => {
|
|
894
884
|
const authWindow = window.open(
|
|
895
|
-
`${endpoints.
|
|
885
|
+
`${endpoints.auth}login/telegram?appid=${appid}`,
|
|
896
886
|
// Replace with the actual authorization URL
|
|
897
887
|
"authWindow",
|
|
898
888
|
"width=800,height=600"
|
|
@@ -909,7 +899,7 @@ function useUserInfo() {
|
|
|
909
899
|
throw new Error("You must login first");
|
|
910
900
|
}
|
|
911
901
|
const authWindow = window.open(
|
|
912
|
-
`${endpoints.
|
|
902
|
+
`${endpoints.auth}bind/wallet?appid=${appid}&st=` + encodeURIComponent(encodeBase64(token)),
|
|
913
903
|
// Replace with the actual authorization URL
|
|
914
904
|
"_blank"
|
|
915
905
|
);
|
|
@@ -919,12 +909,19 @@ function useUserInfo() {
|
|
|
919
909
|
throw new Error("You must login first");
|
|
920
910
|
}
|
|
921
911
|
const authWindow = window.open(
|
|
922
|
-
`${endpoints.
|
|
912
|
+
`${endpoints.auth}bind/telegram?appid=${appid}&st=` + encodeURIComponent(encodeBase64(token)),
|
|
923
913
|
// Replace with the actual authorization URL
|
|
924
914
|
"authWindow",
|
|
925
915
|
"width=800,height=600"
|
|
926
916
|
);
|
|
927
917
|
};
|
|
918
|
+
const auth = async () => {
|
|
919
|
+
const res = await getAuthInfoApi();
|
|
920
|
+
if (isSuccess(res)) {
|
|
921
|
+
return res.data;
|
|
922
|
+
}
|
|
923
|
+
throw new Error(res.message);
|
|
924
|
+
};
|
|
928
925
|
return {
|
|
929
926
|
loginByTelegram,
|
|
930
927
|
loginByTwitter,
|
|
@@ -942,7 +939,8 @@ function useUserInfo() {
|
|
|
942
939
|
overview,
|
|
943
940
|
bindWallet,
|
|
944
941
|
bindTelegram,
|
|
945
|
-
username: overview?.username || ""
|
|
942
|
+
username: overview?.username || "",
|
|
943
|
+
auth
|
|
946
944
|
};
|
|
947
945
|
}
|
|
948
946
|
|
|
@@ -983,13 +981,14 @@ var useStore = create2((set) => ({
|
|
|
983
981
|
var useStore_default = useStore;
|
|
984
982
|
|
|
985
983
|
// src/hooks/useWallet.tsx
|
|
984
|
+
import { toAccount } from "viem/accounts";
|
|
986
985
|
var AppClientId = "react-sdk-" + getVersion();
|
|
987
986
|
function useWallet() {
|
|
988
|
-
const { appid, token, overview } = useLocalStore_default();
|
|
987
|
+
const { appid, token, overview, address } = useLocalStore_default();
|
|
989
988
|
const { setRecoveryModal, closeRecoveryModal } = useStore_default();
|
|
990
989
|
const initWallet = ({
|
|
991
990
|
did,
|
|
992
|
-
address
|
|
991
|
+
address: address2
|
|
993
992
|
}) => {
|
|
994
993
|
return window.waitMatchUntilWalletMessage(
|
|
995
994
|
"initCore",
|
|
@@ -998,7 +997,7 @@ function useWallet() {
|
|
|
998
997
|
AppClientId,
|
|
999
998
|
UserId: did,
|
|
1000
999
|
AccessToken: token,
|
|
1001
|
-
Address:
|
|
1000
|
+
Address: address2
|
|
1002
1001
|
}
|
|
1003
1002
|
);
|
|
1004
1003
|
};
|
|
@@ -1011,33 +1010,21 @@ function useWallet() {
|
|
|
1011
1010
|
userPasscode
|
|
1012
1011
|
}) => {
|
|
1013
1012
|
return await window.waitMatchUntilWalletMessage("generateWallet", {
|
|
1013
|
+
chainType: "ethereum",
|
|
1014
1014
|
recoveryType: "user_passcode_recovery_key",
|
|
1015
1015
|
userPasscode
|
|
1016
1016
|
});
|
|
1017
1017
|
};
|
|
1018
|
-
const
|
|
1018
|
+
const recoverAfter = async (func) => {
|
|
1019
1019
|
return new Promise(async (resolve, reject) => {
|
|
1020
1020
|
const res = await isRecovered();
|
|
1021
1021
|
matchlog_default.log("isRecovered", res);
|
|
1022
|
-
const getSign = async () => {
|
|
1023
|
-
try {
|
|
1024
|
-
const recoverRes = await window.waitMatchUntilWalletMessage("signMessage", {
|
|
1025
|
-
message,
|
|
1026
|
-
chainType: type
|
|
1027
|
-
});
|
|
1028
|
-
closeRecoveryModal();
|
|
1029
|
-
resolve(recoverRes);
|
|
1030
|
-
} catch (error) {
|
|
1031
|
-
console.error("qwe-sign-error", error);
|
|
1032
|
-
reject(error);
|
|
1033
|
-
}
|
|
1034
|
-
};
|
|
1035
1022
|
if (!res) {
|
|
1036
1023
|
setRecoveryModal({
|
|
1037
1024
|
open: true,
|
|
1038
1025
|
success: async () => {
|
|
1039
1026
|
matchlog_default.log("recover Success");
|
|
1040
|
-
await
|
|
1027
|
+
await func(resolve, reject);
|
|
1041
1028
|
},
|
|
1042
1029
|
close: async () => {
|
|
1043
1030
|
closeRecoveryModal();
|
|
@@ -1050,48 +1037,41 @@ function useWallet() {
|
|
|
1050
1037
|
});
|
|
1051
1038
|
} else {
|
|
1052
1039
|
await recoveryWallet("ethereum", "user_passcode_recovery_key");
|
|
1053
|
-
await
|
|
1040
|
+
await func(resolve, reject);
|
|
1054
1041
|
}
|
|
1055
1042
|
});
|
|
1056
1043
|
};
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
const recoverRes = await window.waitMatchUntilWalletMessage("signTransaction", {
|
|
1064
|
-
transaction,
|
|
1065
|
-
chainType: type
|
|
1066
|
-
});
|
|
1067
|
-
closeRecoveryModal();
|
|
1068
|
-
resolve(recoverRes);
|
|
1069
|
-
} catch (error) {
|
|
1070
|
-
console.error("qwe-sign-error", error);
|
|
1071
|
-
reject(error);
|
|
1072
|
-
}
|
|
1073
|
-
};
|
|
1074
|
-
if (!res) {
|
|
1075
|
-
setRecoveryModal({
|
|
1076
|
-
open: true,
|
|
1077
|
-
success: async () => {
|
|
1078
|
-
matchlog_default.log("recover Success");
|
|
1079
|
-
await getSign();
|
|
1080
|
-
},
|
|
1081
|
-
close: async () => {
|
|
1082
|
-
closeRecoveryModal();
|
|
1083
|
-
reject(new Error("recover modal close"));
|
|
1084
|
-
}
|
|
1044
|
+
const signMessage = async (message, type) => {
|
|
1045
|
+
const getSign = async (resolve, reject) => {
|
|
1046
|
+
try {
|
|
1047
|
+
const recoverRes = await window.waitMatchUntilWalletMessage("signMessage", {
|
|
1048
|
+
message,
|
|
1049
|
+
chainType: type
|
|
1085
1050
|
});
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1051
|
+
closeRecoveryModal();
|
|
1052
|
+
resolve(recoverRes);
|
|
1053
|
+
} catch (error) {
|
|
1054
|
+
console.error("qwe-sign-error", error);
|
|
1055
|
+
reject(error);
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
return await recoverAfter(getSign);
|
|
1059
|
+
};
|
|
1060
|
+
const signTransaction = async (transaction, type) => {
|
|
1061
|
+
const getSign = async (resolve, reject) => {
|
|
1062
|
+
try {
|
|
1063
|
+
const recoverRes = await window.waitMatchUntilWalletMessage("signTransaction", {
|
|
1064
|
+
transaction,
|
|
1065
|
+
chainType: type
|
|
1089
1066
|
});
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1067
|
+
closeRecoveryModal();
|
|
1068
|
+
resolve(recoverRes);
|
|
1069
|
+
} catch (error) {
|
|
1070
|
+
console.error("qwe-sign-error", error);
|
|
1071
|
+
reject(error);
|
|
1093
1072
|
}
|
|
1094
|
-
}
|
|
1073
|
+
};
|
|
1074
|
+
return await recoverAfter(getSign);
|
|
1095
1075
|
};
|
|
1096
1076
|
const recoveryWallet = async (chainType, recoveryType, userPasscode) => {
|
|
1097
1077
|
return await window.waitMatchUntilWalletMessage("recoveryWallet", {
|
|
@@ -1100,13 +1080,32 @@ function useWallet() {
|
|
|
1100
1080
|
userPasscode
|
|
1101
1081
|
});
|
|
1102
1082
|
};
|
|
1083
|
+
const evmAccount = address ? toAccount({
|
|
1084
|
+
address,
|
|
1085
|
+
async signMessage({ message }) {
|
|
1086
|
+
return await signMessage(message);
|
|
1087
|
+
},
|
|
1088
|
+
async signTransaction(transaction, options) {
|
|
1089
|
+
const { account, ...restTransaction } = transaction;
|
|
1090
|
+
const sign = await signTransaction({
|
|
1091
|
+
...restTransaction
|
|
1092
|
+
});
|
|
1093
|
+
return sign;
|
|
1094
|
+
},
|
|
1095
|
+
async signTypedData(typedData) {
|
|
1096
|
+
return "0x";
|
|
1097
|
+
}
|
|
1098
|
+
}) : void 0;
|
|
1103
1099
|
return {
|
|
1100
|
+
evmAccount,
|
|
1101
|
+
address,
|
|
1104
1102
|
recoveryWallet,
|
|
1105
1103
|
initWallet,
|
|
1106
1104
|
generateWallet,
|
|
1107
1105
|
signMessage,
|
|
1108
1106
|
signTransaction,
|
|
1109
|
-
isRecovered
|
|
1107
|
+
isRecovered,
|
|
1108
|
+
recoverAfter
|
|
1110
1109
|
};
|
|
1111
1110
|
}
|
|
1112
1111
|
|
|
@@ -1302,7 +1301,7 @@ var AppClientId2 = "react-sdk-" + getVersion();
|
|
|
1302
1301
|
function useWalletInit({
|
|
1303
1302
|
refreshOverview
|
|
1304
1303
|
}) {
|
|
1305
|
-
const {
|
|
1304
|
+
const { endpoints } = useLocalStore_default();
|
|
1306
1305
|
const getWalletIframe = () => {
|
|
1307
1306
|
return document.getElementById("match-wallet");
|
|
1308
1307
|
};
|
|
@@ -1310,17 +1309,15 @@ function useWalletInit({
|
|
|
1310
1309
|
const { appid, token, overview } = useLocalStore_default();
|
|
1311
1310
|
const { initWallet, generateWallet } = useWallet();
|
|
1312
1311
|
useEffect4(() => {
|
|
1313
|
-
if (
|
|
1312
|
+
if (endpoints.auth) {
|
|
1314
1313
|
if (!window.matchWalletMessageIdMap) {
|
|
1315
1314
|
window.matchWalletMessageIdMap = {};
|
|
1316
1315
|
}
|
|
1317
|
-
const config = env_default[env];
|
|
1318
|
-
const endpoints = config.endpoints;
|
|
1319
1316
|
const existingIframe = getWalletIframe();
|
|
1320
1317
|
if (!existingIframe) {
|
|
1321
1318
|
const iframe = document.createElement("iframe");
|
|
1322
1319
|
iframe.id = "match-wallet";
|
|
1323
|
-
iframe.src = endpoints.
|
|
1320
|
+
iframe.src = endpoints.auth + "wallet";
|
|
1324
1321
|
iframe.style.display = "none";
|
|
1325
1322
|
iframe.style.width = "0";
|
|
1326
1323
|
iframe.style.height = "0";
|
|
@@ -1334,8 +1331,8 @@ function useWalletInit({
|
|
|
1334
1331
|
source: "matchid"
|
|
1335
1332
|
};
|
|
1336
1333
|
if (document.getElementById("match-wallet")) {
|
|
1337
|
-
matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.
|
|
1338
|
-
getWalletIframe()?.contentWindow?.postMessage(message, endpoints.
|
|
1334
|
+
matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.auth);
|
|
1335
|
+
getWalletIframe()?.contentWindow?.postMessage(message, endpoints.auth);
|
|
1339
1336
|
return messageId;
|
|
1340
1337
|
}
|
|
1341
1338
|
console.error("not found iframe");
|
|
@@ -1362,16 +1359,16 @@ function useWalletInit({
|
|
|
1362
1359
|
});
|
|
1363
1360
|
};
|
|
1364
1361
|
} else {
|
|
1365
|
-
if (existingIframe.src !== endpoints.
|
|
1362
|
+
if (existingIframe.src !== endpoints.auth + "wallet") {
|
|
1366
1363
|
setWalletInited(false);
|
|
1367
|
-
existingIframe.src = endpoints.
|
|
1364
|
+
existingIframe.src = endpoints.auth + "wallet";
|
|
1368
1365
|
}
|
|
1369
1366
|
}
|
|
1370
1367
|
}
|
|
1371
|
-
}, [
|
|
1368
|
+
}, [endpoints.auth]);
|
|
1372
1369
|
useEffect4(() => {
|
|
1373
1370
|
const messageHandle = async (e) => {
|
|
1374
|
-
if (e.origin !==
|
|
1371
|
+
if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
|
|
1375
1372
|
return;
|
|
1376
1373
|
}
|
|
1377
1374
|
const res = e.data;
|
|
@@ -1437,12 +1434,12 @@ import { useEffect as useEffect5, useRef } from "react";
|
|
|
1437
1434
|
function useInit({
|
|
1438
1435
|
theme,
|
|
1439
1436
|
appid,
|
|
1440
|
-
|
|
1441
|
-
|
|
1437
|
+
events,
|
|
1438
|
+
endpoints
|
|
1442
1439
|
}) {
|
|
1443
1440
|
const {
|
|
1444
1441
|
setAppid,
|
|
1445
|
-
|
|
1442
|
+
setEndpoints,
|
|
1446
1443
|
setToken,
|
|
1447
1444
|
setMid,
|
|
1448
1445
|
token,
|
|
@@ -1452,8 +1449,7 @@ function useInit({
|
|
|
1452
1449
|
const overviewLoadingRef = useRef(false);
|
|
1453
1450
|
const searchParams = new URLSearchParams(window.location.search);
|
|
1454
1451
|
const matchToken = searchParams.get("matchToken");
|
|
1455
|
-
const
|
|
1456
|
-
const endpoints = config.endpoints;
|
|
1452
|
+
const realEndpoints = endpoints || env_default.endpoints;
|
|
1457
1453
|
useEffect5(() => {
|
|
1458
1454
|
setTheme(theme);
|
|
1459
1455
|
}, [theme]);
|
|
@@ -1461,8 +1457,8 @@ function useInit({
|
|
|
1461
1457
|
setAppid(appid);
|
|
1462
1458
|
}, [appid]);
|
|
1463
1459
|
useEffect5(() => {
|
|
1464
|
-
|
|
1465
|
-
}, [
|
|
1460
|
+
setEndpoints(realEndpoints);
|
|
1461
|
+
}, [realEndpoints]);
|
|
1466
1462
|
useEffect5(() => {
|
|
1467
1463
|
if (matchToken) {
|
|
1468
1464
|
const tokenData = JSON.parse(atob(matchToken));
|
|
@@ -1535,8 +1531,7 @@ function useInit({
|
|
|
1535
1531
|
return {
|
|
1536
1532
|
loadOverview,
|
|
1537
1533
|
login,
|
|
1538
|
-
|
|
1539
|
-
endpoints
|
|
1534
|
+
endpoints: realEndpoints
|
|
1540
1535
|
};
|
|
1541
1536
|
}
|
|
1542
1537
|
|
|
@@ -1545,12 +1540,12 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
|
1545
1540
|
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
1546
1541
|
var queryClient = new QueryClient();
|
|
1547
1542
|
var MatchContext = createContext(void 0);
|
|
1548
|
-
var MatchProvider = ({ children, appid,
|
|
1549
|
-
const { loadOverview, login,
|
|
1543
|
+
var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) => {
|
|
1544
|
+
const { loadOverview, login, endpoints: realEndPoints } = useInit({
|
|
1550
1545
|
theme,
|
|
1551
1546
|
appid,
|
|
1552
|
-
|
|
1553
|
-
|
|
1547
|
+
events,
|
|
1548
|
+
endpoints
|
|
1554
1549
|
});
|
|
1555
1550
|
useWalletInit({
|
|
1556
1551
|
refreshOverview: loadOverview
|
|
@@ -1560,8 +1555,7 @@ var MatchProvider = ({ children, appid, env = "main", events, theme = "light" })
|
|
|
1560
1555
|
{
|
|
1561
1556
|
value: {
|
|
1562
1557
|
appid,
|
|
1563
|
-
|
|
1564
|
-
endpoints,
|
|
1558
|
+
endpoints: realEndPoints,
|
|
1565
1559
|
events,
|
|
1566
1560
|
login,
|
|
1567
1561
|
theme
|
|
@@ -2044,7 +2038,8 @@ function UsernameModal({
|
|
|
2044
2038
|
var api_exports = {};
|
|
2045
2039
|
__export(api_exports, {
|
|
2046
2040
|
bind: () => bind_exports,
|
|
2047
|
-
poh: () => poh_exports
|
|
2041
|
+
poh: () => poh_exports,
|
|
2042
|
+
user: () => user_exports
|
|
2048
2043
|
});
|
|
2049
2044
|
|
|
2050
2045
|
// src/hooks/api/bind.ts
|
|
@@ -2101,8 +2096,85 @@ function usePohList(options) {
|
|
|
2101
2096
|
...options
|
|
2102
2097
|
});
|
|
2103
2098
|
}
|
|
2099
|
+
|
|
2100
|
+
// src/hooks/api/user.ts
|
|
2101
|
+
var user_exports = {};
|
|
2102
|
+
__export(user_exports, {
|
|
2103
|
+
chooseIdentityApi: () => chooseIdentityApi,
|
|
2104
|
+
mintPassportNftApi: () => mintPassportNftApi
|
|
2105
|
+
});
|
|
2106
|
+
|
|
2107
|
+
// src/config/chains/index.ts
|
|
2108
|
+
var chains_exports = {};
|
|
2109
|
+
__export(chains_exports, {
|
|
2110
|
+
MatchMain: () => matchMain,
|
|
2111
|
+
MatchTest: () => matchTest
|
|
2112
|
+
});
|
|
2113
|
+
|
|
2114
|
+
// src/config/chains/MatchMain.ts
|
|
2115
|
+
import { defineChain } from "viem";
|
|
2116
|
+
var matchMain = /* @__PURE__ */ defineChain({
|
|
2117
|
+
//定义match链
|
|
2118
|
+
id: 698,
|
|
2119
|
+
name: "Matchain",
|
|
2120
|
+
nativeCurrency: { name: "Match Coin", symbol: "BNB", decimals: 18 },
|
|
2121
|
+
rpcUrls: {
|
|
2122
|
+
default: {
|
|
2123
|
+
http: ["https://rpc.matchain.io"]
|
|
2124
|
+
}
|
|
2125
|
+
},
|
|
2126
|
+
blockExplorers: {
|
|
2127
|
+
default: {
|
|
2128
|
+
name: "Matchscan",
|
|
2129
|
+
url: "https://matchscan.io/",
|
|
2130
|
+
apiUrl: "https://matchscan.io/api"
|
|
2131
|
+
}
|
|
2132
|
+
},
|
|
2133
|
+
iconUrl: "https://matchscan.io/static/identicon_logos/blockies.png",
|
|
2134
|
+
contracts: {
|
|
2135
|
+
multicall3: {
|
|
2136
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11"
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
// testnet: true,
|
|
2140
|
+
});
|
|
2141
|
+
|
|
2142
|
+
// src/config/chains/MatchTest.ts
|
|
2143
|
+
import { defineChain as defineChain2 } from "viem";
|
|
2144
|
+
var matchTest = /* @__PURE__ */ defineChain2({
|
|
2145
|
+
//定义matchTest链
|
|
2146
|
+
id: 699,
|
|
2147
|
+
name: "MatchTest",
|
|
2148
|
+
nativeCurrency: { name: "Match Coin", symbol: "BNB", decimals: 18 },
|
|
2149
|
+
rpcUrls: {
|
|
2150
|
+
default: {
|
|
2151
|
+
http: ["https://testnet-rpc.matchain.io"]
|
|
2152
|
+
}
|
|
2153
|
+
},
|
|
2154
|
+
blockExplorers: {
|
|
2155
|
+
default: {
|
|
2156
|
+
name: "Matchscan",
|
|
2157
|
+
url: "https://testnet.matchscan.io/",
|
|
2158
|
+
apiUrl: "https://testnet.matchscan.io/api"
|
|
2159
|
+
}
|
|
2160
|
+
},
|
|
2161
|
+
iconUrl: "https://testnet.matchscan.io/static/identicon_logos/blockies.png",
|
|
2162
|
+
contracts: {
|
|
2163
|
+
multicall3: {
|
|
2164
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
2165
|
+
blockCreated: 751532
|
|
2166
|
+
},
|
|
2167
|
+
ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" },
|
|
2168
|
+
ensUniversalResolver: {
|
|
2169
|
+
address: "0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",
|
|
2170
|
+
blockCreated: 5317080
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
// testnet: true,
|
|
2174
|
+
});
|
|
2104
2175
|
export {
|
|
2105
2176
|
api_exports as Api,
|
|
2177
|
+
chains_exports as Chains,
|
|
2106
2178
|
components_exports as Components,
|
|
2107
2179
|
hooks_exports as Hooks,
|
|
2108
2180
|
MatchProvider,
|