mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Merge pull request #366 from oceanprotocol/feature/ethereum-navigator
switch to @ethereum-navigator for network lookup
This commit is contained in:
commit
f8fda3b326
14
package-lock.json
generated
14
package-lock.json
generated
@ -229,6 +229,20 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"@ethereum-navigator/atlas": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@ethereum-navigator/atlas/-/atlas-0.5.1.tgz",
|
||||
"integrity": "sha512-ZK8S30ITBolyJaJp0DQNcf8Ish+hPHdJ9otlaIyJUbRXSfzPyPNBeP3NbYG9pxDDrYvfxy/07HH1tUcsRecrIA=="
|
||||
},
|
||||
"@ethereum-navigator/navigator": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@ethereum-navigator/navigator/-/navigator-0.4.1.tgz",
|
||||
"integrity": "sha512-wOLlwiJprq6fAJETCM1dG1kft2UxXOSr2qU5ZxCkX0uRqL6mikUTZVAJif9e5HgL+EzVFI4/u03rpoGzljriWw==",
|
||||
"requires": {
|
||||
"@ethereum-navigator/atlas": "~0.5.1",
|
||||
"web3": "^1.2.4"
|
||||
}
|
||||
},
|
||||
"@iarna/toml": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.3.tgz",
|
||||
|
@ -51,6 +51,7 @@
|
||||
"web3": "^1.2.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ethereum-navigator/navigator": "^0.4.1",
|
||||
"@oceanprotocol/keeper-contracts": "^0.13.2",
|
||||
"@oceanprotocol/secret-store-client": "^0.0.15",
|
||||
"bignumber.js": "^9.0.0",
|
||||
|
1
src/@types/node_modules.d.ts
vendored
Normal file
1
src/@types/node_modules.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare module '@ethereum-navigator/navigator'
|
@ -1,3 +1,4 @@
|
||||
import { lookup } from '@ethereum-navigator/navigator'
|
||||
import { ContractBase } from './contracts/ContractBase'
|
||||
|
||||
import DIDRegistry from './contracts/DIDRegistry'
|
||||
@ -234,36 +235,10 @@ export class Keeper extends Instantiable {
|
||||
* Returns the network by name.
|
||||
* @return {Promise<string>} Network name.
|
||||
*/
|
||||
public getNetworkName(): Promise<string> {
|
||||
public async getNetworkName(): Promise<string> {
|
||||
return this.web3.eth.net.getId().then((networkId: number) => {
|
||||
switch (networkId) {
|
||||
case 1:
|
||||
return 'Main'
|
||||
case 2:
|
||||
return 'Morden'
|
||||
case 3:
|
||||
return 'Ropsten'
|
||||
case 4:
|
||||
return 'Rinkeby'
|
||||
case 77:
|
||||
return 'POA_Sokol'
|
||||
case 99:
|
||||
return 'POA_Core'
|
||||
case 42:
|
||||
return 'Kovan'
|
||||
case 100:
|
||||
return 'xDai'
|
||||
case 2199:
|
||||
return 'Duero'
|
||||
case 8996:
|
||||
return 'Spree'
|
||||
case 8995:
|
||||
return 'Nile'
|
||||
case 0xcea11:
|
||||
return 'Pacific'
|
||||
default:
|
||||
return 'Development'
|
||||
}
|
||||
const network = lookup(networkId)
|
||||
return network && network.name ? network.name : 'Development'
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user