@metamask/connect-multichain 0.3.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +55 -15
  2. package/README.md +1 -1
  3. package/dist/browser/es/connect-multichain.d.mts +26 -12
  4. package/dist/browser/es/connect-multichain.mjs +846 -598
  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 +26 -12
  8. package/dist/browser/iife/connect-multichain.js +4793 -2291
  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 +26 -12
  12. package/dist/browser/umd/connect-multichain.js +846 -598
  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 +26 -12
  16. package/dist/node/cjs/connect-multichain.js +846 -609
  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 +26 -12
  20. package/dist/node/es/connect-multichain.mjs +844 -607
  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 +26 -12
  24. package/dist/react-native/es/connect-multichain.mjs +827 -592
  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/multichain/index.d.ts +4 -4
  28. package/dist/src/domain/multichain/index.d.ts.map +1 -1
  29. package/dist/src/domain/multichain/index.js.map +1 -1
  30. package/dist/src/domain/multichain/types.d.ts +4 -6
  31. package/dist/src/domain/multichain/types.d.ts.map +1 -1
  32. package/dist/src/domain/ui/types.d.ts +7 -0
  33. package/dist/src/domain/ui/types.d.ts.map +1 -1
  34. package/dist/src/domain/ui/types.js.map +1 -1
  35. package/dist/src/index.browser.d.ts +1 -1
  36. package/dist/src/index.browser.d.ts.map +1 -1
  37. package/dist/src/index.browser.js +1 -1
  38. package/dist/src/index.browser.js.map +1 -1
  39. package/dist/src/index.native.d.ts +1 -1
  40. package/dist/src/index.native.d.ts.map +1 -1
  41. package/dist/src/index.native.js +2 -2
  42. package/dist/src/index.native.js.map +1 -1
  43. package/dist/src/index.node.d.ts +1 -1
  44. package/dist/src/index.node.d.ts.map +1 -1
  45. package/dist/src/index.node.js +1 -1
  46. package/dist/src/index.node.js.map +1 -1
  47. package/dist/src/multichain/index.d.ts +8 -27
  48. package/dist/src/multichain/index.d.ts.map +1 -1
  49. package/dist/src/multichain/index.js +480 -427
  50. package/dist/src/multichain/index.js.map +1 -1
  51. package/dist/src/multichain/rpc/requestRouter.d.ts.map +1 -1
  52. package/dist/src/multichain/rpc/requestRouter.js +8 -15
  53. package/dist/src/multichain/rpc/requestRouter.js.map +1 -1
  54. package/dist/src/multichain/transports/default/index.d.ts +2 -1
  55. package/dist/src/multichain/transports/default/index.d.ts.map +1 -1
  56. package/dist/src/multichain/transports/default/index.js +1 -0
  57. package/dist/src/multichain/transports/default/index.js.map +1 -1
  58. package/dist/src/multichain/transports/multichainApiClientWrapper/index.d.ts +21 -0
  59. package/dist/src/multichain/transports/multichainApiClientWrapper/index.d.ts.map +1 -0
  60. package/dist/src/multichain/transports/multichainApiClientWrapper/index.js +159 -0
  61. package/dist/src/multichain/transports/multichainApiClientWrapper/index.js.map +1 -0
  62. package/dist/src/multichain/transports/mwp/index.d.ts +4 -1
  63. package/dist/src/multichain/transports/mwp/index.d.ts.map +1 -1
  64. package/dist/src/multichain/transports/mwp/index.js +76 -6
  65. package/dist/src/multichain/transports/mwp/index.js.map +1 -1
  66. package/dist/src/ui/ModalFactory.d.ts +54 -0
  67. package/dist/src/ui/ModalFactory.d.ts.map +1 -0
  68. package/dist/src/ui/ModalFactory.js +171 -0
  69. package/dist/src/ui/ModalFactory.js.map +1 -0
  70. package/dist/src/ui/index.d.ts +11 -39
  71. package/dist/src/ui/index.d.ts.map +1 -1
  72. package/dist/src/ui/index.js +20 -179
  73. package/dist/src/ui/index.js.map +1 -1
  74. package/dist/src/ui/index.native.d.ts +13 -0
  75. package/dist/src/ui/index.native.d.ts.map +1 -0
  76. package/dist/src/ui/index.native.js +24 -0
  77. package/dist/src/ui/index.native.js.map +1 -0
  78. package/dist/src/ui/modals/base/AbstractInstallModal.d.ts.map +1 -1
  79. package/dist/src/ui/modals/base/AbstractInstallModal.js +0 -4
  80. package/dist/src/ui/modals/base/AbstractInstallModal.js.map +1 -1
  81. package/dist/src/ui/modals/node/install.js +2 -2
  82. package/dist/src/ui/modals/node/install.js.map +1 -1
  83. package/dist/types/connect-multichain.d.ts +26 -12
  84. package/package.json +10 -8
  85. package/dist/src/ui/qr.d.ts +0 -3
  86. package/dist/src/ui/qr.d.ts.map +0 -1
  87. package/dist/src/ui/qr.js +0 -32
  88. package/dist/src/ui/qr.js.map +0 -1
