@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
|
@@ -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;
|
|
@@ -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",
|
|
@@ -1525,7 +1590,9 @@ var RequestRouter = class {
|
|
|
1525
1590
|
if (response.error) {
|
|
1526
1591
|
const { error } = response;
|
|
1527
1592
|
throw new RPCInvokeMethodErr(
|
|
1528
|
-
`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
|
|
1529
1596
|
);
|
|
1530
1597
|
}
|
|
1531
1598
|
return response.result;
|
|
@@ -1566,6 +1633,7 @@ var RequestRouter = class {
|
|
|
1566
1633
|
_RequestRouter_instances = new WeakSet();
|
|
1567
1634
|
withAnalyticsTracking_fn = function(options, execute) {
|
|
1568
1635
|
return __async(this, null, function* () {
|
|
1636
|
+
var _a3;
|
|
1569
1637
|
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRequested_fn).call(this, options);
|
|
1570
1638
|
try {
|
|
1571
1639
|
const result = yield execute();
|
|
@@ -1581,7 +1649,11 @@ withAnalyticsTracking_fn = function(options, execute) {
|
|
|
1581
1649
|
if (error instanceof RPCInvokeMethodErr) {
|
|
1582
1650
|
throw error;
|
|
1583
1651
|
}
|
|
1584
|
-
|
|
1652
|
+
const castError = error;
|
|
1653
|
+
throw new RPCInvokeMethodErr(
|
|
1654
|
+
(_a3 = castError.message) != null ? _a3 : "Unknown error",
|
|
1655
|
+
castError.code
|
|
1656
|
+
);
|
|
1585
1657
|
}
|
|
1586
1658
|
});
|
|
1587
1659
|
};
|
|
@@ -1836,9 +1908,13 @@ handleResponse_fn = function(event) {
|
|
|
1836
1908
|
__privateGet(this, _pendingRequests).delete(responseId);
|
|
1837
1909
|
const response = responseData;
|
|
1838
1910
|
if ("error" in response && response.error) {
|
|
1839
|
-
|
|
1840
|
-
|
|
1911
|
+
const error = new Error(
|
|
1912
|
+
response.error.message || "Request failed"
|
|
1841
1913
|
);
|
|
1914
|
+
if (typeof response.error.code === "number") {
|
|
1915
|
+
error.code = response.error.code;
|
|
1916
|
+
}
|
|
1917
|
+
pendingRequest.reject(error);
|
|
1842
1918
|
} else {
|
|
1843
1919
|
pendingRequest.resolve(response);
|
|
1844
1920
|
}
|
|
@@ -1851,7 +1927,7 @@ handleNotification_fn = function(event) {
|
|
|
1851
1927
|
return;
|
|
1852
1928
|
}
|
|
1853
1929
|
const responseData = (_b = (_a3 = event == null ? void 0 : event.data) == null ? void 0 : _a3.data) == null ? void 0 : _b.data;
|
|
1854
|
-
if (typeof responseData === "object" && responseData !== null &&
|
|
1930
|
+
if (typeof responseData === "object" && responseData !== null && "method" in responseData) {
|
|
1855
1931
|
__privateMethod(this, _DefaultTransport_instances, notifyCallbacks_fn).call(this, responseData);
|
|
1856
1932
|
}
|
|
1857
1933
|
};
|
|
@@ -2727,7 +2803,7 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2727
2803
|
versions: __spreadValues({
|
|
2728
2804
|
// typeof guard needed: Metro (React Native) bundles TS source directly,
|
|
2729
2805
|
// bypassing the tsup build that substitutes __PACKAGE_VERSION__.
|
|
2730
|
-
"connect-multichain": false ? "unknown" : "0.
|
|
2806
|
+
"connect-multichain": false ? "unknown" : "0.11.0"
|
|
2731
2807
|
}, (_f = options.versions) != null ? _f : {})
|
|
2732
2808
|
});
|
|
2733
2809
|
super(allOptions);
|
|
@@ -2751,15 +2827,11 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
|
|
|
2751
2827
|
return this._status;
|
|
2752
2828
|
}
|
|
2753
2829
|
set status(value) {
|
|
2754
|
-
var _a3, _b;
|
|
2755
2830
|
if (this._status === value) {
|
|
2756
2831
|
return;
|
|
2757
2832
|
}
|
|
2758
2833
|
this._status = value;
|
|
2759
|
-
|
|
2760
|
-
method: "stateChanged",
|
|
2761
|
-
params: value
|
|
2762
|
-
});
|
|
2834
|
+
this.emit("stateChanged", value);
|
|
2763
2835
|
}
|
|
2764
2836
|
get provider() {
|
|
2765
2837
|
return __privateGet(this, _provider);
|