git.delta.rocks / unique-network / refs/commits / 7781ab982a4b

difftreelog

style(Scheduler) removed unlikely to be used commented chunks of code

Fahrrader2022-02-21parent: #be56642.patch.diff
in: master

3 files changed

modifiedpallets/scheduler/src/lib.rsdiffbeforeafterboth
159/// The location of a scheduled task that can be used to remove it.159/// The location of a scheduled task that can be used to remove it.
160pub type TaskAddress<BlockNumber> = (BlockNumber, u32);160pub type TaskAddress<BlockNumber> = (BlockNumber, u32);
161
162/*#[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq))] todo remove completely?
163#[derive(Clone, RuntimeDebug, Encode, Decode)]
164struct ScheduledV1<Call, BlockNumber> {
165 maybe_id: Option<Vec<u8>>,
166 priority: schedule::Priority,
167 call: Call,
168 maybe_periodic: Option<schedule::Period<BlockNumber>>,
169}*/
170161
171/// Information regarding an item to be executed in the future.162/// Information regarding an item to be executed in the future.
172#[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq))]163#[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq))]
187 _phantom: PhantomData<AccountId>,178 _phantom: PhantomData<AccountId>,
188}179}
189
190/// The current version of Scheduled struct.
191/*pub type Scheduled<Call, BlockNumber, PalletsOrigin, AccountId, PreDispatch> =
192 ScheduledV2<Call, BlockNumber, PalletsOrigin, AccountId, PreDispatch>;*/
193
194// A value placed in storage that represents the current version of the Scheduler storage.
195// This value is used by the `on_runtime_upgrade` logic to determine whether we run
196// storage migration logic.
197/*#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)] todo remove completely?
198enum Releases {
199 V1,
200 V2,
201}
202
203impl Default for Releases {
204 fn default() -> Self {
205 Releases::V1
206 }
207}*/
208180
209#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]181#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
210pub struct CallSpec {182pub struct CallSpec {
224 <<T as Config>::CallExecutor as DispatchCall<T, H160>>::Pre196 <<T as Config>::CallExecutor as DispatchCall<T, H160>>::Pre
225 >>>;197 >>>;
226198
227 /*pub SpecAgenda: map hasher(twox_64_concat) T::BlockNumber todo remove completely?
228 => Vec<Option<CallSpec>>;*/
229
230 /// Lookup from identity to the block number and index of the task.199 /// Lookup from identity to the block number and index of the task.
231 Lookup: map hasher(twox_64_concat) Vec<u8> => Option<TaskAddress<T::BlockNumber>>;200 Lookup: map hasher(twox_64_concat) Vec<u8> => Option<TaskAddress<T::BlockNumber>>;
232
233 // / Storage version of the pallet.
234 // /
235 // / New networks start with last version.
236 //StorageVersion build(|_| Releases::V2): Releases; todo remove completely?
237 }201 }
238}202}
239203
modifiedruntime/src/lib.rsdiffbeforeafterboth
811811
812type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;812type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;
813
814/*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}*/
826813
827#[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;
850837
851 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();
860
861 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 };
873
874 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,
modifiedtests/src/scheduler.test.tsdiffbeforeafterboth
27 getTokenOwner,27 getTokenOwner,
28 getGenericResult,28 getGenericResult,
29 scheduleTransferFundsPeriodicExpectSuccess,29 scheduleTransferFundsPeriodicExpectSuccess,
30 setCollectionLimitsExpectSuccess,
31 getDetailedCollectionInfo,
32 getFreeBalance,30 getFreeBalance,
33 confirmSponsorshipByKeyExpectSuccess,31 confirmSponsorshipByKeyExpectSuccess,
34} from './util/helpers';32} from './util/helpers';
143 });141 });
144 });142 });
145
146 /*it.skip('Going bankrupt after sponsoring a scheduled transaction does not nullify the transaction', async () => {
147 await usingApi(async (api) => {
148 // Find two empty, unused accounts
149 const zeroBalance = await findUnusedAddress(api);
150 const zeroBalanceSponsor = await findUnusedAddress(api);
151
152 const collectionId = await createCollectionExpectSuccess();
153
154 // Grace these with money, enough to cover future transactions
155 const balanceTx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);
156 await submitTransactionAsync(alice, balanceTx);
157
158 // Grace these with money, enough to cover future transactions
159 const balanceSponsorTx = api.tx.balances.transfer(zeroBalanceSponsor.address, 1n * UNIQUE);
160 await submitTransactionAsync(alice, balanceSponsorTx);
161
162 // Set a collection sponsor
163 await setCollectionSponsorExpectSuccess(collectionId, zeroBalanceSponsor.address);
164 await confirmSponsorshipExpectSuccess(collectionId);
165
166 // Add zeroBalance address to allow list
167 await enablePublicMintingExpectSuccess(alice, collectionId);
168 await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);
169
170 // Mint a fresh NFT
171 const tokenId = await createItemExpectSuccess(zeroBalance, collectionId, 'NFT');
172
173 // Schedule transfer of the NFT a few blocks ahead
174 // const waitForBlocks = 4;
175 await scheduleTransferExpectSuccess(collectionId, tokenId, zeroBalance, alice, 1, 4);
176 //await waitAfterScheduleExpectSuccess(collectionId, tokenId, alice, 3);
177
178 // Get rid of the account's funds before the scheduled transaction takes place
179 const emptyBalanceSponsorTx = api.tx.balances.setBalance(zeroBalanceSponsor.address, 0, 0);
180 const sudoTx = api.tx.sudo.sudo(emptyBalanceSponsorTx as any);
181 const events = await submitTransactionAsync(alice, sudoTx);
182 expect(getGenericResult(events).success).to.be.true;
183
184 // Wait for a certain number of blocks, save for the ones that already happened while accepting the late transactions
185 await waitNewBlocks(4);
186
187 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(alice.address));
188 });
189 });*/
190143
191 it('Sponsor going bankrupt does not impact a scheduled transaction', async () => {144 it('Sponsor going bankrupt does not impact a scheduled transaction', async () => {
192 const collectionId = await createCollectionExpectSuccess();145 const collectionId = await createCollectionExpectSuccess();