@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
@@ -34,6 +34,14 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
34
34
  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);
35
35
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
36
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
37
+ var __privateWrapper = (obj, member, setter, getter) => ({
38
+ set _(value) {
39
+ __privateSet(obj, member, value, setter);
40
+ },
41
+ get _() {
42
+ return __privateGet(obj, member, getter);
43
+ }
44
+ });
37
45
  var __async = (__this, __arguments, generator) => {
38
46
  return new Promise((resolve, reject) => {
39
47
  var fulfilled = (value) => {
@@ -584,11 +592,11 @@ var init_ui = __esm({
584
592
  });
585
593
 
586
594
  // src/multichain/utils/index.ts
587
- import { deflate } from "pako";
588
595
  import {
589
596
  parseCaipAccountId,
590
597
  parseCaipChainId
591
598
  } from "@metamask/utils";
599
+ import { deflate } from "pako";
592
600
  function base64Encode(str) {
593
601
  if (typeof btoa !== "undefined") {
594
602
  return btoa(str);
@@ -607,8 +615,9 @@ function getDappId(dapp) {
607
615
  return (_a2 = dapp.url) != null ? _a2 : dapp.name;
608
616
  }
609
617
  function openDeeplink(options, deeplink, universalLink) {
618
+ var _a2;
610
619
  const { mobile } = options;
611
- const useDeeplink = mobile && mobile.useDeeplink !== void 0 ? mobile.useDeeplink : true;
620
+ const useDeeplink = (_a2 = mobile == null ? void 0 : mobile.useDeeplink) != null ? _a2 : true;
612
621
  if (useDeeplink) {
613
622
  if (typeof window !== "undefined") {
614
623
  window.location.href = deeplink;
@@ -649,7 +658,7 @@ function setupDappMetadata(options) {
649
658
  throw new Error("You must provide dapp url");
650
659
  }
651
660
  const BASE_64_ICON_MAX_LENGTH = 163400;
652
- const urlPattern = /^(http|https):\/\/[^\s]*$/;
661
+ const urlPattern = /^(http|https):\/\/[^\s]*$/u;
653
662
  if (options.dapp) {
654
663
  if ("iconUrl" in options.dapp) {
655
664
  if (options.dapp.iconUrl && !urlPattern.test(options.dapp.iconUrl)) {
@@ -698,9 +707,12 @@ function getValidAccounts(caipAccountIds) {
698
707
  (caipAccounts, caipAccountId) => {
699
708
  try {
700
709
  return [...caipAccounts, parseCaipAccountId(caipAccountId)];
701
- } catch (err) {
710
+ } catch (error) {
702
711
  const stringifiedAccountId = JSON.stringify(caipAccountId);
703
- console.error(`Invalid CAIP account ID: ${stringifiedAccountId}`, err);
712
+ console.error(
713
+ `Invalid CAIP account ID: ${stringifiedAccountId}`,
714
+ error
715
+ );
704
716
  return caipAccounts;
705
717
  }
706
718
  },
@@ -861,7 +873,9 @@ var init_domain = __esm({
861
873
 
862
874
  // src/ui/modals/base/utils.ts
863
875
  function formatRemainingTime(milliseconds) {
864
- if (milliseconds <= 0) return "EXPIRED";
876
+ if (milliseconds <= 0) {
877
+ return "EXPIRED";
878
+ }
865
879
  const seconds = Math.floor(milliseconds / 1e3);
866
880
  return `${seconds}s`;
867
881
  }
@@ -874,9 +888,8 @@ function shouldLogCountdown(remainingSeconds) {
874
888
  return remainingSeconds % 10 === 0;
875
889
  } else if (remainingSeconds <= 300) {
876
890
  return remainingSeconds % 30 === 0;
877
- } else {
878
- return remainingSeconds % 60 === 0;
879
891
  }
892
+ return remainingSeconds % 60 === 0;
880
893
  }
881
894
  var init_utils3 = __esm({
882
895
  "src/ui/modals/base/utils.ts"() {
@@ -885,18 +898,18 @@ var init_utils3 = __esm({
885
898
  });
886
899
 
887
900
  // src/ui/modals/base/AbstractInstallModal.ts
888
- var logger3, AbstractInstallModal;
901
+ var logger3, _expirationInterval, _lastLoggedCountdown, AbstractInstallModal;
889
902
  var init_AbstractInstallModal = __esm({
890
903
  "src/ui/modals/base/AbstractInstallModal.ts"() {
891
904
  "use strict";
892
- init_domain();
893
905
  init_utils3();
906
+ init_domain();
894
907
  logger3 = createLogger("metamask-sdk:ui");
895
908
  AbstractInstallModal = class extends Modal {
896
909
  constructor() {
897
910
  super(...arguments);
898
- this.expirationInterval = null;
899
- this.lastLoggedCountdown = -1;
911
+ __privateAdd(this, _expirationInterval, null);
912
+ __privateAdd(this, _lastLoggedCountdown, -1);
900
913
  }
901
914
  get link() {
902
915
  return this.data;
@@ -924,17 +937,17 @@ var init_AbstractInstallModal = __esm({
924
937
  startExpirationCheck(connectionRequest) {
925
938
  this.stopExpirationCheck();
926
939
  let currentConnectionRequest = connectionRequest;
927
- this.expirationInterval = setInterval(() => __async(this, null, function* () {
940
+ __privateSet(this, _expirationInterval, setInterval(() => __async(this, null, function* () {
928
941
  const { sessionRequest } = currentConnectionRequest;
929
942
  const now = Date.now();
930
943
  const remainingMs = sessionRequest.expiresAt - now;
931
944
  const remainingSeconds = Math.floor(remainingMs / 1e3);
932
- if (remainingMs > 0 && shouldLogCountdown(remainingSeconds) && this.lastLoggedCountdown !== remainingSeconds) {
945
+ if (remainingMs > 0 && shouldLogCountdown(remainingSeconds) && __privateGet(this, _lastLoggedCountdown) !== remainingSeconds) {
933
946
  const formattedTime = formatRemainingTime(remainingMs);
934
947
  logger3(
935
948
  `[UI: InstallModal-nodejs()] QR code expires in: ${formattedTime} (${remainingSeconds}s)`
936
949
  );
937
- this.lastLoggedCountdown = remainingSeconds;
950
+ __privateSet(this, _lastLoggedCountdown, remainingSeconds);
938
951
  }
939
952
  if (now >= sessionRequest.expiresAt) {
940
953
  this.stopExpirationCheck();
@@ -946,7 +959,7 @@ var init_AbstractInstallModal = __esm({
946
959
  const generateQRCode = yield this.options.generateQRCode(
947
960
  currentConnectionRequest
948
961
  );
949
- this.lastLoggedCountdown = -1;
962
+ __privateSet(this, _lastLoggedCountdown, -1);
950
963
  this.updateLink(generateQRCode);
951
964
  this.updateExpiresIn(remainingSeconds);
952
965
  this.renderQRCode(generateQRCode, currentConnectionRequest);
@@ -956,18 +969,20 @@ var init_AbstractInstallModal = __esm({
956
969
  );
957
970
  }
958
971
  }
959
- }), 1e3);
972
+ }), 1e3));
960
973
  }
961
974
  stopExpirationCheck() {
962
- if (this.expirationInterval) {
963
- clearInterval(this.expirationInterval);
964
- this.expirationInterval = null;
975
+ if (__privateGet(this, _expirationInterval)) {
976
+ clearInterval(__privateGet(this, _expirationInterval));
977
+ __privateSet(this, _expirationInterval, null);
965
978
  logger3(
966
979
  "[UI: InstallModal-nodejs()] \u{1F6D1} Stopped QR code expiration checking"
967
980
  );
968
981
  }
969
982
  }
970
983
  };
984
+ _expirationInterval = new WeakMap();
985
+ _lastLoggedCountdown = new WeakMap();
971
986
  }
972
987
  });
973
988
 
@@ -1169,11 +1184,14 @@ var init_web2 = __esm({
1169
1184
 
1170
1185
  // src/polyfills/buffer-shim.ts
1171
1186
  import { Buffer as Buffer2 } from "buffer";
1172
- var g = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {};
1173
- if (!g.Buffer) {
1174
- g.Buffer = Buffer2;
1187
+ var globalObj = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {};
1188
+ if (!globalObj.Buffer) {
1189
+ globalObj.Buffer = Buffer2;
1175
1190
  }
1176
1191
 
1192
+ // src/index.browser.ts
1193
+ init_domain();
1194
+
1177
1195
  // src/multichain/index.ts
1178
1196
  import { analytics as analytics2 } from "@metamask/analytics";
1179
1197
  import {
@@ -1216,7 +1234,9 @@ var RpcClient = class {
1216
1234
  }
1217
1235
  /**
1218
1236
  * Routes the request to a configured RPC node.
1219
- * @param options - The invoke method options
1237
+ *
1238
+ * @param options - The invoke method options.
1239
+ * @returns The JSON response from the RPC node.
1220
1240
  */
1221
1241
  request(options) {
1222
1242
  return __async(this, null, function* () {
@@ -1228,7 +1248,13 @@ var RpcClient = class {
1228
1248
  id: getNextRpcId()
1229
1249
  });
1230
1250
  const rpcEndpoint = this.getRpcEndpoint(options.scope);
1231
- const rpcRequest = yield this.fetchWithTimeout(rpcEndpoint, body, "POST", this.getHeaders(rpcEndpoint), 3e4);
1251
+ const rpcRequest = yield this.fetchWithTimeout(
1252
+ rpcEndpoint,
1253
+ body,
1254
+ "POST",
1255
+ this.getHeaders(rpcEndpoint),
1256
+ 3e4
1257
+ );
1232
1258
  const response = yield this.parseResponse(rpcRequest);
1233
1259
  return response;
1234
1260
  });
@@ -1238,7 +1264,9 @@ var RpcClient = class {
1238
1264
  const supportedNetworks = (_c = (_b = (_a2 = this.config) == null ? void 0 : _a2.api) == null ? void 0 : _b.supportedNetworks) != null ? _c : {};
1239
1265
  const rpcEndpoint = supportedNetworks[scope];
1240
1266
  if (!rpcEndpoint) {
1241
- throw new MissingRpcEndpointErr(`No RPC endpoint found for scope ${scope}`);
1267
+ throw new MissingRpcEndpointErr(
1268
+ `No RPC endpoint found for scope ${scope}`
1269
+ );
1242
1270
  }
1243
1271
  return rpcEndpoint;
1244
1272
  }
@@ -1266,7 +1294,7 @@ var RpcClient = class {
1266
1294
  if (error instanceof Error && error.name === "AbortError") {
1267
1295
  throw new RPCReadonlyRequestErr(`Request timeout after ${timeout}ms`);
1268
1296
  }
1269
- throw new RPCReadonlyRequestErr(error instanceof Error ? error.message : "Unknown error");
1297
+ throw new RPCReadonlyRequestErr(error.message);
1270
1298
  }
1271
1299
  });
1272
1300
  }
@@ -1311,10 +1339,12 @@ var RequestRouter = class {
1311
1339
  * The main entry point for invoking an RPC method.
1312
1340
  * This method acts as a router, determining the correct handling strategy
1313
1341
  * for the request and delegating to the appropriate private handler.
1342
+ *
1343
+ * @param options
1314
1344
  */
1315
1345
  invokeMethod(options) {
1316
1346
  return __async(this, null, function* () {
1317
- const method = options.request.method;
1347
+ const { method } = options.request;
1318
1348
  if (RPC_HANDLED_METHODS.has(method)) {
1319
1349
  return this.handleWithRpcNode(options);
1320
1350
  }
@@ -1326,6 +1356,8 @@ var RequestRouter = class {
1326
1356
  }
1327
1357
  /**
1328
1358
  * Forwards the request directly to the wallet via the transport.
1359
+ *
1360
+ * @param options
1329
1361
  */
1330
1362
  handleWithWallet(options) {
1331
1363
  return __async(this, null, function* () {
@@ -1354,7 +1386,10 @@ var RequestRouter = class {
1354
1386
  }
1355
1387
  const response = yield request;
1356
1388
  if (response.error) {
1357
- throw new RPCInvokeMethodErr(`RPC Request failed with code ${response.error.code}: ${response.error.message}`);
1389
+ const { error } = response;
1390
+ throw new RPCInvokeMethodErr(
1391
+ `RPC Request failed with code ${error.code}: ${error.message}`
1392
+ );
1358
1393
  }
1359
1394
  return response.result;
1360
1395
  }));
@@ -1362,6 +1397,8 @@ var RequestRouter = class {
1362
1397
  }
1363
1398
  /**
1364
1399
  * Routes the request to a configured RPC node.
1400
+ *
1401
+ * @param options
1365
1402
  */
1366
1403
  handleWithRpcNode(options) {
1367
1404
  return __async(this, null, function* () {
@@ -1379,10 +1416,14 @@ var RequestRouter = class {
1379
1416
  }
1380
1417
  /**
1381
1418
  * Responds directly from the SDK's session state.
1419
+ *
1420
+ * @param options
1382
1421
  */
1383
1422
  handleWithSdkState(options) {
1384
1423
  return __async(this, null, function* () {
1385
- console.warn(`Method "${options.request.method}" is configured for SDK state handling, but this is not yet implemented. Falling back to wallet passthrough.`);
1424
+ console.warn(
1425
+ `Method "${options.request.method}" is configured for SDK state handling, but this is not yet implemented. Falling back to wallet passthrough.`
1426
+ );
1386
1427
  return this.handleWithWallet(options);
1387
1428
  });
1388
1429
  }
@@ -1402,31 +1443,50 @@ withAnalyticsTracking_fn = function(options, execute) {
1402
1443
  } else {
1403
1444
  yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options);
1404
1445
  }
1446
+ if (error instanceof RPCInvokeMethodErr) {
1447
+ throw error;
1448
+ }
1405
1449
  throw new RPCInvokeMethodErr(error.message);
1406
1450
  }
1407
1451
  });
1408
1452
  };
1409
1453
  trackWalletActionRequested_fn = function(options) {
1410
1454
  return __async(this, null, function* () {
1411
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1455
+ const props = yield getWalletActionAnalyticsProperties(
1456
+ this.config,
1457
+ this.config.storage,
1458
+ options
1459
+ );
1412
1460
  analytics.track("mmconnect_wallet_action_requested", props);
1413
1461
  });
1414
1462
  };
1415
1463
  trackWalletActionSucceeded_fn = function(options) {
1416
1464
  return __async(this, null, function* () {
1417
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1465
+ const props = yield getWalletActionAnalyticsProperties(
1466
+ this.config,
1467
+ this.config.storage,
1468
+ options
1469
+ );
1418
1470
  analytics.track("mmconnect_wallet_action_succeeded", props);
1419
1471
  });
1420
1472
  };
1421
1473
  trackWalletActionFailed_fn = function(options) {
1422
1474
  return __async(this, null, function* () {
1423
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1475
+ const props = yield getWalletActionAnalyticsProperties(
1476
+ this.config,
1477
+ this.config.storage,
1478
+ options
1479
+ );
1424
1480
  analytics.track("mmconnect_wallet_action_failed", props);
1425
1481
  });
1426
1482
  };
1427
1483
  trackWalletActionRejected_fn = function(options) {
1428
1484
  return __async(this, null, function* () {
1429
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1485
+ const props = yield getWalletActionAnalyticsProperties(
1486
+ this.config,
1487
+ this.config.storage,
1488
+ options
1489
+ );
1430
1490
  analytics.track("mmconnect_wallet_action_rejected", props);
1431
1491
  });
1432
1492
  };
@@ -1490,7 +1550,7 @@ var DefaultTransport = class {
1490
1550
  }
1491
1551
  connect(options) {
1492
1552
  return __async(this, null, function* () {
1493
- var _a2, _b, _c, _d, _e, _f, _g;
1553
+ var _a2, _b, _c, _d, _e;
1494
1554
  __privateMethod(this, _DefaultTransport_instances, setupMessageListener_fn).call(this);
1495
1555
  yield __privateGet(this, _transport).connect();
1496
1556
  const sessionRequest = yield this.request(
@@ -1501,12 +1561,19 @@ var DefaultTransport = class {
1501
1561
  throw new Error(sessionRequest.error.message);
1502
1562
  }
1503
1563
  let walletSession = sessionRequest.result;
1564
+ const createSessionParams = {
1565
+ optionalScopes: addValidAccounts(
1566
+ getOptionalScopes((_a2 = options == null ? void 0 : options.scopes) != null ? _a2 : []),
1567
+ getValidAccounts((_b = options == null ? void 0 : options.caipAccountIds) != null ? _b : [])
1568
+ ),
1569
+ sessionProperties: options == null ? void 0 : options.sessionProperties
1570
+ };
1504
1571
  if (walletSession && options && !options.forceRequest) {
1505
1572
  const currentScopes = Object.keys(
1506
- (_a2 = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _a2 : {}
1573
+ (_c = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _c : {}
1507
1574
  );
1508
- const proposedScopes = (_b = options == null ? void 0 : options.scopes) != null ? _b : [];
1509
- const proposedCaipAccountIds = (_c = options == null ? void 0 : options.caipAccountIds) != null ? _c : [];
1575
+ const proposedScopes = (_d = options == null ? void 0 : options.scopes) != null ? _d : [];
1576
+ const proposedCaipAccountIds = (_e = options == null ? void 0 : options.caipAccountIds) != null ? _e : [];
1510
1577
  const hasSameScopesAndAccounts = isSameScopesAndAccounts(
1511
1578
  currentScopes,
1512
1579
  proposedScopes,
@@ -1518,13 +1585,6 @@ var DefaultTransport = class {
1518
1585
  { method: "wallet_revokeSession", params: walletSession },
1519
1586
  __privateGet(this, _defaultRequestOptions)
1520
1587
  );
1521
- const optionalScopes = addValidAccounts(
1522
- getOptionalScopes((_d = options == null ? void 0 : options.scopes) != null ? _d : []),
1523
- getValidAccounts((_e = options == null ? void 0 : options.caipAccountIds) != null ? _e : [])
1524
- );
1525
- const createSessionParams = {
1526
- optionalScopes
1527
- };
1528
1588
  const response = yield this.request(
1529
1589
  { method: "wallet_createSession", params: createSessionParams },
1530
1590
  __privateGet(this, _defaultRequestOptions)
@@ -1535,14 +1595,6 @@ var DefaultTransport = class {
1535
1595
  walletSession = response.result;
1536
1596
  }
1537
1597
  } else if (!walletSession || (options == null ? void 0 : options.forceRequest)) {
1538
- const optionalScopes = addValidAccounts(
1539
- getOptionalScopes((_f = options == null ? void 0 : options.scopes) != null ? _f : []),
1540
- getValidAccounts((_g = options == null ? void 0 : options.caipAccountIds) != null ? _g : [])
1541
- );
1542
- const createSessionParams = {
1543
- optionalScopes,
1544
- sessionProperties: options == null ? void 0 : options.sessionProperties
1545
- };
1546
1598
  const response = yield this.request(
1547
1599
  { method: "wallet_createSession", params: createSessionParams },
1548
1600
  __privateGet(this, _defaultRequestOptions)
@@ -1594,7 +1646,11 @@ var DefaultTransport = class {
1594
1646
  };
1595
1647
  }
1596
1648
  getActiveSession() {
1597
- throw new Error("getActiveSession is purposely not implemented for the DefaultTransport");
1649
+ return __async(this, null, function* () {
1650
+ throw new Error(
1651
+ "getActiveSession is purposely not implemented for the DefaultTransport"
1652
+ );
1653
+ });
1598
1654
  }
1599
1655
  };
1600
1656
  _notificationCallbacks = new WeakMap();
@@ -1668,6 +1724,164 @@ setupMessageListener_fn = function() {
1668
1724
  window.addEventListener("message", __privateGet(this, _handleNotificationListener));
1669
1725
  };
1670
1726
 
1727
+ // src/multichain/transports/multichainApiClientWrapper/index.ts
1728
+ import { providerErrors } from "@metamask/rpc-errors";
1729
+ var MAX = 4294967295;
1730
+ var idCounter = Math.floor(Math.random() * MAX);
1731
+ var getUniqueId = () => {
1732
+ idCounter = (idCounter + 1) % MAX;
1733
+ return idCounter;
1734
+ };
1735
+ var _requestId, _notificationCallbacks2, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn, walletGetSession_fn, walletRevokeSession_fn, walletInvokeMethod_fn;
1736
+ var MultichainApiClientWrapperTransport = class {
1737
+ constructor(metamaskConnectMultichain) {
1738
+ this.metamaskConnectMultichain = metamaskConnectMultichain;
1739
+ __privateAdd(this, _MultichainApiClientWrapperTransport_instances);
1740
+ __privateAdd(this, _requestId, getUniqueId());
1741
+ __privateAdd(this, _notificationCallbacks2, /* @__PURE__ */ new Set());
1742
+ }
1743
+ isTransportDefined() {
1744
+ try {
1745
+ return Boolean(this.metamaskConnectMultichain.transport);
1746
+ } catch (_error) {
1747
+ return false;
1748
+ }
1749
+ }
1750
+ clearNotificationCallbacks() {
1751
+ __privateGet(this, _notificationCallbacks2).clear();
1752
+ }
1753
+ notifyCallbacks(data) {
1754
+ __privateGet(this, _notificationCallbacks2).forEach((callback) => {
1755
+ callback(data);
1756
+ });
1757
+ }
1758
+ setupNotifcationListener() {
1759
+ this.metamaskConnectMultichain.transport.onNotification(
1760
+ this.notifyCallbacks.bind(this)
1761
+ );
1762
+ }
1763
+ connect() {
1764
+ return __async(this, null, function* () {
1765
+ console.log("\u{1F4DA} connect");
1766
+ return Promise.resolve();
1767
+ });
1768
+ }
1769
+ disconnect() {
1770
+ return __async(this, null, function* () {
1771
+ return Promise.resolve();
1772
+ });
1773
+ }
1774
+ isConnected() {
1775
+ return true;
1776
+ }
1777
+ request(_0) {
1778
+ return __async(this, arguments, function* (params, _options = {}) {
1779
+ const id = __privateWrapper(this, _requestId)._++;
1780
+ const requestPayload = __spreadValues({
1781
+ id,
1782
+ jsonrpc: "2.0"
1783
+ }, params);
1784
+ switch (requestPayload.method) {
1785
+ case "wallet_createSession":
1786
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn).call(this, requestPayload);
1787
+ case "wallet_getSession":
1788
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletGetSession_fn).call(this, requestPayload);
1789
+ case "wallet_revokeSession":
1790
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletRevokeSession_fn).call(this, requestPayload);
1791
+ case "wallet_invokeMethod":
1792
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletInvokeMethod_fn).call(this, requestPayload);
1793
+ default:
1794
+ throw new Error(`Unsupported method: ${requestPayload.method}`);
1795
+ }
1796
+ throw new Error(`Unknown method: ${requestPayload.method}`);
1797
+ });
1798
+ }
1799
+ onNotification(callback) {
1800
+ if (!this.isTransportDefined()) {
1801
+ __privateGet(this, _notificationCallbacks2).add(callback);
1802
+ return () => {
1803
+ __privateGet(this, _notificationCallbacks2).delete(callback);
1804
+ };
1805
+ }
1806
+ return this.metamaskConnectMultichain.transport.onNotification(callback);
1807
+ }
1808
+ };
1809
+ _requestId = new WeakMap();
1810
+ _notificationCallbacks2 = new WeakMap();
1811
+ _MultichainApiClientWrapperTransport_instances = new WeakSet();
1812
+ walletCreateSession_fn = function(request) {
1813
+ return __async(this, null, function* () {
1814
+ console.log("\u{1F4DA} #walletCreateSession", request);
1815
+ const createSessionParams = request.params;
1816
+ const scopes = Object.keys(__spreadValues(__spreadValues({}, createSessionParams.optionalScopes), createSessionParams.requiredScopes));
1817
+ const scopeAccounts = [];
1818
+ scopes.forEach((scope) => {
1819
+ var _a2, _b, _c, _d;
1820
+ const requiredScope = (_a2 = createSessionParams.requiredScopes) == null ? void 0 : _a2[scope];
1821
+ const optionalScope = (_b = createSessionParams.optionalScopes) == null ? void 0 : _b[scope];
1822
+ if (requiredScope) {
1823
+ scopeAccounts.push(...(_c = requiredScope.accounts) != null ? _c : []);
1824
+ }
1825
+ if (optionalScope) {
1826
+ scopeAccounts.push(...(_d = optionalScope.accounts) != null ? _d : []);
1827
+ }
1828
+ });
1829
+ const accounts = [...new Set(scopeAccounts)];
1830
+ console.log("\u{1F4DA} SDK connect");
1831
+ yield this.metamaskConnectMultichain.connect(
1832
+ scopes,
1833
+ accounts,
1834
+ createSessionParams.sessionProperties
1835
+ );
1836
+ console.log("\u{1F4DA} SDK connected");
1837
+ return this.metamaskConnectMultichain.transport.request({
1838
+ method: "wallet_getSession"
1839
+ });
1840
+ });
1841
+ };
1842
+ walletGetSession_fn = function(request) {
1843
+ return __async(this, null, function* () {
1844
+ if (!this.isTransportDefined()) {
1845
+ return {
1846
+ jsonrpc: "2.0",
1847
+ id: request.id,
1848
+ result: {
1849
+ sessionScopes: {}
1850
+ }
1851
+ };
1852
+ }
1853
+ return this.metamaskConnectMultichain.transport.request({
1854
+ method: "wallet_getSession"
1855
+ });
1856
+ });
1857
+ };
1858
+ walletRevokeSession_fn = function(request) {
1859
+ return __async(this, null, function* () {
1860
+ if (!this.isTransportDefined()) {
1861
+ return { jsonrpc: "2.0", id: request.id, result: true };
1862
+ }
1863
+ try {
1864
+ this.metamaskConnectMultichain.disconnect();
1865
+ return { jsonrpc: "2.0", id: request.id, result: true };
1866
+ } catch (_error) {
1867
+ return { jsonrpc: "2.0", id: request.id, result: false };
1868
+ }
1869
+ });
1870
+ };
1871
+ walletInvokeMethod_fn = function(request) {
1872
+ return __async(this, null, function* () {
1873
+ if (!this.isTransportDefined()) {
1874
+ return { error: providerErrors.unauthorized() };
1875
+ }
1876
+ const result = this.metamaskConnectMultichain.invokeMethod(
1877
+ request.params
1878
+ );
1879
+ return {
1880
+ result
1881
+ };
1882
+ });
1883
+ };
1884
+
1671
1885
  // src/multichain/transports/mwp/index.ts
1672
1886
  init_domain();
1673
1887
  init_utils();
@@ -2229,164 +2443,6 @@ var keymanager = new KeyManager();
2229
2443
 
2230
2444
  // src/multichain/index.ts
2231
2445
  init_utils();
2232
-
2233
- // src/multichain/transports/multichainApiClientWrapper/index.ts
2234
- import { providerErrors } from "@metamask/rpc-errors";
2235
- var MAX = 4294967295;
2236
- var idCounter = Math.floor(Math.random() * MAX);
2237
- var getUniqueId = () => {
2238
- idCounter = (idCounter + 1) % MAX;
2239
- return idCounter;
2240
- };
2241
- var _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn, walletGetSession_fn, walletRevokeSession_fn, walletInvokeMethod_fn;
2242
- var MultichainApiClientWrapperTransport = class {
2243
- constructor(metamaskConnectMultichain) {
2244
- this.metamaskConnectMultichain = metamaskConnectMultichain;
2245
- __privateAdd(this, _MultichainApiClientWrapperTransport_instances);
2246
- this.requestId = getUniqueId();
2247
- this.notificationCallbacks = /* @__PURE__ */ new Set();
2248
- }
2249
- isTransportDefined() {
2250
- try {
2251
- return Boolean(this.metamaskConnectMultichain.transport);
2252
- } catch (error) {
2253
- return false;
2254
- }
2255
- }
2256
- clearNotificationCallbacks() {
2257
- this.notificationCallbacks.clear();
2258
- }
2259
- notifyCallbacks(data) {
2260
- this.notificationCallbacks.forEach((callback) => {
2261
- callback(data);
2262
- });
2263
- }
2264
- setupNotifcationListener() {
2265
- this.metamaskConnectMultichain.transport.onNotification(
2266
- this.notifyCallbacks.bind(this)
2267
- );
2268
- }
2269
- connect() {
2270
- return __async(this, null, function* () {
2271
- console.log("\u{1F4DA} connect");
2272
- return Promise.resolve();
2273
- });
2274
- }
2275
- disconnect() {
2276
- return __async(this, null, function* () {
2277
- return Promise.resolve();
2278
- });
2279
- }
2280
- isConnected() {
2281
- return true;
2282
- }
2283
- request(_0) {
2284
- return __async(this, arguments, function* (params, _options = {}) {
2285
- const id = this.requestId++;
2286
- const requestPayload = __spreadValues({
2287
- id,
2288
- jsonrpc: "2.0"
2289
- }, params);
2290
- switch (requestPayload.method) {
2291
- case "wallet_createSession":
2292
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn).call(this, requestPayload);
2293
- case "wallet_getSession":
2294
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletGetSession_fn).call(this, requestPayload);
2295
- case "wallet_revokeSession":
2296
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletRevokeSession_fn).call(this, requestPayload);
2297
- case "wallet_invokeMethod":
2298
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletInvokeMethod_fn).call(this, requestPayload);
2299
- default:
2300
- throw new Error(`Unsupported method: ${requestPayload.method}`);
2301
- }
2302
- throw new Error(`Unknown method: ${requestPayload.method}`);
2303
- });
2304
- }
2305
- onNotification(callback) {
2306
- if (!this.isTransportDefined()) {
2307
- this.notificationCallbacks.add(callback);
2308
- return () => {
2309
- this.notificationCallbacks.delete(callback);
2310
- };
2311
- }
2312
- return this.metamaskConnectMultichain.transport.onNotification(callback);
2313
- }
2314
- };
2315
- _MultichainApiClientWrapperTransport_instances = new WeakSet();
2316
- walletCreateSession_fn = function(request) {
2317
- return __async(this, null, function* () {
2318
- console.log("\u{1F4DA} #walletCreateSession", request);
2319
- const createSessionParams = request.params;
2320
- const scopes = Object.keys(__spreadValues(__spreadValues({}, createSessionParams.optionalScopes), createSessionParams.requiredScopes));
2321
- const scopeAccounts = [];
2322
- scopes.forEach((scope) => {
2323
- var _a2, _b, _c, _d;
2324
- const requiredScope = (_a2 = createSessionParams.requiredScopes) == null ? void 0 : _a2[scope];
2325
- const optionalScope = (_b = createSessionParams.optionalScopes) == null ? void 0 : _b[scope];
2326
- if (requiredScope) {
2327
- scopeAccounts.push(...(_c = requiredScope.accounts) != null ? _c : []);
2328
- }
2329
- if (optionalScope) {
2330
- scopeAccounts.push(...(_d = optionalScope.accounts) != null ? _d : []);
2331
- }
2332
- });
2333
- const accounts = [...new Set(scopeAccounts)];
2334
- console.log("\u{1F4DA} SDK connect");
2335
- yield this.metamaskConnectMultichain.connect(
2336
- scopes,
2337
- accounts,
2338
- createSessionParams.sessionProperties
2339
- );
2340
- console.log("\u{1F4DA} SDK connected");
2341
- return this.metamaskConnectMultichain.transport.request({
2342
- method: "wallet_getSession"
2343
- });
2344
- });
2345
- };
2346
- walletGetSession_fn = function(request) {
2347
- return __async(this, null, function* () {
2348
- if (!this.isTransportDefined()) {
2349
- return {
2350
- jsonrpc: "2.0",
2351
- id: request.id,
2352
- result: {
2353
- sessionScopes: {}
2354
- }
2355
- };
2356
- }
2357
- return this.metamaskConnectMultichain.transport.request({
2358
- method: "wallet_getSession"
2359
- });
2360
- });
2361
- };
2362
- walletRevokeSession_fn = function(request) {
2363
- return __async(this, null, function* () {
2364
- if (!this.isTransportDefined()) {
2365
- return { jsonrpc: "2.0", id: request.id, result: true };
2366
- }
2367
- try {
2368
- this.metamaskConnectMultichain.disconnect();
2369
- return { jsonrpc: "2.0", id: request.id, result: true };
2370
- } catch (error) {
2371
- return { jsonrpc: "2.0", id: request.id, result: false };
2372
- }
2373
- });
2374
- };
2375
- walletInvokeMethod_fn = function(request) {
2376
- return __async(this, null, function* () {
2377
- if (!this.isTransportDefined()) {
2378
- return { error: providerErrors.unauthorized() };
2379
- }
2380
- const result = this.metamaskConnectMultichain.invokeMethod(
2381
- request.params
2382
- );
2383
- return {
2384
- result
2385
- };
2386
- });
2387
- };
2388
-
2389
- // src/multichain/index.ts
2390
2446
  var logger2 = createLogger("metamask-sdk:core");
2391
2447
  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;
2392
2448
  var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends MultichainCore {
@@ -2414,8 +2470,12 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2414
2470
  this._status = "pending";
2415
2471
  __privateAdd(this, _listener);
2416
2472
  __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}`);
2417
- __privateSet(this, _providerTransportWrapper, new MultichainApiClientWrapperTransport(this));
2418
- __privateSet(this, _provider, getMultichainClient({ transport: __privateGet(this, _providerTransportWrapper) }));
2473
+ __privateSet(this, _providerTransportWrapper, new MultichainApiClientWrapperTransport(
2474
+ this
2475
+ ));
2476
+ __privateSet(this, _provider, getMultichainClient({
2477
+ transport: __privateGet(this, _providerTransportWrapper)
2478
+ }));
2419
2479
  }
2420
2480
  get status() {
2421
2481
  return this._status;
@@ -2499,8 +2559,14 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2499
2559
  } catch (error) {
2500
2560
  logger2("Error tracking connection_initiated event", error);
2501
2561
  }
2562
+ const nonEmptySessionProperites = Object.keys(sessionProperties != null ? sessionProperties : {}).length > 0 ? sessionProperties : void 0;
2502
2563
  if (((_a2 = __privateGet(this, _transport2)) == null ? void 0 : _a2.isConnected()) && !secure) {
2503
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateGet(this, _transport2).connect({ scopes, caipAccountIds, sessionProperties, forceRequest }).then(() => __async(this, null, function* () {
2564
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateGet(this, _transport2).connect({
2565
+ scopes,
2566
+ caipAccountIds,
2567
+ sessionProperties: nonEmptySessionProperites,
2568
+ forceRequest
2569
+ }).then(() => __async(this, null, function* () {
2504
2570
  if (__privateGet(this, _transport2) instanceof MWPTransport) {
2505
2571
  return this.storage.setTransport("mwp" /* MWP */);
2506
2572
  }
@@ -2509,18 +2575,28 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2509
2575
  }
2510
2576
  if (platformType === "in-app-browser" /* MetaMaskMobileWebview */) {
2511
2577
  const defaultTransport = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupDefaultTransport_fn).call(this);
2512
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
2578
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({
2579
+ scopes,
2580
+ caipAccountIds,
2581
+ sessionProperties: nonEmptySessionProperites,
2582
+ forceRequest
2583
+ }), scopes, transportType);
2513
2584
  }
2514
2585
  if (isWeb && hasExtensionInstalled && preferExtension) {
2515
2586
  const defaultTransport = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupDefaultTransport_fn).call(this);
2516
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
2587
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({
2588
+ scopes,
2589
+ caipAccountIds,
2590
+ sessionProperties: nonEmptySessionProperites,
2591
+ forceRequest
2592
+ }), scopes, transportType);
2517
2593
  }
2518
2594
  yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupMWP_fn).call(this);
2519
2595
  const shouldShowInstallModal = hasExtensionInstalled ? showInstallModal : !preferExtension || showInstallModal;
2520
2596
  if (secure && !shouldShowInstallModal) {
2521
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, deeplinkConnect_fn).call(this, scopes, caipAccountIds, sessionProperties), scopes, transportType);
2597
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, deeplinkConnect_fn).call(this, scopes, caipAccountIds, nonEmptySessionProperites), scopes, transportType);
2522
2598
  }
2523
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, showInstallModal_fn).call(this, shouldShowInstallModal, scopes, caipAccountIds, sessionProperties), scopes, transportType);
2599
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, showInstallModal_fn).call(this, shouldShowInstallModal, scopes, caipAccountIds, nonEmptySessionProperites), scopes, transportType);
2524
2600
  });
2525
2601
  }
2526
2602
  emit(event, args) {
@@ -2775,7 +2851,11 @@ renderInstallModalAsync_fn = function(desktopPreferred, scopes, caipAccountIds,
2775
2851
  (() => __async(this, null, function* () {
2776
2852
  var _a2;
2777
2853
  try {
2778
- yield this.transport.connect({ scopes, caipAccountIds, sessionProperties });
2854
+ yield this.transport.connect({
2855
+ scopes,
2856
+ caipAccountIds,
2857
+ sessionProperties
2858
+ });
2779
2859
  yield this.options.ui.factory.unload();
2780
2860
  (_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.unmount();
2781
2861
  this.status = "connected";
@@ -2883,7 +2963,7 @@ setupDefaultTransport_fn = function() {
2883
2963
  };
2884
2964
  deeplinkConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
2885
2965
  return __async(this, null, function* () {
2886
- return new Promise((resolve, reject) => {
2966
+ return new Promise((resolve, reject) => __async(this, null, function* () {
2887
2967
  const dappClientMessageHandler = (payload) => {
2888
2968
  var _a2;
2889
2969
  if (typeof payload !== "object" || payload === null || !("data" in payload)) {
@@ -2942,7 +3022,7 @@ deeplinkConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
2942
3022
  clearTimeout(timeout);
2943
3023
  }
2944
3024
  });
2945
- });
3025
+ }));
2946
3026
  });
2947
3027
  };
2948
3028
  handleConnection_fn = function(promise, scopes, transportType) {
@@ -3235,7 +3315,9 @@ var BaseModalFactory = class {
3235
3315
  }
3236
3316
  createConnectionDeeplink(connectionRequest) {
3237
3317
  if (!connectionRequest) {
3238
- throw new Error("createConnectionDeeplink can only be called with a connection request");
3318
+ throw new Error(
3319
+ "createConnectionDeeplink can only be called with a connection request"
3320
+ );
3239
3321
  }
3240
3322
  const json = JSON.stringify(connectionRequest);
3241
3323
  const compressed = compressString(json);
@@ -3341,14 +3423,17 @@ var ModalFactory = class extends BaseModalFactory {
3341
3423
  // src/index.browser.ts
3342
3424
  init_domain();
3343
3425
  var createMultichainClient = (options) => __async(null, null, function* () {
3426
+ if (options.debug) {
3427
+ enableDebug("metamask-sdk:*");
3428
+ }
3344
3429
  const uiModules = yield Promise.resolve().then(() => (init_web(), web_exports));
3345
3430
  let storage;
3346
- if (!options.storage) {
3431
+ if (options.storage) {
3432
+ storage = options.storage;
3433
+ } else {
3347
3434
  const { StoreAdapterWeb: StoreAdapterWeb2 } = yield Promise.resolve().then(() => (init_web2(), web_exports2));
3348
3435
  const adapter = new StoreAdapterWeb2();
3349
3436
  storage = new Store(adapter);
3350
- } else {
3351
- storage = options.storage;
3352
3437
  }
3353
3438
  const factory = new ModalFactory(uiModules);
3354
3439
  return MetaMaskConnectMultichain.create(__spreadProps(__spreadValues({}, options), {