@metamask/connect-multichain 0.5.1 → 0.5.3

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.
Files changed (137) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/README.md +409 -3
  3. package/dist/browser/es/connect-multichain.d.mts +6 -5
  4. package/dist/browser/es/connect-multichain.mjs +311 -226
  5. package/dist/browser/es/connect-multichain.mjs.map +1 -1
  6. package/dist/browser/es/metafile-esm.json +1 -1
  7. package/dist/browser/iife/connect-multichain.d.ts +6 -5
  8. package/dist/browser/iife/connect-multichain.js +24212 -24110
  9. package/dist/browser/iife/connect-multichain.js.map +1 -1
  10. package/dist/browser/iife/metafile-iife.json +1 -1
  11. package/dist/browser/umd/connect-multichain.d.ts +6 -5
  12. package/dist/browser/umd/connect-multichain.js +312 -227
  13. package/dist/browser/umd/connect-multichain.js.map +1 -1
  14. package/dist/browser/umd/metafile-cjs.json +1 -1
  15. package/dist/node/cjs/connect-multichain.d.ts +6 -5
  16. package/dist/node/cjs/connect-multichain.js +314 -230
  17. package/dist/node/cjs/connect-multichain.js.map +1 -1
  18. package/dist/node/cjs/metafile-cjs.json +1 -1
  19. package/dist/node/es/connect-multichain.d.mts +6 -5
  20. package/dist/node/es/connect-multichain.mjs +314 -228
  21. package/dist/node/es/connect-multichain.mjs.map +1 -1
  22. package/dist/node/es/metafile-esm.json +1 -1
  23. package/dist/react-native/es/connect-multichain.d.mts +6 -5
  24. package/dist/react-native/es/connect-multichain.mjs +311 -226
  25. package/dist/react-native/es/connect-multichain.mjs.map +1 -1
  26. package/dist/react-native/es/metafile-esm.json +1 -1
  27. package/dist/src/domain/logger/index.d.ts +1 -1
  28. package/dist/src/domain/logger/index.d.ts.map +1 -1
  29. package/dist/src/domain/logger/index.js.map +1 -1
  30. package/dist/src/domain/multichain/api/constants.js.map +1 -1
  31. package/dist/src/domain/multichain/api/types.d.ts +1 -1
  32. package/dist/src/domain/multichain/api/types.d.ts.map +1 -1
  33. package/dist/src/domain/multichain/index.d.ts.map +1 -1
  34. package/dist/src/domain/multichain/index.js.map +1 -1
  35. package/dist/src/domain/multichain/types.d.ts +2 -0
  36. package/dist/src/domain/multichain/types.d.ts.map +1 -1
  37. package/dist/src/domain/platform/index.d.ts.map +1 -1
  38. package/dist/src/domain/platform/index.js +1 -0
  39. package/dist/src/domain/platform/index.js.map +1 -1
  40. package/dist/src/index.browser.d.ts.map +1 -1
  41. package/dist/src/index.browser.js +9 -4
  42. package/dist/src/index.browser.js.map +1 -1
  43. package/dist/src/index.native.d.ts.map +1 -1
  44. package/dist/src/index.native.js +9 -4
  45. package/dist/src/index.native.js.map +1 -1
  46. package/dist/src/index.node.d.ts.map +1 -1
  47. package/dist/src/index.node.js +8 -4
  48. package/dist/src/index.node.js.map +1 -1
  49. package/dist/src/multichain/index.d.ts +1 -1
  50. package/dist/src/multichain/index.d.ts.map +1 -1
  51. package/dist/src/multichain/index.js +37 -10
  52. package/dist/src/multichain/index.js.map +1 -1
  53. package/dist/src/multichain/rpc/handlers/rpcClient.d.ts +9 -2
  54. package/dist/src/multichain/rpc/handlers/rpcClient.d.ts.map +1 -1
  55. package/dist/src/multichain/rpc/handlers/rpcClient.js +13 -3
  56. package/dist/src/multichain/rpc/handlers/rpcClient.js.map +1 -1
  57. package/dist/src/multichain/rpc/requestRouter.d.ts +14 -1
  58. package/dist/src/multichain/rpc/requestRouter.d.ts.map +1 -1
  59. package/dist/src/multichain/rpc/requestRouter.js +27 -5
  60. package/dist/src/multichain/rpc/requestRouter.js.map +1 -1
  61. package/dist/src/multichain/transports/default/index.d.ts +2 -2
  62. package/dist/src/multichain/transports/default/index.d.ts.map +1 -1
  63. package/dist/src/multichain/transports/default/index.js +14 -17
  64. package/dist/src/multichain/transports/default/index.js.map +1 -1
  65. package/dist/src/multichain/transports/multichainApiClientWrapper/index.d.ts +0 -2
  66. package/dist/src/multichain/transports/multichainApiClientWrapper/index.d.ts.map +1 -1
  67. package/dist/src/multichain/transports/multichainApiClientWrapper/index.js +18 -11
  68. package/dist/src/multichain/transports/multichainApiClientWrapper/index.js.map +1 -1
  69. package/dist/src/multichain/transports/mwp/KeyManager.d.ts.map +1 -1
  70. package/dist/src/multichain/transports/mwp/KeyManager.js.map +1 -1
  71. package/dist/src/multichain/transports/mwp/index.d.ts +1 -1
  72. package/dist/src/multichain/transports/mwp/index.d.ts.map +1 -1
  73. package/dist/src/multichain/transports/mwp/index.js +2 -1
  74. package/dist/src/multichain/transports/mwp/index.js.map +1 -1
  75. package/dist/src/multichain/utils/analytics.d.ts.map +1 -1
  76. package/dist/src/multichain/utils/analytics.js +1 -0
  77. package/dist/src/multichain/utils/analytics.js.map +1 -1
  78. package/dist/src/multichain/utils/index.d.ts +25 -0
  79. package/dist/src/multichain/utils/index.d.ts.map +1 -1
  80. package/dist/src/multichain/utils/index.js +38 -6
  81. package/dist/src/multichain/utils/index.js.map +1 -1
  82. package/dist/src/polyfills/buffer-shim.js +7 -3
  83. package/dist/src/polyfills/buffer-shim.js.map +1 -1
  84. package/dist/src/store/adapters/node.d.ts +1 -1
  85. package/dist/src/store/adapters/node.d.ts.map +1 -1
  86. package/dist/src/store/adapters/node.js +11 -4
  87. package/dist/src/store/adapters/node.js.map +1 -1
  88. package/dist/src/store/adapters/rn.d.ts.map +1 -1
  89. package/dist/src/store/adapters/rn.js +1 -0
  90. package/dist/src/store/adapters/rn.js.map +1 -1
  91. package/dist/src/store/adapters/web.d.ts +4 -4
  92. package/dist/src/store/adapters/web.d.ts.map +1 -1
  93. package/dist/src/store/adapters/web.js +6 -0
  94. package/dist/src/store/adapters/web.js.map +1 -1
  95. package/dist/src/store/index.d.ts.map +1 -1
  96. package/dist/src/store/index.js +2 -0
  97. package/dist/src/store/index.js.map +1 -1
  98. package/dist/src/ui/ModalFactory.d.ts.map +1 -1
  99. package/dist/src/ui/ModalFactory.js +1 -4
  100. package/dist/src/ui/ModalFactory.js.map +1 -1
  101. package/dist/src/ui/index.d.ts.map +1 -1
  102. package/dist/src/ui/index.js +2 -0
  103. package/dist/src/ui/index.js.map +1 -1
  104. package/dist/src/ui/index.native.d.ts.map +1 -1
  105. package/dist/src/ui/index.native.js +4 -1
  106. package/dist/src/ui/index.native.js.map +1 -1
  107. package/dist/src/ui/modals/base/AbstractInstallModal.d.ts +2 -3
  108. package/dist/src/ui/modals/base/AbstractInstallModal.d.ts.map +1 -1
  109. package/dist/src/ui/modals/base/AbstractInstallModal.js +28 -12
  110. package/dist/src/ui/modals/base/AbstractInstallModal.js.map +1 -1
  111. package/dist/src/ui/modals/base/AbstractOTPModal.d.ts +2 -2
  112. package/dist/src/ui/modals/base/AbstractOTPModal.d.ts.map +1 -1
  113. package/dist/src/ui/modals/base/AbstractOTPModal.js.map +1 -1
  114. package/dist/src/ui/modals/base/utils.d.ts +12 -0
  115. package/dist/src/ui/modals/base/utils.d.ts.map +1 -1
  116. package/dist/src/ui/modals/base/utils.js +16 -5
  117. package/dist/src/ui/modals/base/utils.js.map +1 -1
  118. package/dist/src/ui/modals/node/install.d.ts.map +1 -1
  119. package/dist/src/ui/modals/node/install.js +1 -1
  120. package/dist/src/ui/modals/node/install.js.map +1 -1
  121. package/dist/src/ui/modals/node/otp.d.ts.map +1 -1
  122. package/dist/src/ui/modals/node/otp.js +6 -2
  123. package/dist/src/ui/modals/node/otp.js.map +1 -1
  124. package/dist/src/ui/modals/rn/install.d.ts.map +1 -1
  125. package/dist/src/ui/modals/rn/install.js +7 -3
  126. package/dist/src/ui/modals/rn/install.js.map +1 -1
  127. package/dist/src/ui/modals/rn/otp.d.ts.map +1 -1
  128. package/dist/src/ui/modals/rn/otp.js +6 -2
  129. package/dist/src/ui/modals/rn/otp.js.map +1 -1
  130. package/dist/src/ui/modals/web/install.d.ts.map +1 -1
  131. package/dist/src/ui/modals/web/install.js +1 -1
  132. package/dist/src/ui/modals/web/install.js.map +1 -1
  133. package/dist/src/ui/modals/web/otp.d.ts.map +1 -1
  134. package/dist/src/ui/modals/web/otp.js +6 -2
  135. package/dist/src/ui/modals/web/otp.js.map +1 -1
  136. package/dist/types/connect-multichain.d.ts +6 -5
  137. package/package.json +3 -3
@@ -55,6 +55,14 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
55
55
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
56
56
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
57
57
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
58
+ var __privateWrapper = (obj, member, setter, getter) => ({
59
+ set _(value) {
60
+ __privateSet(obj, member, value, setter);
61
+ },
62
+ get _() {
63
+ return __privateGet(obj, member, getter);
64
+ }
65
+ });
58
66
  var __async = (__this, __arguments, generator) => {
59
67
  return new Promise((resolve, reject) => {
60
68
  var fulfilled = (value) => {
@@ -623,8 +631,9 @@ function getDappId(dapp) {
623
631
  return (_a2 = dapp.url) != null ? _a2 : dapp.name;
624
632
  }
625
633
  function openDeeplink(options, deeplink, universalLink) {
634
+ var _a2;
626
635
  const { mobile } = options;
627
- const useDeeplink = mobile && mobile.useDeeplink !== void 0 ? mobile.useDeeplink : true;
636
+ const useDeeplink = (_a2 = mobile == null ? void 0 : mobile.useDeeplink) != null ? _a2 : true;
628
637
  if (useDeeplink) {
629
638
  if (typeof window !== "undefined") {
630
639
  window.location.href = deeplink;
@@ -665,7 +674,7 @@ function setupDappMetadata(options) {
665
674
  throw new Error("You must provide dapp url");
666
675
  }
667
676
  const BASE_64_ICON_MAX_LENGTH = 163400;
668
- const urlPattern = /^(http|https):\/\/[^\s]*$/;
677
+ const urlPattern = /^(http|https):\/\/[^\s]*$/u;
669
678
  if (options.dapp) {
670
679
  if ("iconUrl" in options.dapp) {
671
680
  if (options.dapp.iconUrl && !urlPattern.test(options.dapp.iconUrl)) {
@@ -714,9 +723,12 @@ function getValidAccounts(caipAccountIds) {
714
723
  (caipAccounts, caipAccountId) => {
715
724
  try {
716
725
  return [...caipAccounts, (0, import_utils.parseCaipAccountId)(caipAccountId)];
717
- } catch (err) {
726
+ } catch (error) {
718
727
  const stringifiedAccountId = JSON.stringify(caipAccountId);
719
- console.error(`Invalid CAIP account ID: ${stringifiedAccountId}`, err);
728
+ console.error(
729
+ `Invalid CAIP account ID: ${stringifiedAccountId}`,
730
+ error
731
+ );
720
732
  return caipAccounts;
721
733
  }
722
734
  },
@@ -772,12 +784,12 @@ function addValidAccounts(optionalScopes, validAccounts) {
772
784
  }
773
785
  return result;
774
786
  }
775
- var import_pako, import_utils, extractFavicon;
787
+ var import_utils, import_pako, extractFavicon;
776
788
  var init_utils = __esm({
777
789
  "src/multichain/utils/index.ts"() {
778
790
  "use strict";
779
- import_pako = require("pako");
780
791
  import_utils = require("@metamask/utils");
792
+ import_pako = require("pako");
781
793
  init_domain();
782
794
  extractFavicon = () => {
783
795
  var _a2;
@@ -879,7 +891,9 @@ var init_domain = __esm({
879
891
 
880
892
  // src/ui/modals/base/utils.ts
881
893
  function formatRemainingTime(milliseconds) {
882
- if (milliseconds <= 0) return "EXPIRED";
894
+ if (milliseconds <= 0) {
895
+ return "EXPIRED";
896
+ }
883
897
  const seconds = Math.floor(milliseconds / 1e3);
884
898
  return `${seconds}s`;
885
899
  }
@@ -892,9 +906,8 @@ function shouldLogCountdown(remainingSeconds) {
892
906
  return remainingSeconds % 10 === 0;
893
907
  } else if (remainingSeconds <= 300) {
894
908
  return remainingSeconds % 30 === 0;
895
- } else {
896
- return remainingSeconds % 60 === 0;
897
909
  }
910
+ return remainingSeconds % 60 === 0;
898
911
  }
899
912
  var init_utils3 = __esm({
900
913
  "src/ui/modals/base/utils.ts"() {
@@ -903,18 +916,18 @@ var init_utils3 = __esm({
903
916
  });
904
917
 
905
918
  // src/ui/modals/base/AbstractInstallModal.ts
906
- var logger3, AbstractInstallModal;
919
+ var logger3, _expirationInterval, _lastLoggedCountdown, AbstractInstallModal;
907
920
  var init_AbstractInstallModal = __esm({
908
921
  "src/ui/modals/base/AbstractInstallModal.ts"() {
909
922
  "use strict";
910
- init_domain();
911
923
  init_utils3();
924
+ init_domain();
912
925
  logger3 = createLogger("metamask-sdk:ui");
913
926
  AbstractInstallModal = class extends Modal {
914
927
  constructor() {
915
928
  super(...arguments);
916
- this.expirationInterval = null;
917
- this.lastLoggedCountdown = -1;
929
+ __privateAdd(this, _expirationInterval, null);
930
+ __privateAdd(this, _lastLoggedCountdown, -1);
918
931
  }
919
932
  get link() {
920
933
  return this.data;
@@ -942,17 +955,17 @@ var init_AbstractInstallModal = __esm({
942
955
  startExpirationCheck(connectionRequest) {
943
956
  this.stopExpirationCheck();
944
957
  let currentConnectionRequest = connectionRequest;
945
- this.expirationInterval = setInterval(() => __async(this, null, function* () {
958
+ __privateSet(this, _expirationInterval, setInterval(() => __async(this, null, function* () {
946
959
  const { sessionRequest } = currentConnectionRequest;
947
960
  const now = Date.now();
948
961
  const remainingMs = sessionRequest.expiresAt - now;
949
962
  const remainingSeconds = Math.floor(remainingMs / 1e3);
950
- if (remainingMs > 0 && shouldLogCountdown(remainingSeconds) && this.lastLoggedCountdown !== remainingSeconds) {
963
+ if (remainingMs > 0 && shouldLogCountdown(remainingSeconds) && __privateGet(this, _lastLoggedCountdown) !== remainingSeconds) {
951
964
  const formattedTime = formatRemainingTime(remainingMs);
952
965
  logger3(
953
966
  `[UI: InstallModal-nodejs()] QR code expires in: ${formattedTime} (${remainingSeconds}s)`
954
967
  );
955
- this.lastLoggedCountdown = remainingSeconds;
968
+ __privateSet(this, _lastLoggedCountdown, remainingSeconds);
956
969
  }
957
970
  if (now >= sessionRequest.expiresAt) {
958
971
  this.stopExpirationCheck();
@@ -964,7 +977,7 @@ var init_AbstractInstallModal = __esm({
964
977
  const generateQRCode = yield this.options.generateQRCode(
965
978
  currentConnectionRequest
966
979
  );
967
- this.lastLoggedCountdown = -1;
980
+ __privateSet(this, _lastLoggedCountdown, -1);
968
981
  this.updateLink(generateQRCode);
969
982
  this.updateExpiresIn(remainingSeconds);
970
983
  this.renderQRCode(generateQRCode, currentConnectionRequest);
@@ -974,18 +987,20 @@ var init_AbstractInstallModal = __esm({
974
987
  );
975
988
  }
976
989
  }
977
- }), 1e3);
990
+ }), 1e3));
978
991
  }
979
992
  stopExpirationCheck() {
980
- if (this.expirationInterval) {
981
- clearInterval(this.expirationInterval);
982
- this.expirationInterval = null;
993
+ if (__privateGet(this, _expirationInterval)) {
994
+ clearInterval(__privateGet(this, _expirationInterval));
995
+ __privateSet(this, _expirationInterval, null);
983
996
  logger3(
984
997
  "[UI: InstallModal-nodejs()] \u{1F6D1} Stopped QR code expiration checking"
985
998
  );
986
999
  }
987
1000
  }
988
1001
  };
1002
+ _expirationInterval = new WeakMap();
1003
+ _lastLoggedCountdown = new WeakMap();
989
1004
  }
990
1005
  });
991
1006
 
@@ -1220,11 +1235,14 @@ module.exports = __toCommonJS(index_browser_exports);
1220
1235
 
1221
1236
  // src/polyfills/buffer-shim.ts
1222
1237
  var import_buffer = require("buffer");
1223
- var g = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {};
1224
- if (!g.Buffer) {
1225
- g.Buffer = import_buffer.Buffer;
1238
+ var globalObj = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {};
1239
+ if (!globalObj.Buffer) {
1240
+ globalObj.Buffer = import_buffer.Buffer;
1226
1241
  }
1227
1242
 
1243
+ // src/index.browser.ts
1244
+ init_domain();
1245
+
1228
1246
  // src/multichain/index.ts
1229
1247
  var import_analytics4 = require("@metamask/analytics");
1230
1248
  var import_mobile_wallet_protocol_core2 = require("@metamask/mobile-wallet-protocol-core");
@@ -1260,7 +1278,9 @@ var RpcClient = class {
1260
1278
  }
1261
1279
  /**
1262
1280
  * Routes the request to a configured RPC node.
1263
- * @param options - The invoke method options
1281
+ *
1282
+ * @param options - The invoke method options.
1283
+ * @returns The JSON response from the RPC node.
1264
1284
  */
1265
1285
  request(options) {
1266
1286
  return __async(this, null, function* () {
@@ -1272,7 +1292,13 @@ var RpcClient = class {
1272
1292
  id: getNextRpcId()
1273
1293
  });
1274
1294
  const rpcEndpoint = this.getRpcEndpoint(options.scope);
1275
- const rpcRequest = yield this.fetchWithTimeout(rpcEndpoint, body, "POST", this.getHeaders(rpcEndpoint), 3e4);
1295
+ const rpcRequest = yield this.fetchWithTimeout(
1296
+ rpcEndpoint,
1297
+ body,
1298
+ "POST",
1299
+ this.getHeaders(rpcEndpoint),
1300
+ 3e4
1301
+ );
1276
1302
  const response = yield this.parseResponse(rpcRequest);
1277
1303
  return response;
1278
1304
  });
@@ -1282,7 +1308,9 @@ var RpcClient = class {
1282
1308
  const supportedNetworks = (_c = (_b = (_a2 = this.config) == null ? void 0 : _a2.api) == null ? void 0 : _b.supportedNetworks) != null ? _c : {};
1283
1309
  const rpcEndpoint = supportedNetworks[scope];
1284
1310
  if (!rpcEndpoint) {
1285
- throw new MissingRpcEndpointErr(`No RPC endpoint found for scope ${scope}`);
1311
+ throw new MissingRpcEndpointErr(
1312
+ `No RPC endpoint found for scope ${scope}`
1313
+ );
1286
1314
  }
1287
1315
  return rpcEndpoint;
1288
1316
  }
@@ -1310,7 +1338,7 @@ var RpcClient = class {
1310
1338
  if (error instanceof Error && error.name === "AbortError") {
1311
1339
  throw new RPCReadonlyRequestErr(`Request timeout after ${timeout}ms`);
1312
1340
  }
1313
- throw new RPCReadonlyRequestErr(error instanceof Error ? error.message : "Unknown error");
1341
+ throw new RPCReadonlyRequestErr(error.message);
1314
1342
  }
1315
1343
  });
1316
1344
  }
@@ -1355,10 +1383,12 @@ var RequestRouter = class {
1355
1383
  * The main entry point for invoking an RPC method.
1356
1384
  * This method acts as a router, determining the correct handling strategy
1357
1385
  * for the request and delegating to the appropriate private handler.
1386
+ *
1387
+ * @param options
1358
1388
  */
1359
1389
  invokeMethod(options) {
1360
1390
  return __async(this, null, function* () {
1361
- const method = options.request.method;
1391
+ const { method } = options.request;
1362
1392
  if (RPC_HANDLED_METHODS.has(method)) {
1363
1393
  return this.handleWithRpcNode(options);
1364
1394
  }
@@ -1370,6 +1400,8 @@ var RequestRouter = class {
1370
1400
  }
1371
1401
  /**
1372
1402
  * Forwards the request directly to the wallet via the transport.
1403
+ *
1404
+ * @param options
1373
1405
  */
1374
1406
  handleWithWallet(options) {
1375
1407
  return __async(this, null, function* () {
@@ -1398,7 +1430,10 @@ var RequestRouter = class {
1398
1430
  }
1399
1431
  const response = yield request;
1400
1432
  if (response.error) {
1401
- throw new RPCInvokeMethodErr(`RPC Request failed with code ${response.error.code}: ${response.error.message}`);
1433
+ const { error } = response;
1434
+ throw new RPCInvokeMethodErr(
1435
+ `RPC Request failed with code ${error.code}: ${error.message}`
1436
+ );
1402
1437
  }
1403
1438
  return response.result;
1404
1439
  }));
@@ -1406,6 +1441,8 @@ var RequestRouter = class {
1406
1441
  }
1407
1442
  /**
1408
1443
  * Routes the request to a configured RPC node.
1444
+ *
1445
+ * @param options
1409
1446
  */
1410
1447
  handleWithRpcNode(options) {
1411
1448
  return __async(this, null, function* () {
@@ -1423,10 +1460,14 @@ var RequestRouter = class {
1423
1460
  }
1424
1461
  /**
1425
1462
  * Responds directly from the SDK's session state.
1463
+ *
1464
+ * @param options
1426
1465
  */
1427
1466
  handleWithSdkState(options) {
1428
1467
  return __async(this, null, function* () {
1429
- console.warn(`Method "${options.request.method}" is configured for SDK state handling, but this is not yet implemented. Falling back to wallet passthrough.`);
1468
+ console.warn(
1469
+ `Method "${options.request.method}" is configured for SDK state handling, but this is not yet implemented. Falling back to wallet passthrough.`
1470
+ );
1430
1471
  return this.handleWithWallet(options);
1431
1472
  });
1432
1473
  }
@@ -1446,31 +1487,50 @@ withAnalyticsTracking_fn = function(options, execute) {
1446
1487
  } else {
1447
1488
  yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options);
1448
1489
  }
1490
+ if (error instanceof RPCInvokeMethodErr) {
1491
+ throw error;
1492
+ }
1449
1493
  throw new RPCInvokeMethodErr(error.message);
1450
1494
  }
1451
1495
  });
1452
1496
  };
1453
1497
  trackWalletActionRequested_fn = function(options) {
1454
1498
  return __async(this, null, function* () {
1455
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1499
+ const props = yield getWalletActionAnalyticsProperties(
1500
+ this.config,
1501
+ this.config.storage,
1502
+ options
1503
+ );
1456
1504
  import_analytics2.analytics.track("mmconnect_wallet_action_requested", props);
1457
1505
  });
1458
1506
  };
1459
1507
  trackWalletActionSucceeded_fn = function(options) {
1460
1508
  return __async(this, null, function* () {
1461
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1509
+ const props = yield getWalletActionAnalyticsProperties(
1510
+ this.config,
1511
+ this.config.storage,
1512
+ options
1513
+ );
1462
1514
  import_analytics2.analytics.track("mmconnect_wallet_action_succeeded", props);
1463
1515
  });
1464
1516
  };
1465
1517
  trackWalletActionFailed_fn = function(options) {
1466
1518
  return __async(this, null, function* () {
1467
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1519
+ const props = yield getWalletActionAnalyticsProperties(
1520
+ this.config,
1521
+ this.config.storage,
1522
+ options
1523
+ );
1468
1524
  import_analytics2.analytics.track("mmconnect_wallet_action_failed", props);
1469
1525
  });
1470
1526
  };
1471
1527
  trackWalletActionRejected_fn = function(options) {
1472
1528
  return __async(this, null, function* () {
1473
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1529
+ const props = yield getWalletActionAnalyticsProperties(
1530
+ this.config,
1531
+ this.config.storage,
1532
+ options
1533
+ );
1474
1534
  import_analytics2.analytics.track("mmconnect_wallet_action_rejected", props);
1475
1535
  });
1476
1536
  };
@@ -1532,7 +1592,7 @@ var DefaultTransport = class {
1532
1592
  }
1533
1593
  connect(options) {
1534
1594
  return __async(this, null, function* () {
1535
- var _a2, _b, _c, _d, _e, _f, _g;
1595
+ var _a2, _b, _c, _d, _e;
1536
1596
  __privateMethod(this, _DefaultTransport_instances, setupMessageListener_fn).call(this);
1537
1597
  yield __privateGet(this, _transport).connect();
1538
1598
  const sessionRequest = yield this.request(
@@ -1543,12 +1603,19 @@ var DefaultTransport = class {
1543
1603
  throw new Error(sessionRequest.error.message);
1544
1604
  }
1545
1605
  let walletSession = sessionRequest.result;
1606
+ const createSessionParams = {
1607
+ optionalScopes: addValidAccounts(
1608
+ getOptionalScopes((_a2 = options == null ? void 0 : options.scopes) != null ? _a2 : []),
1609
+ getValidAccounts((_b = options == null ? void 0 : options.caipAccountIds) != null ? _b : [])
1610
+ ),
1611
+ sessionProperties: options == null ? void 0 : options.sessionProperties
1612
+ };
1546
1613
  if (walletSession && options && !options.forceRequest) {
1547
1614
  const currentScopes = Object.keys(
1548
- (_a2 = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _a2 : {}
1615
+ (_c = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _c : {}
1549
1616
  );
1550
- const proposedScopes = (_b = options == null ? void 0 : options.scopes) != null ? _b : [];
1551
- const proposedCaipAccountIds = (_c = options == null ? void 0 : options.caipAccountIds) != null ? _c : [];
1617
+ const proposedScopes = (_d = options == null ? void 0 : options.scopes) != null ? _d : [];
1618
+ const proposedCaipAccountIds = (_e = options == null ? void 0 : options.caipAccountIds) != null ? _e : [];
1552
1619
  const hasSameScopesAndAccounts = isSameScopesAndAccounts(
1553
1620
  currentScopes,
1554
1621
  proposedScopes,
@@ -1560,13 +1627,6 @@ var DefaultTransport = class {
1560
1627
  { method: "wallet_revokeSession", params: walletSession },
1561
1628
  __privateGet(this, _defaultRequestOptions)
1562
1629
  );
1563
- const optionalScopes = addValidAccounts(
1564
- getOptionalScopes((_d = options == null ? void 0 : options.scopes) != null ? _d : []),
1565
- getValidAccounts((_e = options == null ? void 0 : options.caipAccountIds) != null ? _e : [])
1566
- );
1567
- const createSessionParams = {
1568
- optionalScopes
1569
- };
1570
1630
  const response = yield this.request(
1571
1631
  { method: "wallet_createSession", params: createSessionParams },
1572
1632
  __privateGet(this, _defaultRequestOptions)
@@ -1577,14 +1637,6 @@ var DefaultTransport = class {
1577
1637
  walletSession = response.result;
1578
1638
  }
1579
1639
  } else if (!walletSession || (options == null ? void 0 : options.forceRequest)) {
1580
- const optionalScopes = addValidAccounts(
1581
- getOptionalScopes((_f = options == null ? void 0 : options.scopes) != null ? _f : []),
1582
- getValidAccounts((_g = options == null ? void 0 : options.caipAccountIds) != null ? _g : [])
1583
- );
1584
- const createSessionParams = {
1585
- optionalScopes,
1586
- sessionProperties: options == null ? void 0 : options.sessionProperties
1587
- };
1588
1640
  const response = yield this.request(
1589
1641
  { method: "wallet_createSession", params: createSessionParams },
1590
1642
  __privateGet(this, _defaultRequestOptions)
@@ -1636,7 +1688,11 @@ var DefaultTransport = class {
1636
1688
  };
1637
1689
  }
1638
1690
  getActiveSession() {
1639
- throw new Error("getActiveSession is purposely not implemented for the DefaultTransport");
1691
+ return __async(this, null, function* () {
1692
+ throw new Error(
1693
+ "getActiveSession is purposely not implemented for the DefaultTransport"
1694
+ );
1695
+ });
1640
1696
  }
1641
1697
  };
1642
1698
  _notificationCallbacks = new WeakMap();
@@ -1710,6 +1766,164 @@ setupMessageListener_fn = function() {
1710
1766
  window.addEventListener("message", __privateGet(this, _handleNotificationListener));
1711
1767
  };
1712
1768
 
1769
+ // src/multichain/transports/multichainApiClientWrapper/index.ts
1770
+ var import_rpc_errors = require("@metamask/rpc-errors");
1771
+ var MAX = 4294967295;
1772
+ var idCounter = Math.floor(Math.random() * MAX);
1773
+ var getUniqueId = () => {
1774
+ idCounter = (idCounter + 1) % MAX;
1775
+ return idCounter;
1776
+ };
1777
+ var _requestId, _notificationCallbacks2, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn, walletGetSession_fn, walletRevokeSession_fn, walletInvokeMethod_fn;
1778
+ var MultichainApiClientWrapperTransport = class {
1779
+ constructor(metamaskConnectMultichain) {
1780
+ this.metamaskConnectMultichain = metamaskConnectMultichain;
1781
+ __privateAdd(this, _MultichainApiClientWrapperTransport_instances);
1782
+ __privateAdd(this, _requestId, getUniqueId());
1783
+ __privateAdd(this, _notificationCallbacks2, /* @__PURE__ */ new Set());
1784
+ }
1785
+ isTransportDefined() {
1786
+ try {
1787
+ return Boolean(this.metamaskConnectMultichain.transport);
1788
+ } catch (_error) {
1789
+ return false;
1790
+ }
1791
+ }
1792
+ clearNotificationCallbacks() {
1793
+ __privateGet(this, _notificationCallbacks2).clear();
1794
+ }
1795
+ notifyCallbacks(data) {
1796
+ __privateGet(this, _notificationCallbacks2).forEach((callback) => {
1797
+ callback(data);
1798
+ });
1799
+ }
1800
+ setupNotifcationListener() {
1801
+ this.metamaskConnectMultichain.transport.onNotification(
1802
+ this.notifyCallbacks.bind(this)
1803
+ );
1804
+ }
1805
+ connect() {
1806
+ return __async(this, null, function* () {
1807
+ console.log("\u{1F4DA} connect");
1808
+ return Promise.resolve();
1809
+ });
1810
+ }
1811
+ disconnect() {
1812
+ return __async(this, null, function* () {
1813
+ return Promise.resolve();
1814
+ });
1815
+ }
1816
+ isConnected() {
1817
+ return true;
1818
+ }
1819
+ request(_0) {
1820
+ return __async(this, arguments, function* (params, _options = {}) {
1821
+ const id = __privateWrapper(this, _requestId)._++;
1822
+ const requestPayload = __spreadValues({
1823
+ id,
1824
+ jsonrpc: "2.0"
1825
+ }, params);
1826
+ switch (requestPayload.method) {
1827
+ case "wallet_createSession":
1828
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn).call(this, requestPayload);
1829
+ case "wallet_getSession":
1830
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletGetSession_fn).call(this, requestPayload);
1831
+ case "wallet_revokeSession":
1832
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletRevokeSession_fn).call(this, requestPayload);
1833
+ case "wallet_invokeMethod":
1834
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletInvokeMethod_fn).call(this, requestPayload);
1835
+ default:
1836
+ throw new Error(`Unsupported method: ${requestPayload.method}`);
1837
+ }
1838
+ throw new Error(`Unknown method: ${requestPayload.method}`);
1839
+ });
1840
+ }
1841
+ onNotification(callback) {
1842
+ if (!this.isTransportDefined()) {
1843
+ __privateGet(this, _notificationCallbacks2).add(callback);
1844
+ return () => {
1845
+ __privateGet(this, _notificationCallbacks2).delete(callback);
1846
+ };
1847
+ }
1848
+ return this.metamaskConnectMultichain.transport.onNotification(callback);
1849
+ }
1850
+ };
1851
+ _requestId = new WeakMap();
1852
+ _notificationCallbacks2 = new WeakMap();
1853
+ _MultichainApiClientWrapperTransport_instances = new WeakSet();
1854
+ walletCreateSession_fn = function(request) {
1855
+ return __async(this, null, function* () {
1856
+ console.log("\u{1F4DA} #walletCreateSession", request);
1857
+ const createSessionParams = request.params;
1858
+ const scopes = Object.keys(__spreadValues(__spreadValues({}, createSessionParams.optionalScopes), createSessionParams.requiredScopes));
1859
+ const scopeAccounts = [];
1860
+ scopes.forEach((scope) => {
1861
+ var _a2, _b, _c, _d;
1862
+ const requiredScope = (_a2 = createSessionParams.requiredScopes) == null ? void 0 : _a2[scope];
1863
+ const optionalScope = (_b = createSessionParams.optionalScopes) == null ? void 0 : _b[scope];
1864
+ if (requiredScope) {
1865
+ scopeAccounts.push(...(_c = requiredScope.accounts) != null ? _c : []);
1866
+ }
1867
+ if (optionalScope) {
1868
+ scopeAccounts.push(...(_d = optionalScope.accounts) != null ? _d : []);
1869
+ }
1870
+ });
1871
+ const accounts = [...new Set(scopeAccounts)];
1872
+ console.log("\u{1F4DA} SDK connect");
1873
+ yield this.metamaskConnectMultichain.connect(
1874
+ scopes,
1875
+ accounts,
1876
+ createSessionParams.sessionProperties
1877
+ );
1878
+ console.log("\u{1F4DA} SDK connected");
1879
+ return this.metamaskConnectMultichain.transport.request({
1880
+ method: "wallet_getSession"
1881
+ });
1882
+ });
1883
+ };
1884
+ walletGetSession_fn = function(request) {
1885
+ return __async(this, null, function* () {
1886
+ if (!this.isTransportDefined()) {
1887
+ return {
1888
+ jsonrpc: "2.0",
1889
+ id: request.id,
1890
+ result: {
1891
+ sessionScopes: {}
1892
+ }
1893
+ };
1894
+ }
1895
+ return this.metamaskConnectMultichain.transport.request({
1896
+ method: "wallet_getSession"
1897
+ });
1898
+ });
1899
+ };
1900
+ walletRevokeSession_fn = function(request) {
1901
+ return __async(this, null, function* () {
1902
+ if (!this.isTransportDefined()) {
1903
+ return { jsonrpc: "2.0", id: request.id, result: true };
1904
+ }
1905
+ try {
1906
+ this.metamaskConnectMultichain.disconnect();
1907
+ return { jsonrpc: "2.0", id: request.id, result: true };
1908
+ } catch (_error) {
1909
+ return { jsonrpc: "2.0", id: request.id, result: false };
1910
+ }
1911
+ });
1912
+ };
1913
+ walletInvokeMethod_fn = function(request) {
1914
+ return __async(this, null, function* () {
1915
+ if (!this.isTransportDefined()) {
1916
+ return { error: import_rpc_errors.providerErrors.unauthorized() };
1917
+ }
1918
+ const result = this.metamaskConnectMultichain.invokeMethod(
1919
+ request.params
1920
+ );
1921
+ return {
1922
+ result
1923
+ };
1924
+ });
1925
+ };
1926
+
1713
1927
  // src/multichain/transports/mwp/index.ts
1714
1928
  var import_mobile_wallet_protocol_core = require("@metamask/mobile-wallet-protocol-core");
1715
1929
  var import_multichain_api_client2 = require("@metamask/multichain-api-client");
@@ -2269,164 +2483,6 @@ var keymanager = new KeyManager();
2269
2483
 
2270
2484
  // src/multichain/index.ts
2271
2485
  init_utils();
2272
-
2273
- // src/multichain/transports/multichainApiClientWrapper/index.ts
2274
- var import_rpc_errors = require("@metamask/rpc-errors");
2275
- var MAX = 4294967295;
2276
- var idCounter = Math.floor(Math.random() * MAX);
2277
- var getUniqueId = () => {
2278
- idCounter = (idCounter + 1) % MAX;
2279
- return idCounter;
2280
- };
2281
- var _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn, walletGetSession_fn, walletRevokeSession_fn, walletInvokeMethod_fn;
2282
- var MultichainApiClientWrapperTransport = class {
2283
- constructor(metamaskConnectMultichain) {
2284
- this.metamaskConnectMultichain = metamaskConnectMultichain;
2285
- __privateAdd(this, _MultichainApiClientWrapperTransport_instances);
2286
- this.requestId = getUniqueId();
2287
- this.notificationCallbacks = /* @__PURE__ */ new Set();
2288
- }
2289
- isTransportDefined() {
2290
- try {
2291
- return Boolean(this.metamaskConnectMultichain.transport);
2292
- } catch (error) {
2293
- return false;
2294
- }
2295
- }
2296
- clearNotificationCallbacks() {
2297
- this.notificationCallbacks.clear();
2298
- }
2299
- notifyCallbacks(data) {
2300
- this.notificationCallbacks.forEach((callback) => {
2301
- callback(data);
2302
- });
2303
- }
2304
- setupNotifcationListener() {
2305
- this.metamaskConnectMultichain.transport.onNotification(
2306
- this.notifyCallbacks.bind(this)
2307
- );
2308
- }
2309
- connect() {
2310
- return __async(this, null, function* () {
2311
- console.log("\u{1F4DA} connect");
2312
- return Promise.resolve();
2313
- });
2314
- }
2315
- disconnect() {
2316
- return __async(this, null, function* () {
2317
- return Promise.resolve();
2318
- });
2319
- }
2320
- isConnected() {
2321
- return true;
2322
- }
2323
- request(_0) {
2324
- return __async(this, arguments, function* (params, _options = {}) {
2325
- const id = this.requestId++;
2326
- const requestPayload = __spreadValues({
2327
- id,
2328
- jsonrpc: "2.0"
2329
- }, params);
2330
- switch (requestPayload.method) {
2331
- case "wallet_createSession":
2332
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn).call(this, requestPayload);
2333
- case "wallet_getSession":
2334
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletGetSession_fn).call(this, requestPayload);
2335
- case "wallet_revokeSession":
2336
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletRevokeSession_fn).call(this, requestPayload);
2337
- case "wallet_invokeMethod":
2338
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletInvokeMethod_fn).call(this, requestPayload);
2339
- default:
2340
- throw new Error(`Unsupported method: ${requestPayload.method}`);
2341
- }
2342
- throw new Error(`Unknown method: ${requestPayload.method}`);
2343
- });
2344
- }
2345
- onNotification(callback) {
2346
- if (!this.isTransportDefined()) {
2347
- this.notificationCallbacks.add(callback);
2348
- return () => {
2349
- this.notificationCallbacks.delete(callback);
2350
- };
2351
- }
2352
- return this.metamaskConnectMultichain.transport.onNotification(callback);
2353
- }
2354
- };
2355
- _MultichainApiClientWrapperTransport_instances = new WeakSet();
2356
- walletCreateSession_fn = function(request) {
2357
- return __async(this, null, function* () {
2358
- console.log("\u{1F4DA} #walletCreateSession", request);
2359
- const createSessionParams = request.params;
2360
- const scopes = Object.keys(__spreadValues(__spreadValues({}, createSessionParams.optionalScopes), createSessionParams.requiredScopes));
2361
- const scopeAccounts = [];
2362
- scopes.forEach((scope) => {
2363
- var _a2, _b, _c, _d;
2364
- const requiredScope = (_a2 = createSessionParams.requiredScopes) == null ? void 0 : _a2[scope];
2365
- const optionalScope = (_b = createSessionParams.optionalScopes) == null ? void 0 : _b[scope];
2366
- if (requiredScope) {
2367
- scopeAccounts.push(...(_c = requiredScope.accounts) != null ? _c : []);
2368
- }
2369
- if (optionalScope) {
2370
- scopeAccounts.push(...(_d = optionalScope.accounts) != null ? _d : []);
2371
- }
2372
- });
2373
- const accounts = [...new Set(scopeAccounts)];
2374
- console.log("\u{1F4DA} SDK connect");
2375
- yield this.metamaskConnectMultichain.connect(
2376
- scopes,
2377
- accounts,
2378
- createSessionParams.sessionProperties
2379
- );
2380
- console.log("\u{1F4DA} SDK connected");
2381
- return this.metamaskConnectMultichain.transport.request({
2382
- method: "wallet_getSession"
2383
- });
2384
- });
2385
- };
2386
- walletGetSession_fn = function(request) {
2387
- return __async(this, null, function* () {
2388
- if (!this.isTransportDefined()) {
2389
- return {
2390
- jsonrpc: "2.0",
2391
- id: request.id,
2392
- result: {
2393
- sessionScopes: {}
2394
- }
2395
- };
2396
- }
2397
- return this.metamaskConnectMultichain.transport.request({
2398
- method: "wallet_getSession"
2399
- });
2400
- });
2401
- };
2402
- walletRevokeSession_fn = function(request) {
2403
- return __async(this, null, function* () {
2404
- if (!this.isTransportDefined()) {
2405
- return { jsonrpc: "2.0", id: request.id, result: true };
2406
- }
2407
- try {
2408
- this.metamaskConnectMultichain.disconnect();
2409
- return { jsonrpc: "2.0", id: request.id, result: true };
2410
- } catch (error) {
2411
- return { jsonrpc: "2.0", id: request.id, result: false };
2412
- }
2413
- });
2414
- };
2415
- walletInvokeMethod_fn = function(request) {
2416
- return __async(this, null, function* () {
2417
- if (!this.isTransportDefined()) {
2418
- return { error: import_rpc_errors.providerErrors.unauthorized() };
2419
- }
2420
- const result = this.metamaskConnectMultichain.invokeMethod(
2421
- request.params
2422
- );
2423
- return {
2424
- result
2425
- };
2426
- });
2427
- };
2428
-
2429
- // src/multichain/index.ts
2430
2486
  var logger2 = createLogger("metamask-sdk:core");
2431
2487
  var _a, _provider, _providerTransportWrapper, _transport2, _dappClient, _beforeUnloadListener, _listener, _sdkInfo, _MetaMaskConnectMultichain_instances, setupAnalytics_fn, onTransportNotification_fn, getStoredTransport_fn, setupTransport_fn, init_fn, createDappClient_fn, setupMWP_fn, onBeforeUnload_fn, createBeforeUnloadListener_fn, renderInstallModalAsync_fn, showInstallModal_fn, headlessConnect_fn, setupDefaultTransport_fn, deeplinkConnect_fn, handleConnection_fn;
2432
2488
  var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends MultichainCore {
@@ -2454,8 +2510,12 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2454
2510
  this._status = "pending";
2455
2511
  __privateAdd(this, _listener);
2456
2512
  __privateAdd(this, _sdkInfo, `Sdk/Javascript SdkVersion/${getVersion()} Platform/${getPlatformType()} dApp/${(_a = this.options.dapp.url) != null ? _a : this.options.dapp.name} dAppTitle/${this.options.dapp.name}`);
2457
- __privateSet(this, _providerTransportWrapper, new MultichainApiClientWrapperTransport(this));
2458
- __privateSet(this, _provider, (0, import_multichain_api_client3.getMultichainClient)({ transport: __privateGet(this, _providerTransportWrapper) }));
2513
+ __privateSet(this, _providerTransportWrapper, new MultichainApiClientWrapperTransport(
2514
+ this
2515
+ ));
2516
+ __privateSet(this, _provider, (0, import_multichain_api_client3.getMultichainClient)({
2517
+ transport: __privateGet(this, _providerTransportWrapper)
2518
+ }));
2459
2519
  }
2460
2520
  get status() {
2461
2521
  return this._status;
@@ -2539,8 +2599,14 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2539
2599
  } catch (error) {
2540
2600
  logger2("Error tracking connection_initiated event", error);
2541
2601
  }
2602
+ const nonEmptySessionProperites = Object.keys(sessionProperties != null ? sessionProperties : {}).length > 0 ? sessionProperties : void 0;
2542
2603
  if (((_a2 = __privateGet(this, _transport2)) == null ? void 0 : _a2.isConnected()) && !secure) {
2543
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateGet(this, _transport2).connect({ scopes, caipAccountIds, sessionProperties, forceRequest }).then(() => __async(this, null, function* () {
2604
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateGet(this, _transport2).connect({
2605
+ scopes,
2606
+ caipAccountIds,
2607
+ sessionProperties: nonEmptySessionProperites,
2608
+ forceRequest
2609
+ }).then(() => __async(this, null, function* () {
2544
2610
  if (__privateGet(this, _transport2) instanceof MWPTransport) {
2545
2611
  return this.storage.setTransport("mwp" /* MWP */);
2546
2612
  }
@@ -2549,18 +2615,28 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2549
2615
  }
2550
2616
  if (platformType === "in-app-browser" /* MetaMaskMobileWebview */) {
2551
2617
  const defaultTransport = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupDefaultTransport_fn).call(this);
2552
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
2618
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({
2619
+ scopes,
2620
+ caipAccountIds,
2621
+ sessionProperties: nonEmptySessionProperites,
2622
+ forceRequest
2623
+ }), scopes, transportType);
2553
2624
  }
2554
2625
  if (isWeb && hasExtensionInstalled && preferExtension) {
2555
2626
  const defaultTransport = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupDefaultTransport_fn).call(this);
2556
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
2627
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({
2628
+ scopes,
2629
+ caipAccountIds,
2630
+ sessionProperties: nonEmptySessionProperites,
2631
+ forceRequest
2632
+ }), scopes, transportType);
2557
2633
  }
2558
2634
  yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupMWP_fn).call(this);
2559
2635
  const shouldShowInstallModal = hasExtensionInstalled ? showInstallModal : !preferExtension || showInstallModal;
2560
2636
  if (secure && !shouldShowInstallModal) {
2561
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, deeplinkConnect_fn).call(this, scopes, caipAccountIds, sessionProperties), scopes, transportType);
2637
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, deeplinkConnect_fn).call(this, scopes, caipAccountIds, nonEmptySessionProperites), scopes, transportType);
2562
2638
  }
2563
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, showInstallModal_fn).call(this, shouldShowInstallModal, scopes, caipAccountIds, sessionProperties), scopes, transportType);
2639
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, showInstallModal_fn).call(this, shouldShowInstallModal, scopes, caipAccountIds, nonEmptySessionProperites), scopes, transportType);
2564
2640
  });
2565
2641
  }
2566
2642
  emit(event, args) {
@@ -2815,7 +2891,11 @@ renderInstallModalAsync_fn = function(desktopPreferred, scopes, caipAccountIds,
2815
2891
  (() => __async(this, null, function* () {
2816
2892
  var _a2;
2817
2893
  try {
2818
- yield this.transport.connect({ scopes, caipAccountIds, sessionProperties });
2894
+ yield this.transport.connect({
2895
+ scopes,
2896
+ caipAccountIds,
2897
+ sessionProperties
2898
+ });
2819
2899
  yield this.options.ui.factory.unload();
2820
2900
  (_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.unmount();
2821
2901
  this.status = "connected";
@@ -2923,7 +3003,7 @@ setupDefaultTransport_fn = function() {
2923
3003
  };
2924
3004
  deeplinkConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
2925
3005
  return __async(this, null, function* () {
2926
- return new Promise((resolve, reject) => {
3006
+ return new Promise((resolve, reject) => __async(this, null, function* () {
2927
3007
  const dappClientMessageHandler = (payload) => {
2928
3008
  var _a2;
2929
3009
  if (typeof payload !== "object" || payload === null || !("data" in payload)) {
@@ -2982,7 +3062,7 @@ deeplinkConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
2982
3062
  clearTimeout(timeout);
2983
3063
  }
2984
3064
  });
2985
- });
3065
+ }));
2986
3066
  });
2987
3067
  };
2988
3068
  handleConnection_fn = function(promise, scopes, transportType) {
@@ -3275,7 +3355,9 @@ var BaseModalFactory = class {
3275
3355
  }
3276
3356
  createConnectionDeeplink(connectionRequest) {
3277
3357
  if (!connectionRequest) {
3278
- throw new Error("createConnectionDeeplink can only be called with a connection request");
3358
+ throw new Error(
3359
+ "createConnectionDeeplink can only be called with a connection request"
3360
+ );
3279
3361
  }
3280
3362
  const json = JSON.stringify(connectionRequest);
3281
3363
  const compressed = compressString(json);
@@ -3381,14 +3463,17 @@ var ModalFactory = class extends BaseModalFactory {
3381
3463
  // src/index.browser.ts
3382
3464
  init_domain();
3383
3465
  var createMultichainClient = (options) => __async(null, null, function* () {
3466
+ if (options.debug) {
3467
+ enableDebug("metamask-sdk:*");
3468
+ }
3384
3469
  const uiModules = yield Promise.resolve().then(() => (init_web(), web_exports));
3385
3470
  let storage;
3386
- if (!options.storage) {
3471
+ if (options.storage) {
3472
+ storage = options.storage;
3473
+ } else {
3387
3474
  const { StoreAdapterWeb: StoreAdapterWeb2 } = yield Promise.resolve().then(() => (init_web2(), web_exports2));
3388
3475
  const adapter = new StoreAdapterWeb2();
3389
3476
  storage = new Store(adapter);
3390
- } else {
3391
- storage = options.storage;
3392
3477
  }
3393
3478
  const factory = new ModalFactory(uiModules);
3394
3479
  return MetaMaskConnectMultichain.create(__spreadProps(__spreadValues({}, options), {