git.delta.rocks / unique-network / refs/commits / dbf6e6ab649e

difftreelog

Merge pull request #371 from UniqueNetwork/release-v922000

kozyrevdev2022-06-08parents: #2074c93 #dfe6d19.patch.diff
in: master
Release v922000

14 files changed

modifiedREADME.mddiffbeforeafterboth
421. Install Rust:421. Install Rust:
4343
44```bash44```bash
45sudo 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 make
46curl https://sh.rustup.rs -sSf | sh46curl https://sh.rustup.rs -sSf | sh
47```47```
4848
62```62```
6363
645. Build:645. Build:
65
66Opal
67```bash
68cargo build --release
69```
70Quartz
71```bash
72cargo build --features=quartz-runtime --release
73```
74Unique
65```bash75```bash
66cargo build --features=unique-runtime,quartz-runtime --release76cargo build --features=unique-runtime --release
67```77```
6878
69## Building as Parachain locally79## Building as Parachain locally
155location:165location:
156 V0(X2(Parent, Parachain(PARA_ID)))166 V0(X2(Parent, Parachain(PARA_ID)))
157metadata:167metadata:
158 name OPL168 name QTZ
159 symbol OPL169 symbol QTZ
160 decimals 18170 decimals 18
161minimalBalance 1171minimalBalance 1
162```172```
163173
164### Next, we can send tokens from Opal to Karura:174### Next, we can send tokens from Quartz to Karura:
165```175```
166polkadotXcm -> reserveTransferAssets176polkadotXcm -> reserveTransferAssets
167dest:177dest:
179The result will be displayed in ChainState189The result will be displayed in ChainState
180tokens -> accounts190tokens -> accounts
181191
182### To send tokens from Karura to Opal:192### To send tokens from Karura to Quartz:
183```193```
184xtokens -> transfer194xtokens -> transfer
185195
addedchain-specs/polkadot.jsondiffbeforeafterboth

no changes

addedchain-specs/unique.jsondiffbeforeafterboth

