From 47d50acff14bfe5d5c7756ad3d86a0d1af107cf2 Mon Sep 17 00:00:00 2001 From: enrique Date: Mon, 15 Jul 2024 13:05:58 +0200 Subject: [PATCH 01/17] feat: update to support 2 subscription addresses --- package.json | 2 +- src/nevermined/NvmApp.ts | 34 ++++++++++--------------- src/nevermined/resources/AppNetworks.ts | 30 ++++++++++++++-------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index cf3a65a7b..1e18e8b62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "3.0.17", + "version": "3.0.18-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/nevermined/NvmApp.ts b/src/nevermined/NvmApp.ts index 4e9c5eaed..8fb51e091 100644 --- a/src/nevermined/NvmApp.ts +++ b/src/nevermined/NvmApp.ts @@ -1,7 +1,7 @@ +import { SmartAccountSigner } from 'permissionless/accounts' import { NETWORK_FEE_DENOMINATOR } from '../constants/AssetConstants' import { DDO } from '../ddo/DDO' import { Web3Error } from '../errors/NeverminedErrors' -import { ContractHandler } from '../keeper/ContractHandler' import { AssetPrice } from '../models/AssetPrice' import { NFTAttributes } from '../models/NFTAttributes' import { NeverminedOptions } from '../models/NeverminedOptions' @@ -28,7 +28,6 @@ import { CreateProgressStep, OrderProgressStep, UpdateProgressStep } from './Pro import { SearchApi } from './api/SearchApi' import { ServicesApi } from './api/ServicesApi' import { createKernelClient, isValidAddress } from './utils/BlockchainViemUtils' -import { SmartAccountSigner } from 'permissionless/accounts' export enum NVMAppEnvironments { Staging = 'staging', @@ -71,7 +70,8 @@ export class NvmApp { private zeroDevSignerAccount: SmartAccountSigner<'custom', `0x${string}`> | undefined public assetProviders: string[] = [] private loginCredentials: string | undefined - private subscriptionNFTContractAddress: string | undefined + private subscriptionNFTContractTimeAddress: string | undefined + private subscriptionNFTContractCredtisAddress: string | undefined private networkFeeReceiver: string | undefined private networkFee: bigint | undefined @@ -184,21 +184,17 @@ export class NvmApp { const nodeInfo = await this.fullSDK.services.node.getNeverminedNodeInfo() this.assetProviders = [nodeInfo['provider-address']] - if (!isValidAddress(this.configNVM.nftContractAddress as string)) { - const contractABI = await ContractHandler.getABIArtifact( - 'NFT1155SubscriptionUpgradeable', - this.configNVM.artifactsFolder, - await this.fullSDK.keeper.getNetworkName(), - this.configNVM.chainId, - ) - this.subscriptionNFTContractAddress = contractABI.address - } else { - this.subscriptionNFTContractAddress = this.configNVM.nftContractAddress + this.subscriptionNFTContractTimeAddress = this.configNVM.nftContractTimeAddress + this.subscriptionNFTContractCredtisAddress = this.configNVM.nftContractCreditsAddress + + if (!isValidAddress(this.subscriptionNFTContractTimeAddress as string)) { + throw new Web3Error('Invalid Subscription NFT contract time address') } - if (!isValidAddress(this.subscriptionNFTContractAddress as string)) { - throw new Web3Error('Invalid Subscription NFT contract address') + if (!isValidAddress(this.subscriptionNFTContractCredtisAddress as string)) { + throw new Web3Error('Invalid Subscription NFT contract credits address') } - this.sdk.contracts.loadNft1155(this.subscriptionNFTContractAddress as string) + this.sdk.contracts.loadNft1155(this.subscriptionNFTContractTimeAddress as string) + this.sdk.contracts.loadNft1155(this.subscriptionNFTContractCredtisAddress as string) this.networkFeeReceiver = await this.fullSDK.keeper.nvmConfig.getFeeReceiver() this.networkFee = await this.fullSDK.keeper.nvmConfig.getNetworkFee() return { @@ -325,7 +321,7 @@ export class NvmApp { }, ], providers: this.assetProviders, - nftContractAddress: this.subscriptionNFTContractAddress, + nftContractAddress: this.subscriptionNFTContractTimeAddress, preMint: false, }) @@ -397,7 +393,7 @@ export class NvmApp { }, ], providers: this.assetProviders, - nftContractAddress: this.subscriptionNFTContractAddress, + nftContractAddress: this.subscriptionNFTContractCredtisAddress, preMint: false, }) @@ -714,7 +710,6 @@ export class NvmApp { }, ], providers: this.assetProviders, - nftContractAddress: this.subscriptionNFTContractAddress, preMint: false, }) @@ -782,7 +777,6 @@ export class NvmApp { }, ], providers: this.assetProviders, - nftContractAddress: this.subscriptionNFTContractAddress, preMint: false, }) diff --git a/src/nevermined/resources/AppNetworks.ts b/src/nevermined/resources/AppNetworks.ts index 9a9e43eab..1cf6f967f 100644 --- a/src/nevermined/resources/AppNetworks.ts +++ b/src/nevermined/resources/AppNetworks.ts @@ -2,7 +2,8 @@ import { NeverminedOptions } from '../../models' export class NeverminedAppOptions extends NeverminedOptions { instanceName: string - nftContractAddress?: string + nftContractTimeAddress?: string + nftContractCreditsAddress?: string tokenAddress?: string // ERC-20 token address or zero address (0x000..) for native token } @@ -18,7 +19,8 @@ export class AppDeploymentLocal extends NeverminedAppOptions { verbose = true gasMultiplier = 0 gasPriceMultiplier = 0 - nftContractAddress = undefined + nftContractTimeAddress = undefined + nftContractCreditsAddress = undefined } export class AppDeploymentStaging extends NeverminedAppOptions { @@ -33,7 +35,8 @@ export class AppDeploymentStaging extends NeverminedAppOptions { verbose = true gasMultiplier = 0 gasPriceMultiplier = 0 - nftContractAddress = undefined + nftContractTimeAddress = undefined + nftContractCreditsAddress = undefined tokenAddress = '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d' } @@ -49,7 +52,8 @@ export class AppDeploymentTesting extends NeverminedAppOptions { verbose = true gasMultiplier = 0 gasPriceMultiplier = 0 - nftContractAddress = undefined + nftContractTimeAddress = undefined + nftContractCreditsAddress = undefined tokenAddress = '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d' } @@ -65,7 +69,8 @@ export class AppDeploymentArbitrum extends NeverminedAppOptions { verbose = true gasMultiplier = 0 gasPriceMultiplier = 0 - nftContractAddress = undefined + nftContractTimeAddress = undefined + nftContractCreditsAddress = undefined tokenAddress = '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' } @@ -81,7 +86,8 @@ export class AppDeploymentGnosis extends NeverminedAppOptions { verbose = true gasMultiplier = 0 gasPriceMultiplier = 0 - nftContractAddress = undefined + nftContractTimeAddress = undefined + nftContractCreditsAddress = undefined tokenAddress = '0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83' } @@ -97,7 +103,8 @@ export class AppDeploymentMatic extends NeverminedAppOptions { verbose = true gasMultiplier = 1.2 gasPriceMultiplier = 1.2 - nftContractAddress = undefined + nftContractTimeAddress = undefined + nftContractCreditsAddress = undefined tokenAddress = '0x2791bca1f2de4661ed88a30c99a7a9449aa84174' } @@ -113,7 +120,8 @@ export class AppDeploymentBase extends NeverminedAppOptions { verbose = true gasMultiplier = 0 gasPriceMultiplier = 0 - nftContractAddress = undefined + nftContractTimeAddress = undefined + nftContractCreditsAddress = undefined tokenAddress = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' } @@ -129,7 +137,8 @@ export class AppDeploymentCelo extends NeverminedAppOptions { verbose = true gasMultiplier = 0 gasPriceMultiplier = 0 - nftContractAddress = undefined + nftContractTimeAddress = undefined + nftContractCreditsAddress = undefined tokenAddress = '0xef4229c8c3250C675F21BCefa42f58EfbfF6002a' } @@ -145,6 +154,7 @@ export class AppDeploymentOptimism extends NeverminedAppOptions { verbose = true gasMultiplier = 0 gasPriceMultiplier = 0 - nftContractAddress = undefined + nftContractTimeAddress = undefined + nftContractCreditsAddress = undefined tokenAddress = '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85' } From df657fcd84086b2643f60f5a132e8cbe3d55824e Mon Sep 17 00:00:00 2001 From: enrique Date: Mon, 15 Jul 2024 13:16:23 +0200 Subject: [PATCH 02/17] fix: typo --- CHANGELOG.md | 8 ++++---- src/nevermined/NvmApp.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 026fd1a7b..25d24faef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2100,7 +2100,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). > 2 May 2022 -- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) +- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) - Adding v0.19.21 Changelog updates [`c93cdc5`](https://github.com/nevermined-io/sdk-js/commit/c93cdc55f139a43db4130ccb0f80924d2645a931) #### [v0.19.21](https://github.com/nevermined-io/sdk-js/compare/v0.19.20...v0.19.21) @@ -2363,7 +2363,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). > 18 January 2022 -- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) +- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) - [wip] Create agreement+pay in one transaction [`#183`](https://github.com/nevermined-io/sdk-js/pull/183) - Adapting to contracts `v1.3.3` [`#177`](https://github.com/nevermined-io/sdk-js/pull/177) - Adding v0.17.2 Changelog updates [`5eddda4`](https://github.com/nevermined-io/sdk-js/commit/5eddda43954e013e6e6f7344c9a877d801aacb5c) @@ -2869,7 +2869,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Feature/sync develop [`#268`](https://github.com/nevermined-io/sdk-js/pull/268) - Quick fix for non-eip1559 networks [`#266`](https://github.com/nevermined-io/sdk-js/pull/266) - integrate Permissions and refactor search query [`#264`](https://github.com/nevermined-io/sdk-js/pull/264) -- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) +- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) - Get the keeper version from the artifacts instead of package version [`#244`](https://github.com/nevermined-io/sdk-js/pull/244) - replace `metadata-api` url by `marketplace-api` and sort type [`#243`](https://github.com/nevermined-io/sdk-js/pull/243) - fixing issues with BigNumbers [`#246`](https://github.com/nevermined-io/sdk-js/pull/246) @@ -2908,7 +2908,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Feature/190 add did to sec markets [`#191`](https://github.com/nevermined-io/sdk-js/pull/191) - Adding utility methods for getting nft token uri [`#189`](https://github.com/nevermined-io/sdk-js/pull/189) - Lint ... [`#187`](https://github.com/nevermined-io/sdk-js/pull/187) -- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) +- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) - [wip] Create agreement+pay in one transaction [`#183`](https://github.com/nevermined-io/sdk-js/pull/183) - Adapting to contracts `v1.3.3` [`#177`](https://github.com/nevermined-io/sdk-js/pull/177) - Correct typo in route [`#184`](https://github.com/nevermined-io/sdk-js/pull/184) diff --git a/src/nevermined/NvmApp.ts b/src/nevermined/NvmApp.ts index 8fb51e091..8177122dc 100644 --- a/src/nevermined/NvmApp.ts +++ b/src/nevermined/NvmApp.ts @@ -71,7 +71,7 @@ export class NvmApp { public assetProviders: string[] = [] private loginCredentials: string | undefined private subscriptionNFTContractTimeAddress: string | undefined - private subscriptionNFTContractCredtisAddress: string | undefined + private subscriptionNFTContractCreditsAddress: string | undefined private networkFeeReceiver: string | undefined private networkFee: bigint | undefined @@ -185,16 +185,16 @@ export class NvmApp { this.assetProviders = [nodeInfo['provider-address']] this.subscriptionNFTContractTimeAddress = this.configNVM.nftContractTimeAddress - this.subscriptionNFTContractCredtisAddress = this.configNVM.nftContractCreditsAddress + this.subscriptionNFTContractCreditsAddress = this.configNVM.nftContractCreditsAddress if (!isValidAddress(this.subscriptionNFTContractTimeAddress as string)) { throw new Web3Error('Invalid Subscription NFT contract time address') } - if (!isValidAddress(this.subscriptionNFTContractCredtisAddress as string)) { + if (!isValidAddress(this.subscriptionNFTContractCreditsAddress as string)) { throw new Web3Error('Invalid Subscription NFT contract credits address') } this.sdk.contracts.loadNft1155(this.subscriptionNFTContractTimeAddress as string) - this.sdk.contracts.loadNft1155(this.subscriptionNFTContractCredtisAddress as string) + this.sdk.contracts.loadNft1155(this.subscriptionNFTContractCreditsAddress as string) this.networkFeeReceiver = await this.fullSDK.keeper.nvmConfig.getFeeReceiver() this.networkFee = await this.fullSDK.keeper.nvmConfig.getNetworkFee() return { From 51823d92e5d8da7ed4697340ffc4af58dea7ba87 Mon Sep 17 00:00:00 2001 From: enrique Date: Mon, 15 Jul 2024 13:22:22 +0200 Subject: [PATCH 03/17] fix: error --- src/nevermined/NvmApp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nevermined/NvmApp.ts b/src/nevermined/NvmApp.ts index 8177122dc..e25804117 100644 --- a/src/nevermined/NvmApp.ts +++ b/src/nevermined/NvmApp.ts @@ -393,7 +393,7 @@ export class NvmApp { }, ], providers: this.assetProviders, - nftContractAddress: this.subscriptionNFTContractCredtisAddress, + nftContractAddress: this.subscriptionNFTContractCreditsAddress, preMint: false, }) From feb760423636e2eb263bf7e334d4a427ded9132a Mon Sep 17 00:00:00 2001 From: enrique Date: Mon, 15 Jul 2024 13:29:54 +0200 Subject: [PATCH 04/17] fix: test --- integration/nevermined/NVMAppAPI.test.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/integration/nevermined/NVMAppAPI.test.ts b/integration/nevermined/NVMAppAPI.test.ts index 72ff277cd..a8b97000c 100644 --- a/integration/nevermined/NVMAppAPI.test.ts +++ b/integration/nevermined/NVMAppAPI.test.ts @@ -2,17 +2,17 @@ import chai, { assert } from 'chai' import chaiAsPromised from 'chai-as-promised' -import config from '../../test/config' -import TestContractHandler from '../../test/keeper/TestContractHandler' -import { Nevermined } from '../../src/nevermined/Nevermined' -import { NvmAccount } from '../../src/models/NvmAccount' +import { NativeTokenAddress } from '../../src/constants/AssetConstants' +import { NvmAppMetadata } from '../../src/ddo/NvmAppMetadata' +import { Web3Error } from '../../src/errors/NeverminedErrors' import { AssetPrice } from '../../src/models/AssetPrice' -import { ResourceAuthentication } from '../../src/types/DDOTypes' +import { NvmAccount } from '../../src/models/NvmAccount' +import { Nevermined } from '../../src/nevermined/Nevermined' import { NVMAppEnvironments, NvmApp } from '../../src/nevermined/NvmApp' import { SubscriptionCreditsNFTApi } from '../../src/nevermined/api/nfts/SubscriptionCreditsNFTApi' -import { NativeTokenAddress } from '../../src/constants/AssetConstants' -import { Web3Error } from '../../src/errors/NeverminedErrors' -import { NvmAppMetadata } from '../../src/ddo/NvmAppMetadata' +import { ResourceAuthentication } from '../../src/types/DDOTypes' +import config from '../../test/config' +import TestContractHandler from '../../test/keeper/TestContractHandler' chai.use(chaiAsPromised) @@ -84,7 +84,10 @@ describe('NVM App API', () => { }) it('I want to search content from the app', async () => { - nvmApp = await NvmApp.getInstance(NVMAppEnvironments.Local) + nvmApp = await NvmApp.getInstance(NVMAppEnvironments.Local, { + subscriptionNFTContractTimeAddress: subscriptionNFTAddress, + subscriptionNFTContractCreditsAddress: subscriptionNFTAddress, + }) const results = await nvmApp.search.query({}) console.log(JSON.stringify(results.totalResults)) From 3969e7e905477e36349de73339f37e04fc80d0cd Mon Sep 17 00:00:00 2001 From: enrique Date: Mon, 15 Jul 2024 13:59:57 +0200 Subject: [PATCH 05/17] fix: tests --- integration/nevermined/NVMAppAPI.test.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/integration/nevermined/NVMAppAPI.test.ts b/integration/nevermined/NVMAppAPI.test.ts index a8b97000c..ba8fc1294 100644 --- a/integration/nevermined/NVMAppAPI.test.ts +++ b/integration/nevermined/NVMAppAPI.test.ts @@ -84,10 +84,7 @@ describe('NVM App API', () => { }) it('I want to search content from the app', async () => { - nvmApp = await NvmApp.getInstance(NVMAppEnvironments.Local, { - subscriptionNFTContractTimeAddress: subscriptionNFTAddress, - subscriptionNFTContractCreditsAddress: subscriptionNFTAddress, - }) + nvmApp = await NvmApp.getInstance(NVMAppEnvironments.Local) const results = await nvmApp.search.query({}) console.log(JSON.stringify(results.totalResults)) @@ -101,7 +98,11 @@ describe('NVM App API', () => { it('Overwrite the default config with some parameters', async () => { assert.notEqual(nvmApp.config.artifactsFolder, './artifacts') - nvmApp = await NvmApp.getInstance(NVMAppEnvironments.Local, config) + nvmApp = await NvmApp.getInstance(NVMAppEnvironments.Local, { + ...config, + subscriptionNFTContractTimeAddress: subscriptionNFTAddress, + subscriptionNFTContractCreditsAddress: subscriptionNFTAddress, + }) assert.equal(nvmApp.config.artifactsFolder, './artifacts') }) From 4fd4edb2730c5671ce3c188312477b9bc3126c76 Mon Sep 17 00:00:00 2001 From: enrique Date: Mon, 15 Jul 2024 14:41:37 +0200 Subject: [PATCH 06/17] feat: use right name --- integration/nevermined/NVMAppAPI.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/nevermined/NVMAppAPI.test.ts b/integration/nevermined/NVMAppAPI.test.ts index ba8fc1294..b368c41b9 100644 --- a/integration/nevermined/NVMAppAPI.test.ts +++ b/integration/nevermined/NVMAppAPI.test.ts @@ -100,8 +100,8 @@ describe('NVM App API', () => { assert.notEqual(nvmApp.config.artifactsFolder, './artifacts') nvmApp = await NvmApp.getInstance(NVMAppEnvironments.Local, { ...config, - subscriptionNFTContractTimeAddress: subscriptionNFTAddress, - subscriptionNFTContractCreditsAddress: subscriptionNFTAddress, + nftContractTimeAddress: subscriptionNFTAddress, + nftContractCreditsAddress: subscriptionNFTAddress, }) assert.equal(nvmApp.config.artifactsFolder, './artifacts') }) From 019bebec8059a23e45ea9cd7fb7a75c82963ce1f Mon Sep 17 00:00:00 2001 From: enrique Date: Mon, 15 Jul 2024 17:25:52 +0200 Subject: [PATCH 07/17] feat: make tests pass --- integration/nevermined/NVMAppAPI.test.ts | 2 + src/nevermined/NvmApp.ts | 58 +++++++++++------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/integration/nevermined/NVMAppAPI.test.ts b/integration/nevermined/NVMAppAPI.test.ts index b368c41b9..ec3762010 100644 --- a/integration/nevermined/NVMAppAPI.test.ts +++ b/integration/nevermined/NVMAppAPI.test.ts @@ -192,6 +192,7 @@ describe('NVM App API', () => { 2n, // default cost in credits for every succesful query to the agent 1n, // min amount of credits to be consumed 5n, // max amount of credits to be consumed + subscriptionNFTAddress, ) assert.isDefined(ddo) @@ -222,6 +223,7 @@ describe('NVM App API', () => { datasetMetadata, subscriptionDid, 1n, // every file download costs 1 credit to the subscriber + subscriptionNFTAddress, ) assert.isDefined(ddo) diff --git a/src/nevermined/NvmApp.ts b/src/nevermined/NvmApp.ts index e25804117..9b15282c3 100644 --- a/src/nevermined/NvmApp.ts +++ b/src/nevermined/NvmApp.ts @@ -325,16 +325,10 @@ export class NvmApp { preMint: false, }) - return this.fullSDK.nfts1155.create( - nftAttributes, - this.userAccount, - { - metadata: PublishMetadataOptions.OnlyMetadataAPI, - did: PublishOnChainOptions.DIDRegistry, - }, - // TODO: Review ZeroDev integration as part of the NvmAccount - // { ...(this.useZeroDevSigner && { zeroDevSigner: this.zeroDevSignerAccount }) }, - ) + return this.fullSDK.nfts1155.create(nftAttributes, this.userAccount, { + metadata: PublishMetadataOptions.OnlyMetadataAPI, + did: PublishOnChainOptions.DIDRegistry, + }) } /** @@ -675,6 +669,7 @@ export class NvmApp { * @param costInCredits - The cost in credits (default: 1). * @param minCreditsToCharge - The minimum credits required to charge (default: 1). * @param maxCreditsToCharge - The maximum credits to charge (default: 1). + * @param nftContractAddress - The address of the NFT contract associated with the file asset. * @returns A promise that resolves to the progress steps and the registered DDO. * @throws {Web3Error} If Web3 is not connected. * @throws {Error} If the metadata validation fails. @@ -685,6 +680,7 @@ export class NvmApp { costInCredits = 1n, minCreditsToCharge = 1n, maxCreditsToCharge = 1n, + nftContractAddress: string, ): SubscribablePromise { if (!this.fullSDK || !this.isWeb3Connected() || !this.userAccount) throw new Web3Error('Web3 not connected, try calling the connect method first') @@ -710,19 +706,14 @@ export class NvmApp { }, ], providers: this.assetProviders, + nftContractAddress, preMint: false, }) - return this.fullSDK.nfts1155.create( - nftAttributes, - this.userAccount, - { - metadata: PublishMetadataOptions.OnlyMetadataAPI, - did: PublishOnChainOptions.DIDRegistry, - }, - // TODO: Review ZeroDev integration as part of the NvmAccount - // { ...(this.useZeroDevSigner && { zeroDevSigner: this.zeroDevSignerAccount }) }, - ) + return this.fullSDK.nfts1155.create(nftAttributes, this.userAccount, { + metadata: PublishMetadataOptions.OnlyMetadataAPI, + did: PublishOnChainOptions.DIDRegistry, + }) } public async registerServiceAssetAsync( @@ -731,6 +722,7 @@ export class NvmApp { costInCredits = 1n, minCreditsToCharge = 1n, maxCreditsToCharge = 1n, + nftContractAddress: string, ): Promise { return await this.registerServiceAsset( metadata, @@ -738,6 +730,7 @@ export class NvmApp { costInCredits, minCreditsToCharge, maxCreditsToCharge, + nftContractAddress, ) } @@ -747,6 +740,7 @@ export class NvmApp { * @param metadata - The metadata of the file asset. * @param subscriptionDid - The subscription DID (Decentralized Identifier) associated with the file asset. * @param costInCredits - The cost of the file asset in credits (default is 1). + * @param nftContractAddress - The address of the NFT contract associated with the file asset. * @returns A `SubscribablePromise` that resolves to a `DDO` (Decentralized Data Object) representing the registered file asset. * @throws {Web3Error} If the Web3 connection is not established. * @throws {Error} If the file asset metadata is not valid. @@ -755,6 +749,7 @@ export class NvmApp { metadata: MetaData, subscriptionDid: string, costInCredits = 1n, + nftContractAddress: string, ): SubscribablePromise { if (!this.fullSDK || !this.isWeb3Connected() || !this.userAccount) throw new Web3Error('Web3 not connected, try calling the connect method first') @@ -777,19 +772,14 @@ export class NvmApp { }, ], providers: this.assetProviders, + nftContractAddress, preMint: false, }) - return this.fullSDK.nfts1155.create( - nftAttributes, - this.userAccount, - { - metadata: PublishMetadataOptions.OnlyMetadataAPI, - did: PublishOnChainOptions.DIDRegistry, - }, - // TODO: Review ZeroDev integration as part of the NvmAccount - // { ...(this.useZeroDevSigner && { zeroDevSigner: this.zeroDevSignerAccount }) }, - ) + return this.fullSDK.nfts1155.create(nftAttributes, this.userAccount, { + metadata: PublishMetadataOptions.OnlyMetadataAPI, + did: PublishOnChainOptions.DIDRegistry, + }) } /** @@ -804,8 +794,14 @@ export class NvmApp { metadata: MetaData, subscriptionDid: string, costInCredits = 1n, + nftContractAddress: string, ): Promise { - return await this.registerFileAsset(metadata, subscriptionDid, costInCredits) + return await this.registerFileAsset( + metadata, + subscriptionDid, + costInCredits, + nftContractAddress, + ) } /** From 4820951f880f83da41ac59997076df121478f3d5 Mon Sep 17 00:00:00 2001 From: eruizgar91 Date: Mon, 15 Jul 2024 15:52:15 +0000 Subject: [PATCH 08/17] Automated CHANGELOG.md update Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25d24faef..856b041a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ 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.0.18-rc0](https://github.com/nevermined-io/sdk-js/compare/v3.0.17...v3.0.18-rc0) + +> 15 July 2024 + +- docs: updating documentation [skip actions] [`67b3644`](https://github.com/nevermined-io/sdk-js/commit/67b364426f50da9468a5c6c15a107bcddbfc2def) +- feat: update to support 2 subscription addresses [`47d50ac`](https://github.com/nevermined-io/sdk-js/commit/47d50acff14bfe5d5c7756ad3d86a0d1af107cf2) +- feat: make tests pass [`019bebe`](https://github.com/nevermined-io/sdk-js/commit/019bebec8059a23e45ea9cd7fb7a75c82963ce1f) + #### [v3.0.17](https://github.com/nevermined-io/sdk-js/compare/v3.0.17-rc1...v3.0.17) > 11 July 2024 @@ -2100,7 +2108,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). > 2 May 2022 -- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) +- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) - Adding v0.19.21 Changelog updates [`c93cdc5`](https://github.com/nevermined-io/sdk-js/commit/c93cdc55f139a43db4130ccb0f80924d2645a931) #### [v0.19.21](https://github.com/nevermined-io/sdk-js/compare/v0.19.20...v0.19.21) @@ -2363,7 +2371,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). > 18 January 2022 -- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) +- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) - [wip] Create agreement+pay in one transaction [`#183`](https://github.com/nevermined-io/sdk-js/pull/183) - Adapting to contracts `v1.3.3` [`#177`](https://github.com/nevermined-io/sdk-js/pull/177) - Adding v0.17.2 Changelog updates [`5eddda4`](https://github.com/nevermined-io/sdk-js/commit/5eddda43954e013e6e6f7344c9a877d801aacb5c) @@ -2869,7 +2877,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Feature/sync develop [`#268`](https://github.com/nevermined-io/sdk-js/pull/268) - Quick fix for non-eip1559 networks [`#266`](https://github.com/nevermined-io/sdk-js/pull/266) - integrate Permissions and refactor search query [`#264`](https://github.com/nevermined-io/sdk-js/pull/264) -- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) +- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) - Get the keeper version from the artifacts instead of package version [`#244`](https://github.com/nevermined-io/sdk-js/pull/244) - replace `metadata-api` url by `marketplace-api` and sort type [`#243`](https://github.com/nevermined-io/sdk-js/pull/243) - fixing issues with BigNumbers [`#246`](https://github.com/nevermined-io/sdk-js/pull/246) @@ -2908,7 +2916,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Feature/190 add did to sec markets [`#191`](https://github.com/nevermined-io/sdk-js/pull/191) - Adding utility methods for getting nft token uri [`#189`](https://github.com/nevermined-io/sdk-js/pull/189) - Lint ... [`#187`](https://github.com/nevermined-io/sdk-js/pull/187) -- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) +- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) - [wip] Create agreement+pay in one transaction [`#183`](https://github.com/nevermined-io/sdk-js/pull/183) - Adapting to contracts `v1.3.3` [`#177`](https://github.com/nevermined-io/sdk-js/pull/177) - Correct typo in route [`#184`](https://github.com/nevermined-io/sdk-js/pull/184) From 6d9b055ba395f8a7f6ab8f1f1fd348edc8023b6f Mon Sep 17 00:00:00 2001 From: enrique Date: Tue, 16 Jul 2024 12:11:21 +0200 Subject: [PATCH 09/17] feat: udpate with isolatedModules removed --- package.json | 2 +- src/models/NeverminedOptions.ts | 10 ++++++++++ tsconfig.eslint.json | 2 +- tsconfig.json | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 1e18e8b62..ca88d3aa2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "3.0.18-rc0", + "version": "3.0.18-rc1", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts", diff --git a/src/models/NeverminedOptions.ts b/src/models/NeverminedOptions.ts index 258533285..8ce2a1cd4 100644 --- a/src/models/NeverminedOptions.ts +++ b/src/models/NeverminedOptions.ts @@ -97,4 +97,14 @@ export class NeverminedOptions { * Contracts version */ public contractsVersion?: string + + /** + * NFT contract address for time-based subscriptions + */ + public nftContractTimeAddress?: string + + /** + * NFT contract address for credit-based subscriptions + */ + public nftContractCreditsAddress?: string } diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 743724b82..246d036e9 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -1,7 +1,7 @@ { "compilerOptions": { "strict": true, - "isolatedModules": true, + // "isolatedModules": true, "useDefineForClassFields": true, // "noImplicitReturns": true, // Not enabled by default in `strict` mode. // "useUnknownInCatchVariables": true, // TODO: This would normally be enabled in `strict` mode but would require some adjustments to the codebase. diff --git a/tsconfig.json b/tsconfig.json index 68e87ac3a..5c14230b0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "strict": true, - "isolatedModules": true, + // "isolatedModules": true, "useDefineForClassFields": true, // "noImplicitReturns": true, // Not enabled by default in `strict` mode. // "useUnknownInCatchVariables": true, // TODO: This would normally be enabled in `strict` mode but would require some adjustments to the codebase. From 10d116e9a199ead69b1aff597b8df59ce031f79a Mon Sep 17 00:00:00 2001 From: eruizgar91 Date: Tue, 16 Jul 2024 10:17:08 +0000 Subject: [PATCH 10/17] Automated CHANGELOG.md update Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 856b041a0..3ac68d867 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ 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.0.18-rc1](https://github.com/nevermined-io/sdk-js/compare/v3.0.18-rc0...v3.0.18-rc1) + +> 16 July 2024 + +- feat: udpate with isolatedModules removed [`6d9b055`](https://github.com/nevermined-io/sdk-js/commit/6d9b055ba395f8a7f6ab8f1f1fd348edc8023b6f) +- Automated CHANGELOG.md update [`4820951`](https://github.com/nevermined-io/sdk-js/commit/4820951f880f83da41ac59997076df121478f3d5) + #### [v3.0.18-rc0](https://github.com/nevermined-io/sdk-js/compare/v3.0.17...v3.0.18-rc0) > 15 July 2024 From c18993168af73eda9078d9ce9e33e2f0366ed560 Mon Sep 17 00:00:00 2001 From: enrique Date: Tue, 16 Jul 2024 12:24:10 +0200 Subject: [PATCH 11/17] fix: issue --- src/models/NeverminedOptions.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/models/NeverminedOptions.ts b/src/models/NeverminedOptions.ts index 8ce2a1cd4..258533285 100644 --- a/src/models/NeverminedOptions.ts +++ b/src/models/NeverminedOptions.ts @@ -97,14 +97,4 @@ export class NeverminedOptions { * Contracts version */ public contractsVersion?: string - - /** - * NFT contract address for time-based subscriptions - */ - public nftContractTimeAddress?: string - - /** - * NFT contract address for credit-based subscriptions - */ - public nftContractCreditsAddress?: string } From a0346419e7055090f758e1f570b61fad857c1466 Mon Sep 17 00:00:00 2001 From: eruizgar91 Date: Tue, 16 Jul 2024 10:31:20 +0000 Subject: [PATCH 12/17] Automated CHANGELOG.md update Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ac68d867..899e77951 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - feat: udpate with isolatedModules removed [`6d9b055`](https://github.com/nevermined-io/sdk-js/commit/6d9b055ba395f8a7f6ab8f1f1fd348edc8023b6f) - Automated CHANGELOG.md update [`4820951`](https://github.com/nevermined-io/sdk-js/commit/4820951f880f83da41ac59997076df121478f3d5) +- fix: issue [`c189931`](https://github.com/nevermined-io/sdk-js/commit/c18993168af73eda9078d9ce9e33e2f0366ed560) #### [v3.0.18-rc0](https://github.com/nevermined-io/sdk-js/compare/v3.0.17...v3.0.18-rc0) From d2d81d9458263132bf1c48771a221c68ec0769e0 Mon Sep 17 00:00:00 2001 From: enrique Date: Tue, 16 Jul 2024 13:06:38 +0200 Subject: [PATCH 13/17] fix: value initialization --- package.json | 2 +- src/nevermined/NvmApp.ts | 2 +- tsconfig.json | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ca88d3aa2..6c7f0ab0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "3.0.18-rc1", + "version": "3.0.18-rc2", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts", diff --git a/src/nevermined/NvmApp.ts b/src/nevermined/NvmApp.ts index 9b15282c3..bd5f49850 100644 --- a/src/nevermined/NvmApp.ts +++ b/src/nevermined/NvmApp.ts @@ -105,7 +105,7 @@ export class NvmApp { */ public static async getInstance( appEnv: NVMAppEnvironments, - config?: Partial, + config?: Partial, ): Promise { const defaultEnvConfig = this.getConfigFromTagName(appEnv) const mergedConfig = config ? { ...defaultEnvConfig, ...config } : defaultEnvConfig diff --git a/tsconfig.json b/tsconfig.json index 5c14230b0..16c81f167 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { "strict": true, - // "isolatedModules": true, "useDefineForClassFields": true, // "noImplicitReturns": true, // Not enabled by default in `strict` mode. // "useUnknownInCatchVariables": true, // TODO: This would normally be enabled in `strict` mode but would require some adjustments to the codebase. From dea6693169800e767de3766cf964d490b9126c88 Mon Sep 17 00:00:00 2001 From: eruizgar91 Date: Tue, 16 Jul 2024 11:10:31 +0000 Subject: [PATCH 14/17] Automated CHANGELOG.md update Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 899e77951..6d1555a29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ 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.0.18-rc2](https://github.com/nevermined-io/sdk-js/compare/v3.0.18-rc1...v3.0.18-rc2) + +> 16 July 2024 + +- fix: value initialization [`d2d81d9`](https://github.com/nevermined-io/sdk-js/commit/d2d81d9458263132bf1c48771a221c68ec0769e0) +- Automated CHANGELOG.md update [`a034641`](https://github.com/nevermined-io/sdk-js/commit/a0346419e7055090f758e1f570b61fad857c1466) + #### [v3.0.18-rc1](https://github.com/nevermined-io/sdk-js/compare/v3.0.18-rc0...v3.0.18-rc1) > 16 July 2024 From 698162f97af15052284a8946a8cfb163586f6ce3 Mon Sep 17 00:00:00 2001 From: enrique Date: Tue, 16 Jul 2024 17:24:54 +0200 Subject: [PATCH 15/17] feat: add check --- package.json | 2 +- src/nevermined/api/RegistryBaseApi.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6c7f0ab0e..9fb845161 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "3.0.18-rc2", + "version": "3.0.18-rc3", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts", diff --git a/src/nevermined/api/RegistryBaseApi.ts b/src/nevermined/api/RegistryBaseApi.ts index 045ea1a95..6084a1492 100644 --- a/src/nevermined/api/RegistryBaseApi.ts +++ b/src/nevermined/api/RegistryBaseApi.ts @@ -404,7 +404,10 @@ export abstract class RegistryBaseApi extends Instantiable { ) metadataService.attributes.encryptedFiles = JSON.parse(encryptedFilesResponse)['hash'] - if (metadataService.attributes.main.type === 'service') { + if ( + metadataService.attributes.main.type === 'service' && + metadataService.attributes.main.webService.internalAttributes + ) { const encryptedServiceAttributesResponse = await this.nevermined.services.node.encrypt( ddo.id, JSON.stringify(metadataService.attributes.main.webService.internalAttributes), From 59e78ce08a12963dc44acb92638a983ce526955e Mon Sep 17 00:00:00 2001 From: eruizgar91 Date: Tue, 16 Jul 2024 15:42:24 +0000 Subject: [PATCH 16/17] Automated CHANGELOG.md update Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d1555a29..147e7a09d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ 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.0.18-rc3](https://github.com/nevermined-io/sdk-js/compare/v3.0.18-rc2...v3.0.18-rc3) + +> 16 July 2024 + +- feat: add check [`698162f`](https://github.com/nevermined-io/sdk-js/commit/698162f97af15052284a8946a8cfb163586f6ce3) +- Automated CHANGELOG.md update [`dea6693`](https://github.com/nevermined-io/sdk-js/commit/dea6693169800e767de3766cf964d490b9126c88) + #### [v3.0.18-rc2](https://github.com/nevermined-io/sdk-js/compare/v3.0.18-rc1...v3.0.18-rc2) > 16 July 2024 From 6166728c9d3f05aa35a76a0abc36b34fd53d7400 Mon Sep 17 00:00:00 2001 From: enrique Date: Tue, 16 Jul 2024 17:50:49 +0200 Subject: [PATCH 17/17] feat: bumpversion --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9fb845161..62d02758d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "3.0.18-rc3", + "version": "3.0.18", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts",