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

33 lines
924 B
TypeScript
Raw Normal View History

2018-10-02 10:06:26 +02:00
import Keeper from "../keeper/Keeper"
2018-10-05 12:34:31 +02:00
import Logger from "../utils/Logger"
export default class Asset {
2018-10-02 10:06:26 +02:00
private keeper: Keeper
constructor(keeper: Keeper) {
2018-10-02 10:06:26 +02:00
this.keeper = keeper
}
2018-10-05 12:34:31 +02:00
public async isAssetActive(assetId: string): Promise<boolean> {
2018-10-02 10:06:26 +02:00
const {market} = this.keeper
return market.isAssetActive(assetId)
}
2018-10-05 12:34:31 +02:00
public async registerAsset(name: string, description: string,
price: number, publisherAddress: string): Promise<string> {
const {market} = this.keeper
// generate an id
const assetId = await market.generateId(name + description)
Logger.log("Registering: ", assetId)
// register asset in the market
const result = await market.register(assetId, price, publisherAddress)
Logger.log("Registered: ", assetId, "in block", result.blockNumber)
return assetId
}
}