Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling sales with access properly #79

Merged
merged 8 commits into from
Jan 12, 2023
Merged

Handling sales with access properly #79

merged 8 commits into from
Jan 12, 2023

Conversation

mrsmkl
Copy link
Contributor

@mrsmkl mrsmkl commented Jan 4, 2023

Description

Issues that should be thought about

  • when we want to use sales with access flow?
  • if sales with access flow is used, how many tokens should the buyer buy to get access?
  • should we add a mapping to AccessProofCondition (this will require some work because the args to AccessProofCondition are just the babyjub keys)
  • another possibility is just to grant access if the user has enough NFTs

Is this PR related with an open issue?

Related to Issue #

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Follows the code style of this project.
  • Tests Cover Changes
  • Documentation

@mrsmkl mrsmkl marked this pull request as ready for review January 4, 2023 16:59
@mrsmkl mrsmkl requested review from a team as code owners January 4, 2023 16:59
src/auth/auth.service.ts Outdated Show resolved Hide resolved
src/auth/auth.service.ts Outdated Show resolved Hide resolved
src/auth/auth.service.ts Outdated Show resolved Hide resolved
@aaitor
Copy link
Member

aaitor commented Jan 5, 2023

when we want to use sales with access flow?

So the use case here should be: "As a NFT owner I want to sell them to buyers and give access to DTP encrypted contents"
I think this can be expressed via one template (NFTSalesWithAccessTemplate maybe a better name would be NFTSalesWithAccessProofTemplate) as the combination of the following conditions: Lock, Transfer, Escrow, AccessProof

or via 2 DDO services provided by the templates NFTSalesTemplate for doing the NFT purchase and a second one using the template NFTAccessProofTemplate

if sales with access flow is used, how many tokens should the buyer buy to get access?

This needs to be defined by the publisher in the DDO. I think the parameter in the sdk is nftAmount and in the DDO represented by the _numberNfts parameter in the conditions.
So if the user holds >= _numberNfts can get access.

should we add a mapping to AccessProofCondition (this will require some work because the args to AccessProofCondition are just the babyjub keys)

Extract an interface for access conditions (i.e IAccess) that is implemented by AccessCondition and AccessProofCondition would be ideal, but taking into account the babyjub parameters it looks difficult to find a common interface there that is very clean. But if you have a proposal I can take a look at it

another possibility is just to grant access if the user has enough NFTs

Yep, I think this could be achieved via the 2 services/templates scenario. I think it's cleaner/simpler than 1 template with 4 conditions.

src/auth/auth.service.ts Outdated Show resolved Hide resolved
@mrsmkl
Copy link
Contributor Author

mrsmkl commented Jan 10, 2023

when we want to use sales with access flow?

So the use case here should be: "As a NFT owner I want to sell them to buyers and give access to DTP encrypted contents" I think this can be expressed via one template (NFTSalesWithAccessTemplate maybe a better name would be NFTSalesWithAccessProofTemplate) as the combination of the following conditions: Lock, Transfer, Escrow, AccessProof

or via 2 DDO services provided by the templates NFTSalesTemplate for doing the NFT purchase and a second one using the template NFTAccessProofTemplate

The reason why the NFTSalesWithAccessTemplate exists is because it's more secure: otherwise the consumer could buy the NFTs but not get access password.

But I think the simplest approach for now is to just use the NFT Sales template instead...

another possibility is just to grant access if the user has enough NFTs

Yep, I think this could be achieved via the 2 services/templates scenario. I think it's cleaner/simpler than 1 template with 4 conditions.

I meant that the node would let the user download assets the same way as their owners, without necessarily processing the
access agreement.

const [from] = await nevermined.accounts.list()
await plugin.process(params, from, undefined)
return 'success'
}

@Post('nft-sales-proof')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this endpoint will be called by order method that will be implemented in the sdk-dtp right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess at least for now we can use the same end point as normal, basically if there's no access involved it will just be the same thing as normal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrsmkl , I think the best approach would be to use the same endpoint and identify if it's a "regular or DTP" flow. That way we maximize reusing existing code and the endpoints remains the same

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrsmkl but in case that is a DTP do we need to implement something in sdk-dtp right?

@mrsmkl mrsmkl merged commit 02fe913 into main Jan 12, 2023
@mrsmkl mrsmkl deleted the fix/nft-sales branch January 12, 2023 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants