Skip to content

Commit

Permalink
Merge pull request #616 from nevermined-io/fix/credit_owner_download
Browse files Browse the repository at this point in the history
Allowing credits asset publisher to download files
  • Loading branch information
aaitor authored Nov 24, 2023
2 parents 0379128 + c94b529 commit 260ad1d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion integration/external/Services_NFT1155.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 3 additions & 2 deletions src/ddo/DDO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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)
}

/**
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions src/keeper/contracts/templates/NFTAccessTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ export class NFTAccessTemplate extends BaseTemplate<NFTAccessTemplateParams, Ser
return false
}

const subscriptionOwner = await this.nevermined.assets.owner(ddo.id)
const consumerIsOwner =
params.consumer_address.toLowerCase() === subscriptionOwner.toLowerCase()

if (consumerIsOwner) {
// User calling is the asset owner so skipping track()
return false
}

const nftAccessService = (
params.service_index && params.service_index > 0
? ddo.findServiceByIndex(params.service_index)
Expand Down

0 comments on commit 260ad1d

Please sign in to comment.