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

Merge pull request #72 from oceanprotocol/feature/verbose

Feature/verbose
This commit is contained in:
Sebastian Gerske 2018-12-12 07:44:34 +01:00 committed by GitHub
commit 66ab665e62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 33 additions and 9 deletions

View File

@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.1
current_version = 0.2.2
[bumpversion:file:package.json]

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@oceanprotocol/squid",
"version": "0.2.1",
"version": "0.2.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@oceanprotocol/squid",
"version": "0.2.1",
"version": "0.2.2",
"description": "JavaScript client library for Ocean Protocol",
"main": "./dist/node/squid.js",
"browser": "./dist/browser/squid.cjs2.min.js",

View File

@ -6,5 +6,6 @@
"secretStoreUri": "http://localhost:12001",
"threshold": 0,
"password": "secret",
"address": "0xa99d43d86a0758d5632313b8fa3972b6088a21bb"
"address": "0xa99d43d86a0758d5632313b8fa3972b6088a21bb",
"verbose": false
}

View File

@ -1,4 +1,5 @@
import Contract from "web3-eth-contract"
import ConfigProvider from "../ConfigProvider"
import Logger from "../utils/Logger"
import Keeper from "./Keeper"
import Web3Provider from "./Web3Provider"
@ -27,7 +28,9 @@ export default class ContractHandler {
private static async load(what: string, where: string): Promise<Contract> {
const web3 = Web3Provider.getWeb3()
// Logger.log("Loading", what, "from", where)
if (ConfigProvider.getConfig().verbose) {
Logger.log("Loading", what, "from", where)
}
const artifact = require(`@oceanprotocol/keeper-contracts/artifacts/${what}.${where}.json`)
// Logger.log('Loaded artifact', artifact)
const code = await web3.eth.getCode(artifact.address)
@ -35,9 +38,12 @@ export default class ContractHandler {
// no code in the blockchain dude
throw new Error(`No code deployed at address ${artifact.address}, sorry.`)
}
// Logger.log("Getting instance of", what, "from", where, "at", artifact.address)
const contract = new web3.eth.Contract(artifact.abi, artifact.address)
Logger.log("Loaded", what, "from", where)
if (ConfigProvider.getConfig().verbose) {
Logger.log("Getting instance of", what, "from", where, "at address", artifact.address)
} else {
Logger.log("Loaded", what, "from", where)
}
ContractHandler.contracts.set(what, contract)
return ContractHandler.contracts.get(what)
}

View File

@ -24,4 +24,7 @@ export default class Config {
public address: string
// the number of nodes in the secret store that have to agree on changes
public threshold: number
/* Squid config */
public verbose: boolean = false
}

View File

@ -1,3 +1,4 @@
import ConfigProvider from "../../ConfigProvider"
import Condition from "../../ddo/Condition"
import DDO from "../../ddo/DDO"
import Service from "../../ddo/Service"
@ -16,7 +17,9 @@ export default class ServiceAgreement extends OceanBase {
serviceAgreementId: string,
consumer: Account): Promise<string> {
// Logger.log("signing SA", serviceAgreementId)
if (ConfigProvider.getConfig().verbose) {
Logger.log("Signing SA with serviceAgreementId", serviceAgreementId)
}
const service: Service = ddo.findServiceById(serviceDefinitionId)
const values: ValuePair[][] = ServiceAgreement.getValuesFromService(service, serviceAgreementId)
@ -26,6 +29,10 @@ export default class ServiceAgreement extends OceanBase {
const serviceAgreementHashSignature = await ServiceAgreement.createSAHashSignature(service, serviceAgreementId,
valueHashes, timeoutValues, consumer)
if (ConfigProvider.getConfig().verbose) {
Logger.log("SA hash signature:", serviceAgreementHashSignature)
}
return serviceAgreementHashSignature
}
@ -37,7 +44,9 @@ export default class ServiceAgreement extends OceanBase {
consumer: Account,
publisher: Account): Promise<ServiceAgreement> {
// Logger.log("executing SA", serviceAgreementId)
if (ConfigProvider.getConfig().verbose) {
Logger.log("Executing SA with serviceAgreementId", serviceAgreementId)
}
const service: Service = ddo.findServiceById(serviceDefinitionId)
const values: ValuePair[][] = ServiceAgreement.getValuesFromService(service, serviceAgreementId)

View File

@ -1,3 +1,4 @@
import ConfigProvider from "../../ConfigProvider"
import DDOCondition from "../../ddo/Condition"
import Dependency from "../../ddo/Dependency"
import MetaData from "../../ddo/MetaData"
@ -169,6 +170,10 @@ export default class ServiceAgreementTemplate extends OceanBase {
} as Condition
})
if (ConfigProvider.getConfig().verbose) {
Logger.log("Conditions", JSON.stringify(conditions, null, 2))
}
return conditions
}