1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

use promise function of getId

This commit is contained in:
Sebastian Gerske 2018-10-05 10:59:48 +02:00
parent 84c5796dc0
commit 543af59cf3

View File

@ -34,14 +34,10 @@ export default class Web3Helper {
} }
public async getNetworkName(): Promise<string> { public async getNetworkName(): Promise<string> {
return new Promise<string>((resolve, reject) => { return this.web3.eth.net.getId()
.then((networkId) => {
let network: string = "unknown" let network: string = "unknown"
this.web3.eth.net.getId((err, networkId) => {
if (err) {
reject(err)
throw err
}
switch (networkId) { switch (networkId) {
case 1: case 1:
network = "Main" network = "Main"
@ -61,8 +57,7 @@ export default class Web3Helper {
default: default:
network = "development" network = "development"
} }
resolve(network) return network
})
}) })
} }