diff --git a/index.js b/index.js index 6cebca02..77e1f945 100644 --- a/index.js +++ b/index.js @@ -17,6 +17,7 @@ function MetamaskInpageProvider (connectionStream) { const self = this self.selectedAddress = undefined self.networkVersion = undefined + self.chainId = undefined // super constructor SafeEventEmitter.call(self) @@ -47,6 +48,12 @@ function MetamaskInpageProvider (connectionStream) { self.networkVersion = state.networkVersion self.emit('networkChanged', state.networkVersion) } + + // Emit networkChanged event on network change + if ('chainId' in state && state.chainId !== self.chainId) { + self.chainId = state.chainId + self.emit('chainIdChanged', state.chainId) + } }) pump(