@metamask/connect-multichain 0.14.0 → 0.15.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 +8 -1
- package/README.md +20 -19
- package/dist/browser/es/connect-multichain.d.mts +17 -5
- package/dist/browser/es/connect-multichain.mjs +145 -108
- 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 +17 -5
- package/dist/browser/iife/connect-multichain.js +163 -108
- 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 +17 -5
- package/dist/browser/umd/connect-multichain.js +145 -108
- 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 +17 -5
- package/dist/node/cjs/connect-multichain.js +145 -108
- 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 +17 -5
- package/dist/node/es/connect-multichain.mjs +145 -108
- 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 +17 -5
- package/dist/react-native/es/connect-multichain.mjs +145 -108
- 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 +7 -3
- package/dist/src/domain/multichain/index.js.map +1 -1
- package/dist/src/domain/multichain/types.d.ts +15 -3
- 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 +108 -62
- package/dist/src/multichain/index.js.map +1 -1
- package/dist/src/multichain/rpc/requestRouter.d.ts.map +1 -1
- package/dist/src/multichain/rpc/requestRouter.js +23 -5
- package/dist/src/multichain/rpc/requestRouter.js.map +1 -1
- package/dist/types/connect-multichain.d.ts +17 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.15.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add an `analytics.enabled` option to `createMultichainClient()`. Set it to `false` to disable dapp-side analytics events and omit `analytics.remote_session_id` connection metadata. ([#303](https://github.com/MetaMask/connect-monorepo/pull/303))
|
|
15
|
+
|
|
10
16
|
## [0.14.0]
|
|
11
17
|
|
|
12
18
|
### Added
|
|
@@ -277,7 +283,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
277
283
|
|
|
278
284
|
- Initial release
|
|
279
285
|
|
|
280
|
-
[Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.
|
|
286
|
+
[Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.15.0...HEAD
|
|
287
|
+
[0.15.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.14.0...@metamask/connect-multichain@0.15.0
|
|
281
288
|
[0.14.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.13.0...@metamask/connect-multichain@0.14.0
|
|
282
289
|
[0.13.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.12.1...@metamask/connect-multichain@0.13.0
|
|
283
290
|
[0.12.1]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.12.0...@metamask/connect-multichain@0.12.1
|
package/README.md
CHANGED
|
@@ -138,25 +138,26 @@ Factory function to create a new Multichain SDK instance.
|
|
|
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.
|
|
156
|
-
| `
|
|
157
|
-
| `transport.
|
|
158
|
-
| `
|
|
159
|
-
| `
|
|
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.enabled` | `boolean` | No | Enables dapp-side analytics. Defaults to `true`; set to `false` to disable analytics events and wallet correlation metadata. |
|
|
156
|
+
| `analytics.integrationType` | `string` | No | Integration type for analytics |
|
|
157
|
+
| `transport.extensionId` | `string` | No | Custom extension ID |
|
|
158
|
+
| `transport.onNotification` | `(notification: unknown) => void` | No | Notification handler |
|
|
159
|
+
| `versions` | `Partial<ConnectVersions>` | No | Internal: set automatically by `createEVMClient` / `createSolanaClient`. Consumers do not need to provide this. |
|
|
160
|
+
| `debug` | `boolean` | No | Enable debug logging |
|
|
160
161
|
|
|
161
162
|
#### Returns
|
|
162
163
|
|
|
@@ -406,6 +406,19 @@ type ConnectionRequest = {
|
|
|
406
406
|
type ConnectVersions = {
|
|
407
407
|
'connect-multichain': string;
|
|
408
408
|
} & Partial<Record<'connect-evm' | 'connect-solana', string>>;
|
|
409
|
+
type AnalyticsOptions = {
|
|
410
|
+
/**
|
|
411
|
+
* Whether to enable analytics tracking. Defaults to `true` when omitted.
|
|
412
|
+
* Set to `false` to disable all analytics event collection.
|
|
413
|
+
*/
|
|
414
|
+
enabled?: boolean;
|
|
415
|
+
/**
|
|
416
|
+
* Identifies the integration surface that instantiated the SDK (e.g. `'direct'`,
|
|
417
|
+
* `'wagmi'`). Recorded as the `integration_types` global analytics property.
|
|
418
|
+
* Defaults to `'direct'` when omitted or empty.
|
|
419
|
+
*/
|
|
420
|
+
integrationType?: string;
|
|
421
|
+
};
|
|
409
422
|
/**
|
|
410
423
|
* Constructor options for creating a Multichain SDK instance.
|
|
411
424
|
*
|
|
@@ -422,9 +435,7 @@ type MultichainOptions = {
|
|
|
422
435
|
supportedNetworks: RpcUrlsMap;
|
|
423
436
|
};
|
|
424
437
|
/** Analytics configuration */
|
|
425
|
-
analytics?:
|
|
426
|
-
integrationType: string;
|
|
427
|
-
};
|
|
438
|
+
analytics?: AnalyticsOptions;
|
|
428
439
|
/** Storage client for persisting SDK data */
|
|
429
440
|
storage: StoreClient;
|
|
430
441
|
/** UI configuration options */
|
|
@@ -464,6 +475,7 @@ type MultiChainFNOptions = Omit<MultichainOptions, 'storage' | 'ui'> & {
|
|
|
464
475
|
* with an existing singleton.
|
|
465
476
|
*/
|
|
466
477
|
type MergeableMultichainOptions = Omit<MultichainOptions, 'dapp' | 'analytics' | 'storage' | 'api' | 'ui' | 'transport' | 'versions'> & {
|
|
478
|
+
analytics?: AnalyticsOptions;
|
|
467
479
|
api?: MultichainOptions['api'];
|
|
468
480
|
ui?: Pick<MultichainOptions['ui'], 'headless' | 'preferExtension' | 'showInstallModal'>;
|
|
469
481
|
transport?: Pick<NonNullable<MultichainOptions['transport']>, 'extensionId'>;
|
|
@@ -553,7 +565,7 @@ declare abstract class MultichainCore extends EventEmitter<SDKEvents> {
|
|
|
553
565
|
constructor(options: MultichainOptions);
|
|
554
566
|
/**
|
|
555
567
|
* Merges the given options into the current instance options.
|
|
556
|
-
* Only the mergeable keys are updated (api.supportedNetworks, versions, ui.*, mobile.*, transport.extensionId, debug).
|
|
568
|
+
* Only the mergeable keys are updated (api.supportedNetworks, analytics, versions, ui.*, mobile.*, transport.extensionId, debug).
|
|
557
569
|
* The main thing to note is that the value for `dapp` is not merged as it does not make sense for
|
|
558
570
|
* subsequent calls to `createMultichainClient` to have a different `dapp` value.
|
|
559
571
|
* Used when createMultichainClient is called with an existing singleton.
|
|
@@ -757,4 +769,4 @@ declare function getVersion(): string;
|
|
|
757
769
|
|
|
758
770
|
declare const createMultichainClient: CreateMultichainFN;
|
|
759
771
|
|
|
760
|
-
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 FailureReason, 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, classifyFailureReason, createLogger, createMultichainClient, enableDebug, getInfuraRpcUrls, getPlatformType, getTransportType, getVersion, getWalletActionAnalyticsProperties, hasExtension, infuraRpcUrls, isEnabled, isMetamaskExtensionInstalled, isRejectionError, isSecure };
|
|
772
|
+
export { type AnalyticsOptions, 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 FailureReason, 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, classifyFailureReason, createLogger, createMultichainClient, enableDebug, getInfuraRpcUrls, getPlatformType, getTransportType, getVersion, getWalletActionAnalyticsProperties, hasExtension, infuraRpcUrls, isEnabled, isMetamaskExtensionInstalled, isRejectionError, isSecure };
|
|
@@ -472,7 +472,7 @@ var init_multichain = __esm({
|
|
|
472
472
|
}
|
|
473
473
|
/**
|
|
474
474
|
* Merges the given options into the current instance options.
|
|
475
|
-
* Only the mergeable keys are updated (api.supportedNetworks, versions, ui.*, mobile.*, transport.extensionId, debug).
|
|
475
|
+
* Only the mergeable keys are updated (api.supportedNetworks, analytics, versions, ui.*, mobile.*, transport.extensionId, debug).
|
|
476
476
|
* The main thing to note is that the value for `dapp` is not merged as it does not make sense for
|
|
477
477
|
* subsequent calls to `createMultichainClient` to have a different `dapp` value.
|
|
478
478
|
* Used when createMultichainClient is called with an existing singleton.
|
|
@@ -480,23 +480,28 @@ var init_multichain = __esm({
|
|
|
480
480
|
* @param partial - Options to merge/overwrite onto the current instance
|
|
481
481
|
*/
|
|
482
482
|
mergeOptions(partial) {
|
|
483
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
483
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
484
484
|
const opts = this.options;
|
|
485
|
+
const analytics3 = __spreadValues(__spreadValues({}, opts.analytics), (_a3 = partial.analytics) != null ? _a3 : {});
|
|
486
|
+
if (((_b = opts.analytics) == null ? void 0 : _b.enabled) === false) {
|
|
487
|
+
analytics3.enabled = false;
|
|
488
|
+
}
|
|
485
489
|
this.options = __spreadProps(__spreadValues({}, opts), {
|
|
486
490
|
api: __spreadProps(__spreadValues({}, opts.api), {
|
|
487
|
-
supportedNetworks: __spreadValues(__spreadValues({}, opts.api.supportedNetworks), (
|
|
491
|
+
supportedNetworks: __spreadValues(__spreadValues({}, opts.api.supportedNetworks), (_d = (_c = partial.api) == null ? void 0 : _c.supportedNetworks) != null ? _d : {})
|
|
488
492
|
}),
|
|
489
|
-
versions: __spreadValues(__spreadValues({}, opts.versions), (
|
|
493
|
+
versions: __spreadValues(__spreadValues({}, opts.versions), (_e = partial.versions) != null ? _e : {}),
|
|
494
|
+
analytics: __spreadValues({}, analytics3),
|
|
490
495
|
ui: __spreadProps(__spreadValues({}, opts.ui), {
|
|
491
|
-
headless: (
|
|
492
|
-
preferExtension: (
|
|
493
|
-
showInstallModal: (
|
|
496
|
+
headless: (_g = (_f = partial.ui) == null ? void 0 : _f.headless) != null ? _g : opts.ui.headless,
|
|
497
|
+
preferExtension: (_i = (_h = partial.ui) == null ? void 0 : _h.preferExtension) != null ? _i : opts.ui.preferExtension,
|
|
498
|
+
showInstallModal: (_k = (_j = partial.ui) == null ? void 0 : _j.showInstallModal) != null ? _k : opts.ui.showInstallModal
|
|
494
499
|
}),
|
|
495
|
-
mobile: __spreadValues(__spreadValues({}, opts.mobile), (
|
|
496
|
-
transport: __spreadProps(__spreadValues({}, (
|
|
497
|
-
extensionId: (
|
|
500
|
+
mobile: __spreadValues(__spreadValues({}, opts.mobile), (_l = partial.mobile) != null ? _l : {}),
|
|
501
|
+
transport: __spreadProps(__spreadValues({}, (_m = opts.transport) != null ? _m : {}), {
|
|
502
|
+
extensionId: (_p = (_n = partial.transport) == null ? void 0 : _n.extensionId) != null ? _p : (_o = opts.transport) == null ? void 0 : _o.extensionId
|
|
498
503
|
}),
|
|
499
|
-
debug: (
|
|
504
|
+
debug: (_q = partial.debug) != null ? _q : opts.debug
|
|
500
505
|
});
|
|
501
506
|
}
|
|
502
507
|
};
|
|
@@ -2297,6 +2302,17 @@ import { analytics } from "@metamask/analytics";
|
|
|
2297
2302
|
init_domain();
|
|
2298
2303
|
init_utils2();
|
|
2299
2304
|
init_analytics();
|
|
2305
|
+
function toRPCInvokeMethodErr(error) {
|
|
2306
|
+
var _a3;
|
|
2307
|
+
if (error instanceof RPCInvokeMethodErr) {
|
|
2308
|
+
return error;
|
|
2309
|
+
}
|
|
2310
|
+
const castError = error;
|
|
2311
|
+
return new RPCInvokeMethodErr(
|
|
2312
|
+
(_a3 = castError.message) != null ? _a3 : "Unknown error",
|
|
2313
|
+
castError.code
|
|
2314
|
+
);
|
|
2315
|
+
}
|
|
2300
2316
|
var _RequestRouter_instances, withAnalyticsTracking_fn, trackWalletActionRequested_fn, trackWalletActionSucceeded_fn, trackWalletActionFailed_fn, trackWalletActionRejected_fn;
|
|
2301
2317
|
var RequestRouter = class {
|
|
2302
2318
|
constructor(transport, rpcClient, config, transportType) {
|
|
@@ -2403,6 +2419,13 @@ _RequestRouter_instances = new WeakSet();
|
|
|
2403
2419
|
withAnalyticsTracking_fn = function(options, execute) {
|
|
2404
2420
|
return __async(this, null, function* () {
|
|
2405
2421
|
var _a3;
|
|
2422
|
+
if (((_a3 = this.config.analytics) == null ? void 0 : _a3.enabled) === false) {
|
|
2423
|
+
try {
|
|
2424
|
+
return yield execute();
|
|
2425
|
+
} catch (error) {
|
|
2426
|
+
throw toRPCInvokeMethodErr(error);
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2406
2429
|
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRequested_fn).call(this, options);
|
|
2407
2430
|
try {
|
|
2408
2431
|
const result = yield execute();
|
|
@@ -2415,14 +2438,7 @@ withAnalyticsTracking_fn = function(options, execute) {
|
|
|
2415
2438
|
} else {
|
|
2416
2439
|
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options, error);
|
|
2417
2440
|
}
|
|
2418
|
-
|
|
2419
|
-
throw error;
|
|
2420
|
-
}
|
|
2421
|
-
const castError = error;
|
|
2422
|
-
throw new RPCInvokeMethodErr(
|
|
2423
|
-
(_a3 = castError.message) != null ? _a3 : "Unknown error",
|
|
2424
|
-
castError.code
|
|
2425
|
-
);
|
|
2441
|
+
throw toRPCInvokeMethodErr(error);
|
|
2426
2442
|
}
|
|
2427
2443
|
});
|
|
2428
2444
|
};
|
|
@@ -2883,26 +2899,65 @@ walletInvokeMethod_fn = function(request) {
|
|
|
2883
2899
|
init_utils2();
|
|
2884
2900
|
var logger2 = createLogger("metamask-sdk:core");
|
|
2885
2901
|
var SINGLETON_KEY = "__METAMASK_CONNECT_MULTICHAIN_SINGLETON__";
|
|
2902
|
+
function normalizeAnalyticsOptions(analyticsOptions) {
|
|
2903
|
+
var _a3;
|
|
2904
|
+
return __spreadProps(__spreadValues({}, analyticsOptions != null ? analyticsOptions : {}), {
|
|
2905
|
+
enabled: (_a3 = analyticsOptions == null ? void 0 : analyticsOptions.enabled) != null ? _a3 : true,
|
|
2906
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
2907
|
+
integrationType: (analyticsOptions == null ? void 0 : analyticsOptions.integrationType) || "direct"
|
|
2908
|
+
});
|
|
2909
|
+
}
|
|
2910
|
+
function isAnalyticsEnabled(options) {
|
|
2911
|
+
var _a3;
|
|
2912
|
+
return ((_a3 = options.analytics) == null ? void 0 : _a3.enabled) !== false;
|
|
2913
|
+
}
|
|
2914
|
+
function setupAnalyticsGlobals(options, storage, setAnonId) {
|
|
2915
|
+
return __async(this, null, function* () {
|
|
2916
|
+
var _a3, _b;
|
|
2917
|
+
if (!isAnalyticsEnabled(options)) {
|
|
2918
|
+
setAnonId == null ? void 0 : setAnonId(void 0);
|
|
2919
|
+
analytics2.disable();
|
|
2920
|
+
return;
|
|
2921
|
+
}
|
|
2922
|
+
const platform = getPlatformType();
|
|
2923
|
+
const isBrowser = platform === "in-app-browser" /* MetaMaskMobileWebview */ || platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */;
|
|
2924
|
+
const isReactNative2 = platform === "react-native" /* ReactNative */;
|
|
2925
|
+
if (!isBrowser && !isReactNative2) {
|
|
2926
|
+
return;
|
|
2927
|
+
}
|
|
2928
|
+
const dappId = getDappId(options.dapp);
|
|
2929
|
+
const anonId = yield storage.getAnonId();
|
|
2930
|
+
setAnonId == null ? void 0 : setAnonId(anonId);
|
|
2931
|
+
const { integrationType } = (_a3 = options.analytics) != null ? _a3 : {
|
|
2932
|
+
integrationType: ""
|
|
2933
|
+
};
|
|
2934
|
+
analytics2.setGlobalProperty("mmconnect_versions", (_b = options.versions) != null ? _b : {});
|
|
2935
|
+
analytics2.setGlobalProperty("dapp_id", dappId);
|
|
2936
|
+
analytics2.setGlobalProperty("anon_id", anonId);
|
|
2937
|
+
analytics2.setGlobalProperty("platform", platform);
|
|
2938
|
+
if (integrationType) {
|
|
2939
|
+
analytics2.setGlobalProperty("integration_types", [integrationType]);
|
|
2940
|
+
}
|
|
2941
|
+
analytics2.enable();
|
|
2942
|
+
});
|
|
2943
|
+
}
|
|
2886
2944
|
var _a2, _provider, _providerTransportWrapper, _transport2, _dappClient, _beforeUnloadListener, _transportType, _listener, _anonId, _sdkInfo, _MetaMaskConnectMultichain_instances, setupAnalytics_fn, onTransportNotification_fn, getStoredTransport_fn, setupTransport_fn, buildConnectionMetadata_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;
|
|
2887
2945
|
var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends MultichainCore {
|
|
2888
2946
|
constructor(options) {
|
|
2889
|
-
var _a3, _b, _c, _d
|
|
2947
|
+
var _a3, _b, _c, _d;
|
|
2890
2948
|
const withDappMetadata = setupDappMetadata(options);
|
|
2891
|
-
const integrationType = ((_a3 = options.analytics) == null ? void 0 : _a3.integrationType) || "direct";
|
|
2892
2949
|
const allOptions = __spreadProps(__spreadValues({}, withDappMetadata), {
|
|
2893
2950
|
ui: __spreadProps(__spreadValues({}, withDappMetadata.ui), {
|
|
2894
|
-
preferExtension: (
|
|
2895
|
-
showInstallModal: (
|
|
2896
|
-
headless: (
|
|
2897
|
-
}),
|
|
2898
|
-
analytics: __spreadProps(__spreadValues({}, (_e = options.analytics) != null ? _e : {}), {
|
|
2899
|
-
integrationType
|
|
2951
|
+
preferExtension: (_a3 = withDappMetadata.ui.preferExtension) != null ? _a3 : true,
|
|
2952
|
+
showInstallModal: (_b = withDappMetadata.ui.showInstallModal) != null ? _b : false,
|
|
2953
|
+
headless: (_c = withDappMetadata.ui.headless) != null ? _c : false
|
|
2900
2954
|
}),
|
|
2955
|
+
analytics: normalizeAnalyticsOptions(options.analytics),
|
|
2901
2956
|
versions: __spreadValues({
|
|
2902
2957
|
// typeof guard needed: Metro (React Native) bundles TS source directly,
|
|
2903
2958
|
// bypassing the tsup build that substitutes __PACKAGE_VERSION__.
|
|
2904
|
-
"connect-multichain": false ? "unknown" : "0.
|
|
2905
|
-
}, (
|
|
2959
|
+
"connect-multichain": false ? "unknown" : "0.15.0"
|
|
2960
|
+
}, (_d = options.versions) != null ? _d : {})
|
|
2906
2961
|
});
|
|
2907
2962
|
super(allOptions);
|
|
2908
2963
|
__privateAdd(this, _MetaMaskConnectMultichain_instances);
|
|
@@ -2958,25 +3013,22 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2958
3013
|
// Creates a singleton instance of MetaMaskConnectMultichain.
|
|
2959
3014
|
// If the singleton already exists, it merges the incoming options with the
|
|
2960
3015
|
// existing singleton options for the following keys: `api.supportedNetworks`,
|
|
2961
|
-
// `versions`, `ui.*`, `mobile.*`, `transport.extensionId`,
|
|
2962
|
-
// that the value for `dapp` is not merged as it does not
|
|
2963
|
-
// subsequent calls to `createMultichainClient` to have a
|
|
3016
|
+
// `analytics`, `versions`, `ui.*`, `mobile.*`, `transport.extensionId`,
|
|
3017
|
+
// `debug`. Take note that the value for `dapp` is not merged as it does not
|
|
3018
|
+
// make sense for subsequent calls to `createMultichainClient` to have a
|
|
3019
|
+
// different `dapp` value.
|
|
2964
3020
|
static create(options) {
|
|
2965
3021
|
return __async(this, null, function* () {
|
|
2966
|
-
var _a3
|
|
3022
|
+
var _a3;
|
|
2967
3023
|
const globalObject = getGlobalObject();
|
|
2968
3024
|
const existing = globalObject[SINGLETON_KEY];
|
|
2969
3025
|
if (existing) {
|
|
2970
3026
|
const instance = yield existing;
|
|
2971
3027
|
instance.mergeOptions(options);
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
if ((_b = options.analytics) == null ? void 0 : _b.integrationType) {
|
|
2977
|
-
analytics2.setGlobalProperty("integration_types", [
|
|
2978
|
-
options.analytics.integrationType
|
|
2979
|
-
]);
|
|
3028
|
+
if (instance instanceof _MetaMaskConnectMultichain) {
|
|
3029
|
+
yield __privateMethod(_a3 = instance, _MetaMaskConnectMultichain_instances, setupAnalytics_fn).call(_a3);
|
|
3030
|
+
} else {
|
|
3031
|
+
yield setupAnalyticsGlobals(instance.options, instance.storage);
|
|
2980
3032
|
}
|
|
2981
3033
|
if (options.debug) {
|
|
2982
3034
|
enableDebug("metamask-sdk:*");
|
|
@@ -3026,21 +3078,23 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
3026
3078
|
} else {
|
|
3027
3079
|
transportType = "mwp" /* MWP */;
|
|
3028
3080
|
}
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3081
|
+
if (isAnalyticsEnabled(this.options)) {
|
|
3082
|
+
try {
|
|
3083
|
+
const baseProps = yield getBaseAnalyticsProperties(
|
|
3084
|
+
this.options,
|
|
3085
|
+
this.storage
|
|
3086
|
+
);
|
|
3087
|
+
const dappConfiguredChains = Object.keys(
|
|
3088
|
+
this.options.api.supportedNetworks
|
|
3089
|
+
);
|
|
3090
|
+
analytics2.track("mmconnect_connection_initiated", __spreadProps(__spreadValues({}, baseProps), {
|
|
3091
|
+
transport_type: transportType,
|
|
3092
|
+
dapp_configured_chains: dappConfiguredChains,
|
|
3093
|
+
dapp_requested_chains: scopes
|
|
3094
|
+
}));
|
|
3095
|
+
} catch (error) {
|
|
3096
|
+
logger2("Error tracking connection_initiated event", error);
|
|
3097
|
+
}
|
|
3044
3098
|
}
|
|
3045
3099
|
const sessionData = yield __privateMethod(this, _MetaMaskConnectMultichain_instances, getCaipSession_fn).call(this);
|
|
3046
3100
|
const { mergedScopes, mergedCaipAccountIds, mergedSessionProperties } = mergeRequestedSessionWithExisting(
|
|
@@ -3183,30 +3237,9 @@ _sdkInfo = new WeakMap();
|
|
|
3183
3237
|
_MetaMaskConnectMultichain_instances = new WeakSet();
|
|
3184
3238
|
setupAnalytics_fn = function() {
|
|
3185
3239
|
return __async(this, null, function* () {
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
const isReactNative2 = platform === "react-native" /* ReactNative */;
|
|
3190
|
-
if (!isBrowser && !isReactNative2) {
|
|
3191
|
-
return;
|
|
3192
|
-
}
|
|
3193
|
-
const dappId = getDappId(this.options.dapp);
|
|
3194
|
-
const anonId = yield this.storage.getAnonId();
|
|
3195
|
-
__privateSet(this, _anonId, anonId);
|
|
3196
|
-
const { integrationType } = (_a3 = this.options.analytics) != null ? _a3 : {
|
|
3197
|
-
integrationType: ""
|
|
3198
|
-
};
|
|
3199
|
-
analytics2.setGlobalProperty(
|
|
3200
|
-
"mmconnect_versions",
|
|
3201
|
-
(_b = this.options.versions) != null ? _b : {}
|
|
3202
|
-
);
|
|
3203
|
-
analytics2.setGlobalProperty("dapp_id", dappId);
|
|
3204
|
-
analytics2.setGlobalProperty("anon_id", anonId);
|
|
3205
|
-
analytics2.setGlobalProperty("platform", platform);
|
|
3206
|
-
if (integrationType) {
|
|
3207
|
-
analytics2.setGlobalProperty("integration_types", [integrationType]);
|
|
3208
|
-
}
|
|
3209
|
-
analytics2.enable();
|
|
3240
|
+
yield setupAnalyticsGlobals(this.options, this.storage, (anonId) => {
|
|
3241
|
+
__privateSet(this, _anonId, anonId);
|
|
3242
|
+
});
|
|
3210
3243
|
});
|
|
3211
3244
|
};
|
|
3212
3245
|
onTransportNotification_fn = function(payload) {
|
|
@@ -3295,7 +3328,7 @@ buildConnectionMetadata_fn = function() {
|
|
|
3295
3328
|
dapp: this.options.dapp,
|
|
3296
3329
|
sdk: { version: getVersion(), platform: getPlatformType() }
|
|
3297
3330
|
};
|
|
3298
|
-
if (__privateGet(this, _anonId)) {
|
|
3331
|
+
if (isAnalyticsEnabled(this.options) && __privateGet(this, _anonId)) {
|
|
3299
3332
|
metadata.analytics = { remote_session_id: __privateGet(this, _anonId) };
|
|
3300
3333
|
}
|
|
3301
3334
|
return metadata;
|
|
@@ -3577,38 +3610,42 @@ handleConnection_fn = function(promise, scopes, transportType) {
|
|
|
3577
3610
|
this.status = "connecting";
|
|
3578
3611
|
return promise.then(() => __async(this, null, function* () {
|
|
3579
3612
|
this.status = "connected";
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3613
|
+
if (isAnalyticsEnabled(this.options)) {
|
|
3614
|
+
try {
|
|
3615
|
+
const baseProps = yield getBaseAnalyticsProperties(
|
|
3616
|
+
this.options,
|
|
3617
|
+
this.storage
|
|
3618
|
+
);
|
|
3619
|
+
analytics2.track("mmconnect_connection_established", __spreadProps(__spreadValues({}, baseProps), {
|
|
3620
|
+
transport_type: transportType,
|
|
3621
|
+
user_permissioned_chains: scopes
|
|
3622
|
+
}));
|
|
3623
|
+
} catch (error) {
|
|
3624
|
+
logger2("Error tracking connection_established event", error);
|
|
3625
|
+
}
|
|
3591
3626
|
}
|
|
3592
3627
|
return void 0;
|
|
3593
3628
|
})).catch((error) => __async(this, null, function* () {
|
|
3594
3629
|
this.status = "disconnected";
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3630
|
+
if (isAnalyticsEnabled(this.options)) {
|
|
3631
|
+
try {
|
|
3632
|
+
const baseProps = yield getBaseAnalyticsProperties(
|
|
3633
|
+
this.options,
|
|
3634
|
+
this.storage
|
|
3635
|
+
);
|
|
3636
|
+
const isRejection = isRejectionError(error);
|
|
3637
|
+
if (isRejection) {
|
|
3638
|
+
analytics2.track("mmconnect_connection_rejected", __spreadProps(__spreadValues({}, baseProps), {
|
|
3639
|
+
transport_type: transportType
|
|
3640
|
+
}));
|
|
3641
|
+
} else {
|
|
3642
|
+
analytics2.track("mmconnect_connection_failed", __spreadValues(__spreadProps(__spreadValues({}, baseProps), {
|
|
3643
|
+
transport_type: transportType
|
|
3644
|
+
}), extractErrorDiagnostics(error)));
|
|
3645
|
+
}
|
|
3646
|
+
} catch (e) {
|
|
3647
|
+
logger2("Error tracking connection failed/rejected event", error);
|
|
3609
3648
|
}
|
|
3610
|
-
} catch (e) {
|
|
3611
|
-
logger2("Error tracking connection failed/rejected event", error);
|
|
3612
3649
|
}
|
|
3613
3650
|
throw error;
|
|
3614
3651
|
}));
|