Skip to content

Commit

Permalink
Add AssetId to codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
HenriqueNogara committed Oct 22, 2024
1 parent 84d76ee commit ddebbb5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 29 deletions.
11 changes: 0 additions & 11 deletions crates/polymesh-api-client/src/basic_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,17 +709,6 @@ impl<'de> Deserialize<'de> for IdentityId {
#[cfg_attr(all(feature = "std", feature = "type_info"), derive(TypeInfo))]
pub struct AssetId([u8; 16]);

impl From<[u8; 16]> for AssetId {
fn from(mut value: [u8; 16]) -> Self {
// Version 8.
value[6] = (value[6] & 0x0f) | 0x80;
// Standard RFC4122 variant (bits 10xx)
value[8] = (value[8] & 0x3f) | 0x80;

AssetId(value)
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
4 changes: 4 additions & 0 deletions crates/polymesh-api-codegen/src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ mod v14 {
"polymesh_primitives::identity_id::IdentityId",
quote!(#api_interface::IdentityId),
),
(
"polymesh_primitives::asset::AssetId",
quote!(#api_interface::AssetId),
),
(
"sp_runtime::multiaddress::MultiAddress",
quote!(#api_interface::MultiAddress),
Expand Down
11 changes: 0 additions & 11 deletions crates/polymesh-api-ink/src/basic_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,3 @@ impl From<[u8; 32]> for IdentityId {
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Encode, Decode)]
#[cfg_attr(feature = "std", derive(TypeInfo, StorageLayout))]
pub struct AssetId([u8; 16]);

impl From<[u8; 16]> for AssetId {
fn from(mut value: [u8; 16]) -> Self {
// Version 8.
value[6] = (value[6] & 0x0f) | 0x80;
// Standard RFC4122 variant (bits 10xx)
value[8] = (value[8] & 0x3f) | 0x80;

AssetId(value)
}
}
4 changes: 1 addition & 3 deletions crates/polymesh-api-tester/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#[cfg(feature = "polymesh_v7")]
pub use polymesh_api::polymesh::types::polymesh_primitives::asset::AssetId;
pub use polymesh_api::{
client::{AccountId, IdentityId, Signer},
client::{AccountId, AssetId, IdentityId, Signer},
polymesh::types::{
polymesh_primitives::{
secondary_key::{KeyRecord, Permissions, SecondaryKey},
Expand Down
6 changes: 2 additions & 4 deletions crates/polymesh-api-tester/src/tester.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::collections::HashMap;

#[cfg(feature = "polymesh_v7")]
use polymesh_api::polymesh::types::polymesh_primitives::{
asset::AssetId, secondary_key::ExtrinsicPermissions,
};
use polymesh_api::polymesh::types::polymesh_primitives::secondary_key::ExtrinsicPermissions;
use polymesh_api::{
client::{AccountId, IdentityId},
client::{AccountId, AssetId, IdentityId},
polymesh::types::polymesh_primitives::{
secondary_key::{KeyRecord, Permissions, SecondaryKey},
subset::SubsetRestriction,
Expand Down

0 comments on commit ddebbb5

Please sign in to comment.