git.delta.rocks / unique-network / refs/commits / 900dc0450c74

difftreelog

reafactor: switch scheduler to sponsoring primitive

Yaroslav Bolyukin2021-06-24parent: #afcf32a.patch.diff
in: master

2 files changed

modifiedpallets/scheduler/Cargo.tomldiffbeforeafterboth
14codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }14codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
15frame-support = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }15frame-support = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
16frame-system = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }16frame-system = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
17pallet-contracts = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
18sp-runtime = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }17sp-runtime = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
19sp-std = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }18sp-std = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
20sp-io = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }19sp-io = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
21frame-benchmarking = { default-features = false, version = '3.0.0', optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }20frame-benchmarking = { default-features = false, version = '3.0.0', optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.3' }
2221
23pallet-nft-transaction-payment = { default-features = false, path = "../nft-transaction-payment" }22up-sponsorship = { default-features = false, path = "../../primitives/sponsorship", version = "0.1.0" }
24pallet-nft = { default-features = false, path = "../nft" }
25nft-data-structs = { path = '../../primitives', default-features = false }
26log = { version = "0.4.14", default-features = false }23log = { version = "0.4.14", default-features = false }
2724
28[dev-dependencies]25[dev-dependencies]
37 "frame-benchmarking/std",34 "frame-benchmarking/std",
38 "frame-support/std",35 "frame-support/std",
39 "frame-system/std",36 "frame-system/std",
40 "pallet-nft-transaction-payment/std",
41 "pallet-nft/std",
42 "pallet-contracts/std",
43 "nft-data-structs/std",37 "up-sponsorship/std",
44 "sp-io/std",38 "sp-io/std",
45 "sp-std/std",39 "sp-std/std",
46 "log/std",40 "log/std",
modifiedpallets/scheduler/src/lib.rsdiffbeforeafterboth
64 weights::{GetDispatchInfo, Weight},64 weights::{GetDispatchInfo, Weight},
65};65};
66use frame_system::{self as system, ensure_signed};66use frame_system::{self as system, ensure_signed};
67use pallet_nft::*;67pub use weights::WeightInfo;
68// use pallet_nft_transaction_payment::{self as nft_transaction_payment};
69use nft_data_structs::*;68use up_sponsorship::SponsorshipHandler;
70pub use weights::WeightInfo;
7169
72/// Our pallet's configuration trait. All our types and constants go in here. If the70/// Our pallet's configuration trait. All our types and constants go in here. If the
73/// pallet is dependent on specific other pallets, then their configuration traits71/// pallet is dependent on specific other pallets, then their configuration traits
103 type MaxScheduledPerBlock: Get<u32>;101 type MaxScheduledPerBlock: Get<u32>;
104102
105 /// Sponsoring function103 /// Sponsoring function
106 type Sponsoring: SponsoringResolve<Self::AccountId, <Self as Config>::Call>;104 type SponsorshipHandler: SponsorshipHandler<Self::AccountId, <Self as Config>::Call>;
107105
108 /// Weight information for extrinsics in this pallet.106 /// Weight information for extrinsics in this pallet.
109 type WeightInfo: WeightInfo;107 type WeightInfo: WeightInfo;
405 s.origin.clone()403 s.origin.clone()
406 ).into();404 ).into();
407 let sender = ensure_signed(origin).unwrap_or(T::AccountId::default());405 let sender = ensure_signed(origin).unwrap_or(T::AccountId::default());
408 let who_will_pay = T::Sponsoring::resolve(&sender, &s.call.clone()).unwrap_or(406 let who_will_pay = T::SponsorshipHandler::get_sponsor(&sender, &s.call).unwrap_or(sender);
409 sender);
410 let sponsor = T::PalletsOrigin::from(system::RawOrigin::Signed(who_will_pay));407 let sponsor = T::PalletsOrigin::from(system::RawOrigin::Signed(who_will_pay));
411 let r = s.call.clone().dispatch(sponsor.into());408 let r = s.call.clone().dispatch(sponsor.into());