diff --git a/metadata/simpleComputeDataset.json b/metadata/simpleComputeDataset.json index 8d99cb1..c087a43 100644 --- a/metadata/simpleComputeDataset.json +++ b/metadata/simpleComputeDataset.json @@ -42,8 +42,8 @@ "compute": { "allowRawAlgorithm": false, "allowNetworkAccess": true, - "publisherTrustedAlgorithmPublishers": [], - "publisherTrustedAlgorithms": [] + "publisherTrustedAlgorithmPublishers": ["*"], + "publisherTrustedAlgorithms": ["*"] } } ], diff --git a/package-lock.json b/package-lock.json index 763101c..b4fcd9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,8 +11,8 @@ "dependencies": { "@oasisprotocol/sapphire-paratime": "^1.3.2", "@oceanprotocol/contracts": "^2.3.1", - "@oceanprotocol/ddo-js": "^0.0.8", - "@oceanprotocol/lib": "^4.1.3", + "@oceanprotocol/ddo-js": "^0.1.0", + "@oceanprotocol/lib": "^4.1.4", "commander": "^13.1.0", "cross-fetch": "^3.1.5", "crypto-js": "^4.1.1", @@ -3561,10 +3561,9 @@ "license": "Apache-2.0" }, "node_modules/@oceanprotocol/ddo-js": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@oceanprotocol/ddo-js/-/ddo-js-0.0.8.tgz", - "integrity": "sha512-Rv/vbsWjMEmwsLX57TYmJ0nuV3lOnJ4C6IKFvW14lfsN72e6i8kBshpFx7tYjpuVyW+WgyHvGOGjQmf0WBj0Mw==", - "license": "Apache-2.0", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@oceanprotocol/ddo-js/-/ddo-js-0.1.0.tgz", + "integrity": "sha512-dQmwKZiq6/D7mIDWQVsCuZzMtkWPKHYL7fVM9xk5qXByka/aieziVBLP+L2ObfYZFX77aOJLR8Bj4q5kpGwd/Q==", "dependencies": { "@rdfjs/formats-common": "^3.1.0", "@types/rdfjs__formats-common": "^3.1.5", @@ -3627,28 +3626,14 @@ "node": ">= 14.16" } }, - "node_modules/@oceanprotocol/ddo-js/node_modules/rdf-literal": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/rdf-literal/-/rdf-literal-2.0.0.tgz", - "integrity": "sha512-jlQ+h7EvnXmncmk8OzOYR8T3gNfd4g0LQXbflHkEkancic8dh0Tdt5RiRq8vUFndjIeNHt1RWeA5TAj6rgrtng==", - "license": "MIT", - "dependencies": { - "rdf-data-factory": "^2.0.0" - }, - "funding": { - "type": "individual", - "url": "https://github.com/sponsors/rubensworks/" - } - }, "node_modules/@oceanprotocol/lib": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-4.1.3.tgz", - "integrity": "sha512-PmMwrZPpWo/bBErK/LddVRXdWNBKdFqUgckMR2UukaftApBNqYukefodPOUoOSRAZyVBdAcsXh74MyeWvOff4w==", - "license": "Apache-2.0", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-4.1.4.tgz", + "integrity": "sha512-AGZi7/YckwxmoN0dyK+iGl58vr8VvQqk9dG6cU2x9nSmJDD1xcgFOinpV2fqw+6pohjjEvLAr+DgzJpdh7PJaw==", "dependencies": { "@oasisprotocol/sapphire-paratime": "^1.3.2", "@oceanprotocol/contracts": "^2.3.0", - "@oceanprotocol/ddo-js": "^0.0.8", + "@oceanprotocol/ddo-js": "^0.1.0", "@rdfjs/dataset": "^2.0.2", "@rdfjs/formats-common": "^3.1.0", "@zazuko/env-node": "^2.1.4", @@ -13323,6 +13308,18 @@ "readable-stream": "3 - 4" } }, + "node_modules/rdf-literal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/rdf-literal/-/rdf-literal-2.0.0.tgz", + "integrity": "sha512-jlQ+h7EvnXmncmk8OzOYR8T3gNfd4g0LQXbflHkEkancic8dh0Tdt5RiRq8vUFndjIeNHt1RWeA5TAj6rgrtng==", + "dependencies": { + "rdf-data-factory": "^2.0.0" + }, + "funding": { + "type": "individual", + "url": "https://github.com/sponsors/rubensworks/" + } + }, "node_modules/rdf-validate-datatype": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/rdf-validate-datatype/-/rdf-validate-datatype-0.2.2.tgz", @@ -18787,9 +18784,9 @@ "integrity": "sha512-43Vz+DJfoNZLteg91sYvNDR5tJLWcAXl78VoSTriw38j81p6FSLcPNCHzPZKwX9FxyMk3uQe9U4u9REUBEQUfw==" }, "@oceanprotocol/ddo-js": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@oceanprotocol/ddo-js/-/ddo-js-0.0.8.tgz", - "integrity": "sha512-Rv/vbsWjMEmwsLX57TYmJ0nuV3lOnJ4C6IKFvW14lfsN72e6i8kBshpFx7tYjpuVyW+WgyHvGOGjQmf0WBj0Mw==", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@oceanprotocol/ddo-js/-/ddo-js-0.1.0.tgz", + "integrity": "sha512-dQmwKZiq6/D7mIDWQVsCuZzMtkWPKHYL7fVM9xk5qXByka/aieziVBLP+L2ObfYZFX77aOJLR8Bj4q5kpGwd/Q==", "requires": { "@rdfjs/formats-common": "^3.1.0", "@types/rdfjs__formats-common": "^3.1.5", @@ -18836,25 +18833,17 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==" - }, - "rdf-literal": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/rdf-literal/-/rdf-literal-2.0.0.tgz", - "integrity": "sha512-jlQ+h7EvnXmncmk8OzOYR8T3gNfd4g0LQXbflHkEkancic8dh0Tdt5RiRq8vUFndjIeNHt1RWeA5TAj6rgrtng==", - "requires": { - "rdf-data-factory": "^2.0.0" - } } } }, "@oceanprotocol/lib": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-4.1.3.tgz", - "integrity": "sha512-PmMwrZPpWo/bBErK/LddVRXdWNBKdFqUgckMR2UukaftApBNqYukefodPOUoOSRAZyVBdAcsXh74MyeWvOff4w==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-4.1.4.tgz", + "integrity": "sha512-AGZi7/YckwxmoN0dyK+iGl58vr8VvQqk9dG6cU2x9nSmJDD1xcgFOinpV2fqw+6pohjjEvLAr+DgzJpdh7PJaw==", "requires": { "@oasisprotocol/sapphire-paratime": "^1.3.2", "@oceanprotocol/contracts": "^2.3.0", - "@oceanprotocol/ddo-js": "^0.0.8", + "@oceanprotocol/ddo-js": "^0.1.0", "@rdfjs/dataset": "^2.0.2", "@rdfjs/formats-common": "^3.1.0", "@zazuko/env-node": "^2.1.4", @@ -25874,6 +25863,14 @@ "readable-stream": "3 - 4" } }, + "rdf-literal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/rdf-literal/-/rdf-literal-2.0.0.tgz", + "integrity": "sha512-jlQ+h7EvnXmncmk8OzOYR8T3gNfd4g0LQXbflHkEkancic8dh0Tdt5RiRq8vUFndjIeNHt1RWeA5TAj6rgrtng==", + "requires": { + "rdf-data-factory": "^2.0.0" + } + }, "rdf-validate-datatype": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/rdf-validate-datatype/-/rdf-validate-datatype-0.2.2.tgz", diff --git a/package.json b/package.json index 09ae16a..ff1ff74 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,8 @@ "dependencies": { "@oasisprotocol/sapphire-paratime": "^1.3.2", "@oceanprotocol/contracts": "^2.3.1", - "@oceanprotocol/ddo-js": "^0.0.8", - "@oceanprotocol/lib": "^4.1.3", + "@oceanprotocol/ddo-js": "^0.1.0", + "@oceanprotocol/lib": "^4.1.4", "commander": "^13.1.0", "cross-fetch": "^3.1.5", "crypto-js": "^4.1.1", diff --git a/src/cli.ts b/src/cli.ts index 2b16123..7bfbb78 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -225,6 +225,10 @@ export async function createCLI() { const proceed = options.accept; if (!proceed) { + if (!process.stdin.isTTY) { + console.error(chalk.red('Cannot prompt for confirmation (non-TTY). Use "--accept true" to skip.')); + process.exit(1); + } const rl = createInterface({ input, output }); const confirmation = await rl.question(`\nProceed with payment for starting compute job at price ${amount} in tokens from address ${initResp.payment.token}? (y/n): `); rl.close(); diff --git a/test/consumeFlow.test.ts b/test/consumeFlow.test.ts index 9219b03..94545c5 100644 --- a/test/consumeFlow.test.ts +++ b/test/consumeFlow.test.ts @@ -57,7 +57,7 @@ describe("Ocean CLI Publishing", function() { const jsonMatch = output.match(/did:op:[a-f0-9]{64}/); if (!jsonMatch) { console.error("Raw output:", output); - throw new Error("Could not find compute environments in the output"); + throw new Error("Could not find did in the output"); } try { @@ -81,7 +81,7 @@ describe("Ocean CLI Publishing", function() { const jsonMatch = output.match(/did:op:[a-f0-9]{64}/); if (!jsonMatch) { console.error("Raw output:", output); - throw new Error("Could not find compute environments in the output"); + throw new Error("Could not find did in the output"); } try { @@ -104,7 +104,7 @@ describe("Ocean CLI Publishing", function() { const jsonMatch = output.match(/did:op:[a-f0-9]{64}/); if (!jsonMatch) { console.error("Raw output:", output); - throw new Error("Could not find compute environments in the output"); + throw new Error("Could not find did in the output"); } try { @@ -127,7 +127,7 @@ describe("Ocean CLI Publishing", function() { const jsonMatch = output.match(/did:op:[a-f0-9]{64}/); if (!jsonMatch) { console.error("Raw output:", output); - throw new Error("Could not find compute environments in the output"); + throw new Error("Could not find did in the output"); } try { @@ -145,7 +145,7 @@ describe("Ocean CLI Publishing", function() { const jsonMatch = output.match(/s*([\s\S]*)/); if (!jsonMatch) { console.error("Raw output:", output); - throw new Error("Could not find compute environments in the output"); + throw new Error("Could not find ddo in the output"); } try { @@ -162,7 +162,7 @@ describe("Ocean CLI Publishing", function() { const jsonMatch = output.match(/s*([\s\S]*)/); if (!jsonMatch) { console.error("Raw output:", output); - throw new Error("Could not find compute environments in the output"); + throw new Error("Could not find ddo in the output"); } try { @@ -179,7 +179,7 @@ describe("Ocean CLI Publishing", function() { const jsonMatch = output.match(/s*([\s\S]*)/); if (!jsonMatch) { console.error("Raw output:", output); - throw new Error("Could not find compute environments in the output"); + throw new Error("Could not find ddo in the output"); } try { @@ -196,7 +196,7 @@ describe("Ocean CLI Publishing", function() { const jsonMatch = output.match(/s*([\s\S]*)/); if (!jsonMatch) { console.error("Raw output:", output); - throw new Error("Could not find compute environments in the output"); + throw new Error("Could not find ddo in the output"); } try { diff --git a/test/paidComputeFlow.test.ts b/test/paidComputeFlow.test.ts index dec76c2..b53395b 100644 --- a/test/paidComputeFlow.test.ts +++ b/test/paidComputeFlow.test.ts @@ -89,7 +89,7 @@ describe("Ocean CLI Paid Compute", function() { const jsonMatch = output.match(/s*([\s\S]*)/); if (!jsonMatch) { console.error("Raw output:", output); - throw new Error("Could not find compute environments in the output"); + throw new Error("Could not find ddo in the output"); } try { @@ -106,7 +106,7 @@ describe("Ocean CLI Paid Compute", function() { const jsonMatch = output.match(/s*([\s\S]*)/); if (!jsonMatch) { console.error("Raw output:", output); - throw new Error("Could not find compute environments in the output"); + throw new Error("Could not find ddo in the output"); } try { @@ -125,18 +125,12 @@ describe("Ocean CLI Paid Compute", function() { console.error("Raw output:", output); throw new Error("Could not find compute environments in the output"); } - const match = jsonMatch[0].match(/Exiting compute environments:\s*(.*)/s); - const result = match ? match[1].trim() : null; - if (!result) { - console.error("Raw output:", output); - throw new Error("Could not find compute environments in the output"); - } - + let environments; try { - environments = eval(result); + environments = eval(jsonMatch[1]); } catch (error) { - console.error(`Extracted output: ${jsonMatch[0]} and final result: ${result}`); + console.error(`Extracted output: ${jsonMatch[0]} and final result: ${jsonMatch[1]}`); throw new Error("Failed to parse the extracted output:\n" + error); }