@metamask/connect-multichain 0.8.0 → 0.10.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 (58) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/README.md +38 -25
  3. package/dist/browser/es/connect-multichain.d.mts +31 -8
  4. package/dist/browser/es/connect-multichain.mjs +87 -68
  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 +31 -8
  8. package/dist/browser/iife/connect-multichain.js +100 -84
  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 +31 -8
  12. package/dist/browser/umd/connect-multichain.js +87 -68
  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 +31 -8
  16. package/dist/node/cjs/connect-multichain.js +87 -67
  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 +31 -8
  20. package/dist/node/es/connect-multichain.mjs +87 -67
  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 +31 -8
  24. package/dist/react-native/es/connect-multichain.mjs +87 -67
  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/api/infura.d.ts +13 -1
  28. package/dist/src/domain/multichain/api/infura.d.ts.map +1 -1
  29. package/dist/src/domain/multichain/api/infura.js +17 -5
  30. package/dist/src/domain/multichain/api/infura.js.map +1 -1
  31. package/dist/src/domain/multichain/index.d.ts +1 -1
  32. package/dist/src/domain/multichain/index.d.ts.map +1 -1
  33. package/dist/src/domain/multichain/index.js +3 -3
  34. package/dist/src/domain/multichain/index.js.map +1 -1
  35. package/dist/src/domain/multichain/types.d.ts +12 -1
  36. package/dist/src/domain/multichain/types.d.ts.map +1 -1
  37. package/dist/src/multichain/index.d.ts.map +1 -1
  38. package/dist/src/multichain/index.js +24 -17
  39. package/dist/src/multichain/index.js.map +1 -1
  40. package/dist/src/multichain/rpc/requestRouter.d.ts +3 -2
  41. package/dist/src/multichain/rpc/requestRouter.d.ts.map +1 -1
  42. package/dist/src/multichain/rpc/requestRouter.js +14 -15
  43. package/dist/src/multichain/rpc/requestRouter.js.map +1 -1
  44. package/dist/src/multichain/transports/default/index.d.ts.map +1 -1
  45. package/dist/src/multichain/transports/default/index.js +7 -1
  46. package/dist/src/multichain/transports/default/index.js.map +1 -1
  47. package/dist/src/multichain/utils/analytics.d.ts +6 -6
  48. package/dist/src/multichain/utils/analytics.d.ts.map +1 -1
  49. package/dist/src/multichain/utils/analytics.js +8 -12
  50. package/dist/src/multichain/utils/analytics.js.map +1 -1
  51. package/dist/src/ui/ModalFactory.d.ts.map +1 -1
  52. package/dist/src/ui/ModalFactory.js +1 -3
  53. package/dist/src/ui/ModalFactory.js.map +1 -1
  54. package/dist/src/ui/modals/web/install.d.ts.map +1 -1
  55. package/dist/src/ui/modals/web/install.js +0 -1
  56. package/dist/src/ui/modals/web/install.js.map +1 -1
  57. package/dist/types/connect-multichain.d.ts +31 -8
  58. package/package.json +3 -3
@@ -1,7 +1,7 @@
1
1
  import debug from 'debug';
2
2
  import { SessionData, Transport, SessionProperties, TransportRequest, TransportResponse, MultichainApiClient } from '@metamask/multichain-api-client';
3
3
  export { SessionData } from '@metamask/multichain-api-client';
4
- import { CaipAccountId, Json } from '@metamask/utils';
4
+ import { CaipAccountId, CaipChainId, Json } from '@metamask/utils';
5
5
  import { SessionRequest, Session } from '@metamask/mobile-wallet-protocol-core';
6
6
  import { Components } from '@metamask/multichain-ui';
7
7
 
@@ -386,6 +386,14 @@ type ConnectionRequest = {
386
386
  };
387
387
  };
388
388
  };
