difftreelog
style(Scheduler) removed unlikely to be used commented chunks of code
in: master
3 files changed
pallets/scheduler/src/lib.rsdiffbeforeafterboth--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -159,15 +159,6 @@
/// The location of a scheduled task that can be used to remove it.
pub type TaskAddress<BlockNumber> = (BlockNumber, u32);
-/*#[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq))] todo remove completely?
-#[derive(Clone, RuntimeDebug, Encode, Decode)]
-struct ScheduledV1<Call, BlockNumber> {
- maybe_id: Option<Vec<u8>>,
- priority: schedule::Priority,
- call: Call,
- maybe_periodic: Option<schedule::Period<BlockNumber>>,
-}*/
-
/// Information regarding an item to be executed in the future.
#[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq))]
#[derive(Clone, RuntimeDebug, Encode, Decode, TypeInfo)]
@@ -185,27 +176,8 @@
/// The information regarding the call's preparation for dispatch, in particular the fee, to be sent to post-dispatch.
pre_dispatch: PreDispatch,
_phantom: PhantomData<AccountId>,
-}
-
-/// The current version of Scheduled struct.
-/*pub type Scheduled<Call, BlockNumber, PalletsOrigin, AccountId, PreDispatch> =
- ScheduledV2<Call, BlockNumber, PalletsOrigin, AccountId, PreDispatch>;*/
-
-// A value placed in storage that represents the current version of the Scheduler storage.
-// This value is used by the `on_runtime_upgrade` logic to determine whether we run
-// storage migration logic.
-/*#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)] todo remove completely?
-enum Releases {
- V1,
- V2,
}
-impl Default for Releases {
- fn default() -> Self {
- Releases::V1
- }
-}*/
-
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub struct CallSpec {
module: u32,
@@ -223,17 +195,9 @@
T::AccountId,
<<T as Config>::CallExecutor as DispatchCall<T, H160>>::Pre
>>>;
-
- /*pub SpecAgenda: map hasher(twox_64_concat) T::BlockNumber todo remove completely?
- => Vec<Option<CallSpec>>;*/
-
+
/// Lookup from identity to the block number and index of the task.
Lookup: map hasher(twox_64_concat) Vec<u8> => Option<TaskAddress<T::BlockNumber>>;
-
- // / Storage version of the pallet.
- // /
- // / New networks start with last version.
- //StorageVersion build(|_| Releases::V2): Releases; todo remove completely?
}
}
@@ -535,9 +499,9 @@
<<T as Config>::Origin as From<T::PalletsOrigin>>::from(origin.clone()).into(),
)
.unwrap_or_default(); // todo sponsoring doesn't work with the line below -- found sponsoring is already checked for in transaction_payment
- //let who_will_pay = T::SponsorshipHandler::get_sponsor(&sender, &call).unwrap_or(sender);
- //let sponsor = T::PalletsOrigin::from(system::RawOrigin::Signed(who_will_pay.clone()));
- //let r = call.clone().dispatch(sponsor.into());
+ //let who_will_pay = T::SponsorshipHandler::get_sponsor(&sender, &call).unwrap_or(sender);
+ //let sponsor = T::PalletsOrigin::from(system::RawOrigin::Signed(who_will_pay.clone()));
+ //let r = call.clone().dispatch(sponsor.into());
let pre_dispatch = match T::CallExecutor::pre_dispatch(sender.clone(), call.clone()) {
Ok(pre_dispatch) => pre_dispatch,
runtime/src/lib.rsdiffbeforeafterboth811811812type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;812type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;813814/*fn get_signed_extra(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtra {815 (816 frame_system::CheckSpecVersion::<Runtime>::new(),817 frame_system::CheckGenesis::<Runtime>::new(),818 frame_system::CheckEra::<Runtime>::from(Era::Immortal),819 frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(820 from,821 )),822 frame_system::CheckWeight::<Runtime>::new(),823 ChargeTransactionPayment::new(0),824 )825}*/826813827#[derive(Default, Encode, Decode, Clone, TypeInfo)]814#[derive(Default, Encode, Decode, Clone, TypeInfo)]828pub struct SchedulerPreDispatch {815pub struct SchedulerPreDispatch {849 type Pre = SchedulerPreDispatch;836 type Pre = SchedulerPreDispatch;850837851 fn dispatch_call(838 fn dispatch_call(852 //signer: <T as frame_system::Config>::AccountId,853 pre_dispatch: Self::Pre,839 pre_dispatch: Self::Pre,854 call: <T as pallet_unq_scheduler::Config>::Call,840 call: <T as pallet_unq_scheduler::Config>::Call,855 ) -> Result<841 ) -> Result<856 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,842 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,857 TransactionValidityError,843 TransactionValidityError,858 > {844 > {859 /*let dispatch_info = call.get_dispatch_info();860861 let extrinsic = fp_self_contained::CheckedExtrinsic::<862 AccountId,863 Call,864 SignedExtra,865 SelfContainedSignedInfo,866 > {867 signed: CheckedSignature::<AccountId, SignedExtra, SelfContainedSignedInfo>::Signed(868 signer.clone().into(),869 get_signed_extra(signer.clone().into()),870 ),871 function: call.clone().into(),872 };873874 extrinsic.apply::<Runtime>(&dispatch_info, 0)*/875 let dispatch_info = call.get_dispatch_info();845 let dispatch_info = call.get_dispatch_info();876 let pre = (846 let pre = (877 pre_dispatch.tip,847 pre_dispatch.tip,tests/src/scheduler.test.tsdiffbeforeafterboth--- a/tests/src/scheduler.test.ts
+++ b/tests/src/scheduler.test.ts
@@ -3,7 +3,7 @@
// file 'LICENSE', which is part of this source code package.
//
-import chai, { expect } from 'chai';
+import chai, {expect} from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
import {
@@ -27,8 +27,6 @@
getTokenOwner,
getGenericResult,
scheduleTransferFundsPeriodicExpectSuccess,
- setCollectionLimitsExpectSuccess,
- getDetailedCollectionInfo,
getFreeBalance,
confirmSponsorshipByKeyExpectSuccess,
} from './util/helpers';
@@ -142,51 +140,6 @@
expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(alice.address));
});
});
-
- /*it.skip('Going bankrupt after sponsoring a scheduled transaction does not nullify the transaction', async () => {
- await usingApi(async (api) => {
- // Find two empty, unused accounts
- const zeroBalance = await findUnusedAddress(api);
- const zeroBalanceSponsor = await findUnusedAddress(api);
-
- const collectionId = await createCollectionExpectSuccess();
-
- // Grace these with money, enough to cover future transactions
- const balanceTx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);
- await submitTransactionAsync(alice, balanceTx);
-
- // Grace these with money, enough to cover future transactions
- const balanceSponsorTx = api.tx.balances.transfer(zeroBalanceSponsor.address, 1n * UNIQUE);
- await submitTransactionAsync(alice, balanceSponsorTx);
-
- // Set a collection sponsor
- await setCollectionSponsorExpectSuccess(collectionId, zeroBalanceSponsor.address);
- await confirmSponsorshipExpectSuccess(collectionId);
-
- // Add zeroBalance address to allow list
- await enablePublicMintingExpectSuccess(alice, collectionId);
- await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);
-
- // Mint a fresh NFT
- const tokenId = await createItemExpectSuccess(zeroBalance, collectionId, 'NFT');
-
- // Schedule transfer of the NFT a few blocks ahead
- // const waitForBlocks = 4;
- await scheduleTransferExpectSuccess(collectionId, tokenId, zeroBalance, alice, 1, 4);
- //await waitAfterScheduleExpectSuccess(collectionId, tokenId, alice, 3);
-
- // Get rid of the account's funds before the scheduled transaction takes place
- const emptyBalanceSponsorTx = api.tx.balances.setBalance(zeroBalanceSponsor.address, 0, 0);
- const sudoTx = api.tx.sudo.sudo(emptyBalanceSponsorTx as any);
- const events = await submitTransactionAsync(alice, sudoTx);
- expect(getGenericResult(events).success).to.be.true;
-
- // Wait for a certain number of blocks, save for the ones that already happened while accepting the late transactions
- await waitNewBlocks(4);
-
- expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(alice.address));
- });
- });*/
it('Sponsor going bankrupt does not impact a scheduled transaction', async () => {
const collectionId = await createCollectionExpectSuccess();