Skip to content

Commit

Permalink
v1.0.2: Fixed bug with incorrect network
Browse files Browse the repository at this point in the history
  • Loading branch information
Alirun committed Nov 26, 2020
1 parent c8b4d06 commit e6ac959
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opiumteam/mobx-web3",
"version": "1.0.1",
"version": "1.0.2",
"description": "Opium mobx-web3",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
5 changes: 5 additions & 0 deletions src/Classes/Blockchain.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export class BlockchainStore {
return this._blockchain.currentNetworkName
}

@computed
get requiredNetworkName () {
return this._blockchain.requiredNetworkName
}

@computed
get correctNetwork () {
return this._blockchain.correctNetwork
Expand Down
9 changes: 7 additions & 2 deletions src/Classes/Blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Blockchain {
protected _log: any
protected _injectedWalletChangesRefreshTime: number = 1000
@observable protected _networkId = 0
@observable protected _requiredNetworkId = 0
public providerName: ProviderName | null = null
public providerType: ProviderType | null = null

Expand All @@ -49,7 +50,7 @@ class Blockchain {

@computed
get correctNetwork() {
return this._networkId === this._networkId
return this._networkId === this._requiredNetworkId
}

@computed
Expand All @@ -60,7 +61,7 @@ class Blockchain {

@computed
get requiredNetworkName() {
return NETWORK_NAMES[this._networkId]
return NETWORK_NAMES[this._requiredNetworkId]
}

constructor(networkId: number, networkName: string, infuraId: string, fortmaticKey: string, infuraWs: string, logger: any) {
Expand All @@ -84,6 +85,8 @@ class Blockchain {
})

this._networkId = networkId
this._requiredNetworkId = networkId

this._log = logger

this._web3ws = new Web3(
Expand Down Expand Up @@ -274,6 +277,8 @@ class Blockchain {
// TODO: when implemented this._provider.wc.close
break
}

// TODO: Clear provider, types, web3, etc
}

public subscribeNewBlockHeaders = (_callback: () => void) => {
Expand Down

0 comments on commit e6ac959

Please sign in to comment.