389
+ /**
390
+ * Package versions keyed by connect package name.
391
+ * connect-multichain is always present; chain-specific packages
392
+ * appear only when their client is instantiated.
393
+ */
394
+ type ConnectVersions = {
395
+ 'connect-multichain': string;
396
+ } & Partial<Record<'connect-evm' | 'connect-solana', string>>;
389
397
  /**
390
398
  * Constructor options for creating a Multichain SDK instance.
391
399
  *
@@ -431,6 +439,8 @@ type MultichainOptions = {
431
439
  };
432
440
  /** Enable debug logging */
433
441
  debug?: boolean;
442
+ /** Package versions contributed by chain-specific clients (merged on each createMultichainClient call) */
443
+ versions?: Partial<ConnectVersions>;
434
444
  };
435
445
  type MultiChainFNOptions = Omit<MultichainOptions, 'storage' | 'ui'> & {
436
446
  ui?: Omit<MultichainOptions['ui'], 'factory'>;
@@ -441,11 +451,12 @@ type MultiChainFNOptions = Omit<MultichainOptions, 'storage' | 'ui'> & {
441
451
  * Options that can be merged/overwritten when createMultichainClient is called
442
452
  * with an existing singleton.
443
453
  */
444
- type MergeableMultichainOptions = Omit<MultichainOptions, 'dapp' | 'analytics' | 'storage' | 'api' | 'ui' | 'transport'> & {
454
+ type MergeableMultichainOptions = Omit<MultichainOptions, 'dapp' | 'analytics' | 'storage' | 'api' | 'ui' | 'transport' | 'versions'> & {
445
455
  api?: MultichainOptions['api'];
446
456
  ui?: Pick<MultichainOptions['ui'], 'headless' | 'preferExtension' | 'showInstallModal'>;
447
457
  transport?: Pick<NonNullable<MultichainOptions['transport']>, 'extensionId'>;
448
458
  debug?: boolean;
459
+ versions?: Partial<ConnectVersions>;
449
460
  };
450
461
  /**
451
462
  * Complete options for Multichain SDK configuration.
@@ -474,7 +485,18 @@ declare const infuraRpcUrls: RpcUrlsMap;
474
485
  declare const RPC_HANDLED_METHODS: Set<string>;
475
486
  declare const SDK_HANDLED_METHODS: Set<string>;
476
487
 
477
- declare function getInfuraRpcUrls(infuraAPIKey: string): RpcUrlsMap;
488
+ /**
489
+ * Generates Infura RPC URLs for common networks keyed by CAIP Chain ID.
490
+ *
491
+ * @param options - The options for generating Infura RPC URLs
492
+ * @param options.infuraApiKey - The Infura API key
493
+ * @param options.caipChainIds - Optional CAIP-2 chain IDs to filter the output
494
+ * @returns A map of CAIP-2 chain IDs to Infura RPC URLs
495
+ */
496
+ declare function getInfuraRpcUrls({ infuraApiKey, caipChainIds, }: {
497
+ infuraApiKey: string;
498
+ caipChainIds?: CaipChainId[];
499
+ }): RpcUrlsMap;
478
500
 
479
501
  type ConnectionStatus = 'pending' | 'loaded' | 'disconnected' | 'connected' | 'connecting';
480
502
  declare enum TransportType {
@@ -519,7 +541,7 @@ declare abstract class MultichainCore extends EventEmitter<SDKEvents> {
519
541
  constructor(options: MultichainOptions);
520
542
  /**
521
543
  * Merges the given options into the current instance options.
522
- * Only the mergeable keys are updated (api.supportedNetworks, ui.*, mobile.*, transport.extensionId, debug).
544
+ * Only the mergeable keys are updated (api.supportedNetworks, versions, ui.*, mobile.*, transport.extensionId, debug).
523
545
  * The main thing to note is that the value for `dapp` is not merged as it does not make sense for
524
546
  * subsequent calls to `createMultichainClient` to have a different `dapp` value.
525
547
  * Used when createMultichainClient is called with an existing singleton.
@@ -658,15 +680,16 @@ declare function isRejectionError(error: unknown): boolean;
658
680
  * @param options - Multichain options containing dapp and analytics config
659
681
  * @param storage - Storage client for getting anonymous ID
660
682
  * @param invokeOptions - The invoke method options containing method and scope
683
+ * @param transportType - The transport type to use for the analytics event
661
684
  * @returns Wallet action analytics properties
662
685
  */
663
- declare function getWalletActionAnalyticsProperties(options: MultichainOptions, storage: StoreClient, invokeOptions: InvokeMethodOptions): Promise<{
664
- mmconnect_version: string;
686
+ declare function getWalletActionAnalyticsProperties(options: MultichainOptions, storage: StoreClient, invokeOptions: InvokeMethodOptions, transportType: TransportType): Promise<{
687
+ mmconnect_versions: Record<string, string>;
665
688
  dapp_id: string;
666
689
  method: string;
667
- integration_type: string;
668
690
  caip_chain_id: string;
669
691
  anon_id: string;
692
+ transport_type: TransportType;
670
693
  }>;
671
694
 
672
695
  /**
@@ -678,4 +701,4 @@ declare function getVersion(): string;
678
701
 
679
702
  declare const createMultichainClient: CreateMultichainFN;
680
703
 
681
- export { type ConnectionRequest, type ConnectionStatus, type CreateMultichainFN, type DappSettings, type DataType, type DomainErrorCodes, type Enumerate, type ErrorCodeRange, type ErrorCodes, EventEmitter, type EventTypes, type ExtendedTransport, type InstallWidgetProps, type InvokeMethodOptions, type LoggerNameSpaces, type MergeableMultichainOptions, Modal, type ModalFactoryConnectOptions, type ModalFactoryOptions, MultichainCore, type MultichainOptions, type NotificationCallback, type OTPCode, type OTPCodeWidgetProps, PlatformType, type QRLink, type RPCAPI, type RPCErrorCodes, RPCHttpErr, RPCInvokeMethodErr, RPCReadonlyRequestErr, RPCReadonlyResponseErr, type RPCResponse, RPC_HANDLED_METHODS, type RpcMethod, type RpcUrlsMap, type SDKEvents, SDK_HANDLED_METHODS, type Scope, type StorageErrorCodes, StoreAdapter, StoreClient, type StoreOptions, TransportType, createLogger, createMultichainClient, enableDebug, getInfuraRpcUrls, getPlatformType, getTransportType, getVersion, getWalletActionAnalyticsProperties, hasExtension, infuraRpcUrls, isEnabled, isMetamaskExtensionInstalled, isRejectionError, isSecure };
704
+ export { type ConnectVersions, type ConnectionRequest, type ConnectionStatus, type CreateMultichainFN, type DappSettings, type DataType, type DomainErrorCodes, type Enumerate, type ErrorCodeRange, type ErrorCodes, EventEmitter, type EventTypes, type ExtendedTransport, type InstallWidgetProps, type InvokeMethodOptions, type LoggerNameSpaces, type MergeableMultichainOptions, Modal, type ModalFactoryConnectOptions, type ModalFactoryOptions, MultichainCore, type MultichainOptions, type NotificationCallback, type OTPCode, type OTPCodeWidgetProps, PlatformType, type QRLink, type RPCAPI, type RPCErrorCodes, RPCHttpErr, RPCInvokeMethodErr, RPCReadonlyRequestErr, RPCReadonlyResponseErr, type RPCResponse, RPC_HANDLED_METHODS, type RpcMethod, type RpcUrlsMap, type SDKEvents, SDK_HANDLED_METHODS, type Scope, type StorageErrorCodes, StoreAdapter, StoreClient, type StoreOptions, TransportType, createLogger, createMultichainClient, enableDebug, getInfuraRpcUrls, getPlatformType, getTransportType, getVersion, getWalletActionAnalyticsProperties, hasExtension, infuraRpcUrls, isEnabled, isMetamaskExtensionInstalled, isRejectionError, isSecure };
@@ -377,10 +377,16 @@ var init_constants = __esm({
377
377
  });
378
378
 
379
379
  // src/domain/multichain/api/infura.ts
380
- function getInfuraRpcUrls(infuraAPIKey) {
381
- return Object.keys(infuraRpcUrls).reduce((acc, key) => {
382
- const typedKey = key;
383
- acc[typedKey] = `${infuraRpcUrls[typedKey]}${infuraAPIKey}`;
380
+ function getInfuraRpcUrls({
381
+ infuraApiKey,
382
+ caipChainIds
383
+ }) {
384
+ const keys = caipChainIds && caipChainIds.length > 0 ? caipChainIds : Object.keys(infuraRpcUrls);
385
+ return keys.reduce((acc, key) => {
386
+ const baseUrl = infuraRpcUrls[key];
387
+ if (baseUrl) {
388
+ acc[key] = `${baseUrl}${infuraApiKey}`;
389
+ }
384
390
  return acc;
385
391
  }, {});
386
392
  }
@@ -422,7 +428,7 @@ var init_multichain = __esm({
422
428
  }
423
429
  /**
424
430
  * Merges the given options into the current instance options.
425
- * Only the mergeable keys are updated (api.supportedNetworks, ui.*, mobile.*, transport.extensionId, debug).
431
+ * Only the mergeable keys are updated (api.supportedNetworks, versions, ui.*, mobile.*, transport.extensionId, debug).
426
432
  * The main thing to note is that the value for `dapp` is not merged as it does not make sense for
427
433
  * subsequent calls to `createMultichainClient` to have a different `dapp` value.
428
434
  * Used when createMultichainClient is called with an existing singleton.
@@ -430,22 +436,23 @@ var init_multichain = __esm({
430
436
  * @param partial - Options to merge/overwrite onto the current instance
431
437
  */
432
438
  mergeOptions(partial) {
433
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
439
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
434
440
  const opts = this.options;
435
441
  this.options = __spreadProps(__spreadValues({}, opts), {
436
442
  api: __spreadProps(__spreadValues({}, opts.api), {
437
443
  supportedNetworks: __spreadValues(__spreadValues({}, opts.api.supportedNetworks), (_b = (_a3 = partial.api) == null ? void 0 : _a3.supportedNetworks) != null ? _b : {})
438
444
  }),
445
+ versions: __spreadValues(__spreadValues({}, opts.versions), (_c = partial.versions) != null ? _c : {}),
439
446
  ui: __spreadProps(__spreadValues({}, opts.ui), {
440
- headless: (_d = (_c = partial.ui) == null ? void 0 : _c.headless) != null ? _d : opts.ui.headless,
441
- preferExtension: (_f = (_e = partial.ui) == null ? void 0 : _e.preferExtension) != null ? _f : opts.ui.preferExtension,
442
- showInstallModal: (_h = (_g = partial.ui) == null ? void 0 : _g.showInstallModal) != null ? _h : opts.ui.showInstallModal
447
+ headless: (_e = (_d = partial.ui) == null ? void 0 : _d.headless) != null ? _e : opts.ui.headless,
448
+ preferExtension: (_g = (_f = partial.ui) == null ? void 0 : _f.preferExtension) != null ? _g : opts.ui.preferExtension,
449
+ showInstallModal: (_i = (_h = partial.ui) == null ? void 0 : _h.showInstallModal) != null ? _i : opts.ui.showInstallModal
443
450
  }),
444
- mobile: __spreadValues(__spreadValues({}, opts.mobile), (_i = partial.mobile) != null ? _i : {}),
445
- transport: __spreadProps(__spreadValues({}, (_j = opts.transport) != null ? _j : {}), {
446
- extensionId: (_m = (_k = partial.transport) == null ? void 0 : _k.extensionId) != null ? _m : (_l = opts.transport) == null ? void 0 : _l.extensionId
451
+ mobile: __spreadValues(__spreadValues({}, opts.mobile), (_j = partial.mobile) != null ? _j : {}),
452
+ transport: __spreadProps(__spreadValues({}, (_k = opts.transport) != null ? _k : {}), {
453
+ extensionId: (_n = (_l = partial.transport) == null ? void 0 : _l.extensionId) != null ? _n : (_m = opts.transport) == null ? void 0 : _m.extensionId
447
454
  }),
448
- debug: (_n = partial.debug) != null ? _n : opts.debug
455
+ debug: (_o = partial.debug) != null ? _o : opts.debug
449
456
  });
450
457
  }
451
458
  };
@@ -647,35 +654,30 @@ function isRejectionError(error) {
647
654
  }
648
655
  function getBaseAnalyticsProperties(options, storage) {
649
656
  return __async(this, null, function* () {
650
- var _a3, _b;
651
- const version = getVersion();
657
+ var _a3;
652
658
  const dappId = getDappId(options.dapp);
653
659
  const platform = getPlatformType();
654
660
  const anonId = yield storage.getAnonId();
655
- const integrationType = (_b = (_a3 = options.analytics) == null ? void 0 : _a3.integrationType) != null ? _b : "unknown" /* UNKNOWN */;
656
661
  return {
657
- mmconnect_version: version,
662
+ mmconnect_versions: (_a3 = options.versions) != null ? _a3 : {},
658
663
  dapp_id: dappId,
659
664
  platform,
660
- integration_type: integrationType,
661
665
  anon_id: anonId
662
666
  };
663
667
  });
664
668
  }
665
- function getWalletActionAnalyticsProperties(options, storage, invokeOptions) {
669
+ function getWalletActionAnalyticsProperties(options, storage, invokeOptions, transportType) {
666
670
  return __async(this, null, function* () {
667
- var _a3, _b;
668
- const version = getVersion();
671
+ var _a3;
669
672
  const dappId = getDappId(options.dapp);
670
673
  const anonId = yield storage.getAnonId();
671
- const integrationType = (_b = (_a3 = options.analytics) == null ? void 0 : _a3.integrationType) != null ? _b : "unknown";
672
674
  return {
673
- mmconnect_version: version,
675
+ mmconnect_versions: (_a3 = options.versions) != null ? _a3 : {},
674
676
  dapp_id: dappId,
675
677
  method: invokeOptions.request.method,
676
- integration_type: integrationType,
677
678
  caip_chain_id: invokeOptions.scope,
678
- anon_id: anonId
679
+ anon_id: anonId,
680
+ transport_type: transportType
679
681
  };
680
682
  });
681
683
  }
@@ -1111,7 +1113,6 @@ var init_install = __esm({
1111
1113
  "mm-install-modal"
1112
1114
  );
1113
1115
  modal.showInstallModal = options.showInstallModal;
1114
- modal.sdkVersion = options.sdkVersion;
1115
1116
  modal.addEventListener("close", (ev) => {
1116
1117
  const { detail } = ev;
1117
1118
  options.onClose(detail == null ? void 0 : detail.shouldTerminate);
@@ -1464,10 +1465,11 @@ init_utils2();
1464
1465
  init_analytics();
1465
1466
  var _RequestRouter_instances, withAnalyticsTracking_fn, trackWalletActionRequested_fn, trackWalletActionSucceeded_fn, trackWalletActionFailed_fn, trackWalletActionRejected_fn;
1466
1467
  var RequestRouter = class {
1467
- constructor(transport, rpcClient, config) {
1468
+ constructor(transport, rpcClient, config, transportType) {
1468
1469
  this.transport = transport;
1469
1470
  this.rpcClient = rpcClient;
1470
1471
  this.config = config;
1472
+ this.transportType = transportType;
1471
1473
  __privateAdd(this, _RequestRouter_instances);
1472
1474
  }
1473
1475
  /**
@@ -1537,16 +1539,14 @@ var RequestRouter = class {
1537
1539
  */
1538
1540
  handleWithRpcNode(options) {
1539
1541
  return __async(this, null, function* () {
1540
- return __privateMethod(this, _RequestRouter_instances, withAnalyticsTracking_fn).call(this, options, () => __async(this, null, function* () {
1541
- try {
1542
- return yield this.rpcClient.request(options);
1543
- } catch (error) {
1544
- if (error instanceof MissingRpcEndpointErr) {
1545
- return this.handleWithWallet(options);
1546
- }
1547
- throw error;
1542
+ try {
1543
+ return yield this.rpcClient.request(options);
1544
+ } catch (error) {
1545
+ if (error instanceof MissingRpcEndpointErr) {
1546
+ return this.handleWithWallet(options);
1548
1547
  }
1549
- }));
1548
+ throw error;
1549
+ }
1550
1550
  });
1551
1551
  }
1552
1552
  /**
@@ -1590,7 +1590,8 @@ trackWalletActionRequested_fn = function(options) {
1590
1590
  const props = yield getWalletActionAnalyticsProperties(
1591
1591
  this.config,
1592
1592
  this.config.storage,
1593
- options
1593
+ options,
1594
+ this.transportType
1594
1595
  );
1595
1596
  import_analytics2.analytics.track("mmconnect_wallet_action_requested", props);
1596
1597
  });
@@ -1600,7 +1601,8 @@ trackWalletActionSucceeded_fn = function(options) {
1600
1601
  const props = yield getWalletActionAnalyticsProperties(
1601
1602
  this.config,
1602
1603
  this.config.storage,
1603
- options
1604
+ options,
1605
+ this.transportType
1604
1606
  );
1605
1607
  import_analytics2.analytics.track("mmconnect_wallet_action_succeeded", props);
1606
1608
  });
@@ -1610,7 +1612,8 @@ trackWalletActionFailed_fn = function(options) {
1610
1612
  const props = yield getWalletActionAnalyticsProperties(
1611
1613
  this.config,
1612
1614
  this.config.storage,
1613
- options
1615
+ options,
1616
+ this.transportType
1614
1617
  );
1615
1618
  import_analytics2.analytics.track("mmconnect_wallet_action_failed", props);
1616
1619
  });
@@ -1620,7 +1623,8 @@ trackWalletActionRejected_fn = function(options) {
1620
1623
  const props = yield getWalletActionAnalyticsProperties(
1621
1624
  this.config,
1622
1625
  this.config.storage,
1623
- options
1626
+ options,
1627
+ this.transportType
1624
1628
  );
1625
1629
  import_analytics2.analytics.track("mmconnect_wallet_action_rejected", props);
1626
1630
  });
@@ -1863,7 +1867,9 @@ setupMessageListener_fn = function() {
1863
1867
  init_fn = function() {
1864
1868
  return __async(this, null, function* () {
1865
1869
  __privateMethod(this, _DefaultTransport_instances, setupMessageListener_fn).call(this);
1866
- yield __privateGet(this, _transport).connect();
1870
+ if (!__privateGet(this, _transport).isConnected()) {
1871
+ yield __privateGet(this, _transport).connect();
1872
+ }
1867
1873
  });
1868
1874
  };
1869
1875
 
@@ -2708,16 +2714,21 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2708
2714
  constructor(options) {
2709
2715
  var _a3, _b, _c, _d, _e, _f;
2710
2716
  const withDappMetadata = setupDappMetadata(options);
2711
- const integrationType = (_b = (_a3 = options.analytics) == null ? void 0 : _a3.integrationType) != null ? _b : "direct";
2717
+ const integrationType = ((_a3 = options.analytics) == null ? void 0 : _a3.integrationType) || "direct";
2712
2718
  const allOptions = __spreadProps(__spreadValues({}, withDappMetadata), {
2713
2719
  ui: __spreadProps(__spreadValues({}, withDappMetadata.ui), {
2714
- preferExtension: (_c = withDappMetadata.ui.preferExtension) != null ? _c : true,
2715
- showInstallModal: (_d = withDappMetadata.ui.showInstallModal) != null ? _d : false,
2716
- headless: (_e = withDappMetadata.ui.headless) != null ? _e : false
2720
+ preferExtension: (_b = withDappMetadata.ui.preferExtension) != null ? _b : true,
2721
+ showInstallModal: (_c = withDappMetadata.ui.showInstallModal) != null ? _c : false,
2722
+ headless: (_d = withDappMetadata.ui.headless) != null ? _d : false
2717
2723
  }),
2718
- analytics: __spreadProps(__spreadValues({}, (_f = options.analytics) != null ? _f : {}), {
2724
+ analytics: __spreadProps(__spreadValues({}, (_e = options.analytics) != null ? _e : {}), {
2719
2725
  integrationType
2720
- })
2726
+ }),
2727
+ versions: __spreadValues({
2728
+ // typeof guard needed: Metro (React Native) bundles TS source directly,
2729
+ // bypassing the tsup build that substitutes __PACKAGE_VERSION__.
2730
+ "connect-multichain": false ? "unknown" : "0.10.0"
2731
+ }, (_f = options.versions) != null ? _f : {})
2721
2732
  });
2722
2733
  super(allOptions);
2723
2734
  __privateAdd(this, _MetaMaskConnectMultichain_instances);
@@ -2774,23 +2785,33 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2774
2785
  // Creates a singleton instance of MetaMaskConnectMultichain.
2775
2786
  // If the singleton already exists, it merges the incoming options with the
2776
2787
  // existing singleton options for the following keys: `api.supportedNetworks`,
2777
- // `ui.*`, `mobile.*`, `transport.extensionId`, `debug`. Take note that the
2778
- // value for `dapp` is not merged as it does not make sense for subsequent calls to
2779
- // `createMultichainClient` to have a different `dapp` value.
2788
+ // `versions`, `ui.*`, `mobile.*`, `transport.extensionId`, `debug`. Take note
2789
+ // that the value for `dapp` is not merged as it does not make sense for
2790
+ // subsequent calls to `createMultichainClient` to have a different `dapp` value.
2780
2791
  static create(options) {
2781
2792
  return __async(this, null, function* () {
2793
+ var _a3, _b;
2782
2794
  const globalObject = getGlobalObject();
2783
2795
  const existing = globalObject[SINGLETON_KEY];
2784
2796
  if (existing) {
2785
2797
  const instance = yield existing;
2786
2798
  instance.mergeOptions(options);
2799
+ import_analytics4.analytics.setGlobalProperty(
2800
+ "mmconnect_versions",
2801
+ (_a3 = instance.options.versions) != null ? _a3 : {}
2802
+ );
2803
+ if ((_b = options.analytics) == null ? void 0 : _b.integrationType) {
2804
+ import_analytics4.analytics.setGlobalProperty("integration_types", [
2805
+ options.analytics.integrationType
2806
+ ]);
2807
+ }
2787
2808
  if (options.debug) {
2788
2809
  enableDebug("metamask-sdk:*");
2789
2810
  }
2790
2811
  return instance;
2791
2812
  }
2792
2813
  const instancePromise = (() => __async(null, null, function* () {
2793
- var _a3;
2814
+ var _a4;
2794
2815
  const instance = new _MetaMaskConnectMultichain(options);
2795
2816
  const isEnabled2 = yield isEnabled(
2796
2817
  "metamask-sdk:core",
@@ -2799,7 +2820,7 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2799
2820
  if (isEnabled2) {
2800
2821
  enableDebug("metamask-sdk:core");
2801
2822
  }
2802
- yield __privateMethod(_a3 = instance, _MetaMaskConnectMultichain_instances, init_fn2).call(_a3);
2823
+ yield __privateMethod(_a4 = instance, _MetaMaskConnectMultichain_instances, init_fn2).call(_a4);
2803
2824
  return instance;
2804
2825
  }))();
2805
2826
  globalObject[SINGLETON_KEY] = instancePromise;
@@ -2927,7 +2948,12 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2927
2948
  return __async(this, null, function* () {
2928
2949
  const { transport, options } = this;
2929
2950
  const rpcClient = new RpcClient(options, __privateGet(this, _sdkInfo));
2930
- const requestRouter = new RequestRouter(transport, rpcClient, options);
2951
+ const requestRouter = new RequestRouter(
2952
+ transport,
2953
+ rpcClient,
2954
+ options,
2955
+ this.transportType
2956
+ );
2931
2957
  return requestRouter.invokeMethod(request);
2932
2958
  });
2933
2959
  }
@@ -2980,24 +3006,28 @@ _sdkInfo = new WeakMap();
2980
3006
  _MetaMaskConnectMultichain_instances = new WeakSet();
2981
3007
  setupAnalytics_fn = function() {
2982
3008
  return __async(this, null, function* () {
2983
- var _a3;
3009
+ var _a3, _b;
2984
3010
  const platform = getPlatformType();
2985
3011
  const isBrowser = platform === "in-app-browser" /* MetaMaskMobileWebview */ || platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */;
2986
3012
  const isReactNative2 = platform === "react-native" /* ReactNative */;
2987
3013
  if (!isBrowser && !isReactNative2) {
2988
3014
  return;
2989
3015
  }
2990
- const version = getVersion();
2991
3016
  const dappId = getDappId(this.options.dapp);
2992
3017
  const anonId = yield this.storage.getAnonId();
2993
3018
  const { integrationType } = (_a3 = this.options.analytics) != null ? _a3 : {
2994
3019
  integrationType: ""
2995
3020
  };
2996
- import_analytics4.analytics.setGlobalProperty("mmconnect_version", version);
3021
+ import_analytics4.analytics.setGlobalProperty(
3022
+ "mmconnect_versions",
3023
+ (_b = this.options.versions) != null ? _b : {}
3024
+ );
2997
3025
  import_analytics4.analytics.setGlobalProperty("dapp_id", dappId);
2998
3026
  import_analytics4.analytics.setGlobalProperty("anon_id", anonId);
2999
3027
  import_analytics4.analytics.setGlobalProperty("platform", platform);
3000
- import_analytics4.analytics.setGlobalProperty("integration_type", integrationType);
3028
+ if (integrationType) {
3029
+ import_analytics4.analytics.setGlobalProperty("integration_types", [integrationType]);
3030
+ }
3001
3031
  import_analytics4.analytics.enable();
3002
3032
  });
3003
3033
  };
@@ -3084,15 +3114,6 @@ init_fn2 = function() {
3084
3114
  try {
3085
3115
  yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupAnalytics_fn).call(this);
3086
3116
  yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupTransport_fn).call(this);
3087
- try {
3088
- const baseProps = yield getBaseAnalyticsProperties(
3089
- this.options,
3090
- this.storage
3091
- );
3092
- import_analytics4.analytics.track("mmconnect_initialized", baseProps);
3093
- } catch (error) {
3094
- logger2("Error tracking initialized event", error);
3095
- }
3096
3117
  } catch (error) {
3097
3118
  yield this.storage.removeTransport();
3098
3119
  this.status = "pending";
@@ -3746,7 +3767,6 @@ var BaseModalFactory = class {
3746
3767
  parentElement,
3747
3768
  showInstallModal,
3748
3769
  link: qrCodeLink,
3749
- sdkVersion: getVersion(),
3750
3770
  generateQRCode: (request) => __async(this, null, function* () {
3751
3771
  var _a4;
3752
3772
  const newLink = this.createConnectionDeeplink(request);
@@ -3772,7 +3792,6 @@ var BaseModalFactory = class {
3772
3792
  const otpCode = yield createOTPCode();
3773
3793
  const modal = new this.options.OTPCodeModal({
3774
3794
  parentElement: container,
3775
- sdkVersion: getVersion(),
3776
3795
  otpCode,
3777
3796
  onClose: this.onCloseModal.bind(this),
3778
3797
  createOTPCode,