@canton-network/dapp-sdk 1.2.0 → 1.4.0

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.js CHANGED
@@ -901,7 +901,17 @@ var WalletConnectAdapter = class _WalletConnectAdapter {
901
901
  });
902
902
  } catch {
903
903
  }
904
- popupWin.postMessage({ type: "wc-uri", uri, qrDataUrl }, "*");
904
+ const targetOrigin = typeof window !== "undefined" ? window.location.origin : "*";
905
+ if (targetOrigin !== "*") {
906
+ popupWin.postMessage(
907
+ { type: "wc-uri", uri, qrDataUrl },
908
+ targetOrigin
909
+ );
910
+ } else {
911
+ throw new Error(
912
+ "Cannot securely send WalletConnect URI: Origin undefined"
913
+ );
914
+ }
905
915
  } catch {
906
916
  }
907
917
  }
@@ -914,6 +924,23 @@ var gateways_default = [
914
924
  rpcUrl: "http://localhost:3030/api/v0/dapp"
915
925
  }
916
926
  ];
927
+
928
+ // src/wallets.json
929
+ var wallets_default = [
930
+ {
931
+ name: "Send Connect",
932
+ type: "browser",
933
+ providerId: "browser:ext:ldmohiccoioolenadmogclhoklmanpgi",
934
+ description: "Connect via a browser extension wallet",
935
+ icon: "https://info.send.it/img/favicon.svg",
936
+ installUrls: [
937
+ {
938
+ platform: "chrome",
939
+ url: "https://chromewebstore.google.com/detail/send-connect/ldmohiccoioolenadmogclhoklmanpgi"
940
+ }
941
+ ]
942
+ }
943
+ ];
917
944
  async function requestAnnouncedProviders(options) {
918
945
  if (typeof window === "undefined") return [];
919
946
  const timeoutMs = 300;
@@ -943,10 +970,14 @@ async function requestAnnouncedProviders(options) {
943
970
  }
944
971
 
945
972
  // src/sdk.ts
973
+ function defaultTrue(b) {
974
+ return b === void 0 ? true : b;
975
+ }
946
976
  function normalizeConnectOptions(options) {
947
977
  return {
948
978
  defaultAdapters: options.defaultAdapters === void 0 ? createDefaultAdapters(gateways_default) : options.defaultAdapters,
949
- additionalAdapters: options.additionalAdapters
979
+ additionalAdapters: options.additionalAdapters,
980
+ enableSuggestedWallets: defaultTrue(options.enableSuggestedWallets)
950
981
  };
951
982
  }
952
983
  var DappSDK = class {
@@ -1124,6 +1155,17 @@ var DappSDK = class {
1124
1155
  if (options) {
1125
1156
  this.configuredAdapters = normalizeConnectOptions(options);
1126
1157
  }
1158
+ const enableSuggestedWallets = defaultTrue(
1159
+ this.configuredAdapters?.enableSuggestedWallets
1160
+ );
1161
+ if (enableSuggestedWallets) {
1162
+ localStorage.setItem(
1163
+ "splice_wallet_picker_suggested_entries",
1164
+ JSON.stringify(wallets_default)
1165
+ );
1166
+ } else {
1167
+ localStorage.removeItem("splice_wallet_picker_suggested_entries");
1168
+ }
1127
1169
  this.initPromise = this.initPromise ? this.initPromise.then(
1128
1170
  () => this.ensureDiscovery(this.configuredAdapters)
1129
1171
  ) : this.ensureDiscovery(this.configuredAdapters);