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

57 lines
1.7 KiB
TypeScript

import OceanAuth from "./contracts/Auth"
import OceanMarket from "./contracts/Market"
import ServiceAgreement from "./contracts/ServiceAgreement"
import OceanToken from "./contracts/Token"
import Web3Provider from "./Web3Provider"
export default class Keeper {
public static async getInstance() {
if (Keeper.instance === null) {
Keeper.instance = new Keeper()
Keeper.instance.market = await OceanMarket.getInstance()
Keeper.instance.auth = await OceanAuth.getInstance()
Keeper.instance.token = await OceanToken.getInstance()
Keeper.instance.serviceAgreement = await ServiceAgreement.getInstance()
}
return Keeper.instance
}
private static instance: Keeper = null
public token: OceanToken
public market: OceanMarket
public auth: OceanAuth
public serviceAgreement: ServiceAgreement
public async getNetworkName(): Promise<string> {
return Web3Provider.getWeb3().eth.net.getId()
.then((networkId) => {
let network: string = "unknown"
switch (networkId) {
case 1:
network = "Main"
break
case 2:
network = "Morden"
break
case 3:
network = "Ropsten"
break
case 4:
network = "Rinkeby"
break
case 42:
network = "Kovan"
break
default:
network = "development"
}
return network
})
}
}