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:
commit
66ab665e62
@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.2.1
|
current_version = 0.2.2
|
||||||
|
|
||||||
[bumpversion:file:package.json]
|
[bumpversion:file:package.json]
|
||||||
|
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@oceanprotocol/squid",
|
"name": "@oceanprotocol/squid",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@oceanprotocol/squid",
|
"name": "@oceanprotocol/squid",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"description": "JavaScript client library for Ocean Protocol",
|
"description": "JavaScript client library for Ocean Protocol",
|
||||||
"main": "./dist/node/squid.js",
|
"main": "./dist/node/squid.js",
|
||||||
"browser": "./dist/browser/squid.cjs2.min.js",
|
"browser": "./dist/browser/squid.cjs2.min.js",
|
||||||
|
@ -6,5 +6,6 @@
|
|||||||
"secretStoreUri": "http://localhost:12001",
|
"secretStoreUri": "http://localhost:12001",
|
||||||
"threshold": 0,
|
"threshold": 0,
|
||||||
"password": "secret",
|
"password": "secret",
|
||||||
"address": "0xa99d43d86a0758d5632313b8fa3972b6088a21bb"
|
"address": "0xa99d43d86a0758d5632313b8fa3972b6088a21bb",
|
||||||
|
"verbose": false
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Contract from "web3-eth-contract"
|
import Contract from "web3-eth-contract"
|
||||||
|
import ConfigProvider from "../ConfigProvider"
|
||||||
import Logger from "../utils/Logger"
|
import Logger from "../utils/Logger"
|
||||||
import Keeper from "./Keeper"
|
import Keeper from "./Keeper"
|
||||||
import Web3Provider from "./Web3Provider"
|
import Web3Provider from "./Web3Provider"
|
||||||
@ -27,7 +28,9 @@ export default class ContractHandler {
|
|||||||
|
|
||||||
private static async load(what: string, where: string): Promise<Contract> {
|
private static async load(what: string, where: string): Promise<Contract> {
|
||||||
const web3 = Web3Provider.getWeb3()
|
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`)
|
const artifact = require(`@oceanprotocol/keeper-contracts/artifacts/${what}.${where}.json`)
|
||||||
// Logger.log('Loaded artifact', artifact)
|
// Logger.log('Loaded artifact', artifact)
|
||||||
const code = await web3.eth.getCode(artifact.address)
|
const code = await web3.eth.getCode(artifact.address)
|
||||||
@ -35,9 +38,12 @@ export default class ContractHandler {
|
|||||||
// no code in the blockchain dude
|
// no code in the blockchain dude
|
||||||
throw new Error(`No code deployed at address ${artifact.address}, sorry.`)
|
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)
|
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)
|
ContractHandler.contracts.set(what, contract)
|
||||||
return ContractHandler.contracts.get(what)
|
return ContractHandler.contracts.get(what)
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,7 @@ export default class Config {
|
|||||||
public address: string
|
public address: string
|
||||||
// the number of nodes in the secret store that have to agree on changes
|
// the number of nodes in the secret store that have to agree on changes
|
||||||
public threshold: number
|
public threshold: number
|
||||||
|
|
||||||
|
/* Squid config */
|
||||||
|
public verbose: boolean = false
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import ConfigProvider from "../../ConfigProvider"
|
||||||
import Condition from "../../ddo/Condition"
|
import Condition from "../../ddo/Condition"
|
||||||
import DDO from "../../ddo/DDO"
|
import DDO from "../../ddo/DDO"
|
||||||
import Service from "../../ddo/Service"
|
import Service from "../../ddo/Service"
|
||||||
@ -16,7 +17,9 @@ export default class ServiceAgreement extends OceanBase {
|
|||||||
serviceAgreementId: string,
|
serviceAgreementId: string,
|
||||||
consumer: Account): Promise<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 service: Service = ddo.findServiceById(serviceDefinitionId)
|
||||||
const values: ValuePair[][] = ServiceAgreement.getValuesFromService(service, serviceAgreementId)
|
const values: ValuePair[][] = ServiceAgreement.getValuesFromService(service, serviceAgreementId)
|
||||||
@ -26,6 +29,10 @@ export default class ServiceAgreement extends OceanBase {
|
|||||||
const serviceAgreementHashSignature = await ServiceAgreement.createSAHashSignature(service, serviceAgreementId,
|
const serviceAgreementHashSignature = await ServiceAgreement.createSAHashSignature(service, serviceAgreementId,
|
||||||
valueHashes, timeoutValues, consumer)
|
valueHashes, timeoutValues, consumer)
|
||||||
|
|
||||||
|
if (ConfigProvider.getConfig().verbose) {
|
||||||
|
Logger.log("SA hash signature:", serviceAgreementHashSignature)
|
||||||
|
}
|
||||||
|
|
||||||
return serviceAgreementHashSignature
|
return serviceAgreementHashSignature
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +44,9 @@ export default class ServiceAgreement extends OceanBase {
|
|||||||
consumer: Account,
|
consumer: Account,
|
||||||
publisher: Account): Promise<ServiceAgreement> {
|
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 service: Service = ddo.findServiceById(serviceDefinitionId)
|
||||||
const values: ValuePair[][] = ServiceAgreement.getValuesFromService(service, serviceAgreementId)
|
const values: ValuePair[][] = ServiceAgreement.getValuesFromService(service, serviceAgreementId)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import ConfigProvider from "../../ConfigProvider"
|
||||||
import DDOCondition from "../../ddo/Condition"
|
import DDOCondition from "../../ddo/Condition"
|
||||||
import Dependency from "../../ddo/Dependency"
|
import Dependency from "../../ddo/Dependency"
|
||||||
import MetaData from "../../ddo/MetaData"
|
import MetaData from "../../ddo/MetaData"
|
||||||
@ -169,6 +170,10 @@ export default class ServiceAgreementTemplate extends OceanBase {
|
|||||||
} as Condition
|
} as Condition
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (ConfigProvider.getConfig().verbose) {
|
||||||
|
Logger.log("Conditions", JSON.stringify(conditions, null, 2))
|
||||||
|
}
|
||||||
|
|
||||||
return conditions
|
return conditions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user