@@ -235,8 +235,8 @@ var init_logger = __esm({
235
235
  debug.enable(namespace);
236
236
  };
237
237
  isEnabled = (namespace, storage) => __async(null, null, function* () {
238
- var _a;
239
- if ("process" in globalThis && ((_a = process == null ? void 0 : process.env) == null ? void 0 : _a.DEBUG)) {
238
+ var _a2;
239
+ if ("process" in globalThis && ((_a2 = process == null ? void 0 : process.env) == null ? void 0 : _a2.DEBUG)) {
240
240
  const { DEBUG } = process.env;
241
241
  return isNamespaceEnabled(DEBUG, namespace);
242
242
  }
@@ -406,35 +406,35 @@ var init_multichain = __esm({
406
406
  // src/domain/platform/index.ts
407
407
  import Bowser from "bowser";
408
408
  function isNotBrowser() {
409
- var _a;
409
+ var _a2;
410
410
  if (typeof window === "undefined") {
411
411
  return true;
412
412
  }
413
413
  if (!(window == null ? void 0 : window.navigator)) {
414
414
  return true;
415
415
  }
416
- if (typeof global !== "undefined" && ((_a = global == null ? void 0 : global.navigator) == null ? void 0 : _a.product) === "ReactNative") {
416
+ if (typeof global !== "undefined" && ((_a2 = global == null ? void 0 : global.navigator) == null ? void 0 : _a2.product) === "ReactNative") {
417
417
  return true;
418
418
  }
419
419
  return (navigator == null ? void 0 : navigator.product) === "ReactNative";
420
420
  }
421
421
  function isReactNative() {
422
- var _a;
422
+ var _a2;
423
423
  const hasWindowNavigator = typeof window !== "undefined" && window.navigator !== void 0;
424
424
  const nav = hasWindowNavigator ? window.navigator : void 0;
425
425
  if (!nav) {
426
426
  return false;
427
427
  }
428
- return hasWindowNavigator && ((_a = window.navigator) == null ? void 0 : _a.product) === "ReactNative";
428
+ return hasWindowNavigator && ((_a2 = window.navigator) == null ? void 0 : _a2.product) === "ReactNative";
429
429
  }
430
430
  function isMetaMaskMobileWebView() {
431
431
  return typeof window !== "undefined" && // @ts-expect-error ReactNativeWebView should be defined
432
432
  Boolean(window.ReactNativeWebView) && Boolean(window.navigator.userAgent.endsWith("MetaMaskMobile"));
433
433
  }
434
434
  function isMobile() {
435
- var _a, _b;
435
+ var _a2, _b;
436
436
  const browser = Bowser.parse(window.navigator.userAgent);
437
- return ((_a = browser == null ? void 0 : browser.platform) == null ? void 0 : _a.type) === "mobile" || ((_b = browser == null ? void 0 : browser.platform) == null ? void 0 : _b.type) === "tablet";
437
+ return ((_a2 = browser == null ? void 0 : browser.platform) == null ? void 0 : _a2.type) === "mobile" || ((_b = browser == null ? void 0 : browser.platform) == null ? void 0 : _b.type) === "tablet";
438
438
  }
439
439
  function getPlatformType() {
440
440
  if (isReactNative()) {
@@ -452,11 +452,11 @@ function getPlatformType() {
452
452
  return "web-desktop" /* DesktopWeb */;
453
453
  }
454
454
  function isMetamaskExtensionInstalled() {
455
- var _a;
455
+ var _a2;
456
456
  if (typeof window === "undefined") {
457
457
  return false;
458
458
  }
459
- return Boolean((_a = window.ethereum) == null ? void 0 : _a.isMetaMask);
459
+ return Boolean((_a2 = window.ethereum) == null ? void 0 : _a2.isMetaMask);
460
460
  }
461
461
  function isSecure() {
462
462
  const platformType = getPlatformType();
@@ -487,8 +487,8 @@ var init_platform = __esm({
487
487
  return new Promise((resolve) => {
488
488
  const providers = [];
489
489
  const handler = (event) => {
490
- var _a, _b;
491
- if ((_b = (_a = event == null ? void 0 : event.detail) == null ? void 0 : _a.info) == null ? void 0 : _b.rdns) {
490
+ var _a2, _b;
491
+ if ((_b = (_a2 = event == null ? void 0 : event.detail) == null ? void 0 : _a2.info) == null ? void 0 : _b.rdns) {
492
492
  providers.push(event.detail);
493
493
  }
494
494
  };
@@ -498,8 +498,8 @@ var init_platform = __esm({
498
498
  window.removeEventListener("eip6963:announceProvider", handler);
499
499
  const hasMetaMask = providers.some(
500
500
  (provider) => {
501
- var _a, _b;
502
- return (_b = (_a = provider == null ? void 0 : provider.info) == null ? void 0 : _a.rdns) == null ? void 0 : _b.startsWith("io.metamask");
501
+ var _a2, _b;
502
+ return (_b = (_a2 = provider == null ? void 0 : provider.info) == null ? void 0 : _a2.rdns) == null ? void 0 : _b.startsWith("io.metamask");
503
503
  }
504
504
  );
505
505
  resolve(hasMetaMask);
@@ -603,8 +603,8 @@ function compressString(str) {
603
603
  return base64Encode(binaryString);
604
604
  }
605
605
  function getDappId(dapp) {
606
- var _a;
607
- return (_a = dapp.url) != null ? _a : dapp.name;
606
+ var _a2;
607
+ return (_a2 = dapp.url) != null ? _a2 : dapp.name;
608
608
  }
609
609
  function openDeeplink(options, deeplink, universalLink) {
610
610
  const { mobile } = options;
@@ -634,10 +634,10 @@ function getOptionalScopes(scopes) {
634
634
  );
635
635
  }
636
636
  function setupDappMetadata(options) {
637
- var _a, _b;
637
+ var _a2, _b;
638
638
  const platform = getPlatformType();
639
639
  const isBrowser = platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */ || platform === "in-app-browser" /* MetaMaskMobileWebview */;
640
- if (!((_a = options.dapp) == null ? void 0 : _a.name)) {
640
+ if (!((_a2 = options.dapp) == null ? void 0 : _a2.name)) {
641
641
  throw new Error("You must provide dapp name");
642
642
  }
643
643
  if (isBrowser) {
@@ -708,17 +708,17 @@ function getValidAccounts(caipAccountIds) {
708
708
  );
709
709
  }
710
710
  function addValidAccounts(optionalScopes, validAccounts) {
711
- var _a;
711
+ var _a2;
712
712
  if (!optionalScopes || !(validAccounts == null ? void 0 : validAccounts.length)) {
713
713
  return optionalScopes;
714
714
  }
715
715
  const result = Object.fromEntries(
716
716
  Object.entries(optionalScopes).map(([scope, scopeData]) => {
717
- var _a2, _b, _c;
717
+ var _a3, _b, _c;
718
718
  return [
719
719
  scope,
720
720
  {
721
- methods: [...(_a2 = scopeData == null ? void 0 : scopeData.methods) != null ? _a2 : []],
721
+ methods: [...(_a3 = scopeData == null ? void 0 : scopeData.methods) != null ? _a3 : []],
722
722
  notifications: [...(_b = scopeData == null ? void 0 : scopeData.notifications) != null ? _b : []],
723
723
  accounts: [...(_c = scopeData == null ? void 0 : scopeData.accounts) != null ? _c : []]
724
724
  }
@@ -732,7 +732,7 @@ function addValidAccounts(optionalScopes, validAccounts) {
732
732
  if (!accountsByChain.has(chainKey)) {
733
733
  accountsByChain.set(chainKey, []);
734
734
  }
735
- (_a = accountsByChain.get(chainKey)) == null ? void 0 : _a.push(accountId);
735
+ (_a2 = accountsByChain.get(chainKey)) == null ? void 0 : _a2.push(accountId);
736
736
  }
737
737
  for (const [scopeKey, scopeData] of Object.entries(result)) {
738
738
  if (!(scopeData == null ? void 0 : scopeData.accounts)) {
@@ -762,7 +762,7 @@ var init_utils = __esm({
762
762
  "use strict";
763
763
  init_domain();
764
764
  extractFavicon = () => {
765
- var _a;
765
+ var _a2;
766
766
  if (typeof document === "undefined") {
767
767
  return void 0;
768
768
  }
@@ -770,7 +770,7 @@ var init_utils = __esm({
770
770
  const nodeList = document.getElementsByTagName("link");
771
771
  for (let i = 0; i < nodeList.length; i++) {
772
772
  if (nodeList[i].getAttribute("rel") === "icon" || nodeList[i].getAttribute("rel") === "shortcut icon") {
773
- favicon = (_a = nodeList[i].getAttribute("href")) != null ? _a : void 0;
773
+ favicon = (_a2 = nodeList[i].getAttribute("href")) != null ? _a2 : void 0;
774
774
  }
775
775
  }
776
776
  return favicon;
@@ -780,25 +780,25 @@ var init_utils = __esm({
780
780
 
781
781
  // src/multichain/utils/analytics.ts
782
782
  function isRejectionError(error) {
783
- var _a, _b;
783
+ var _a2, _b;
784
784
  if (typeof error !== "object" || error === null) {
785
785
  return false;
786
786
  }
787
787
  const errorObj = error;
788
788
  const errorCode = errorObj.code;
789
- const errorMessage = (_b = (_a = errorObj.message) == null ? void 0 : _a.toLowerCase()) != null ? _b : "";
789
+ const errorMessage = (_b = (_a2 = errorObj.message) == null ? void 0 : _a2.toLowerCase()) != null ? _b : "";
790
790
  return errorCode === 4001 || // User rejected request (common EIP-1193 code)
791
791
  errorCode === 4100 || // Unauthorized (common rejection code)
792
792
  errorMessage.includes("reject") || errorMessage.includes("denied") || errorMessage.includes("cancel") || errorMessage.includes("user");
793
793
  }
794
794
  function getBaseAnalyticsProperties(options, storage) {
795
795
  return __async(this, null, function* () {
796
- var _a, _b;
796
+ var _a2, _b;
797
797
  const version = getVersion();
798
798
  const dappId = getDappId(options.dapp);
799
799
  const platform = getPlatformType();
800
800
  const anonId = yield storage.getAnonId();
801
- const integrationType = (_b = (_a = options.analytics) == null ? void 0 : _a.integrationType) != null ? _b : "unknown" /* UNKNOWN */;
801
+ const integrationType = (_b = (_a2 = options.analytics) == null ? void 0 : _a2.integrationType) != null ? _b : "unknown" /* UNKNOWN */;
802
802
  return {
803
803
  mmconnect_version: version,
804
804
  dapp_id: dappId,
@@ -810,11 +810,11 @@ function getBaseAnalyticsProperties(options, storage) {
810
810
  }
811
811
  function getWalletActionAnalyticsProperties(options, storage, invokeOptions) {
812
812
  return __async(this, null, function* () {
813
- var _a, _b;
813
+ var _a2, _b;
814
814
  const version = getVersion();
815
815
  const dappId = getDappId(options.dapp);
816
816
  const anonId = yield storage.getAnonId();
817
- const integrationType = (_b = (_a = options.analytics) == null ? void 0 : _a.integrationType) != null ? _b : "unknown";
817
+ const integrationType = (_b = (_a2 = options.analytics) == null ? void 0 : _a2.integrationType) != null ? _b : "unknown";
818
818
  return {
819
819
  mmconnect_version: version,
820
820
  dapp_id: dappId,
@@ -955,11 +955,6 @@ var init_AbstractInstallModal = __esm({
955
955
  `[UI: InstallModal-nodejs()] \u274C Error generating new QR code: ${error}`
956
956
  );
957
957
  }
958
- } else {
959
- const generateQRCode = yield this.options.generateQRCode(
960
- currentConnectionRequest
961
- );
962
- this.renderQRCode(generateQRCode, currentConnectionRequest);
963
958
  }
964
959
  }), 1e3);
965
960
  }
@@ -1140,8 +1135,8 @@ var RpcClient = class {
1140
1135
  });
1141
1136
  }
1142
1137
  getRpcEndpoint(scope) {
1143
- var _a, _b, _c;
1144
- const supportedNetworks = (_c = (_b = (_a = this.config) == null ? void 0 : _a.api) == null ? void 0 : _b.supportedNetworks) != null ? _c : {};
1138
+ var _a2, _b, _c;
1139
+ const supportedNetworks = (_c = (_b = (_a2 = this.config) == null ? void 0 : _a2.api) == null ? void 0 : _b.supportedNetworks) != null ? _c : {};
1145
1140
  const rpcEndpoint = supportedNetworks[scope];
1146
1141
  if (!rpcEndpoint) {
1147
1142
  throw new MissingRpcEndpointErr(`No RPC endpoint found for scope ${scope}`);
@@ -1296,24 +1291,17 @@ var RequestRouter = class {
1296
1291
  _RequestRouter_instances = new WeakSet();
1297
1292
  withAnalyticsTracking_fn = function(options, execute) {
1298
1293
  return __async(this, null, function* () {
1299
- var _a, _b, _c;
1300
- if ((_a = this.config.analytics) == null ? void 0 : _a.enabled) {
1301
- yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRequested_fn).call(this, options);
1302
- }
1294
+ yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRequested_fn).call(this, options);
1303
1295
  try {
1304
1296
  const result = yield execute();
1305
- if ((_b = this.config.analytics) == null ? void 0 : _b.enabled) {
1306
- yield __privateMethod(this, _RequestRouter_instances, trackWalletActionSucceeded_fn).call(this, options);
1307
- }
1297
+ yield __privateMethod(this, _RequestRouter_instances, trackWalletActionSucceeded_fn).call(this, options);
1308
1298
  return result;
1309
1299
  } catch (error) {
1310
- if ((_c = this.config.analytics) == null ? void 0 : _c.enabled) {
1311
- const isRejection = isRejectionError(error);
1312
- if (isRejection) {
1313
- yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRejected_fn).call(this, options);
1314
- } else {
1315
- yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options);
1316
- }
1300
+ const isRejection = isRejectionError(error);
1301
+ if (isRejection) {
1302
+ yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRejected_fn).call(this, options);
1303
+ } else {
1304
+ yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options);
1317
1305
  }
1318
1306
  throw new RPCInvokeMethodErr(error.message);
1319
1307
  }
@@ -1375,11 +1363,11 @@ var DefaultTransport = class {
1375
1363
  id: requestId
1376
1364
  }, payload);
1377
1365
  return new Promise((resolve, reject) => {
1378
- var _a;
1366
+ var _a2;
1379
1367
  const timeout = setTimeout(() => {
1380
1368
  __privateGet(this, _pendingRequests).delete(requestId);
1381
1369
  reject(new Error("Request timeout"));
1382
- }, (_a = options == null ? void 0 : options.timeout) != null ? _a : __privateGet(this, _defaultRequestOptions).timeout);
1370
+ }, (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : __privateGet(this, _defaultRequestOptions).timeout);
1383
1371
  __privateGet(this, _pendingRequests).set(requestId, {
1384
1372
  resolve: (response) => {
1385
1373
  resolve(response);
@@ -1403,7 +1391,7 @@ var DefaultTransport = class {
1403
1391
  }
1404
1392
  connect(options) {
1405
1393
  return __async(this, null, function* () {
1406
- var _a, _b, _c, _d, _e, _f, _g;
1394
+ var _a2, _b, _c, _d, _e, _f, _g;
1407
1395
  __privateMethod(this, _DefaultTransport_instances, setupMessageListener_fn).call(this);
1408
1396
  yield __privateGet(this, _transport).connect();
1409
1397
  const sessionRequest = yield this.request(
@@ -1416,7 +1404,7 @@ var DefaultTransport = class {
1416
1404
  let walletSession = sessionRequest.result;
1417
1405
  if (walletSession && options && !options.forceRequest) {
1418
1406
  const currentScopes = Object.keys(
1419
- (_a = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _a : {}
1407
+ (_a2 = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _a2 : {}
1420
1408
  );
1421
1409
  const proposedScopes = (_b = options == null ? void 0 : options.scopes) != null ? _b : [];
1422
1410
  const proposedCaipAccountIds = (_c = options == null ? void 0 : options.caipAccountIds) != null ? _c : [];
@@ -1453,7 +1441,8 @@ var DefaultTransport = class {
1453
1441
  getValidAccounts((_g = options == null ? void 0 : options.caipAccountIds) != null ? _g : [])
1454
1442
  );
1455
1443
  const createSessionParams = {
1456
- optionalScopes
1444
+ optionalScopes,
1445
+ sessionProperties: options == null ? void 0 : options.sessionProperties
1457
1446
  };
1458
1447
  const response = yield this.request(
1459
1448
  { method: "wallet_createSession", params: createSessionParams },
@@ -1530,16 +1519,16 @@ notifyCallbacks_fn = function(data) {
1530
1519
  }
1531
1520
  };
1532
1521
  isMetamaskProviderEvent_fn = function(event) {
1533
- var _a, _b;
1534
- return ((_b = (_a = event == null ? void 0 : event.data) == null ? void 0 : _a.data) == null ? void 0 : _b.name) === "metamask-provider" && // eslint-disable-next-line no-restricted-globals
1522
+ var _a2, _b;
1523
+ return ((_b = (_a2 = event == null ? void 0 : event.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.name) === "metamask-provider" && // eslint-disable-next-line no-restricted-globals
1535
1524
  event.origin === location.origin;
1536
1525
  };
1537
1526
  handleResponse_fn = function(event) {
1538
- var _a, _b;
1527
+ var _a2, _b;
1539
1528
  if (!__privateMethod(this, _DefaultTransport_instances, isMetamaskProviderEvent_fn).call(this, event)) {
1540
1529
  return;
1541
1530
  }
1542
- const responseData = (_b = (_a = event == null ? void 0 : event.data) == null ? void 0 : _a.data) == null ? void 0 : _b.data;
1531
+ const responseData = (_b = (_a2 = event == null ? void 0 : event.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.data;
1543
1532
  if (typeof responseData === "object" && responseData !== null && "method" in responseData) {
1544
1533
  return;
1545
1534
  }
@@ -1561,11 +1550,11 @@ handleResponse_fn = function(event) {
1561
1550
  }
1562
1551
  };
1563
1552
  handleNotification_fn = function(event) {
1564
- var _a, _b;
1553
+ var _a2, _b;
1565
1554
  if (!__privateMethod(this, _DefaultTransport_instances, isMetamaskProviderEvent_fn).call(this, event)) {
1566
1555
  return;
1567
1556
  }
1568
- const responseData = (_b = (_a = event == null ? void 0 : event.data) == null ? void 0 : _a.data) == null ? void 0 : _b.data;
1557
+ const responseData = (_b = (_a2 = event == null ? void 0 : event.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.data;
1569
1558
  if (typeof responseData === "object" && responseData.method === "metamask_chainChanged" || responseData.method === "metamask_accountsChanged") {
1570
1559
  __privateMethod(this, _DefaultTransport_instances, notifyCallbacks_fn).call(this, responseData);
1571
1560
  }
@@ -1595,6 +1584,7 @@ var MULTICHAIN_PROVIDER_STREAM_NAME = "metamask-multichain-provider";
1595
1584
  var DEFAULT_REQUEST_TIMEOUT2 = 60 * 1e3;
1596
1585
  var CONNECTION_GRACE_PERIOD = 60 * 1e3;
1597
1586
  var DEFAULT_CONNECTION_TIMEOUT = DEFAULT_REQUEST_TIMEOUT2 + CONNECTION_GRACE_PERIOD;
1587
+ var DEFAULT_RESUME_TIMEOUT = 10 * 1e3;
1598
1588
  var SESSION_STORE_KEY = "cache_wallet_getSession";
1599
1589
  var ACCOUNTS_STORE_KEY = "cache_eth_accounts";
1600
1590
  var CHAIN_STORE_KEY = "cache_eth_chainId";
@@ -1611,7 +1601,8 @@ var logger = createLogger("metamask-sdk:transport");
1611
1601
  var MWPTransport = class {
1612
1602
  constructor(dappClient, kvstore, options = {
1613
1603
  requestTimeout: DEFAULT_REQUEST_TIMEOUT2,
1614
- connectionTimeout: DEFAULT_CONNECTION_TIMEOUT
1604
+ connectionTimeout: DEFAULT_CONNECTION_TIMEOUT,
1605
+ resumeTimeout: DEFAULT_RESUME_TIMEOUT
1615
1606
  }) {
1616
1607
  this.dappClient = dappClient;
1617
1608
  this.kvstore = kvstore;
@@ -1686,6 +1677,13 @@ var MWPTransport = class {
1686
1677
  )
1687
1678
  );
1688
1679
  }
1680
+ if (message.data.method === "wallet_sessionChanged") {
1681
+ const notification = message.data;
1682
+ const response = {
1683
+ result: notification.params
1684
+ };
1685
+ this.kvstore.set(SESSION_STORE_KEY, JSON.stringify(response));
1686
+ }
1689
1687
  this.notifyCallbacks(message.data);
1690
1688
  }
1691
1689
  }
@@ -1693,8 +1691,9 @@ var MWPTransport = class {
1693
1691
  }
1694
1692
  onResumeSuccess(resumeResolve, resumeReject, options) {
1695
1693
  return __async(this, null, function* () {
1696
- var _a, _b, _c, _d, _e, _f, _g;
1694
+ var _a2, _b, _c, _d, _e, _f, _g;
1697
1695
  try {
1696
+ yield this.waitForWalletSessionIfNotCached();
1698
1697
  const sessionRequest = yield this.request({
1699
1698
  method: "wallet_getSession"
1700
1699
  });
@@ -1704,7 +1703,7 @@ var MWPTransport = class {
1704
1703
  let walletSession = sessionRequest.result;
1705
1704
  if (walletSession && options) {
1706
1705
  const currentScopes = Object.keys(
1707
- (_a = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _a : {}
1706
+ (_a2 = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _a2 : {}
1708
1707
  );
1709
1708
  const proposedScopes = (_b = options == null ? void 0 : options.scopes) != null ? _b : [];
1710
1709
  const proposedCaipAccountIds = (_c = options == null ? void 0 : options.caipAccountIds) != null ? _c : [];
@@ -1769,10 +1768,10 @@ var MWPTransport = class {
1769
1768
  return cachedWalletSession;
1770
1769
  }
1771
1770
  return new Promise((resolve, reject) => {
1772
- var _a;
1771
+ var _a2;
1773
1772
  const timeout = setTimeout(() => {
1774
1773
  this.rejectRequest(request.id, new TransportTimeoutError());
1775
- }, (_a = options == null ? void 0 : options.timeout) != null ? _a : this.options.requestTimeout);
1774
+ }, (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : this.options.requestTimeout);
1776
1775
  this.pendingRequests.set(request.id, {
1777
1776
  request,
1778
1777
  method: request.method,
@@ -1798,30 +1797,32 @@ var MWPTransport = class {
1798
1797
  logger("active session found", session);
1799
1798
  }
1800
1799
  let timeout;
1801
- const connectionPromise = new Promise((resolve, reject) => {
1800
+ let initialConnectionMessageHandler;
1801
+ const connectionPromise = new Promise((resolve, reject) => __async(this, null, function* () {
1802
1802
  let connection;
1803
1803
  if (session) {
1804
1804
  connection = new Promise((resumeResolve, resumeReject) => {
1805
- var _a;
1805
+ var _a2;
1806
1806
  if (this.dappClient.state === "CONNECTED") {
1807
1807
  this.onResumeSuccess(resumeResolve, resumeReject, options);
1808
1808
  } else {
1809
1809
  this.dappClient.once("connected", () => __async(this, null, function* () {
1810
1810
  this.onResumeSuccess(resumeResolve, resumeReject, options);
1811
1811
  }));
1812
- dappClient.resume((_a = session == null ? void 0 : session.id) != null ? _a : "");
1812
+ dappClient.resume((_a2 = session == null ? void 0 : session.id) != null ? _a2 : "");
1813
1813
  }
1814
1814
  });
1815
1815
  } else {
1816
1816
  connection = new Promise(
1817
1817
  (resolveConnection, rejectConnection) => {
1818
- var _a, _b;
1818
+ var _a2, _b;
1819
1819
  const optionalScopes = addValidAccounts(
1820
- getOptionalScopes((_a = options == null ? void 0 : options.scopes) != null ? _a : []),
1820
+ getOptionalScopes((_a2 = options == null ? void 0 : options.scopes) != null ? _a2 : []),
1821
1821
  getValidAccounts((_b = options == null ? void 0 : options.caipAccountIds) != null ? _b : [])
1822
1822
  );
1823
1823
  const sessionRequest = {
1824
- optionalScopes
1824
+ optionalScopes,
1825
+ sessionProperties: options == null ? void 0 : options.sessionProperties
1825
1826
  };
1826
1827
  const request = {
1827
1828
  jsonrpc: "2.0",
@@ -1829,12 +1830,18 @@ var MWPTransport = class {
1829
1830
  method: "wallet_createSession",
1830
1831
  params: sessionRequest
1831
1832
  };
1832
- this.dappClient.on("message", (message) => __async(this, null, function* () {
1833
+ initialConnectionMessageHandler = (message) => __async(this, null, function* () {
1833
1834
  if (typeof message === "object" && message !== null) {
1834
1835
  if ("data" in message) {
1835
1836
  const messagePayload = message.data;
1836
1837
  if (messagePayload.method === "wallet_createSession" || messagePayload.method === "wallet_sessionChanged") {
1837
1838
  if (messagePayload.error) {
1839
+ if (initialConnectionMessageHandler) {
1840
+ this.dappClient.off(
1841
+ "message",
1842
+ initialConnectionMessageHandler
1843
+ );
1844
+ }
1838
1845
  return rejectConnection(messagePayload.error);
1839
1846
  }
1840
1847
  yield this.storeWalletSession(
@@ -1846,14 +1853,23 @@ var MWPTransport = class {
1846
1853
  }
1847
1854
  }
1848
1855
  }
1849
- }));
1856
+ });
1857
+ this.dappClient.on("message", initialConnectionMessageHandler);
1850
1858
  dappClient.connect({
1851
1859
  mode: "trusted",
1852
1860
  initialPayload: {
1853
1861
  name: MULTICHAIN_PROVIDER_STREAM_NAME,
1854
1862
  data: request
1855
1863
  }
1856
- }).catch(rejectConnection);
1864
+ }).catch((error) => {
1865
+ if (initialConnectionMessageHandler) {
1866
+ this.dappClient.off(
1867
+ "message",
1868
+ initialConnectionMessageHandler
1869
+ );
1870
+ }
1871
+ rejectConnection(error);
1872
+ });
1857
1873
  }
1858
1874
  );
1859
1875
  }
@@ -1861,11 +1877,17 @@ var MWPTransport = class {
1861
1877
  reject(new TransportTimeoutError());
1862
1878
  }, this.options.connectionTimeout);
1863
1879
  connection.then(resolve).catch(reject);
1864
- });
1865
- return connectionPromise.finally(() => {
1880
+ }));
1881
+ return connectionPromise.catch((error) => {
1882
+ throw error;
1883
+ }).finally(() => {
1866
1884
  if (timeout) {
1867
1885
  clearTimeout(timeout);
1868
1886
  }
1887
+ if (initialConnectionMessageHandler) {
1888
+ this.dappClient.off("message", initialConnectionMessageHandler);
1889
+ initialConnectionMessageHandler = void 0;
1890
+ }
1869
1891
  });
1870
1892
  });
1871
1893
  }
@@ -1928,7 +1950,7 @@ var MWPTransport = class {
1928
1950
  }
1929
1951
  getCachedResponse(request) {
1930
1952
  return __async(this, null, function* () {
1931
- var _a;
1953
+ var _a2;
1932
1954
  if (request.method === "wallet_getSession") {
1933
1955
  const walletGetSession = yield this.kvstore.get(SESSION_STORE_KEY);
1934
1956
  if (walletGetSession) {
@@ -1936,7 +1958,7 @@ var MWPTransport = class {
1936
1958
  return {
1937
1959
  id: request.id,
1938
1960
  jsonrpc: "2.0",
1939
- result: (_a = walletSession.params) != null ? _a : walletSession.result,
1961
+ result: (_a2 = walletSession.params) != null ? _a2 : walletSession.result,
1940
1962
  // "what?... why walletSession.params?.."
1941
1963
  method: request.method
1942
1964
  };
@@ -2000,10 +2022,10 @@ var MWPTransport = class {
2000
2022
  yield this.attemptResumeSession();
2001
2023
  }
2002
2024
  return new Promise((resolve, reject) => {
2003
- var _a;
2025
+ var _a2;
2004
2026
  const timeout = setTimeout(() => {
2005
2027
  this.rejectRequest(request.id, new TransportTimeoutError());
2006
- }, (_a = options == null ? void 0 : options.timeout) != null ? _a : this.options.requestTimeout);
2028
+ }, (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : this.options.requestTimeout);
2007
2029
  this.pendingRequests.set(request.id, {
2008
2030
  request,
2009
2031
  method: request.method,
@@ -2040,6 +2062,43 @@ var MWPTransport = class {
2040
2062
  }
2041
2063
  });
2042
2064
  }
2065
+ // This method checks if an existing CAIP session response is cached or waits for one
2066
+ // to be received from the wallet if not cached. This is necessary because there is an edge
2067
+ // case during the initial connection flow where after the user has accepted the permission approval
2068
+ // and returned back to the dapp from the wallet, the dapp page may have gotten unloaded and refreshed.
2069
+ // When it is unloaded and refreshed, it will try to resume the session by making a request for wallet_getSession
2070
+ // which should resolve from cache, but because a race condition makes it possible for the response from the wallet
2071
+ // for the initial wallet_createSession connection request to not have been handled and cached yet. This results
2072
+ // in the wallet_getSession request never resolving unless we wait for it explicitly as done in this method.
2073
+ waitForWalletSessionIfNotCached() {
2074
+ return __async(this, null, function* () {
2075
+ const cachedWalletGetSessionResponse = yield this.kvstore.get(SESSION_STORE_KEY);
2076
+ if (cachedWalletGetSessionResponse) {
2077
+ return;
2078
+ }
2079
+ let unsubscribe;
2080
+ const responsePromise = new Promise((resolve) => {
2081
+ unsubscribe = this.onNotification((message) => {
2082
+ if (typeof message === "object" && message !== null) {
2083
+ if ("data" in message) {
2084
+ const messagePayload = message.data;
2085
+ if (messagePayload.method === "wallet_getSession" || messagePayload.method === "wallet_sessionChanged") {
2086
+ unsubscribe();
2087
+ resolve();
2088
+ }
2089
+ }
2090
+ }
2091
+ });
2092
+ });
2093
+ const timeoutPromise = new Promise((_resolve, reject) => {
2094
+ setTimeout(() => {
2095
+ unsubscribe();
2096
+ reject(new TransportTimeoutError());
2097
+ }, this.options.resumeTimeout);
2098
+ });
2099
+ return Promise.race([responsePromise, timeoutPromise]);
2100
+ });
2101
+ }
2043
2102
  };
2044
2103
 
2045
2104
  // src/multichain/transports/mwp/KeyManager.ts
@@ -2071,74 +2130,229 @@ var keymanager = new KeyManager();
2071
2130
 
2072
2131
  // src/multichain/index.ts
2073
2132
  init_utils();
2133
+
2134
+ // src/multichain/transports/multichainApiClientWrapper/index.ts
2135
+ import { providerErrors } from "@metamask/rpc-errors";
2136
+ var MAX = 4294967295;
2137
+ var idCounter = Math.floor(Math.random() * MAX);
2138
+ var getUniqueId = () => {
2139
+ idCounter = (idCounter + 1) % MAX;
2140
+ return idCounter;
2141
+ };
2142
+ var _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn, walletGetSession_fn, walletRevokeSession_fn, walletInvokeMethod_fn;
2143
+ var MultichainApiClientWrapperTransport = class {
2144
+ constructor(multichainSDK) {
2145
+ this.multichainSDK = multichainSDK;
2146
+ __privateAdd(this, _MultichainApiClientWrapperTransport_instances);
2147
+ this.requestId = getUniqueId();
2148
+ this.notificationCallbacks = /* @__PURE__ */ new Set();
2149
+ }
2150
+ isTransportDefined() {
2151
+ try {
2152
+ return Boolean(this.multichainSDK.transport);
2153
+ } catch (error) {
2154
+ return false;
2155
+ }
2156
+ }
2157
+ clearNotificationCallbacks() {
2158
+ this.notificationCallbacks.clear();
2159
+ }
2160
+ notifyCallbacks(data) {
2161
+ this.notificationCallbacks.forEach((callback) => {
2162
+ callback(data);
2163
+ });
2164
+ }
2165
+ setupNotifcationListener() {
2166
+ this.multichainSDK.transport.onNotification(
2167
+ this.notifyCallbacks.bind(this)
2168
+ );
2169
+ }
2170
+ connect() {
2171
+ return __async(this, null, function* () {
2172
+ console.log("\u{1F4DA} connect");
2173
+ return Promise.resolve();
2174
+ });
2175
+ }
2176
+ disconnect() {
2177
+ return __async(this, null, function* () {
2178
+ return Promise.resolve();
2179
+ });
2180
+ }
2181
+ isConnected() {
2182
+ return true;
2183
+ }
2184
+ request(_0) {
2185
+ return __async(this, arguments, function* (params, _options = {}) {
2186
+ const id = this.requestId++;
2187
+ const requestPayload = __spreadValues({
2188
+ id,
2189
+ jsonrpc: "2.0"
2190
+ }, params);
2191
+ switch (requestPayload.method) {
2192
+ case "wallet_createSession":
2193
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn).call(this, requestPayload);
2194
+ case "wallet_getSession":
2195
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletGetSession_fn).call(this, requestPayload);
2196
+ case "wallet_revokeSession":
2197
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletRevokeSession_fn).call(this, requestPayload);
2198
+ case "wallet_invokeMethod":
2199
+ return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletInvokeMethod_fn).call(this, requestPayload);
2200
+ default:
2201
+ throw new Error(`Unsupported method: ${requestPayload.method}`);
2202
+ }
2203
+ throw new Error(`Unknown method: ${requestPayload.method}`);
2204
+ });
2205
+ }
2206
+ onNotification(callback) {
2207
+ if (!this.isTransportDefined()) {
2208
+ this.notificationCallbacks.add(callback);
2209
+ return () => {
2210
+ this.notificationCallbacks.delete(callback);
2211
+ };
2212
+ }
2213
+ return this.multichainSDK.transport.onNotification(callback);
2214
+ }
2215
+ };
2216
+ _MultichainApiClientWrapperTransport_instances = new WeakSet();
2217
+ walletCreateSession_fn = function(request) {
2218
+ return __async(this, null, function* () {
2219
+ console.log("\u{1F4DA} #walletCreateSession", request);
2220
+ const createSessionParams = request.params;
2221
+ const scopes = Object.keys(__spreadValues(__spreadValues({}, createSessionParams.optionalScopes), createSessionParams.requiredScopes));
2222
+ const scopeAccounts = [];
2223
+ scopes.forEach((scope) => {
2224
+ var _a2, _b, _c, _d;
2225
+ const requiredScope = (_a2 = createSessionParams.requiredScopes) == null ? void 0 : _a2[scope];
2226
+ const optionalScope = (_b = createSessionParams.optionalScopes) == null ? void 0 : _b[scope];
2227
+ if (requiredScope) {
2228
+ scopeAccounts.push(...(_c = requiredScope.accounts) != null ? _c : []);
2229
+ }
2230
+ if (optionalScope) {
2231
+ scopeAccounts.push(...(_d = optionalScope.accounts) != null ? _d : []);
2232
+ }
2233
+ });
2234
+ const accounts = [...new Set(scopeAccounts)];
2235
+ console.log("\u{1F4DA} SDK connect");
2236
+ yield this.multichainSDK.connect(
2237
+ scopes,
2238
+ accounts,
2239
+ createSessionParams.sessionProperties
2240
+ );
2241
+ console.log("\u{1F4DA} SDK connected");
2242
+ return this.multichainSDK.transport.request({
2243
+ method: "wallet_getSession"
2244
+ });
2245
+ });
2246
+ };
2247
+ walletGetSession_fn = function(request) {
2248
+ return __async(this, null, function* () {
2249
+ if (!this.isTransportDefined()) {
2250
+ return {
2251
+ jsonrpc: "2.0",
2252
+ id: request.id,
2253
+ result: {
2254
+ sessionScopes: {}
2255
+ }
2256
+ };
2257
+ }
2258
+ return this.multichainSDK.transport.request({
2259
+ method: "wallet_getSession"
2260
+ });
2261
+ });
2262
+ };
2263
+ walletRevokeSession_fn = function(request) {
2264
+ return __async(this, null, function* () {
2265
+ if (!this.isTransportDefined()) {
2266
+ return { jsonrpc: "2.0", id: request.id, result: true };
2267
+ }
2268
+ try {
2269
+ this.multichainSDK.disconnect();
2270
+ return { jsonrpc: "2.0", id: request.id, result: true };
2271
+ } catch (error) {
2272
+ return { jsonrpc: "2.0", id: request.id, result: false };
2273
+ }
2274
+ });
2275
+ };
2276
+ walletInvokeMethod_fn = function(request) {
2277
+ return __async(this, null, function* () {
2278
+ if (!this.isTransportDefined()) {
2279
+ return { error: providerErrors.unauthorized() };
2280
+ }
2281
+ const result = this.multichainSDK.invokeMethod(
2282
+ request.params
2283
+ );
2284
+ return {
2285
+ result
2286
+ };
2287
+ });
2288
+ };
2289
+
2290
+ // src/multichain/index.ts
2074
2291
  var logger2 = createLogger("metamask-sdk:core");
2075
- var MultichainSDK = class _MultichainSDK extends MultichainCore {
2292
+ var _a, _provider, _providerTransportWrapper, _transport2, _dappClient, _beforeUnloadListener, _listener, _sdkInfo, _MultichainSDK_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;
2293
+ var _MultichainSDK = class _MultichainSDK extends MultichainCore {
2076
2294
  constructor(options) {
2077
- var _a, _b, _c, _d, _e, _f, _g;
2295
+ var _a2, _b, _c, _d, _e, _f;
2078
2296
  const withDappMetadata = setupDappMetadata(options);
2079
- const integrationType = ((_a = options.analytics) == null ? void 0 : _a.enabled) ? options.analytics.integrationType : "direct";
2297
+ const integrationType = (_b = (_a2 = options.analytics) == null ? void 0 : _a2.integrationType) != null ? _b : "direct";
2080
2298
  const allOptions = __spreadProps(__spreadValues({}, withDappMetadata), {
2081
2299
  ui: __spreadProps(__spreadValues({}, withDappMetadata.ui), {
2082
- preferExtension: (_b = withDappMetadata.ui.preferExtension) != null ? _b : true,
2083
- showInstallModal: (_c = withDappMetadata.ui.showInstallModal) != null ? _c : false,
2084
- headless: (_d = withDappMetadata.ui.headless) != null ? _d : false
2300
+ preferExtension: (_c = withDappMetadata.ui.preferExtension) != null ? _c : true,
2301
+ showInstallModal: (_d = withDappMetadata.ui.showInstallModal) != null ? _d : false,
2302
+ headless: (_e = withDappMetadata.ui.headless) != null ? _e : false
2085
2303
  }),
2086
- analytics: __spreadProps(__spreadValues({}, (_e = options.analytics) != null ? _e : {}), {
2087
- enabled: (_g = (_f = options.analytics) == null ? void 0 : _f.enabled) != null ? _g : true,
2304
+ analytics: __spreadProps(__spreadValues({}, (_f = options.analytics) != null ? _f : {}), {
2088
2305
  integrationType
2089
2306
  })
2090
2307
  });
2091
2308
  super(allOptions);
2092
- this.__provider = void 0;
2093
- this.__transport = void 0;
2094
- this.__dappClient = void 0;
2095
- this.__state = "pending";
2096
- }
2097
- get state() {
2098
- return this.__state;
2099
- }
2100
- set state(value) {
2101
- var _a, _b;
2102
- this.__state = value;
2103
- (_b = (_a = this.options.transport) == null ? void 0 : _a.onNotification) == null ? void 0 : _b.call(_a, {
2309
+ __privateAdd(this, _MultichainSDK_instances);
2310
+ __privateAdd(this, _provider);
2311
+ __privateAdd(this, _providerTransportWrapper);
2312
+ __privateAdd(this, _transport2);
2313
+ __privateAdd(this, _dappClient);
2314
+ __privateAdd(this, _beforeUnloadListener);
2315
+ this._status = "pending";
2316
+ __privateAdd(this, _listener);
2317
+ __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}`);
2318
+ __privateSet(this, _providerTransportWrapper, new MultichainApiClientWrapperTransport(this));
2319
+ __privateSet(this, _provider, getMultichainClient({ transport: __privateGet(this, _providerTransportWrapper) }));
2320
+ }
2321
+ get status() {
2322
+ return this._status;
2323
+ }
2324
+ set status(value) {
2325
+ var _a2, _b;
2326
+ this._status = value;
2327
+ (_b = (_a2 = this.options.transport) == null ? void 0 : _a2.onNotification) == null ? void 0 : _b.call(_a2, {
2104
2328
  method: "stateChanged",
2105
2329
  params: value
2106
2330
  });
2107
2331
  }
2108
2332
  get provider() {
2109
- if (!this.__provider && this.__transport) {
2110
- this.__provider = getMultichainClient({ transport: this.__transport });
2111
- return this.__provider;
2112
- }
2113
- if (!this.__provider) {
2114
- throw new Error("Provider not initialized, establish connection first");
2115
- }
2116
- return this.__provider;
2333
+ return __privateGet(this, _provider);
2117
2334
  }
2118
2335
  get transport() {
2119
- if (!this.__transport) {
2336
+ if (!__privateGet(this, _transport2)) {
2120
2337
  throw new Error("Transport not initialized, establish connection first");
2121
2338
  }
2122
- return this.__transport;
2339
+ return __privateGet(this, _transport2);
2123
2340
  }
2124
2341
  get dappClient() {
2125
- if (!this.__dappClient) {
2342
+ if (!__privateGet(this, _dappClient)) {
2126
2343
  throw new Error("DappClient not initialized, establish connection first");
2127
2344
  }
2128
- return this.__dappClient;
2345
+ return __privateGet(this, _dappClient);
2129
2346
  }
2130
2347
  get storage() {
2131
2348
  return this.options.storage;
2132
2349
  }
2133
2350
  get transportType() {
2134
- return this.__transport instanceof MWPTransport ? "mwp" /* MWP */ : "browser" /* Browser */;
2135
- }
2136
- get sdkInfo() {
2137
- var _a;
2138
- return `Sdk/Javascript SdkVersion/${getVersion()} Platform/${getPlatformType()} dApp/${(_a = this.options.dapp.url) != null ? _a : this.options.dapp.name} dAppTitle/${this.options.dapp.name}`;
2351
+ return __privateGet(this, _transport2) instanceof MWPTransport ? "mwp" /* MWP */ : "browser" /* Browser */;
2139
2352
  }
2140
2353
  static create(options) {
2141
2354
  return __async(this, null, function* () {
2355
+ var _a2;
2142
2356
  const instance = new _MultichainSDK(options);
2143
2357
  const isEnabled2 = yield isEnabled(
2144
2358
  "metamask-sdk:core",
@@ -2147,353 +2361,17 @@ var MultichainSDK = class _MultichainSDK extends MultichainCore {
2147
2361
  if (isEnabled2) {
2148
2362
  enableDebug("metamask-sdk:core");
2149
2363
  }
2150
- yield instance.init();
2364
+ yield __privateMethod(_a2 = instance, _MultichainSDK_instances, init_fn).call(_a2);
2151
2365
  return instance;
2152
2366
  });
2153
2367
  }
2154
- setupAnalytics() {
2155
- return __async(this, null, function* () {
2156
- var _a, _b;
2157
- if (!((_a = this.options.analytics) == null ? void 0 : _a.enabled)) {
2158
- return;
2159
- }
2160
- const platform = getPlatformType();
2161
- const isBrowser = platform === "in-app-browser" /* MetaMaskMobileWebview */ || platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */;
2162
- const isReactNative2 = platform === "react-native" /* ReactNative */;
2163
- if (!isBrowser && !isReactNative2) {
2164
- return;
2165
- }
2166
- const version = getVersion();
2167
- const dappId = getDappId(this.options.dapp);
2168
- const anonId = yield this.storage.getAnonId();
2169
- const { integrationType } = (_b = this.options.analytics) != null ? _b : {
2170
- integrationType: ""
2171
- };
2172
- analytics2.setGlobalProperty("mmconnect_version", version);
2173
- analytics2.setGlobalProperty("dapp_id", dappId);
2174
- analytics2.setGlobalProperty("anon_id", anonId);
2175
- analytics2.setGlobalProperty("platform", platform);
2176
- analytics2.setGlobalProperty("integration_type", integrationType);
2177
- analytics2.enable();
2178
- });
2179
- }
2180
- onTransportNotification(payload) {
2368
+ // TODO: make this into param object
2369
+ connect(scopes, caipAccountIds, sessionProperties, forceRequest) {
2181
2370
  return __async(this, null, function* () {
2182
- var _a;
2183
- if (typeof payload === "object" && payload !== null && "method" in payload) {
2184
- this.emit(payload.method, (_a = payload.params) != null ? _a : payload.result);
2371
+ var _a2;
2372
+ if (this.status !== "connected") {
2373
+ yield this.disconnect();
2185
2374
  }
2186
- });
2187
- }
2188
- getStoredTransport() {
2189
- return __async(this, null, function* () {
2190
- const transportType = yield this.storage.getTransport();
2191
- const hasExtensionInstalled = yield hasExtension();
2192
- if (transportType) {
2193
- if (transportType === "browser" /* Browser */) {
2194
- if (hasExtensionInstalled) {
2195
- const apiTransport = new DefaultTransport();
2196
- this.__transport = apiTransport;
2197
- this.listener = apiTransport.onNotification(
2198
- this.onTransportNotification.bind(this)
2199
- );
2200
- return apiTransport;
2201
- }
2202
- } else if (transportType === "mwp" /* MWP */) {
2203
- const { adapter: kvstore } = this.options.storage;
2204
- const dappClient = yield this.createDappClient();
2205
- const apiTransport = new MWPTransport(dappClient, kvstore);
2206
- this.__dappClient = dappClient;
2207
- this.__transport = apiTransport;
2208
- this.listener = apiTransport.onNotification(
2209
- this.onTransportNotification.bind(this)
2210
- );
2211
- return apiTransport;
2212
- }
2213
- yield this.storage.removeTransport();
2214
- }
2215
- return void 0;
2216
- });
2217
- }
2218
- setupTransport() {
2219
- return __async(this, null, function* () {
2220
- const transport = yield this.getStoredTransport();
2221
- if (transport) {
2222
- if (!this.transport.isConnected()) {
2223
- this.state = "connecting";
2224
- yield this.transport.connect();
2225
- }
2226
- this.state = "connected";
2227
- if (this.transport instanceof MWPTransport) {
2228
- yield this.storage.setTransport("mwp" /* MWP */);
2229
- } else {
2230
- yield this.storage.setTransport("browser" /* Browser */);
2231
- }
2232
- } else {
2233
- this.state = "loaded";
2234
- }
2235
- });
2236
- }
2237
- init() {
2238
- return __async(this, null, function* () {
2239
- var _a, _b;
2240
- try {
2241
- if (typeof window !== "undefined" && ((_a = window.mmsdk) == null ? void 0 : _a.isInitialized)) {
2242
- logger2("MetaMaskSDK: init already initialized");
2243
- } else {
2244
- yield this.setupAnalytics();
2245
- yield this.setupTransport();
2246
- if ((_b = this.options.analytics) == null ? void 0 : _b.enabled) {
2247
- try {
2248
- const baseProps = yield getBaseAnalyticsProperties(
2249
- this.options,
2250
- this.storage
2251
- );
2252
- analytics2.track("mmconnect_initialized", baseProps);
2253
- } catch (error) {
2254
- logger2("Error tracking initialized event", error);
2255
- }
2256
- }
2257
- if (typeof window !== "undefined") {
2258
- window.mmsdk = this;
2259
- }
2260
- }
2261
- } catch (error) {
2262
- yield this.storage.removeTransport();
2263
- this.state = "pending";
2264
- logger2("MetaMaskSDK error during initialization", error);
2265
- }
2266
- });
2267
- }
2268
- createDappClient() {
2269
- return __async(this, null, function* () {
2270
- const { adapter: kvstore } = this.options.storage;
2271
- const sessionstore = new SessionStore2(kvstore);
2272
- const websocket = (
2273
- // eslint-disable-next-line no-negated-condition
2274
- typeof window !== "undefined" ? WebSocket : (yield import("ws")).WebSocket
2275
- );
2276
- const transport = yield WebSocketTransport.create({
2277
- url: MWP_RELAY_URL,
2278
- kvstore,
2279
- websocket
2280
- });
2281
- const dappClient = new DappClient({ transport, sessionstore, keymanager });
2282
- return dappClient;
2283
- });
2284
- }
2285
- setupMWP() {
2286
- return __async(this, null, function* () {
2287
- if (this.__transport instanceof MWPTransport) {
2288
- return;
2289
- }
2290
- const { adapter: kvstore } = this.options.storage;
2291
- const dappClient = yield this.createDappClient();
2292
- this.__dappClient = dappClient;
2293
- const apiTransport = new MWPTransport(dappClient, kvstore);
2294
- this.__transport = apiTransport;
2295
- this.listener = this.transport.onNotification(
2296
- this.onTransportNotification.bind(this)
2297
- );
2298
- yield this.storage.setTransport("mwp" /* MWP */);
2299
- });
2300
- }
2301
- onBeforeUnload() {
2302
- return __async(this, null, function* () {
2303
- var _a;
2304
- if ((_a = this.options.ui.factory.modal) == null ? void 0 : _a.isMounted) {
2305
- yield this.storage.removeTransport();
2306
- }
2307
- });
2308
- }
2309
- createBeforeUnloadListener() {
2310
- if (typeof window !== "undefined" && typeof window.addEventListener !== "undefined") {
2311
- window.addEventListener("beforeunload", this.onBeforeUnload.bind(this));
2312
- }
2313
- return () => {
2314
- if (typeof window !== "undefined" && typeof window.removeEventListener !== "undefined") {
2315
- window.removeEventListener(
2316
- "beforeunload",
2317
- this.onBeforeUnload.bind(this)
2318
- );
2319
- }
2320
- };
2321
- }
2322
- showInstallModal(desktopPreferred, scopes, caipAccountIds) {
2323
- return __async(this, null, function* () {
2324
- var _a;
2325
- (_a = this.__beforeUnloadListener) != null ? _a : this.__beforeUnloadListener = this.createBeforeUnloadListener();
2326
- return new Promise((resolve, reject) => {
2327
- this.options.ui.factory.renderInstallModal(
2328
- desktopPreferred,
2329
- () => __async(this, null, function* () {
2330
- if (this.dappClient.state === "CONNECTED" || this.dappClient.state === "CONNECTING") {
2331
- yield this.dappClient.disconnect();
2332
- }
2333
- return new Promise((resolveConnectionRequest) => {
2334
- this.dappClient.on(
2335
- "session_request",
2336
- (sessionRequest) => {
2337
- resolveConnectionRequest({
2338
- sessionRequest,
2339
- metadata: {
2340
- dapp: this.options.dapp,
2341
- sdk: {
2342
- version: getVersion(),
2343
- platform: getPlatformType()
2344
- }
2345
- }
2346
- });
2347
- }
2348
- );
2349
- this.transport.connect({ scopes, caipAccountIds }).then(() => {
2350
- var _a2;
2351
- this.options.ui.factory.unload();
2352
- (_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.unmount();
2353
- this.state = "connected";
2354
- return this.storage.setTransport("mwp" /* MWP */);
2355
- }).catch((error) => {
2356
- if (error instanceof ProtocolError) {
2357
- if (error.code !== ErrorCode.REQUEST_EXPIRED) {
2358
- this.state = "disconnected";
2359
- reject(error);
2360
- }
2361
- } else {
2362
- this.state = "disconnected";
2363
- reject(error);
2364
- }
2365
- });
2366
- });
2367
- }),
2368
- (error) => __async(this, null, function* () {
2369
- if (!error) {
2370
- yield this.storage.setTransport("mwp" /* MWP */);
2371
- resolve();
2372
- } else {
2373
- yield this.storage.removeTransport();
2374
- reject(error);
2375
- }
2376
- })
2377
- );
2378
- });
2379
- });
2380
- }
2381
- setupDefaultTransport() {
2382
- return __async(this, null, function* () {
2383
- this.state = "connecting";
2384
- yield this.storage.setTransport("browser" /* Browser */);
2385
- const transport = new DefaultTransport();
2386
- this.listener = transport.onNotification(
2387
- this.onTransportNotification.bind(this)
2388
- );
2389
- this.__transport = transport;
2390
- return transport;
2391
- });
2392
- }
2393
- deeplinkConnect(scopes, caipAccountIds) {
2394
- return __async(this, null, function* () {
2395
- return new Promise((resolve, reject) => __async(this, null, function* () {
2396
- this.dappClient.on("message", (payload) => {
2397
- var _a, _b, _c;
2398
- const data = payload.data;
2399
- if (typeof data === "object" && data !== null) {
2400
- if ("method" in data && data.method === "wallet_createSession") {
2401
- if (data.error) {
2402
- this.state = "loaded";
2403
- return reject(data.error);
2404
- }
2405
- const session = (_a = data.params) != null ? _a : data.result;
2406
- if (session) {
2407
- (_c = (_b = this.options.transport) == null ? void 0 : _b.onNotification) == null ? void 0 : _c.call(_b, payload.data);
2408
- this.emit("wallet_sessionChanged", session);
2409
- }
2410
- }
2411
- }
2412
- });
2413
- let timeout;
2414
- if (!this.transport.isConnected()) {
2415
- this.dappClient.once(
2416
- "session_request",
2417
- (sessionRequest) => {
2418
- var _a;
2419
- const connectionRequest = {
2420
- sessionRequest,
2421
- metadata: {
2422
- dapp: this.options.dapp,
2423
- sdk: { version: getVersion(), platform: getPlatformType() }
2424
- }
2425
- };
2426
- const deeplink = this.options.ui.factory.createConnectionDeeplink(connectionRequest);
2427
- const universalLink = this.options.ui.factory.createConnectionUniversalLink(connectionRequest);
2428
- if ((_a = this.options.mobile) == null ? void 0 : _a.preferredOpenLink) {
2429
- this.options.mobile.preferredOpenLink(deeplink, "_self");
2430
- } else {
2431
- openDeeplink(this.options, deeplink, universalLink);
2432
- }
2433
- }
2434
- );
2435
- }
2436
- this.transport.connect({ scopes, caipAccountIds }).then(resolve).catch((error) => {
2437
- this.storage.removeTransport();
2438
- reject(error);
2439
- }).finally(() => {
2440
- if (timeout) {
2441
- clearTimeout(timeout);
2442
- }
2443
- });
2444
- }));
2445
- });
2446
- }
2447
- handleConnection(promise, scopes, transportType) {
2448
- return __async(this, null, function* () {
2449
- this.state = "connecting";
2450
- return promise.then(() => __async(this, null, function* () {
2451
- var _a;
2452
- this.state = "connected";
2453
- if ((_a = this.options.analytics) == null ? void 0 : _a.enabled) {
2454
- try {
2455
- const baseProps = yield getBaseAnalyticsProperties(
2456
- this.options,
2457
- this.storage
2458
- );
2459
- analytics2.track("mmconnect_connection_established", __spreadProps(__spreadValues({}, baseProps), {
2460
- transport_type: transportType,
2461
- user_permissioned_chains: scopes
2462
- }));
2463
- } catch (error) {
2464
- logger2("Error tracking connection_established event", error);
2465
- }
2466
- }
2467
- })).catch((error) => __async(this, null, function* () {
2468
- var _a;
2469
- this.state = "disconnected";
2470
- if ((_a = this.options.analytics) == null ? void 0 : _a.enabled) {
2471
- try {
2472
- const baseProps = yield getBaseAnalyticsProperties(
2473
- this.options,
2474
- this.storage
2475
- );
2476
- const isRejection = isRejectionError(error);
2477
- if (isRejection) {
2478
- analytics2.track("mmconnect_connection_rejected", __spreadProps(__spreadValues({}, baseProps), {
2479
- transport_type: transportType
2480
- }));
2481
- } else {
2482
- analytics2.track("mmconnect_connection_failed", __spreadProps(__spreadValues({}, baseProps), {
2483
- transport_type: transportType
2484
- }));
2485
- }
2486
- } catch (e) {
2487
- logger2("Error tracking connection failed/rejected event", error);
2488
- }
2489
- }
2490
- return Promise.reject(error);
2491
- }));
2492
- });
2493
- }
2494
- connect(scopes, caipAccountIds, forceRequest) {
2495
- return __async(this, null, function* () {
2496
- var _a, _b;
2497
2375
  const { ui } = this.options;
2498
2376
  const platformType = getPlatformType();
2499
2377
  const isWeb = platformType === "in-app-browser" /* MetaMaskMobileWebview */ || platformType === "web-desktop" /* DesktopWeb */;
@@ -2506,96 +2384,70 @@ var MultichainSDK = class _MultichainSDK extends MultichainCore {
2506
2384
  } else {
2507
2385
  transportType = "mwp" /* MWP */;
2508
2386
  }
2509
- if ((_a = this.options.analytics) == null ? void 0 : _a.enabled) {
2510
- try {
2511
- const baseProps = yield getBaseAnalyticsProperties(
2512
- this.options,
2513
- this.storage
2514
- );
2515
- const dappConfiguredChains = Object.keys(
2516
- this.options.api.supportedNetworks
2517
- );
2518
- analytics2.track("mmconnect_connection_initiated", __spreadProps(__spreadValues({}, baseProps), {
2519
- transport_type: transportType,
2520
- dapp_configured_chains: dappConfiguredChains,
2521
- dapp_requested_chains: scopes
2522
- }));
2523
- } catch (error) {
2524
- logger2("Error tracking connection_initiated event", error);
2525
- }
2526
- }
2527
- if (((_b = this.__transport) == null ? void 0 : _b.isConnected()) && !secure) {
2528
- return this.handleConnection(
2529
- this.__transport.connect({ scopes, caipAccountIds, forceRequest }).then(() => {
2530
- if (this.__transport instanceof MWPTransport) {
2531
- return this.storage.setTransport("mwp" /* MWP */);
2532
- } else {
2533
- return this.storage.setTransport("browser" /* Browser */);
2534
- }
2535
- }),
2536
- scopes,
2537
- transportType
2387
+ try {
2388
+ const baseProps = yield getBaseAnalyticsProperties(
2389
+ this.options,
2390
+ this.storage
2391
+ );
2392
+ const dappConfiguredChains = Object.keys(
2393
+ this.options.api.supportedNetworks
2538
2394
  );
2395
+ analytics2.track("mmconnect_connection_initiated", __spreadProps(__spreadValues({}, baseProps), {
2396
+ transport_type: transportType,
2397
+ dapp_configured_chains: dappConfiguredChains,
2398
+ dapp_requested_chains: scopes
2399
+ }));
2400
+ } catch (error) {
2401
+ logger2("Error tracking connection_initiated event", error);
2402
+ }
2403
+ if (((_a2 = __privateGet(this, _transport2)) == null ? void 0 : _a2.isConnected()) && !secure) {
2404
+ return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, __privateGet(this, _transport2).connect({ scopes, caipAccountIds, sessionProperties, forceRequest }).then(() => __async(this, null, function* () {
2405
+ if (__privateGet(this, _transport2) instanceof MWPTransport) {
2406
+ return this.storage.setTransport("mwp" /* MWP */);
2407
+ }
2408
+ return this.storage.setTransport("browser" /* Browser */);
2409
+ })), scopes, transportType);
2539
2410
  }
2540
2411
  if (platformType === "in-app-browser" /* MetaMaskMobileWebview */) {
2541
- const defaultTransport = yield this.setupDefaultTransport();
2542
- return this.handleConnection(
2543
- defaultTransport.connect({ scopes, caipAccountIds, forceRequest }),
2544
- scopes,
2545
- transportType
2546
- );
2412
+ const defaultTransport = yield __privateMethod(this, _MultichainSDK_instances, setupDefaultTransport_fn).call(this);
2413
+ return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
2547
2414
  }
2548
2415
  if (isWeb && hasExtensionInstalled && preferExtension) {
2549
- const defaultTransport = yield this.setupDefaultTransport();
2550
- return this.handleConnection(
2551
- defaultTransport.connect({ scopes, caipAccountIds, forceRequest }),
2552
- scopes,
2553
- transportType
2554
- );
2416
+ const defaultTransport = yield __privateMethod(this, _MultichainSDK_instances, setupDefaultTransport_fn).call(this);
2417
+ return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
2555
2418
  }
2556
- yield this.setupMWP();
2419
+ yield __privateMethod(this, _MultichainSDK_instances, setupMWP_fn).call(this);
2557
2420
  const shouldShowInstallModal = hasExtensionInstalled ? showInstallModal : !preferExtension || showInstallModal;
2558
2421
  if (secure && !shouldShowInstallModal) {
2559
- return this.handleConnection(
2560
- this.deeplinkConnect(scopes, caipAccountIds),
2561
- scopes,
2562
- transportType
2563
- );
2422
+ return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, __privateMethod(this, _MultichainSDK_instances, deeplinkConnect_fn).call(this, scopes, caipAccountIds, sessionProperties), scopes, transportType);
2564
2423
  }
2565
- return this.handleConnection(
2566
- this.showInstallModal(shouldShowInstallModal, scopes, caipAccountIds),
2567
- scopes,
2568
- transportType
2569
- );
2424
+ return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, __privateMethod(this, _MultichainSDK_instances, showInstallModal_fn).call(this, shouldShowInstallModal, scopes, caipAccountIds, sessionProperties), scopes, transportType);
2570
2425
  });
2571
2426
  }
2572
2427
  emit(event, args) {
2573
- var _a, _b;
2574
- (_b = (_a = this.options.transport) == null ? void 0 : _a.onNotification) == null ? void 0 : _b.call(_a, { method: event, params: args });
2428
+ var _a2, _b;
2429
+ (_b = (_a2 = this.options.transport) == null ? void 0 : _a2.onNotification) == null ? void 0 : _b.call(_a2, { method: event, params: args });
2575
2430
  super.emit(event, args);
2576
2431
  }
2577
2432
  disconnect() {
2578
2433
  return __async(this, null, function* () {
2579
- var _a, _b, _c;
2580
- (_a = this.listener) == null ? void 0 : _a.call(this);
2581
- (_b = this.__beforeUnloadListener) == null ? void 0 : _b.call(this);
2582
- yield (_c = this.__transport) == null ? void 0 : _c.disconnect();
2434
+ var _a2, _b, _c;
2435
+ yield (_a2 = __privateGet(this, _listener)) == null ? void 0 : _a2.call(this);
2436
+ (_b = __privateGet(this, _beforeUnloadListener)) == null ? void 0 : _b.call(this);
2437
+ yield (_c = __privateGet(this, _transport2)) == null ? void 0 : _c.disconnect();
2583
2438
  yield this.storage.removeTransport();
2584
- this.emit("wallet_sessionChanged", void 0);
2585
2439
  this.emit("stateChanged", "disconnected");
2586
- this.listener = void 0;
2587
- this.__beforeUnloadListener = void 0;
2588
- this.__transport = void 0;
2589
- this.__provider = void 0;
2590
- this.__dappClient = void 0;
2440
+ __privateSet(this, _listener, void 0);
2441
+ __privateSet(this, _beforeUnloadListener, void 0);
2442
+ __privateSet(this, _transport2, void 0);
2443
+ __privateGet(this, _providerTransportWrapper).clearNotificationCallbacks();
2444
+ __privateSet(this, _dappClient, void 0);
2591
2445
  });
2592
2446
  }
2593
2447
  invokeMethod(request) {
2594
2448
  return __async(this, null, function* () {
2595
- var _a;
2596
- const { sdkInfo, transport, options } = this;
2597
- (_a = this.__provider) != null ? _a : this.__provider = getMultichainClient({ transport });
2598
- const rpcClient = new RpcClient(options, sdkInfo);
2449
+ const { transport, options } = this;
2450
+ const rpcClient = new RpcClient(options, __privateGet(this, _sdkInfo));
2599
2451
  const requestRouter = new RequestRouter(transport, rpcClient, options);
2600
2452
  return requestRouter.invokeMethod(request);
2601
2453
  });
@@ -2616,16 +2468,427 @@ var MultichainSDK = class _MultichainSDK extends MultichainCore {
2616
2468
  if (mobile == null ? void 0 : mobile.preferredOpenLink) {
2617
2469
  mobile.preferredOpenLink(url, "_self");
2618
2470
  } else {
2619
- openDeeplink(
2620
- this.options,
2621
- url,
2622
- METAMASK_CONNECT_BASE_URL
2623
- );
2471
+ openDeeplink(this.options, url, METAMASK_CONNECT_BASE_URL);
2624
2472
  }
2625
2473
  }), 10);
2626
2474
  }
2627
2475
  }
2628
2476
  };
2477
+ _provider = new WeakMap();
2478
+ _providerTransportWrapper = new WeakMap();
2479
+ _transport2 = new WeakMap();
2480
+ _dappClient = new WeakMap();
2481
+ _beforeUnloadListener = new WeakMap();
2482
+ _listener = new WeakMap();
2483
+ _sdkInfo = new WeakMap();
2484
+ _MultichainSDK_instances = new WeakSet();
2485
+ setupAnalytics_fn = function() {
2486
+ return __async(this, null, function* () {
2487
+ var _a2;
2488
+ const platform = getPlatformType();
2489
+ const isBrowser = platform === "in-app-browser" /* MetaMaskMobileWebview */ || platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */;
2490
+ const isReactNative2 = platform === "react-native" /* ReactNative */;
2491
+ if (!isBrowser && !isReactNative2) {
2492
+ return;
2493
+ }
2494
+ const version = getVersion();
2495
+ const dappId = getDappId(this.options.dapp);
2496
+ const anonId = yield this.storage.getAnonId();
2497
+ const { integrationType } = (_a2 = this.options.analytics) != null ? _a2 : {
2498
+ integrationType: ""
2499
+ };
2500
+ analytics2.setGlobalProperty("mmconnect_version", version);
2501
+ analytics2.setGlobalProperty("dapp_id", dappId);
2502
+ analytics2.setGlobalProperty("anon_id", anonId);
2503
+ analytics2.setGlobalProperty("platform", platform);
2504
+ analytics2.setGlobalProperty("integration_type", integrationType);
2505
+ analytics2.enable();
2506
+ });
2507
+ };
2508
+ onTransportNotification_fn = function(payload) {
2509
+ return __async(this, null, function* () {
2510
+ var _a2;
2511
+ if (typeof payload === "object" && payload !== null && "method" in payload) {
2512
+ this.emit(payload.method, (_a2 = payload.params) != null ? _a2 : payload.result);
2513
+ }
2514
+ });
2515
+ };
2516
+ getStoredTransport_fn = function() {
2517
+ return __async(this, null, function* () {
2518
+ const transportType = yield this.storage.getTransport();
2519
+ const hasExtensionInstalled = yield hasExtension();
2520
+ if (transportType) {
2521
+ if (transportType === "browser" /* Browser */) {
2522
+ if (hasExtensionInstalled) {
2523
+ const apiTransport = new DefaultTransport();
2524
+ __privateSet(this, _transport2, apiTransport);
2525
+ __privateGet(this, _providerTransportWrapper).setupNotifcationListener();
2526
+ __privateSet(this, _listener, apiTransport.onNotification(
2527
+ __privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
2528
+ ));
2529
+ return apiTransport;
2530
+ }
2531
+ } else if (transportType === "mwp" /* MWP */) {
2532
+ const { adapter: kvstore } = this.options.storage;
2533
+ const dappClient = yield __privateMethod(this, _MultichainSDK_instances, createDappClient_fn).call(this);
2534
+ const apiTransport = new MWPTransport(dappClient, kvstore);
2535
+ __privateSet(this, _dappClient, dappClient);
2536
+ __privateSet(this, _transport2, apiTransport);
2537
+ __privateGet(this, _providerTransportWrapper).setupNotifcationListener();
2538
+ __privateSet(this, _listener, apiTransport.onNotification(
2539
+ __privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
2540
+ ));
2541
+ return apiTransport;
2542
+ }
2543
+ yield this.storage.removeTransport();
2544
+ }
2545
+ return void 0;
2546
+ });
2547
+ };
2548
+ setupTransport_fn = function() {
2549
+ return __async(this, null, function* () {
2550
+ const transport = yield __privateMethod(this, _MultichainSDK_instances, getStoredTransport_fn).call(this);
2551
+ if (transport) {
2552
+ if (!this.transport.isConnected()) {
2553
+ this.status = "connecting";
2554
+ yield this.transport.connect();
2555
+ }
2556
+ this.status = "connected";
2557
+ if (this.transport instanceof MWPTransport) {
2558
+ yield this.storage.setTransport("mwp" /* MWP */);
2559
+ } else {
2560
+ yield this.storage.setTransport("browser" /* Browser */);
2561
+ }
2562
+ } else {
2563
+ this.status = "loaded";
2564
+ }
2565
+ });
2566
+ };
2567
+ init_fn = function() {
2568
+ return __async(this, null, function* () {
2569
+ var _a2;
2570
+ try {
2571
+ if (typeof window !== "undefined" && ((_a2 = window.mmsdk) == null ? void 0 : _a2.isInitialized)) {
2572
+ logger2("MetaMaskSDK: init already initialized");
2573
+ } else {
2574
+ yield __privateMethod(this, _MultichainSDK_instances, setupAnalytics_fn).call(this);
2575
+ yield __privateMethod(this, _MultichainSDK_instances, setupTransport_fn).call(this);
2576
+ try {
2577
+ const baseProps = yield getBaseAnalyticsProperties(
2578
+ this.options,
2579
+ this.storage
2580
+ );
2581
+ analytics2.track("mmconnect_initialized", baseProps);
2582
+ } catch (error) {
2583
+ logger2("Error tracking initialized event", error);
2584
+ }
2585
+ if (typeof window !== "undefined") {
2586
+ window.mmsdk = this;
2587
+ }
2588
+ }
2589
+ } catch (error) {
2590
+ yield this.storage.removeTransport();
2591
+ this.status = "pending";
2592
+ logger2("MetaMaskSDK error during initialization", error);
2593
+ }
2594
+ });
2595
+ };
2596
+ createDappClient_fn = function() {
2597
+ return __async(this, null, function* () {
2598
+ const { adapter: kvstore } = this.options.storage;
2599
+ const sessionstore = new SessionStore2(kvstore);
2600
+ const websocket = (
2601
+ // eslint-disable-next-line no-negated-condition
2602
+ typeof window !== "undefined" ? WebSocket : (yield import("ws")).WebSocket
2603
+ );
2604
+ const transport = yield WebSocketTransport.create({
2605
+ url: MWP_RELAY_URL,
2606
+ kvstore,
2607
+ websocket
2608
+ });
2609
+ const dappClient = new DappClient({ transport, sessionstore, keymanager });
2610
+ return dappClient;
2611
+ });
2612
+ };
2613
+ setupMWP_fn = function() {
2614
+ return __async(this, null, function* () {
2615
+ if (__privateGet(this, _transport2) instanceof MWPTransport) {
2616
+ return;
2617
+ }
2618
+ const { adapter: kvstore } = this.options.storage;
2619
+ const dappClient = yield __privateMethod(this, _MultichainSDK_instances, createDappClient_fn).call(this);
2620
+ __privateSet(this, _dappClient, dappClient);
2621
+ const apiTransport = new MWPTransport(dappClient, kvstore);
2622
+ __privateSet(this, _transport2, apiTransport);
2623
+ __privateGet(this, _providerTransportWrapper).setupNotifcationListener();
2624
+ __privateSet(this, _listener, this.transport.onNotification(
2625
+ __privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
2626
+ ));
2627
+ yield this.storage.setTransport("mwp" /* MWP */);
2628
+ });
2629
+ };
2630
+ onBeforeUnload_fn = function() {
2631
+ return __async(this, null, function* () {
2632
+ var _a2;
2633
+ if ((_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.isMounted) {
2634
+ yield this.storage.removeTransport();
2635
+ }
2636
+ });
2637
+ };
2638
+ createBeforeUnloadListener_fn = function() {
2639
+ if (typeof window !== "undefined" && typeof window.addEventListener !== "undefined") {
2640
+ window.addEventListener("beforeunload", __privateMethod(this, _MultichainSDK_instances, onBeforeUnload_fn).bind(this));
2641
+ }
2642
+ return () => {
2643
+ if (typeof window !== "undefined" && typeof window.removeEventListener !== "undefined") {
2644
+ window.removeEventListener(
2645
+ "beforeunload",
2646
+ __privateMethod(this, _MultichainSDK_instances, onBeforeUnload_fn).bind(this)
2647
+ );
2648
+ }
2649
+ };
2650
+ };
2651
+ renderInstallModalAsync_fn = function(desktopPreferred, scopes, caipAccountIds, sessionProperties) {
2652
+ return __async(this, null, function* () {
2653
+ return new Promise((resolve, reject) => {
2654
+ this.options.ui.factory.renderInstallModal(
2655
+ desktopPreferred,
2656
+ () => __async(this, null, function* () {
2657
+ if (this.dappClient.state === "CONNECTED" || this.dappClient.state === "CONNECTING") {
2658
+ yield this.dappClient.disconnect();
2659
+ }
2660
+ return new Promise((_resolve) => {
2661
+ this.dappClient.on(
2662
+ "session_request",
2663
+ (sessionRequest) => {
2664
+ _resolve({
2665
+ sessionRequest,
2666
+ metadata: {
2667
+ dapp: this.options.dapp,
2668
+ sdk: {
2669
+ version: getVersion(),
2670
+ platform: getPlatformType()
2671
+ }
2672
+ }
2673
+ });
2674
+ }
2675
+ );
2676
+ (() => __async(this, null, function* () {
2677
+ var _a2;
2678
+ try {
2679
+ yield this.transport.connect({ scopes, caipAccountIds, sessionProperties });
2680
+ yield this.options.ui.factory.unload();
2681
+ (_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.unmount();
2682
+ this.status = "connected";
2683
+ yield this.storage.setTransport("mwp" /* MWP */);
2684
+ } catch (error) {
2685
+ if (error instanceof ProtocolError) {
2686
+ if (error.code !== ErrorCode.REQUEST_EXPIRED) {
2687
+ this.status = "disconnected";
2688
+ reject(error);
2689
+ }
2690
+ } else {
2691
+ this.status = "disconnected";
2692
+ reject(
2693
+ error instanceof Error ? error : new Error(String(error))
2694
+ );
2695
+ }
2696
+ }
2697
+ }))().catch(() => {
2698
+ });
2699
+ });
2700
+ }),
2701
+ (error) => __async(this, null, function* () {
2702
+ if (error) {
2703
+ yield this.storage.removeTransport();
2704
+ reject(error);
2705
+ } else {
2706
+ yield this.storage.setTransport("mwp" /* MWP */);
2707
+ resolve();
2708
+ }
2709
+ }),
2710
+ (uri) => {
2711
+ this.emit("display_uri", uri);
2712
+ }
2713
+ ).catch((error) => {
2714
+ reject(error instanceof Error ? error : new Error(String(error)));
2715
+ });
2716
+ });
2717
+ });
2718
+ };
2719
+ showInstallModal_fn = function(desktopPreferred, scopes, caipAccountIds, sessionProperties) {
2720
+ return __async(this, null, function* () {
2721
+ var _a2;
2722
+ (_a2 = __privateGet(this, _beforeUnloadListener)) != null ? _a2 : __privateSet(this, _beforeUnloadListener, __privateMethod(this, _MultichainSDK_instances, createBeforeUnloadListener_fn).call(this));
2723
+ if (this.options.ui.headless) {
2724
+ yield __privateMethod(this, _MultichainSDK_instances, headlessConnect_fn).call(this, scopes, caipAccountIds, sessionProperties);
2725
+ } else {
2726
+ yield __privateMethod(this, _MultichainSDK_instances, renderInstallModalAsync_fn).call(this, desktopPreferred, scopes, caipAccountIds, sessionProperties);
2727
+ }
2728
+ });
2729
+ };
2730
+ headlessConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
2731
+ return __async(this, null, function* () {
2732
+ return new Promise((resolve, reject) => {
2733
+ if (this.dappClient.state === "CONNECTED" || this.dappClient.state === "CONNECTING") {
2734
+ this.dappClient.disconnect().catch(() => {
2735
+ });
2736
+ }
2737
+ this.dappClient.on(
2738
+ "session_request",
2739
+ (sessionRequest) => {
2740
+ const connectionRequest = {
2741
+ sessionRequest,
2742
+ metadata: {
2743
+ dapp: this.options.dapp,
2744
+ sdk: {
2745
+ version: getVersion(),
2746
+ platform: getPlatformType()
2747
+ }
2748
+ }
2749
+ };
2750
+ const deeplink = this.options.ui.factory.createConnectionDeeplink(connectionRequest);
2751
+ this.emit("display_uri", deeplink);
2752
+ }
2753
+ );
2754
+ this.transport.connect({ scopes, caipAccountIds, sessionProperties }).then(() => __async(this, null, function* () {
2755
+ this.status = "connected";
2756
+ yield this.storage.setTransport("mwp" /* MWP */);
2757
+ resolve();
2758
+ })).catch((error) => __async(this, null, function* () {
2759
+ if (error instanceof ProtocolError) {
2760
+ this.status = "disconnected";
2761
+ yield this.storage.removeTransport();
2762
+ reject(error);
2763
+ } else {
2764
+ this.status = "disconnected";
2765
+ yield this.storage.removeTransport();
2766
+ reject(error instanceof Error ? error : new Error(String(error)));
2767
+ }
2768
+ }));
2769
+ });
2770
+ });
2771
+ };
2772
+ setupDefaultTransport_fn = function() {
2773
+ return __async(this, null, function* () {
2774
+ this.status = "connecting";
2775
+ yield this.storage.setTransport("browser" /* Browser */);
2776
+ const transport = new DefaultTransport();
2777
+ __privateSet(this, _listener, transport.onNotification(
2778
+ __privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
2779
+ ));
2780
+ __privateSet(this, _transport2, transport);
2781
+ __privateGet(this, _providerTransportWrapper).setupNotifcationListener();
2782
+ return transport;
2783
+ });
2784
+ };
2785
+ deeplinkConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
2786
+ return __async(this, null, function* () {
2787
+ return new Promise((resolve, reject) => {
2788
+ const dappClientMessageHandler = (payload) => {
2789
+ var _a2;
2790
+ if (typeof payload !== "object" || payload === null || !("data" in payload)) {
2791
+ return;
2792
+ }
2793
+ const data = payload.data;
2794
+ if (typeof data === "object" && data !== null) {
2795
+ if (data.error) {
2796
+ this.dappClient.off("message", dappClientMessageHandler);
2797
+ reject(data.error);
2798
+ }
2799
+ if ((_a2 = data == null ? void 0 : data.result) == null ? void 0 : _a2.sessionScopes) {
2800
+ this.dappClient.off("message", dappClientMessageHandler);
2801
+ }
2802
+ }
2803
+ };
2804
+ this.dappClient.on("message", dappClientMessageHandler);
2805
+ let timeout;
2806
+ if (this.transport.isConnected()) {
2807
+ timeout = setTimeout(() => {
2808
+ this.openDeeplinkIfNeeded();
2809
+ }, 250);
2810
+ } else {
2811
+ this.dappClient.once(
2812
+ "session_request",
2813
+ (sessionRequest) => {
2814
+ var _a2;
2815
+ const connectionRequest = {
2816
+ sessionRequest,
2817
+ metadata: {
2818
+ dapp: this.options.dapp,
2819
+ sdk: { version: getVersion(), platform: getPlatformType() }
2820
+ }
2821
+ };
2822
+ const deeplink = this.options.ui.factory.createConnectionDeeplink(
2823
+ connectionRequest
2824
+ );
2825
+ const universalLink = this.options.ui.factory.createConnectionUniversalLink(
2826
+ connectionRequest
2827
+ );
2828
+ this.emit("display_uri", deeplink);
2829
+ if ((_a2 = this.options.mobile) == null ? void 0 : _a2.preferredOpenLink) {
2830
+ this.options.mobile.preferredOpenLink(deeplink, "_self");
2831
+ } else {
2832
+ openDeeplink(this.options, deeplink, universalLink);
2833
+ }
2834
+ }
2835
+ );
2836
+ }
2837
+ return this.transport.connect({ scopes, caipAccountIds, sessionProperties }).then(resolve).catch((error) => __async(this, null, function* () {
2838
+ yield this.storage.removeTransport();
2839
+ this.dappClient.off("message", dappClientMessageHandler);
2840
+ reject(error instanceof Error ? error : new Error(String(error)));
2841
+ })).finally(() => {
2842
+ if (timeout) {
2843
+ clearTimeout(timeout);
2844
+ }
2845
+ });
2846
+ });
2847
+ });
2848
+ };
2849
+ handleConnection_fn = function(promise, scopes, transportType) {
2850
+ return __async(this, null, function* () {
2851
+ this.status = "connecting";
2852
+ return promise.then(() => __async(this, null, function* () {
2853
+ this.status = "connected";
2854
+ try {
2855
+ const baseProps = yield getBaseAnalyticsProperties(
2856
+ this.options,
2857
+ this.storage
2858
+ );
2859
+ analytics2.track("mmconnect_connection_established", __spreadProps(__spreadValues({}, baseProps), {
2860
+ transport_type: transportType,
2861
+ user_permissioned_chains: scopes
2862
+ }));
2863
+ } catch (error) {
2864
+ logger2("Error tracking connection_established event", error);
2865
+ }
2866
+ return void 0;
2867
+ })).catch((error) => __async(this, null, function* () {
2868
+ this.status = "disconnected";
2869
+ try {
2870
+ const baseProps = yield getBaseAnalyticsProperties(
2871
+ this.options,
2872
+ this.storage
2873
+ );
2874
+ const isRejection = isRejectionError(error);
2875
+ if (isRejection) {
2876
+ analytics2.track("mmconnect_connection_rejected", __spreadProps(__spreadValues({}, baseProps), {
2877
+ transport_type: transportType
2878
+ }));
2879
+ } else {
2880
+ analytics2.track("mmconnect_connection_failed", __spreadProps(__spreadValues({}, baseProps), {
2881
+ transport_type: transportType
2882
+ }));
2883
+ }
2884
+ } catch (e) {
2885
+ logger2("Error tracking connection failed/rejected event", error);
2886
+ }
2887
+ throw error;
2888
+ }));
2889
+ });
2890
+ };
2891
+ var MultichainSDK = _MultichainSDK;
2629
2892
 
2630
2893
  // src/store/index.ts
2631
2894
  import * as uuid from "uuid";
@@ -2806,54 +3069,11 @@ var Store = class extends StoreClient {
2806
3069
  }
2807
3070
  };
2808
3071
 
2809
- // src/ui/index.ts
3072
+ // src/ui/ModalFactory.ts
2810
3073
  import MetaMaskOnboarding from "@metamask/onboarding";
2811
3074
  init_domain();
2812
-
2813
- // src/ui/qr.ts
2814
- var encodeQRImpl = null;
2815
- function preloadQR() {
2816
- return __async(this, null, function* () {
2817
- if (encodeQRImpl) {
2818
- return;
2819
- }
2820
- const mod = yield import("@paulmillr/qr");
2821
- encodeQRImpl = mod.default;
2822
- });
2823
- }
2824
-
2825
- // src/ui/index.ts
2826
3075
  init_utils();
2827
- var __instance;
2828
- function preload() {
2829
- return __async(this, null, function* () {
2830
- if (false) {
2831
- __instance != null ? __instance : __instance = yield null.then((loader) => __async(null, null, function* () {
2832
- if (typeof (loader == null ? void 0 : loader.defineCustomElements) === "function") {
2833
- loader.defineCustomElements();
2834
- }
2835
- return Promise.resolve(loader);
2836
- })).catch((error) => __async(null, null, function* () {
2837
- console.error(`Gracefully Failed to load modal customElements:`, error);
2838
- return Promise.resolve(void 0);
2839
- }));
2840
- } else {
2841
- const dynamicImport = (0, eval)("import");
2842
- __instance != null ? __instance : __instance = yield dynamicImport(
2843
- "@metamask/multichain-ui/dist/loader/index.js"
2844
- ).then((loader) => __async(null, null, function* () {
2845
- if (typeof (loader == null ? void 0 : loader.defineCustomElements) === "function") {
2846
- loader.defineCustomElements();
2847
- }
2848
- return Promise.resolve(loader);
2849
- })).catch((error) => __async(null, null, function* () {
2850
- console.error(`Gracefully Failed to load modal customElements:`, error);
2851
- return Promise.resolve(void 0);
2852
- }));
2853
- }
2854
- });
2855
- }
2856
- var ModalFactory = class {
3076
+ var BaseModalFactory = class {
2857
3077
  /**
2858
3078
  * Creates a new modal factory instance.
2859
3079
  *
@@ -2875,8 +3095,8 @@ var ModalFactory = class {
2875
3095
  }
2876
3096
  unload(error) {
2877
3097
  return __async(this, null, function* () {
2878
- var _a, _b;
2879
- (_a = this.modal) == null ? void 0 : _a.unmount();
3098
+ var _a2, _b;
3099
+ (_a2 = this.modal) == null ? void 0 : _a2.unmount();
2880
3100
  yield (_b = this.successCallback) == null ? void 0 : _b.call(this, error);
2881
3101
  });
2882
3102
  }
@@ -2942,15 +3162,17 @@ var ModalFactory = class {
2942
3162
  onStartDesktopOnboarding() {
2943
3163
  new MetaMaskOnboarding().startOnboarding();
2944
3164
  }
2945
- renderInstallModal(showInstallModal, createConnectionRequest, successCallback) {
3165
+ renderInstallModal(showInstallModal, createConnectionRequest, successCallback, onDisplayUri) {
2946
3166
  return __async(this, null, function* () {
2947
- var _a;
2948
- (_a = this.modal) == null ? void 0 : _a.unmount();
2949
- yield Promise.all([preload(), preloadQR()]);
3167
+ var _a2, _b;
3168
+ (_a2 = this.modal) == null ? void 0 : _a2.unmount();
3169
+ yield this.preload();
2950
3170
  this.successCallback = successCallback;
3171
+ this.displayUriCallback = onDisplayUri;
2951
3172
  const parentElement = this.getMountedContainer();
2952
3173
  const connectionRequest = yield createConnectionRequest();
2953
3174
  const qrCodeLink = this.createConnectionDeeplink(connectionRequest);
3175
+ (_b = this.displayUriCallback) == null ? void 0 : _b.call(this, qrCodeLink);
2954
3176
  const modal = new this.options.InstallModal({
2955
3177
  expiresIn: (connectionRequest.sessionRequest.expiresAt - Date.now()) / 1e3,
2956
3178
  connectionRequest,
@@ -2959,11 +3181,15 @@ var ModalFactory = class {
2959
3181
  link: qrCodeLink,
2960
3182
  sdkVersion: getVersion(),
2961
3183
  generateQRCode: (request) => __async(this, null, function* () {
2962
- return this.createConnectionDeeplink(request);
3184
+ var _a3;
3185
+ const newLink = this.createConnectionDeeplink(request);
3186
+ (_a3 = this.displayUriCallback) == null ? void 0 : _a3.call(this, newLink);
3187
+ return newLink;
2963
3188
  }),
2964
3189
  onClose: this.onCloseModal.bind(this),
2965
3190
  startDesktopOnboarding: this.onStartDesktopOnboarding.bind(this),
2966
- createConnectionRequest
3191
+ createConnectionRequest,
3192
+ onDisplayUri: this.displayUriCallback
2967
3193
  });
2968
3194
  this.modal = modal;
2969
3195
  modal.mount();
@@ -2971,9 +3197,9 @@ var ModalFactory = class {
2971
3197
  }
2972
3198
  renderOTPCodeModal(createOTPCode, successCallback, updateOTPCode) {
2973
3199
  return __async(this, null, function* () {
2974
- var _a;
2975
- (_a = this.modal) == null ? void 0 : _a.unmount();
2976
- yield Promise.all([preload(), preloadQR()]);
3200
+ var _a2;
3201
+ (_a2 = this.modal) == null ? void 0 : _a2.unmount();
3202
+ yield this.preload();
2977
3203
  this.successCallback = successCallback;
2978
3204
  const container = this.getMountedContainer();
2979
3205
  const otpCode = yield createOTPCode();
@@ -2991,9 +3217,18 @@ var ModalFactory = class {
2991
3217
  }
2992
3218
  };
2993
3219
 
3220
+ // src/ui/index.native.ts
3221
+ var ModalFactory = class extends BaseModalFactory {
3222
+ // No-op for React Native - web components are not applicable
3223
+ preload() {
3224
+ return __async(this, null, function* () {
3225
+ });
3226
+ }
3227
+ };
3228
+
2994
3229
  // src/index.native.ts
2995
3230
  init_domain();
2996
- var createMetamaskConnect = (options) => __async(null, null, function* () {
3231
+ var createMultichainClient = (options) => __async(null, null, function* () {
2997
3232
  const uiModules = yield Promise.resolve().then(() => (init_rn(), rn_exports));
2998
3233
  let storage;
2999
3234
  if (!options.storage) {
@@ -3026,7 +3261,7 @@ export {
3026
3261
  StoreClient,
3027
3262
  TransportType,
3028
3263
  createLogger,
3029
- createMetamaskConnect,
3264
+ createMultichainClient,
3030
3265
  enableDebug,
3031
3266
  getInfuraRpcUrls,
3032
3267
  getPlatformType,