@metamask/connect-multichain 0.8.0 → 0.9.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.
- package/CHANGELOG.md +20 -1
- package/README.md +20 -19
- package/dist/browser/es/connect-multichain.d.mts +18 -5
- package/dist/browser/es/connect-multichain.mjs +63 -55
- package/dist/browser/es/connect-multichain.mjs.map +1 -1
- package/dist/browser/es/metafile-esm.json +1 -1
- package/dist/browser/iife/connect-multichain.d.ts +18 -5
- package/dist/browser/iife/connect-multichain.js +68 -71
- package/dist/browser/iife/connect-multichain.js.map +1 -1
- package/dist/browser/iife/metafile-iife.json +1 -1
- package/dist/browser/umd/connect-multichain.d.ts +18 -5
- package/dist/browser/umd/connect-multichain.js +63 -55
- package/dist/browser/umd/connect-multichain.js.map +1 -1
- package/dist/browser/umd/metafile-cjs.json +1 -1
- package/dist/node/cjs/connect-multichain.d.ts +18 -5
- package/dist/node/cjs/connect-multichain.js +63 -54
- package/dist/node/cjs/connect-multichain.js.map +1 -1
- package/dist/node/cjs/metafile-cjs.json +1 -1
- package/dist/node/es/connect-multichain.d.mts +18 -5
- package/dist/node/es/connect-multichain.mjs +63 -54
- package/dist/node/es/connect-multichain.mjs.map +1 -1
- package/dist/node/es/metafile-esm.json +1 -1
- package/dist/react-native/es/connect-multichain.d.mts +18 -5
- package/dist/react-native/es/connect-multichain.mjs +63 -54
- package/dist/react-native/es/connect-multichain.mjs.map +1 -1
- package/dist/react-native/es/metafile-esm.json +1 -1
- package/dist/src/domain/multichain/index.d.ts +1 -1
- package/dist/src/domain/multichain/index.d.ts.map +1 -1
- package/dist/src/domain/multichain/index.js +3 -3
- package/dist/src/domain/multichain/index.js.map +1 -1
- package/dist/src/domain/multichain/types.d.ts +12 -1
- package/dist/src/domain/multichain/types.d.ts.map +1 -1
- package/dist/src/multichain/index.d.ts.map +1 -1
- package/dist/src/multichain/index.js +11 -17
- package/dist/src/multichain/index.js.map +1 -1
- package/dist/src/multichain/rpc/requestRouter.d.ts +3 -2
- package/dist/src/multichain/rpc/requestRouter.d.ts.map +1 -1
- package/dist/src/multichain/rpc/requestRouter.js +14 -15
- package/dist/src/multichain/rpc/requestRouter.js.map +1 -1
- package/dist/src/multichain/transports/default/index.d.ts.map +1 -1
- package/dist/src/multichain/transports/default/index.js +7 -1
- package/dist/src/multichain/transports/default/index.js.map +1 -1
- package/dist/src/multichain/utils/analytics.d.ts +6 -3
- package/dist/src/multichain/utils/analytics.d.ts.map +1 -1
- package/dist/src/multichain/utils/analytics.js +8 -8
- package/dist/src/multichain/utils/analytics.js.map +1 -1
- package/dist/src/ui/ModalFactory.d.ts.map +1 -1
- package/dist/src/ui/ModalFactory.js +1 -3
- package/dist/src/ui/ModalFactory.js.map +1 -1
- package/dist/src/ui/modals/web/install.d.ts.map +1 -1
- package/dist/src/ui/modals/web/install.js +0 -1
- package/dist/src/ui/modals/web/install.js.map +1 -1
- package/dist/types/connect-multichain.d.ts +18 -5
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.9.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add `versions` constructor option to `createMultichainClient` so chain-specific packages (`connect-evm`, `connect-solana`) can report their version in analytics events. Versions are merged into the singleton on each call, following the same pattern as `api.supportedNetworks`. ([#206](https://github.com/MetaMask/connect-monorepo/pull/206))
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **BREAKING** `mmconnect_versions` analytics property is now a `Record<string, string>` keyed by package name instead of a plain version string ([#206](https://github.com/MetaMask/connect-monorepo/pull/206))
|
|
19
|
+
|
|
20
|
+
### Removed
|
|
21
|
+
|
|
22
|
+
- Stop passing `sdkVersion` to install and OTP modals ([#212](https://github.com/MetaMask/connect-monorepo/pull/212))
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Fix a bug where wallet_sessionChanged events were failing to propagate to the `ConnectMultichain` instance when the `DefaultTransport` is using the `WindowPostMessageTransport`. This was affecting Firefox, both iOS and Android in-app browsers ([#204](https://github.com/MetaMask/connect-monorepo/pull/204))
|
|
27
|
+
|
|
10
28
|
## [0.8.0]
|
|
11
29
|
|
|
12
30
|
### Added
|
|
@@ -181,7 +199,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
181
199
|
|
|
182
200
|
- Initial release
|
|
183
201
|
|
|
184
|
-
[Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.
|
|
202
|
+
[Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.9.0...HEAD
|
|
203
|
+
[0.9.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.8.0...@metamask/connect-multichain@0.9.0
|
|
185
204
|
[0.8.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.7.0...@metamask/connect-multichain@0.8.0
|
|
186
205
|
[0.7.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.6.0...@metamask/connect-multichain@0.7.0
|
|
187
206
|
[0.6.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.5.3...@metamask/connect-multichain@0.6.0
|
package/README.md
CHANGED
|
@@ -134,28 +134,29 @@ This package is written in TypeScript and includes full type definitions. No add
|
|
|
134
134
|
|
|
135
135
|
Factory function to create a new Multichain SDK instance.
|
|
136
136
|
|
|
137
|
-
> **Singleton:** `createMultichainClient` returns a single shared instance per global context. Calling it a second time with different options will merge the new `api.supportedNetworks`, `ui.*`, `mobile.*`, `transport.extensionId`, and `debug` values into the existing instance rather than creating a new one. The `dapp` value is never overwritten on subsequent calls.
|
|
137
|
+
> **Singleton:** `createMultichainClient` returns a single shared instance per global context. Calling it a second time with different options will merge the new `api.supportedNetworks`, `versions`, `ui.*`, `mobile.*`, `transport.extensionId`, and `debug` values into the existing instance rather than creating a new one. The `dapp` value is never overwritten on subsequent calls.
|
|
138
138
|
|
|
139
139
|
#### Parameters
|
|
140
140
|
|
|
141
|
-
| Option | Type | Required | Description
|
|
142
|
-
| --------------------------- | --------------------------------------------- | -------- |
|
|
143
|
-
| `dapp.name` | `string` | Yes | Name of your dApp
|
|
144
|
-
| `api.supportedNetworks` | `RpcUrlsMap` | Yes | Map of [CAIP-2 chain IDs](https://chainagnostic.org/CAIPs/caip-2) to RPC URLs
|
|
145
|
-
| `dapp.url` | `string` | No | URL of your dApp
|
|
146
|
-
| `dapp.iconUrl` | `string` | No | Icon URL for your dApp
|
|
147
|
-
| `dapp.base64Icon` | `string` | No | Base64-encoded icon (alternative to iconUrl)
|
|
148
|
-
| `storage` | `StoreClient` | No | Custom storage adapter
|
|
149
|
-
| `ui.factory` | `BaseModalFactory` | No | Custom modal factory
|
|
150
|
-
| `ui.headless` | `boolean` | No | Run without UI (for custom QR implementations)
|
|
151
|
-
| `ui.preferExtension` | `boolean` | No | Prefer browser extension (default: true)
|
|
152
|
-
| `ui.showInstallModal` | `boolean` | No | Show installation modal
|
|
153
|
-
| `mobile.preferredOpenLink` | `(deeplink: string, target?: string) => void` | No | Custom deeplink handler
|
|
154
|
-
| `mobile.useDeeplink` | `boolean` | No | Use `metamask://` instead of universal links
|
|
155
|
-
| `analytics.integrationType` | `string` | No | Integration type for analytics
|
|
156
|
-
| `transport.extensionId` | `string` | No | Custom extension ID
|
|
157
|
-
| `transport.onNotification` | `(notification: unknown) => void` | No | Notification handler
|
|
158
|
-
| `
|
|
141
|
+
| Option | Type | Required | Description |
|
|
142
|
+
| --------------------------- | --------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
|
|
143
|
+
| `dapp.name` | `string` | Yes | Name of your dApp |
|
|
144
|
+
| `api.supportedNetworks` | `RpcUrlsMap` | Yes | Map of [CAIP-2 chain IDs](https://chainagnostic.org/CAIPs/caip-2) to RPC URLs |
|
|
145
|
+
| `dapp.url` | `string` | No | URL of your dApp |
|
|
146
|
+
| `dapp.iconUrl` | `string` | No | Icon URL for your dApp |
|
|
147
|
+
| `dapp.base64Icon` | `string` | No | Base64-encoded icon (alternative to iconUrl) |
|
|
148
|
+
| `storage` | `StoreClient` | No | Custom storage adapter |
|
|
149
|
+
| `ui.factory` | `BaseModalFactory` | No | Custom modal factory |
|
|
150
|
+
| `ui.headless` | `boolean` | No | Run without UI (for custom QR implementations) |
|
|
151
|
+
| `ui.preferExtension` | `boolean` | No | Prefer browser extension (default: true) |
|
|
152
|
+
| `ui.showInstallModal` | `boolean` | No | Show installation modal |
|
|
153
|
+
| `mobile.preferredOpenLink` | `(deeplink: string, target?: string) => void` | No | Custom deeplink handler |
|
|
154
|
+
| `mobile.useDeeplink` | `boolean` | No | Use `metamask://` instead of universal links |
|
|
155
|
+
| `analytics.integrationType` | `string` | No | Integration type for analytics |
|
|
156
|
+
| `transport.extensionId` | `string` | No | Custom extension ID |
|
|
157
|
+
| `transport.onNotification` | `(notification: unknown) => void` | No | Notification handler |
|
|
158
|
+
| `versions` | `Partial<ConnectVersions>` | No | Internal: set automatically by `createEVMClient` / `createSolanaClient`. Consumers do not need to provide this. |
|
|
159
|
+
| `debug` | `boolean` | No | Enable debug logging |
|
|
159
160
|
|
|
160
161
|
#### Returns
|
|
161
162
|
|
|
@@ -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.
|
|
@@ -519,7 +530,7 @@ declare abstract class MultichainCore extends EventEmitter<SDKEvents> {
|
|
|
519
530
|
constructor(options: MultichainOptions);
|
|
520
531
|
/**
|
|
521
532
|
* Merges the given options into the current instance options.
|
|
522
|
-
* Only the mergeable keys are updated (api.supportedNetworks, ui.*, mobile.*, transport.extensionId, debug).
|
|
533
|
+
* Only the mergeable keys are updated (api.supportedNetworks, versions, ui.*, mobile.*, transport.extensionId, debug).
|
|
523
534
|
* The main thing to note is that the value for `dapp` is not merged as it does not make sense for
|
|
524
535
|
* subsequent calls to `createMultichainClient` to have a different `dapp` value.
|
|
525
536
|
* Used when createMultichainClient is called with an existing singleton.
|
|
@@ -658,15 +669,17 @@ declare function isRejectionError(error: unknown): boolean;
|
|
|
658
669
|
* @param options - Multichain options containing dapp and analytics config
|
|
659
670
|
* @param storage - Storage client for getting anonymous ID
|
|
660
671
|
* @param invokeOptions - The invoke method options containing method and scope
|
|
672
|
+
* @param transportType - The transport type to use for the analytics event
|
|
661
673
|
* @returns Wallet action analytics properties
|
|
662
674
|
*/
|
|
663
|
-
declare function getWalletActionAnalyticsProperties(options: MultichainOptions, storage: StoreClient, invokeOptions: InvokeMethodOptions): Promise<{
|
|
664
|
-
|
|
675
|
+
declare function getWalletActionAnalyticsProperties(options: MultichainOptions, storage: StoreClient, invokeOptions: InvokeMethodOptions, transportType: TransportType): Promise<{
|
|
676
|
+
mmconnect_versions: Record<string, string>;
|
|
665
677
|
dapp_id: string;
|
|
666
678
|
method: string;
|
|
667
679
|
integration_type: string;
|
|
668
680
|
caip_chain_id: string;
|
|
669
681
|
anon_id: string;
|
|
682
|
+
transport_type: TransportType;
|
|
670
683
|
}>;
|
|
671
684
|
|
|
672
685
|
/**
|
|
@@ -678,4 +691,4 @@ declare function getVersion(): string;
|
|
|
678
691
|
|
|
679
692
|
declare const createMultichainClient: CreateMultichainFN;
|
|
680
693
|
|
|
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 };
|
|
694
|
+
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 };
|
|
@@ -401,7 +401,7 @@ var init_multichain = __esm({
|
|
|
401
401
|
}
|
|
402
402
|
/**
|
|
403
403
|
* Merges the given options into the current instance options.
|
|
404
|
-
* Only the mergeable keys are updated (api.supportedNetworks, ui.*, mobile.*, transport.extensionId, debug).
|
|
404
|
+
* Only the mergeable keys are updated (api.supportedNetworks, versions, ui.*, mobile.*, transport.extensionId, debug).
|
|
405
405
|
* The main thing to note is that the value for `dapp` is not merged as it does not make sense for
|
|
406
406
|
* subsequent calls to `createMultichainClient` to have a different `dapp` value.
|
|
407
407
|
* Used when createMultichainClient is called with an existing singleton.
|
|
@@ -409,22 +409,23 @@ var init_multichain = __esm({
|
|
|
409
409
|
* @param partial - Options to merge/overwrite onto the current instance
|
|
410
410
|
*/
|
|
411
411
|
mergeOptions(partial) {
|
|
412
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
412
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
413
413
|
const opts = this.options;
|
|
414
414
|
this.options = __spreadProps(__spreadValues({}, opts), {
|
|
415
415
|
api: __spreadProps(__spreadValues({}, opts.api), {
|
|
416
416
|
supportedNetworks: __spreadValues(__spreadValues({}, opts.api.supportedNetworks), (_b = (_a3 = partial.api) == null ? void 0 : _a3.supportedNetworks) != null ? _b : {})
|
|
417
417
|
}),
|
|
418
|
+
versions: __spreadValues(__spreadValues({}, opts.versions), (_c = partial.versions) != null ? _c : {}),
|
|
418
419
|
ui: __spreadProps(__spreadValues({}, opts.ui), {
|
|
419
|
-
headless: (
|
|
420
|
-
preferExtension: (
|
|
421
|
-
showInstallModal: (
|
|
420
|
+
headless: (_e = (_d = partial.ui) == null ? void 0 : _d.headless) != null ? _e : opts.ui.headless,
|
|
421
|
+
preferExtension: (_g = (_f = partial.ui) == null ? void 0 : _f.preferExtension) != null ? _g : opts.ui.preferExtension,
|
|
422
|
+
showInstallModal: (_i = (_h = partial.ui) == null ? void 0 : _h.showInstallModal) != null ? _i : opts.ui.showInstallModal
|
|
422
423
|
}),
|
|
423
|
-
mobile: __spreadValues(__spreadValues({}, opts.mobile), (
|
|
424
|
-
transport: __spreadProps(__spreadValues({}, (
|
|
425
|
-
extensionId: (
|
|
424
|
+
mobile: __spreadValues(__spreadValues({}, opts.mobile), (_j = partial.mobile) != null ? _j : {}),
|
|
425
|
+
transport: __spreadProps(__spreadValues({}, (_k = opts.transport) != null ? _k : {}), {
|
|
426
|
+
extensionId: (_n = (_l = partial.transport) == null ? void 0 : _l.extensionId) != null ? _n : (_m = opts.transport) == null ? void 0 : _m.extensionId
|
|
426
427
|
}),
|
|
427
|
-
debug: (
|
|
428
|
+
debug: (_o = partial.debug) != null ? _o : opts.debug
|
|
428
429
|
});
|
|
429
430
|
}
|
|
430
431
|
};
|
|
@@ -626,14 +627,13 @@ function isRejectionError(error) {
|
|
|
626
627
|
}
|
|
627
628
|
function getBaseAnalyticsProperties(options, storage) {
|
|
628
629
|
return __async(this, null, function* () {
|
|
629
|
-
var _a3, _b;
|
|
630
|
-
const version = getVersion();
|
|
630
|
+
var _a3, _b, _c;
|
|
631
631
|
const dappId = getDappId(options.dapp);
|
|
632
632
|
const platform = getPlatformType();
|
|
633
633
|
const anonId = yield storage.getAnonId();
|
|
634
634
|
const integrationType = (_b = (_a3 = options.analytics) == null ? void 0 : _a3.integrationType) != null ? _b : "unknown" /* UNKNOWN */;
|
|
635
635
|
return {
|
|
636
|
-
|
|
636
|
+
mmconnect_versions: (_c = options.versions) != null ? _c : {},
|
|
637
637
|
dapp_id: dappId,
|
|
638
638
|
platform,
|
|
639
639
|
integration_type: integrationType,
|
|
@@ -641,20 +641,20 @@ function getBaseAnalyticsProperties(options, storage) {
|
|
|
641
641
|
};
|
|
642
642
|
});
|
|
643
643
|
}
|
|
644
|
-
function getWalletActionAnalyticsProperties(options, storage, invokeOptions) {
|
|
644
|
+
function getWalletActionAnalyticsProperties(options, storage, invokeOptions, transportType) {
|
|
645
645
|
return __async(this, null, function* () {
|
|
646
|
-
var _a3, _b;
|
|
647
|
-
const version = getVersion();
|
|
646
|
+
var _a3, _b, _c;
|
|
648
647
|
const dappId = getDappId(options.dapp);
|
|
649
648
|
const anonId = yield storage.getAnonId();
|
|
650
649
|
const integrationType = (_b = (_a3 = options.analytics) == null ? void 0 : _a3.integrationType) != null ? _b : "unknown";
|
|
651
650
|
return {
|
|
652
|
-
|
|
651
|
+
mmconnect_versions: (_c = options.versions) != null ? _c : {},
|
|
653
652
|
dapp_id: dappId,
|
|
654
653
|
method: invokeOptions.request.method,
|
|
655
654
|
integration_type: integrationType,
|
|
656
655
|
caip_chain_id: invokeOptions.scope,
|
|
657
|
-
anon_id: anonId
|
|
656
|
+
anon_id: anonId,
|
|
657
|
+
transport_type: transportType
|
|
658
658
|
};
|
|
659
659
|
});
|
|
660
660
|
}
|
|
@@ -1093,7 +1093,6 @@ var init_install = __esm({
|
|
|
1093
1093
|
"mm-install-modal"
|
|
1094
1094
|
);
|
|
1095
1095
|
modal.showInstallModal = options.showInstallModal;
|
|
1096
|
-
modal.sdkVersion = options.sdkVersion;
|
|
1097
1096
|
modal.addEventListener("close", (ev) => {
|
|
1098
1097
|
const { detail } = ev;
|
|
1099
1098
|
options.onClose(detail == null ? void 0 : detail.shouldTerminate);
|
|
@@ -1420,10 +1419,11 @@ init_utils2();
|
|
|
1420
1419
|
init_analytics();
|
|
1421
1420
|
var _RequestRouter_instances, withAnalyticsTracking_fn, trackWalletActionRequested_fn, trackWalletActionSucceeded_fn, trackWalletActionFailed_fn, trackWalletActionRejected_fn;
|
|
1422
1421
|
var RequestRouter = class {
|
|
1423
|
-
constructor(transport, rpcClient, config) {
|
|
1422
|
+
constructor(transport, rpcClient, config, transportType) {
|
|
1424
1423
|
this.transport = transport;
|
|
1425
1424
|
this.rpcClient = rpcClient;
|
|
1426
1425
|
this.config = config;
|
|
1426
|
+
this.transportType = transportType;
|
|
1427
1427
|
__privateAdd(this, _RequestRouter_instances);
|
|
1428
1428
|
}
|
|
1429
1429
|
/**
|
|
@@ -1493,16 +1493,14 @@ var RequestRouter = class {
|
|
|
1493
1493
|
*/
|
|
1494
1494
|
handleWithRpcNode(options) {
|
|
1495
1495
|
return __async(this, null, function* () {
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
return this.handleWithWallet(options);
|
|
1502
|
-
}
|
|
1503
|
-
throw error;
|
|
1496
|
+
try {
|
|
1497
|
+
return yield this.rpcClient.request(options);
|
|
1498
|
+
} catch (error) {
|
|
1499
|
+
if (error instanceof MissingRpcEndpointErr) {
|
|
1500
|
+
return this.handleWithWallet(options);
|
|
1504
1501
|
}
|
|
1505
|
-
|
|
1502
|
+
throw error;
|
|
1503
|
+
}
|
|
1506
1504
|
});
|
|
1507
1505
|
}
|
|
1508
1506
|
/**
|
|
@@ -1546,7 +1544,8 @@ trackWalletActionRequested_fn = function(options) {
|
|
|
1546
1544
|
const props = yield getWalletActionAnalyticsProperties(
|
|
1547
1545
|
this.config,
|
|
1548
1546
|
this.config.storage,
|
|
1549
|
-
options
|
|
1547
|
+
options,
|
|
1548
|
+
this.transportType
|
|
1550
1549
|
);
|
|
1551
1550
|
analytics.track("mmconnect_wallet_action_requested", props);
|
|
1552
1551
|
});
|
|
@@ -1556,7 +1555,8 @@ trackWalletActionSucceeded_fn = function(options) {
|
|
|
1556
1555
|
const props = yield getWalletActionAnalyticsProperties(
|
|
1557
1556
|
this.config,
|
|
1558
1557
|
this.config.storage,
|
|
1559
|
-
options
|
|
1558
|
+
options,
|
|
1559
|
+
this.transportType
|
|
1560
1560
|
);
|
|
1561
1561
|
analytics.track("mmconnect_wallet_action_succeeded", props);
|
|
1562
1562
|
});
|
|
@@ -1566,7 +1566,8 @@ trackWalletActionFailed_fn = function(options) {
|
|
|
1566
1566
|
const props = yield getWalletActionAnalyticsProperties(
|
|
1567
1567
|
this.config,
|
|
1568
1568
|
this.config.storage,
|
|
1569
|
-
options
|
|
1569
|
+
options,
|
|
1570
|
+
this.transportType
|
|
1570
1571
|
);
|
|
1571
1572
|
analytics.track("mmconnect_wallet_action_failed", props);
|
|
1572
1573
|
});
|
|
@@ -1576,7 +1577,8 @@ trackWalletActionRejected_fn = function(options) {
|
|
|
1576
1577
|
const props = yield getWalletActionAnalyticsProperties(
|
|
1577
1578
|
this.config,
|
|
1578
1579
|
this.config.storage,
|
|
1579
|
-
options
|
|
1580
|
+
options,
|
|
1581
|
+
this.transportType
|
|
1580
1582
|
);
|
|
1581
1583
|
analytics.track("mmconnect_wallet_action_rejected", props);
|
|
1582
1584
|
});
|
|
@@ -1821,7 +1823,9 @@ setupMessageListener_fn = function() {
|
|
|
1821
1823
|
init_fn = function() {
|
|
1822
1824
|
return __async(this, null, function* () {
|
|
1823
1825
|
__privateMethod(this, _DefaultTransport_instances, setupMessageListener_fn).call(this);
|
|
1824
|
-
|
|
1826
|
+
if (!__privateGet(this, _transport).isConnected()) {
|
|
1827
|
+
yield __privateGet(this, _transport).connect();
|
|
1828
|
+
}
|
|
1825
1829
|
});
|
|
1826
1830
|
};
|
|
1827
1831
|
|
|
@@ -2666,7 +2670,7 @@ var SINGLETON_KEY = "__METAMASK_CONNECT_MULTICHAIN_SINGLETON__";
|
|
|
2666
2670
|
var _a2, _provider, _providerTransportWrapper, _transport2, _dappClient, _beforeUnloadListener, _listener, _sdkInfo, _MetaMaskConnectMultichain_instances, setupAnalytics_fn, onTransportNotification_fn, getStoredTransport_fn, setupTransport_fn, init_fn2, createDappClient_fn, setupMWP_fn, onBeforeUnload_fn, createBeforeUnloadListener_fn, renderInstallModalAsync_fn, showInstallModal_fn, headlessConnect_fn, setupDefaultTransport_fn, deeplinkConnect_fn, handleConnection_fn, getCaipSession_fn, openConnectDeeplinkIfNeeded_fn;
|
|
2667
2671
|
var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends MultichainCore {
|
|
2668
2672
|
constructor(options) {
|
|
2669
|
-
var _a3, _b, _c, _d, _e, _f;
|
|
2673
|
+
var _a3, _b, _c, _d, _e, _f, _g;
|
|
2670
2674
|
const withDappMetadata = setupDappMetadata(options);
|
|
2671
2675
|
const integrationType = (_b = (_a3 = options.analytics) == null ? void 0 : _a3.integrationType) != null ? _b : "direct";
|
|
2672
2676
|
const allOptions = __spreadProps(__spreadValues({}, withDappMetadata), {
|
|
@@ -2677,7 +2681,10 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2677
2681
|
}),
|
|
2678
2682
|
analytics: __spreadProps(__spreadValues({}, (_f = options.analytics) != null ? _f : {}), {
|
|
2679
2683
|
integrationType
|
|
2680
|
-
})
|
|
2684
|
+
}),
|
|
2685
|
+
versions: __spreadValues({
|
|
2686
|
+
"connect-multichain": "0.9.0"
|
|
2687
|
+
}, (_g = options.versions) != null ? _g : {})
|
|
2681
2688
|
});
|
|
2682
2689
|
super(allOptions);
|
|
2683
2690
|
__privateAdd(this, _MetaMaskConnectMultichain_instances);
|
|
@@ -2734,23 +2741,28 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2734
2741
|
// Creates a singleton instance of MetaMaskConnectMultichain.
|
|
2735
2742
|
// If the singleton already exists, it merges the incoming options with the
|
|
2736
2743
|
// existing singleton options for the following keys: `api.supportedNetworks`,
|
|
2737
|
-
// `ui.*`, `mobile.*`, `transport.extensionId`, `debug`. Take note
|
|
2738
|
-
// value for `dapp` is not merged as it does not make sense for
|
|
2739
|
-
// `createMultichainClient` to have a different `dapp` value.
|
|
2744
|
+
// `versions`, `ui.*`, `mobile.*`, `transport.extensionId`, `debug`. Take note
|
|
2745
|
+
// that the value for `dapp` is not merged as it does not make sense for
|
|
2746
|
+
// subsequent calls to `createMultichainClient` to have a different `dapp` value.
|
|
2740
2747
|
static create(options) {
|
|
2741
2748
|
return __async(this, null, function* () {
|
|
2749
|
+
var _a3;
|
|
2742
2750
|
const globalObject = getGlobalObject();
|
|
2743
2751
|
const existing = globalObject[SINGLETON_KEY];
|
|
2744
2752
|
if (existing) {
|
|
2745
2753
|
const instance = yield existing;
|
|
2746
2754
|
instance.mergeOptions(options);
|
|
2755
|
+
analytics2.setGlobalProperty(
|
|
2756
|
+
"mmconnect_versions",
|
|
2757
|
+
(_a3 = instance.options.versions) != null ? _a3 : {}
|
|
2758
|
+
);
|
|
2747
2759
|
if (options.debug) {
|
|
2748
2760
|
enableDebug("metamask-sdk:*");
|
|
2749
2761
|
}
|
|
2750
2762
|
return instance;
|
|
2751
2763
|
}
|
|
2752
2764
|
const instancePromise = (() => __async(null, null, function* () {
|
|
2753
|
-
var
|
|
2765
|
+
var _a4;
|
|
2754
2766
|
const instance = new _MetaMaskConnectMultichain(options);
|
|
2755
2767
|
const isEnabled2 = yield isEnabled(
|
|
2756
2768
|
"metamask-sdk:core",
|
|
@@ -2759,7 +2771,7 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2759
2771
|
if (isEnabled2) {
|
|
2760
2772
|
enableDebug("metamask-sdk:core");
|
|
2761
2773
|
}
|
|
2762
|
-
yield __privateMethod(
|
|
2774
|
+
yield __privateMethod(_a4 = instance, _MetaMaskConnectMultichain_instances, init_fn2).call(_a4);
|
|
2763
2775
|
return instance;
|
|
2764
2776
|
}))();
|
|
2765
2777
|
globalObject[SINGLETON_KEY] = instancePromise;
|
|
@@ -2887,7 +2899,12 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2887
2899
|
return __async(this, null, function* () {
|
|
2888
2900
|
const { transport, options } = this;
|
|
2889
2901
|
const rpcClient = new RpcClient(options, __privateGet(this, _sdkInfo));
|
|
2890
|
-
const requestRouter = new RequestRouter(
|
|
2902
|
+
const requestRouter = new RequestRouter(
|
|
2903
|
+
transport,
|
|
2904
|
+
rpcClient,
|
|
2905
|
+
options,
|
|
2906
|
+
this.transportType
|
|
2907
|
+
);
|
|
2891
2908
|
return requestRouter.invokeMethod(request);
|
|
2892
2909
|
});
|
|
2893
2910
|
}
|
|
@@ -2940,20 +2957,22 @@ _sdkInfo = new WeakMap();
|
|
|
2940
2957
|
_MetaMaskConnectMultichain_instances = new WeakSet();
|
|
2941
2958
|
setupAnalytics_fn = function() {
|
|
2942
2959
|
return __async(this, null, function* () {
|
|
2943
|
-
var _a3;
|
|
2960
|
+
var _a3, _b;
|
|
2944
2961
|
const platform = getPlatformType();
|
|
2945
2962
|
const isBrowser = platform === "in-app-browser" /* MetaMaskMobileWebview */ || platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */;
|
|
2946
2963
|
const isReactNative2 = platform === "react-native" /* ReactNative */;
|
|
2947
2964
|
if (!isBrowser && !isReactNative2) {
|
|
2948
2965
|
return;
|
|
2949
2966
|
}
|
|
2950
|
-
const version = getVersion();
|
|
2951
2967
|
const dappId = getDappId(this.options.dapp);
|
|
2952
2968
|
const anonId = yield this.storage.getAnonId();
|
|
2953
2969
|
const { integrationType } = (_a3 = this.options.analytics) != null ? _a3 : {
|
|
2954
2970
|
integrationType: ""
|
|
2955
2971
|
};
|
|
2956
|
-
analytics2.setGlobalProperty(
|
|
2972
|
+
analytics2.setGlobalProperty(
|
|
2973
|
+
"mmconnect_versions",
|
|
2974
|
+
(_b = this.options.versions) != null ? _b : {}
|
|
2975
|
+
);
|
|
2957
2976
|
analytics2.setGlobalProperty("dapp_id", dappId);
|
|
2958
2977
|
analytics2.setGlobalProperty("anon_id", anonId);
|
|
2959
2978
|
analytics2.setGlobalProperty("platform", platform);
|
|
@@ -3044,15 +3063,6 @@ init_fn2 = function() {
|
|
|
3044
3063
|
try {
|
|
3045
3064
|
yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupAnalytics_fn).call(this);
|
|
3046
3065
|
yield __privateMethod(this, _MetaMaskConnectMultichain_instances, setupTransport_fn).call(this);
|
|
3047
|
-
try {
|
|
3048
|
-
const baseProps = yield getBaseAnalyticsProperties(
|
|
3049
|
-
this.options,
|
|
3050
|
-
this.storage
|
|
3051
|
-
);
|
|
3052
|
-
analytics2.track("mmconnect_initialized", baseProps);
|
|
3053
|
-
} catch (error) {
|
|
3054
|
-
logger2("Error tracking initialized event", error);
|
|
3055
|
-
}
|
|
3056
3066
|
} catch (error) {
|
|
3057
3067
|
yield this.storage.removeTransport();
|
|
3058
3068
|
this.status = "pending";
|
|
@@ -3706,7 +3716,6 @@ var BaseModalFactory = class {
|
|
|
3706
3716
|
parentElement,
|
|
3707
3717
|
showInstallModal,
|
|
3708
3718
|
link: qrCodeLink,
|
|
3709
|
-
sdkVersion: getVersion(),
|
|
3710
3719
|
generateQRCode: (request) => __async(this, null, function* () {
|
|
3711
3720
|
var _a4;
|
|
3712
3721
|
const newLink = this.createConnectionDeeplink(request);
|
|
@@ -3732,7 +3741,6 @@ var BaseModalFactory = class {
|
|
|
3732
3741
|
const otpCode = yield createOTPCode();
|
|
3733
3742
|
const modal = new this.options.OTPCodeModal({
|
|
3734
3743
|
parentElement: container,
|
|
3735
|
-
sdkVersion: getVersion(),
|
|
3736
3744
|
otpCode,
|
|
3737
3745
|
onClose: this.onCloseModal.bind(this),
|
|
3738
3746
|
createOTPCode,
|