From 5fd7d6ffa1293f33ec9d82711333bf2ab6957c70 Mon Sep 17 00:00:00 2001 From: enrique Date: Tue, 7 Jan 2025 16:19:53 +0100 Subject: [PATCH 1/3] feat: return tx hash --- package.json | 2 +- .../templates/BaseTemplate.abstract.ts | 22 ++++++++++++------- .../contracts/templates/NFTAccessTemplate.ts | 7 +++--- src/nevermined/AccessService.ts | 6 ++--- src/types/DDOTypes.ts | 6 ++++- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 2948497c5..9d2b7b835 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "3.0.45", + "version": "3.0.46-rc0", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts", diff --git a/src/keeper/contracts/templates/BaseTemplate.abstract.ts b/src/keeper/contracts/templates/BaseTemplate.abstract.ts index 887c3d2ea..eeac837a5 100644 --- a/src/keeper/contracts/templates/BaseTemplate.abstract.ts +++ b/src/keeper/contracts/templates/BaseTemplate.abstract.ts @@ -11,13 +11,13 @@ import { TxParameters } from '../../../models/Transactions' import { isValidAddress } from '../../../nevermined/utils/BlockchainViemUtils' import { ConditionState } from '../../../types/ContractTypes' import { - Service, - ServicePlugin, - ServiceType, MetaData, - ServiceAttributes, PricedMetadataInformation, + Service, + ServiceAttributes, serviceIndex, + ServicePlugin, + ServiceType, ValidationParams, } from '../../../types/DDOTypes' import { zeroX } from '../../../utils/ConversionTypeHelpers' @@ -127,8 +127,8 @@ export abstract class BaseTemplate params: ValidationParams, from: NvmAccount, txparams?: TxParameters, - ): Promise { - await this.validateAgreement( + ): Promise { + return await this.validateAgreement( params.agreement_id, params.did, await this.paramsGen(params), @@ -145,7 +145,7 @@ export abstract class BaseTemplate from: NvmAccount, extra: any = {}, txparams?: TxParameters, - ): Promise { + ): Promise { const ddo = await this.nevermined.assets.resolve(did) if (!ddo) { throw new Error(`Asset ${did} not found`) @@ -166,12 +166,16 @@ export abstract class BaseTemplate ) } + const results: { [key: string]: any } = {} + for (const a of this.conditions()) { const condInstance = agreementData.instances.find( (c) => c.condition === a.contractName, ) as ConditionInstance - await a.fulfillWithNode(condInstance, extra, from, txparams) + const result = await a.fulfillWithNode(condInstance, extra, from, txparams) + results[a.contractName] = result + const lock_state = await this.nevermined.keeper.conditionStoreManager.getCondition( condInstance.id, ) @@ -182,5 +186,7 @@ export abstract class BaseTemplate ) } } + + return results } } diff --git a/src/keeper/contracts/templates/NFTAccessTemplate.ts b/src/keeper/contracts/templates/NFTAccessTemplate.ts index 199759ed2..6c28ae72a 100644 --- a/src/keeper/contracts/templates/NFTAccessTemplate.ts +++ b/src/keeper/contracts/templates/NFTAccessTemplate.ts @@ -102,8 +102,8 @@ export class NFTAccessTemplate extends BaseTemplate { - await this.validateAgreement( + ): Promise { + return await this.validateAgreement( params.agreement_id, params.did, await this.paramsGen(params), @@ -120,13 +120,14 @@ export class NFTAccessTemplate extends BaseTemplate { + ): Promise { const ddo = await this.nevermined.assets.resolve(did) const metadataService = ddo.findServiceByType('metadata') const isNft1155Credit = (metadataService.attributes.main.nftType as string) === NeverminedNFT1155Type.nft1155Credit.toString() if (isNft1155Credit) return + return this.validateAgreement(agreement_id, did, params, from, extra, txparams) } diff --git a/src/nevermined/AccessService.ts b/src/nevermined/AccessService.ts index a9c6bad72..223c2436f 100644 --- a/src/nevermined/AccessService.ts +++ b/src/nevermined/AccessService.ts @@ -54,7 +54,7 @@ export class AccessService extends Instantiable implements ServicePlugin { + ): Promise { return this.normal.process(params, from, txparams) } public async accept(params: ValidationParams): Promise { @@ -105,7 +105,7 @@ export class NFTAccessService extends Instantiable implements ServicePlugin { + ): Promise { const ddo = await this.nevermined.assets.resolve(params.did) const metadata = ddo.findServiceByType('metadata').attributes.main return this.select(metadata).process(params, from, txparams) @@ -162,7 +162,7 @@ export class NFTSalesService extends Instantiable implements ServicePlugin { + ): Promise { const ddo = await this.nevermined.assets.resolve(params.did) const metadata = ddo.findServiceByType('metadata').attributes.main return this.select(metadata).process(params, from, txparams) diff --git a/src/types/DDOTypes.ts b/src/types/DDOTypes.ts index 0cfdb0b80..fc41997c4 100644 --- a/src/types/DDOTypes.ts +++ b/src/types/DDOTypes.ts @@ -846,7 +846,11 @@ export interface ServicePlugin { pricedData?: PricedMetadataInformation, ): T // Process agreement for provider - process(params: ValidationParams, from: NvmAccount, txparams?: TxParameters): Promise + process( + params: ValidationParams, + from: NvmAccount, + txparams?: TxParameters, + ): Promise // Check if service can be granted without agreement accept(params: ValidationParams): Promise // It registers the usage of a service From 96c15275dceb11175d73418fb2bae75aba6ff869 Mon Sep 17 00:00:00 2001 From: eruizgar91 Date: Tue, 7 Jan 2025 15:24:04 +0000 Subject: [PATCH 2/3] Automated CHANGELOG.md update Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5562c477c..08d11ccc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ 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.5](https://github.com/nevermined-io/sdk-js/compare/v3.0.46-rc0...v3.4.5) + +> 13 December 2024 + +#### [v3.0.46-rc0](https://github.com/nevermined-io/sdk-js/compare/v3.0.44...v3.0.46-rc0) + +> 7 January 2025 + +- feat: add search endpoint [`#735`](https://github.com/nevermined-io/sdk-js/pull/735) +- docs: updating documentation [skip actions] [`dd39011`](https://github.com/nevermined-io/sdk-js/commit/dd39011cca2077c7bd523ee0d1875e4981658fff) +- docs: updating documentation [skip actions] [`214a92d`](https://github.com/nevermined-io/sdk-js/commit/214a92dcb9714f95b6d0153a00b32db4a8a4856a) +- feat: return tx hash [`5fd7d6f`](https://github.com/nevermined-io/sdk-js/commit/5fd7d6ffa1293f33ec9d82711333bf2ab6957c70) + #### [v3.0.44](https://github.com/nevermined-io/sdk-js/compare/v3.0.43...v3.0.44) > 22 November 2024 From 22cb3355cdf6f3b995058cc79b21318829e3a773 Mon Sep 17 00:00:00 2001 From: enrique Date: Wed, 8 Jan 2025 16:44:37 +0100 Subject: [PATCH 3/3] feat: revert --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9d2b7b835..ba70b399b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "3.0.46-rc0", + "version": "3.0.46", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts",