@metamask/connect-multichain 0.9.0 → 0.11.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 +31 -1
- package/README.md +18 -6
- package/dist/browser/es/connect-multichain.d.mts +23 -4
- package/dist/browser/es/connect-multichain.mjs +135 -52
- 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 +23 -4
- package/dist/browser/iife/connect-multichain.js +143 -52
- 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 +23 -4
- package/dist/browser/umd/connect-multichain.js +135 -52
- 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 +23 -4
- package/dist/node/cjs/connect-multichain.js +135 -52
- 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 +23 -4
- package/dist/node/es/connect-multichain.mjs +135 -52
- 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 +23 -4
- package/dist/react-native/es/connect-multichain.mjs +144 -53
- 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/errors/rpc.d.ts +3 -1
- package/dist/src/domain/errors/rpc.d.ts.map +1 -1
- package/dist/src/domain/errors/rpc.js +3 -1
- package/dist/src/domain/errors/rpc.js.map +1 -1
- package/dist/src/domain/events/types/index.d.ts +7 -0
- package/dist/src/domain/events/types/index.d.ts.map +1 -1
- package/dist/src/domain/multichain/api/constants.d.ts.map +1 -1
- package/dist/src/domain/multichain/api/constants.js +82 -19
- package/dist/src/domain/multichain/api/constants.js.map +1 -1
- package/dist/src/domain/multichain/api/infura.d.ts +13 -1
- package/dist/src/domain/multichain/api/infura.d.ts.map +1 -1
- package/dist/src/domain/multichain/api/infura.js +17 -5
- package/dist/src/domain/multichain/api/infura.js.map +1 -1
- package/dist/src/index.native.d.ts.map +1 -1
- package/dist/src/index.native.js +9 -1
- package/dist/src/index.native.js.map +1 -1
- package/dist/src/multichain/index.d.ts.map +1 -1
- package/dist/src/multichain/index.js +20 -11
- 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 -2
- 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 +9 -3
- package/dist/src/multichain/transports/default/index.js.map +1 -1
- package/dist/src/multichain/utils/analytics.d.ts +1 -4
- package/dist/src/multichain/utils/analytics.d.ts.map +1 -1
- package/dist/src/multichain/utils/analytics.js +5 -9
- package/dist/src/multichain/utils/analytics.js.map +1 -1
- package/dist/types/connect-multichain.d.ts +23 -4
- package/package.json +7 -2
|
@@ -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
|
|
|
@@ -37,13 +37,22 @@ declare class RPCReadonlyRequestErr extends BaseErr<'RPC', RPCErrorCodes> {
|
|
|
37
37
|
}
|
|
38
38
|
declare class RPCInvokeMethodErr extends BaseErr<'RPC', RPCErrorCodes> {
|
|
39
39
|
readonly reason: string;
|
|
40
|
+
readonly rpcCode?: number | undefined;
|
|
41
|
+
readonly rpcMessage?: string | undefined;
|
|
40
42
|
static readonly code = 53;
|
|
41
|
-
constructor(reason: string);
|
|
43
|
+
constructor(reason: string, rpcCode?: number | undefined, rpcMessage?: string | undefined);
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
type SDKEvents = {
|
|
45
47
|
display_uri: [evt: string];
|
|
46
48
|
wallet_sessionChanged: [evt: SessionData | undefined];
|
|
49
|
+
metamask_accountsChanged: [evt: string[]];
|
|
50
|
+
metamask_chainChanged: [evt: {
|
|
51
|
+
chainId: string;
|
|
52
|
+
}];
|
|
53
|
+
stateChanged: [
|
|
54
|
+
evt: 'pending' | 'loaded' | 'disconnected' | 'connected' | 'connecting'
|
|
55
|
+
];
|
|
47
56
|
[key: string]: [evt: unknown];
|
|
48
57
|
};
|
|
49
58
|
type EventTypes = SDKEvents;
|
|
@@ -485,7 +494,18 @@ declare const infuraRpcUrls: RpcUrlsMap;
|
|
|
485
494
|
declare const RPC_HANDLED_METHODS: Set<string>;
|
|
486
495
|
declare const SDK_HANDLED_METHODS: Set<string>;
|
|
487
496
|
|
|
488
|
-
|
|
497
|
+
/**
|
|
498
|
+
* Generates Infura RPC URLs for common networks keyed by CAIP Chain ID.
|
|
499
|
+
*
|
|
500
|
+
* @param options - The options for generating Infura RPC URLs
|
|
501
|
+
* @param options.infuraApiKey - The Infura API key
|
|
502
|
+
* @param options.caipChainIds - Optional CAIP-2 chain IDs to filter the output
|
|
503
|
+
* @returns A map of CAIP-2 chain IDs to Infura RPC URLs
|
|
504
|
+
*/
|
|
505
|
+
declare function getInfuraRpcUrls({ infuraApiKey, caipChainIds, }: {
|
|
506
|
+
infuraApiKey: string;
|
|
507
|
+
caipChainIds?: CaipChainId[];
|
|
508
|
+
}): RpcUrlsMap;
|
|
489
509
|
|
|
490
510
|
type ConnectionStatus = 'pending' | 'loaded' | 'disconnected' | 'connected' | 'connecting';
|
|
491
511
|
declare enum TransportType {
|
|
@@ -676,7 +696,6 @@ declare function getWalletActionAnalyticsProperties(options: MultichainOptions,
|
|
|
676
696
|
mmconnect_versions: Record<string, string>;
|
|
677
697
|
dapp_id: string;
|
|
678
698
|
method: string;
|
|
679
|
-
integration_type: string;
|
|
680
699
|
caip_chain_id: string;
|
|
681
700
|
anon_id: string;
|
|
682
701
|
transport_type: TransportType;
|
|
@@ -133,12 +133,14 @@ var init_rpc = __esm({
|
|
|
133
133
|
_RPCReadonlyRequestErr.code = 52;
|
|
134
134
|
RPCReadonlyRequestErr = _RPCReadonlyRequestErr;
|
|
135
135
|
_RPCInvokeMethodErr = class _RPCInvokeMethodErr extends BaseErr {
|
|
136
|
-
constructor(reason) {
|
|
136
|
+
constructor(reason, rpcCode, rpcMessage) {
|
|
137
137
|
super(
|
|
138
138
|
`RPCErr${_RPCInvokeMethodErr.code}: RPC Client invoke method reason (${reason})`,
|
|
139
139
|
_RPCInvokeMethodErr.code
|
|
140
140
|
);
|
|
141
141
|
this.reason = reason;
|
|
142
|
+
this.rpcCode = rpcCode;
|
|
143
|
+
this.rpcMessage = rpcMessage;
|
|
142
144
|
}
|
|
143
145
|
};
|
|
144
146
|
_RPCInvokeMethodErr.code = 53;
|
|
@@ -279,35 +281,98 @@ var init_constants = __esm({
|
|
|
279
281
|
// ###### Ethereum ######
|
|
280
282
|
// Mainnet
|
|
281
283
|
"eip155:1": "https://mainnet.infura.io/v3/",
|
|
282
|
-
// Goerli
|
|
283
|
-
"eip155:5": "https://goerli.infura.io/v3/",
|
|
284
284
|
// Sepolia 11155111
|
|
285
285
|
"eip155:11155111": "https://sepolia.infura.io/v3/",
|
|
286
|
+
// Hoodi
|
|
287
|
+
"eip155:560048": "https://hoodi.infura.io/v3/",
|
|
286
288
|
// ###### Linea ######
|
|
287
289
|
// Mainnet Alpha
|
|
288
290
|
"eip155:59144": "https://linea-mainnet.infura.io/v3/",
|
|
289
|
-
//
|
|
290
|
-
"eip155:
|
|
291
|
+
// Sepolia
|
|
292
|
+
"eip155:59141": "https://linea-sepolia.infura.io/v3/",
|
|
291
293
|
// ###### Polygon ######
|
|
292
294
|
// Mainnet
|
|
293
295
|
"eip155:137": "https://polygon-mainnet.infura.io/v3/",
|
|
294
|
-
//
|
|
295
|
-
"eip155:
|
|
296
|
+
// Amoy
|
|
297
|
+
"eip155:80002": "https://polygon-amoy.infura.io/v3/",
|
|
296
298
|
// ###### Optimism ######
|
|
297
299
|
// Mainnet
|
|
298
300
|
"eip155:10": "https://optimism-mainnet.infura.io/v3/",
|
|
299
|
-
//
|
|
300
|
-
"eip155:
|
|
301
|
+
// Sepolia
|
|
302
|
+
"eip155:11155420": "https://optimism-sepolia.infura.io/v3/",
|
|
301
303
|
// ###### Arbitrum ######
|
|
302
304
|
// Mainnet
|
|
303
305
|
"eip155:42161": "https://arbitrum-mainnet.infura.io/v3/",
|
|
304
|
-
//
|
|
305
|
-
"eip155:
|
|
306
|
+
// Sepolia
|
|
307
|
+
"eip155:421614": "https://arbitrum-sepolia.infura.io/v3/",
|
|
308
|
+
// ###### Base ######
|
|
309
|
+
// Mainnet
|
|
310
|
+
"eip155:8453": "https://base-mainnet.infura.io/v3/",
|
|
311
|
+
// Sepolia
|
|
312
|
+
"eip155:84532": "https://base-sepolia.infura.io/v3/",
|
|
313
|
+
// ###### Blast ######
|
|
314
|
+
// Mainnet
|
|
315
|
+
"eip155:81457": "https://blast-mainnet.infura.io/v3/",
|
|
316
|
+
// Sepolia
|
|
317
|
+
"eip155:168587773": "https://blast-sepolia.infura.io/v3/",
|
|
318
|
+
// ###### zkSync ######
|
|
319
|
+
// Mainnet
|
|
320
|
+
"eip155:324": "https://zksync-mainnet.infura.io/v3/",
|
|
321
|
+
// Sepolia
|
|
322
|
+
"eip155:300": "https://zksync-sepolia.infura.io/v3/",
|
|
323
|
+
// ###### BSC ######
|
|
324
|
+
// Mainnet
|
|
325
|
+
"eip155:56": "https://bsc-mainnet.infura.io/v3/",
|
|
326
|
+
// Testnet
|
|
327
|
+
"eip155:97": "https://bsc-testnet.infura.io/v3/",
|
|
328
|
+
// ###### opBNB ######
|
|
329
|
+
// Mainnet
|
|
330
|
+
"eip155:204": "https://opbnb-mainnet.infura.io/v3/",
|
|
331
|
+
// Testnet
|
|
332
|
+
"eip155:5611": "https://opbnb-testnet.infura.io/v3/",
|
|
333
|
+
// ###### Scroll ######
|
|
334
|
+
// Mainnet
|
|
335
|
+
"eip155:534352": "https://scroll-mainnet.infura.io/v3/",
|
|
336
|
+
// Sepolia
|
|
337
|
+
"eip155:534351": "https://scroll-sepolia.infura.io/v3/",
|
|
338
|
+
// ###### Mantle ######
|
|
339
|
+
// Mainnet
|
|
340
|
+
"eip155:5000": "https://mantle-mainnet.infura.io/v3/",
|
|
341
|
+
// Sepolia
|
|
342
|
+
"eip155:5003": "https://mantle-sepolia.infura.io/v3/",
|
|
343
|
+
// ###### Sei ######
|
|
344
|
+
// Mainnet
|
|
345
|
+
"eip155:1329": "https://sei-mainnet.infura.io/v3/",
|
|
346
|
+
// Testnet
|
|
347
|
+
"eip155:713715": "https://sei-testnet.infura.io/v3/",
|
|
348
|
+
// ###### Swellchain ######
|
|
349
|
+
// Mainnet
|
|
350
|
+
"eip155:1923": "https://swellchain-mainnet.infura.io/v3/",
|
|
351
|
+
// Testnet
|
|
352
|
+
"eip155:1924": "https://swellchain-testnet.infura.io/v3/",
|
|
353
|
+
// ###### Unichain ######
|
|
354
|
+
// Mainnet
|
|
355
|
+
"eip155:130": "https://unichain-mainnet.infura.io/v3/",
|
|
356
|
+
// Sepolia
|
|
357
|
+
"eip155:1301": "https://unichain-sepolia.infura.io/v3/",
|
|
358
|
+
// ###### Hemi ######
|
|
359
|
+
// Mainnet
|
|
360
|
+
"eip155:43111": "https://hemi-mainnet.infura.io/v3/",
|
|
361
|
+
// Testnet
|
|
362
|
+
"eip155:743111": "https://hemi-testnet.infura.io/v3/",
|
|
363
|
+
// ###### MegaETH ######
|
|
364
|
+
// Mainnet
|
|
365
|
+
"eip155:6342": "https://megaeth-mainnet.infura.io/v3/",
|
|
366
|
+
// Testnet
|
|
367
|
+
"eip155:6342001": "https://megaeth-testnet.infura.io/v3/",
|
|
368
|
+
// ###### Monad ######
|
|
369
|
+
// Mainnet
|
|
370
|
+
"eip155:143": "https://monad-mainnet.infura.io/v3/",
|
|
371
|
+
// Testnet
|
|
372
|
+
"eip155:10143": "https://monad-testnet.infura.io/v3/",
|
|
306
373
|
// ###### Palm ######
|
|
307
374
|
// Mainnet
|
|
308
375
|
"eip155:11297108109": "https://palm-mainnet.infura.io/v3/",
|
|
309
|
-
// Testnet
|
|
310
|
-
"eip155:11297108099": "https://palm-testnet.infura.io/v3/",
|
|
311
376
|
// ###### Avalanche C-Chain ######
|
|
312
377
|
// Mainnet
|
|
313
378
|
"eip155:43114": "https://avalanche-mainnet.infura.io/v3/",
|
|
@@ -318,11 +383,6 @@ var init_constants = __esm({
|
|
|
318
383
|
// 'near:mainnet': `https://near-mainnet.infura.io/v3/`,
|
|
319
384
|
// // Testnet
|
|
320
385
|
// 'near:testnet': `https://near-testnet.infura.io/v3/`,
|
|
321
|
-
// ###### Aurora ######
|
|
322
|
-
// Mainnet
|
|
323
|
-
"eip155:1313161554": "https://aurora-mainnet.infura.io/v3/",
|
|
324
|
-
// Testnet
|
|
325
|
-
"eip155:1313161555": "https://aurora-testnet.infura.io/v3/",
|
|
326
386
|
// ###### StarkNet ######
|
|
327
387
|
// Mainnet
|
|
328
388
|
//
|
|
@@ -334,8 +394,13 @@ var init_constants = __esm({
|
|
|
334
394
|
// ###### Celo ######
|
|
335
395
|
// Mainnet
|
|
336
396
|
"eip155:42220": "https://celo-mainnet.infura.io/v3/",
|
|
337
|
-
//
|
|
338
|
-
"eip155:44787": "https://celo-
|
|
397
|
+
// Sepolia
|
|
398
|
+
"eip155:44787": "https://celo-sepolia.infura.io/v3/",
|
|
399
|
+
// ###### Solana ######
|
|
400
|
+
// Mainnet
|
|
401
|
+
"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": "https://solana-mainnet.infura.io/v3/",
|
|
402
|
+
// Devnet
|
|
403
|
+
"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": "https://solana-devnet.infura.io/v3/"
|
|
339
404
|
};
|
|
340
405
|
RPC_HANDLED_METHODS = /* @__PURE__ */ new Set([
|
|
341
406
|
"eth_blockNumber",
|
|
@@ -377,10 +442,16 @@ var init_constants = __esm({
|
|
|
377
442
|
});
|
|
378
443
|
|
|
379
444
|
// src/domain/multichain/api/infura.ts
|
|
380
|
-
function getInfuraRpcUrls(
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
445
|
+
function getInfuraRpcUrls({
|
|
446
|
+
infuraApiKey,
|
|
447
|
+
caipChainIds
|
|
448
|
+
}) {
|
|
449
|
+
const keys = caipChainIds && caipChainIds.length > 0 ? caipChainIds : Object.keys(infuraRpcUrls);
|
|
450
|
+
return keys.reduce((acc, key) => {
|
|
451
|
+
const baseUrl = infuraRpcUrls[key];
|
|
452
|
+
if (baseUrl) {
|
|
453
|
+
acc[key] = `${baseUrl}${infuraApiKey}`;
|
|
454
|
+
}
|
|
384
455
|
return acc;
|
|
385
456
|
}, {});
|
|
386
457
|
}
|
|
@@ -648,31 +719,27 @@ function isRejectionError(error) {
|
|
|
648
719
|
}
|
|
649
720
|
function getBaseAnalyticsProperties(options, storage) {
|
|
650
721
|
return __async(this, null, function* () {
|
|
651
|
-
var _a3
|
|
722
|
+
var _a3;
|
|
652
723
|
const dappId = getDappId(options.dapp);
|
|
653
724
|
const platform = getPlatformType();
|
|
654
725
|
const anonId = yield storage.getAnonId();
|
|
655
|
-
const integrationType = (_b = (_a3 = options.analytics) == null ? void 0 : _a3.integrationType) != null ? _b : "unknown" /* UNKNOWN */;
|
|
656
726
|
return {
|
|
657
|
-
mmconnect_versions: (
|
|
727
|
+
mmconnect_versions: (_a3 = options.versions) != null ? _a3 : {},
|
|
658
728
|
dapp_id: dappId,
|
|
659
729
|
platform,
|
|
660
|
-
integration_type: integrationType,
|
|
661
730
|
anon_id: anonId
|
|
662
731
|
};
|
|
663
732
|
});
|
|
664
733
|
}
|
|
665
734
|
function getWalletActionAnalyticsProperties(options, storage, invokeOptions, transportType) {
|
|
666
735
|
return __async(this, null, function* () {
|
|
667
|
-
var _a3
|
|
736
|
+
var _a3;
|
|
668
737
|
const dappId = getDappId(options.dapp);
|
|
669
738
|
const anonId = yield storage.getAnonId();
|
|
670
|
-
const integrationType = (_b = (_a3 = options.analytics) == null ? void 0 : _a3.integrationType) != null ? _b : "unknown";
|
|
671
739
|
return {
|
|
672
|
-
mmconnect_versions: (
|
|
740
|
+
mmconnect_versions: (_a3 = options.versions) != null ? _a3 : {},
|
|
673
741
|
dapp_id: dappId,
|
|
674
742
|
method: invokeOptions.request.method,
|
|
675
|
-
integration_type: integrationType,
|
|
676
743
|
caip_chain_id: invokeOptions.scope,
|
|
677
744
|
anon_id: anonId,
|
|
678
745
|
transport_type: transportType
|
|
@@ -1523,7 +1590,9 @@ var RequestRouter = class {
|
|
|
1523
1590
|
if (response.error) {
|
|
1524
1591
|
const { error } = response;
|
|
1525
1592
|
throw new RPCInvokeMethodErr(
|
|
1526
|
-
`RPC Request failed with code ${error.code}: ${error.message}
|
|
1593
|
+
`RPC Request failed with code ${error.code}: ${error.message}`,
|
|
1594
|
+
error.code,
|
|
1595
|
+
error.message
|
|
1527
1596
|
);
|
|
1528
1597
|
}
|
|
1529
1598
|
return response.result;
|
|
@@ -1564,6 +1633,7 @@ var RequestRouter = class {
|
|
|
1564
1633
|
_RequestRouter_instances = new WeakSet();
|
|
1565
1634
|
withAnalyticsTracking_fn = function(options, execute) {
|
|
1566
1635
|
return __async(this, null, function* () {
|
|
1636
|
+
var _a3;
|
|
1567
1637
|
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRequested_fn).call(this, options);
|
|
1568
1638
|
try {
|
|
1569
1639
|
const result = yield execute();
|
|
@@ -1579,7 +1649,11 @@ withAnalyticsTracking_fn = function(options, execute) {
|
|
|
1579
1649
|
if (error instanceof RPCInvokeMethodErr) {
|
|
1580
1650
|
throw error;
|
|
1581
1651
|
}
|
|
1582
|
-
|
|
1652
|
+
const castError = error;
|
|
1653
|
+
throw new RPCInvokeMethodErr(
|
|
1654
|
+
(_a3 = castError.message) != null ? _a3 : "Unknown error",
|
|
1655
|
+
castError.code
|
|
1656
|
+
);
|
|
1583
1657
|
}
|
|
1584
1658
|
});
|
|
1585
1659
|
};
|
|
@@ -1834,9 +1908,13 @@ handleResponse_fn = function(event) {
|
|
|
1834
1908
|
__privateGet(this, _pendingRequests).delete(responseId);
|
|
1835
1909
|
const response = responseData;
|
|
1836
1910
|
if ("error" in response && response.error) {
|
|
1837
|
-
|
|
1838
|
-
|
|
1911
|
+
const error = new Error(
|
|
1912
|
+
response.error.message || "Request failed"
|
|
1839
1913
|
);
|
|
1914
|
+
if (typeof response.error.code === "number") {
|
|
1915
|
+
error.code = response.error.code;
|
|
1916
|
+
}
|
|
1917
|
+
pendingRequest.reject(error);
|
|
1840
1918
|
} else {
|
|
1841
1919
|
pendingRequest.resolve(response);
|
|
1842
1920
|
}
|
|
@@ -1849,7 +1927,7 @@ handleNotification_fn = function(event) {
|
|
|
1849
1927
|
return;
|
|
1850
1928
|
}
|
|
1851
1929
|
const responseData = (_b = (_a3 = event == null ? void 0 : event.data) == null ? void 0 : _a3.data) == null ? void 0 : _b.data;
|
|
1852
|
-
if (typeof responseData === "object" && responseData !== null &&
|
|
1930
|
+
if (typeof responseData === "object" && responseData !== null && "method" in responseData) {
|
|
1853
1931
|
__privateMethod(this, _DefaultTransport_instances, notifyCallbacks_fn).call(this, responseData);
|
|
1854
1932
|
}
|
|
1855
1933
|
};
|
|
@@ -2710,21 +2788,23 @@ var SINGLETON_KEY = "__METAMASK_CONNECT_MULTICHAIN_SINGLETON__";
|
|
|
2710
2788
|
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;
|
|
2711
2789
|
var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends MultichainCore {
|
|
2712
2790
|
constructor(options) {
|
|
2713
|
-
var _a3, _b, _c, _d, _e, _f
|
|
2791
|
+
var _a3, _b, _c, _d, _e, _f;
|
|
2714
2792
|
const withDappMetadata = setupDappMetadata(options);
|
|
2715
|
-
const integrationType = (
|
|
2793
|
+
const integrationType = ((_a3 = options.analytics) == null ? void 0 : _a3.integrationType) || "direct";
|
|
2716
2794
|
const allOptions = __spreadProps(__spreadValues({}, withDappMetadata), {
|
|
2717
2795
|
ui: __spreadProps(__spreadValues({}, withDappMetadata.ui), {
|
|
2718
|
-
preferExtension: (
|
|
2719
|
-
showInstallModal: (
|
|
2720
|
-
headless: (
|
|
2796
|
+
preferExtension: (_b = withDappMetadata.ui.preferExtension) != null ? _b : true,
|
|
2797
|
+
showInstallModal: (_c = withDappMetadata.ui.showInstallModal) != null ? _c : false,
|
|
2798
|
+
headless: (_d = withDappMetadata.ui.headless) != null ? _d : false
|
|
2721
2799
|
}),
|
|
2722
|
-
analytics: __spreadProps(__spreadValues({}, (
|
|
2800
|
+
analytics: __spreadProps(__spreadValues({}, (_e = options.analytics) != null ? _e : {}), {
|
|
2723
2801
|
integrationType
|
|
2724
2802
|
}),
|
|
2725
2803
|
versions: __spreadValues({
|
|
2726
|
-
|
|
2727
|
-
|
|
2804
|
+
// typeof guard needed: Metro (React Native) bundles TS source directly,
|
|
2805
|
+
// bypassing the tsup build that substitutes __PACKAGE_VERSION__.
|
|
2806
|
+
"connect-multichain": false ? "unknown" : "0.11.0"
|
|
2807
|
+
}, (_f = options.versions) != null ? _f : {})
|
|
2728
2808
|
});
|
|
2729
2809
|
super(allOptions);
|
|
2730
2810
|
__privateAdd(this, _MetaMaskConnectMultichain_instances);
|
|
@@ -2747,15 +2827,11 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2747
2827
|
return this._status;
|
|
2748
2828
|
}
|
|
2749
2829
|
set status(value) {
|
|
2750
|
-
var _a3, _b;
|
|
2751
2830
|
if (this._status === value) {
|
|
2752
2831
|
return;
|
|
2753
2832
|
}
|
|
2754
2833
|
this._status = value;
|
|
2755
|
-
|
|
2756
|
-
method: "stateChanged",
|
|
2757
|
-
params: value
|
|
2758
|
-
});
|
|
2834
|
+
this.emit("stateChanged", value);
|
|
2759
2835
|
}
|
|
2760
2836
|
get provider() {
|
|
2761
2837
|
return __privateGet(this, _provider);
|
|
@@ -2786,7 +2862,7 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2786
2862
|
// subsequent calls to `createMultichainClient` to have a different `dapp` value.
|
|
2787
2863
|
static create(options) {
|
|
2788
2864
|
return __async(this, null, function* () {
|
|
2789
|
-
var _a3;
|
|
2865
|
+
var _a3, _b;
|
|
2790
2866
|
const globalObject = getGlobalObject();
|
|
2791
2867
|
const existing = globalObject[SINGLETON_KEY];
|
|
2792
2868
|
if (existing) {
|
|
@@ -2796,6 +2872,11 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2796
2872
|
"mmconnect_versions",
|
|
2797
2873
|
(_a3 = instance.options.versions) != null ? _a3 : {}
|
|
2798
2874
|
);
|
|
2875
|
+
if ((_b = options.analytics) == null ? void 0 : _b.integrationType) {
|
|
2876
|
+
import_analytics4.analytics.setGlobalProperty("integration_types", [
|
|
2877
|
+
options.analytics.integrationType
|
|
2878
|
+
]);
|
|
2879
|
+
}
|
|
2799
2880
|
if (options.debug) {
|
|
2800
2881
|
enableDebug("metamask-sdk:*");
|
|
2801
2882
|
}
|
|
@@ -3016,7 +3097,9 @@ setupAnalytics_fn = function() {
|
|
|
3016
3097
|
import_analytics4.analytics.setGlobalProperty("dapp_id", dappId);
|
|
3017
3098
|
import_analytics4.analytics.setGlobalProperty("anon_id", anonId);
|
|
3018
3099
|
import_analytics4.analytics.setGlobalProperty("platform", platform);
|
|
3019
|
-
|
|
3100
|
+
if (integrationType) {
|
|
3101
|
+
import_analytics4.analytics.setGlobalProperty("integration_types", [integrationType]);
|
|
3102
|
+
}
|
|
3020
3103
|
import_analytics4.analytics.enable();
|
|
3021
3104
|
});
|
|
3022
3105
|
};
|