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
17pub use sp_core::{ecdsa, ed25519, sr25519};
18
19#[derive(
21 Clone, Copy, Debug, Encode, Decode, CompactAs, Default, PartialEq, Eq, PartialOrd, Ord,
22)]
23#[cfg_attr(feature = "std", derive(TypeInfo))]
24pub struct OldWeight(pub u64);
25
26#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)]
27#[cfg_attr(feature = "std", derive(TypeInfo))]
28pub enum MultiSignature {
29 Ed25519(ed25519::Signature),
31 Sr25519(sr25519::Signature),
33 Ecdsa(ecdsa::Signature),
35}
36
37#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, PartialOrd, Ord)]
38#[cfg_attr(feature = "std", derive(Hash))]
39#[cfg_attr(feature = "std", derive(TypeInfo))]
40pub enum MultiAddress<AccountId, AccountIndex> {
41 Id(AccountId),
43 Index(#[codec(compact)] AccountIndex),
45 Raw(Vec<u8>),
47 Address32([u8; 32]),
49 Address20([u8; 20]),
51}
52
53impl<AccountId: Clone, AccountIndex> From<&AccountId> for MultiAddress<AccountId, AccountIndex> {
54 fn from(other: &AccountId) -> Self {
55 Self::Id(other.clone())
56 }
57}
58
59impl<AccountId, AccountIndex> From<AccountId> for MultiAddress<AccountId, AccountIndex> {
60 fn from(other: AccountId) -> Self {
61 Self::Id(other)
62 }
63}
64
65#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Encode, Decode)]
66#[cfg_attr(feature = "std", derive(TypeInfo, StorageLayout))]
67pub struct IdentityId(pub [u8; 32]);
68
69impl fmt::Debug for IdentityId {
70 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
71 let h = hex::encode(&self.0);
72 write!(f, "0x{}", h)
73 }
74}
75
76impl From<[u8; 32]> for IdentityId {
77 fn from(raw: [u8; 32]) -> Self {
78 Self(raw)
79 }
80}
81
82#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Encode, Decode)]
83#[cfg_attr(feature = "std", derive(TypeInfo, StorageLayout))]
84pub struct AssetId([u8; 16]);