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

apply changes on examples

This commit is contained in:
Pedro Gutiérrez 2019-02-04 18:04:23 +01:00 committed by Pedro Gutiérrez
parent c24aea4bda
commit f557fccd29
7 changed files with 49 additions and 53 deletions

View File

@ -1,7 +1,6 @@
import DDO from "../ddo/DDO" import { DDO } from "../ddo/DDO"
import MetaData from "../ddo/MetaData" import { MetaData } from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase" import { Service } from "../ddo/Service"
import Service from "../ddo/Service"
import DID from "../ocean/DID" import DID from "../ocean/DID"
import {Account, Logger, Ocean, ServiceAgreement} from "../squid" import {Account, Logger, Ocean, ServiceAgreement} from "../squid"
import config from "./config" import config from "./config"
@ -11,9 +10,10 @@ async function exec() {
const ocean: Ocean = await Ocean.getInstance(config) const ocean: Ocean = await Ocean.getInstance(config)
const publisher: Account = (await ocean.getAccounts())[0] const publisher: Account = (await ocean.getAccounts())[0]
publisher.setPassword('node0')
const consumer: Account = (await ocean.getAccounts())[1] const consumer: Account = (await ocean.getAccounts())[1]
const metaData = new MetaData({ const metaData: Partial<MetaData> = <any>{
base: { base: {
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
@ -40,10 +40,10 @@ async function exec() {
inLanguage: "en", inLanguage: "en",
tags: "weather, uk, 2011, temperature, humidity", tags: "weather, uk, 2011, temperature, humidity",
price: 10, price: 10,
} as MetaDataBase, },
} as MetaData) }
const ddo: DDO = await ocean.registerAsset(metaData, publisher) const ddo: DDO = await ocean.registerAsset(<any>metaData, publisher)
Logger.log("did", ddo.id) Logger.log("did", ddo.id)
const did: DID = DID.parse(ddo.id) const did: DID = DID.parse(ddo.id)

View File

@ -1,7 +1,6 @@
import DDO from "../ddo/DDO" import { DDO } from "../ddo/DDO"
import MetaData from "../ddo/MetaData" import { MetaData } from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase" import { Service } from "../ddo/Service"
import Service from "../ddo/Service"
import {Account, Logger, Ocean, ServiceAgreement} from "../squid" import {Account, Logger, Ocean, ServiceAgreement} from "../squid"
import config from "./config" import config from "./config"
import {runner} from "./runner" import {runner} from "./runner"
@ -10,9 +9,10 @@ async function exec() {
const ocean: Ocean = await Ocean.getInstance(config) const ocean: Ocean = await Ocean.getInstance(config)
const publisher: Account = (await ocean.getAccounts())[0] const publisher: Account = (await ocean.getAccounts())[0]
publisher.setPassword('node0')
const consumer: Account = (await ocean.getAccounts())[1] const consumer: Account = (await ocean.getAccounts())[1]
const metaData = new MetaData({ const metaData: Partial<MetaData> = <any>{
base: { base: {
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
@ -39,10 +39,10 @@ async function exec() {
inLanguage: "en", inLanguage: "en",
tags: "weather, uk, 2011, temperature, humidity", tags: "weather, uk, 2011, temperature, humidity",
price: 10, price: 10,
} as MetaDataBase, },
} as MetaData) }
const ddo: DDO = await ocean.registerAsset(metaData, publisher) const ddo: DDO = await ocean.registerAsset(<any>metaData, publisher)
Logger.log("did", ddo.id) Logger.log("did", ddo.id)
const accessService = ddo.findServiceByType("Access") const accessService = ddo.findServiceByType("Access")

View File

@ -1,7 +1,6 @@
import DDO from "../ddo/DDO" import { DDO } from "../ddo/DDO"
import MetaData from "../ddo/MetaData" import { MetaData } from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase" import { Service } from "../ddo/Service"
import Service from "../ddo/Service"
import DID from "../ocean/DID" import DID from "../ocean/DID"
import {Account, Logger, Ocean, ServiceAgreement} from "../squid" import {Account, Logger, Ocean, ServiceAgreement} from "../squid"
import config from "./config" import config from "./config"
@ -11,9 +10,10 @@ async function exec() {
const ocean: Ocean = await Ocean.getInstance(config) const ocean: Ocean = await Ocean.getInstance(config)
const publisher: Account = (await ocean.getAccounts())[0] const publisher: Account = (await ocean.getAccounts())[0]
publisher.setPassword('node0')
const consumer: Account = (await ocean.getAccounts())[1] const consumer: Account = (await ocean.getAccounts())[1]
const metaData = new MetaData({ const metaData: Partial<MetaData> = <any>{
base: { base: {
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
@ -40,10 +40,10 @@ async function exec() {
inLanguage: "en", inLanguage: "en",
tags: "weather, uk, 2011, temperature, humidity", tags: "weather, uk, 2011, temperature, humidity",
price: 10, price: 10,
} as MetaDataBase, },
} as MetaData) }
const ddo: DDO = await ocean.registerAsset(metaData, publisher) const ddo: DDO = await ocean.registerAsset(<any>metaData, publisher)
Logger.log("did", ddo.id) Logger.log("did", ddo.id)
const did: DID = DID.parse(ddo.id) const did: DID = DID.parse(ddo.id)

View File

@ -1,7 +1,6 @@
import DDO from "../ddo/DDO" import { DDO } from "../ddo/DDO"
import MetaData from "../ddo/MetaData" import { MetaData } from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase" import { Service } from "../ddo/Service"
import Service from "../ddo/Service"
import {Account, Logger, Ocean} from "../squid" import {Account, Logger, Ocean} from "../squid"
import config from "./config" import config from "./config"
import {runner} from "./runner" import {runner} from "./runner"
@ -12,7 +11,7 @@ async function exec() {
const publisher: Account = (await ocean.getAccounts())[1] const publisher: Account = (await ocean.getAccounts())[1]
const consumer: Account = (await ocean.getAccounts())[1] const consumer: Account = (await ocean.getAccounts())[1]
const metaData = new MetaData({ const metaData: Partial<MetaData> = <any>{
base: { base: {
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
@ -38,10 +37,10 @@ async function exec() {
inLanguage: "en", inLanguage: "en",
tags: "weather, uk, 2011, temperature, humidity", tags: "weather, uk, 2011, temperature, humidity",
price: 10, price: 10,
} as MetaDataBase, },
} as MetaData) }
const ddo: DDO = await ocean.registerAsset(metaData, publisher) const ddo: DDO = await ocean.registerAsset(<any>metaData, publisher)
Logger.log("Registered asset with did:", ddo.id) Logger.log("Registered asset with did:", ddo.id)
const accessService = ddo.findServiceByType("Access") const accessService = ddo.findServiceByType("Access")

View File

@ -1,7 +1,6 @@
import DDO from "../ddo/DDO" import { DDO } from "../ddo/DDO"
import MetaData from "../ddo/MetaData" import { MetaData } from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase" import { Account, Logger, Ocean } from "../squid"
import {Account, Logger, Ocean} from "../squid"
import config from "./config" import config from "./config"
import {runner} from "./runner" import {runner} from "./runner"
@ -9,8 +8,9 @@ async function exec() {
const ocean: Ocean = await Ocean.getInstance(config) const ocean: Ocean = await Ocean.getInstance(config)
const publisher: Account = (await ocean.getAccounts())[0] const publisher: Account = (await ocean.getAccounts())[0]
publisher.setPassword('node0')
const metaData = new MetaData({ const metaData: Partial<MetaData> = <any>{
base: { base: {
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
@ -37,10 +37,10 @@ async function exec() {
inLanguage: "en", inLanguage: "en",
tags: "weather, uk, 2011, temperature, humidity", tags: "weather, uk, 2011, temperature, humidity",
price: 10, price: 10,
} as MetaDataBase, },
} as MetaData) }
const ddo: DDO = await ocean.registerAsset(metaData, publisher) const ddo: DDO = await ocean.registerAsset(<any>metaData, publisher)
Logger.log(ddo.id) Logger.log(ddo.id)
} }

View File

@ -1,4 +1,4 @@
import DDO from "../ddo/DDO" import { DDO } from "../ddo/DDO"
import {Logger, Ocean} from "../squid" import {Logger, Ocean} from "../squid"
import config from "./config" import config from "./config"
import {runner} from "./runner" import {runner} from "./runner"

View File

@ -1,9 +1,6 @@
import AdditionalInformation from "../ddo/AdditionalInformation" import { DDO } from "../ddo/DDO"
import Curation from "../ddo/Curation" import { MetaData } from "../ddo/MetaData"
import DDO from "../ddo/DDO" import { Service } from "../ddo/Service"
import MetaData from "../ddo/MetaData"
import MetaDataBase from "../ddo/MetaDataBase"
import Service from "../ddo/Service"
import {Account, Logger, Ocean} from "../squid" import {Account, Logger, Ocean} from "../squid"
import config from "./config" import config from "./config"
import {runner} from "./runner" import {runner} from "./runner"
@ -14,7 +11,7 @@ async function exec() {
const publisher: Account = (await ocean.getAccounts())[0] const publisher: Account = (await ocean.getAccounts())[0]
const consumer: Account = (await ocean.getAccounts())[1] const consumer: Account = (await ocean.getAccounts())[1]
const metaData = { const metaData: MetaData = {
additionalInformation: { additionalInformation: {
structuredMarkup: [ structuredMarkup: [
{ {
@ -28,8 +25,8 @@ async function exec() {
], ],
updateFrecuency: "yearly", updateFrecuency: "yearly",
checksum: "efdd14d39feb726e321931f408b3454d26f1a4899bcc608a68b5397f23203174", checksum: "efdd14d39feb726e321931f408b3454d26f1a4899bcc608a68b5397f23203174",
} as AdditionalInformation, },
base: { base: <any>{
name: "Office Humidity", name: "Office Humidity",
type: "dataset", type: "dataset",
description: "Weather information of UK including temperature and humidity", description: "Weather information of UK including temperature and humidity",
@ -55,15 +52,15 @@ async function exec() {
inLanguage: "en", inLanguage: "en",
tags: "weather, uk, 2011, temperature, humidity", tags: "weather, uk, 2011, temperature, humidity",
price: 10, price: 10,
} as MetaDataBase, },
curation: { curation: {
rating: 0.94, rating: 0.94,
numVotes: 124, numVotes: 124,
schema: "Binary Votting", schema: "Binary Votting",
} as Curation, },
} }
const ddo: DDO = await ocean.registerAsset(metaData as MetaData, publisher) const ddo: DDO = await ocean.registerAsset(metaData, publisher)
Logger.log("did", ddo.id) Logger.log("did", ddo.id)
const accessService: Service = ddo.findServiceByType("Access") const accessService: Service = ddo.findServiceByType("Access")