polymesh_api_ink/
basic_types.rs1use codec::{CompactAs, Decode, Encode};
2
3#[cfg(not(feature = "std"))]
4use alloc::vec::Vec;
5
6use alloc::fmt;
7
8#[cfg(feature = "std")]
9use scale_info::TypeInfo;
10
11#[cfg(feature = "std")]
12use ink::storage::traits::StorageLayout;
13
14pub use ink::primitives::AccountId;
15pub use sp_arithmetic::per_things;
16
17#[derive(
19 Clone, Copy, Debug, Encode, Decode, CompactAs, Default, PartialEq, Eq, PartialOrd, Ord,
20)]
21#[cfg_attr(feature = "std", derive(TypeInfo))]
22pub struct OldWeight(pub u64);
23
24#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, PartialOrd, Ord)]
25#[cfg_attr(feature = "std", derive(Hash))]
26#[cfg_attr(feature = "std", derive(TypeInfo))]
27pub enum MultiAddress<AccountId, AccountIndex> {
28 Id(AccountId),
30 Index(#[codec(compact)] AccountIndex),
32 Raw(Vec<u8>),
34 Address32([u8; 32]),
36 Address20([u8; 20]),
38}
39
40impl<AccountId: Clone, AccountIndex> From<&AccountId> for MultiAddress<AccountId, AccountIndex> {
41 fn from(other: &AccountId) -> Self {
42 Self::Id(other.clone())
43 }
44}
45
46impl<AccountId, AccountIndex> From<AccountId> for MultiAddress<AccountId, AccountIndex> {
47 fn from(other: AccountId) -> Self {
48 Self::Id(other)
49 }
50}
51
52#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Encode, Decode)]
53#[cfg_attr(feature = "std", derive(TypeInfo, StorageLayout))]
54pub struct IdentityId(pub [u8; 32]);
55
56impl fmt::Debug for IdentityId {
57 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
58 let h = hex::encode(&self.0);
59 write!(f, "0x{}", h)
60 }
61}
62
63impl From<[u8; 32]> for IdentityId {
64 fn from(raw: [u8; 32]) -> Self {
65 Self(raw)
66 }
67}
68
69#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Encode, Decode)]
70#[cfg_attr(feature = "std", derive(TypeInfo, StorageLayout))]
71pub struct AssetId([u8; 16]);