no changes

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// 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/>.
1616
17// Original License
17use std::sync::Arc;18use std::sync::Arc;
1819
19use codec::{Decode, Encode};20use codec::{Decode, Encode};
modifiednode/cli/src/service.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// 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/>.
16
17//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
1816
19// std17// std
20use std::sync::Arc;18use std::sync::Arc;
modifiedpallets/scheduler/src/lib.rsdiffbeforeafterboth
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
2// This file is part of Unique Network.
3
4// Unique Network is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Unique Network is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
16
17// Original license:
1// This file is part of Substrate.18// This file is part of Substrate.
219
3// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.20// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
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::*;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;
3534
36use 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};
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
28use 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;
3334
50pub 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};
78
69// 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};
91
92use fp_self_contained::{SelfContainedCall, CheckedSignature};
93100
94// 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;
96103
97// Polkadot imports104// Polkadot imports
98use 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;
117117
118use xcm::latest::{118use xcm::latest::{
119 // Xcm,119 // Xcm,
149 }149 }
150}150}
151
152/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
153/// never know...
154pub type AccountIndex = u32;
155
156/// Balance of an account.
157pub type Balance = u128;
158
159/// Index of a transaction in the chain.
160pub type Index = u32;
161
162/// A hash of some data used by the chain.
163pub type Hash = sp_core::H256;
164
165/// Digest item type.
166pub type DigestItem = generic::DigestItem;
151167
152/// 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 know
153/// 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 formats
278 }294 }
279}295}
296
297impl 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}
280302
281impl 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}
398421
399impl 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}
882
883impl 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}
888905
889impl 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}
930947
931type EvmSponsorshipHandler = (948type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;
949use frame_support::traits::NamedReservableCurrency;
950
951fn 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 logic
961 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),
934);962 )
963}
964
965pub struct SchedulerPaymentExecutor;
966impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>
967 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
968where
969 <T as frame_system::Config>::Call: Member
935type SponsorshipHandler = (970 + Dispatchable<Origin = Origin, Info = DispatchInfo>
971 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
972 + GetDispatchInfo
936 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 };
1001
1002 extrinsic.apply::<Runtime>(&dispatch_info, 0)
1003 }
1004
1005 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());
1014
1015 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
1016 &id,
1017 &(sponsor.into()),
1018 weight.into(),
1019 )
1020 }
1021
1022 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 }
1037
1038 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}
9401051
941parameter_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}
1081
1082type 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);
9691091
970impl 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// }
982
983type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;
984use frame_support::traits::NamedReservableCurrency;
985
986fn 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 logic
996 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),
997 )
998}
999
1000pub struct SchedulerPaymentExecutor;
1001impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>
1002 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
1003where
1004 <T as frame_system::Config>::Call: Member
1005 + Dispatchable<Origin = Origin, Info = DispatchInfo>
1006 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
1007 + GetDispatchInfo
1008 + 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 };
1036
1037 extrinsic.apply::<Runtime>(&dispatch_info, 0)
1038 }
1039
1040 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());
1049
1050 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
1051 &id,
1052 &(sponsor.into()),
1053 weight.into(),
1054 )
1055 }
1056
1057 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 }
1072
1073 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}
10861104
1087parameter_types! {1105parameter_types! {
1088 // 0x842899ECF380553E8a4de75bF534cdf6fBF640491106 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049
1199 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);
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
28use 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;
3334
34use 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};
45
46use fp_self_contained::{SelfContainedCall, CheckedSignature};
47use sp_std::{cmp::Ordering, marker::PhantomData};
48use pallet_unq_scheduler::DispatchCall;
4941
50use sp_std::prelude::*;42use sp_std::prelude::*;
5143
76 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};
77
79// 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};
9199
92// pub use pallet_timestamp::Call as TimestampCall;100// pub use pallet_timestamp::Call as TimestampCall;
101pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
93102
94// Polkadot imports103// Polkadot imports
95use 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};
111116
112use xcm::latest::{117use xcm::latest::{
113 // Xcm,118 // Xcm,
143 }147 }
144}148}
149
150/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
151/// never know...
152pub type AccountIndex = u32;
153
154/// Balance of an account.
155pub type Balance = u128;
156
157/// Index of a transaction in the chain.
158pub type Index = u32;
159
160/// A hash of some data used by the chain.
161pub type Hash = sp_core::H256;
162
163/// Digest item type.
164pub type DigestItem = generic::DigestItem;
145165
146/// 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 know
147/// 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 formats
272 }292 }
273}293}
294
295impl 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}
274300
275impl 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}
392419
393impl 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}
876
877impl 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}
882903
883impl 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}
945
946type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;
947use frame_support::traits::NamedReservableCurrency;
948
949fn 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 logic
959 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),
960 )
961}
962
963pub struct SchedulerPaymentExecutor;
964impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>
965 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
966where
967 <T as frame_system::Config>::Call: Member
968 + Dispatchable<Origin = Origin, Info = DispatchInfo>
969 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
970 + GetDispatchInfo
971 + 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 };
999
1000 extrinsic.apply::<Runtime>(&dispatch_info, 0)
1001 }
1002
1003 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());
1012
1013 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
1014 &id,
1015 &(sponsor.into()),
1016 weight,
1017 )
1018 }
1019
1020 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 }
1035
1036 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}
9241049
925parameter_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}
953
954type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;
955use frame_support::traits::NamedReservableCurrency;
956
957fn 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 logic
967 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),
968 )
969}
970
971pub struct SchedulerPaymentExecutor;
972impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>
973 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
974where
975 <T as frame_system::Config>::Call: Member
976 + Dispatchable<Origin = Origin, Info = DispatchInfo>
977 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
978 + GetDispatchInfo
979 + 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 };
1007
1008 extrinsic.apply::<Runtime>(&dispatch_info, 0)
1009 }
1010
1011 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());
1020
1021 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
1022 &id,
1023 &(sponsor.into()),
1024 weight.into(),
1025 )
1026 }
1027
1028 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 }
1043
1044 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}
10571079
1058type EvmSponsorshipHandler = (1080type EvmSponsorshipHandler = (
1059 UniqueEthSponsorshipHandler<Runtime>,1081 UniqueEthSponsorshipHandler<Runtime>,
modifiedtests/flipper-src/lib.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// 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/>.
1616
17// Original license17// Original License
18// 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");
modifiedtests/ink-types-node-runtime/src/calls.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// 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/>.
1616
17// Original license17// Original License
18// 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//
modifiedtests/ink-types-node-runtime/src/lib.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// 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/>.
1616
17// Original license17// Original License
18// 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//
modifiedtests/loadtester-src/lib.rsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// 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/>.
1616
17// Original License
17#![cfg_attr(not(feature = "std"), no_std)]18#![cfg_attr(not(feature = "std"), no_std)]
1819
19use ink_lang as ink;20use ink_lang as ink;
modifiedtests/src/xcmTransfer.test.tsdiffbeforeafterboth
33const KARURA_CHAIN = 2000;33const KARURA_CHAIN = 2000;
34const KARURA_PORT = '9946';34const KARURA_PORT = '9946';
3535
36describe('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 () => {
5959
60 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 });
7575
76 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 });
142142
143 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) => {