@matchain/matchid-sdk-react 0.1.40-alpha.0 → 0.1.40-alpha.1

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.
@@ -9,7 +9,7 @@ import {
9
9
  unBindWalletApi,
10
10
  useUserInfo,
11
11
  verifyPohApi
12
- } from "./chunk-XMGJLSI2.mjs";
12
+ } from "./chunk-R3JJJMNQ.mjs";
13
13
  import {
14
14
  __export
15
15
  } from "./chunk-J5LGTIGS.mjs";
@@ -90,4 +90,4 @@ export {
90
90
  user_exports,
91
91
  api_exports
92
92
  };
93
- //# sourceMappingURL=chunk-75ZLGQV7.mjs.map
93
+ //# sourceMappingURL=chunk-OG7AO57N.mjs.map
@@ -2883,7 +2883,26 @@ function useWalletInit({
2883
2883
  setIframeLoaded(true);
2884
2884
  });
2885
2885
  document.body.insertBefore(iframe, document.body.firstChild);
2886
- window.sendMatchWalletMessage = (method, data) => {
2886
+ window.sendMatchWalletMessage = (method, data, retry = 5, times = 0) => {
2887
+ try {
2888
+ if (!iframeLoaded) {
2889
+ throw new Error("Wallet not ready");
2890
+ }
2891
+ if (!walletInited) {
2892
+ throw new Error("Wallet not inited");
2893
+ }
2894
+ if (!document.getElementById("match-wallet")) {
2895
+ throw new Error("Wallet not found");
2896
+ }
2897
+ } catch (error) {
2898
+ if (times < retry) {
2899
+ setTimeout(() => {
2900
+ window.sendMatchWalletMessage(method, data, retry, times + 1);
2901
+ }, 1e3);
2902
+ } else {
2903
+ throw error;
2904
+ }
2905
+ }
2887
2906
  const messageId = Date.now().toString() + Math.random().toString().slice(6);
2888
2907
  const message = {
2889
2908
  method,
@@ -2891,18 +2910,9 @@ function useWalletInit({
2891
2910
  messageId,
2892
2911
  source: "matchid"
2893
2912
  };
2894
- if (!iframeLoaded) {
2895
- throw new Error("Wallet not ready");
2896
- }
2897
- if (!walletInited) {
2898
- throw new Error("Wallet not inited");
2899
- }
2900
- if (document.getElementById("match-wallet")) {
2901
- matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.auth);
2902
- getWalletIframe()?.contentWindow?.postMessage(message, endpoints.auth);
2903
- return messageId;
2904
- }
2905
- throw new Error("Wallet not found");
2913
+ matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.auth);
2914
+ getWalletIframe()?.contentWindow?.postMessage(message, endpoints.auth);
2915
+ return messageId;
2906
2916
  };
2907
2917
  window.waitMatchUntilWalletMessage = async (method, data, timeout = 3e4) => {
2908
2918
  return new Promise((resolve, reject) => {
@@ -3912,4 +3922,4 @@ export {
3912
3922
  MatchProvider,
3913
3923
  useMatch
3914
3924
  };
3915
- //# sourceMappingURL=chunk-XMGJLSI2.mjs.map
3925
+ //# sourceMappingURL=chunk-R3JJJMNQ.mjs.map