From 8687962abd34586d2947082ff5bffa13ecca8035 Mon Sep 17 00:00:00 2001 From: Maria Carmina <50501033+mariacarmina@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:17:33 +0200 Subject: [PATCH 1/2] Remove checks from publishing. ADded chain ID check for ordering. (#1875) * Remove checks from publishing. ADded chain ID check for ordering. * Add 2 more keys for DDO object. * Fix lint. * Remove stats and nft from DDO. * Add check back for chain id only if ddo chain id. --- src/@types/DDO/DDO.ts | 1 - src/utils/Assets.ts | 9 ++++----- src/utils/OrderUtils.ts | 4 ++++ test/integration/helpers.ts | 4 ++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/@types/DDO/DDO.ts b/src/@types/DDO/DDO.ts index 211813d6..25fba995 100644 --- a/src/@types/DDO/DDO.ts +++ b/src/@types/DDO/DDO.ts @@ -1,5 +1,4 @@ import { Service, Metadata, Credentials, Event } from '..' - /** * DID Descriptor Object. * Contains metadata about the asset, and define access in at least one service. diff --git a/src/utils/Assets.ts b/src/utils/Assets.ts index bd1aa7b9..7fa95b47 100644 --- a/src/utils/Assets.ts +++ b/src/utils/Assets.ts @@ -153,11 +153,10 @@ export async function createAsset( } const chainID = (await owner.provider.getNetwork()).chainId - if (ddo.chainId !== chainID) { - throw new Error('Chain ID from DDO is different than the configured network.') - } - if (ddo.id) { - throw new Error('DID already filled in.') + if (ddo.chainId) { + if (ddo.chainId !== chainID) { + throw new Error('Chain ID from DDO is different than the configured network.') + } } const config = new ConfigHelper().getConfig(parseInt(String(chainID))) diff --git a/src/utils/OrderUtils.ts b/src/utils/OrderUtils.ts index 69eba8e6..6bd08fdd 100644 --- a/src/utils/OrderUtils.ts +++ b/src/utils/OrderUtils.ts @@ -54,6 +54,10 @@ export async function orderAsset( consumeMarketFeeToken: asset.stats.price.tokenAddress || '0x0000000000000000000000000000000000000000' } + const chainID = (await consumerAccount.provider.getNetwork()).chainId + if (asset.chainId !== chainID) { + throw new Error('Chain ID from DDO is different than the configured network.') + } if (!asset.datatokens[datatokenIndex].address) throw new Error( diff --git a/test/integration/helpers.ts b/test/integration/helpers.ts index bafe4dea..6e3f7c75 100644 --- a/test/integration/helpers.ts +++ b/test/integration/helpers.ts @@ -133,6 +133,10 @@ export async function handleComputeOrder( - have validOrder and providerFees -> then order is valid but providerFees are not valid, we need to call reuseOrder and pay only providerFees - no validOrder -> we need to call startOrder, to pay 1 DT & providerFees */ + const chainID = (await payerAccount.provider.getNetwork()).chainId + if (config.chainId !== chainID) { + throw new Error('Chain ID from DDO is different than the configured network.') + } if (order.providerFee && order.providerFee.providerFeeAmount) { await approveWei( payerAccount, From fa242a5095d16327adf2d53830a643350fcdfa84 Mon Sep 17 00:00:00 2001 From: mariacarmina Date: Wed, 20 Nov 2024 15:43:36 +0200 Subject: [PATCH 2/2] Release 3.4.4 --- CHANGELOG.md | 21 +++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52786bdb..1cad1b84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,31 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [v3.4.4](https://github.com/oceanprotocol/ocean.js/compare/v4.0.0-next.1...v3.4.4) + +- Remove checks from publishing. ADded chain ID check for ordering. [`#1875`](https://github.com/oceanprotocol/ocean.js/pull/1875) + +#### [v4.0.0-next.1](https://github.com/oceanprotocol/ocean.js/compare/v4.0.0-next.0...v4.0.0-next.1) + +> 12 November 2024 + +- add datasets on ComputeAsset, new start compute fn [`8563429`](https://github.com/oceanprotocol/ocean.js/commit/85634293306fca9aaa3ab5ae06a114149ccc8911) +- support for consumer signature on initialize compute [`71c5923`](https://github.com/oceanprotocol/ocean.js/commit/71c59230db99a08a6c28df66c26e32ca61c71089) +- add file object types [`cd936c2`](https://github.com/oceanprotocol/ocean.js/commit/cd936c24a989633d3d8e71b908a375802d2e2970) + +#### [v4.0.0-next.0](https://github.com/oceanprotocol/ocean.js/compare/v3.4.3...v4.0.0-next.0) + +> 12 November 2024 + +- Release 4.0.0-next.0 [`658cfe8`](https://github.com/oceanprotocol/ocean.js/commit/658cfe83ff855a83eb97e3cbf1276bed6022a1a6) + #### [v3.4.3](https://github.com/oceanprotocol/ocean.js/compare/v3.4.2...v3.4.3) +> 5 November 2024 + - Add checks for ddo chain id and did. [`#1868`](https://github.com/oceanprotocol/ocean.js/pull/1868) - generate types to dist/types [`#1862`](https://github.com/oceanprotocol/ocean.js/pull/1862) +- Release 3.4.3 [`9d385b0`](https://github.com/oceanprotocol/ocean.js/commit/9d385b0f0be4df0d280b8c6353b25ed0f005b66a) - fix tests tsconfig path in eslint [`bae1874`](https://github.com/oceanprotocol/ocean.js/commit/bae18749bf96d8cc34592aa6dd271b7c1fd6dbfb) #### [v3.4.2](https://github.com/oceanprotocol/ocean.js/compare/v3.4.1...v3.4.2) diff --git a/package-lock.json b/package-lock.json index 154ffd08..402fc755 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@oceanprotocol/lib", - "version": "3.4.3", + "version": "3.4.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@oceanprotocol/lib", - "version": "3.4.3", + "version": "3.4.4", "license": "Apache-2.0", "dependencies": { "@oasisprotocol/sapphire-paratime": "^1.3.2", diff --git a/package.json b/package.json index 283e17ba..8144acd2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@oceanprotocol/lib", "source": "./src/index.ts", - "version": "3.4.3", + "version": "3.4.4", "description": "JavaScript client library for Ocean Protocol", "main": "./dist/lib.js", "umd:main": "dist/lib.umd.js",