difftreelog
fix serde no_std usage
in: master
6 files changed
pallets/inflation/Cargo.tomldiffbeforeafterboth--- a/pallets/inflation/Cargo.toml
+++ b/pallets/inflation/Cargo.toml
@@ -19,7 +19,7 @@
version = '2.0.0'
[dependencies]
-serde = { version = "1.0.119" }
+serde = { default-features = false, version = "1.0.119", features = ["derive"] }
frame-support = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
frame-system = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
pallet-balances = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
pallets/inflation/src/lib.rsdiffbeforeafterboth--- a/pallets/inflation/src/lib.rs
+++ b/pallets/inflation/src/lib.rs
@@ -10,8 +10,7 @@
#[cfg(feature = "std")]
pub use std::*;
-#[cfg(feature = "std")]
-pub use serde::*;
+pub use serde::{Serialize, Deserialize};
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
pallets/nft/Cargo.tomldiffbeforeafterboth--- a/pallets/nft/Cargo.toml
+++ b/pallets/nft/Cargo.toml
@@ -19,7 +19,7 @@
version = '2.0.0'
[dependencies]
-serde = { version = "1.0.119" }
+serde = { default-features = false, version = "1.0.119", features = ["derive"] }
frame-support = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
frame-system = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
pallet-balances = { default-features = false, version = '3.0.0', git = "https://github.com/paritytech/substrate.git", branch = "frontier" }
pallets/nft/src/eth/account.rsdiffbeforeafterboth--- a/pallets/nft/src/eth/account.rs
+++ b/pallets/nft/src/eth/account.rs
@@ -2,7 +2,6 @@
use codec::{Encode, EncodeLike, Decode};
use sp_core::{H160, H256, crypto::AccountId32};
use core::cmp::Ordering;
-#[cfg(feature = "std")]
use serde::{Serialize, Deserialize};
use pallet_evm::AddressMapping;
use sp_std::vec::Vec;
@@ -21,7 +20,7 @@
}
#[derive(Eq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Serialize, Deserialize)]
pub struct BasicCrossAccountId<T: Config> {
/// If true - then ethereum is canonical encoding
from_ethereum: bool,
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -7,9 +7,9 @@
#![cfg_attr(not(feature = "std"), no_std)]
-#[cfg(feature = "std")]
-pub use serde::*;
+pub use serde::{Serialize, Deserialize};
+
use core::ops::{Deref, DerefMut};
use codec::{Decode, Encode};
pub use frame_support::{
@@ -71,7 +71,7 @@
pub type DecimalPoints = u8;
#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Serialize, Deserialize)]
pub enum CollectionMode {
Invalid,
NFT,
pallets/nft/src/types.rsdiffbeforeafterboth1#[cfg(feature = "std")]2pub use std::*;34#[cfg(feature = "std")]5pub use serde::*;67use codec::{Decode, Encode};89pub type CollectionId = u32;10pub type TokenId = u32;11pub type DecimalPoints = u8;1213#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]14#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]15pub enum CollectionMode {16 Invalid,17 NFT,18 // decimal points19 Fungible(DecimalPoints),20 // decimal points21 ReFungible(DecimalPoints),22}2324impl Into<u8> for CollectionMode {25 fn into(self) -> u8 {26 match self {27 CollectionMode::Invalid => 0,28 CollectionMode::NFT => 1,29 CollectionMode::Fungible(_) => 2,30 CollectionMode::ReFungible(_) => 3,31 }32 }33}3435#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]36#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]37pub enum AccessMode {38 Normal,39 WhiteList,40}41impl Default for AccessMode {42 fn default() -> Self {43 Self::Normal44 }45}4647impl Default for CollectionMode {48 fn default() -> Self {49 Self::Invalid50 }51}5253#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]54#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]55pub enum SchemaVersion {56 ImageURL,57 Unique,58}59impl Default for SchemaVersion {60 fn default() -> Self {61 Self::ImageURL62 }63}6465#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]66#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]67pub struct Ownership<AccountId> {68 pub owner: AccountId,69 pub fraction: u128,70}7172#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]73#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]74pub struct CollectionType<AccountId> {75 pub owner: AccountId,76 pub mode: CollectionMode,77 pub access: AccessMode,78 pub decimal_points: DecimalPoints,79 pub name: Vec<u16>, // 64 include null escape char80 pub description: Vec<u16>, // 256 include null escape char81 pub token_prefix: Vec<u8>, // 16 include null escape char82 pub mint_mode: bool,83 pub offchain_schema: Vec<u8>,84 pub schema_version: SchemaVersion,85 pub sponsor: AccountId, // Who pays fees. If set to default address, the fees are applied to the transaction sender86 pub unconfirmed_sponsor: AccountId, // Sponsor address that has not yet confirmed sponsorship87 pub limits: CollectionLimits, // Collection private restrictions 88 pub variable_on_chain_schema: Vec<u8>, //89 pub const_on_chain_schema: Vec<u8>, //90}9192#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]93#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]94pub struct NftItemType<AccountId> {95 pub collection: CollectionId,96 pub owner: AccountId,97 pub const_data: Vec<u8>,98 pub variable_data: Vec<u8>,99}100101#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]102#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]103pub struct FungibleItemType<AccountId> {104 pub collection: CollectionId,105 pub owner: AccountId,106 pub value: u128,107}108109#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]110#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]111pub struct ReFungibleItemType<AccountId> {112 pub collection: CollectionId,113 pub owner: Vec<Ownership<AccountId>>,114 pub const_data: Vec<u8>,115 pub variable_data: Vec<u8>,116}117118#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]119#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]120pub struct ApprovePermissions<AccountId> {121 pub approved: AccountId,122 pub amount: u128,123}124125#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]126#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]127pub struct VestingItem<AccountId, Moment> {128 pub sender: AccountId,129 pub recipient: AccountId,130 pub collection_id: CollectionId,131 pub item_id: TokenId,132 pub amount: u64,133 pub vesting_date: Moment,134}135136#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]137#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]138pub struct BasketItem<AccountId, BlockNumber> {139 pub address: AccountId,140 pub start_block: BlockNumber,141}142143#[derive(Encode, Decode, Debug, Clone, PartialEq)]144#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]145pub struct CollectionLimits {146 pub account_token_ownership_limit: u32,147 pub sponsored_data_size: u32,148 pub token_limit: u32,149150 // Timeouts for item types in passed blocks151 pub sponsor_transfer_timeout: u32,152}153154impl Default for CollectionLimits {155 fn default() -> CollectionLimits {156 CollectionLimits { 157 account_token_ownership_limit: 10_000_000, 158 token_limit: u32::max_value(),159 sponsored_data_size: u32::max_value(), 160 sponsor_transfer_timeout: 14400 }161 }162}163164#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]165#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]166pub struct ChainLimits {167 pub collection_numbers_limit: u32,168 pub account_token_ownership_limit: u32,169 pub collections_admins_limit: u64,170 pub custom_data_limit: u32,171172 // Timeouts for item types in passed blocks173 pub nft_sponsor_transfer_timeout: u32,174 pub fungible_sponsor_transfer_timeout: u32,175 pub refungible_sponsor_transfer_timeout: u32,176}177178179#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]180#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]181pub struct CreateNftData {182 pub const_data: Vec<u8>,183 pub variable_data: Vec<u8>,184}185186#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]187#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]188pub struct CreateFungibleData {189}190191#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]192#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]193pub struct CreateReFungibleData {194 pub const_data: Vec<u8>,195 pub variable_data: Vec<u8>,196}197198#[derive(Encode, Decode, Debug, Clone, PartialEq)]199#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]200pub enum CreateItemData {201 NFT(CreateNftData),202 Fungible(CreateFungibleData),203 ReFungible(CreateReFungibleData),204}205206impl CreateItemData {207 pub fn len(&self) -> usize {208 let len = match self {209 CreateItemData::NFT(data) => data.variable_data.len() + data.const_data.len(),210 CreateItemData::ReFungible(data) => data.variable_data.len() + data.const_data.len(),211 _ => 0212 };213 214 return len;215 }216}217218impl From<CreateNftData> for CreateItemData {219 fn from(item: CreateNftData) -> Self {220 CreateItemData::NFT(item)221 }222}223224impl From<CreateReFungibleData> for CreateItemData {225 fn from(item: CreateReFungibleData) -> Self {226 CreateItemData::ReFungible(item)227 }228}229230impl From<CreateFungibleData> for CreateItemData {231 fn from(item: CreateFungibleData) -> Self {232 CreateItemData::Fungible(item)233 }234}