@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
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.11.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- `DefaultTransport` now forwards all wallet notifications instead of filtering to only `metamask_chainChanged` and `metamask_accountsChanged`, matching `MWPTransport` behavior ([#230](https://github.com/MetaMask/connect-monorepo/pull/230))
|
|
15
|
+
- `stateChanged` is now emitted via the `EventEmitter` so `client.on('stateChanged', cb)` fires correctly ([#230](https://github.com/MetaMask/connect-monorepo/pull/230))
|
|
16
|
+
- `SDKEvents` type now includes explicit entries for `metamask_accountsChanged`, `metamask_chainChanged`, and `stateChanged` ([#230](https://github.com/MetaMask/connect-monorepo/pull/230))
|
|
17
|
+
- Mark `@react-native-async-storage/async-storage` peer dependency as optional — web/Node consumers no longer pull in the React Native toolchain ([#234](https://github.com/MetaMask/connect-monorepo/pull/234))
|
|
18
|
+
- `getInfuraRpcUrls` now includes Solana mainnet and devnet CAIP chain IDs in the generated RPC URL map ([#235](https://github.com/MetaMask/connect-monorepo/pull/235))
|
|
19
|
+
- Updated `infuraRpcUrls` to align with Infura's currently supported networks by removing deprecated testnets (Goerli variants, Mumbai, Palm testnet, Aurora) and adding new mainnet/testnet coverage across Base, Blast, zkSync, BSC/opBNB, Scroll, Mantle, Sei, Swellchain, Unichain, Hemi, MegaETH, Monad, and Celo Sepolia ([#237](https://github.com/MetaMask/connect-monorepo/pull/237))
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- `RPCInvokeMethodErr` now carries the original numeric RPC code from the wallet (`rpcCode`) and the original wallet-facing message (`rpcMessage`) as separate fields, so higher layers can re-surface them without losing them inside internal error formatting. ([#232](https://github.com/MetaMask/connect-monorepo/pull/232))
|
|
24
|
+
- `RequestRouter` now propagates the numeric RPC error code from wallet response errors and transport exceptions into `RPCInvokeMethodErr`, ensuring the code is not dropped during error wrapping. ([#232](https://github.com/MetaMask/connect-monorepo/pull/232))
|
|
25
|
+
- `DefaultTransport` now attaches the numeric RPC code to errors produced from `window.postMessage` responses, so it survives the transport boundary. ([#232](https://github.com/MetaMask/connect-monorepo/pull/232))
|
|
26
|
+
|
|
27
|
+
## [0.10.0]
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- **BREAKING** `getInfuraRpcUrls` now accepts a single options object `{ infuraApiKey, caipChainIds? }` instead of a positional `infuraApiKey` string. The optional `caipChainIds` parameter filters the output to only the specified CAIP-2 chain IDs ([#211](https://github.com/MetaMask/connect-monorepo/pull/211))
|
|
32
|
+
- use merged integration types in analytics ([#223](https://github.com/MetaMask/connect-monorepo/pull/223))
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- fix: Fix react-native-playground consumption of **PACKAGE_VERSION** build-time constant in connect packages ([#221](https://github.com/MetaMask/connect-monorepo/pull/221))
|
|
37
|
+
|
|
10
38
|
## [0.9.0]
|
|
11
39
|
|
|
12
40
|
### Added
|
|
@@ -199,7 +227,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
199
227
|
|
|
200
228
|
- Initial release
|
|
201
229
|
|
|
202
|
-
[Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.
|
|
230
|
+
[Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.11.0...HEAD
|
|
231
|
+
[0.11.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.10.0...@metamask/connect-multichain@0.11.0
|
|
232
|
+
[0.10.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.9.0...@metamask/connect-multichain@0.10.0
|
|
203
233
|
[0.9.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.8.0...@metamask/connect-multichain@0.9.0
|
|
204
234
|
[0.8.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.7.0...@metamask/connect-multichain@0.8.0
|
|
205
235
|
[0.7.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.6.0...@metamask/connect-multichain@0.7.0
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ const client = await createMultichainClient({
|
|
|
32
32
|
api: {
|
|
33
33
|
supportedNetworks: {
|
|
34
34
|
// use the `getInfuraRpcUrls` helper to generate a map of Infura RPC endpoints
|
|
35
|
-
...getInfuraRpcUrls(INFURA_API_KEY),
|
|
35
|
+
...getInfuraRpcUrls({ infuraApiKey: INFURA_API_KEY }),
|
|
36
36
|
// or specify your own CAIP Chain ID to rpc endpoint mapping
|
|
37
37
|
'eip155:1': 'https://mainnet.example.io/rpc',
|
|
38
38
|
'eip155:137': 'https://polygon-mainnet.example.io/rpc',
|
|
@@ -338,15 +338,16 @@ Emits an event to all registered handlers.
|
|
|
338
338
|
|
|
339
339
|
### Utilities
|
|
340
340
|
|
|
341
|
-
#### `getInfuraRpcUrls(
|
|
341
|
+
#### `getInfuraRpcUrls(options)`
|
|
342
342
|
|
|
343
343
|
Generates Infura RPC URLs for common networks keyed by CAIP Chain ID.
|
|
344
344
|
|
|
345
345
|
**Parameters**
|
|
346
346
|
|
|
347
|
-
| Name | Type
|
|
348
|
-
| -------------- |
|
|
349
|
-
| `infuraApiKey` | `string`
|
|
347
|
+
| Name | Type | Required | Description |
|
|
348
|
+
| -------------- | --------------- | -------- | ------------------------------------- |
|
|
349
|
+
| `infuraApiKey` | `string` | Yes | Your Infura API key |
|
|
350
|
+
| `caipChainIds` | `CaipChainId[]` | No | CAIP-2 chain IDs to filter the output |
|
|
350
351
|
|
|
351
352
|
**Returns**
|
|
352
353
|
|
|
@@ -355,13 +356,24 @@ A map of [CAIP-2 chain IDs](https://chainagnostic.org/CAIPs/caip-2) to Infura RP
|
|
|
355
356
|
```typescript
|
|
356
357
|
import { getInfuraRpcUrls } from '@metamask/connect-multichain';
|
|
357
358
|
|
|
358
|
-
|
|
359
|
+
// Get all supported Infura RPC URLs
|
|
360
|
+
const rpcUrls = getInfuraRpcUrls({ infuraApiKey: 'YOUR_INFURA_KEY' });
|
|
359
361
|
// {
|
|
360
362
|
// 'eip155:1': 'https://mainnet.infura.io/v3/YOUR_KEY',
|
|
361
363
|
// 'eip155:137': 'https://polygon-mainnet.infura.io/v3/YOUR_KEY',
|
|
362
364
|
// 'eip155:11155111': 'https://sepolia.infura.io/v3/YOUR_KEY',
|
|
363
365
|
// ...
|
|
364
366
|
// }
|
|
367
|
+
|
|
368
|
+
// Filter to specific chains
|
|
369
|
+
const filtered = getInfuraRpcUrls({
|
|
370
|
+
infuraApiKey: 'YOUR_INFURA_KEY',
|
|
371
|
+
caipChainIds: ['eip155:1', 'eip155:137'],
|
|
372
|
+
});
|
|
373
|
+
// {
|
|
374
|
+
// 'eip155:1': 'https://mainnet.infura.io/v3/YOUR_KEY',
|
|
375
|
+
// 'eip155:137': 'https://polygon-mainnet.infura.io/v3/YOUR_KEY',
|
|
376
|
+
// }
|
|
365
377
|
```
|
|
366
378
|
|
|
367
379
|
---
|
|
@@ -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;
|
|
@@ -112,12 +112,14 @@ var init_rpc = __esm({
|
|
|
112
112
|
_RPCReadonlyRequestErr.code = 52;
|
|
113
113
|
RPCReadonlyRequestErr = _RPCReadonlyRequestErr;
|
|
114
114
|
_RPCInvokeMethodErr = class _RPCInvokeMethodErr extends BaseErr {
|
|
115
|
-
constructor(reason) {
|
|
115
|
+
constructor(reason, rpcCode, rpcMessage) {
|
|
116
116
|
super(
|
|
117
117
|
`RPCErr${_RPCInvokeMethodErr.code}: RPC Client invoke method reason (${reason})`,
|
|
118
118
|
_RPCInvokeMethodErr.code
|
|
119
119
|
);
|
|
120
120
|
this.reason = reason;
|
|
121
|
+
this.rpcCode = rpcCode;
|
|
122
|
+
this.rpcMessage = rpcMessage;
|
|
121
123
|
}
|
|
122
124
|
};
|
|
123
125
|
_RPCInvokeMethodErr.code = 53;
|
|
@@ -258,35 +260,98 @@ var init_constants = __esm({
|
|
|
258
260
|
// ###### Ethereum ######
|
|
259
261
|
// Mainnet
|
|
260
262
|
"eip155:1": "https://mainnet.infura.io/v3/",
|
|
261
|
-
// Goerli
|
|
262
|
-
"eip155:5": "https://goerli.infura.io/v3/",
|
|
263
263
|
// Sepolia 11155111
|
|
264
264
|
"eip155:11155111": "https://sepolia.infura.io/v3/",
|
|
265
|
+
// Hoodi
|
|
266
|
+
"eip155:560048": "https://hoodi.infura.io/v3/",
|
|
265
267
|
// ###### Linea ######
|
|
266
268
|
// Mainnet Alpha
|
|
267
269
|
"eip155:59144": "https://linea-mainnet.infura.io/v3/",
|
|
268
|
-
//
|
|
269
|
-
"eip155:
|
|
270
|
+
// Sepolia
|
|
271
|
+
"eip155:59141": "https://linea-sepolia.infura.io/v3/",
|
|
270
272
|
// ###### Polygon ######
|
|
271
273
|
// Mainnet
|
|
272
274
|
"eip155:137": "https://polygon-mainnet.infura.io/v3/",
|
|
273
|
-
//
|
|
274
|
-
"eip155:
|
|
275
|
+
// Amoy
|
|
276
|
+
"eip155:80002": "https://polygon-amoy.infura.io/v3/",
|
|
275
277
|
// ###### Optimism ######
|
|
276
278
|
// Mainnet
|
|
277
279
|
"eip155:10": "https://optimism-mainnet.infura.io/v3/",
|
|
278
|
-
//
|
|
279
|
-
"eip155:
|
|
280
|
+
// Sepolia
|
|
281
|
+
"eip155:11155420": "https://optimism-sepolia.infura.io/v3/",
|
|
280
282
|
// ###### Arbitrum ######
|
|
281
283
|
// Mainnet
|
|
282
284
|
"eip155:42161": "https://arbitrum-mainnet.infura.io/v3/",
|
|
283
|
-
//
|
|
284
|
-
"eip155:
|
|
285
|
+
// Sepolia
|
|
286
|
+
"eip155:421614": "https://arbitrum-sepolia.infura.io/v3/",
|
|
287
|
+
// ###### Base ######
|
|
288
|
+
// Mainnet
|
|
289
|
+
"eip155:8453": "https://base-mainnet.infura.io/v3/",
|
|
290
|
+
// Sepolia
|
|
291
|
+
"eip155:84532": "https://base-sepolia.infura.io/v3/",
|
|
292
|
+
// ###### Blast ######
|
|
293
|
+
// Mainnet
|
|
294
|
+
"eip155:81457": "https://blast-mainnet.infura.io/v3/",
|
|
295
|
+
// Sepolia
|
|
296
|
+
"eip155:168587773": "https://blast-sepolia.infura.io/v3/",
|
|
297
|
+
// ###### zkSync ######
|
|
298
|
+
// Mainnet
|
|
299
|
+
"eip155:324": "https://zksync-mainnet.infura.io/v3/",
|
|
300
|
+
// Sepolia
|
|
301
|
+
"eip155:300": "https://zksync-sepolia.infura.io/v3/",
|
|
302
|
+
// ###### BSC ######
|
|
303
|
+
// Mainnet
|
|
304
|
+
"eip155:56": "https://bsc-mainnet.infura.io/v3/",
|
|
305
|
+
// Testnet
|
|
306
|
+
"eip155:97": "https://bsc-testnet.infura.io/v3/",
|
|
307
|
+
// ###### opBNB ######
|
|
308
|
+
// Mainnet
|
|
309
|
+
"eip155:204": "https://opbnb-mainnet.infura.io/v3/",
|
|
310
|
+
// Testnet
|
|
311
|
+
"eip155:5611": "https://opbnb-testnet.infura.io/v3/",
|
|
312
|
+
// ###### Scroll ######
|
|
313
|
+
// Mainnet
|
|
314
|
+
"eip155:534352": "https://scroll-mainnet.infura.io/v3/",
|
|
315
|
+
// Sepolia
|
|
316
|
+
"eip155:534351": "https://scroll-sepolia.infura.io/v3/",
|
|
317
|
+
// ###### Mantle ######
|
|
318
|
+
// Mainnet
|
|
319
|
+
"eip155:5000": "https://mantle-mainnet.infura.io/v3/",
|
|
320
|
+
// Sepolia
|
|
321
|
+
"eip155:5003": "https://mantle-sepolia.infura.io/v3/",
|
|
322
|
+
// ###### Sei ######
|
|
323
|
+
// Mainnet
|
|
324
|
+
"eip155:1329": "https://sei-mainnet.infura.io/v3/",
|
|
325
|
+
// Testnet
|
|
326
|
+
"eip155:713715": "https://sei-testnet.infura.io/v3/",
|
|
327
|
+
// ###### Swellchain ######
|
|
328
|
+
// Mainnet
|
|
329
|
+
"eip155:1923": "https://swellchain-mainnet.infura.io/v3/",
|
|
330
|
+
// Testnet
|
|
331
|
+
"eip155:1924": "https://swellchain-testnet.infura.io/v3/",
|
|
332
|
+
// ###### Unichain ######
|
|
333
|
+
// Mainnet
|
|
334
|
+
"eip155:130": "https://unichain-mainnet.infura.io/v3/",
|
|
335
|
+
// Sepolia
|
|
336
|
+
"eip155:1301": "https://unichain-sepolia.infura.io/v3/",
|
|
337
|
+
// ###### Hemi ######
|
|
338
|
+
// Mainnet
|
|
339
|
+
"eip155:43111": "https://hemi-mainnet.infura.io/v3/",
|
|
340
|
+
// Testnet
|
|
341
|
+
"eip155:743111": "https://hemi-testnet.infura.io/v3/",
|
|
342
|
+
// ###### MegaETH ######
|
|
343
|
+
// Mainnet
|
|
344
|
+
"eip155:6342": "https://megaeth-mainnet.infura.io/v3/",
|
|
345
|
+
// Testnet
|
|
346
|
+
"eip155:6342001": "https://megaeth-testnet.infura.io/v3/",
|
|
347
|
+
// ###### Monad ######
|
|
348
|
+
// Mainnet
|
|
349
|
+
"eip155:143": "https://monad-mainnet.infura.io/v3/",
|
|
350
|
+
// Testnet
|
|
351
|
+
"eip155:10143": "https://monad-testnet.infura.io/v3/",
|
|
285
352
|
// ###### Palm ######
|
|
286
353
|
// Mainnet
|
|
287
354
|
"eip155:11297108109": "https://palm-mainnet.infura.io/v3/",
|
|
288
|
-
// Testnet
|
|
289
|
-
"eip155:11297108099": "https://palm-testnet.infura.io/v3/",
|
|
290
355
|
// ###### Avalanche C-Chain ######
|
|
291
356
|
// Mainnet
|
|
292
357
|
"eip155:43114": "https://avalanche-mainnet.infura.io/v3/",
|
|
@@ -297,11 +362,6 @@ var init_constants = __esm({
|
|
|
297
362
|
// 'near:mainnet': `https://near-mainnet.infura.io/v3/`,
|
|
298
363
|
// // Testnet
|
|
299
364
|
// 'near:testnet': `https://near-testnet.infura.io/v3/`,
|
|
300
|
-
// ###### Aurora ######
|
|
301
|
-
// Mainnet
|
|
302
|
-
"eip155:1313161554": "https://aurora-mainnet.infura.io/v3/",
|
|
303
|
-
// Testnet
|
|
304
|
-
"eip155:1313161555": "https://aurora-testnet.infura.io/v3/",
|
|
305
365
|
// ###### StarkNet ######
|
|
306
366
|
// Mainnet
|
|
307
367
|
//
|
|
@@ -313,8 +373,13 @@ var init_constants = __esm({
|
|
|
313
373
|
// ###### Celo ######
|
|
314
374
|
// Mainnet
|
|
315
375
|
"eip155:42220": "https://celo-mainnet.infura.io/v3/",
|
|
316
|
-
//
|
|
317
|
-
"eip155:44787": "https://celo-
|
|
376
|
+
// Sepolia
|
|
377
|
+
"eip155:44787": "https://celo-sepolia.infura.io/v3/",
|
|
378
|
+
// ###### Solana ######
|
|
379
|
+
// Mainnet
|
|
380
|
+
"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": "https://solana-mainnet.infura.io/v3/",
|
|
381
|
+
// Devnet
|
|
382
|
+
"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": "https://solana-devnet.infura.io/v3/"
|
|
318
383
|
};
|
|
319
384
|
RPC_HANDLED_METHODS = /* @__PURE__ */ new Set([
|
|
320
385
|
"eth_blockNumber",
|
|
@@ -356,10 +421,16 @@ var init_constants = __esm({
|
|
|
356
421
|
});
|
|
357
422
|
|
|
358
423
|
// src/domain/multichain/api/infura.ts
|
|
359
|
-
function getInfuraRpcUrls(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
424
|
+
function getInfuraRpcUrls({
|
|
425
|
+
infuraApiKey,
|
|
426
|
+
caipChainIds
|
|
427
|
+
}) {
|
|
428
|
+
const keys = caipChainIds && caipChainIds.length > 0 ? caipChainIds : Object.keys(infuraRpcUrls);
|
|
429
|
+
return keys.reduce((acc, key) => {
|
|
430
|
+
const baseUrl = infuraRpcUrls[key];
|
|
431
|
+
if (baseUrl) {
|
|
432
|
+
acc[key] = `${baseUrl}${infuraApiKey}`;
|
|
433
|
+
}
|
|
363
434
|
return acc;
|
|
364
435
|
}, {});
|
|
365
436
|
}
|
|
@@ -627,31 +698,27 @@ function isRejectionError(error) {
|
|
|
627
698
|
}
|
|
628
699
|
function getBaseAnalyticsProperties(options, storage) {
|
|
629
700
|
return __async(this, null, function* () {
|
|
630
|
-
var _a3
|
|
701
|
+
var _a3;
|
|
631
702
|
const dappId = getDappId(options.dapp);
|
|
632
703
|
const platform = getPlatformType();
|
|
633
704
|
const anonId = yield storage.getAnonId();
|
|
634
|
-
const integrationType = (_b = (_a3 = options.analytics) == null ? void 0 : _a3.integrationType) != null ? _b : "unknown" /* UNKNOWN */;
|
|
635
705
|
return {
|
|
636
|
-
mmconnect_versions: (
|
|
706
|
+
mmconnect_versions: (_a3 = options.versions) != null ? _a3 : {},
|
|
637
707
|
dapp_id: dappId,
|
|
638
708
|
platform,
|
|
639
|
-
integration_type: integrationType,
|
|
640
709
|
anon_id: anonId
|
|
641
710
|
};
|
|
642
711
|
});
|
|
643
712
|
}
|
|
644
713
|
function getWalletActionAnalyticsProperties(options, storage, invokeOptions, transportType) {
|
|
645
714
|
return __async(this, null, function* () {
|
|
646
|
-
var _a3
|
|
715
|
+
var _a3;
|
|
647
716
|
const dappId = getDappId(options.dapp);
|
|
648
717
|
const anonId = yield storage.getAnonId();
|
|
649
|
-
const integrationType = (_b = (_a3 = options.analytics) == null ? void 0 : _a3.integrationType) != null ? _b : "unknown";
|
|
650
718
|
return {
|
|
651
|
-
mmconnect_versions: (
|
|
719
|
+
mmconnect_versions: (_a3 = options.versions) != null ? _a3 : {},
|
|
652
720
|
dapp_id: dappId,
|
|
653
721
|
method: invokeOptions.request.method,
|
|
654
|
-
integration_type: integrationType,
|
|
655
722
|
caip_chain_id: invokeOptions.scope,
|
|
656
723
|
anon_id: anonId,
|
|
657
724
|
transport_type: transportType
|
|
@@ -1479,7 +1546,9 @@ var RequestRouter = class {
|
|
|
1479
1546
|
if (response.error) {
|
|
1480
1547
|
const { error } = response;
|
|
1481
1548
|
throw new RPCInvokeMethodErr(
|
|
1482
|
-
`RPC Request failed with code ${error.code}: ${error.message}
|
|
1549
|
+
`RPC Request failed with code ${error.code}: ${error.message}`,
|
|
1550
|
+
error.code,
|
|
1551
|
+
error.message
|
|
1483
1552
|
);
|
|
1484
1553
|
}
|
|
1485
1554
|
return response.result;
|
|
@@ -1520,6 +1589,7 @@ var RequestRouter = class {
|
|
|
1520
1589
|
_RequestRouter_instances = new WeakSet();
|
|
1521
1590
|
withAnalyticsTracking_fn = function(options, execute) {
|
|
1522
1591
|
return __async(this, null, function* () {
|
|
1592
|
+
var _a3;
|
|
1523
1593
|
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRequested_fn).call(this, options);
|
|
1524
1594
|
try {
|
|
1525
1595
|
const result = yield execute();
|
|
@@ -1535,7 +1605,11 @@ withAnalyticsTracking_fn = function(options, execute) {
|
|
|
1535
1605
|
if (error instanceof RPCInvokeMethodErr) {
|
|
1536
1606
|
throw error;
|
|
1537
1607
|
}
|
|
1538
|
-
|
|
1608
|
+
const castError = error;
|
|
1609
|
+
throw new RPCInvokeMethodErr(
|
|
1610
|
+
(_a3 = castError.message) != null ? _a3 : "Unknown error",
|
|
1611
|
+
castError.code
|
|
1612
|
+
);
|
|
1539
1613
|
}
|
|
1540
1614
|
});
|
|
1541
1615
|
};
|
|
@@ -1792,9 +1866,13 @@ handleResponse_fn = function(event) {
|
|
|
1792
1866
|
__privateGet(this, _pendingRequests).delete(responseId);
|
|
1793
1867
|
const response = responseData;
|
|
1794
1868
|
if ("error" in response && response.error) {
|
|
1795
|
-
|
|
1796
|
-
|
|
1869
|
+
const error = new Error(
|
|
1870
|
+
response.error.message || "Request failed"
|
|
1797
1871
|
);
|
|
1872
|
+
if (typeof response.error.code === "number") {
|
|
1873
|
+
error.code = response.error.code;
|
|
1874
|
+
}
|
|
1875
|
+
pendingRequest.reject(error);
|
|
1798
1876
|
} else {
|
|
1799
1877
|
pendingRequest.resolve(response);
|
|
1800
1878
|
}
|
|
@@ -1807,7 +1885,7 @@ handleNotification_fn = function(event) {
|
|
|
1807
1885
|
return;
|
|
1808
1886
|
}
|
|
1809
1887
|
const responseData = (_b = (_a3 = event == null ? void 0 : event.data) == null ? void 0 : _a3.data) == null ? void 0 : _b.data;
|
|
1810
|
-
if (typeof responseData === "object" && responseData !== null &&
|
|
1888
|
+
if (typeof responseData === "object" && responseData !== null && "method" in responseData) {
|
|
1811
1889
|
__privateMethod(this, _DefaultTransport_instances, notifyCallbacks_fn).call(this, responseData);
|
|
1812
1890
|
}
|
|
1813
1891
|
};
|
|
@@ -2670,21 +2748,23 @@ var SINGLETON_KEY = "__METAMASK_CONNECT_MULTICHAIN_SINGLETON__";
|
|
|
2670
2748
|
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;
|
|
2671
2749
|
var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends MultichainCore {
|
|
2672
2750
|
constructor(options) {
|
|
2673
|
-
var _a3, _b, _c, _d, _e, _f
|
|
2751
|
+
var _a3, _b, _c, _d, _e, _f;
|
|
2674
2752
|
const withDappMetadata = setupDappMetadata(options);
|
|
2675
|
-
const integrationType = (
|
|
2753
|
+
const integrationType = ((_a3 = options.analytics) == null ? void 0 : _a3.integrationType) || "direct";
|
|
2676
2754
|
const allOptions = __spreadProps(__spreadValues({}, withDappMetadata), {
|
|
2677
2755
|
ui: __spreadProps(__spreadValues({}, withDappMetadata.ui), {
|
|
2678
|
-
preferExtension: (
|
|
2679
|
-
showInstallModal: (
|
|
2680
|
-
headless: (
|
|
2756
|
+
preferExtension: (_b = withDappMetadata.ui.preferExtension) != null ? _b : true,
|
|
2757
|
+
showInstallModal: (_c = withDappMetadata.ui.showInstallModal) != null ? _c : false,
|
|
2758
|
+
headless: (_d = withDappMetadata.ui.headless) != null ? _d : false
|
|
2681
2759
|
}),
|
|
2682
|
-
analytics: __spreadProps(__spreadValues({}, (
|
|
2760
|
+
analytics: __spreadProps(__spreadValues({}, (_e = options.analytics) != null ? _e : {}), {
|
|
2683
2761
|
integrationType
|
|
2684
2762
|
}),
|
|
2685
2763
|
versions: __spreadValues({
|
|
2686
|
-
|
|
2687
|
-
|
|
2764
|
+
// typeof guard needed: Metro (React Native) bundles TS source directly,
|
|
2765
|
+
// bypassing the tsup build that substitutes __PACKAGE_VERSION__.
|
|
2766
|
+
"connect-multichain": false ? "unknown" : "0.11.0"
|
|
2767
|
+
}, (_f = options.versions) != null ? _f : {})
|
|
2688
2768
|
});
|
|
2689
2769
|
super(allOptions);
|
|
2690
2770
|
__privateAdd(this, _MetaMaskConnectMultichain_instances);
|
|
@@ -2707,15 +2787,11 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2707
2787
|
return this._status;
|
|
2708
2788
|
}
|
|
2709
2789
|
set status(value) {
|
|
2710
|
-
var _a3, _b;
|
|
2711
2790
|
if (this._status === value) {
|
|
2712
2791
|
return;
|
|
2713
2792
|
}
|
|
2714
2793
|
this._status = value;
|
|
2715
|
-
|
|
2716
|
-
method: "stateChanged",
|
|
2717
|
-
params: value
|
|
2718
|
-
});
|
|
2794
|
+
this.emit("stateChanged", value);
|
|
2719
2795
|
}
|
|
2720
2796
|
get provider() {
|
|
2721
2797
|
return __privateGet(this, _provider);
|
|
@@ -2746,7 +2822,7 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2746
2822
|
// subsequent calls to `createMultichainClient` to have a different `dapp` value.
|
|
2747
2823
|
static create(options) {
|
|
2748
2824
|
return __async(this, null, function* () {
|
|
2749
|
-
var _a3;
|
|
2825
|
+
var _a3, _b;
|
|
2750
2826
|
const globalObject = getGlobalObject();
|
|
2751
2827
|
const existing = globalObject[SINGLETON_KEY];
|
|
2752
2828
|
if (existing) {
|
|
@@ -2756,6 +2832,11 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2756
2832
|
"mmconnect_versions",
|
|
2757
2833
|
(_a3 = instance.options.versions) != null ? _a3 : {}
|
|
2758
2834
|
);
|
|
2835
|
+
if ((_b = options.analytics) == null ? void 0 : _b.integrationType) {
|
|
2836
|
+
analytics2.setGlobalProperty("integration_types", [
|
|
2837
|
+
options.analytics.integrationType
|
|
2838
|
+
]);
|
|
2839
|
+
}
|
|
2759
2840
|
if (options.debug) {
|
|
2760
2841
|
enableDebug("metamask-sdk:*");
|
|
2761
2842
|
}
|
|
@@ -2976,7 +3057,9 @@ setupAnalytics_fn = function() {
|
|
|
2976
3057
|
analytics2.setGlobalProperty("dapp_id", dappId);
|
|
2977
3058
|
analytics2.setGlobalProperty("anon_id", anonId);
|
|
2978
3059
|
analytics2.setGlobalProperty("platform", platform);
|
|
2979
|
-
|
|
3060
|
+
if (integrationType) {
|
|
3061
|
+
analytics2.setGlobalProperty("integration_types", [integrationType]);
|
|
3062
|
+
}
|
|
2980
3063
|
analytics2.enable();
|
|
2981
3064
|
});
|
|
2982
3065
|
};
|