From c94b5293d4fc7a3bdc27f829b7fc9ca28f39b8fa Mon Sep 17 00:00:00 2001 From: Aitor <1726644+aaitor@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:04:16 +0100 Subject: [PATCH] fix: allowing to download from credits owner --- integration/external/Services_NFT1155.e2e.test.ts | 2 +- package.json | 2 +- src/ddo/DDO.ts | 5 +++-- src/keeper/contracts/templates/NFTAccessTemplate.ts | 9 +++++++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/integration/external/Services_NFT1155.e2e.test.ts b/integration/external/Services_NFT1155.e2e.test.ts index 51027a8c6..cba30a905 100644 --- a/integration/external/Services_NFT1155.e2e.test.ts +++ b/integration/external/Services_NFT1155.e2e.test.ts @@ -206,7 +206,7 @@ describe('Gate-keeping of Web Services using NFT ERC-1155 End-to-End', () => { const isOperator = await subscriptionNFT.getContract.isOperator(transferNftCondition.address) assert.isTrue(isOperator) - subscriptionMetadata = getMetadata(undefined, 'Service Subscription NFT1155') + subscriptionMetadata = getMetadata(Math.random().toString(), 'Service Subscription NFT1155') subscriptionMetadata.main.type = 'subscription' const nftAttributes = NFTAttributes.getCreditsSubscriptionInstance({ metadata: subscriptionMetadata, diff --git a/package.json b/package.json index 89e9acbb1..336e163f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "2.0.5", + "version": "2.0.6", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts", diff --git a/src/ddo/DDO.ts b/src/ddo/DDO.ts index 8d389109c..aad80fcb1 100644 --- a/src/ddo/DDO.ts +++ b/src/ddo/DDO.ts @@ -24,6 +24,7 @@ import { DDOParamNotFoundError, DDOServiceAlreadyExists, } from '../errors/DDOError' +import { jsonReplacer } from '../common' // DDO Services including a sales process export const SALES_SERVICES = ['access', 'compute', 'nft-sales'] @@ -41,7 +42,7 @@ export class DDO { * @returns DDO serialized. */ public static serialize(ddo: DDO): string { - return JSON.stringify(ddo, null, 2) + return JSON.stringify(ddo, jsonReplacer, 2) } /** @@ -244,7 +245,7 @@ export class DDO { const checksum = {} this.service.forEach((svc) => { checksum[svc.index] = this.checksum( - JSON.stringify(this.findServiceByType(svc.type).attributes.main), + JSON.stringify(this.findServiceByType(svc.type).attributes.main, jsonReplacer), ) }) return { diff --git a/src/keeper/contracts/templates/NFTAccessTemplate.ts b/src/keeper/contracts/templates/NFTAccessTemplate.ts index 1cb79aed4..47c7113f7 100644 --- a/src/keeper/contracts/templates/NFTAccessTemplate.ts +++ b/src/keeper/contracts/templates/NFTAccessTemplate.ts @@ -163,6 +163,15 @@ export class NFTAccessTemplate extends BaseTemplate 0 ? ddo.findServiceByIndex(params.service_index)