--- a/primitives/data-structs/src/lib.rs +++ b/primitives/data-structs/src/lib.rs @@ -181,7 +181,7 @@ pub struct TokenData { pub properties: Vec, pub owner: Option, - pub pieces: Option, + pub pieces: u128, } pub struct OverflowError; --- a/runtime/common/src/runtime_apis.rs +++ b/runtime/common/src/runtime_apis.rs @@ -90,7 +90,7 @@ let token_data = TokenData { properties: Self::token_properties(collection, token_id, keys)?, owner: Self::token_owner(collection, token_id)?, - pieces: Self::total_pieces(collection, token_id)? + pieces: Self::total_pieces(collection, token_id)?.expect("Token pieces always must have some value"), }; Ok(token_data) --- a/tests/src/interfaces/unique/definitions.ts +++ b/tests/src/interfaces/unique/definitions.ts @@ -79,5 +79,6 @@ allowed: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam()], 'bool'), nextSponsored: fun('Get number of blocks when sponsored transaction is available', [collectionParam, crossAccountParam(), tokenParam], 'Option'), effectiveCollectionLimits: fun('Get effective collection limits', [collectionParam], 'Option'), + totalPieces: fun('Get total pieces of token', [collectionParam, tokenParam], 'Option'), }, };