git.delta.rocks / unique-network / refs/commits / 7a21a78fef2e

difftreelog

Code style update

str-mv2020-09-09parent: #d96245d.patch.diff
in: master

9 files changed

modifiednode/src/cli.rsdiffbeforeafterboth

no syntactic changes

modifiednode/src/command.rsdiffbeforeafterboth

no syntactic changes

modifiednode/src/main.rsdiffbeforeafterboth

no syntactic changes

modifiednode/src/service.rsdiffbeforeafterboth

no syntactic changes

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
5
6use codec::{Decode, Encode};5use codec::{Decode, Encode};
7pub use frame_support::{6pub use frame_support::{
8 decl_event, decl_module, decl_storage,7 construct_runtime, decl_event, decl_module, decl_storage,
9 construct_runtime, parameter_types,8 dispatch::DispatchResult,
9 ensure, parameter_types,
10 traits::{Currency, Get, ExistenceRequirement, KeyOwnerProofSystem, OnUnbalanced, Randomness, WithdrawReason, Imbalance},10 traits::{
11 Currency, ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced,
12 Randomness, WithdrawReason,
13 },
11 weights::{14 weights::{
12 DispatchInfo, PostDispatchInfo, constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},15 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
13 IdentityFee, Weight, WeightToFeePolynomial, GetDispatchInfo, Pays,16 DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
17 WeightToFeePolynomial,
14 },18 },
15 StorageValue,
16 dispatch::DispatchResult,
17 IsSubType,19 IsSubType, StorageValue,
18 ensure
19};20};
2021
21use frame_system::{self as system, ensure_signed};22use frame_system::{self as system, ensure_signed};
22use sp_runtime::sp_std::prelude::Vec;23use sp_runtime::sp_std::prelude::Vec;
23use sp_std::prelude::*;
24use sp_runtime::{24use sp_runtime::{
25 FixedU128, FixedPointOperand,
26 transaction_validity::{25 traits::{
27 TransactionPriority, ValidTransaction, InvalidTransaction, TransactionValidityError, TransactionValidity26 DispatchInfoOf, Dispatchable, PostDispatchInfoOf, SaturatedConversion, Saturating,
27 SignedExtension, Zero,
28 },28 },
29 traits::{29 transaction_validity::{
30 Saturating, Dispatchable, DispatchInfoOf, PostDispatchInfoOf, SignedExtension, Zero, SaturatedConversion,30 InvalidTransaction, TransactionPriority, TransactionValidity, TransactionValidityError,
31 ValidTransaction,
31 },32 },
33 FixedPointOperand, FixedU128,
32};34};
35use sp_std::prelude::*;
3336
34#[cfg(test)]37#[cfg(test)]
35mod mock;38mod mock;
385 let target_collection = <Collection<T>>::get(collection_id);394 let target_collection = <Collection<T>>::get(collection_id);
386 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;395 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;
387396
388 // TODO: implement other modes
389 match target_collection.mode 397 match target_collection.mode
390 {398 {
391 CollectionMode::NFT(_) => {399 CollectionMode::NFT(_) => {
743 let target_collection = <Collection<T>>::get(collection_id);781 let target_collection = <Collection<T>>::get(collection_id);
744782
745 match target_collection.mode {783 match target_collection.mode {
746 CollectionMode::NFT(_) => <NftItemList<T>>::get(collection_id, item_id).owner == subject,784 CollectionMode::NFT(_) => {
785 <NftItemList<T>>::get(collection_id, item_id).owner == subject
786 }
747 CollectionMode::Fungible(_) => <FungibleItemList<T>>::get(collection_id, item_id).owner == subject,787 CollectionMode::Fungible(_) => {
788 <FungibleItemList<T>>::get(collection_id, item_id).owner == subject
789 }
748 CollectionMode::ReFungible(_, _) => <ReFungibleItemList<T>>::get(collection_id, item_id).owner.iter().any(|i| i.owner == subject),790 CollectionMode::ReFungible(_, _) => {
791 <ReFungibleItemList<T>>::get(collection_id, item_id)
792 .owner
793 .iter()
794 .any(|i| i.owner == subject)
795 }
749 CollectionMode::Invalid => false796 CollectionMode::Invalid => false,
750 }797 }
751 }798 }
752799
808 let item = FungibleItemType {861 let item = FungibleItemType {
809 collection: collection_id,862 collection: collection_id,
810 owner: new_owner.clone(),863 owner: new_owner.clone(),
811 value: val64864 value: val64,
812 };865 };
813866
814 Self::add_fungible_item(item)?;867 Self::add_fungible_item(item)?;
873 // new owner do not have account951 // new owner do not have account
874 new_full_item.owner.push(Ownership { owner: new_owner.clone(), fraction: val64});952 new_full_item.owner.push(Ownership {
953 owner: new_owner.clone(),
954 fraction: val64,
955 });
875 Self::add_token_index(collection_id, item_id, new_owner.clone())?;956 Self::add_token_index(collection_id, item_id, new_owner.clone())?;
876 }957 }
967pub type Multiplier = FixedU128;1058pub type Multiplier = FixedU128;
9681059
969type BalanceOf<T> =1060type BalanceOf<T> = <<T as transaction_payment::Trait>::Currency as Currency<
970 <<T as transaction_payment::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;1061 <T as system::Trait>::AccountId,
1062>>::Balance;
971type NegativeImbalanceOf<T> = <<T as transaction_payment::Trait>::Currency as Currency<1063type NegativeImbalanceOf<T> = <<T as transaction_payment::Trait>::Currency as Currency<
972 <T as system::Trait>::AccountId,>>::NegativeImbalance;1064 <T as system::Trait>::AccountId,
977/// in the queue.1068/// in the queue.
978#[derive(Encode, Decode, Clone, Eq, PartialEq)]1069#[derive(Encode, Decode, Clone, Eq, PartialEq)]
979pub struct ChargeTransactionPayment<T: transaction_payment::Trait + Send + Sync>(#[codec(compact)] BalanceOf<T>);1070pub struct ChargeTransactionPayment<T: transaction_payment::Trait + Send + Sync>(
1071 #[codec(compact)] BalanceOf<T>,
1072);
9801073
981impl<T:Trait + transaction_payment::Trait + Send + Sync> sp_std::fmt::Debug for ChargeTransactionPayment<T> {1074impl<T: Trait + transaction_payment::Trait + Send + Sync> sp_std::fmt::Debug
1021 // All other transactions have traditional fees so far1119 // All other transactions have traditional fees so far
1022 let fee = match call.is_sub_type() {1120 let fee = match call.is_sub_type() {
1023 Some(Call::create_collection(..)) => <BalanceOf<T>>::from(1_000_000_000),1121 Some(Call::create_collection(..)) => <BalanceOf<T>>::from(1_000_000_000),
1024 _ => Self::traditional_fee(len, info, tip)1122 _ => Self::traditional_fee(len, info, tip), // Flat fee model, use only for testing purposes
1025
1026 // Flat fee model, use only for testing purposes
1027 // _ => <BalanceOf<T>>::from(100)1123 // _ => <BalanceOf<T>>::from(100)
1032 let sponsor: T::AccountId = match call.is_sub_type() {1128 let sponsor: T::AccountId = match call.is_sub_type() {
1033 Some(Call::create_item(collection_id, _properties, _owner)) => {1129 Some(Call::create_item(collection_id, _properties, _owner)) => {
1034 <Collection<T>>::get(collection_id).sponsor1130 <Collection<T>>::get(collection_id).sponsor
1035 },1131 }
1036 Some(Call::transfer(_new_owner, collection_id, _item_id, _value)) => {1132 Some(Call::transfer(_new_owner, collection_id, _item_id, _value)) => {
1037 <Collection<T>>::get(collection_id).sponsor1133 <Collection<T>>::get(collection_id).sponsor
1038 },1134 }
10391135
1040 _ => T::AccountId::default()1136 _ => T::AccountId::default(),
1041 };1137 };
10421138
1043 let mut who_pays_fee: T::AccountId = sponsor.clone();1139 let mut who_pays_fee: T::AccountId = sponsor.clone();
1177 BalanceOf<T>,
1178 Self::AccountId,
1179 Option<NegativeImbalanceOf<T>>,
1180 BalanceOf<T>,
1181 );
1078 fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) }1182 fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> {
1183 Ok(())
modifiedpallets/nft/src/mock.rsdiffbeforeafterboth
1// Creating mock runtime here1// Creating mock runtime here
22
3use crate::{Module, Trait};3use crate::{Module, Trait};
4use frame_support::{
5 impl_outer_origin, parameter_types,
6 weights::{
7 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
8 Weight,
9 },
10};
4use frame_system as system;11use frame_system as system;
5use sp_core::H256;12use sp_core::H256;
6use sp_runtime::{13use sp_runtime::{
7 testing::Header,14 testing::Header,
8 traits::{BlakeTwo256, IdentityLookup, Saturating},15 traits::{BlakeTwo256, IdentityLookup, Saturating},
9 Perbill,16 Perbill,
10};17};
11use frame_support::{
12 parameter_types, impl_outer_origin,
13 weights::{
14 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
15 Weight,
16 },
17};
1818
19impl_outer_origin! {19impl_outer_origin! {
20 pub enum Origin for Test {}20 pub enum Origin for Test {}
modifiedpallets/nft/src/tests.rsdiffbeforeafterboth
1// Tests to be written here1// Tests to be written here
2use crate::mock::*;2use crate::mock::*;
3use crate::{CollectionMode, Ownership, ApprovePermissions};3use crate::{ApprovePermissions, CollectionMode, Ownership};
4use frame_support::{assert_noop, assert_ok};4use frame_support::{assert_noop, assert_ok};
55
6#[test]6#[test]
modifiedruntime/build.rsdiffbeforeafterboth

no syntactic changes

modifiedruntime/src/lib.rsdiffbeforeafterboth
16use sp_core::{crypto::KeyTypeId, OpaqueMetadata};16use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
17use sp_runtime::{17use sp_runtime::{
18 create_runtime_str, generic, impl_opaque_keys,18 create_runtime_str, generic, impl_opaque_keys,
19 transaction_validity::{TransactionSource, TransactionValidity},
20 ApplyExtrinsicResult, MultiSignature,
21 traits::{19 traits::{
22 BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, Saturating, Verify,20 BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, Saturating,
21 Verify,
23 },22 },
23 transaction_validity::{TransactionSource, TransactionValidity},
24 ApplyExtrinsicResult, MultiSignature,
24};25};
25use sp_std::prelude::*;26use sp_std::prelude::*;
26#[cfg(feature = "std")]27#[cfg(feature = "std")]
32pub use contracts::Schedule as ContractsSchedule;33pub use contracts::Schedule as ContractsSchedule;
33pub use frame_support::{34pub use frame_support::{
34 construct_runtime, parameter_types,35 construct_runtime,
36 dispatch::DispatchResult,
37 parameter_types,
35 traits::{Currency, Get, ExistenceRequirement, KeyOwnerProofSystem, OnUnbalanced, Randomness, WithdrawReason},38 traits::{
39 Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,
40 WithdrawReason,
41 },
36 weights::{42 weights::{
37 DispatchInfo, PostDispatchInfo, constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},43 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
38 IdentityFee, Weight, WeightToFeePolynomial, GetDispatchInfo, Pays,44 DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
45 WeightToFeePolynomial,
39 },46 },
40 StorageValue,47 StorageValue,
41 dispatch::DispatchResult,
42};48};
43use system::{self as system};
44#[cfg(any(feature = "std", test))]49#[cfg(any(feature = "std", test))]
45pub use sp_runtime::BuildStorage;50pub use sp_runtime::BuildStorage;
46use sp_runtime::{51use sp_runtime::Perbill;
47 Perbill,52use system::{self as system};
48};
49
5053
51pub use timestamp::Call as TimestampCall;54pub use timestamp::Call as TimestampCall;