git.delta.rocks / unique-network / refs/commits / 2c2f26df4c02

difftreelog

Merge branch 'develop' into feature/recursive-token-burning

Yaroslav Bolyukin2022-06-08parents: #cacbebe #dbf6e6a.patch.diff
in: master

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 TokenChild,
77};
78
79// 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};
91100
92// pub use pallet_timestamp::Call as TimestampCall;101// pub use pallet_timestamp::Call as TimestampCall;
102pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
93103
94// Polkadot imports104// Polkadot imports
95use 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};
112117
113use xcm::latest::{118use xcm::latest::{
114 // Xcm,119 // Xcm,
144 }148 }
145}149}
150
151/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
152/// never know...
153pub type AccountIndex = u32;
154
155/// Balance of an account.
156pub type Balance = u128;
157
158/// Index of a transaction in the chain.
159pub type Index = u32;
160
161/// A hash of some data used by the chain.
162pub type Hash = sp_core::H256;
163
164/// Digest item type.
165pub type DigestItem = generic::DigestItem;
146166
147/// 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 know
148/// 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 formats
273 }293 }
274}294}
295
296impl 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}
275301
276impl 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}
393420
394impl 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}
877
878impl 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}
883904
884impl 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}
946
947type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;
948use frame_support::traits::NamedReservableCurrency;
949
950fn 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 logic
960 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),
961 )
962}
963
964pub struct SchedulerPaymentExecutor;
965impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>
966 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
967where
968 <T as frame_system::Config>::Call: Member
969 + Dispatchable<Origin = Origin, Info = DispatchInfo>
970 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
971 + GetDispatchInfo
972 + 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 };
1000
1001 extrinsic.apply::<Runtime>(&dispatch_info, 0)
1002 }
1003
1004 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());
1013
1014 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
1015 &id,
1016 &(sponsor.into()),
1017 weight,
1018 )
1019 }
1020
1021 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 }
1036
1037 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}
9251050
926parameter_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}
954
955type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;
956use frame_support::traits::NamedReservableCurrency;
957
958fn 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 logic
968 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),
969 )
970}
971
972pub struct SchedulerPaymentExecutor;
973impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>
974 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
975where
976 <T as frame_system::Config>::Call: Member
977 + Dispatchable<Origin = Origin, Info = DispatchInfo>
978 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
979 + GetDispatchInfo
980 + 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 };
1008
1009 extrinsic.apply::<Runtime>(&dispatch_info, 0)
1010 }
1011
1012 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());
1021
1022 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(
1023 &id,
1024 &(sponsor.into()),
1025 weight.into(),
1026 )
1027 }
1028
1029 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 }
1044
1045 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}
10581080
1059type EvmSponsorshipHandler = (1081type EvmSponsorshipHandler = (
1060 UniqueEthSponsorshipHandler<Runtime>,1082 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) => {