@metamask/connect-multichain 0.10.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 +19 -1
- package/dist/browser/es/connect-multichain.d.mts +10 -1
- package/dist/browser/es/connect-multichain.mjs +103 -31
- 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 +10 -1
- package/dist/browser/iife/connect-multichain.js +103 -31
- 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 +10 -1
- package/dist/browser/umd/connect-multichain.js +103 -31
- 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 +10 -1
- package/dist/node/cjs/connect-multichain.js +103 -31
- 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 +10 -1
- package/dist/node/es/connect-multichain.mjs +103 -31
- 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 +10 -1
- package/dist/react-native/es/connect-multichain.mjs +112 -32
- 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/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 +1 -5
- 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/types/connect-multichain.d.ts +10 -1
- package/package.json +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ 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
|
+
|
|
10
27
|
## [0.10.0]
|
|
11
28
|
|
|
12
29
|
### Changed
|
|
@@ -210,7 +227,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
210
227
|
|
|
211
228
|
- Initial release
|
|
212
229
|
|
|
213
|
-
[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
|
|
214
232
|
[0.10.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.9.0...@metamask/connect-multichain@0.10.0
|
|
215
233
|
[0.9.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.8.0...@metamask/connect-multichain@0.9.0
|
|
216
234
|
[0.8.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.7.0...@metamask/connect-multichain@0.8.0
|
|
@@ -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;
|
|
@@ -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",
|
|
@@ -1481,7 +1546,9 @@ var RequestRouter = class {
|
|
|
1481
1546
|
if (response.error) {
|
|
1482
1547
|
const { error } = response;
|
|
1483
1548
|
throw new RPCInvokeMethodErr(
|
|
1484
|
-
`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
|
|
1485
1552
|
);
|
|
1486
1553
|
}
|
|
1487
1554
|
return response.result;
|
|
@@ -1522,6 +1589,7 @@ var RequestRouter = class {
|
|
|
1522
1589
|
_RequestRouter_instances = new WeakSet();
|
|
1523
1590
|
withAnalyticsTracking_fn = function(options, execute) {
|
|
1524
1591
|
return __async(this, null, function* () {
|
|
1592
|
+
var _a3;
|
|
1525
1593
|
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRequested_fn).call(this, options);
|
|
1526
1594
|
try {
|
|
1527
1595
|
const result = yield execute();
|
|
@@ -1537,7 +1605,11 @@ withAnalyticsTracking_fn = function(options, execute) {
|
|
|
1537
1605
|
if (error instanceof RPCInvokeMethodErr) {
|
|
1538
1606
|
throw error;
|
|
1539
1607
|
}
|
|
1540
|
-
|
|
1608
|
+
const castError = error;
|
|
1609
|
+
throw new RPCInvokeMethodErr(
|
|
1610
|
+
(_a3 = castError.message) != null ? _a3 : "Unknown error",
|
|
1611
|
+
castError.code
|
|
1612
|
+
);
|
|
1541
1613
|
}
|
|
1542
1614
|
});
|
|
1543
1615
|
};
|
|
@@ -1794,9 +1866,13 @@ handleResponse_fn = function(event) {
|
|
|
1794
1866
|
__privateGet(this, _pendingRequests).delete(responseId);
|
|
1795
1867
|
const response = responseData;
|
|
1796
1868
|
if ("error" in response && response.error) {
|
|
1797
|
-
|
|
1798
|
-
|
|
1869
|
+
const error = new Error(
|
|
1870
|
+
response.error.message || "Request failed"
|
|
1799
1871
|
);
|
|
1872
|
+
if (typeof response.error.code === "number") {
|
|
1873
|
+
error.code = response.error.code;
|
|
1874
|
+
}
|
|
1875
|
+
pendingRequest.reject(error);
|
|
1800
1876
|
} else {
|
|
1801
1877
|
pendingRequest.resolve(response);
|
|
1802
1878
|
}
|
|
@@ -1809,7 +1885,7 @@ handleNotification_fn = function(event) {
|
|
|
1809
1885
|
return;
|
|
1810
1886
|
}
|
|
1811
1887
|
const responseData = (_b = (_a3 = event == null ? void 0 : event.data) == null ? void 0 : _a3.data) == null ? void 0 : _b.data;
|
|
1812
|
-
if (typeof responseData === "object" && responseData !== null &&
|
|
1888
|
+
if (typeof responseData === "object" && responseData !== null && "method" in responseData) {
|
|
1813
1889
|
__privateMethod(this, _DefaultTransport_instances, notifyCallbacks_fn).call(this, responseData);
|
|
1814
1890
|
}
|
|
1815
1891
|
};
|
|
@@ -2687,7 +2763,7 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2687
2763
|
versions: __spreadValues({
|
|
2688
2764
|
// typeof guard needed: Metro (React Native) bundles TS source directly,
|
|
2689
2765
|
// bypassing the tsup build that substitutes __PACKAGE_VERSION__.
|
|
2690
|
-
"connect-multichain": false ? "unknown" : "0.
|
|
2766
|
+
"connect-multichain": false ? "unknown" : "0.11.0"
|
|
2691
2767
|
}, (_f = options.versions) != null ? _f : {})
|
|
2692
2768
|
});
|
|
2693
2769
|
super(allOptions);
|
|
@@ -2711,15 +2787,11 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2711
2787
|
return this._status;
|
|
2712
2788
|
}
|
|
2713
2789
|
set status(value) {
|
|
2714
|
-
var _a3, _b;
|
|
2715
2790
|
if (this._status === value) {
|
|
2716
2791
|
return;
|
|
2717
2792
|
}
|
|
2718
2793
|
this._status = value;
|
|
2719
|
-
|
|
2720
|
-
method: "stateChanged",
|
|
2721
|
-
params: value
|
|
2722
|
-
});
|
|
2794
|
+
this.emit("stateChanged", value);
|
|
2723
2795
|
}
|
|
2724
2796
|
get provider() {
|
|
2725
2797
|
return __privateGet(this, _provider);
|