@metamask/connect-multichain 0.13.0 → 0.14.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 +17 -1
- package/dist/browser/es/connect-multichain.d.mts +46 -2
- package/dist/browser/es/connect-multichain.mjs +144 -19
- 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 +46 -2
- package/dist/browser/iife/connect-multichain.js +144 -19
- 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 +46 -2
- package/dist/browser/umd/connect-multichain.js +144 -19
- 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 +46 -2
- package/dist/node/cjs/connect-multichain.js +145 -19
- 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 +46 -2
- package/dist/node/es/connect-multichain.mjs +144 -19
- 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 +46 -2
- package/dist/react-native/es/connect-multichain.mjs +144 -19
- 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/utils/index.d.ts +2 -1
- package/dist/src/domain/utils/index.d.ts.map +1 -1
- package/dist/src/domain/utils/index.js +1 -1
- package/dist/src/domain/utils/index.js.map +1 -1
- package/dist/src/multichain/index.d.ts.map +1 -1
- package/dist/src/multichain/index.js +2 -2
- 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 +4 -4
- package/dist/src/multichain/rpc/requestRouter.js.map +1 -1
- package/dist/src/multichain/transports/mwp/index.d.ts.map +1 -1
- package/dist/src/multichain/transports/mwp/index.js +17 -5
- package/dist/src/multichain/transports/mwp/index.js.map +1 -1
- package/dist/src/multichain/utils/analytics.d.ts +82 -1
- package/dist/src/multichain/utils/analytics.d.ts.map +1 -1
- package/dist/src/multichain/utils/analytics.js +252 -17
- package/dist/src/multichain/utils/analytics.js.map +1 -1
- package/dist/types/connect-multichain.d.ts +46 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.14.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Attach a `failure_reason` tag to `mmconnect_wallet_action_failed` and `mmconnect_connection_failed` events via a new `classifyFailureReason` helper, distinguishing transport timeouts, transport disconnects, EIP-1193 wallet errors (`4100 wallet_unauthorized`, `4200 wallet_method_unsupported`, `4902 unrecognized_chain`), and JSON-RPC wallet errors (`-32601`, `-32602`, `-32603`, plus the `-32000…-32099` server-error range), with an `unknown` fallback. Schema-side: [`metamask-sdk-analytics-api#31`](https://github.com/consensys-vertical-apps/metamask-sdk-analytics-api/pull/31). ([#290](https://github.com/MetaMask/connect-monorepo/pull/290))
|
|
15
|
+
- Attach `error_code` and `error_message_sample` companion properties to `mmconnect_wallet_action_failed` and `mmconnect_connection_failed`. `error_code` preserves the raw wallet-side JSON-RPC / EIP-1193 code (e.g. `4001`, `-32603`). `error_message_sample` is a sanitised, 200-char-max preview of the original error message, with wallet addresses, long hex blobs, URLs, and large decimal numbers scrubbed. Both fields are optional and only set on the two `*_failed` events. Schema-side: [`metamask-sdk-analytics-api#32`](https://github.com/consensys-vertical-apps/metamask-sdk-analytics-api/pull/32). ([#290](https://github.com/MetaMask/connect-monorepo/pull/290))
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Improves QR code scanning reliability. The QR code MWP flow (desktop web and Node.js) now omits the initial `wallet_createSession` request from the deeplink URI, instead sending it as a separate request after the wallet completes the MWP handshake. This results in a shorter deeplink URI and a less dense QR code. The native deeplink (non-QR MWP) flow used on mobile web and React Native is unchanged. ([#295](https://github.com/MetaMask/connect-monorepo/pull/295))
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Tightened `isRejectionError` so `mmconnect_wallet_action_rejected` more accurately reflects user-driven cancellations: it now unwraps `RPCInvokeMethodErr` (so wallet-side codes survive the router's transport-boundary wrapping rather than being masked by the wrapper's `code: 53`), no longer classifies EIP-1193 `4100 Unauthorized` as a rejection (it's a CAIP-25 permission denial, not a user decision), and narrows the bare `"user"` substring match to four explicit phrases — `"user rejected"` / `"user denied"` / `"user cancelled"` / `"user canceled"` — so unrelated messages like Account Abstraction's `"user operation reverted"` no longer count. Net effect: `_rejected` becomes more precise; `_failed` picks up everything `4100` was previously hiding. ([#292](https://github.com/MetaMask/connect-monorepo/pull/292))
|
|
24
|
+
|
|
10
25
|
## [0.13.0]
|
|
11
26
|
|
|
12
27
|
### Uncategorized
|
|
@@ -262,7 +277,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
262
277
|
|
|
263
278
|
- Initial release
|
|
264
279
|
|
|
265
|
-
[Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.
|
|
280
|
+
[Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.14.0...HEAD
|
|
281
|
+
[0.14.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.13.0...@metamask/connect-multichain@0.14.0
|
|
266
282
|
[0.13.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.12.1...@metamask/connect-multichain@0.13.0
|
|
267
283
|
[0.12.1]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.12.0...@metamask/connect-multichain@0.12.1
|
|
268
284
|
[0.12.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.11.1...@metamask/connect-multichain@0.12.0
|
|
@@ -679,13 +679,42 @@ declare abstract class Modal<Options, Data extends DataType = DataType> {
|
|
|
679
679
|
set data(data: Data);
|
|
680
680
|
}
|
|
681
681
|
|
|
682
|
+
/**
|
|
683
|
+
* Tag describing the cause of a failed wallet action / connection. Surfaced
|
|
684
|
+
* as the `failure_reason` property on `mmconnect_wallet_action_failed` and
|
|
685
|
+
* `mmconnect_connection_failed` events so we can distinguish e.g. a transport
|
|
686
|
+
* timeout from a wallet-side internal error in Mixpanel.
|
|
687
|
+
*
|
|
688
|
+
* Intentionally a string union (not a const enum) so callers stay free to
|
|
689
|
+
* pass through a new bucket; the schema-side property is an open string for
|
|
690
|
+
* the same reason.
|
|
691
|
+
*/
|
|
692
|
+
type FailureReason = 'transport_timeout' | 'transport_disconnect' | 'wallet_method_unsupported' | 'wallet_invalid_params' | 'wallet_internal_error' | 'wallet_unauthorized' | 'unrecognized_chain' | 'unknown';
|
|
682
693
|
/**
|
|
683
694
|
* Checks if an error represents a user rejection.
|
|
684
695
|
*
|
|
696
|
+
* Unwraps `RPCInvokeMethodErr` so the wallet's `code: 4001` survives the
|
|
697
|
+
* SDK's transport-boundary wrapping (the outer error otherwise reports
|
|
698
|
+
* `code: 53`, which would never match the heuristics here).
|
|
699
|
+
*
|
|
685
700
|
* @param error - The error object to check
|
|
686
701
|
* @returns True if the error indicates a user rejection, false otherwise
|
|
687
702
|
*/
|
|
688
703
|
declare function isRejectionError(error: unknown): boolean;
|
|
704
|
+
/**
|
|
705
|
+
* Classifies a failed wallet action / connection error into a short tag for
|
|
706
|
+
* the `failure_reason` analytics property. Caller is expected to have already
|
|
707
|
+
* established that the error is *not* a user rejection (use `isRejectionError`
|
|
708
|
+
* for that branching).
|
|
709
|
+
*
|
|
710
|
+
* The taxonomy is deliberately producer-side-only — the schema accepts any
|
|
711
|
+
* string — so we can add buckets here without an API migration. Once the
|
|
712
|
+
* distribution stabilises we may convert the schema field to a closed enum.
|
|
713
|
+
*
|
|
714
|
+
* @param error - The error to classify
|
|
715
|
+
* @returns A short, snake_case tag describing why the operation failed
|
|
716
|
+
*/
|
|
717
|
+
declare function classifyFailureReason(error: unknown): FailureReason;
|
|
689
718
|
/**
|
|
690
719
|
* Gets analytics properties specific to wallet action events.
|
|
691
720
|
*
|
|
@@ -693,15 +722,30 @@ declare function isRejectionError(error: unknown): boolean;
|
|
|
693
722
|
* @param storage - Storage client for getting anonymous ID
|
|
694
723
|
* @param invokeOptions - The invoke method options containing method and scope
|
|
695
724
|
* @param transportType - The transport type to use for the analytics event
|
|
725
|
+
* @param extra - Optional event-specific diagnostic properties. Used by
|
|
726
|
+
* `mmconnect_wallet_action_failed` to attach the {@link ErrorDiagnostics}
|
|
727
|
+
* bundle (`failure_reason`, `error_code`, `error_message_sample`).
|
|
728
|
+
* @param extra.failure_reason - A short tag describing why the operation
|
|
729
|
+
* failed; see `classifyFailureReason` and the `FailureReason` union.
|
|
730
|
+
* @param extra.error_code - The raw wallet-side error code, if present.
|
|
731
|
+
* @param extra.error_message_sample - A sanitised, truncated sample of the
|
|
732
|
+
* original error message.
|
|
696
733
|
* @returns Wallet action analytics properties
|
|
697
734
|
*/
|
|
698
|
-
declare function getWalletActionAnalyticsProperties(options: MultichainOptions, storage: StoreClient, invokeOptions: InvokeMethodOptions, transportType: TransportType
|
|
735
|
+
declare function getWalletActionAnalyticsProperties(options: MultichainOptions, storage: StoreClient, invokeOptions: InvokeMethodOptions, transportType: TransportType, extra?: {
|
|
736
|
+
failure_reason?: FailureReason;
|
|
737
|
+
error_code?: number;
|
|
738
|
+
error_message_sample?: string;
|
|
739
|
+
}): Promise<{
|
|
699
740
|
mmconnect_versions: Record<string, string>;
|
|
700
741
|
dapp_id: string;
|
|
701
742
|
method: string;
|
|
702
743
|
caip_chain_id: string;
|
|
703
744
|
anon_id: string;
|
|
704
745
|
transport_type: TransportType;
|
|
746
|
+
failure_reason?: FailureReason;
|
|
747
|
+
error_code?: number;
|
|
748
|
+
error_message_sample?: string;
|
|
705
749
|
}>;
|
|
706
750
|
|
|
707
751
|
/**
|
|
@@ -713,4 +757,4 @@ declare function getVersion(): string;
|
|
|
713
757
|
|
|
714
758
|
declare const createMultichainClient: CreateMultichainFN;
|
|
715
759
|
|
|
716
|
-
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 };
|
|
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 };
|
|
@@ -679,17 +679,94 @@ var init_ui = __esm({
|
|
|
679
679
|
});
|
|
680
680
|
|
|
681
681
|
// src/multichain/utils/analytics.ts
|
|
682
|
+
function sanitiseErrorMessage(message) {
|
|
683
|
+
if (!message) {
|
|
684
|
+
return void 0;
|
|
685
|
+
}
|
|
686
|
+
let sanitised = message;
|
|
687
|
+
for (const { pattern, replacement } of SANITISE_PATTERNS) {
|
|
688
|
+
sanitised = sanitised.replace(pattern, replacement);
|
|
689
|
+
}
|
|
690
|
+
if (sanitised.length > ERROR_MESSAGE_SAMPLE_MAX_LENGTH) {
|
|
691
|
+
sanitised = `${sanitised.slice(0, ERROR_MESSAGE_SAMPLE_MAX_LENGTH - 1)}\u2026`;
|
|
692
|
+
}
|
|
693
|
+
return sanitised;
|
|
694
|
+
}
|
|
695
|
+
function getUnwrappedErrorDetails(error) {
|
|
696
|
+
var _a3, _b, _c, _d;
|
|
697
|
+
if (typeof error !== "object" || error === null) {
|
|
698
|
+
return { code: void 0, message: "" };
|
|
699
|
+
}
|
|
700
|
+
if (error instanceof RPCInvokeMethodErr) {
|
|
701
|
+
return {
|
|
702
|
+
code: (_a3 = error.rpcCode) != null ? _a3 : error.code,
|
|
703
|
+
message: (_c = (_b = error.rpcMessage) != null ? _b : error.message) != null ? _c : ""
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
const errorObj = error;
|
|
707
|
+
return {
|
|
708
|
+
code: errorObj.code,
|
|
709
|
+
message: (_d = errorObj.message) != null ? _d : ""
|
|
710
|
+
};
|
|
711
|
+
}
|
|
682
712
|
function isRejectionError(error) {
|
|
683
|
-
var _a3, _b;
|
|
684
713
|
if (typeof error !== "object" || error === null) {
|
|
685
714
|
return false;
|
|
686
715
|
}
|
|
716
|
+
const { code, message } = getUnwrappedErrorDetails(error);
|
|
717
|
+
const errorMessage = message.toLowerCase();
|
|
718
|
+
return code === 4001 || errorMessage.includes("reject") || errorMessage.includes("denied") || errorMessage.includes("cancel") || // Narrow "user …" matches — bare "user" is too greedy (catches Account
|
|
719
|
+
// Abstraction errors like "user operation reverted").
|
|
720
|
+
errorMessage.includes("user rejected") || errorMessage.includes("user denied") || errorMessage.includes("user cancelled") || errorMessage.includes("user canceled");
|
|
721
|
+
}
|
|
722
|
+
function classifyFailureReason(error) {
|
|
723
|
+
var _a3, _b;
|
|
724
|
+
if (typeof error !== "object" || error === null) {
|
|
725
|
+
return "unknown";
|
|
726
|
+
}
|
|
687
727
|
const errorObj = error;
|
|
688
|
-
const
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
728
|
+
const errorName = (_a3 = errorObj.name) != null ? _a3 : "";
|
|
729
|
+
const errorMessageRaw = (_b = errorObj.message) != null ? _b : "";
|
|
730
|
+
const errorMessage = errorMessageRaw.toLowerCase();
|
|
731
|
+
const { code } = getUnwrappedErrorDetails(error);
|
|
732
|
+
if (typeof code === "number") {
|
|
733
|
+
if (code === -32601) {
|
|
734
|
+
return "wallet_method_unsupported";
|
|
735
|
+
}
|
|
736
|
+
if (code === -32602) {
|
|
737
|
+
return "wallet_invalid_params";
|
|
738
|
+
}
|
|
739
|
+
if (code === -32603) {
|
|
740
|
+
return "wallet_internal_error";
|
|
741
|
+
}
|
|
742
|
+
if (code <= -32e3 && code >= -32099) {
|
|
743
|
+
return "wallet_internal_error";
|
|
744
|
+
}
|
|
745
|
+
if (code === 4100) {
|
|
746
|
+
return "wallet_unauthorized";
|
|
747
|
+
}
|
|
748
|
+
if (code === 4200) {
|
|
749
|
+
return "wallet_method_unsupported";
|
|
750
|
+
}
|
|
751
|
+
if (code === 4902) {
|
|
752
|
+
return "unrecognized_chain";
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (errorName === "TransportTimeoutError" || errorMessageRaw === "Request timeout" || errorMessage.includes("timed out") || errorMessage.includes("timeout")) {
|
|
756
|
+
return "transport_timeout";
|
|
757
|
+
}
|
|
758
|
+
if (errorName === "TransportError" || errorMessage.includes("not connected") || errorMessage.includes("transport disconnect") || errorMessage.includes("connection lost") || errorMessage.includes("socket closed")) {
|
|
759
|
+
return "transport_disconnect";
|
|
760
|
+
}
|
|
761
|
+
return "unknown";
|
|
762
|
+
}
|
|
763
|
+
function extractErrorDiagnostics(error) {
|
|
764
|
+
const failureReason = classifyFailureReason(error);
|
|
765
|
+
const { code, message } = getUnwrappedErrorDetails(error);
|
|
766
|
+
const messageSample = sanitiseErrorMessage(message);
|
|
767
|
+
return __spreadValues(__spreadValues({
|
|
768
|
+
failure_reason: failureReason
|
|
769
|
+
}, typeof code === "number" ? { error_code: code } : {}), messageSample ? { error_message_sample: messageSample } : {});
|
|
693
770
|
}
|
|
694
771
|
function getBaseAnalyticsProperties(options, storage) {
|
|
695
772
|
return __async(this, null, function* () {
|
|
@@ -705,26 +782,61 @@ function getBaseAnalyticsProperties(options, storage) {
|
|
|
705
782
|
};
|
|
706
783
|
});
|
|
707
784
|
}
|
|
708
|
-
function getWalletActionAnalyticsProperties(options, storage, invokeOptions, transportType) {
|
|
785
|
+
function getWalletActionAnalyticsProperties(options, storage, invokeOptions, transportType, extra) {
|
|
709
786
|
return __async(this, null, function* () {
|
|
710
787
|
var _a3;
|
|
711
788
|
const dappId = getDappId(options.dapp);
|
|
712
789
|
const anonId = yield storage.getAnonId();
|
|
713
|
-
return {
|
|
790
|
+
return __spreadValues(__spreadValues(__spreadValues({
|
|
714
791
|
mmconnect_versions: (_a3 = options.versions) != null ? _a3 : {},
|
|
715
792
|
dapp_id: dappId,
|
|
716
793
|
method: invokeOptions.request.method,
|
|
717
794
|
caip_chain_id: invokeOptions.scope,
|
|
718
795
|
anon_id: anonId,
|
|
719
796
|
transport_type: transportType
|
|
720
|
-
};
|
|
797
|
+
}, (extra == null ? void 0 : extra.failure_reason) ? { failure_reason: extra.failure_reason } : {}), typeof (extra == null ? void 0 : extra.error_code) === "number" ? { error_code: extra.error_code } : {}), (extra == null ? void 0 : extra.error_message_sample) ? { error_message_sample: extra.error_message_sample } : {});
|
|
721
798
|
});
|
|
722
799
|
}
|
|
800
|
+
var ERROR_MESSAGE_SAMPLE_MAX_LENGTH, SANITISE_PATTERNS;
|
|
723
801
|
var init_analytics = __esm({
|
|
724
802
|
"src/multichain/utils/analytics.ts"() {
|
|
725
803
|
"use strict";
|
|
726
804
|
init_utils2();
|
|
727
805
|
init_domain();
|
|
806
|
+
ERROR_MESSAGE_SAMPLE_MAX_LENGTH = 200;
|
|
807
|
+
SANITISE_PATTERNS = [
|
|
808
|
+
// EVM-style 20-byte hex addresses (e.g. `0x` + 40 hex chars).
|
|
809
|
+
{ pattern: /0x[a-fA-F0-9]{40}/gu, replacement: "<addr>" },
|
|
810
|
+
// Other long hex blobs: tx hashes, signatures, raw byte strings, large
|
|
811
|
+
// hex amounts. 16+ hex chars catches 32-byte hashes/signatures without
|
|
812
|
+
// snagging EVM method selectors (8 chars) or short hex codes.
|
|
813
|
+
{ pattern: /(?:0x)?[a-fA-F0-9]{16,}/gu, replacement: "<hex>" },
|
|
814
|
+
// URLs of any scheme up to the first whitespace / quote / closing paren.
|
|
815
|
+
// Catches RPC endpoints, dapp deeplinks, query strings with secrets.
|
|
816
|
+
{ pattern: /https?:\/\/[^\s"')]+/gu, replacement: "<url>" },
|
|
817
|
+
// Bech32 addresses: short HRP (1-10 lowercase chars) + `1` separator +
|
|
818
|
+
// ≥38 chars of Bech32 data alphabet `[ac-hj-np-z02-9]` (excludes the
|
|
819
|
+
// look-alike chars `b`, `i`, `o`, `1`). Covers Bitcoin SegWit
|
|
820
|
+
// (`bc1…`/`tb1…`) and Cosmos-SDK chains (`cosmos1…`, `osmo1…`,
|
|
821
|
+
// `juno1…`, `inj1…`, etc.) without enumerating every HRP. Runs before
|
|
822
|
+
// the Base58 pattern below — see header comment for why.
|
|
823
|
+
{
|
|
824
|
+
pattern: /\b[a-z]{1,10}1[ac-hj-np-z02-9]{38,}\b/gu,
|
|
825
|
+
replacement: "<addr>"
|
|
826
|
+
},
|
|
827
|
+
// Base58 tokens (32+ chars, Base58 alphabet `[1-9A-HJ-NP-Za-km-z]`).
|
|
828
|
+
// Covers Solana pubkeys (32-44 chars), Solana tx signatures (~88 chars),
|
|
829
|
+
// and Bitcoin Base58 addresses ≥32 chars. The 32-char floor and `\b`
|
|
830
|
+
// word boundary keep English words and shorter alphanumerics safe.
|
|
831
|
+
{
|
|
832
|
+
pattern: /\b[1-9A-HJ-NP-Za-km-z]{32,}\b/gu,
|
|
833
|
+
replacement: "<addr>"
|
|
834
|
+
},
|
|
835
|
+
// Long decimal numbers — token amounts, gas units, timestamps, lamports.
|
|
836
|
+
// 10+ digits catches typical chain quantities without affecting JSON-RPC
|
|
837
|
+
// codes (-32601, 4001, etc.) or short numeric IDs.
|
|
838
|
+
{ pattern: /\d{10,}/gu, replacement: "<num>" }
|
|
839
|
+
];
|
|
728
840
|
}
|
|
729
841
|
});
|
|
730
842
|
|
|
@@ -1386,13 +1498,24 @@ var init_mwp = __esm({
|
|
|
1386
1498
|
return resolveConnection();
|
|
1387
1499
|
});
|
|
1388
1500
|
this.dappClient.on("message", initialConnectionMessageHandler);
|
|
1501
|
+
const platformType = getPlatformType();
|
|
1502
|
+
const isQRCodeFlow = [
|
|
1503
|
+
"web-desktop" /* DesktopWeb */,
|
|
1504
|
+
"nodejs" /* NonBrowser */
|
|
1505
|
+
].includes(platformType);
|
|
1506
|
+
const initialPayload = {
|
|
1507
|
+
name: MULTICHAIN_PROVIDER_STREAM_NAME,
|
|
1508
|
+
data: request
|
|
1509
|
+
};
|
|
1389
1510
|
dappClient.connect({
|
|
1390
1511
|
mode: "trusted",
|
|
1391
|
-
initialPayload:
|
|
1392
|
-
|
|
1393
|
-
|
|
1512
|
+
initialPayload: isQRCodeFlow ? void 0 : initialPayload
|
|
1513
|
+
}).then(() => __async(this, null, function* () {
|
|
1514
|
+
if (isQRCodeFlow) {
|
|
1515
|
+
return dappClient.sendRequest(initialPayload);
|
|
1394
1516
|
}
|
|
1395
|
-
|
|
1517
|
+
return void 0;
|
|
1518
|
+
})).catch((error) => {
|
|
1396
1519
|
if (initialConnectionMessageHandler) {
|
|
1397
1520
|
this.dappClient.off(
|
|
1398
1521
|
"message",
|
|
@@ -2290,7 +2413,7 @@ withAnalyticsTracking_fn = function(options, execute) {
|
|
|
2290
2413
|
if (isRejection) {
|
|
2291
2414
|
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRejected_fn).call(this, options);
|
|
2292
2415
|
} else {
|
|
2293
|
-
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options);
|
|
2416
|
+
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options, error);
|
|
2294
2417
|
}
|
|
2295
2418
|
if (error instanceof RPCInvokeMethodErr) {
|
|
2296
2419
|
throw error;
|
|
@@ -2325,13 +2448,14 @@ trackWalletActionSucceeded_fn = function(options) {
|
|
|
2325
2448
|
analytics.track("mmconnect_wallet_action_succeeded", props);
|
|
2326
2449
|
});
|
|
2327
2450
|
};
|
|
2328
|
-
trackWalletActionFailed_fn = function(options) {
|
|
2451
|
+
trackWalletActionFailed_fn = function(options, error) {
|
|
2329
2452
|
return __async(this, null, function* () {
|
|
2330
2453
|
const props = yield getWalletActionAnalyticsProperties(
|
|
2331
2454
|
this.config,
|
|
2332
2455
|
this.config.storage,
|
|
2333
2456
|
options,
|
|
2334
|
-
this.transportType
|
|
2457
|
+
this.transportType,
|
|
2458
|
+
extractErrorDiagnostics(error)
|
|
2335
2459
|
);
|
|
2336
2460
|
analytics.track("mmconnect_wallet_action_failed", props);
|
|
2337
2461
|
});
|
|
@@ -2777,7 +2901,7 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2777
2901
|
versions: __spreadValues({
|
|
2778
2902
|
// typeof guard needed: Metro (React Native) bundles TS source directly,
|
|
2779
2903
|
// bypassing the tsup build that substitutes __PACKAGE_VERSION__.
|
|
2780
|
-
"connect-multichain": false ? "unknown" : "0.
|
|
2904
|
+
"connect-multichain": false ? "unknown" : "0.14.0"
|
|
2781
2905
|
}, (_f = options.versions) != null ? _f : {})
|
|
2782
2906
|
});
|
|
2783
2907
|
super(allOptions);
|
|
@@ -3479,9 +3603,9 @@ handleConnection_fn = function(promise, scopes, transportType) {
|
|
|
3479
3603
|
transport_type: transportType
|
|
3480
3604
|
}));
|
|
3481
3605
|
} else {
|
|
3482
|
-
analytics2.track("mmconnect_connection_failed", __spreadProps(__spreadValues({}, baseProps), {
|
|
3606
|
+
analytics2.track("mmconnect_connection_failed", __spreadValues(__spreadProps(__spreadValues({}, baseProps), {
|
|
3483
3607
|
transport_type: transportType
|
|
3484
|
-
}));
|
|
3608
|
+
}), extractErrorDiagnostics(error)));
|
|
3485
3609
|
}
|
|
3486
3610
|
} catch (e) {
|
|
3487
3611
|
logger2("Error tracking connection failed/rejected event", error);
|
|
@@ -3926,6 +4050,7 @@ export {
|
|
|
3926
4050
|
StoreAdapter,
|
|
3927
4051
|
StoreClient,
|
|
3928
4052
|
TransportType,
|
|
4053
|
+
classifyFailureReason,
|
|
3929
4054
|
createLogger,
|
|
3930
4055
|
createMultichainClient,
|
|
3931
4056
|
enableDebug,
|