2019-06-20 00:20:09 +02:00
|
|
|
import { Instantiable, InstantiableConfig } from '../../Instantiable.abstract'
|
2019-03-28 12:20:22 +01:00
|
|
|
|
2020-01-27 19:14:12 +01:00
|
|
|
import { ServiceUtils } from './ServiceUtils'
|
2019-06-20 00:20:09 +02:00
|
|
|
import { ServiceAgreement } from './ServiceAgreement'
|
|
|
|
import { SignatureUtils } from './SignatureUtils'
|
|
|
|
import { WebServiceConnector } from './WebServiceConnector'
|
2019-03-28 12:20:22 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Utils internal submodule of Ocean Protocol.
|
|
|
|
*/
|
|
|
|
export class OceanUtils extends Instantiable {
|
|
|
|
/**
|
|
|
|
* Returns the instance of OceanUtils.
|
|
|
|
* @return {Promise<OceanUtils>}
|
|
|
|
*/
|
2019-09-09 12:18:54 +02:00
|
|
|
public static async getInstance(config: InstantiableConfig): Promise<OceanUtils> {
|
2019-03-28 12:20:22 +01:00
|
|
|
const instance = new OceanUtils()
|
|
|
|
instance.setInstanceConfig(config)
|
|
|
|
|
2020-01-15 15:58:44 +01:00
|
|
|
instance.agreements = new ServiceAgreement(
|
|
|
|
config.ocean,
|
|
|
|
config.logger,
|
|
|
|
config.web3
|
|
|
|
)
|
2020-01-27 19:14:12 +01:00
|
|
|
instance.services = new ServiceUtils(config.ocean, config.logger)
|
2020-01-15 10:33:42 +01:00
|
|
|
instance.signature = new SignatureUtils(config.web3, config.logger)
|
|
|
|
instance.fetch = new WebServiceConnector(config.logger)
|
2019-03-28 12:20:22 +01:00
|
|
|
|
|
|
|
return instance
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Agreement utils.
|
|
|
|
* @type {ServiceAgreement}
|
|
|
|
*/
|
|
|
|
public agreements: ServiceAgreement
|
|
|
|
|
2020-01-27 19:14:12 +01:00
|
|
|
/**
|
|
|
|
* Service utils.
|
|
|
|
* @type {ServiceUtils}
|
|
|
|
*/
|
|
|
|
public services: ServiceUtils
|
|
|
|
|
2019-03-28 12:20:22 +01:00
|
|
|
/**
|
|
|
|
* Signature utils.
|
|
|
|
* @type {SignatureUtils}
|
|
|
|
*/
|
|
|
|
public signature: SignatureUtils
|
2019-05-08 14:14:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetch utils.
|
|
|
|
* @type {WebServiceConnector}
|
|
|
|
*/
|
|
|
|
public fetch: WebServiceConnector
|
2019-03-28 12:20:22 +01:00
|
|
|
}
|