From 671cbafb490e08206487f5aca98c8785e15b89c3 Mon Sep 17 00:00:00 2001 From: mariacarmina Date: Thu, 7 Nov 2024 17:25:33 +0200 Subject: [PATCH 1/5] Remove checks from publishing. ADded chain ID check for ordering. --- src/utils/Assets.ts | 7 ------- src/utils/OrderUtils.ts | 4 ++++ test/integration/helpers.ts | 4 ++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/utils/Assets.ts b/src/utils/Assets.ts index bd1aa7b9a..568c68579 100644 --- a/src/utils/Assets.ts +++ b/src/utils/Assets.ts @@ -153,13 +153,6 @@ 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.') - } - const config = new ConfigHelper().getConfig(parseInt(String(chainID))) let templateIndex = await calculateActiveTemplateIndex( diff --git a/src/utils/OrderUtils.ts b/src/utils/OrderUtils.ts index 69eba8e63..6bd08fdd2 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 bafe4dea2..6e3f7c75d 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 c12d19ab69ace6a1ae430bc65264f18f915379b5 Mon Sep 17 00:00:00 2001 From: mariacarmina Date: Mon, 18 Nov 2024 15:14:30 +0200 Subject: [PATCH 2/5] Add 2 more keys for DDO object. --- src/@types/DDO/DDO.ts | 13 ++++++++++++- src/@types/DDO/Nft.ts | 10 ++++++++++ src/@types/DDO/Stats.ts | 9 +++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/@types/DDO/Nft.ts create mode 100644 src/@types/DDO/Stats.ts diff --git a/src/@types/DDO/DDO.ts b/src/@types/DDO/DDO.ts index 211813d68..5d1383ca6 100644 --- a/src/@types/DDO/DDO.ts +++ b/src/@types/DDO/DDO.ts @@ -1,4 +1,5 @@ -import { Service, Metadata, Credentials, Event } from '..' +import { Service, Metadata, Credentials, Event, Stats } from '..' +import { Nft } from './Nft' /** * DID Descriptor Object. @@ -61,4 +62,14 @@ export interface DDO { * @type {Event} */ event?: Event + /** + * Describes the stats for the datasets, number of orders, price if applicable + * @type {Stats} + */ + stats?: Stats + /** + * Describes the NFT object + * @type {Nft} + */ + nft?: Nft } diff --git a/src/@types/DDO/Nft.ts b/src/@types/DDO/Nft.ts new file mode 100644 index 000000000..98b2b5a3a --- /dev/null +++ b/src/@types/DDO/Nft.ts @@ -0,0 +1,10 @@ + +export interface Nft { + address: string + name: string + symbol: string + state: number + tokenURI: string + owner: string + created: string +} \ No newline at end of file diff --git a/src/@types/DDO/Stats.ts b/src/@types/DDO/Stats.ts new file mode 100644 index 000000000..c254761b5 --- /dev/null +++ b/src/@types/DDO/Stats.ts @@ -0,0 +1,9 @@ +export interface Price { + value?: number +} + +export interface Stats { + allocated?: number + orders?: number + price?: Price +} \ No newline at end of file From 45cf5a86e700a7949c5eae440378e3ba52bbbbef Mon Sep 17 00:00:00 2001 From: mariacarmina Date: Mon, 18 Nov 2024 15:18:37 +0200 Subject: [PATCH 3/5] Fix lint. --- src/@types/DDO/Nft.ts | 17 ++++++++--------- src/@types/DDO/Stats.ts | 10 +++++----- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/@types/DDO/Nft.ts b/src/@types/DDO/Nft.ts index 98b2b5a3a..b6d085e36 100644 --- a/src/@types/DDO/Nft.ts +++ b/src/@types/DDO/Nft.ts @@ -1,10 +1,9 @@ - export interface Nft { - address: string - name: string - symbol: string - state: number - tokenURI: string - owner: string - created: string -} \ No newline at end of file + address: string + name: string + symbol: string + state: number + tokenURI: string + owner: string + created: string +} diff --git a/src/@types/DDO/Stats.ts b/src/@types/DDO/Stats.ts index c254761b5..226d46f76 100644 --- a/src/@types/DDO/Stats.ts +++ b/src/@types/DDO/Stats.ts @@ -1,9 +1,9 @@ export interface Price { - value?: number + value?: number } export interface Stats { - allocated?: number - orders?: number - price?: Price -} \ No newline at end of file + allocated?: number + orders?: number + price?: Price +} From 7d3481a9ce176f50361bae92249993efb307376a Mon Sep 17 00:00:00 2001 From: mariacarmina Date: Mon, 18 Nov 2024 16:14:05 +0200 Subject: [PATCH 4/5] Remove stats and nft from DDO. --- src/@types/DDO/DDO.ts | 14 +------------- src/@types/DDO/Nft.ts | 9 --------- src/@types/DDO/Stats.ts | 9 --------- 3 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 src/@types/DDO/Nft.ts delete mode 100644 src/@types/DDO/Stats.ts diff --git a/src/@types/DDO/DDO.ts b/src/@types/DDO/DDO.ts index 5d1383ca6..25fba9957 100644 --- a/src/@types/DDO/DDO.ts +++ b/src/@types/DDO/DDO.ts @@ -1,6 +1,4 @@ -import { Service, Metadata, Credentials, Event, Stats } from '..' -import { Nft } from './Nft' - +import { Service, Metadata, Credentials, Event } from '..' /** * DID Descriptor Object. * Contains metadata about the asset, and define access in at least one service. @@ -62,14 +60,4 @@ export interface DDO { * @type {Event} */ event?: Event - /** - * Describes the stats for the datasets, number of orders, price if applicable - * @type {Stats} - */ - stats?: Stats - /** - * Describes the NFT object - * @type {Nft} - */ - nft?: Nft } diff --git a/src/@types/DDO/Nft.ts b/src/@types/DDO/Nft.ts deleted file mode 100644 index b6d085e36..000000000 --- a/src/@types/DDO/Nft.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface Nft { - address: string - name: string - symbol: string - state: number - tokenURI: string - owner: string - created: string -} diff --git a/src/@types/DDO/Stats.ts b/src/@types/DDO/Stats.ts deleted file mode 100644 index 226d46f76..000000000 --- a/src/@types/DDO/Stats.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface Price { - value?: number -} - -export interface Stats { - allocated?: number - orders?: number - price?: Price -} From 72c6a49ef63d08334a925f09b02258228a21e2f4 Mon Sep 17 00:00:00 2001 From: mariacarmina Date: Mon, 18 Nov 2024 17:31:36 +0200 Subject: [PATCH 5/5] Add check back for chain id only if ddo chain id. --- src/utils/Assets.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/Assets.ts b/src/utils/Assets.ts index 568c68579..7fa95b47f 100644 --- a/src/utils/Assets.ts +++ b/src/utils/Assets.ts @@ -153,6 +153,12 @@ export async function createAsset( } const chainID = (await owner.provider.getNetwork()).chainId + 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))) let templateIndex = await calculateActiveTemplateIndex(