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

RMRK multi asset implementation #14

Merged
merged 14 commits into from
Dec 10, 2022
Merged

RMRK multi asset implementation #14

merged 14 commits into from
Dec 10, 2022

Conversation

Maar-io
Copy link
Contributor

@Maar-io Maar-io commented Dec 5, 2022

Adding multi Asset functionality for RMRK. (assets were called resources in previous versions of RMRK)

This ink implementation follows evm implementation of multiasset defined here
Implemented functions are:

  • fn add_asset_entry()
  • fn add_asset_to_token()
  • fn accept_asset()
  • fn reject_asset()
  • fn set_priority()

Getters

  • fn total_assets()
  • fn get_asset_uri()
  • fn total_token_assets()
  • fn get_accepted_token_assets()
  • fn remove_asset()

Events

  • AssetSet
  • AssetAddedToToken
  • AssetAccepted
  • AssetRejected
  • AssetRemoved
  • AssetPrioritySet

Test

  • Unit test
  • e2e test with tyopechain (test/multiasset.spec.ts)

Copy link
Contributor

@PierreOssun PierreOssun left a comment

Choose a reason for hiding this comment

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

Awesome Job !

logics/impls/rmrk/minting.rs Outdated Show resolved Hide resolved
logics/impls/rmrk/multiasset.rs Show resolved Hide resolved
logics/impls/rmrk/multiasset.rs Outdated Show resolved Hide resolved
logics/impls/rmrk/multiasset.rs Outdated Show resolved Hide resolved
logics/impls/rmrk/multiasset.rs Outdated Show resolved Hide resolved
contracts/rmrk/lib.rs Outdated Show resolved Hide resolved
logics/impls/rmrk/multiasset.rs Show resolved Hide resolved
logics/impls/rmrk/multiasset.rs Show resolved Hide resolved
logics/impls/rmrk/multiasset.rs Show resolved Hide resolved
tests/multiasset.spec.ts Show resolved Hide resolved
@Maar-io Maar-io merged commit 0d6f802 into main Dec 10, 2022
@Maar-io Maar-io deleted the feature/multi-assets branch December 10, 2022 18:45
Copy link
Member

@steven2308 steven2308 left a comment

Choose a reason for hiding this comment

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

Really nice stuff!
Most comments are minor or doubts due to lack of !ink knowledge. I hope you can take a look even though it's merged.

token: Id,
#[ink(topic)]
asset: AssetId,
}
Copy link
Member

Choose a reason for hiding this comment

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

I know I'm late but hopefully I can provide some help
We thought it was useful to include here the replaced asset Id. A caveat is we do it only when it was really replaced, that is for instance: You have asset A on token, then add B to replace A and also C to replace A. If B is accepted first, when you accept C, it is not really replacing A, so we would set it to zero.
I hope it makes sense 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I don't get it. Please create an issue

Copy link
Member

Choose a reason for hiding this comment

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

I think replacing assets is not yet implement, is it?
I'll create the issue when it is

contracts/rmrk/lib.rs Show resolved Hide resolved
contracts/rmrk/lib.rs Show resolved Hide resolved
contracts/rmrk/lib.rs Show resolved Hide resolved
contracts/rmrk/lib.rs Show resolved Hide resolved
logics/impls/rmrk/multiasset.rs Show resolved Hide resolved
logics/impls/rmrk/multiasset.rs Show resolved Hide resolved
}

/// Used to retrieve asset's uri
fn get_asset_uri(&self, asset_id: AssetId) -> Option<String> {
Copy link
Member

Choose a reason for hiding this comment

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

There's a big difference here we have on EVM and you might find useful.
Some context first:
On regular NFTs, there's tokenURI function which receives the tokenID. Some collections set the token URI for each token, and others do an enumerated version, so they have just a baseURI and append the tokenId to the baseURI. This saves them from doing 1 call for every NFT to set it's URI, and instead doing just 1!

We considered it might be important to have the same behavior (at least make it possible) for assetURI. So in this function we also receive token tokenId. That way, if the implementer wants some assets to be enumerated (so they only create one asset instead of possible thousands) it can be easily done by appending the tokenId at the end of the assetURI.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

apparently I did not yet implement this function, this is just a check if token exists.
I wanted to discuss it with your team. I will create an issue for someone to implement it.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's just a check, it does return a string. The check is just part of it.
Our suggestions is that this method should also receive the tokenId, but let's discuss please.


/// Used to retrieve asset's uri
fn get_asset_uri(&self, asset_id: AssetId) -> Option<String> {
self.asset_id_exists(asset_id)
Copy link
Member

Choose a reason for hiding this comment

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

This call here makes my claim to rename the function even stronger 😅 It's very confusing currently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how your comment on renaming applies for this line. Please explain

Copy link
Member

Choose a reason for hiding this comment

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

My suggestion is to rename asset_id_exists to get_asset_uri. It is very confusing currently.

logics/impls/rmrk/types.rs Show resolved Hide resolved
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.

3 participants