@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
 
@@ -1077,11 +1092,14 @@ var init_rn2 = __esm({
1077
1092
 
1078
1093
  // src/polyfills/buffer-shim.ts
1079
1094
  import { Buffer as Buffer2 } from "buffer";
1080
- var g = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {};
1081
- if (!g.Buffer) {
1082
- g.Buffer = Buffer2;
1095
+ var globalObj = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {};
1096
+ if (!globalObj.Buffer) {
1097
+ globalObj.Buffer = Buffer2;
1083
1098
  }
1084
1099
 
1100
+ // src/index.native.ts
1101
+ init_domain();
1102
+
1085
1103
  // src/multichain/index.ts
1086
1104
  import { analytics as analytics2 } from "@metamask/analytics";
1087
1105
  import {
@@ -1124,7 +1142,9 @@ var RpcClient = class {
1124
1142
  }
1125
1143
  /**
1126
1144
  * Routes the request to a configured RPC node.
1127
- * @param options - The invoke method options
1145
+ *
1146
+ * @param options - The invoke method options.
1147
+ * @returns The JSON response from the RPC node.
1128
1148
  */
1129
1149
  request(options) {
1130
1150
  return __async(this, null, function* () {
@@ -1136,7 +1156,13 @@ var RpcClient = class {
1136
1156
  id: getNextRpcId()
1137
1157
  });
1138
1158
  const rpcEndpoint = this.getRpcEndpoint(options.scope);
1139
- const rpcRequest = yield this.fetchWithTimeout(rpcEndpoint, body, "POST", this.getHeaders(rpcEndpoint), 3e4);
1159
+ const rpcRequest = yield this.fetchWithTimeout(
1160
+ rpcEndpoint,
1161
+ body,
1162
+ "POST",
1163
+ this.getHeaders(rpcEndpoint),
1164
+ 3e4
1165
+ );
1140
1166
  const response = yield this.parseResponse(rpcRequest);
1141
1167
  return response;
1142
1168
  });
@@ -1146,7 +1172,9 @@ var RpcClient = class {
1146
1172
  const supportedNetworks = (_c = (_b = (_a2 = this.config) == null ? void 0 : _a2.api) == null ? void 0 : _b.supportedNetworks) != null ? _c : {};
1147
1173
  const rpcEndpoint = supportedNetworks[scope];
1148
1174
  if (!rpcEndpoint) {
1149
- throw new MissingRpcEndpointErr(`No RPC endpoint found for scope ${scope}`);
1175
+ throw new MissingRpcEndpointErr(
1176
+ `No RPC endpoint found for scope ${scope}`
1177
+ );
1150
1178
  }
1151
1179
  return rpcEndpoint;
1152
1180
  }
@@ -1174,7 +1202,7 @@ var RpcClient = class {
1174
1202
  if (error instanceof Error && error.name === "AbortError") {
1175
1203
  throw new RPCReadonlyRequestErr(`Request timeout after ${timeout}ms`);
1176
1204
  }
1177
- throw new RPCReadonlyRequestErr(error instanceof Error ? error.message : "Unknown error");
1205
+ throw new RPCReadonlyRequestErr(error.message);
1178
1206
  }
1179
1207
  });
1180
1208
  }
@@ -1219,10 +1247,12 @@ var RequestRouter = class {
1219
1247
  * The main entry point for invoking an RPC method.
1220
1248
  * This method acts as a router, determining the correct handling strategy
1221
1249
  * for the request and delegating to the appropriate private handler.
1250
+ *
1251
+ * @param options
1222
1252
  */
1223
1253
  invokeMethod(options) {
1224
1254
  return __async(this, null, function* () {
1225
- const method = options.request.method;
1255
+ const { method } = options.request;
1226
1256
  if (RPC_HANDLED_METHODS.has(method)) {
1227
1257
  return this.handleWithRpcNode(options);
1228
1258
  }
@@ -1234,6 +1264,8 @@ var RequestRouter = class {
1234
1264
  }
1235
1265
  /**
1236
1266
  * Forwards the request directly to the wallet via the transport.
1267
+ *
1268
+ * @param options
1237
1269
  */
1238
1270
  handleWithWallet(options) {
1239
1271
  return __async(this, null, function* () {
@@ -1262,7 +1294,10 @@ var RequestRouter = class {
1262
1294
  }
1263
1295
  const response = yield request;
1264
1296
  if (response.error) {
1265
- throw new RPCInvokeMethodErr(`RPC Request failed with code ${response.error.code}: ${response.error.message}`);
1297
+ const { error } = response;
1298
+ throw new RPCInvokeMethodErr(
1299
+ `RPC Request failed with code ${error.code}: ${error.message}`
1300
+ );
1266
1301
  }
1267
1302
  return response.result;
1268
1303
  }));
@@ -1270,6 +1305,8 @@ var RequestRouter = class {
1270
1305
  }
1271
1306
  /**
1272
1307
  * Routes the request to a configured RPC node.
1308
+ *
1309
+ * @param options
1273
1310
  */
1274
1311
  handleWithRpcNode(options) {
1275
1312
  return __async(this, null, function* () {
@@ -1287,10 +1324,14 @@ var RequestRouter = class {
1287
1324
  }
1288
1325
  /**
1289
1326
  * Responds directly from the SDK's session state.
1327
+ *
1328
+ * @param options
1290
1329
  */
1291
1330
  handleWithSdkState(options) {
1292
1331
  return __async(this, null, function* () {
1293
- console.warn(`Method "${options.request.method}" is configured for SDK state handling, but this is not yet implemented. Falling back to wallet passthrough.`);
1332
+ console.warn(
1333
+ `Method "${options.request.method}" is configured for SDK state handling, but this is not yet implemented. Falling back to wallet passthrough.`
1334
+ );
1294
1335
  return this.handleWithWallet(options);
1295
1336
  });
1296
1337
  }
@@ -1310,31 +1351,50 @@ withAnalyticsTracking_fn = function(options, execute) {
1310
1351
  } else {
1311
1352
  yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options);
1312
1353
  }
1354
+ if (error instanceof RPCInvokeMethodErr) {
1355
+ throw error;
1356
+ }
1313
1357
  throw new RPCInvokeMethodErr(error.message);
1314
1358
  }
1315
1359
  });
1316
1360
  };
1317
1361
  trackWalletActionRequested_fn = function(options) {
1318
1362
  return __async(this, null, function* () {
1319
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1363
+ const props = yield getWalletActionAnalyticsProperties(
1364
+ this.config,
1365
+ this.config.storage,
1366
+ options
1367
+ );
1320
1368
  analytics.track("mmconnect_wallet_action_requested", props);
1321
1369
  });
1322
1370
  };
1323
1371
  trackWalletActionSucceeded_fn = function(options) {
1324
1372
  return __async(this, null, function* () {
1325
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1373
+ const props = yield getWalletActionAnalyticsProperties(
1374
+ this.config,
1375
+ this.config.storage,
1376
+ options
1377
+ );
1326
1378
  analytics.track("mmconnect_wallet_action_succeeded", props);
1327
1379
  });
1328
1380
  };
1329
1381
  trackWalletActionFailed_fn = function(options) {
1330
1382
  return __async(this, null, function* () {
1331
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1383
+ const props = yield getWalletActionAnalyticsProperties(
1384
+ this.config,
1385
+ this.config.storage,
1386
+ options
1387
+ );
1332
1388
  analytics.track("mmconnect_wallet_action_failed", props);
1333
1389
  });
1334
1390
  };
1335
1391
  trackWalletActionRejected_fn = function(options) {
1336
1392
  return __async(this, null, function* () {
1337
- const props = yield getWalletActionAnalyticsProperties(this.config, this.config.storage, options);
1393
+ const props = yield getWalletActionAnalyticsProperties(
1394
+ this.config,
1395
+ this.config.storage,
1396
+ options
1397
+ );
1338
1398
  analytics.track("mmconnect_wallet_action_rejected", props);
1339
1399
  });
1340
1400
  };
@@ -1398,7 +1458,7 @@ var DefaultTransport = class {
1398
1458
  }
1399
1459
  connect(options) {
1400
1460
  return __async(this, null, function* () {
1401
- var _a2, _b, _c, _d, _e, _f, _g;
1461
+ var _a2, _b, _c, _d, _e;
1402
1462
  __privateMethod(this, _DefaultTransport_instances, setupMessageListener_fn).call(this);
1403
1463
  yield __privateGet(this, _transport).connect();
1404
1464
  const sessionRequest = yield this.request(
@@ -1409,12 +1469,19 @@ var DefaultTransport = class {
1409
1469
  throw new Error(sessionRequest.error.message);
1410
1470
  }
1411
1471
  let walletSession = sessionRequest.result;
1472
+ const createSessionParams = {
1473
+ optionalScopes: addValidAccounts(
1474
+ getOptionalScopes((_a2 = options == null ? void 0 : options.scopes) != null ? _a2 : []),
1475
+ getValidAccounts((_b = options == null ? void 0 : options.caipAccountIds) != null ? _b : [])
1476
+ ),
1477
+ sessionProperties: options == null ? void 0 : options.sessionProperties
1478
+ };
1412
1479
  if (walletSession && options && !options.forceRequest) {
1413
1480
  const currentScopes = Object.keys(
1414
- (_a2 = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _a2 : {}
1481
+ (_c = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _c : {}
1415
1482
  );
1416
- const proposedScopes = (_b = options == null ? void 0 : options.scopes) != null ? _b : [];
1417
- const proposedCaipAccountIds = (_c = options == null ? void 0 : options.caipAccountIds) != null ? _c : [];
1483
+ const proposedScopes = (_d = options == null ? void 0 : options.scopes) != null ? _d : [];
1484
+ const proposedCaipAccountIds = (_e = options == null ? void 0 : options.caipAccountIds) != null ? _e : [];
1418
1485
  const hasSameScopesAndAccounts = isSameScopesAndAccounts(
1419
1486
  currentScopes,
1420
1487
  proposedScopes,
@@ -1426,13 +1493,6 @@ var DefaultTransport = class {
1426
1493
  { method: "wallet_revokeSession", params: walletSession },
1427
1494
  __privateGet(this, _defaultRequestOptions)
1428
1495
  );
1429
- const optionalScopes = addValidAccounts(
1430
- getOptionalScopes((_d = options == null ? void 0 : options.scopes) != null ? _d : []),
1431
- getValidAccounts((_e = options == null ? void 0 : options.caipAccountIds) != null ? _e : [])
1432
- );
1433
- const createSessionParams = {
1434
- optionalScopes
1435
- };
1436
1496
  const response = yield this.request(
1437
1497
  { method: "wallet_createSession", params: createSessionParams },
1438
1498
  __privateGet(this, _defaultRequestOptions)
@@ -1443,14 +1503,6 @@ var DefaultTransport = class {
1443
1503
  walletSession = response.result;
1444
1504
  }
1445
1505
  } else if (!walletSession || (options == null ? void 0 : options.forceRequest)) {
1446
- const optionalScopes = addValidAccounts(
1447
- getOptionalScopes((_f = options == null ? void 0 : options.scopes) != null ? _f : []),
1448
- getValidAccounts((_g = options == null ? void 0 : options.caipAccountIds) != null ? _g : [])
1449
- );
1450
- const createSessionParams = {
1451
- optionalScopes,
1452
- sessionProperties: options == null ? void 0 : options.sessionProperties
1453
- };
1454
1506
  const response = yield this.request(
1455
1507
  { method: "wallet_createSession", params: createSessionParams },
1456
1508
  __privateGet(this, _defaultRequestOptions)
@@ -1502,7 +1554,11 @@ var DefaultTransport = class {
1502
1554
  };
1503
1555
  }
1504
1556
  getActiveSession() {
1505
- throw new Error("getActiveSession is purposely not implemented for the DefaultTransport");
1557
+ return __async(this, null, function* () {
1558
+ throw new Error(
1559
+ "getActiveSession is purposely not implemented for the DefaultTransport"
1560
+ );
1561
+ });
1506
1562
  }
1507
1563
  };
1508
1564
  _notificationCallbacks = new WeakMap();
@@ -1576,6 +1632,164 @@ setupMessageListener_fn = function() {
1576
1632
  window.addEventListener("message", __privateGet(this, _handleNotificationListener));
1577
1633
  };
1578
1634
 
1635
+ // src/multichain/transports/multichainApiClientWrapper/index.ts
1636
+ import { providerErrors } from "@metamask/rpc-errors";
1637
+ var MAX = 4294967295;
1638
+ var idCounter = Math.floor(Math.random() * MAX);
1639
+ var getUniqueId = () => {
1640
+ idCounter = (idCounter + 1) % MAX;
1641
+ return idCounter;
1642
+ };
1643
+ var _requestId, _notificationCallbacks2, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn, walletGetSession_fn, walletRevokeSession_fn, walletInvokeMethod_fn;
1644
+ var MultichainApiClientWrapperTransport = class {
1645
+ constructor(metamaskConnectMultichain) {
1646
+ this.metamaskConnectMultichain = metamaskConnectMultichain;
1647
+ __privateAdd(this, _MultichainApiClientWrapperTransport_instances);
1648
+ __privateAdd(this, _requestId, getUniqueId());
1649
+ __privateAdd(this, _notificationCallbacks2, /* @__PURE__ */ new Set());
1650
+ }
1651
+ isTransportDefined() {
1652
+ try {
1653
+ return Boolean(this.metamaskConnectMultichain.transport);
1654
+ } catch (_error) {
1655
+ return false;
1656
+ }
1657
+ }
1658
+ clearNotificationCallbacks() {
1659
+ __privateGet(this, _notificationCallbacks2).clear();
1660
+ }
1661
+ notifyCallbacks(data) {
1662
+ __privateGet(this, _notificationCallbacks2).forEach((callback) => {
1663
+ callback(data);
1664
+ });
1665
+ }
1666
+ setupNotifcationListener() {
1667
+ this.metamaskConnectMultichain.transport.onNotification(
1668
+ this.notifyCallbacks.bind(this)
1669
+ );
1670
+ }
1671
+ connect() {
1672
+ return __async(this, null, function* () {
1673
+ console.log("\u{1F4DA} connect");
1674
+ return Promise.resolve();
1675
+ });
1676
+ }
1677
+ disconnect() {
1678
+ return __async(this, null, function* () {
1679
+ return Promise.resolve();
1680
+ });
1681
+ }
1682
+ isConnected() {
1683
+ return true;
1684
+ }
1685
+ request(_0) {
1686
+ return __async(this, arguments, function* (params, _options = {}) {
1687
+ const id = __privateWrapper(this, _requestId)._++;
1688
+ const requestPayload = __spreadValues({
1689
+ id,
1690
+ jsonrpc: "2.0"
1691
+ }, params);
1692
+ switch (requestPayload.method) {
1693
+ case "wallet_createSession":
1694
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn).call(this, requestPayload);
1695
+ case "wallet_getSession":
1696
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletGetSession_fn).call(this, requestPayload);
1697
+ case "wallet_revokeSession":
1698
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletRevokeSession_fn).call(this, requestPayload);
1699
+ case "wallet_invokeMethod":
1700
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletInvokeMethod_fn).call(this, requestPayload);
1701
+ default:
1702
+ throw new Error(`Unsupported method: ${requestPayload.method}`);
1703
+ }
1704
+ throw new Error(`Unknown method: ${requestPayload.method}`);
1705
+ });
1706
+ }
1707
+ onNotification(callback) {
1708
+ if (!this.isTransportDefined()) {
1709
+ __privateGet(this, _notificationCallbacks2).add(callback);
1710
+ return () => {
1711
+ __privateGet(this, _notificationCallbacks2).delete(callback);
1712
+ };
1713
+ }
1714
+ return this.metamaskConnectMultichain.transport.onNotification(callback);
1715
+ }
1716
+ };
1717
+ _requestId = new WeakMap();
1718
+ _notificationCallbacks2 = new WeakMap();
1719
+ _MultichainApiClientWrapperTransport_instances = new WeakSet();
1720
+ walletCreateSession_fn = function(request) {
1721
+ return __async(this, null, function* () {
1722
+ console.log("\u{1F4DA} #walletCreateSession", request);
1723
+ const createSessionParams = request.params;
1724
+ const scopes = Object.keys(__spreadValues(__spreadValues({}, createSessionParams.optionalScopes), createSessionParams.requiredScopes));
1725
+ const scopeAccounts = [];
1726
+ scopes.forEach((scope) => {
1727
+ var _a2, _b, _c, _d;
1728
+ const requiredScope = (_a2 = createSessionParams.requiredScopes) == null ? void 0 : _a2[scope];
1729
+ const optionalScope = (_b = createSessionParams.optionalScopes) == null ? void 0 : _b[scope];
1730
+ if (requiredScope) {
1731
+ scopeAccounts.push(...(_c = requiredScope.accounts) != null ? _c : []);
1732
+ }
1733
+ if (optionalScope) {
1734
+ scopeAccounts.push(...(_d = optionalScope.accounts) != null ? _d : []);
1735
+ }
1736
+ });
1737
+ const accounts = [...new Set(scopeAccounts)];
1738
+ console.log("\u{1F4DA} SDK connect");
1739
+ yield this.metamaskConnectMultichain.connect(
1740
+ scopes,
1741
+ accounts,
1742
+ createSessionParams.sessionProperties
1743
+ );
1744
+ console.log("\u{1F4DA} SDK connected");
1745
+ return this.metamaskConnectMultichain.transport.request({
1746
+ method: "wallet_getSession"
1747
+ });
1748
+ });
1749
+ };
1750
+ walletGetSession_fn = function(request) {
1751
+ return __async(this, null, function* () {
1752
+ if (!this.isTransportDefined()) {
1753
+ return {
1754
+ jsonrpc: "2.0",
1755
+ id: request.id,
1756
+ result: {
1757
+ sessionScopes: {}
1758
+ }
1759
+ };
1760
+ }
1761
+ return this.metamaskConnectMultichain.transport.request({
1762
+ method: "wallet_getSession"
1763
+ });
1764
+ });
1765
+ };
1766
+ walletRevokeSession_fn = function(request) {
1767
+ return __async(this, null, function* () {
1768
+ if (!this.isTransportDefined()) {
1769
+ return { jsonrpc: "2.0", id: request.id, result: true };
1770
+ }
1771
+ try {
1772
+ this.metamaskConnectMultichain.disconnect();
1773
+ return { jsonrpc: "2.0", id: request.id, result: true };
1774
+ } catch (_error) {
1775
+ return { jsonrpc: "2.0", id: request.id, result: false };
1776
+ }
1777
+ });
1778
+ };
1779
+ walletInvokeMethod_fn = function(request) {
1780
+ return __async(this, null, function* () {
1781
+ if (!this.isTransportDefined()) {
1782
+ return { error: providerErrors.unauthorized() };
1783
+ }
1784
+ const result = this.metamaskConnectMultichain.invokeMethod(
1785
+ request.params
1786
+ );
1787
+ return {
1788
+ result
1789
+ };
1790
+ });
1791
+ };
1792
+
1579
1793
  // src/multichain/transports/mwp/index.ts
1580
1794
  init_domain();
1581
1795
  init_utils();
@@ -2137,164 +2351,6 @@ var keymanager = new KeyManager();
2137
2351
 
2138
2352
  // src/multichain/index.ts
2139
2353
  init_utils();
2140
-
2141
- // src/multichain/transports/multichainApiClientWrapper/index.ts
2142
- import { providerErrors } from "@metamask/rpc-errors";
2143
- var MAX = 4294967295;
2144
- var idCounter = Math.floor(Math.random() * MAX);
2145
- var getUniqueId = () => {
2146
- idCounter = (idCounter + 1) % MAX;
2147
- return idCounter;
2148
- };
2149
- var _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn, walletGetSession_fn, walletRevokeSession_fn, walletInvokeMethod_fn;
2150
- var MultichainApiClientWrapperTransport = class {
2151
- constructor(metamaskConnectMultichain) {
2152
- this.metamaskConnectMultichain = metamaskConnectMultichain;
2153
- __privateAdd(this, _MultichainApiClientWrapperTransport_instances);
2154
- this.requestId = getUniqueId();
2155
- this.notificationCallbacks = /* @__PURE__ */ new Set();
2156
- }
2157
- isTransportDefined() {
2158
- try {
2159
- return Boolean(this.metamaskConnectMultichain.transport);
2160
- } catch (error) {
2161
- return false;
2162
- }
2163
- }
2164
- clearNotificationCallbacks() {
2165
- this.notificationCallbacks.clear();
2166
- }
2167
- notifyCallbacks(data) {
2168
- this.notificationCallbacks.forEach((callback) => {
2169
- callback(data);
2170
- });
2171
- }
2172
- setupNotifcationListener() {
2173
- this.metamaskConnectMultichain.transport.onNotification(
2174
- this.notifyCallbacks.bind(this)
2175
- );
2176
- }
2177
- connect() {
2178
- return __async(this, null, function* () {
2179
- console.log("\u{1F4DA} connect");
2180
- return Promise.resolve();
2181
- });
2182
- }
2183
- disconnect() {
2184
- return __async(this, null, function* () {
2185
- return Promise.resolve();
2186
- });
2187
- }
2188
- isConnected() {
2189
- return true;
2190
- }
2191
- request(_0) {
2192
- return __async(this, arguments, function* (params, _options = {}) {
2193
- const id = this.requestId++;
2194
- const requestPayload = __spreadValues({
2195
- id,
2196
- jsonrpc: "2.0"
2197
- }, params);
2198
- switch (requestPayload.method) {
2199
- case "wallet_createSession":
2200
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn).call(this, requestPayload);
2201
- case "wallet_getSession":
2202
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletGetSession_fn).call(this, requestPayload);
2203
- case "wallet_revokeSession":
2204
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletRevokeSession_fn).call(this, requestPayload);
2205
- case "wallet_invokeMethod":
2206
- return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletInvokeMethod_fn).call(this, requestPayload);
2207
- default:
2208
- throw new Error(`Unsupported method: ${requestPayload.method}`);
2209
- }
2210
- throw new Error(`Unknown method: ${requestPayload.method}`);
2211
- });
2212
- }
2213
- onNotification(callback) {
2214
- if (!this.isTransportDefined()) {
2215
- this.notificationCallbacks.add(callback);
2216
- return () => {
2217
- this.notificationCallbacks.delete(callback);
2218
- };
2219
- }
2220
- return this.metamaskConnectMultichain.transport.onNotification(callback);
2221
- }
2222
- };
2223
- _MultichainApiClientWrapperTransport_instances = new WeakSet();
2224
- walletCreateSession_fn = function(request) {
2225
- return __async(this, null, function* () {
2226
- console.log("\u{1F4DA} #walletCreateSession", request);
2227
- const createSessionParams = request.params;
2228
- const scopes = Object.keys(__spreadValues(__spreadValues({}, createSessionParams.optionalScopes), createSessionParams.requiredScopes));
2229
- const scopeAccounts = [];
2230
- scopes.forEach((scope) => {
2231
- var _a2, _b, _c, _d;
2232
- const requiredScope = (_a2 = createSessionParams.requiredScopes) == null ? void 0 : _a2[scope];
2233
- const optionalScope = (_b = createSessionParams.optionalScopes) == null ? void 0 : _b[scope];
2234
- if (requiredScope) {
2235
- scopeAccounts.push(...(_c = requiredScope.accounts) != null ? _c : []);
2236
- }
2237
- if (optionalScope) {
2238
- scopeAccounts.push(...(_d = optionalScope.accounts) != null ? _d : []);
2239
- }
2240
- });
2241
- const accounts = [...new Set(scopeAccounts)];
2242
- console.log("\u{1F4DA} SDK connect");
2243
- yield this.metamaskConnectMultichain.connect(
2244
- scopes,
2245
- accounts,
2246
- createSessionParams.sessionProperties
2247
- );
2248
- console.log("\u{1F4DA} SDK connected");
2249
- return this.metamaskConnectMultichain.transport.request({
2250
- method: "wallet_getSession"
2251
- });
2252
- });
2253
- };
2254
- walletGetSession_fn = function(request) {
2255
- return __async(this, null, function* () {
2256
- if (!this.isTransportDefined()) {
2257
- return {
2258
- jsonrpc: "2.0",
2259
- id: request.id,
2260
- result: {
2261
- sessionScopes: {}
2262
- }
2263
- };
2264
- }
2265
- return this.metamaskConnectMultichain.transport.request({
2266
- method: "wallet_getSession"
2267
- });
2268
- });
2269
- };
2270
- walletRevokeSession_fn = function(request) {
2271
- return __async(this, null, function* () {
2272
- if (!this.isTransportDefined()) {
2273
- return { jsonrpc: "2.0", id: request.id, result: true };
2274
- }
2275
- try {
2276
- this.metamaskConnectMultichain.disconnect();
2277
- return { jsonrpc: "2.0", id: request.id, result: true };
2278
- } catch (error) {
2279
- return { jsonrpc: "2.0", id: request.id, result: false };
2280
- }
2281
- });
2282
- };
2283
- walletInvokeMethod_fn = function(request) {
2284
- return __async(this, null, function* () {
2285
- if (!this.isTransportDefined()) {
2286
- return { error: providerErrors.unauthorized() };
2287
- }
2288
- const result = this.metamaskConnectMultichain.invokeMethod(
2289
- request.params
2290
- );
2291
- return {
2292
- result
2293
- };
2294
- });
2295
- };
2296
-
2297
- // src/multichain/index.ts
2298
2354
  var logger2 = createLogger("metamask-sdk:core");
2299
2355
  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;
2300
2356
  var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends MultichainCore {
@@ -2322,8 +2378,12 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2322
2378
  this._status = "pending";
2323
2379
  __privateAdd(this, _listener);
2324
2380
  __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}`);
2325
- __privateSet(this, _providerTransportWrapper, new MultichainApiClientWrapperTransport(this));
2326
- __privateSet(this, _provider, getMultichainClient({ transport: __privateGet(this, _providerTransportWrapper) }));
2381
+ __privateSet(this, _providerTransportWrapper, new MultichainApiClientWrapperTransport(
2382
+ this
2383
+ ));
2384
+ __privateSet(this, _provider, getMultichainClient({
2385
+ transport: __privateGet(this, _providerTransportWrapper)
2386
+ }));
2327
2387
  }
2328
2388
  get status() {
2329
2389
  return this._status;
@@ -2407,8 +2467,14 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2407
2467
  } catch (error) {
2408
2468
  logger2("Error tracking connection_initiated event", error);
2409
2469
  }
2470
+ const nonEmptySessionProperites = Object.keys(sessionProperties != null ? sessionProperties : {}).length > 0 ? sessionProperties : void 0;
2410
2471
  if (((_a2 = __privateGet(this, _transport2)) == null ? void 0 : _a2.isConnected()) && !secure) {
2411
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateGet(this, _transport2).connect({ scopes, caipAccountIds, sessionProperties, forceRequest }).then(() => __async(this, null, function* () {
2472
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateGet(this, _transport2).connect({
2473
+ scopes,
2474
+ caipAccountIds,
2475
+ sessionProperties: nonEmptySessionProperites,
2476
+ forceRequest
2477
+ }).then(() => __async(this, null, function* () {
2412
2478
  if (__privateGet(this, _transport2) instanceof MWPTransport) {
2413
2479
  return this.storage.setTransport("mwp" /* MWP */);
2414
2480
  }
@@ -2417,18 +2483,28 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2417
2483
  }
2418
2484
  if (platformType === "in-app-browser" /* MetaMaskMobileWebview */) {
2419
2485
  const defaultTransport = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupDefaultTransport_fn).call(this);
2420
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
2486
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({
2487
+ scopes,
2488
+ caipAccountIds,
2489
+ sessionProperties: nonEmptySessionProperites,
2490
+ forceRequest
2491
+ }), scopes, transportType);
2421
2492
  }
2422
2493
  if (isWeb && hasExtensionInstalled && preferExtension) {
2423
2494
  const defaultTransport = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupDefaultTransport_fn).call(this);
2424
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
2495
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, defaultTransport.connect({
2496
+ scopes,
2497
+ caipAccountIds,
2498
+ sessionProperties: nonEmptySessionProperites,
2499
+ forceRequest
2500
+ }), scopes, transportType);
2425
2501
  }
2426
2502
  yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupMWP_fn).call(this);
2427
2503
  const shouldShowInstallModal = hasExtensionInstalled ? showInstallModal : !preferExtension || showInstallModal;
2428
2504
  if (secure && !shouldShowInstallModal) {
2429
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, deeplinkConnect_fn).call(this, scopes, caipAccountIds, sessionProperties), scopes, transportType);
2505
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, deeplinkConnect_fn).call(this, scopes, caipAccountIds, nonEmptySessionProperites), scopes, transportType);
2430
2506
  }
2431
- return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, showInstallModal_fn).call(this, shouldShowInstallModal, scopes, caipAccountIds, sessionProperties), scopes, transportType);
2507
+ return __privateMethod(this, _MetaMaskConnectMultichain_instances, handleConnection_fn).call(this, __privateMethod(this, _MetaMaskConnectMultichain_instances, showInstallModal_fn).call(this, shouldShowInstallModal, scopes, caipAccountIds, nonEmptySessionProperites), scopes, transportType);
2432
2508
  });
2433
2509
  }
2434
2510
  emit(event, args) {
@@ -2683,7 +2759,11 @@ renderInstallModalAsync_fn = function(desktopPreferred, scopes, caipAccountIds,
2683
2759
  (() => __async(this, null, function* () {
2684
2760
  var _a2;
2685
2761
  try {
2686
- yield this.transport.connect({ scopes, caipAccountIds, sessionProperties });
2762
+ yield this.transport.connect({
2763
+ scopes,
2764
+ caipAccountIds,
2765
+ sessionProperties
2766
+ });
2687
2767
  yield this.options.ui.factory.unload();
2688
2768
  (_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.unmount();
2689
2769
  this.status = "connected";
@@ -2791,7 +2871,7 @@ setupDefaultTransport_fn = function() {
2791
2871
  };
2792
2872
  deeplinkConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
2793
2873
  return __async(this, null, function* () {
2794
- return new Promise((resolve, reject) => {
2874
+ return new Promise((resolve, reject) => __async(this, null, function* () {
2795
2875
  const dappClientMessageHandler = (payload) => {
2796
2876
  var _a2;
2797
2877
  if (typeof payload !== "object" || payload === null || !("data" in payload)) {
@@ -2850,7 +2930,7 @@ deeplinkConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
2850
2930
  clearTimeout(timeout);
2851
2931
  }
2852
2932
  });
2853
- });
2933
+ }));
2854
2934
  });
2855
2935
  };
2856
2936
  handleConnection_fn = function(promise, scopes, transportType) {
@@ -3143,7 +3223,9 @@ var BaseModalFactory = class {
3143
3223
  }
3144
3224
  createConnectionDeeplink(connectionRequest) {
3145
3225
  if (!connectionRequest) {
3146
- throw new Error("createConnectionDeeplink can only be called with a connection request");
3226
+ throw new Error(
3227
+ "createConnectionDeeplink can only be called with a connection request"
3228
+ );
3147
3229
  }
3148
3230
  const json = JSON.stringify(connectionRequest);
3149
3231
  const compressed = compressString(json);
@@ -3236,14 +3318,17 @@ var ModalFactory = class extends BaseModalFactory {
3236
3318
  // src/index.native.ts
3237
3319
  init_domain();
3238
3320
  var createMultichainClient = (options) => __async(null, null, function* () {
3321
+ if (options.debug) {
3322
+ enableDebug("metamask-sdk:*");
3323
+ }
3239
3324
  const uiModules = yield Promise.resolve().then(() => (init_rn(), rn_exports));
3240
3325
  let storage;
3241
- if (!options.storage) {
3326
+ if (options.storage) {
3327
+ storage = options.storage;
3328
+ } else {
3242
3329
  const { StoreAdapterRN: StoreAdapterRN2 } = yield Promise.resolve().then(() => (init_rn2(), rn_exports2));
3243
3330
  const adapter = new StoreAdapterRN2();
3244
3331
  storage = new Store(adapter);
3245
- } else {
3246
- storage = options.storage;
3247
3332
  }
3248
3333
  const factory = new ModalFactory(uiModules);
3249
3334
  return MetaMaskConnectMultichain.create(__spreadProps(__spreadValues({}, options), {