1- import ObjectMultiplex from '@metamask/object-multiplex' ;
2- import { type Duplex , pipeline } from 'readable-stream' ;
1+ import { type Duplex } from 'readable-stream' ;
32
43import type { CAIP294WalletData } from './CAIP294' ;
54import { announceWallet } from './CAIP294' ;
65import { announceProvider as announceEip6963Provider } from './EIP6963' ;
76import { getBuildType } from './extension-provider/createExternalExtensionProvider' ;
87import type { MetaMaskInpageProviderOptions } from './MetaMaskInpageProvider' ;
9- import {
10- MetaMaskInpageProvider ,
11- MetaMaskInpageProviderStreamName ,
12- } from './MetaMaskInpageProvider' ;
8+ import { MetaMaskInpageProvider } from './MetaMaskInpageProvider' ;
139import { shimWeb3 } from './shimWeb3' ;
1410import type { BaseProviderInfo } from './types' ;
1511
@@ -33,18 +29,13 @@ type InitializeProviderOptions = {
3329 * Whether the window.web3 shim should be set.
3430 */
3531 shouldShimWeb3 ?: boolean ;
36- /**
37- * The name of the stream used to connect to the wallet.
38- */
39- jsonRpcStreamName ?: string ;
4032} & MetaMaskInpageProviderOptions ;
4133
4234/**
4335 * Initializes a MetaMaskInpageProvider and (optionally) assigns it as window.ethereum.
4436 *
4537 * @param options - An options bag.
4638 * @param options.connectionStream - A Node.js stream.
47- * @param options.jsonRpcStreamName - The name of the internal JSON-RPC stream.
4839 * @param options.maxEventListeners - The maximum number of event listeners.
4940 * @param options.providerInfo - The EIP-6963 provider info / CAIP-294 wallet data that should be announced if set.
5041 * @param options.shouldSendMetadata - Whether the provider should send page metadata.
@@ -55,30 +46,18 @@ type InitializeProviderOptions = {
5546 */
5647export function initializeProvider ( {
5748 connectionStream,
58- jsonRpcStreamName = MetaMaskInpageProviderStreamName ,
5949 logger = console ,
6050 maxEventListeners = 100 ,
6151 providerInfo,
6252 shouldSendMetadata = true ,
6353 shouldSetOnWindow = true ,
6454 shouldShimWeb3 = false ,
6555} : InitializeProviderOptions ) : MetaMaskInpageProvider {
66- const mux = new ObjectMultiplex ( ) ;
67- pipeline ( connectionStream , mux , connectionStream , ( error : Error | null ) => {
68- let warningMsg = `Lost connection to "${ jsonRpcStreamName } ".` ;
69- if ( error ?. stack ) {
70- warningMsg += `\n${ error . stack } ` ;
71- }
72- console . warn ( warningMsg ) ;
56+ const provider = new MetaMaskInpageProvider ( connectionStream , {
57+ logger,
58+ maxEventListeners,
59+ shouldSendMetadata,
7360 } ) ;
74- const provider = new MetaMaskInpageProvider (
75- mux . createStream ( jsonRpcStreamName ) ,
76- {
77- logger,
78- maxEventListeners,
79- shouldSendMetadata,
80- } ,
81- ) ;
8261
8362 const proxiedProvider = new Proxy ( provider , {
8463 // some common libraries, e.g. web3@1.x, mess with our API
0 commit comments