@metamask/connect-evm 1.3.1 → 2.0.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 +32 -1
- package/README.md +36 -15
- package/dist/browser/es/connect-evm.mjs +375 -51
- package/dist/browser/es/connect-evm.mjs.map +1 -1
- package/dist/src/connect.d.ts +12 -2
- package/dist/src/connect.d.ts.map +1 -1
- package/dist/src/connect.js +140 -26
- package/dist/src/connect.js.map +1 -1
- package/dist/src/eip6963.d.ts +80 -0
- package/dist/src/eip6963.d.ts.map +1 -0
- package/dist/src/eip6963.js +297 -0
- package/dist/src/eip6963.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils/infura.js.map +1 -1
- package/dist/types/index.d.ts +22 -3
- package/package.json +10 -5
|
@@ -88,6 +88,7 @@ import {
|
|
|
88
88
|
TransportType
|
|
89
89
|
} from "@metamask/connect-multichain";
|
|
90
90
|
import { hexToNumber as hexToNumber3 } from "@metamask/utils";
|
|
91
|
+
import { satisfies } from "semver";
|
|
91
92
|
|
|
92
93
|
// src/constants.ts
|
|
93
94
|
var IGNORED_METHODS = [
|
|
@@ -119,6 +120,9 @@ var CONNECT_EVM_SESSION_PROPERTIES = {
|
|
|
119
120
|
[EIP1193_COMPATIBLE_SESSION_PROPERTY]: true
|
|
120
121
|
};
|
|
121
122
|
|
|
123
|
+
// src/assets/metamask-fox.svg
|
|
124
|
+
var metamask_fox_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 142 137">%0A <path fill="%23FF5C16" d="m132.24 131.751-30.481-9.076-22.986 13.741-16.038-.007-23-13.734-30.467 9.076L0 100.465l9.268-34.723L0 36.385 9.268 0l47.607 28.443h27.757L132.24 0l9.268 36.385-9.268 29.357 9.268 34.723-9.268 31.286Z"/>%0A <path fill="%23FF5C16" d="m9.274 0 47.608 28.463-1.893 19.534L9.274 0Zm30.468 100.478 20.947 15.957-20.947 6.24v-22.197Zm19.273-26.381L54.989 48.01l-25.77 17.74-.014-.007v.013l.08 18.26 10.45-9.918h19.28ZM132.24 0 84.632 28.463l1.887 19.534L132.24 0Zm-30.467 100.478-20.948 15.957 20.948 6.24v-22.197Zm10.529-34.723h.007-.007v-.013l-.006.007-25.77-17.739L82.5 74.097h19.272l10.457 9.917.073-18.259Z"/>%0A <path fill="%23E34807" d="m39.735 122.675-30.467 9.076L0 100.478h39.735v22.197ZM59.008 74.09l5.82 37.714-8.066-20.97-27.49-6.82 10.456-9.923h19.28Zm42.764 48.585 30.468 9.076 9.268-31.273h-39.736v22.197ZM82.5 74.09l-5.82 37.714 8.065-20.97 27.491-6.82-10.463-9.923H82.5Z"/>%0A <path fill="%23FF8D5D" d="m0 100.465 9.268-34.723h19.93l.073 18.266 27.492 6.82 8.065 20.969-4.146 4.618-20.947-15.957H0v.007Zm141.508 0-9.268-34.723h-19.931l-.073 18.266-27.49 6.82-8.066 20.969 4.145 4.618 20.948-15.957h39.735v.007ZM84.632 28.443H56.875L54.99 47.977l9.839 63.8H76.68l9.845-63.8-1.893-19.534Z"/>%0A <path fill="%23661800" d="M9.268 0 0 36.385l9.268 29.357h19.93l25.784-17.745L9.268 0Zm43.98 81.665h-9.029l-4.916 4.819 17.466 4.33-3.521-9.155v.006ZM132.24 0l9.268 36.385-9.268 29.357h-19.931L86.526 47.997 132.24 0ZM88.273 81.665h9.042l4.916 4.825-17.486 4.338 3.528-9.17v.007Zm-9.507 42.305 2.06-7.542-4.146-4.618H64.82l-4.145 4.618 2.059 7.542"/>%0A <path fill="%23C0C4CD" d="M78.766 123.969v12.453H62.735v-12.453h16.03Z"/>%0A <path fill="%23E7EBF6" d="m39.742 122.662 23.006 13.754v-12.453l-2.06-7.541-20.946 6.24Zm62.031 0-23.007 13.754v-12.453l2.06-7.541 20.947 6.24Z"/>%0A</svg>%0A';
|
|
125
|
+
|
|
122
126
|
// src/logger.ts
|
|
123
127
|
import {
|
|
124
128
|
createLogger,
|
|
@@ -130,6 +134,220 @@ var enableDebug = () => {
|
|
|
130
134
|
debug(namespace);
|
|
131
135
|
};
|
|
132
136
|
|
|
137
|
+
// src/eip6963.ts
|
|
138
|
+
var EIP6963_ANNOUNCE_PROVIDER_EVENT = "eip6963:announceProvider";
|
|
139
|
+
var EIP6963_REQUEST_PROVIDER_EVENT = "eip6963:requestProvider";
|
|
140
|
+
var EIP6963_DETECTION_TIMEOUT_MS = 300;
|
|
141
|
+
var CONNECT_EVM_EIP6963_NAME = "MetaMask";
|
|
142
|
+
var CONNECT_EVM_EIP6963_RDNS = "io.metamask.mmc";
|
|
143
|
+
var METAMASK_EIP6963_RDNS = [
|
|
144
|
+
"io.metamask",
|
|
145
|
+
"io.metamask.mobile"
|
|
146
|
+
];
|
|
147
|
+
var CONNECT_EVM_EIP6963_ICON = metamask_fox_default;
|
|
148
|
+
var getBrowserWindow = () => {
|
|
149
|
+
const { window: browserWindow } = globalThis;
|
|
150
|
+
return typeof (browserWindow == null ? void 0 : browserWindow.dispatchEvent) === "function" ? browserWindow : void 0;
|
|
151
|
+
};
|
|
152
|
+
var delay = (ms) => __async(null, null, function* () {
|
|
153
|
+
return yield new Promise((resolve) => setTimeout(resolve, ms));
|
|
154
|
+
});
|
|
155
|
+
var isNativeMetaMaskRdns = (rdns) => METAMASK_EIP6963_RDNS.some((nativeRdns) => nativeRdns === rdns);
|
|
156
|
+
var getAnnouncementRdns = (event) => {
|
|
157
|
+
var _a;
|
|
158
|
+
const { detail } = event;
|
|
159
|
+
const rdns = (_a = detail == null ? void 0 : detail.info) == null ? void 0 : _a.rdns;
|
|
160
|
+
return typeof rdns === "string" ? rdns : void 0;
|
|
161
|
+
};
|
|
162
|
+
var UUID_BYTE_TO_HEX = Array.from(
|
|
163
|
+
{ length: 256 },
|
|
164
|
+
(_, byte) => byte.toString(16).padStart(2, "0")
|
|
165
|
+
);
|
|
166
|
+
var formatUuidV4 = (bytes) => {
|
|
167
|
+
bytes[6] = bytes[6] % 16 + 64;
|
|
168
|
+
bytes[8] = bytes[8] % 64 + 128;
|
|
169
|
+
return [
|
|
170
|
+
UUID_BYTE_TO_HEX[bytes[0]],
|
|
171
|
+
UUID_BYTE_TO_HEX[bytes[1]],
|
|
172
|
+
UUID_BYTE_TO_HEX[bytes[2]],
|
|
173
|
+
UUID_BYTE_TO_HEX[bytes[3]],
|
|
174
|
+
"-",
|
|
175
|
+
UUID_BYTE_TO_HEX[bytes[4]],
|
|
176
|
+
UUID_BYTE_TO_HEX[bytes[5]],
|
|
177
|
+
"-",
|
|
178
|
+
UUID_BYTE_TO_HEX[bytes[6]],
|
|
179
|
+
UUID_BYTE_TO_HEX[bytes[7]],
|
|
180
|
+
"-",
|
|
181
|
+
UUID_BYTE_TO_HEX[bytes[8]],
|
|
182
|
+
UUID_BYTE_TO_HEX[bytes[9]],
|
|
183
|
+
"-",
|
|
184
|
+
UUID_BYTE_TO_HEX[bytes[10]],
|
|
185
|
+
UUID_BYTE_TO_HEX[bytes[11]],
|
|
186
|
+
UUID_BYTE_TO_HEX[bytes[12]],
|
|
187
|
+
UUID_BYTE_TO_HEX[bytes[13]],
|
|
188
|
+
UUID_BYTE_TO_HEX[bytes[14]],
|
|
189
|
+
UUID_BYTE_TO_HEX[bytes[15]]
|
|
190
|
+
].join("");
|
|
191
|
+
};
|
|
192
|
+
var createUuid = () => {
|
|
193
|
+
const { crypto: cryptoProvider } = globalThis;
|
|
194
|
+
if (cryptoProvider == null ? void 0 : cryptoProvider.randomUUID) {
|
|
195
|
+
return cryptoProvider.randomUUID();
|
|
196
|
+
}
|
|
197
|
+
if (cryptoProvider == null ? void 0 : cryptoProvider.getRandomValues) {
|
|
198
|
+
const bytes = new Uint8Array(16);
|
|
199
|
+
cryptoProvider.getRandomValues(bytes);
|
|
200
|
+
return formatUuidV4(bytes);
|
|
201
|
+
}
|
|
202
|
+
throw new Error("Web Crypto API is required for EIP-6963 announcement");
|
|
203
|
+
};
|
|
204
|
+
var createAnnouncementEvent = (detail) => {
|
|
205
|
+
const { CustomEvent: CustomEventConstructor } = globalThis;
|
|
206
|
+
return new CustomEventConstructor(EIP6963_ANNOUNCE_PROVIDER_EVENT, {
|
|
207
|
+
detail
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
var createRequestProviderEvent = () => {
|
|
211
|
+
const { Event: EventConstructor } = globalThis;
|
|
212
|
+
return new EventConstructor(EIP6963_REQUEST_PROVIDER_EVENT);
|
|
213
|
+
};
|
|
214
|
+
var createProviderInfo = () => Object.freeze({
|
|
215
|
+
uuid: createUuid(),
|
|
216
|
+
name: CONNECT_EVM_EIP6963_NAME,
|
|
217
|
+
icon: CONNECT_EVM_EIP6963_ICON,
|
|
218
|
+
rdns: CONNECT_EVM_EIP6963_RDNS
|
|
219
|
+
});
|
|
220
|
+
var hasNativeMetaMaskProvider = () => __async(null, null, function* () {
|
|
221
|
+
const browserWindow = getBrowserWindow();
|
|
222
|
+
if (!browserWindow) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
const announcedRdns = /* @__PURE__ */ new Set();
|
|
226
|
+
const handler = (event) => {
|
|
227
|
+
const rdns = getAnnouncementRdns(event);
|
|
228
|
+
if (rdns) {
|
|
229
|
+
announcedRdns.add(rdns);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
browserWindow.addEventListener(EIP6963_ANNOUNCE_PROVIDER_EVENT, handler);
|
|
233
|
+
try {
|
|
234
|
+
browserWindow.dispatchEvent(createRequestProviderEvent());
|
|
235
|
+
yield delay(EIP6963_DETECTION_TIMEOUT_MS);
|
|
236
|
+
} finally {
|
|
237
|
+
browserWindow.removeEventListener(EIP6963_ANNOUNCE_PROVIDER_EVENT, handler);
|
|
238
|
+
}
|
|
239
|
+
return [...announcedRdns].some(isNativeMetaMaskRdns);
|
|
240
|
+
});
|
|
241
|
+
var _provider, _detail, _suppressed, _requestHandler, _announcementPromise, _EIP6963ProviderAnnouncer_instances, announceOnce_fn, installRequestProviderListener_fn, dispatchAnnouncement_fn;
|
|
242
|
+
var EIP6963ProviderAnnouncer = class {
|
|
243
|
+
/**
|
|
244
|
+
* Creates an EIP-6963 announcer for one SDK provider instance.
|
|
245
|
+
*
|
|
246
|
+
* @param provider - EIP-1193 provider to announce.
|
|
247
|
+
*/
|
|
248
|
+
constructor(provider) {
|
|
249
|
+
__privateAdd(this, _EIP6963ProviderAnnouncer_instances);
|
|
250
|
+
/** EIP-1193 provider exposed in EIP-6963 announcements. */
|
|
251
|
+
__privateAdd(this, _provider);
|
|
252
|
+
/** Stable announcement payload for this SDK provider instance. */
|
|
253
|
+
__privateAdd(this, _detail);
|
|
254
|
+
/** Whether native MetaMask detection already suppressed this provider. */
|
|
255
|
+
__privateAdd(this, _suppressed, false);
|
|
256
|
+
/** Listener used to re-announce the SDK provider on future requests. */
|
|
257
|
+
__privateAdd(this, _requestHandler);
|
|
258
|
+
/** In-flight announcement detection promise, shared by concurrent calls. */
|
|
259
|
+
__privateAdd(this, _announcementPromise);
|
|
260
|
+
__privateSet(this, _provider, provider);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Announces the SDK provider unless native MetaMask has already announced.
|
|
264
|
+
*
|
|
265
|
+
* Repeated calls are idempotent: once announced, this re-dispatches the same
|
|
266
|
+
* provider detail and does not install duplicate request listeners. The first
|
|
267
|
+
* call may take up to `EIP6963_DETECTION_TIMEOUT_MS` while native providers
|
|
268
|
+
* are requested.
|
|
269
|
+
*
|
|
270
|
+
* @returns A promise that resolves once detection and any announcement finish.
|
|
271
|
+
*/
|
|
272
|
+
announce() {
|
|
273
|
+
return __async(this, null, function* () {
|
|
274
|
+
try {
|
|
275
|
+
if (__privateGet(this, _suppressed)) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (__privateGet(this, _detail)) {
|
|
279
|
+
__privateMethod(this, _EIP6963ProviderAnnouncer_instances, dispatchAnnouncement_fn).call(this);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (!__privateGet(this, _announcementPromise)) {
|
|
283
|
+
__privateSet(this, _announcementPromise, __privateMethod(this, _EIP6963ProviderAnnouncer_instances, announceOnce_fn).call(this).catch((error) => {
|
|
284
|
+
logger("EIP-6963 provider announcement failed", error);
|
|
285
|
+
}).finally(() => {
|
|
286
|
+
__privateSet(this, _announcementPromise, void 0);
|
|
287
|
+
}));
|
|
288
|
+
}
|
|
289
|
+
yield __privateGet(this, _announcementPromise);
|
|
290
|
+
} catch (error) {
|
|
291
|
+
logger("EIP-6963 provider announcement failed", error);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
_provider = new WeakMap();
|
|
297
|
+
_detail = new WeakMap();
|
|
298
|
+
_suppressed = new WeakMap();
|
|
299
|
+
_requestHandler = new WeakMap();
|
|
300
|
+
_announcementPromise = new WeakMap();
|
|
301
|
+
_EIP6963ProviderAnnouncer_instances = new WeakSet();
|
|
302
|
+
announceOnce_fn = function() {
|
|
303
|
+
return __async(this, null, function* () {
|
|
304
|
+
if (!getBrowserWindow()) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (yield hasNativeMetaMaskProvider()) {
|
|
308
|
+
logger("MetaMask EIP-6963 provider is already announced. Skipping...");
|
|
309
|
+
__privateSet(this, _suppressed, true);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
__privateSet(this, _detail, Object.freeze({
|
|
313
|
+
info: createProviderInfo(),
|
|
314
|
+
provider: __privateGet(this, _provider)
|
|
315
|
+
}));
|
|
316
|
+
__privateMethod(this, _EIP6963ProviderAnnouncer_instances, installRequestProviderListener_fn).call(this);
|
|
317
|
+
__privateMethod(this, _EIP6963ProviderAnnouncer_instances, dispatchAnnouncement_fn).call(this);
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Installs a single persistent EIP-6963 request listener for re-announcement.
|
|
322
|
+
*/
|
|
323
|
+
installRequestProviderListener_fn = function() {
|
|
324
|
+
const browserWindow = getBrowserWindow();
|
|
325
|
+
if (!browserWindow || __privateGet(this, _requestHandler)) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
__privateSet(this, _requestHandler, () => {
|
|
329
|
+
try {
|
|
330
|
+
__privateMethod(this, _EIP6963ProviderAnnouncer_instances, dispatchAnnouncement_fn).call(this);
|
|
331
|
+
} catch (error) {
|
|
332
|
+
logger("EIP-6963 provider announcement failed", error);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
browserWindow.addEventListener(
|
|
336
|
+
EIP6963_REQUEST_PROVIDER_EVENT,
|
|
337
|
+
__privateGet(this, _requestHandler)
|
|
338
|
+
);
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* Dispatches the current provider detail through EIP-6963.
|
|
342
|
+
*/
|
|
343
|
+
dispatchAnnouncement_fn = function() {
|
|
344
|
+
const browserWindow = getBrowserWindow();
|
|
345
|
+
if (!browserWindow || !__privateGet(this, _detail)) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
browserWindow.dispatchEvent(createAnnouncementEvent(__privateGet(this, _detail)));
|
|
349
|
+
};
|
|
350
|
+
|
|
133
351
|
// src/provider.ts
|
|
134
352
|
import { EventEmitter, RPCInvokeMethodErr } from "@metamask/connect-multichain";
|
|
135
353
|
import { hexToNumber as hexToNumber2 } from "@metamask/utils";
|
|
@@ -393,7 +611,65 @@ ${invalidUrls.join("\n")}`
|
|
|
393
611
|
// src/connect.ts
|
|
394
612
|
var DEFAULT_CHAIN_ID = "0x1";
|
|
395
613
|
var CHAIN_STORE_KEY = "cache_eth_chainId";
|
|
396
|
-
|
|
614
|
+
function isAnalyticsEnabled(options) {
|
|
615
|
+
var _a;
|
|
616
|
+
return ((_a = options == null ? void 0 : options.analytics) == null ? void 0 : _a.enabled) !== false;
|
|
617
|
+
}
|
|
618
|
+
var createPermissionId = () => {
|
|
619
|
+
var _a;
|
|
620
|
+
if ((_a = globalThis.crypto) == null ? void 0 : _a.randomUUID) {
|
|
621
|
+
return globalThis.crypto.randomUUID();
|
|
622
|
+
}
|
|
623
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
624
|
+
};
|
|
625
|
+
var getDappInvoker = (options) => {
|
|
626
|
+
const { name, nativeScheme, url: dappUrl } = options.dapp;
|
|
627
|
+
const fallbackInvoker = nativeScheme != null ? nativeScheme : name;
|
|
628
|
+
if (!dappUrl) {
|
|
629
|
+
return fallbackInvoker;
|
|
630
|
+
}
|
|
631
|
+
try {
|
|
632
|
+
const { origin } = new URL(dappUrl);
|
|
633
|
+
return origin === "null" ? fallbackInvoker : origin;
|
|
634
|
+
} catch (e) {
|
|
635
|
+
return fallbackInvoker;
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
var getRequestedPermissions = ({
|
|
639
|
+
accounts,
|
|
640
|
+
chainIds,
|
|
641
|
+
invoker
|
|
642
|
+
}) => {
|
|
643
|
+
const id = createPermissionId();
|
|
644
|
+
const date = Date.now();
|
|
645
|
+
return [
|
|
646
|
+
{
|
|
647
|
+
id,
|
|
648
|
+
parentCapability: "eth_accounts",
|
|
649
|
+
invoker,
|
|
650
|
+
caveats: [
|
|
651
|
+
{
|
|
652
|
+
type: "restrictReturnedAccounts",
|
|
653
|
+
value: accounts
|
|
654
|
+
}
|
|
655
|
+
],
|
|
656
|
+
date
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
id,
|
|
660
|
+
parentCapability: "endowment:permitted-chains",
|
|
661
|
+
invoker,
|
|
662
|
+
caveats: [
|
|
663
|
+
{
|
|
664
|
+
type: "restrictNetworkSwitching",
|
|
665
|
+
value: chainIds
|
|
666
|
+
}
|
|
667
|
+
],
|
|
668
|
+
date
|
|
669
|
+
}
|
|
670
|
+
];
|
|
671
|
+
};
|
|
672
|
+
var _core2, _provider2, _eip6963Announcer, _sessionScopes, _eventHandlers, _sessionChangedHandler, _displayUriHandler, _removeNotificationHandler, _status, _pendingPreferredChainId, _MetamaskConnectEVM_instances, getCoreOptions_fn, createInvokeOptions_fn, trackWalletActionRequested_fn, trackWalletActionSucceeded_fn, trackWalletActionFailed_fn, getSelectedChainId_fn, requestInterceptor_fn, clearConnectionState_fn, addEthereumChain_fn, request_fn, cacheChainId_fn, onSessionChanged_fn, onChainChanged_fn, onAccountsChanged_fn, onConnect_fn, onDisconnect_fn, onDisplayUri_fn;
|
|
397
673
|
var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
398
674
|
/**
|
|
399
675
|
* Creates a new MetamaskConnectEVM instance.
|
|
@@ -408,7 +684,9 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
408
684
|
/** The core instance of the Multichain SDK */
|
|
409
685
|
__privateAdd(this, _core2);
|
|
410
686
|
/** An instance of the EIP-1193 provider interface */
|
|
411
|
-
__privateAdd(this,
|
|
687
|
+
__privateAdd(this, _provider2);
|
|
688
|
+
/** Handles EIP-6963 discovery announcements for the provider */
|
|
689
|
+
__privateAdd(this, _eip6963Announcer);
|
|
412
690
|
/** The session scopes currently permitted */
|
|
413
691
|
__privateAdd(this, _sessionScopes, {});
|
|
414
692
|
/** Optional event handlers for the EIP-1193 provider events. */
|
|
@@ -429,10 +707,11 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
429
707
|
*/
|
|
430
708
|
__privateAdd(this, _pendingPreferredChainId);
|
|
431
709
|
__privateSet(this, _core2, core);
|
|
432
|
-
__privateSet(this,
|
|
710
|
+
__privateSet(this, _provider2, new EIP1193Provider(
|
|
433
711
|
core,
|
|
434
712
|
__privateMethod(this, _MetamaskConnectEVM_instances, requestInterceptor_fn).bind(this)
|
|
435
713
|
));
|
|
714
|
+
__privateSet(this, _eip6963Announcer, new EIP6963ProviderAnnouncer(__privateGet(this, _provider2)));
|
|
436
715
|
__privateSet(this, _eventHandlers, eventHandlers);
|
|
437
716
|
__privateSet(this, _sessionChangedHandler, __privateMethod(this, _MetamaskConnectEVM_instances, onSessionChanged_fn).bind(this));
|
|
438
717
|
__privateGet(this, _core2).on("wallet_sessionChanged", __privateGet(this, _sessionChangedHandler));
|
|
@@ -494,7 +773,7 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
494
773
|
try {
|
|
495
774
|
const result = new Promise(
|
|
496
775
|
(resolve) => {
|
|
497
|
-
__privateGet(this,
|
|
776
|
+
__privateGet(this, _provider2).once("connect", ({ chainId, accounts }) => {
|
|
498
777
|
logger("fulfilled-request: connect", {
|
|
499
778
|
chainId,
|
|
500
779
|
accounts
|
|
@@ -540,7 +819,7 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
540
819
|
const { accounts, chainId } = yield this.connect({
|
|
541
820
|
chainIds: chainIds != null ? chainIds : [DEFAULT_CHAIN_ID]
|
|
542
821
|
});
|
|
543
|
-
const signature = yield __privateGet(this,
|
|
822
|
+
const signature = yield __privateGet(this, _provider2).request({
|
|
544
823
|
method: "personal_sign",
|
|
545
824
|
params: [accounts[0], message]
|
|
546
825
|
});
|
|
@@ -579,7 +858,7 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
579
858
|
forceRequest
|
|
580
859
|
});
|
|
581
860
|
const resolvedParams = typeof params === "function" ? params(connectedAccounts[0]) : params;
|
|
582
|
-
const result = yield __privateGet(this,
|
|
861
|
+
const result = yield __privateGet(this, _provider2).request({
|
|
583
862
|
method,
|
|
584
863
|
params: resolvedParams
|
|
585
864
|
});
|
|
@@ -641,15 +920,12 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
641
920
|
yield __privateMethod(this, _MetamaskConnectEVM_instances, trackWalletActionRequested_fn).call(this, method, scope, params);
|
|
642
921
|
try {
|
|
643
922
|
const result = yield __privateMethod(this, _MetamaskConnectEVM_instances, request_fn).call(this, {
|
|
923
|
+
scope,
|
|
644
924
|
method: "wallet_switchEthereumChain",
|
|
645
925
|
params
|
|
646
926
|
});
|
|
647
|
-
const resultWithError = result;
|
|
648
|
-
if (resultWithError == null ? void 0 : resultWithError.error) {
|
|
649
|
-
throw new Error(resultWithError.error.message);
|
|
650
|
-
}
|
|
651
927
|
yield __privateMethod(this, _MetamaskConnectEVM_instances, trackWalletActionSucceeded_fn).call(this, method, scope, params);
|
|
652
|
-
if (result
|
|
928
|
+
if (result === null) {
|
|
653
929
|
yield __privateMethod(this, _MetamaskConnectEVM_instances, cacheChainId_fn).call(this, chainId);
|
|
654
930
|
__privateMethod(this, _MetamaskConnectEVM_instances, onChainChanged_fn).call(this, chainId);
|
|
655
931
|
}
|
|
@@ -672,7 +948,19 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
672
948
|
* @returns The EIP-1193 provider instance
|
|
673
949
|
*/
|
|
674
950
|
getProvider() {
|
|
675
|
-
return __privateGet(this,
|
|
951
|
+
return __privateGet(this, _provider2);
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Announces the EIP-1193 provider through EIP-6963 wallet discovery.
|
|
955
|
+
*
|
|
956
|
+
* This is a no-op when a native MetaMask EIP-6963 provider has already
|
|
957
|
+
* announced, or when running outside a browser environment. The first call
|
|
958
|
+
* may take up to 300 ms while native providers are requested.
|
|
959
|
+
*/
|
|
960
|
+
announceProvider() {
|
|
961
|
+
return __async(this, null, function* () {
|
|
962
|
+
yield __privateGet(this, _eip6963Announcer).announce();
|
|
963
|
+
});
|
|
676
964
|
}
|
|
677
965
|
/**
|
|
678
966
|
* Gets the currently selected chain ID on the wallet
|
|
@@ -688,7 +976,7 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
688
976
|
* @returns The currently selected account or undefined if no account is selected
|
|
689
977
|
*/
|
|
690
978
|
getAccount() {
|
|
691
|
-
return __privateGet(this,
|
|
979
|
+
return __privateGet(this, _provider2).selectedAccount;
|
|
692
980
|
}
|
|
693
981
|
// Convenience getters for the EIP-1193 provider
|
|
694
982
|
/**
|
|
@@ -697,7 +985,7 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
697
985
|
* @returns The currently permitted accounts
|
|
698
986
|
*/
|
|
699
987
|
get accounts() {
|
|
700
|
-
return __privateGet(this,
|
|
988
|
+
return __privateGet(this, _provider2).accounts;
|
|
701
989
|
}
|
|
702
990
|
/**
|
|
703
991
|
* Gets the currently selected account on the wallet
|
|
@@ -705,7 +993,7 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
705
993
|
* @returns The currently selected account or undefined if no account is selected
|
|
706
994
|
*/
|
|
707
995
|
get selectedAccount() {
|
|
708
|
-
return __privateGet(this,
|
|
996
|
+
return __privateGet(this, _provider2).selectedAccount;
|
|
709
997
|
}
|
|
710
998
|
/**
|
|
711
999
|
* Gets the currently selected chain ID on the wallet
|
|
@@ -713,7 +1001,7 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
713
1001
|
* @returns The currently selected chain ID or undefined if no chain is selected
|
|
714
1002
|
*/
|
|
715
1003
|
get selectedChainId() {
|
|
716
|
-
return __privateGet(this,
|
|
1004
|
+
return __privateGet(this, _provider2).selectedChainId;
|
|
717
1005
|
}
|
|
718
1006
|
/**
|
|
719
1007
|
* Gets the current connection status
|
|
@@ -725,7 +1013,8 @@ var _MetamaskConnectEVM = class _MetamaskConnectEVM {
|
|
|
725
1013
|
}
|
|
726
1014
|
};
|
|
727
1015
|
_core2 = new WeakMap();
|
|
728
|
-
|
|
1016
|
+
_provider2 = new WeakMap();
|
|
1017
|
+
_eip6963Announcer = new WeakMap();
|
|
729
1018
|
_sessionScopes = new WeakMap();
|
|
730
1019
|
_eventHandlers = new WeakMap();
|
|
731
1020
|
_sessionChangedHandler = new WeakMap();
|
|
@@ -759,6 +1048,9 @@ createInvokeOptions_fn = function(method, scope, params) {
|
|
|
759
1048
|
trackWalletActionRequested_fn = function(method, scope, params) {
|
|
760
1049
|
return __async(this, null, function* () {
|
|
761
1050
|
const coreOptions = __privateMethod(this, _MetamaskConnectEVM_instances, getCoreOptions_fn).call(this);
|
|
1051
|
+
if (!isAnalyticsEnabled(coreOptions)) {
|
|
1052
|
+
return;
|
|
1053
|
+
}
|
|
762
1054
|
try {
|
|
763
1055
|
const invokeOptions = __privateMethod(this, _MetamaskConnectEVM_instances, createInvokeOptions_fn).call(this, method, scope, params);
|
|
764
1056
|
const props = yield getWalletActionAnalyticsProperties(
|
|
@@ -776,6 +1068,9 @@ trackWalletActionRequested_fn = function(method, scope, params) {
|
|
|
776
1068
|
trackWalletActionSucceeded_fn = function(method, scope, params) {
|
|
777
1069
|
return __async(this, null, function* () {
|
|
778
1070
|
const coreOptions = __privateMethod(this, _MetamaskConnectEVM_instances, getCoreOptions_fn).call(this);
|
|
1071
|
+
if (!isAnalyticsEnabled(coreOptions)) {
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
779
1074
|
try {
|
|
780
1075
|
const invokeOptions = __privateMethod(this, _MetamaskConnectEVM_instances, createInvokeOptions_fn).call(this, method, scope, params);
|
|
781
1076
|
const props = yield getWalletActionAnalyticsProperties(
|
|
@@ -793,6 +1088,9 @@ trackWalletActionSucceeded_fn = function(method, scope, params) {
|
|
|
793
1088
|
trackWalletActionFailed_fn = function(method, scope, params, error) {
|
|
794
1089
|
return __async(this, null, function* () {
|
|
795
1090
|
const coreOptions = __privateMethod(this, _MetamaskConnectEVM_instances, getCoreOptions_fn).call(this);
|
|
1091
|
+
if (!isAnalyticsEnabled(coreOptions)) {
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
796
1094
|
try {
|
|
797
1095
|
const invokeOptions = __privateMethod(this, _MetamaskConnectEVM_instances, createInvokeOptions_fn).call(this, method, scope, params);
|
|
798
1096
|
const props = yield getWalletActionAnalyticsProperties(
|
|
@@ -852,7 +1150,7 @@ requestInterceptor_fn = function(request) {
|
|
|
852
1150
|
if (permitted.length === 0) {
|
|
853
1151
|
permitted.push(DEFAULT_CHAIN_ID);
|
|
854
1152
|
}
|
|
855
|
-
const selected = __privateGet(this,
|
|
1153
|
+
const selected = __privateGet(this, _provider2).selectedChainId;
|
|
856
1154
|
const preferred = selected && permitted.includes(selected) ? selected : permitted[0];
|
|
857
1155
|
const chainIds = [
|
|
858
1156
|
preferred,
|
|
@@ -869,6 +1167,13 @@ requestInterceptor_fn = function(request) {
|
|
|
869
1167
|
if (request.method === "eth_requestAccounts") {
|
|
870
1168
|
return result.accounts;
|
|
871
1169
|
}
|
|
1170
|
+
if (request.method === "wallet_requestPermissions") {
|
|
1171
|
+
return getRequestedPermissions({
|
|
1172
|
+
accounts: result.accounts,
|
|
1173
|
+
chainIds: getPermittedEthChainIds(__privateGet(this, _sessionScopes)),
|
|
1174
|
+
invoker: getDappInvoker(__privateMethod(this, _MetamaskConnectEVM_instances, getCoreOptions_fn).call(this))
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
872
1177
|
return result;
|
|
873
1178
|
} catch (error) {
|
|
874
1179
|
yield __privateMethod(this, _MetamaskConnectEVM_instances, trackWalletActionFailed_fn).call(this, method, scope, params, error);
|
|
@@ -876,21 +1181,23 @@ requestInterceptor_fn = function(request) {
|
|
|
876
1181
|
}
|
|
877
1182
|
}
|
|
878
1183
|
if (isSwitchChainRequest(request)) {
|
|
879
|
-
|
|
1184
|
+
yield this.switchChain({
|
|
880
1185
|
chainId: request.params[0].chainId
|
|
881
1186
|
});
|
|
1187
|
+
return null;
|
|
882
1188
|
}
|
|
883
1189
|
if (isAddChainRequest(request)) {
|
|
884
|
-
|
|
1190
|
+
yield __privateMethod(this, _MetamaskConnectEVM_instances, addEthereumChain_fn).call(this, request.params[0]);
|
|
1191
|
+
return null;
|
|
885
1192
|
}
|
|
886
1193
|
if (isAccountsRequest(request)) {
|
|
887
1194
|
if (request.method === "eth_coinbase") {
|
|
888
|
-
return (_a = __privateGet(this,
|
|
1195
|
+
return (_a = __privateGet(this, _provider2).selectedAccount) != null ? _a : null;
|
|
889
1196
|
}
|
|
890
|
-
return __privateGet(this,
|
|
1197
|
+
return __privateGet(this, _provider2).accounts;
|
|
891
1198
|
}
|
|
892
1199
|
if (isChainIdRequest(request)) {
|
|
893
|
-
return __privateGet(this,
|
|
1200
|
+
return __privateGet(this, _provider2).selectedChainId;
|
|
894
1201
|
}
|
|
895
1202
|
logger("Request not intercepted, forwarding to default handler", request);
|
|
896
1203
|
return Promise.resolve();
|
|
@@ -900,8 +1207,8 @@ requestInterceptor_fn = function(request) {
|
|
|
900
1207
|
* Clears the internal connection state: accounts and chainId
|
|
901
1208
|
*/
|
|
902
1209
|
clearConnectionState_fn = function() {
|
|
903
|
-
__privateGet(this,
|
|
904
|
-
__privateGet(this,
|
|
1210
|
+
__privateGet(this, _provider2).accounts = [];
|
|
1211
|
+
__privateGet(this, _provider2).selectedChainId = void 0;
|
|
905
1212
|
};
|
|
906
1213
|
addEthereumChain_fn = function(chainConfiguration) {
|
|
907
1214
|
return __async(this, null, function* () {
|
|
@@ -910,17 +1217,18 @@ addEthereumChain_fn = function(chainConfiguration) {
|
|
|
910
1217
|
if (!chainConfiguration) {
|
|
911
1218
|
throw new Error("No chain configuration found.");
|
|
912
1219
|
}
|
|
913
|
-
const chainId = chainConfiguration.chainId || __privateGet(this,
|
|
1220
|
+
const chainId = chainConfiguration.chainId || __privateGet(this, _provider2).selectedChainId || "0x1";
|
|
914
1221
|
const decimalChainId = hexToNumber3(chainId);
|
|
915
1222
|
const scope = `eip155:${decimalChainId}`;
|
|
916
1223
|
const params = [chainConfiguration];
|
|
917
1224
|
yield __privateMethod(this, _MetamaskConnectEVM_instances, trackWalletActionRequested_fn).call(this, method, scope, params);
|
|
918
1225
|
try {
|
|
919
1226
|
const result = yield __privateMethod(this, _MetamaskConnectEVM_instances, request_fn).call(this, {
|
|
1227
|
+
scope,
|
|
920
1228
|
method: "wallet_addEthereumChain",
|
|
921
1229
|
params
|
|
922
1230
|
});
|
|
923
|
-
if (result
|
|
1231
|
+
if (result === null) {
|
|
924
1232
|
yield __privateMethod(this, _MetamaskConnectEVM_instances, cacheChainId_fn).call(this, chainId);
|
|
925
1233
|
__privateMethod(this, _MetamaskConnectEVM_instances, onChainChanged_fn).call(this, chainId);
|
|
926
1234
|
}
|
|
@@ -934,7 +1242,10 @@ addEthereumChain_fn = function(chainConfiguration) {
|
|
|
934
1242
|
request_fn = function(request) {
|
|
935
1243
|
return __async(this, null, function* () {
|
|
936
1244
|
logger("direct request to metamask-provider called", request);
|
|
937
|
-
const result = __privateGet(this, _core2).
|
|
1245
|
+
const result = __privateGet(this, _core2).invokeMethod({
|
|
1246
|
+
scope: request.scope,
|
|
1247
|
+
request: { method: request.method, params: request.params }
|
|
1248
|
+
});
|
|
938
1249
|
if (request.method === "wallet_addEthereumChain" || request.method === "wallet_switchEthereumChain") {
|
|
939
1250
|
__privateGet(this, _core2).openSimpleDeeplinkIfNeeded();
|
|
940
1251
|
}
|
|
@@ -964,11 +1275,10 @@ onSessionChanged_fn = function(session) {
|
|
|
964
1275
|
} else {
|
|
965
1276
|
let initialAccounts = [];
|
|
966
1277
|
if (__privateGet(this, _core2).status === "connected") {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
params: []
|
|
1278
|
+
initialAccounts = yield __privateGet(this, _core2).invokeMethod({
|
|
1279
|
+
scope: `eip155:${hexToNumber3(hexPermittedChainIds[0])}`,
|
|
1280
|
+
request: { method: "eth_accounts", params: [] }
|
|
970
1281
|
});
|
|
971
|
-
initialAccounts = ethAccountsResponse.result;
|
|
972
1282
|
} else {
|
|
973
1283
|
initialAccounts = getEthAccounts(__privateGet(this, _sessionScopes));
|
|
974
1284
|
}
|
|
@@ -987,12 +1297,12 @@ onSessionChanged_fn = function(session) {
|
|
|
987
1297
|
*/
|
|
988
1298
|
onChainChanged_fn = function(chainId) {
|
|
989
1299
|
var _a, _b;
|
|
990
|
-
if (chainId === __privateGet(this,
|
|
1300
|
+
if (chainId === __privateGet(this, _provider2).selectedChainId) {
|
|
991
1301
|
return;
|
|
992
1302
|
}
|
|
993
1303
|
logger("handler: chainChanged", { chainId });
|
|
994
|
-
__privateGet(this,
|
|
995
|
-
__privateGet(this,
|
|
1304
|
+
__privateGet(this, _provider2).selectedChainId = chainId;
|
|
1305
|
+
__privateGet(this, _provider2).emit("chainChanged", chainId);
|
|
996
1306
|
(_b = (_a = __privateGet(this, _eventHandlers)) == null ? void 0 : _a.chainChanged) == null ? void 0 : _b.call(_a, chainId);
|
|
997
1307
|
};
|
|
998
1308
|
/**
|
|
@@ -1002,13 +1312,13 @@ onChainChanged_fn = function(chainId) {
|
|
|
1002
1312
|
*/
|
|
1003
1313
|
onAccountsChanged_fn = function(accounts) {
|
|
1004
1314
|
var _a, _b;
|
|
1005
|
-
const accountsUnchanged = accounts.length === __privateGet(this,
|
|
1315
|
+
const accountsUnchanged = accounts.length === __privateGet(this, _provider2).accounts.length && accounts.every((acct, idx) => acct === __privateGet(this, _provider2).accounts[idx]);
|
|
1006
1316
|
if (accountsUnchanged) {
|
|
1007
1317
|
return;
|
|
1008
1318
|
}
|
|
1009
1319
|
logger("handler: accountsChanged", accounts);
|
|
1010
|
-
__privateGet(this,
|
|
1011
|
-
__privateGet(this,
|
|
1320
|
+
__privateGet(this, _provider2).accounts = accounts;
|
|
1321
|
+
__privateGet(this, _provider2).emit("accountsChanged", accounts);
|
|
1012
1322
|
(_b = (_a = __privateGet(this, _eventHandlers)) == null ? void 0 : _a.accountsChanged) == null ? void 0 : _b.call(_a, accounts);
|
|
1013
1323
|
};
|
|
1014
1324
|
/**
|
|
@@ -1033,14 +1343,14 @@ onConnect_fn = function({
|
|
|
1033
1343
|
__privateMethod(this, _MetamaskConnectEVM_instances, onAccountsChanged_fn).call(this, accounts);
|
|
1034
1344
|
return;
|
|
1035
1345
|
}
|
|
1036
|
-
__privateGet(this,
|
|
1037
|
-
__privateGet(this,
|
|
1346
|
+
__privateGet(this, _provider2).selectedChainId = chainId;
|
|
1347
|
+
__privateGet(this, _provider2).accounts = accounts;
|
|
1038
1348
|
__privateSet(this, _status, "connected");
|
|
1039
|
-
__privateGet(this,
|
|
1349
|
+
__privateGet(this, _provider2).emit("connect", data);
|
|
1040
1350
|
(_b = (_a = __privateGet(this, _eventHandlers)) == null ? void 0 : _a.connect) == null ? void 0 : _b.call(_a, data);
|
|
1041
|
-
__privateGet(this,
|
|
1351
|
+
__privateGet(this, _provider2).emit("chainChanged", chainId);
|
|
1042
1352
|
(_d = (_c = __privateGet(this, _eventHandlers)) == null ? void 0 : _c.chainChanged) == null ? void 0 : _d.call(_c, chainId);
|
|
1043
|
-
__privateGet(this,
|
|
1353
|
+
__privateGet(this, _provider2).emit("accountsChanged", accounts);
|
|
1044
1354
|
(_f = (_e = __privateGet(this, _eventHandlers)) == null ? void 0 : _e.accountsChanged) == null ? void 0 : _f.call(_e, accounts);
|
|
1045
1355
|
(_g = __privateGet(this, _removeNotificationHandler)) == null ? void 0 : _g.call(this);
|
|
1046
1356
|
const onAccountsChanged = (accs) => {
|
|
@@ -1072,7 +1382,7 @@ onDisconnect_fn = function() {
|
|
|
1072
1382
|
}
|
|
1073
1383
|
__privateSet(this, _status, "disconnected");
|
|
1074
1384
|
logger("handler: disconnect");
|
|
1075
|
-
__privateGet(this,
|
|
1385
|
+
__privateGet(this, _provider2).emit("disconnect");
|
|
1076
1386
|
(_b = (_a = __privateGet(this, _eventHandlers)) == null ? void 0 : _a.disconnect) == null ? void 0 : _b.call(_a);
|
|
1077
1387
|
__privateMethod(this, _MetamaskConnectEVM_instances, onAccountsChanged_fn).call(this, []);
|
|
1078
1388
|
};
|
|
@@ -1088,13 +1398,13 @@ onDisplayUri_fn = function(uri) {
|
|
|
1088
1398
|
return;
|
|
1089
1399
|
}
|
|
1090
1400
|
logger("handler: display_uri", uri);
|
|
1091
|
-
__privateGet(this,
|
|
1401
|
+
__privateGet(this, _provider2).emit("display_uri", uri);
|
|
1092
1402
|
(_b = (_a = __privateGet(this, _eventHandlers)) == null ? void 0 : _a.displayUri) == null ? void 0 : _b.call(_a, uri);
|
|
1093
1403
|
};
|
|
1094
1404
|
var MetamaskConnectEVM = _MetamaskConnectEVM;
|
|
1095
1405
|
function createEVMClient(options) {
|
|
1096
1406
|
return __async(this, null, function* () {
|
|
1097
|
-
var _a, _b;
|
|
1407
|
+
var _a, _b, _c;
|
|
1098
1408
|
if (options.debug) {
|
|
1099
1409
|
enableDebug();
|
|
1100
1410
|
}
|
|
@@ -1118,21 +1428,33 @@ function createEVMClient(options) {
|
|
|
1118
1428
|
api: {
|
|
1119
1429
|
supportedNetworks: supportedNetworksCaipChainId
|
|
1120
1430
|
},
|
|
1121
|
-
analytics: {
|
|
1431
|
+
analytics: __spreadProps(__spreadValues({}, (_b = options.analytics) != null ? _b : {}), {
|
|
1122
1432
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1123
|
-
integrationType: ((
|
|
1124
|
-
},
|
|
1433
|
+
integrationType: ((_c = options.analytics) == null ? void 0 : _c.integrationType) || "direct"
|
|
1434
|
+
}),
|
|
1125
1435
|
versions: {
|
|
1126
1436
|
// typeof guard needed: Metro (React Native) bundles TS source directly,
|
|
1127
1437
|
// bypassing the tsup build that substitutes __PACKAGE_VERSION__.
|
|
1128
|
-
"connect-evm": false ? "unknown" : "
|
|
1438
|
+
"connect-evm": false ? "unknown" : "2.0.0"
|
|
1129
1439
|
}
|
|
1130
1440
|
}));
|
|
1131
|
-
|
|
1441
|
+
const multichainClientPeerRange = false ? "unknown" : "^1.0.0";
|
|
1442
|
+
if (multichainClientPeerRange !== "unknown" && multichainClientPeerRange !== "" && !satisfies(core.version, multichainClientPeerRange)) {
|
|
1443
|
+
console.warn(
|
|
1444
|
+
`@metamask/connect-evm expected @metamask/connect-multichain version ${multichainClientPeerRange}, but got ${core.version}. This may lead to unexpected behavior.`
|
|
1445
|
+
);
|
|
1446
|
+
}
|
|
1447
|
+
const client = yield MetamaskConnectEVM.create({
|
|
1132
1448
|
core,
|
|
1133
1449
|
eventHandlers: options.eventHandlers,
|
|
1134
1450
|
supportedNetworks: options.api.supportedNetworks
|
|
1135
1451
|
});
|
|
1452
|
+
if (!options.skipAutoAnnounce) {
|
|
1453
|
+
client.announceProvider().catch((error) => {
|
|
1454
|
+
logger("EIP-6963 provider announcement failed", error);
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
return client;
|
|
1136
1458
|
} catch (error) {
|
|
1137
1459
|
console.error("Error creating Metamask Connect/EVM", error);
|
|
1138
1460
|
throw error;
|
|
@@ -1140,6 +1462,8 @@ function createEVMClient(options) {
|
|
|
1140
1462
|
});
|
|
1141
1463
|
}
|
|
1142
1464
|
export {
|
|
1465
|
+
EIP6963_ANNOUNCE_PROVIDER_EVENT,
|
|
1466
|
+
EIP6963_REQUEST_PROVIDER_EVENT,
|
|
1143
1467
|
createEVMClient,
|
|
1144
1468
|
getInfuraRpcUrls
|
|
1145
1469
|
};
|