difftreelog
Merge branch 'develop' into feature/recursive-token-burning
in: master
14 files changed
README.mddiffbeforeafterboth421. Install Rust:421. Install Rust:434344```bash44```bash45sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang45sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang make46curl https://sh.rustup.rs -sSf | sh46curl https://sh.rustup.rs -sSf | sh47```47```484862```62```6363645. Build:645. Build:6566Opal67```bash68cargo build --release69```70Quartz71```bash72cargo build --features=quartz-runtime --release73```74Unique65```bash75```bash66cargo build --features=unique-runtime,quartz-runtime --release76cargo build --features=unique-runtime --release67```77```687869## Building as Parachain locally79## Building as Parachain locally155location:165location:156 V0(X2(Parent, Parachain(PARA_ID)))166 V0(X2(Parent, Parachain(PARA_ID)))157metadata:167metadata:158 name OPL168 name QTZ159 symbol OPL169 symbol QTZ160 decimals 18170 decimals 18161minimalBalance 1171minimalBalance 1162```172```163173164### Next, we can send tokens from Opal to Karura:174### Next, we can send tokens from Quartz to Karura:165```175```166polkadotXcm -> reserveTransferAssets176polkadotXcm -> reserveTransferAssets167dest:177dest:179The result will be displayed in ChainState189The result will be displayed in ChainState180tokens -> accounts190tokens -> accounts181191182### To send tokens from Karura to Opal:192### To send tokens from Karura to Quartz:183```193```184xtokens -> transfer194xtokens -> transfer185195chain-specs/polkadot.jsondiffbeforeafterbothno changes
chain-specs/unique.jsondiffbeforeafterbothno changes
client/rpc/src/lib.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617// Original License17use std::sync::Arc;18use std::sync::Arc;181919use codec::{Decode, Encode};20use codec::{Decode, Encode};node/cli/src/service.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.181619// std17// std20use std::sync::Arc;18use std::sync::Arc;pallets/scheduler/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Original license:1// This file is part of Substrate.18// This file is part of Substrate.2193// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.20// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.runtime/opal/src/lib.rsdiffbeforeafterboth29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;30use sp_runtime::DispatchError;31use fp_self_contained::*;31use fp_self_contained::*;32use sp_runtime::traits::{Member};33// #[cfg(any(feature = "std", test))]32// #[cfg(any(feature = "std", test))]34// pub use sp_runtime::BuildStorage;33// pub use sp_runtime::BuildStorage;353436use sp_runtime::{35use sp_runtime::{37 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,38 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero, Member},39 transaction_validity::{TransactionSource, TransactionValidity},38 transaction_validity::{TransactionSource, TransactionValidity},40 ApplyExtrinsicResult, RuntimeAppPublic,39 ApplyExtrinsicResult, RuntimeAppPublic,41};40};runtime/quartz/src/lib.rsdiffbeforeafterboth28use sp_api::impl_runtime_apis;28use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;30use sp_runtime::DispatchError;31use fp_self_contained::*;31// #[cfg(any(feature = "std", test))]32// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;33// pub use sp_runtime::BuildStorage;333450pub use pallet_balances::Call as BalancesCall;51pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52pub use pallet_evm::{52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,53 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,54 OnMethodCall, Account as EVMAccount, FeeCalculator, GasWeightMapping,53};55};54pub use frame_support::{56pub use frame_support::{55 construct_runtime, match_types,57 construct_runtime, match_types,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,68 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67 },69 },68};70};71use pallet_unq_scheduler::DispatchCall;72use up_data_structs::{73 CollectionId, TokenId, TokenData, Property, PropertyKeyPermission, CollectionLimits, 74 CollectionStats, RpcCollection, 75 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},76 TokenChild,77};7869// use pallet_contracts::weights::WeightInfo;79// use pallet_contracts::weights::WeightInfo;70// #[cfg(any(feature = "std", test))]80// #[cfg(any(feature = "std", test))]77};87};78use smallvec::smallvec;88use smallvec::smallvec;79use codec::{Encode, Decode};89use codec::{Encode, Decode};80use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};81use fp_rpc::TransactionStatus;90use fp_rpc::TransactionStatus;82use sp_runtime::{91use sp_runtime::{83 traits::{92 traits::{86 },95 },87 generic::Era,96 generic::Era,88 transaction_validity::TransactionValidityError,97 transaction_validity::TransactionValidityError,89 SaturatedConversion, DispatchErrorWithPostInfo,98 DispatchErrorWithPostInfo, SaturatedConversion, 90};99};9192use fp_self_contained::{SelfContainedCall, CheckedSignature};9310094// pub use pallet_timestamp::Call as TimestampCall;101// pub use pallet_timestamp::Call as TimestampCall;95pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;102pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;9610397// Polkadot imports104// Polkadot imports98use pallet_xcm::XcmPassthrough;105use pallet_xcm::XcmPassthrough;99use polkadot_parachain::primitives::Sibling;106use polkadot_parachain::primitives::Sibling;100use up_data_structs::{101 CollectionId, TokenId, TokenData, Property, PropertyKeyPermission, CollectionLimits, 102 CollectionStats, RpcCollection, 103 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},104 TokenChild,105};106use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};107use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};107use xcm_builder::{108use xcm_builder::{108 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,109 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,113};114};114use xcm_executor::{Config, XcmExecutor, Assets};115use xcm_executor::{Config, XcmExecutor, Assets};115use sp_std::{cmp::Ordering, marker::PhantomData};116use sp_std::{cmp::Ordering, marker::PhantomData};116use pallet_unq_scheduler::DispatchCall;117117118use xcm::latest::{118use xcm::latest::{119 // Xcm,119 // Xcm,149 }149 }150}150}151152/// The type for looking up accounts. We don't expect more than 4 billion of them, but you153/// never know...154pub type AccountIndex = u32;155156/// Balance of an account.157pub type Balance = u128;158159/// Index of a transaction in the chain.160pub type Index = u32;161162/// A hash of some data used by the chain.163pub type Hash = sp_core::H256;164165/// Digest item type.166pub type DigestItem = generic::DigestItem;151167152/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know168/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know153/// the specifics of the runtime. They can then be made to be agnostic over specific formats169/// the specifics of the runtime. They can then be made to be agnostic over specific formats278 }294 }279}295}296297impl pallet_evm::account::Config for Runtime {298 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;299 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;300 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;301}280302281impl pallet_evm::Config for Runtime {303impl pallet_evm::Config for Runtime {282 type BlockGasLimit = BlockGasLimit;304 type BlockGasLimit = BlockGasLimit;394 // pub const ExistentialDeposit: u128 = 500;416 // pub const ExistentialDeposit: u128 = 500;395 pub const ExistentialDeposit: u128 = 0;417 pub const ExistentialDeposit: u128 = 0;396 pub const MaxLocks: u32 = 50;418 pub const MaxLocks: u32 = 50;419 pub const MaxReserves: u32 = 50;397}420}398421399impl pallet_balances::Config for Runtime {422impl pallet_balances::Config for Runtime {400 type MaxLocks = MaxLocks;423 type MaxLocks = MaxLocks;401 type MaxReserves = ();424 type MaxReserves = MaxReserves;402 type ReserveIdentifier = [u8; 16];425 type ReserveIdentifier = [u8; 16];403 /// The type for recording an account's balance.426 /// The type for recording an account's balance.404 type Balance = Balance;427 type Balance = Balance;880 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;903 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;881}904}882883impl pallet_evm::account::Config for Runtime {884 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;885 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;886 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;887}888905889impl pallet_fungible::Config for Runtime {906impl pallet_fungible::Config for Runtime {890 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;907 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;928 pub const MaxScheduledPerBlock: u32 = 50;945 pub const MaxScheduledPerBlock: u32 = 50;929}946}930947931type EvmSponsorshipHandler = (948type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;949use frame_support::traits::NamedReservableCurrency;950951fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {952 (932 UniqueEthSponsorshipHandler<Runtime>,953 frame_system::CheckSpecVersion::<Runtime>::new(),954 frame_system::CheckGenesis::<Runtime>::new(),955 frame_system::CheckEra::<Runtime>::from(Era::Immortal),933 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,956 frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(957 from,958 )),959 frame_system::CheckWeight::<Runtime>::new(),960 // sponsoring transaction logic961 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),934);962 )963}964965pub struct SchedulerPaymentExecutor;966impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>967 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor968where969 <T as frame_system::Config>::Call: Member935type SponsorshipHandler = (970 + Dispatchable<Origin = Origin, Info = DispatchInfo>971 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>972 + GetDispatchInfo936 UniqueSponsorshipHandler<Runtime>,973 + From<frame_system::Call<Runtime>>,937 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,974 SelfContainedSignedInfo: Send + Sync + 'static,975 Call: From<<T as frame_system::Config>::Call>976 + From<<T as pallet_unq_scheduler::Config>::Call>977 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,978 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,979{980 fn dispatch_call(938 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,981 signer: <T as frame_system::Config>::AccountId,982 call: <T as pallet_unq_scheduler::Config>::Call,983 ) -> Result<984 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,985 TransactionValidityError,986 > {987 let dispatch_info = call.get_dispatch_info();988 let extrinsic = fp_self_contained::CheckedExtrinsic::<989 AccountId,990 Call,991 SignedExtraScheduler,992 SelfContainedSignedInfo,993 > {994 signed:995 CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(996 signer.clone().into(),997 get_signed_extras(signer.into()),998 ),999 function: call.into(),1000 };10011002 extrinsic.apply::<Runtime>(&dispatch_info, 0)1003 }10041005 fn reserve_balance(1006 id: [u8; 16],1007 sponsor: <T as frame_system::Config>::AccountId,1008 call: <T as pallet_unq_scheduler::Config>::Call,1009 count: u32,1010 ) -> Result<(), DispatchError> {939);1011 let dispatch_info = call.get_dispatch_info();1012 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)1013 .saturating_mul(count.into());10141015 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(1016 &id,1017 &(sponsor.into()),1018 weight.into(),1019 )1020 }10211022 fn pay_for_call(1023 id: [u8; 16],1024 sponsor: <T as frame_system::Config>::AccountId,1025 call: <T as pallet_unq_scheduler::Config>::Call,1026 ) -> Result<u128, DispatchError> {1027 let dispatch_info = call.get_dispatch_info();1028 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);1029 Ok(1030 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1031 &id,1032 &(sponsor.into()),1033 weight.into(),1034 ),1035 )1036 }10371038 fn cancel_reserve(1039 id: [u8; 16],1040 sponsor: <T as frame_system::Config>::AccountId,1041 ) -> Result<u128, DispatchError> {1042 Ok(1043 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1044 &id,1045 &(sponsor.into()),1046 u128::MAX,1047 ),1048 )1049 }1050}9401051941parameter_types! {1052parameter_types! {942 pub const NoPreimagePostponement: Option<u32> = Some(10);1053 pub const NoPreimagePostponement: Option<u32> = Some(10);967 type NoPreimagePostponement = NoPreimagePostponement;1079 type NoPreimagePostponement = NoPreimagePostponement;968}1080}10811082type EvmSponsorshipHandler = (1083 UniqueEthSponsorshipHandler<Runtime>,1084 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,1085);1086type SponsorshipHandler = (1087 UniqueSponsorshipHandler<Runtime>,1088 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,1089 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,1090);9691091970impl pallet_evm_transaction_payment::Config for Runtime {1092impl pallet_evm_transaction_payment::Config for Runtime {971 type EvmSponsorshipHandler = EvmSponsorshipHandler;1093 type EvmSponsorshipHandler = EvmSponsorshipHandler;980// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;1102// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;981// }1103// }982983type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;984use frame_support::traits::NamedReservableCurrency;985986fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {987 (988 frame_system::CheckSpecVersion::<Runtime>::new(),989 frame_system::CheckGenesis::<Runtime>::new(),990 frame_system::CheckEra::<Runtime>::from(Era::Immortal),991 frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(992 from,993 )),994 frame_system::CheckWeight::<Runtime>::new(),995 // sponsoring transaction logic996 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),997 )998}9991000pub struct SchedulerPaymentExecutor;1001impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>1002 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor1003where1004 <T as frame_system::Config>::Call: Member1005 + Dispatchable<Origin = Origin, Info = DispatchInfo>1006 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>1007 + GetDispatchInfo1008 + From<frame_system::Call<Runtime>>,1009 SelfContainedSignedInfo: Send + Sync + 'static,1010 Call: From<<T as frame_system::Config>::Call>1011 + From<<T as pallet_unq_scheduler::Config>::Call>1012 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,1013 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,1014{1015 fn dispatch_call(1016 signer: <T as frame_system::Config>::AccountId,1017 call: <T as pallet_unq_scheduler::Config>::Call,1018 ) -> Result<1019 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,1020 TransactionValidityError,1021 > {1022 let dispatch_info = call.get_dispatch_info();1023 let extrinsic = fp_self_contained::CheckedExtrinsic::<1024 AccountId,1025 Call,1026 SignedExtraScheduler,1027 SelfContainedSignedInfo,1028 > {1029 signed:1030 CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(1031 signer.clone().into(),1032 get_signed_extras(signer.into()),1033 ),1034 function: call.into(),1035 };10361037 extrinsic.apply::<Runtime>(&dispatch_info, 0)1038 }10391040 fn reserve_balance(1041 id: [u8; 16],1042 sponsor: <T as frame_system::Config>::AccountId,1043 call: <T as pallet_unq_scheduler::Config>::Call,1044 count: u32,1045 ) -> Result<(), DispatchError> {1046 let dispatch_info = call.get_dispatch_info();1047 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)1048 .saturating_mul(count.into());10491050 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(1051 &id,1052 &(sponsor.into()),1053 weight.into(),1054 )1055 }10561057 fn pay_for_call(1058 id: [u8; 16],1059 sponsor: <T as frame_system::Config>::AccountId,1060 call: <T as pallet_unq_scheduler::Config>::Call,1061 ) -> Result<u128, DispatchError> {1062 let dispatch_info = call.get_dispatch_info();1063 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);1064 Ok(1065 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1066 &id,1067 &(sponsor.into()),1068 weight.into(),1069 ),1070 )1071 }10721073 fn cancel_reserve(1074 id: [u8; 16],1075 sponsor: <T as frame_system::Config>::AccountId,1076 ) -> Result<u128, DispatchError> {1077 Ok(1078 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1079 &id,1080 &(sponsor.into()),1081 u128::MAX,1082 ),1083 )1084 }1085}108611041087parameter_types! {1105parameter_types! {1088 // 0x842899ECF380553E8a4de75bF534cdf6fBF640491106 // 0x842899ECF380553E8a4de75bF534cdf6fBF640491199 frame_system::CheckEra<Runtime>,1217 frame_system::CheckEra<Runtime>,1200 frame_system::CheckNonce<Runtime>,1218 frame_system::CheckNonce<Runtime>,1201 frame_system::CheckWeight<Runtime>,1219 frame_system::CheckWeight<Runtime>,1202 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1220 ChargeTransactionPayment,1203 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1221 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1204 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1222 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1205);1223);runtime/unique/src/lib.rsdiffbeforeafterboth28use sp_api::impl_runtime_apis;28use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;30use sp_runtime::DispatchError;31use fp_self_contained::*;31// #[cfg(any(feature = "std", test))]32// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;33// pub use sp_runtime::BuildStorage;333434use sp_runtime::{35use sp_runtime::{35 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36 generic::Era,37 traits::{37 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero, Member},38 Applyable, BlockNumberProvider, Dispatchable, PostDispatchInfoOf, DispatchInfoOf, Saturating,39 CheckedConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion,40 Zero, Member,41 },42 transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError},38 transaction_validity::{TransactionSource, TransactionValidity},43 ApplyExtrinsicResult, RuntimeAppPublic, SaturatedConversion, DispatchErrorWithPostInfo,39 ApplyExtrinsicResult, RuntimeAppPublic,44};40};4546use fp_self_contained::{SelfContainedCall, CheckedSignature};47use sp_std::{cmp::Ordering, marker::PhantomData};48use pallet_unq_scheduler::DispatchCall;494150use sp_std::prelude::*;42use sp_std::prelude::*;514376 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,68 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,77 },69 },78};70};71use pallet_unq_scheduler::DispatchCall;72use up_data_structs::{73 CollectionId, TokenId, TokenData, Property, PropertyKeyPermission, CollectionLimits,74 CollectionStats, RpcCollection,75 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},76 TokenChild,77};7879// use pallet_contracts::weights::WeightInfo;79// use pallet_contracts::weights::WeightInfo;80// #[cfg(any(feature = "std", test))]80// #[cfg(any(feature = "std", test))]88use smallvec::smallvec;88use smallvec::smallvec;89use codec::{Encode, Decode};89use codec::{Encode, Decode};90use fp_rpc::TransactionStatus;90use fp_rpc::TransactionStatus;91use sp_runtime::{92 traits::{93 Applyable, BlockNumberProvider, Dispatchable, PostDispatchInfoOf, DispatchInfoOf,94 Saturating, CheckedConversion,95 },96 generic::Era,97 transaction_validity::TransactionValidityError,98 DispatchErrorWithPostInfo, SaturatedConversion,99};9110092// pub use pallet_timestamp::Call as TimestampCall;101// pub use pallet_timestamp::Call as TimestampCall;102pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;9310394// Polkadot imports104// Polkadot imports95use pallet_xcm::XcmPassthrough;105use pallet_xcm::XcmPassthrough;96use polkadot_parachain::primitives::Sibling;106use polkadot_parachain::primitives::Sibling;97use up_data_structs::{98 CollectionId, TokenId, TokenData, Property, PropertyKeyPermission, CollectionLimits, 99 CollectionStats, RpcCollection, 100 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},101 TokenChild,102};103use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};107use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};104use xcm_builder::{108use xcm_builder::{105 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,109 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,109 ParentIsPreset,113 ParentIsPreset,110};114};111use xcm_executor::{Config, XcmExecutor, Assets};115use xcm_executor::{Config, XcmExecutor, Assets};116use sp_std::{cmp::Ordering, marker::PhantomData};112117113use xcm::latest::{118use xcm::latest::{114 // Xcm,119 // Xcm,144 }148 }145}149}150151/// The type for looking up accounts. We don't expect more than 4 billion of them, but you152/// never know...153pub type AccountIndex = u32;154155/// Balance of an account.156pub type Balance = u128;157158/// Index of a transaction in the chain.159pub type Index = u32;160161/// A hash of some data used by the chain.162pub type Hash = sp_core::H256;163164/// Digest item type.165pub type DigestItem = generic::DigestItem;146166147/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know167/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know148/// the specifics of the runtime. They can then be made to be agnostic over specific formats168/// the specifics of the runtime. They can then be made to be agnostic over specific formats273 }293 }274}294}295296impl pallet_evm::account::Config for Runtime {297 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;298 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;299 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;300}275301276impl pallet_evm::Config for Runtime {302impl pallet_evm::Config for Runtime {277 type BlockGasLimit = BlockGasLimit;303 type BlockGasLimit = BlockGasLimit;389 // pub const ExistentialDeposit: u128 = 500;415 // pub const ExistentialDeposit: u128 = 500;390 pub const ExistentialDeposit: u128 = 0;416 pub const ExistentialDeposit: u128 = 0;391 pub const MaxLocks: u32 = 50;417 pub const MaxLocks: u32 = 50;418 pub const MaxReserves: u32 = 50;392}419}393420394impl pallet_balances::Config for Runtime {421impl pallet_balances::Config for Runtime {395 type MaxLocks = MaxLocks;422 type MaxLocks = MaxLocks;396 type MaxReserves = ();423 type MaxReserves = MaxReserves;397 type ReserveIdentifier = [u8; 16];424 type ReserveIdentifier = [u8; 16];398 /// The type for recording an account's balance.425 /// The type for recording an account's balance.399 type Balance = Balance;426 type Balance = Balance;875 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;902 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;876}903}877878impl pallet_evm::account::Config for Runtime {879 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;880 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;881 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;882}883904884impl pallet_fungible::Config for Runtime {905impl pallet_fungible::Config for Runtime {885 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;906 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;923 pub const MaxScheduledPerBlock: u32 = 50;944 pub const MaxScheduledPerBlock: u32 = 50;924}945}946947type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;948use frame_support::traits::NamedReservableCurrency;949950fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {951 (952 frame_system::CheckSpecVersion::<Runtime>::new(),953 frame_system::CheckGenesis::<Runtime>::new(),954 frame_system::CheckEra::<Runtime>::from(Era::Immortal),955 frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(956 from,957 )),958 frame_system::CheckWeight::<Runtime>::new(),959 // sponsoring transaction logic960 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),961 )962}963964pub struct SchedulerPaymentExecutor;965impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>966 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor967where968 <T as frame_system::Config>::Call: Member969 + Dispatchable<Origin = Origin, Info = DispatchInfo>970 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>971 + GetDispatchInfo972 + From<frame_system::Call<Runtime>>,973 SelfContainedSignedInfo: Send + Sync + 'static,974 Call: From<<T as frame_system::Config>::Call>975 + From<<T as pallet_unq_scheduler::Config>::Call>976 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,977 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,978{979 fn dispatch_call(980 signer: <T as frame_system::Config>::AccountId,981 call: <T as pallet_unq_scheduler::Config>::Call,982 ) -> Result<983 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,984 TransactionValidityError,985 > {986 let dispatch_info = call.get_dispatch_info();987 let extrinsic = fp_self_contained::CheckedExtrinsic::<988 AccountId,989 Call,990 SignedExtraScheduler,991 SelfContainedSignedInfo,992 > {993 signed:994 CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(995 signer.clone().into(),996 get_signed_extras(signer.into()),997 ),998 function: call.into(),999 };10001001 extrinsic.apply::<Runtime>(&dispatch_info, 0)1002 }10031004 fn reserve_balance(1005 id: [u8; 16],1006 sponsor: <T as frame_system::Config>::AccountId,1007 call: <T as pallet_unq_scheduler::Config>::Call,1008 count: u32,1009 ) -> Result<(), DispatchError> {1010 let dispatch_info = call.get_dispatch_info();1011 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)1012 .saturating_mul(count.into());10131014 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(1015 &id,1016 &(sponsor.into()),1017 weight,1018 )1019 }10201021 fn pay_for_call(1022 id: [u8; 16],1023 sponsor: <T as frame_system::Config>::AccountId,1024 call: <T as pallet_unq_scheduler::Config>::Call,1025 ) -> Result<u128, DispatchError> {1026 let dispatch_info = call.get_dispatch_info();1027 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);1028 Ok(1029 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1030 &id,1031 &(sponsor.into()),1032 weight,1033 ),1034 )1035 }10361037 fn cancel_reserve(1038 id: [u8; 16],1039 sponsor: <T as frame_system::Config>::AccountId,1040 ) -> Result<u128, DispatchError> {1041 Ok(1042 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1043 &id,1044 &(sponsor.into()),1045 u128::MAX,1046 ),1047 )1048 }1049}9251050926parameter_types! {1051parameter_types! {927 pub const NoPreimagePostponement: Option<u32> = Some(10);1052 pub const NoPreimagePostponement: Option<u32> = Some(10);952 type NoPreimagePostponement = NoPreimagePostponement;1078 type NoPreimagePostponement = NoPreimagePostponement;953}1079}954955type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;956use frame_support::traits::NamedReservableCurrency;957958fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {959 (960 frame_system::CheckSpecVersion::<Runtime>::new(),961 frame_system::CheckGenesis::<Runtime>::new(),962 frame_system::CheckEra::<Runtime>::from(Era::Immortal),963 frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(964 from,965 )),966 frame_system::CheckWeight::<Runtime>::new(),967 // sponsoring transaction logic968 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),969 )970}971972pub struct SchedulerPaymentExecutor;973impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>974 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor975where976 <T as frame_system::Config>::Call: Member977 + Dispatchable<Origin = Origin, Info = DispatchInfo>978 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>979 + GetDispatchInfo980 + From<frame_system::Call<Runtime>>,981 SelfContainedSignedInfo: Send + Sync + 'static,982 Call: From<<T as frame_system::Config>::Call>983 + From<<T as pallet_unq_scheduler::Config>::Call>984 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,985 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,986{987 fn dispatch_call(988 signer: <T as frame_system::Config>::AccountId,989 call: <T as pallet_unq_scheduler::Config>::Call,990 ) -> Result<991 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,992 TransactionValidityError,993 > {994 let dispatch_info = call.get_dispatch_info();995 let extrinsic = fp_self_contained::CheckedExtrinsic::<996 AccountId,997 Call,998 SignedExtraScheduler,999 SelfContainedSignedInfo,1000 > {1001 signed:1002 CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(1003 signer.clone().into(),1004 get_signed_extras(signer.into()),1005 ),1006 function: call.into(),1007 };10081009 extrinsic.apply::<Runtime>(&dispatch_info, 0)1010 }10111012 fn reserve_balance(1013 id: [u8; 16],1014 sponsor: <T as frame_system::Config>::AccountId,1015 call: <T as pallet_unq_scheduler::Config>::Call,1016 count: u32,1017 ) -> Result<(), DispatchError> {1018 let dispatch_info = call.get_dispatch_info();1019 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)1020 .saturating_mul(count.into());10211022 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(1023 &id,1024 &(sponsor.into()),1025 weight.into(),1026 )1027 }10281029 fn pay_for_call(1030 id: [u8; 16],1031 sponsor: <T as frame_system::Config>::AccountId,1032 call: <T as pallet_unq_scheduler::Config>::Call,1033 ) -> Result<u128, DispatchError> {1034 let dispatch_info = call.get_dispatch_info();1035 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);1036 Ok(1037 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1038 &id,1039 &(sponsor.into()),1040 weight.into(),1041 ),1042 )1043 }10441045 fn cancel_reserve(1046 id: [u8; 16],1047 sponsor: <T as frame_system::Config>::AccountId,1048 ) -> Result<u128, DispatchError> {1049 Ok(1050 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1051 &id,1052 &(sponsor.into()),1053 u128::MAX,1054 ),1055 )1056 }1057}105810801059type EvmSponsorshipHandler = (1081type EvmSponsorshipHandler = (1060 UniqueEthSponsorshipHandler<Runtime>,1082 UniqueEthSponsorshipHandler<Runtime>,tests/flipper-src/lib.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617// Original license17// Original License18// Copyright 2018-2020 Parity Technologies (UK) Ltd.18// Copyright 2018-2020 Parity Technologies (UK) Ltd.19//19//20// Licensed under the Apache License, Version 2.0 (the "License");20// Licensed under the Apache License, Version 2.0 (the "License");tests/ink-types-node-runtime/src/calls.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617// Original license17// Original License18// Copyright 2019 Parity Technologies (UK) Ltd.18// Copyright 2019 Parity Technologies (UK) Ltd.19// This file is part of ink!.19// This file is part of ink!.20//20//tests/ink-types-node-runtime/src/lib.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617// Original license17// Original License18// Copyright 2018-2019 Parity Technologies (UK) Ltd.18// Copyright 2018-2019 Parity Technologies (UK) Ltd.19// This file is part of ink!.19// This file is part of ink!.20//20//tests/loadtester-src/lib.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617// Original License17#![cfg_attr(not(feature = "std"), no_std)]18#![cfg_attr(not(feature = "std"), no_std)]181919use ink_lang as ink;20use ink_lang as ink;tests/src/xcmTransfer.test.tsdiffbeforeafterboth33const KARURA_CHAIN = 2000;33const KARURA_CHAIN = 2000;34const KARURA_PORT = '9946';34const KARURA_PORT = '9946';353536describe('Integration test: Exchanging OPL with Karura', () => {36describe('Integration test: Exchanging QTZ with Karura', () => {37 let alice: IKeyringPair;37 let alice: IKeyringPair;38 38 39 before(async () => {39 before(async () => {595960 const metadata =60 const metadata =61 {61 {62 name: 'OPL',62 name: 'QTZ',63 symbol: 'OPL',63 symbol: 'QTZ',64 decimals: 18,64 decimals: 18,65 minimalBalance: 1,65 minimalBalance: 1,66 };66 };73 }, karuraApiOptions);73 }, karuraApiOptions);74 });74 });757576 it('Should connect and send OPL to Karura', async () => {76 it('Should connect and send QTZ to Karura', async () => {77 let balanceOnKaruraBefore: bigint;77 let balanceOnKaruraBefore: bigint;78 78 79 await usingApi(async (api) => {79 await usingApi(async (api) => {140 }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});140 }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});141 });141 });142142143 it('Should connect to Karura and send OPL back', async () => {143 it('Should connect to Karura and send QTZ back', async () => {144 let balanceBefore: bigint;144 let balanceBefore: bigint;145 145 146 await usingApi(async (api) => {146 await usingApi(async (api) => {