-
Notifications
You must be signed in to change notification settings - Fork 277
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
feat!: Separate fungible and non-fungible assets #5308
base: main
Are you sure you want to change the base?
feat!: Separate fungible and non-fungible assets #5308
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this looks great. @0x009922 what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO looks great too!
Finally, this separation makes sense, and it's easier to understand how to use both types.
.domain(&nft_id.domain) | ||
.expect("INTERNAL BUG: Can't find domain of NFT to register"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be FindError::Domain
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two options. If domain check is after NFT is found and removed, it should be .expect("INTERNAL BUG ...")
. If before, it should be FindError::Domain
(#5308 (comment)). Changed to have domain check after.
@@ -59,7 +59,7 @@ | |||
"Register": { | |||
"AssetDefinition": { | |||
"id": "rose#wonderland", | |||
"type": "Numeric", | |||
"spec": "Numeric", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemingly doesn't make sense. spec
must be { "scale": 0 }
or something, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we have this behaviour for formatting NumericSpec
:
scale = 0
is formatted asNumeric(0)
scale = None
is formatted as justNumeric
iroha/crates/iroha_numeric/src/lib.rs
Lines 380 to 385 in 591dd5e
impl core::fmt::Display for NumericSpec { | |
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { | |
write!(f, "Numeric")?; | |
if let Some(scale) = self.scale { | |
write!(f, "({scale})")?; | |
} |
One option I see here is to change spec: NumericSpec
field of AssetDefinition
to just scale: Option<u32>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemingly doesn't make sense.
spec
must be{ "scale": 0 }
or something, right?
No, it's not necessary that spec is defined. When scale is undefined the number is a variable precision as opposed to fixed precision when it is defined
Signed-off-by: Dmitry Murzin <[email protected]>
Signed-off-by: Dmitry Murzin <[email protected]>
Signed-off-by: Dmitry Murzin <[email protected]>
Signed-off-by: Dmitry Murzin <[email protected]>
Signed-off-by: Dmitry Murzin <[email protected]>
Signed-off-by: Dmitry Murzin <[email protected]>
23c5252
to
20431ef
Compare
Context
Currently, there are two asset types:
Numeric
andStore
. Because they are quite different entities, it is proposed to separate them. See #4087 for details.AssetType
inconsistencies #4087Solution
This PR removes
Store
asset type and instead introduces newNft
entity.Nft
is similar toAssetDefinition
(from implementation point of view), see #4672 (comment) for types visualization.Naming:
nft$domain
asset#domain#account@domain
orasset##account@domain
ISI changes:
Register<Asset>
/Unregister<Asset>
Mint<Numeric, Asset>
/Burn<Numeric, Asset>
Transfer<Asset, Numeric, Account>
Transfer<Asset, Metadata, Account>
Metadata
argument 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:
FindNfts
Permission changes:
CanRegisterAsset
/CanUnregisterAsset
CanModifyAssetMetadata
CanRegisterNft
/CanUnregisterNft
CanTransferNft
CanModifyNftMetadata
Migration Guide
AssetDefinition::store
,AssetType::Store
,AssetValue::Store
. UseNft
insteadRegister<Asset>
/Unregister<Asset>
ISI for numeric assets. UseMint<Numeric, Asset>
instead of register, andBurn<Numeric, Asset>
to zero value instead of unregister.Solution
sectionReview notes
Files with important changes:
crates/iroha_data_model/src/nft.rs
- New structsNft
andNftId
crates/iroha_data_model/src/asset.rs
- Changes toAsset
andAssetDefinition
crates/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
.