difftreelog
fix test both scheduling variants - anon and named
in: master
8 files changed
tests/src/eth/scheduling.test.tsdiffbeforeafterboth--- a/tests/src/eth/scheduling.test.ts
+++ b/tests/src/eth/scheduling.test.ts
@@ -15,7 +15,7 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {expect} from 'chai';
-import {EthUniqueHelper, itEth} from './util';
+import {EthUniqueHelper, itSchedEth} from './util';
import {Pallets, usingPlaygrounds} from '../util';
describe('Scheduing EVM smart contracts', () => {
@@ -26,11 +26,11 @@
});
});
- itEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async ({helper, privateKey}) => {
+ itSchedEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async (scheduleKind, {helper, privateKey}) => {
const donor = await privateKey({filename: __filename});
const [alice] = await helper.arrange.createAccounts([1000n], donor);
- const scheduledId = await helper.arrange.makeScheduledId();
+ const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;
const deployer = await helper.eth.createAccountWithBalance(alice);
const flipper = await helper.eth.deployFlipper(deployer);
@@ -44,7 +44,7 @@
repetitions: 2,
};
- await helper.scheduler.scheduleAfter<EthUniqueHelper>(scheduledId, waitForBlocks, {periodic})
+ await helper.scheduler.scheduleAfter<EthUniqueHelper>(waitForBlocks, {scheduledId, periodic})
.eth.sendEVM(
alice,
flipper.options.address,
tests/src/eth/util/index.tsdiffbeforeafterboth--- a/tests/src/eth/util/index.ts
+++ b/tests/src/eth/util/index.ts
@@ -8,6 +8,7 @@
import {EthUniqueHelper} from './playgrounds/unique.dev';
import {SilentLogger, SilentConsole} from '../../util/playgrounds/unique.dev';
+import {SchedKind} from '../../util';
export {EthUniqueHelper} from './playgrounds/unique.dev';
@@ -81,3 +82,19 @@
itEthIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEthIfWithPallet(name, required, cb, {only: true});
itEthIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEthIfWithPallet(name, required, cb, {skip: true});
itEth.ifWithPallets = itEthIfWithPallet;
+
+export function itSchedEth(
+ name: string,
+ cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any,
+ opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {},
+) {
+ itEth(name + ' (anonymous scheduling)', (apis) => cb('anon', apis), opts);
+ itEth(name + ' (named scheduling)', (apis) => cb('named', apis), opts);
+}
+itSchedEth.only = (name: string, cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itSchedEth(name, cb, {only: true});
+itSchedEth.skip = (name: string, cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itSchedEth(name, cb, {skip: true});
+itSchedEth.ifWithPallets = itSchedIfWithPallets;
+
+function itSchedIfWithPallets(name: string, required: string[], cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
+ return itSchedEth(name, cb, {requiredPallets: required, ...opts});
+}
tests/src/maintenanceMode.seqtest.tsdiffbeforeafterboth--- a/tests/src/maintenanceMode.seqtest.ts
+++ b/tests/src/maintenanceMode.seqtest.ts
@@ -16,7 +16,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {ApiPromise} from '@polkadot/api';
-import {expect, itSub, Pallets, usingPlaygrounds} from './util';
+import {expect, itSched, itSub, Pallets, usingPlaygrounds} from './util';
import {itEth} from './eth/util';
async function maintenanceEnabled(api: ApiPromise): Promise<boolean> {
@@ -162,7 +162,7 @@
await expect(helper.balance.transferToSubstrate(bob, superuser.address, 1n)).to.be.fulfilled;
});
- itSub.ifWithPallets('MM blocks scheduled calls and the scheduler itself', [Pallets.Scheduler], async ({helper}) => {
+ itSched.ifWithPallets('MM blocks scheduled calls and the scheduler itself', [Pallets.Scheduler], async (scheduleKind, {helper}) => {
const collection = await helper.nft.mintCollection(bob);
const nftBeforeMM = await collection.mintToken(bob);
@@ -175,23 +175,25 @@
scheduledIdBunkerThroughMM,
scheduledIdAttemptDuringMM,
scheduledIdAfterMM,
- ] = await helper.arrange.makeScheduledIds(5);
+ ] = scheduleKind == 'named'
+ ? helper.arrange.makeScheduledIds(5)
+ : new Array(5);
const blocksToWait = 6;
// Scheduling works before the maintenance
- await nftBeforeMM.scheduleAfter(scheduledIdBeforeMM, blocksToWait)
+ await nftBeforeMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdBeforeMM})
.transfer(bob, {Substrate: superuser.address});
await helper.wait.newBlocks(blocksToWait + 1);
expect(await nftBeforeMM.getOwner()).to.be.deep.equal({Substrate: superuser.address});
// Schedule a transaction that should occur *during* the maintenance
- await nftDuringMM.scheduleAfter(scheduledIdDuringMM, blocksToWait)
+ await nftDuringMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdDuringMM})
.transfer(bob, {Substrate: superuser.address});
// Schedule a transaction that should occur *after* the maintenance
- await nftDuringMM.scheduleAfter(scheduledIdBunkerThroughMM, blocksToWait * 2)
+ await nftDuringMM.scheduleAfter(blocksToWait * 2, {scheduledId: scheduledIdBunkerThroughMM})
.transfer(bob, {Substrate: superuser.address});
await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);
@@ -202,7 +204,7 @@
expect(await nftDuringMM.getOwner()).to.be.deep.equal({Substrate: bob.address});
// Any attempts to schedule a tx during the MM should be rejected
- await expect(nftDuringMM.scheduleAfter(scheduledIdAttemptDuringMM, blocksToWait)
+ await expect(nftDuringMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdAttemptDuringMM})
.transfer(bob, {Substrate: superuser.address}))
.to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);
@@ -210,7 +212,7 @@
expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;
// Scheduling works after the maintenance
- await nftAfterMM.scheduleAfter(scheduledIdAfterMM, blocksToWait)
+ await nftAfterMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdAfterMM})
.transfer(bob, {Substrate: superuser.address});
await helper.wait.newBlocks(blocksToWait + 1);
tests/src/scheduler.seqtest.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {expect, itSched, itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds} from './util';18import {IKeyringPair} from '@polkadot/types/types';19import {DevUniqueHelper} from './util/playgrounds/unique.dev';2021describe('Scheduling token and balance transfers', () => {22 let superuser: IKeyringPair;23 let alice: IKeyringPair;24 let bob: IKeyringPair;25 let charlie: IKeyringPair;2627 before(async function() {28 await usingPlaygrounds(async (helper, privateKey) => {29 requirePalletsOrSkip(this, helper, [Pallets.Scheduler]);3031 superuser = await privateKey('//Alice');32 const donor = await privateKey({filename: __filename});33 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);3435 await helper.testUtils.enable();36 });37 });3839 beforeEach(async () => {40 await usingPlaygrounds(async (helper) => {41 await helper.wait.noScheduledTasks();42 });43 });4445 itSched('Can delay a transfer of an owned token', async (scheduleKind, {helper}) => {46 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});47 const token = await collection.mintToken(alice);48 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;49 const blocksBeforeExecution = 4;50 51 await token.scheduleAfter(blocksBeforeExecution, {scheduledId})52 .transfer(alice, {Substrate: bob.address});53 const executionBlock = await helper.chain.getLatestBlockNumber() + blocksBeforeExecution + 1;5455 expect(await token.getOwner()).to.be.deep.equal({Substrate: alice.address});5657 await helper.wait.forParachainBlockNumber(executionBlock);5859 expect(await token.getOwner()).to.be.deep.equal({Substrate: bob.address});60 });6162 itSched('Can transfer funds periodically', async (scheduleKind, {helper}) => {63 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;64 const waitForBlocks = 1;6566 const amount = 1n * helper.balance.getOneTokenNominal();67 const periodic = {68 period: 2,69 repetitions: 2,70 };7172 const bobsBalanceBefore = await helper.balance.getSubstrate(bob.address);7374 await helper.scheduler.scheduleAfter(waitForBlocks, {scheduledId, periodic})75 .balance.transferToSubstrate(alice, bob.address, amount);76 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;7778 await helper.wait.forParachainBlockNumber(executionBlock);7980 const bobsBalanceAfterFirst = await helper.balance.getSubstrate(bob.address);81 expect(bobsBalanceAfterFirst)82 .to.be.equal(83 bobsBalanceBefore + 1n * amount,84 '#1 Balance of the recipient should be increased by 1 * amount',85 );8687 await helper.wait.forParachainBlockNumber(executionBlock + periodic.period);8889 const bobsBalanceAfterSecond = await helper.balance.getSubstrate(bob.address);90 expect(bobsBalanceAfterSecond)91 .to.be.equal(92 bobsBalanceBefore + 2n * amount,93 '#2 Balance of the recipient should be increased by 2 * amount',94 );95 });9697 itSub('Can cancel a scheduled operation which has not yet taken effect', async ({helper}) => {98 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});99 const token = await collection.mintToken(alice);100101 const scheduledId = helper.arrange.makeScheduledId();102 const waitForBlocks = 4;103104 expect(await token.getOwner()).to.be.deep.equal({Substrate: alice.address});105106 await token.scheduleAfter(waitForBlocks, {scheduledId})107 .transfer(alice, {Substrate: bob.address});108 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;109110 await helper.scheduler.cancelScheduled(alice, scheduledId);111112 await helper.wait.forParachainBlockNumber(executionBlock);113114 expect(await token.getOwner()).to.be.deep.equal({Substrate: alice.address});115 });116117 itSub('Can cancel a periodic operation (transfer of funds)', async ({helper}) => {118 const waitForBlocks = 1;119 const periodic = {120 period: 3,121 repetitions: 2,122 };123124 const scheduledId = helper.arrange.makeScheduledId();125126 const amount = 1n * helper.balance.getOneTokenNominal();127128 const bobsBalanceBefore = await helper.balance.getSubstrate(bob.address);129130 await helper.scheduler.scheduleAfter(waitForBlocks, {scheduledId, periodic})131 .balance.transferToSubstrate(alice, bob.address, amount);132 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;133134 await helper.wait.forParachainBlockNumber(executionBlock);135136 const bobsBalanceAfterFirst = await helper.balance.getSubstrate(bob.address);137138 expect(bobsBalanceAfterFirst)139 .to.be.equal(140 bobsBalanceBefore + 1n * amount,141 '#1 Balance of the recipient should be increased by 1 * amount',142 );143144 await helper.scheduler.cancelScheduled(alice, scheduledId);145 await helper.wait.forParachainBlockNumber(executionBlock + periodic.period);146147 const bobsBalanceAfterSecond = await helper.balance.getSubstrate(bob.address);148 expect(bobsBalanceAfterSecond)149 .to.be.equal(150 bobsBalanceAfterFirst,151 '#2 Balance of the recipient should not be changed',152 );153 });154155 itSched('scheduler will not insert more tasks than allowed', async (scheduleKind, {helper}) => {156 const maxScheduledPerBlock = 50;157 let fillScheduledIds = new Array(maxScheduledPerBlock);158 let extraScheduledId = undefined;159 160 if (scheduleKind == 'named') {161 const scheduledIds = helper.arrange.makeScheduledIds(maxScheduledPerBlock + 1);162 fillScheduledIds = scheduledIds.slice(0, maxScheduledPerBlock);163 extraScheduledId = scheduledIds[maxScheduledPerBlock];164 }165166 // Since the dev node has Instant Seal,167 // we need a larger gap between the current block and the target one.168 //169 // We will schedule `maxScheduledPerBlock` transaction into the target block,170 // so we need at least `maxScheduledPerBlock`-wide gap.171 // We add some additional blocks to this gap to mitigate possible PolkadotJS delays.172 const waitForBlocks = await helper.arrange.isDevNode() ? maxScheduledPerBlock + 5 : 5;173174 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks;175176 const amount = 1n * helper.balance.getOneTokenNominal();177178 const balanceBefore = await helper.balance.getSubstrate(bob.address);179180 // Fill the target block181 for (let i = 0; i < maxScheduledPerBlock; i++) {182 await helper.scheduler.scheduleAt(executionBlock, {scheduledId: fillScheduledIds[i]})183 .balance.transferToSubstrate(superuser, bob.address, amount);184 }185186 // Try to schedule a task into a full block187 await expect(helper.scheduler.scheduleAt(executionBlock, {scheduledId: extraScheduledId})188 .balance.transferToSubstrate(superuser, bob.address, amount))189 .to.be.rejectedWith(/scheduler\.AgendaIsExhausted/);190191 await helper.wait.forParachainBlockNumber(executionBlock);192193 const balanceAfter = await helper.balance.getSubstrate(bob.address);194195 expect(balanceAfter > balanceBefore).to.be.true;196197 const diff = balanceAfter - balanceBefore;198 expect(diff).to.be.equal(amount * BigInt(maxScheduledPerBlock));199 });200201 itSched.ifWithPallets('Scheduled tasks are transactional', [Pallets.TestUtils], async (scheduleKind, {helper}) => {202 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;203 const waitForBlocks = 4;204205 const initTestVal = 42;206 const changedTestVal = 111;207208 await helper.testUtils.setTestValue(alice, initTestVal);209210 await helper.scheduler.scheduleAfter<DevUniqueHelper>(waitForBlocks, {scheduledId})211 .testUtils.setTestValueAndRollback(alice, changedTestVal);212 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;213214 await helper.wait.forParachainBlockNumber(executionBlock);215216 const testVal = await helper.testUtils.testValue();217 expect(testVal, 'The test value should NOT be commited')218 .to.be.equal(initTestVal);219 });220221 itSched.ifWithPallets('Scheduled tasks should take correct fees', [Pallets.TestUtils], async function(scheduleKind, {helper}) {222 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;223 const waitForBlocks = 4;224 const periodic = {225 period: 2,226 repetitions: 2,227 };228229 const dummyTx = helper.constructApiCall('api.tx.testUtils.justTakeFee', []);230 const scheduledLen = dummyTx.callIndex.length;231232 const expectedScheduledFee = (await helper.getPaymentInfo(alice, dummyTx, scheduledLen))233 .partialFee.toBigInt();234235 await helper.scheduler.scheduleAfter<DevUniqueHelper>(waitForBlocks, {scheduledId, periodic})236 .testUtils.justTakeFee(alice);237 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;238239 const aliceInitBalance = await helper.balance.getSubstrate(alice.address);240 let diff;241242 await helper.wait.forParachainBlockNumber(executionBlock);243244 const aliceBalanceAfterFirst = await helper.balance.getSubstrate(alice.address);245 expect(246 aliceBalanceAfterFirst < aliceInitBalance,247 '[after execution #1] Scheduled task should take a fee',248 ).to.be.true;249250 diff = aliceInitBalance - aliceBalanceAfterFirst;251 expect(diff).to.be.equal(252 expectedScheduledFee,253 'Scheduled task should take the right amount of fees',254 );255256 await helper.wait.forParachainBlockNumber(executionBlock + periodic.period);257258 const aliceBalanceAfterSecond = await helper.balance.getSubstrate(alice.address);259 expect(260 aliceBalanceAfterSecond < aliceBalanceAfterFirst,261 '[after execution #2] Scheduled task should take a fee',262 ).to.be.true;263264 diff = aliceBalanceAfterFirst - aliceBalanceAfterSecond;265 expect(diff).to.be.equal(266 expectedScheduledFee,267 'Scheduled task should take the right amount of fees',268 );269 });270271 // Check if we can cancel a scheduled periodic operation272 // in the same block in which it is running273 itSub.ifWithPallets('Can cancel the periodic sheduled tx when the tx is running', [Pallets.TestUtils], async ({helper}) => {274 const currentBlockNumber = await helper.chain.getLatestBlockNumber();275 const blocksBeforeExecution = 10;276 const firstExecutionBlockNumber = currentBlockNumber + blocksBeforeExecution;277278 const [279 scheduledId,280 scheduledCancelId,281 ] = helper.arrange.makeScheduledIds(2);282283 const periodic = {284 period: 5,285 repetitions: 5,286 };287288 const initTestVal = 0;289 const incTestVal = initTestVal + 1;290 const finalTestVal = initTestVal + 2;291292 await helper.testUtils.setTestValue(alice, initTestVal);293294 await helper.scheduler.scheduleAt<DevUniqueHelper>(firstExecutionBlockNumber, {scheduledId, periodic})295 .testUtils.incTestValue(alice);296297 // Cancel the inc tx after 2 executions298 // *in the same block* in which the second execution is scheduled299 await helper.scheduler.scheduleAt(300 firstExecutionBlockNumber + periodic.period,301 {scheduledId: scheduledCancelId},302 ).scheduler.cancelScheduled(alice, scheduledId);303304 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber);305306 // execution #0307 expect(await helper.testUtils.testValue())308 .to.be.equal(incTestVal);309310 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber + periodic.period);311312 // execution #1313 expect(await helper.testUtils.testValue())314 .to.be.equal(finalTestVal);315316 for (let i = 1; i < periodic.repetitions; i++) {317 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber + periodic.period * (i + 1));318 expect(await helper.testUtils.testValue())319 .to.be.equal(finalTestVal);320 }321 });322323 itSub.ifWithPallets('A scheduled operation can cancel itself', [Pallets.TestUtils], async ({helper}) => {324 const scheduledId = helper.arrange.makeScheduledId();325 const waitForBlocks = 4;326 const periodic = {327 period: 2,328 repetitions: 5,329 };330331 const initTestVal = 0;332 const maxTestVal = 2;333334 await helper.testUtils.setTestValue(alice, initTestVal);335336 await helper.scheduler.scheduleAfter<DevUniqueHelper>(waitForBlocks, {scheduledId, periodic})337 .testUtils.selfCancelingInc(alice, scheduledId, maxTestVal);338 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;339340 await helper.wait.forParachainBlockNumber(executionBlock);341342 // execution #0343 expect(await helper.testUtils.testValue())344 .to.be.equal(initTestVal + 1);345346 await helper.wait.forParachainBlockNumber(executionBlock + periodic.period);347348 // execution #1349 expect(await helper.testUtils.testValue())350 .to.be.equal(initTestVal + 2);351352 await helper.wait.forParachainBlockNumber(executionBlock + 2 * periodic.period);353354 // <canceled>355 expect(await helper.testUtils.testValue())356 .to.be.equal(initTestVal + 2);357 });358359 itSub('Root can cancel any scheduled operation', async ({helper}) => {360 const collection = await helper.nft.mintCollection(bob, {tokenPrefix: 'schd'});361 const token = await collection.mintToken(bob);362363 const scheduledId = helper.arrange.makeScheduledId();364 const waitForBlocks = 4;365366 await token.scheduleAfter(waitForBlocks, {scheduledId})367 .transfer(bob, {Substrate: alice.address});368 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;369370 await helper.getSudo().scheduler.cancelScheduled(superuser, scheduledId);371372 await helper.wait.forParachainBlockNumber(executionBlock);373374 expect(await token.getOwner()).to.be.deep.equal({Substrate: bob.address});375 });376377 itSched('Root can set prioritized scheduled operation', async (scheduleKind, {helper}) => {378 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;379 const waitForBlocks = 4;380381 const amount = 42n * helper.balance.getOneTokenNominal();382383 const balanceBefore = await helper.balance.getSubstrate(charlie.address);384385 await helper.getSudo()386 .scheduler.scheduleAfter(waitForBlocks, {scheduledId, priority: 42})387 .balance.forceTransferToSubstrate(superuser, bob.address, charlie.address, amount);388 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;389390 await helper.wait.forParachainBlockNumber(executionBlock);391392 const balanceAfter = await helper.balance.getSubstrate(charlie.address);393394 expect(balanceAfter > balanceBefore).to.be.true;395396 const diff = balanceAfter - balanceBefore;397 expect(diff).to.be.equal(amount);398 });399400 itSub("Root can change scheduled operation's priority", async ({helper}) => {401 const collection = await helper.nft.mintCollection(bob, {tokenPrefix: 'schd'});402 const token = await collection.mintToken(bob);403404 const scheduledId = helper.arrange.makeScheduledId();405 const waitForBlocks = 6;406407 await token.scheduleAfter(waitForBlocks, {scheduledId})408 .transfer(bob, {Substrate: alice.address});409 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;410411 const priority = 112;412 await helper.getSudo().scheduler.changePriority(superuser, scheduledId, priority);413414 const priorityChanged = await helper.wait.event(415 waitForBlocks,416 'scheduler',417 'PriorityChanged',418 );419420 expect(priorityChanged !== null).to.be.true;421422 const [blockNumber, index] = priorityChanged!.event.data[0].toJSON() as any[];423 expect(blockNumber).to.be.equal(executionBlock);424 expect(index).to.be.equal(0);425426 expect(priorityChanged!.event.data[1].toString()).to.be.equal(priority.toString());427 });428429 itSub('Prioritized operations execute in valid order', async ({helper}) => {430 const [431 scheduledFirstId,432 scheduledSecondId,433 ] = helper.arrange.makeScheduledIds(2);434435 const currentBlockNumber = await helper.chain.getLatestBlockNumber();436 const blocksBeforeExecution = 6;437 const firstExecutionBlockNumber = currentBlockNumber + blocksBeforeExecution;438439 const prioHigh = 0;440 const prioLow = 255;441442 const periodic = {443 period: 6,444 repetitions: 2,445 };446447 const amount = 1n * helper.balance.getOneTokenNominal();448449 // Scheduler a task with a lower priority first, then with a higher priority450 await helper.getSudo().scheduler.scheduleAt(firstExecutionBlockNumber, {451 scheduledId: scheduledFirstId,452 priority: prioLow,453 periodic,454 }).balance.forceTransferToSubstrate(superuser, alice.address, bob.address, amount);455456 await helper.getSudo().scheduler.scheduleAt(firstExecutionBlockNumber, {457 scheduledId: scheduledSecondId,458 priority: prioHigh,459 periodic,460 }).balance.forceTransferToSubstrate(superuser, alice.address, bob.address, amount);461462 const capture = await helper.arrange.captureEvents('scheduler', 'Dispatched');463464 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber);465466 // Flip priorities467 await helper.getSudo().scheduler.changePriority(superuser, scheduledFirstId, prioHigh);468 await helper.getSudo().scheduler.changePriority(superuser, scheduledSecondId, prioLow);469470 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber + periodic.period);471472 const dispatchEvents = capture.extractCapturedEvents();473 expect(dispatchEvents.length).to.be.equal(4);474475 const dispatchedIds = dispatchEvents.map(r => r.event.data[1].toString());476477 const firstExecuctionIds = [dispatchedIds[0], dispatchedIds[1]];478 const secondExecuctionIds = [dispatchedIds[2], dispatchedIds[3]];479480 expect(firstExecuctionIds[0]).to.be.equal(scheduledSecondId);481 expect(firstExecuctionIds[1]).to.be.equal(scheduledFirstId);482483 expect(secondExecuctionIds[0]).to.be.equal(scheduledFirstId);484 expect(secondExecuctionIds[1]).to.be.equal(scheduledSecondId);485 });486487 itSched('Periodic operations always can be rescheduled', async (scheduleKind, {helper}) => {488 const maxScheduledPerBlock = 50;489 const numFilledBlocks = 3;490 const ids = helper.arrange.makeScheduledIds(numFilledBlocks * maxScheduledPerBlock + 1);491 const periodicId = scheduleKind == 'named' ? ids[0] : undefined;492 const fillIds = ids.slice(1);493494 const fillScheduleFn = scheduleKind == 'named' ? 'scheduleNamed' : 'schedule';495496 const initTestVal = 0;497 const firstExecTestVal = 1;498 const secondExecTestVal = 2;499 await helper.testUtils.setTestValue(alice, initTestVal);500501 const currentBlockNumber = await helper.chain.getLatestBlockNumber();502 const blocksBeforeExecution = 8;503 const firstExecutionBlockNumber = currentBlockNumber + blocksBeforeExecution;504505 const period = 5;506507 const periodic = {508 period,509 repetitions: 2,510 };511512 // Fill `numFilledBlocks` blocks beginning from the block in which the second execution should occur513 const txs = [];514 for (let offset = 0; offset < numFilledBlocks; offset ++) {515 for (let i = 0; i < maxScheduledPerBlock; i++) {516517 const scheduledTx = helper.constructApiCall('api.tx.balances.transfer', [bob.address, 1n]);518519 const when = firstExecutionBlockNumber + period + offset;520 const mandatoryArgs = [when, null, null, scheduledTx];521 const scheduleArgs = scheduleKind == 'named'522 ? [fillIds[i + offset * maxScheduledPerBlock], ...mandatoryArgs]523 : mandatoryArgs;524525 const tx = helper.constructApiCall(`api.tx.scheduler.${fillScheduleFn}`, scheduleArgs);526527 txs.push(tx);528 }529 }530 await helper.executeExtrinsic(alice, 'api.tx.testUtils.batchAll', [txs], true);531532 await helper.scheduler.scheduleAt<DevUniqueHelper>(firstExecutionBlockNumber, {533 scheduledId: periodicId,534 periodic,535 }).testUtils.incTestValue(alice);536537 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber);538 expect(await helper.testUtils.testValue()).to.be.equal(firstExecTestVal);539540 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber + period + numFilledBlocks);541542 // The periodic operation should be postponed by `numFilledBlocks`543 for (let i = 0; i < numFilledBlocks; i++) {544 expect(await helper.testUtils.testValue(firstExecutionBlockNumber + period + i)).to.be.equal(firstExecTestVal);545 }546547 // After the `numFilledBlocks` the periodic operation will eventually be executed548 expect(await helper.testUtils.testValue()).to.be.equal(secondExecTestVal);549 });550551 itSched('scheduled operations does not change nonce', async (scheduleKind, {helper}) => {552 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;553 const blocksBeforeExecution = 4;554555 await helper.scheduler556 .scheduleAfter<DevUniqueHelper>(blocksBeforeExecution, {scheduledId})557 .balance.transferToSubstrate(alice, bob.address, 1n);558 const executionBlock = await helper.chain.getLatestBlockNumber() + blocksBeforeExecution + 1;559560 const initNonce = await helper.chain.getNonce(alice.address);561562 await helper.wait.forParachainBlockNumber(executionBlock);563564 const finalNonce = await helper.chain.getNonce(alice.address);565566 expect(initNonce).to.be.equal(finalNonce);567 });568});569570describe('Negative Test: Scheduling', () => {571 let alice: IKeyringPair;572 let bob: IKeyringPair;573574 before(async function() {575 await usingPlaygrounds(async (helper, privateKey) => {576 requirePalletsOrSkip(this, helper, [Pallets.Scheduler]);577578 const donor = await privateKey({filename: __filename});579 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);580581 await helper.testUtils.enable();582 });583 });584585 itSub("Can't overwrite a scheduled ID", async ({helper}) => {586 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});587 const token = await collection.mintToken(alice);588589 const scheduledId = helper.arrange.makeScheduledId();590 const waitForBlocks = 4;591592 await token.scheduleAfter(waitForBlocks, {scheduledId})593 .transfer(alice, {Substrate: bob.address});594 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;595596 const scheduled = helper.scheduler.scheduleAfter(waitForBlocks, {scheduledId});597 await expect(scheduled.balance.transferToSubstrate(alice, bob.address, 1n * helper.balance.getOneTokenNominal()))598 .to.be.rejectedWith(/scheduler\.FailedToSchedule/);599600 const bobsBalanceBefore = await helper.balance.getSubstrate(bob.address);601602 await helper.wait.forParachainBlockNumber(executionBlock);603604 const bobsBalanceAfter = await helper.balance.getSubstrate(bob.address);605606 expect(await token.getOwner()).to.be.deep.equal({Substrate: bob.address});607 expect(bobsBalanceBefore).to.be.equal(bobsBalanceAfter);608 });609610 itSub("Can't cancel an operation which is not scheduled", async ({helper}) => {611 const scheduledId = helper.arrange.makeScheduledId();612 await expect(helper.scheduler.cancelScheduled(alice, scheduledId))613 .to.be.rejectedWith(/scheduler\.NotFound/);614 });615616 itSub("Can't cancel a non-owned scheduled operation", async ({helper}) => {617 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});618 const token = await collection.mintToken(alice);619620 const scheduledId = helper.arrange.makeScheduledId();621 const waitForBlocks = 4;622623 await token.scheduleAfter(waitForBlocks, {scheduledId})624 .transfer(alice, {Substrate: bob.address});625 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;626627 await expect(helper.scheduler.cancelScheduled(bob, scheduledId))628 .to.be.rejectedWith(/BadOrigin/);629630 await helper.wait.forParachainBlockNumber(executionBlock);631632 expect(await token.getOwner()).to.be.deep.equal({Substrate: bob.address});633 });634635 itSched("Regular user can't set prioritized scheduled operation", async (scheduleKind, {helper}) => {636 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;637 const waitForBlocks = 4;638639 const amount = 42n * helper.balance.getOneTokenNominal();640641 const balanceBefore = await helper.balance.getSubstrate(bob.address);642643 const scheduled = helper.scheduler.scheduleAfter(waitForBlocks, {scheduledId, priority: 42});644 645 await expect(scheduled.balance.transferToSubstrate(alice, bob.address, amount))646 .to.be.rejectedWith(/BadOrigin/);647648 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;649650 await helper.wait.forParachainBlockNumber(executionBlock);651652 const balanceAfter = await helper.balance.getSubstrate(bob.address);653654 expect(balanceAfter).to.be.equal(balanceBefore);655 });656657 itSub("Regular user can't change scheduled operation's priority", async ({helper}) => {658 const collection = await helper.nft.mintCollection(bob, {tokenPrefix: 'schd'});659 const token = await collection.mintToken(bob);660661 const scheduledId = helper.arrange.makeScheduledId();662 const waitForBlocks = 4;663664 await token.scheduleAfter(waitForBlocks, {scheduledId})665 .transfer(bob, {Substrate: alice.address});666667 const priority = 112;668 await expect(helper.scheduler.changePriority(alice, scheduledId, priority))669 .to.be.rejectedWith(/BadOrigin/);670671 const priorityChanged = await helper.wait.event(672 waitForBlocks,673 'scheduler',674 'PriorityChanged',675 );676677 expect(priorityChanged === null).to.be.true;678 });679});680681// Implementation of the functionality tested here was postponed/shelved682describe.skip('Sponsoring scheduling', () => {683 // let alice: IKeyringPair;684 // let bob: IKeyringPair;685686 // before(async() => {687 // await usingApi(async (_, privateKey) => {688 // alice = privateKey('//Alice');689 // bob = privateKey('//Bob');690 // });691 // });692693 it('Can sponsor scheduling a transaction', async () => {694 // const collectionId = await createCollectionExpectSuccess();695 // await setCollectionSponsorExpectSuccess(collectionId, bob.address);696 // await confirmSponsorshipExpectSuccess(collectionId, '//Bob');697698 // await usingApi(async api => {699 // const scheduledId = await makeScheduledId();700 // const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);701702 // const bobBalanceBefore = await getFreeBalance(bob);703 // const waitForBlocks = 4;704 // // no need to wait to check, fees must be deducted on scheduling, immediately705 // await scheduleTransferExpectSuccess(api, collectionId, tokenId, alice, bob, 0, waitForBlocks, scheduledId);706 // const bobBalanceAfter = await getFreeBalance(bob);707 // // expect(aliceBalanceAfter == aliceBalanceBefore).to.be.true;708 // expect(bobBalanceAfter < bobBalanceBefore).to.be.true;709 // // wait for sequentiality matters710 // await waitNewBlocks(waitForBlocks - 1);711 // });712 });713714 it('Schedules and dispatches a transaction even if the caller has no funds at the time of the dispatch', async () => {715 // await usingApi(async (api, privateKey) => {716 // // Find an empty, unused account717 // const zeroBalance = await findUnusedAddress(api, privateKey);718719 // const collectionId = await createCollectionExpectSuccess();720721 // // Add zeroBalance address to allow list722 // await enablePublicMintingExpectSuccess(alice, collectionId);723 // await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);724725 // // Grace zeroBalance with money, enough to cover future transactions726 // const balanceTx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);727 // await submitTransactionAsync(alice, balanceTx);728729 // // Mint a fresh NFT730 // const tokenId = await createItemExpectSuccess(zeroBalance, collectionId, 'NFT');731 // const scheduledId = await makeScheduledId();732733 // // Schedule transfer of the NFT a few blocks ahead734 // const waitForBlocks = 5;735 // await scheduleTransferExpectSuccess(api, collectionId, tokenId, zeroBalance, alice, 1, waitForBlocks, scheduledId);736737 // // Get rid of the account's funds before the scheduled transaction takes place738 // const balanceTx2 = api.tx.balances.transfer(alice.address, UNIQUE * 68n / 100n);739 // const events = await submitTransactionAsync(zeroBalance, balanceTx2);740 // expect(getGenericResult(events).success).to.be.true;741 // /*const emptyBalanceTx = api.tx.balances.setBalance(zeroBalance.address, 0, 0); // do not null reserved?742 // const sudoTx = api.tx.sudo.sudo(emptyBalanceTx as any);743 // const events = await submitTransactionAsync(alice, sudoTx);744 // expect(getGenericResult(events).success).to.be.true;*/745746 // // Wait for a certain number of blocks, discarding the ones that already happened while accepting the late transactions747 // await waitNewBlocks(waitForBlocks - 3);748749 // expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(alice.address));750 // });751 });752753 it('Sponsor going bankrupt does not impact a scheduled transaction', async () => {754 // const collectionId = await createCollectionExpectSuccess();755756 // await usingApi(async (api, privateKey) => {757 // const zeroBalance = await findUnusedAddress(api, privateKey);758 // const balanceTx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);759 // await submitTransactionAsync(alice, balanceTx);760761 // await setCollectionSponsorExpectSuccess(collectionId, zeroBalance.address);762 // await confirmSponsorshipByKeyExpectSuccess(collectionId, zeroBalance);763764 // const scheduledId = await makeScheduledId();765 // const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);766767 // const waitForBlocks = 5;768 // await scheduleTransferExpectSuccess(api, collectionId, tokenId, alice, zeroBalance, 1, waitForBlocks, scheduledId);769770 // const emptyBalanceSponsorTx = api.tx.balances.setBalance(zeroBalance.address, 0, 0);771 // const sudoTx = api.tx.sudo.sudo(emptyBalanceSponsorTx as any);772 // const events = await submitTransactionAsync(alice, sudoTx);773 // expect(getGenericResult(events).success).to.be.true;774775 // // Wait for a certain number of blocks, save for the ones that already happened while accepting the late transactions776 // await waitNewBlocks(waitForBlocks - 3);777778 // expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(zeroBalance.address));779 // });780 });781782 it('Exceeding sponsor rate limit without having enough funds prevents scheduling a periodic transaction', async () => {783 // const collectionId = await createCollectionExpectSuccess();784 // await setCollectionSponsorExpectSuccess(collectionId, bob.address);785 // await confirmSponsorshipExpectSuccess(collectionId, '//Bob');786787 // await usingApi(async (api, privateKey) => {788 // const zeroBalance = await findUnusedAddress(api, privateKey);789790 // await enablePublicMintingExpectSuccess(alice, collectionId);791 // await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);792793 // const bobBalanceBefore = await getFreeBalance(bob);794795 // const createData = {nft: {const_data: [], variable_data: []}};796 // const creationTx = api.tx.unique.createItem(collectionId, normalizeAccountId(zeroBalance), createData as any);797 // const scheduledId = await makeScheduledId();798799 // /*const badTransaction = async function () {800 // await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);801 // };802 // await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');*/803804 // await expect(scheduleAfter(api, creationTx, zeroBalance, 3, scheduledId, 1, 3)).to.be.rejectedWith(/Inability to pay some fees/);805806 // expect(await getFreeBalance(bob)).to.be.equal(bobBalanceBefore);807 // });808 });809});tests/src/util/index.tsdiffbeforeafterboth--- a/tests/src/util/index.ts
+++ b/tests/src/util/index.ts
@@ -130,6 +130,24 @@
itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});
itSub.ifWithPallets = itSubIfWithPallet;
+export type SchedKind = 'anon' | 'named';
+
+export function itSched(
+ name: string,
+ cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any,
+ opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {},
+) {
+ itSub(name + ' (anonymous scheduling)', (apis) => cb('anon', apis), opts);
+ itSub(name + ' (named scheduling)', (apis) => cb('named', apis), opts);
+}
+itSched.only = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {only: true});
+itSched.skip = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {skip: true});
+itSched.ifWithPallets = itSchedIfWithPallets;
+
+function itSchedIfWithPallets(name: string, required: string[], cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
+ return itSched(name, cb, {requiredPallets: required, ...opts});
+}
+
export function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {
(process.env.RUN_XCM_TESTS && !opts.skip
? describe
tests/src/util/playgrounds/types.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/types.ts
+++ b/tests/src/util/playgrounds/types.ts
@@ -172,6 +172,7 @@
}
export interface ISchedulerOptions {
+ scheduledId?: string,
priority?: number,
periodic?: {
period: number,
tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -308,9 +308,7 @@
return encodeAddress(address);
}
- async makeScheduledIds(num: number): Promise<string[]> {
- await this.helper.wait.noScheduledTasks();
-
+ makeScheduledIds(num: number): string[] {
function makeId(slider: number) {
const scheduledIdSize = 64;
const hexId = slider.toString(16);
@@ -330,8 +328,8 @@
return ids;
}
- async makeScheduledId(): Promise<string> {
- return (await this.makeScheduledIds(1))[0];
+ makeScheduledId(): string {
+ return (this.makeScheduledIds(1))[0];
}
async captureEvents(eventSection: string, eventMethod: string): Promise<EventCapture> {
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2560,24 +2560,21 @@
}
scheduleAt<T extends UniqueHelper>(
- scheduledId: string,
executionBlockNumber: number,
options: ISchedulerOptions = {},
) {
- return this.schedule<T>('scheduleNamed', scheduledId, executionBlockNumber, options);
+ return this.schedule<T>('schedule', executionBlockNumber, options);
}
scheduleAfter<T extends UniqueHelper>(
- scheduledId: string,
blocksBeforeExecution: number,
options: ISchedulerOptions = {},
) {
- return this.schedule<T>('scheduleNamedAfter', scheduledId, blocksBeforeExecution, options);
+ return this.schedule<T>('scheduleAfter', blocksBeforeExecution, options);
}
schedule<T extends UniqueHelper>(
- scheduleFn: 'scheduleNamed' | 'scheduleNamedAfter',
- scheduledId: string,
+ scheduleFn: 'schedule' | 'scheduleAfter',
blocksNum: number,
options: ISchedulerOptions = {},
) {
@@ -2585,7 +2582,6 @@
const ScheduledHelperType = ScheduledUniqueHelper(this.helper.helperBase);
return this.helper.clone(ScheduledHelperType, {
scheduleFn,
- scheduledId,
blocksNum,
options,
}) as T;
@@ -2874,16 +2870,14 @@
// eslint-disable-next-line @typescript-eslint/naming-convention
function ScheduledUniqueHelper<T extends UniqueHelperConstructor>(Base: T) {
return class extends Base {
- scheduleFn: 'scheduleNamed' | 'scheduleNamedAfter';
- scheduledId: string;
+ scheduleFn: 'schedule' | 'scheduleAfter';
blocksNum: number;
options: ISchedulerOptions;
constructor(...args: any[]) {
const logger = args[0] as ILogger;
const options = args[1] as {
- scheduleFn: 'scheduleNamed' | 'scheduleNamedAfter',
- scheduledId: string,
+ scheduleFn: 'schedule' | 'scheduleAfter',
blocksNum: number,
options: ISchedulerOptions
};
@@ -2891,25 +2885,42 @@
super(logger);
this.scheduleFn = options.scheduleFn;
- this.scheduledId = options.scheduledId;
this.blocksNum = options.blocksNum;
this.options = options.options;
}
executeExtrinsic(sender: IKeyringPair, scheduledExtrinsic: string, scheduledParams: any[], expectSuccess?: boolean): Promise<ITransactionResult> {
const scheduledTx = this.constructApiCall(scheduledExtrinsic, scheduledParams);
- const extrinsic = 'api.tx.scheduler.' + this.scheduleFn;
+
+ const mandatorySchedArgs = [
+ this.blocksNum,
+ this.options.periodic ? [this.options.periodic.period, this.options.periodic.repetitions] : null,
+ this.options.priority ?? null,
+ scheduledTx,
+ ];
+
+ let schedArgs;
+ let scheduleFn;
+
+ if (this.options.scheduledId) {
+ schedArgs = [this.options.scheduledId!, ...mandatorySchedArgs];
+ if (this.scheduleFn == 'schedule') {
+ scheduleFn = 'scheduleNamed';
+ } else if (this.scheduleFn == 'scheduleAfter') {
+ scheduleFn = 'scheduleNamedAfter';
+ }
+ } else {
+ schedArgs = mandatorySchedArgs;
+ scheduleFn = this.scheduleFn;
+ }
+
+ const extrinsic = 'api.tx.scheduler.' + scheduleFn;
+
return super.executeExtrinsic(
sender,
extrinsic,
- [
- this.scheduledId,
- this.blocksNum,
- this.options.periodic ? [this.options.periodic.period, this.options.periodic.repetitions] : null,
- this.options.priority ?? null,
- scheduledTx,
- ],
+ schedArgs,
expectSuccess,
);
}
@@ -3046,20 +3057,18 @@
}
scheduleAt<T extends UniqueHelper>(
- scheduledId: string,
executionBlockNumber: number,
options: ISchedulerOptions = {},
) {
- const scheduledHelper = this.helper.scheduler.scheduleAt<T>(scheduledId, executionBlockNumber, options);
+ const scheduledHelper = this.helper.scheduler.scheduleAt<T>(executionBlockNumber, options);
return new UniqueBaseCollection(this.collectionId, scheduledHelper);
}
scheduleAfter<T extends UniqueHelper>(
- scheduledId: string,
blocksBeforeExecution: number,
options: ISchedulerOptions = {},
) {
- const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);
+ const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(blocksBeforeExecution, options);
return new UniqueBaseCollection(this.collectionId, scheduledHelper);
}
@@ -3155,20 +3164,18 @@
}
scheduleAt<T extends UniqueHelper>(
- scheduledId: string,
executionBlockNumber: number,
options: ISchedulerOptions = {},
) {
- const scheduledHelper = this.helper.scheduler.scheduleAt<T>(scheduledId, executionBlockNumber, options);
+ const scheduledHelper = this.helper.scheduler.scheduleAt<T>(executionBlockNumber, options);
return new UniqueNFTCollection(this.collectionId, scheduledHelper);
}
scheduleAfter<T extends UniqueHelper>(
- scheduledId: string,
blocksBeforeExecution: number,
options: ISchedulerOptions = {},
) {
- const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);
+ const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(blocksBeforeExecution, options);
return new UniqueNFTCollection(this.collectionId, scheduledHelper);
}
@@ -3260,20 +3267,18 @@
}
scheduleAt<T extends UniqueHelper>(
- scheduledId: string,
executionBlockNumber: number,
options: ISchedulerOptions = {},
) {
- const scheduledHelper = this.helper.scheduler.scheduleAt<T>(scheduledId, executionBlockNumber, options);
+ const scheduledHelper = this.helper.scheduler.scheduleAt<T>(executionBlockNumber, options);
return new UniqueRFTCollection(this.collectionId, scheduledHelper);
}
scheduleAfter<T extends UniqueHelper>(
- scheduledId: string,
blocksBeforeExecution: number,
options: ISchedulerOptions = {},
) {
- const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);
+ const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(blocksBeforeExecution, options);
return new UniqueRFTCollection(this.collectionId, scheduledHelper);
}
@@ -3329,20 +3334,18 @@
}
scheduleAt<T extends UniqueHelper>(
- scheduledId: string,
executionBlockNumber: number,
options: ISchedulerOptions = {},
) {
- const scheduledHelper = this.helper.scheduler.scheduleAt<T>(scheduledId, executionBlockNumber, options);
+ const scheduledHelper = this.helper.scheduler.scheduleAt<T>(executionBlockNumber, options);
return new UniqueFTCollection(this.collectionId, scheduledHelper);
}
scheduleAfter<T extends UniqueHelper>(
- scheduledId: string,
blocksBeforeExecution: number,
options: ISchedulerOptions = {},
) {
- const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);
+ const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(blocksBeforeExecution, options);
return new UniqueFTCollection(this.collectionId, scheduledHelper);
}
@@ -3388,20 +3391,18 @@
}
scheduleAt<T extends UniqueHelper>(
- scheduledId: string,
executionBlockNumber: number,
options: ISchedulerOptions = {},
) {
- const scheduledCollection = this.collection.scheduleAt<T>(scheduledId, executionBlockNumber, options);
+ const scheduledCollection = this.collection.scheduleAt<T>(executionBlockNumber, options);
return new UniqueBaseToken(this.tokenId, scheduledCollection);
}
scheduleAfter<T extends UniqueHelper>(
- scheduledId: string,
blocksBeforeExecution: number,
options: ISchedulerOptions = {},
) {
- const scheduledCollection = this.collection.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);
+ const scheduledCollection = this.collection.scheduleAfter<T>(blocksBeforeExecution, options);
return new UniqueBaseToken(this.tokenId, scheduledCollection);
}
@@ -3468,20 +3469,18 @@
}
scheduleAt<T extends UniqueHelper>(
- scheduledId: string,
executionBlockNumber: number,
options: ISchedulerOptions = {},
) {
- const scheduledCollection = this.collection.scheduleAt<T>(scheduledId, executionBlockNumber, options);
+ const scheduledCollection = this.collection.scheduleAt<T>(executionBlockNumber, options);
return new UniqueNFToken(this.tokenId, scheduledCollection);
}
scheduleAfter<T extends UniqueHelper>(
- scheduledId: string,
blocksBeforeExecution: number,
options: ISchedulerOptions = {},
) {
- const scheduledCollection = this.collection.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);
+ const scheduledCollection = this.collection.scheduleAfter<T>(blocksBeforeExecution, options);
return new UniqueNFToken(this.tokenId, scheduledCollection);
}
@@ -3543,20 +3542,18 @@
}
scheduleAt<T extends UniqueHelper>(
- scheduledId: string,
executionBlockNumber: number,
options: ISchedulerOptions = {},
) {
- const scheduledCollection = this.collection.scheduleAt<T>(scheduledId, executionBlockNumber, options);
+ const scheduledCollection = this.collection.scheduleAt<T>(executionBlockNumber, options);
return new UniqueRFToken(this.tokenId, scheduledCollection);
}
scheduleAfter<T extends UniqueHelper>(
- scheduledId: string,
blocksBeforeExecution: number,
options: ISchedulerOptions = {},
) {
- const scheduledCollection = this.collection.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);
+ const scheduledCollection = this.collection.scheduleAfter<T>(blocksBeforeExecution, options);
return new UniqueRFToken(this.tokenId, scheduledCollection);
}