difftreelog
Merge pull request #371 from UniqueNetwork/release-v922000
in: master
Release v922000
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};7779// use pallet_contracts::weights::WeightInfo;78// use pallet_contracts::weights::WeightInfo;80// #[cfg(any(feature = "std", test))]79// #[cfg(any(feature = "std", test))]88use smallvec::smallvec;87use smallvec::smallvec;89use codec::{Encode, Decode};88use codec::{Encode, Decode};90use fp_rpc::TransactionStatus;89use fp_rpc::TransactionStatus;90use sp_runtime::{91 traits::{92 Applyable, BlockNumberProvider, Dispatchable, PostDispatchInfoOf, DispatchInfoOf,93 Saturating, CheckedConversion,94 },95 generic::Era,96 transaction_validity::TransactionValidityError,97 DispatchErrorWithPostInfo, SaturatedConversion,98};919992// pub use pallet_timestamp::Call as TimestampCall;100// pub use pallet_timestamp::Call as TimestampCall;101pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;9310294// Polkadot imports103// Polkadot imports95use pallet_xcm::XcmPassthrough;104use pallet_xcm::XcmPassthrough;96use polkadot_parachain::primitives::Sibling;105use polkadot_parachain::primitives::Sibling;97use up_data_structs::{98 CollectionId, TokenId, TokenData, Property, PropertyKeyPermission, CollectionLimits, 99 CollectionStats, RpcCollection, 100 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping}101};102use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};106use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};103use xcm_builder::{107use xcm_builder::{104 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,108 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,108 ParentIsPreset,112 ParentIsPreset,109};113};110use xcm_executor::{Config, XcmExecutor, Assets};114use xcm_executor::{Config, XcmExecutor, Assets};115use sp_std::{cmp::Ordering, marker::PhantomData};111116112use xcm::latest::{117use xcm::latest::{113 // Xcm,118 // Xcm,143 }147 }144}148}149150/// The type for looking up accounts. We don't expect more than 4 billion of them, but you151/// never know...152pub type AccountIndex = u32;153154/// Balance of an account.155pub type Balance = u128;156157/// Index of a transaction in the chain.158pub type Index = u32;159160/// A hash of some data used by the chain.161pub type Hash = sp_core::H256;162163/// Digest item type.164pub type DigestItem = generic::DigestItem;145165146/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know166/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know147/// the specifics of the runtime. They can then be made to be agnostic over specific formats167/// the specifics of the runtime. They can then be made to be agnostic over specific formats272 }292 }273}293}294295impl pallet_evm::account::Config for Runtime {296 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;297 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;298 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;299}274300275impl pallet_evm::Config for Runtime {301impl pallet_evm::Config for Runtime {276 type BlockGasLimit = BlockGasLimit;302 type BlockGasLimit = BlockGasLimit;388 // pub const ExistentialDeposit: u128 = 500;414 // pub const ExistentialDeposit: u128 = 500;389 pub const ExistentialDeposit: u128 = 0;415 pub const ExistentialDeposit: u128 = 0;390 pub const MaxLocks: u32 = 50;416 pub const MaxLocks: u32 = 50;417 pub const MaxReserves: u32 = 50;391}418}392419393impl pallet_balances::Config for Runtime {420impl pallet_balances::Config for Runtime {394 type MaxLocks = MaxLocks;421 type MaxLocks = MaxLocks;395 type MaxReserves = ();422 type MaxReserves = MaxReserves;396 type ReserveIdentifier = [u8; 16];423 type ReserveIdentifier = [u8; 16];397 /// The type for recording an account's balance.424 /// The type for recording an account's balance.398 type Balance = Balance;425 type Balance = Balance;874 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;901 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;875}902}876877impl pallet_evm::account::Config for Runtime {878 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;879 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;880 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;881}882903883impl pallet_fungible::Config for Runtime {904impl pallet_fungible::Config for Runtime {884 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;905 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;922 pub const MaxScheduledPerBlock: u32 = 50;943 pub const MaxScheduledPerBlock: u32 = 50;923}944}945946type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;947use frame_support::traits::NamedReservableCurrency;948949fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {950 (951 frame_system::CheckSpecVersion::<Runtime>::new(),952 frame_system::CheckGenesis::<Runtime>::new(),953 frame_system::CheckEra::<Runtime>::from(Era::Immortal),954 frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(955 from,956 )),957 frame_system::CheckWeight::<Runtime>::new(),958 // sponsoring transaction logic959 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),960 )961}962963pub struct SchedulerPaymentExecutor;964impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>965 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor966where967 <T as frame_system::Config>::Call: Member968 + Dispatchable<Origin = Origin, Info = DispatchInfo>969 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>970 + GetDispatchInfo971 + From<frame_system::Call<Runtime>>,972 SelfContainedSignedInfo: Send + Sync + 'static,973 Call: From<<T as frame_system::Config>::Call>974 + From<<T as pallet_unq_scheduler::Config>::Call>975 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,976 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,977{978 fn dispatch_call(979 signer: <T as frame_system::Config>::AccountId,980 call: <T as pallet_unq_scheduler::Config>::Call,981 ) -> Result<982 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,983 TransactionValidityError,984 > {985 let dispatch_info = call.get_dispatch_info();986 let extrinsic = fp_self_contained::CheckedExtrinsic::<987 AccountId,988 Call,989 SignedExtraScheduler,990 SelfContainedSignedInfo,991 > {992 signed:993 CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(994 signer.clone().into(),995 get_signed_extras(signer.into()),996 ),997 function: call.into(),998 };9991000 extrinsic.apply::<Runtime>(&dispatch_info, 0)1001 }10021003 fn reserve_balance(1004 id: [u8; 16],1005 sponsor: <T as frame_system::Config>::AccountId,1006 call: <T as pallet_unq_scheduler::Config>::Call,1007 count: u32,1008 ) -> Result<(), DispatchError> {1009 let dispatch_info = call.get_dispatch_info();1010 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)1011 .saturating_mul(count.into());10121013 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(1014 &id,1015 &(sponsor.into()),1016 weight,1017 )1018 }10191020 fn pay_for_call(1021 id: [u8; 16],1022 sponsor: <T as frame_system::Config>::AccountId,1023 call: <T as pallet_unq_scheduler::Config>::Call,1024 ) -> Result<u128, DispatchError> {1025 let dispatch_info = call.get_dispatch_info();1026 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);1027 Ok(1028 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1029 &id,1030 &(sponsor.into()),1031 weight,1032 ),1033 )1034 }10351036 fn cancel_reserve(1037 id: [u8; 16],1038 sponsor: <T as frame_system::Config>::AccountId,1039 ) -> Result<u128, DispatchError> {1040 Ok(1041 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1042 &id,1043 &(sponsor.into()),1044 u128::MAX,1045 ),1046 )1047 }1048}9241049925parameter_types! {1050parameter_types! {926 pub const NoPreimagePostponement: Option<u32> = Some(10);1051 pub const NoPreimagePostponement: Option<u32> = Some(10);951 type NoPreimagePostponement = NoPreimagePostponement;1077 type NoPreimagePostponement = NoPreimagePostponement;952}1078}953954type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;955use frame_support::traits::NamedReservableCurrency;956957fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {958 (959 frame_system::CheckSpecVersion::<Runtime>::new(),960 frame_system::CheckGenesis::<Runtime>::new(),961 frame_system::CheckEra::<Runtime>::from(Era::Immortal),962 frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(963 from,964 )),965 frame_system::CheckWeight::<Runtime>::new(),966 // sponsoring transaction logic967 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),968 )969}970971pub struct SchedulerPaymentExecutor;972impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>973 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor974where975 <T as frame_system::Config>::Call: Member976 + Dispatchable<Origin = Origin, Info = DispatchInfo>977 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>978 + GetDispatchInfo979 + From<frame_system::Call<Runtime>>,980 SelfContainedSignedInfo: Send + Sync + 'static,981 Call: From<<T as frame_system::Config>::Call>982 + From<<T as pallet_unq_scheduler::Config>::Call>983 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,984 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,985{986 fn dispatch_call(987 signer: <T as frame_system::Config>::AccountId,988 call: <T as pallet_unq_scheduler::Config>::Call,989 ) -> Result<990 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,991 TransactionValidityError,992 > {993 let dispatch_info = call.get_dispatch_info();994 let extrinsic = fp_self_contained::CheckedExtrinsic::<995 AccountId,996 Call,997 SignedExtraScheduler,998 SelfContainedSignedInfo,999 > {1000 signed:1001 CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(1002 signer.clone().into(),1003 get_signed_extras(signer.into()),1004 ),1005 function: call.into(),1006 };10071008 extrinsic.apply::<Runtime>(&dispatch_info, 0)1009 }10101011 fn reserve_balance(1012 id: [u8; 16],1013 sponsor: <T as frame_system::Config>::AccountId,1014 call: <T as pallet_unq_scheduler::Config>::Call,1015 count: u32,1016 ) -> Result<(), DispatchError> {1017 let dispatch_info = call.get_dispatch_info();1018 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)1019 .saturating_mul(count.into());10201021 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(1022 &id,1023 &(sponsor.into()),1024 weight.into(),1025 )1026 }10271028 fn pay_for_call(1029 id: [u8; 16],1030 sponsor: <T as frame_system::Config>::AccountId,1031 call: <T as pallet_unq_scheduler::Config>::Call,1032 ) -> Result<u128, DispatchError> {1033 let dispatch_info = call.get_dispatch_info();1034 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);1035 Ok(1036 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1037 &id,1038 &(sponsor.into()),1039 weight.into(),1040 ),1041 )1042 }10431044 fn cancel_reserve(1045 id: [u8; 16],1046 sponsor: <T as frame_system::Config>::AccountId,1047 ) -> Result<u128, DispatchError> {1048 Ok(1049 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1050 &id,1051 &(sponsor.into()),1052 u128::MAX,1053 ),1054 )1055 }1056}105710791058type EvmSponsorshipHandler = (1080type EvmSponsorshipHandler = (1059 UniqueEthSponsorshipHandler<Runtime>,1081 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) => {