feat!: Separate fungible and non-fungible assets#5308
Merged
dima74 merged 6 commits intohyperledger-iroha:mainfrom Feb 27, 2025
Merged
feat!: Separate fungible and non-fungible assets#5308dima74 merged 6 commits intohyperledger-iroha:mainfrom
dima74 merged 6 commits intohyperledger-iroha:mainfrom
Conversation
s8sato
reviewed
Feb 10, 2025
s8sato
reviewed
Feb 10, 2025
s8sato
reviewed
Feb 12, 2025
0x009922
reviewed
Feb 21, 2025
Contributor
0x009922
left a comment
There was a problem hiding this comment.
IMO looks great too!
Finally, this separation makes sense, and it's easier to understand how to use both types.
20431ef to
f2820cf
Compare
mversic
approved these changes
Feb 24, 2025
7 tasks
s8sato
approved these changes
Feb 25, 2025
Signed-off-by: Dmitry Murzin <diralik@yandex.ru>
Signed-off-by: Dmitry Murzin <diralik@yandex.ru>
Signed-off-by: Dmitry Murzin <diralik@yandex.ru>
Signed-off-by: Dmitry Murzin <diralik@yandex.ru>
Signed-off-by: Dmitry Murzin <diralik@yandex.ru>
Signed-off-by: Dmitry Murzin <diralik@yandex.ru>
f2820cf to
ced33ed
Compare
Contributor
Author
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Currently, there are two asset types:
NumericandStore. Because they are quite different entities, it is proposed to separate them. See #4087 for details.AssetTypeinconsistencies #4087World#4672 (comment)Solution
This PR removes
Storeasset type and instead introduces newNftentity.Nftis similar toAssetDefinition(from implementation point of view), see #4672 (comment) for types visualization.Naming:
nft$domainasset#domain#account@domainorasset##account@domainISI changes:
Register<Asset>/Unregister<Asset>Mint<Numeric, Asset>/Burn<Numeric, Asset>Transfer<Asset, Numeric, Account>Transfer<Asset, Metadata, Account>Metadataargument is ignored. Also looks like we have bug in implementation, and asset is not moved, but copiedSetKeyValue<Asset>RemoveKeyValue<ASset>Mint<Numeric, Asset>instead of register, andBurn<Numeric, Asset>to zero value instead of unregister.Mint<Numeric, Asset>/Burn<Numeric, Asset>Transfer<Asset, Numeric, Account>Register<Nft>/Unregister<Nft>Transfer<Account, NftId, Account>SetKeyValue<Nft>RemoveKeyValue<Nft>Queries changes:
FindNftsPermission changes:
CanRegisterAsset/CanUnregisterAssetCanModifyAssetMetadataCanRegisterNft/CanUnregisterNftCanTransferNftCanModifyNftMetadataMigration Guide
If you use only numeric assets, and don't use store assets:
Register<Asset>/Unregister<Asset>ISI for numeric assets.Mint<Numeric, Asset>instead ofRegister<Asset>Burn<Numeric, Asset>to zero value instead ofUnregister<Asset>Assetchanges:valuefield was inlined (previously had typeAssetValue, now has typeNumeric)AssetDefinitionchanges:type_: AssetTypefield was replaced withspec: NumericSpecfieldgenesis.json: it is needed to change fromto
(if you had
"type": "Numeric(N)", replace with"scale": N)If you use store assets:
AssetDefinition::store,AssetType::Store,AssetValue::Store. UseNftinsteadSolutionsectionReview notes
Files with important changes:
crates/iroha_data_model/src/nft.rs- New structsNftandNftIdcrates/iroha_data_model/src/asset.rs- Changes toAssetandAssetDefinitioncrates/iroha_core/src/smartcontracts/isi/nft.rs- ISI and Queries implementation for NFTcrates/iroha_executor/src/default/mod.rs- default executorvisit_*methods for NFTcrates/iroha_cli/src/main.rs- CLI changesTodo:
Checklist
CONTRIBUTING.md.