Skip to content

Commit e936982

Browse files
authored
Use _handleConnect for initial 'connect' event (#214)
We were basically re-implementing the logic of `_handleConnect` by setting up a listener in the `BaseProvider` constructor that we never tore down. This PR just uses the dedicated handler for the event like nature intended.
1 parent a6e3b8a commit e936982

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ module.exports = {
2020
coveragePathIgnorePatterns: ['/node_modules/', '/mocks/', '/test/'],
2121
coverageThreshold: {
2222
global: {
23-
branches: 56.19,
24-
functions: 53.33,
25-
lines: 58.44,
26-
statements: 58.73,
23+
branches: 55.75,
24+
functions: 52.81,
25+
lines: 58.22,
26+
statements: 58.52,
2727
},
2828
},
2929
projects: [

src/BaseProvider.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ export abstract class BaseProvider extends SafeEventEmitter {
131131
this._rpcRequest = this._rpcRequest.bind(this);
132132
this.request = this.request.bind(this);
133133

134-
// EIP-1193 connect, emitted in _initializeState
135-
this.on('connect', () => {
136-
this._state.isConnected = true;
137-
});
138-
139134
// Handle RPC requests via dapp-side RPC engine.
140135
//
141136
// ATTN: Implementers must push a middleware that hands off requests to
@@ -233,8 +228,7 @@ export abstract class BaseProvider extends SafeEventEmitter {
233228
const { accounts, chainId, isUnlocked, networkVersion } = initialState;
234229

235230
// EIP-1193 connect
236-
this.emit('connect', { chainId });
237-
231+
this._handleConnect(chainId);
238232
this._handleChainChanged({ chainId, networkVersion });
239233
this._handleUnlockStateChanged({ accounts, isUnlocked });
240234
this._handleAccountsChanged(accounts);

0 commit comments

Comments
 (0)