difftreelog
fix test both scheduling variants - anon and named
in: master
8 files changed
tests/src/eth/scheduling.test.tsdiffbeforeafterboth15// 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/>.161617import {expect} from 'chai';17import {expect} from 'chai';18import {EthUniqueHelper, itEth} from './util';18import {EthUniqueHelper, itSchedEth} from './util';19import {Pallets, usingPlaygrounds} from '../util';19import {Pallets, usingPlaygrounds} from '../util';202021describe('Scheduing EVM smart contracts', () => {21describe('Scheduing EVM smart contracts', () => {26 });26 });27 });27 });282829 itEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async ({helper, privateKey}) => {29 itSchedEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async (scheduleKind, {helper, privateKey}) => {30 const donor = await privateKey({filename: __filename});30 const donor = await privateKey({filename: __filename});31 const [alice] = await helper.arrange.createAccounts([1000n], donor);31 const [alice] = await helper.arrange.createAccounts([1000n], donor);323233 const scheduledId = await helper.arrange.makeScheduledId();33 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;343435 const deployer = await helper.eth.createAccountWithBalance(alice);35 const deployer = await helper.eth.createAccountWithBalance(alice);36 const flipper = await helper.eth.deployFlipper(deployer);36 const flipper = await helper.eth.deployFlipper(deployer);44 repetitions: 2,44 repetitions: 2,45 };45 };464647 await helper.scheduler.scheduleAfter<EthUniqueHelper>(scheduledId, waitForBlocks, {periodic})47 await helper.scheduler.scheduleAfter<EthUniqueHelper>(waitForBlocks, {scheduledId, periodic})48 .eth.sendEVM(48 .eth.sendEVM(49 alice,49 alice,50 flipper.options.address,50 flipper.options.address,tests/src/eth/util/index.tsdiffbeforeafterboth889import {EthUniqueHelper} from './playgrounds/unique.dev';9import {EthUniqueHelper} from './playgrounds/unique.dev';10import {SilentLogger, SilentConsole} from '../../util/playgrounds/unique.dev';10import {SilentLogger, SilentConsole} from '../../util/playgrounds/unique.dev';11import {SchedKind} from '../../util';111212export {EthUniqueHelper} from './playgrounds/unique.dev';13export {EthUniqueHelper} from './playgrounds/unique.dev';131482itEthIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEthIfWithPallet(name, required, cb, {skip: true});83itEthIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEthIfWithPallet(name, required, cb, {skip: true});83itEth.ifWithPallets = itEthIfWithPallet;84itEth.ifWithPallets = itEthIfWithPallet;8586export function itSchedEth(87 name: string,88 cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any,89 opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {},90) {91 itEth(name + ' (anonymous scheduling)', (apis) => cb('anon', apis), opts);92 itEth(name + ' (named scheduling)', (apis) => cb('named', apis), opts);93}94itSchedEth.only = (name: string, cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itSchedEth(name, cb, {only: true});95itSchedEth.skip = (name: string, cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itSchedEth(name, cb, {skip: true});96itSchedEth.ifWithPallets = itSchedIfWithPallets;9798function 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[] } = {}) {99 return itSchedEth(name, cb, {requiredPallets: required, ...opts});100}84101tests/src/maintenanceMode.seqtest.tsdiffbeforeafterboth161617import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import {ApiPromise} from '@polkadot/api';18import {ApiPromise} from '@polkadot/api';19import {expect, itSub, Pallets, usingPlaygrounds} from './util';19import {expect, itSched, itSub, Pallets, usingPlaygrounds} from './util';20import {itEth} from './eth/util';20import {itEth} from './eth/util';212122async function maintenanceEnabled(api: ApiPromise): Promise<boolean> {22async function maintenanceEnabled(api: ApiPromise): Promise<boolean> {162 await expect(helper.balance.transferToSubstrate(bob, superuser.address, 1n)).to.be.fulfilled;162 await expect(helper.balance.transferToSubstrate(bob, superuser.address, 1n)).to.be.fulfilled;163 });163 });164164165 itSub.ifWithPallets('MM blocks scheduled calls and the scheduler itself', [Pallets.Scheduler], async ({helper}) => {165 itSched.ifWithPallets('MM blocks scheduled calls and the scheduler itself', [Pallets.Scheduler], async (scheduleKind, {helper}) => {166 const collection = await helper.nft.mintCollection(bob);166 const collection = await helper.nft.mintCollection(bob);167167168 const nftBeforeMM = await collection.mintToken(bob);168 const nftBeforeMM = await collection.mintToken(bob);175 scheduledIdBunkerThroughMM,175 scheduledIdBunkerThroughMM,176 scheduledIdAttemptDuringMM,176 scheduledIdAttemptDuringMM,177 scheduledIdAfterMM,177 scheduledIdAfterMM,178 ] = await helper.arrange.makeScheduledIds(5);178 ] = scheduleKind == 'named'179 ? helper.arrange.makeScheduledIds(5)180 : new Array(5);179181180 const blocksToWait = 6;182 const blocksToWait = 6;181183182 // Scheduling works before the maintenance184 // Scheduling works before the maintenance183 await nftBeforeMM.scheduleAfter(scheduledIdBeforeMM, blocksToWait)185 await nftBeforeMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdBeforeMM})184 .transfer(bob, {Substrate: superuser.address});186 .transfer(bob, {Substrate: superuser.address});185187186 await helper.wait.newBlocks(blocksToWait + 1);188 await helper.wait.newBlocks(blocksToWait + 1);187 expect(await nftBeforeMM.getOwner()).to.be.deep.equal({Substrate: superuser.address});189 expect(await nftBeforeMM.getOwner()).to.be.deep.equal({Substrate: superuser.address});188190189 // Schedule a transaction that should occur *during* the maintenance191 // Schedule a transaction that should occur *during* the maintenance190 await nftDuringMM.scheduleAfter(scheduledIdDuringMM, blocksToWait)192 await nftDuringMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdDuringMM})191 .transfer(bob, {Substrate: superuser.address});193 .transfer(bob, {Substrate: superuser.address});192 194 193 // Schedule a transaction that should occur *after* the maintenance195 // Schedule a transaction that should occur *after* the maintenance194 await nftDuringMM.scheduleAfter(scheduledIdBunkerThroughMM, blocksToWait * 2)196 await nftDuringMM.scheduleAfter(blocksToWait * 2, {scheduledId: scheduledIdBunkerThroughMM})195 .transfer(bob, {Substrate: superuser.address});197 .transfer(bob, {Substrate: superuser.address});196198197 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);199 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);202 expect(await nftDuringMM.getOwner()).to.be.deep.equal({Substrate: bob.address});204 expect(await nftDuringMM.getOwner()).to.be.deep.equal({Substrate: bob.address});203205204 // Any attempts to schedule a tx during the MM should be rejected206 // Any attempts to schedule a tx during the MM should be rejected205 await expect(nftDuringMM.scheduleAfter(scheduledIdAttemptDuringMM, blocksToWait)207 await expect(nftDuringMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdAttemptDuringMM})206 .transfer(bob, {Substrate: superuser.address}))208 .transfer(bob, {Substrate: superuser.address}))207 .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);209 .to.be.rejectedWith(/Invalid Transaction: Transaction call is not expected/);208210209 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);211 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.disable', []);210 expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;212 expect(await maintenanceEnabled(helper.getApi()), 'MM is ON when it should be OFF').to.be.false;211213212 // Scheduling works after the maintenance214 // Scheduling works after the maintenance213 await nftAfterMM.scheduleAfter(scheduledIdAfterMM, blocksToWait)215 await nftAfterMM.scheduleAfter(blocksToWait, {scheduledId: scheduledIdAfterMM})214 .transfer(bob, {Substrate: superuser.address});216 .transfer(bob, {Substrate: superuser.address});215 217 216 await helper.wait.newBlocks(blocksToWait + 1);218 await helper.wait.newBlocks(blocksToWait + 1);tests/src/scheduler.seqtest.tsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// 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/>.161617import {expect, itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds} from './util';17import {expect, itSched, itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds} from './util';18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {DevUniqueHelper} from './util/playgrounds/unique.dev';19import {DevUniqueHelper} from './util/playgrounds/unique.dev';202036 });36 });37 });37 });3839 beforeEach(async () => {40 await usingPlaygrounds(async (helper) => {41 await helper.wait.noScheduledTasks();42 });43 });384439 itSub('Can delay a transfer of an owned token', async ({helper}) => {45 itSched('Can delay a transfer of an owned token', async (scheduleKind, {helper}) => {40 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});46 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});41 const token = await collection.mintToken(alice);47 const token = await collection.mintToken(alice);42 const schedulerId = await helper.arrange.makeScheduledId();48 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;43 const blocksBeforeExecution = 4;49 const blocksBeforeExecution = 4;44 50 45 await token.scheduleAfter(schedulerId, blocksBeforeExecution)51 await token.scheduleAfter(blocksBeforeExecution, {scheduledId})46 .transfer(alice, {Substrate: bob.address});52 .transfer(alice, {Substrate: bob.address});47 const executionBlock = await helper.chain.getLatestBlockNumber() + blocksBeforeExecution + 1;53 const executionBlock = await helper.chain.getLatestBlockNumber() + blocksBeforeExecution + 1;485453 expect(await token.getOwner()).to.be.deep.equal({Substrate: bob.address});59 expect(await token.getOwner()).to.be.deep.equal({Substrate: bob.address});54 });60 });556156 itSub('Can transfer funds periodically', async ({helper}) => {62 itSched('Can transfer funds periodically', async (scheduleKind, {helper}) => {57 const scheduledId = await helper.arrange.makeScheduledId();63 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;58 const waitForBlocks = 1;64 const waitForBlocks = 1;596560 const amount = 1n * helper.balance.getOneTokenNominal();66 const amount = 1n * helper.balance.getOneTokenNominal();657166 const bobsBalanceBefore = await helper.balance.getSubstrate(bob.address);72 const bobsBalanceBefore = await helper.balance.getSubstrate(bob.address);677368 await helper.scheduler.scheduleAfter(scheduledId, waitForBlocks, {periodic})74 await helper.scheduler.scheduleAfter(waitForBlocks, {scheduledId, periodic})69 .balance.transferToSubstrate(alice, bob.address, amount);75 .balance.transferToSubstrate(alice, bob.address, amount);70 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;76 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;717792 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});98 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});93 const token = await collection.mintToken(alice);99 const token = await collection.mintToken(alice);9410095 const scheduledId = await helper.arrange.makeScheduledId();101 const scheduledId = helper.arrange.makeScheduledId();96 const waitForBlocks = 4;102 const waitForBlocks = 4;9710398 expect(await token.getOwner()).to.be.deep.equal({Substrate: alice.address});104 expect(await token.getOwner()).to.be.deep.equal({Substrate: alice.address});99105100 await token.scheduleAfter(scheduledId, waitForBlocks)106 await token.scheduleAfter(waitForBlocks, {scheduledId})101 .transfer(alice, {Substrate: bob.address});107 .transfer(alice, {Substrate: bob.address});102 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;108 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;103109115 repetitions: 2,121 repetitions: 2,116 };122 };117123118 const scheduledId = await helper.arrange.makeScheduledId();124 const scheduledId = helper.arrange.makeScheduledId();119125120 const amount = 1n * helper.balance.getOneTokenNominal();126 const amount = 1n * helper.balance.getOneTokenNominal();121127122 const bobsBalanceBefore = await helper.balance.getSubstrate(bob.address);128 const bobsBalanceBefore = await helper.balance.getSubstrate(bob.address);123129124 await helper.scheduler.scheduleAfter(scheduledId, waitForBlocks, {periodic})130 await helper.scheduler.scheduleAfter(waitForBlocks, {scheduledId, periodic})125 .balance.transferToSubstrate(alice, bob.address, amount);131 .balance.transferToSubstrate(alice, bob.address, amount);126 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;132 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;127133146 );152 );147 });153 });148154149 itSub('scheduler will not insert more tasks than allowed', async ({helper}) => {155 itSched('scheduler will not insert more tasks than allowed', async (scheduleKind, {helper}) => {150 const maxScheduledPerBlock = 50;156 const maxScheduledPerBlock = 50;157 let fillScheduledIds = new Array(maxScheduledPerBlock);158 let extraScheduledId = undefined;159 160 if (scheduleKind == 'named') {151 const scheduledIds = await helper.arrange.makeScheduledIds(maxScheduledPerBlock + 1);161 const scheduledIds = helper.arrange.makeScheduledIds(maxScheduledPerBlock + 1);152 const fillScheduledIds = scheduledIds.slice(0, maxScheduledPerBlock);162 fillScheduledIds = scheduledIds.slice(0, maxScheduledPerBlock);153 const extraScheduledId = scheduledIds[maxScheduledPerBlock];163 extraScheduledId = scheduledIds[maxScheduledPerBlock];164 }154165155 // Since the dev node has Instant Seal,166 // Since the dev node has Instant Seal,156 // we need a larger gap between the current block and the target one.167 // we need a larger gap between the current block and the target one.168179169 // Fill the target block180 // Fill the target block170 for (let i = 0; i < maxScheduledPerBlock; i++) {181 for (let i = 0; i < maxScheduledPerBlock; i++) {171 await helper.scheduler.scheduleAt(fillScheduledIds[i], executionBlock)182 await helper.scheduler.scheduleAt(executionBlock, {scheduledId: fillScheduledIds[i]})172 .balance.transferToSubstrate(superuser, bob.address, amount);183 .balance.transferToSubstrate(superuser, bob.address, amount);173 }184 }174185175 // Try to schedule a task into a full block186 // Try to schedule a task into a full block176 await expect(helper.scheduler.scheduleAt(extraScheduledId, executionBlock)187 await expect(helper.scheduler.scheduleAt(executionBlock, {scheduledId: extraScheduledId})177 .balance.transferToSubstrate(superuser, bob.address, amount))188 .balance.transferToSubstrate(superuser, bob.address, amount))178 .to.be.rejectedWith(/scheduler\.AgendaIsExhausted/);189 .to.be.rejectedWith(/scheduler\.AgendaIsExhausted/);179190187 expect(diff).to.be.equal(amount * BigInt(maxScheduledPerBlock));198 expect(diff).to.be.equal(amount * BigInt(maxScheduledPerBlock));188 });199 });189200190 itSub.ifWithPallets('Scheduled tasks are transactional', [Pallets.TestUtils], async ({helper}) => {201 itSched.ifWithPallets('Scheduled tasks are transactional', [Pallets.TestUtils], async (scheduleKind, {helper}) => {191 const scheduledId = await helper.arrange.makeScheduledId();202 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;192 const waitForBlocks = 4;203 const waitForBlocks = 4;193204194 const initTestVal = 42;205 const initTestVal = 42;195 const changedTestVal = 111;206 const changedTestVal = 111;196207197 await helper.testUtils.setTestValue(alice, initTestVal);208 await helper.testUtils.setTestValue(alice, initTestVal);198209199 await helper.scheduler.scheduleAfter<DevUniqueHelper>(scheduledId, waitForBlocks)210 await helper.scheduler.scheduleAfter<DevUniqueHelper>(waitForBlocks, {scheduledId})200 .testUtils.setTestValueAndRollback(alice, changedTestVal);211 .testUtils.setTestValueAndRollback(alice, changedTestVal);201 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;212 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;202213207 .to.be.equal(initTestVal);218 .to.be.equal(initTestVal);208 });219 });209220210 itSub.ifWithPallets('Scheduled tasks should take correct fees', [Pallets.TestUtils], async function({helper}) {221 itSched.ifWithPallets('Scheduled tasks should take correct fees', [Pallets.TestUtils], async function(scheduleKind, {helper}) {211 const scheduledId = await helper.arrange.makeScheduledId();222 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;212 const waitForBlocks = 4;223 const waitForBlocks = 4;213 const periodic = {224 const periodic = {214 period: 2,225 period: 2,221 const expectedScheduledFee = (await helper.getPaymentInfo(alice, dummyTx, scheduledLen))232 const expectedScheduledFee = (await helper.getPaymentInfo(alice, dummyTx, scheduledLen))222 .partialFee.toBigInt();233 .partialFee.toBigInt();223234224 await helper.scheduler.scheduleAfter<DevUniqueHelper>(scheduledId, waitForBlocks, {periodic})235 await helper.scheduler.scheduleAfter<DevUniqueHelper>(waitForBlocks, {scheduledId, periodic})225 .testUtils.justTakeFee(alice);236 .testUtils.justTakeFee(alice);226 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;237 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;227238267 const [278 const [268 scheduledId,279 scheduledId,269 scheduledCancelId,280 scheduledCancelId,270 ] = await helper.arrange.makeScheduledIds(2);281 ] = helper.arrange.makeScheduledIds(2);271282272 const periodic = {283 const periodic = {273 period: 5,284 period: 5,280291281 await helper.testUtils.setTestValue(alice, initTestVal);292 await helper.testUtils.setTestValue(alice, initTestVal);282293283 await helper.scheduler.scheduleAt<DevUniqueHelper>(scheduledId, firstExecutionBlockNumber, {periodic})294 await helper.scheduler.scheduleAt<DevUniqueHelper>(firstExecutionBlockNumber, {scheduledId, periodic})284 .testUtils.incTestValue(alice);295 .testUtils.incTestValue(alice);285296286 // Cancel the inc tx after 2 executions297 // Cancel the inc tx after 2 executions287 // *in the same block* in which the second execution is scheduled298 // *in the same block* in which the second execution is scheduled288 await helper.scheduler.scheduleAt(299 await helper.scheduler.scheduleAt(289 scheduledCancelId,290 firstExecutionBlockNumber + periodic.period,300 firstExecutionBlockNumber + periodic.period,301 {scheduledId: scheduledCancelId},291 ).scheduler.cancelScheduled(alice, scheduledId);302 ).scheduler.cancelScheduled(alice, scheduledId);292303293 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber);304 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber);310 });321 });311322312 itSub.ifWithPallets('A scheduled operation can cancel itself', [Pallets.TestUtils], async ({helper}) => {323 itSub.ifWithPallets('A scheduled operation can cancel itself', [Pallets.TestUtils], async ({helper}) => {313 const scheduledId = await helper.arrange.makeScheduledId();324 const scheduledId = helper.arrange.makeScheduledId();314 const waitForBlocks = 4;325 const waitForBlocks = 4;315 const periodic = {326 const periodic = {316 period: 2,327 period: 2,322333323 await helper.testUtils.setTestValue(alice, initTestVal);334 await helper.testUtils.setTestValue(alice, initTestVal);324335325 await helper.scheduler.scheduleAfter<DevUniqueHelper>(scheduledId, waitForBlocks, {periodic})336 await helper.scheduler.scheduleAfter<DevUniqueHelper>(waitForBlocks, {scheduledId, periodic})326 .testUtils.selfCancelingInc(alice, scheduledId, maxTestVal);337 .testUtils.selfCancelingInc(alice, scheduledId, maxTestVal);327 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;338 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;328339349 const collection = await helper.nft.mintCollection(bob, {tokenPrefix: 'schd'});360 const collection = await helper.nft.mintCollection(bob, {tokenPrefix: 'schd'});350 const token = await collection.mintToken(bob);361 const token = await collection.mintToken(bob);351362352 const scheduledId = await helper.arrange.makeScheduledId();363 const scheduledId = helper.arrange.makeScheduledId();353 const waitForBlocks = 4;364 const waitForBlocks = 4;354365355 await token.scheduleAfter(scheduledId, waitForBlocks)366 await token.scheduleAfter(waitForBlocks, {scheduledId})356 .transfer(bob, {Substrate: alice.address});367 .transfer(bob, {Substrate: alice.address});357 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;368 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;358369363 expect(await token.getOwner()).to.be.deep.equal({Substrate: bob.address});374 expect(await token.getOwner()).to.be.deep.equal({Substrate: bob.address});364 });375 });365376366 itSub('Root can set prioritized scheduled operation', async ({helper}) => {377 itSched('Root can set prioritized scheduled operation', async (scheduleKind, {helper}) => {367 const scheduledId = await helper.arrange.makeScheduledId();378 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;368 const waitForBlocks = 4;379 const waitForBlocks = 4;369380370 const amount = 42n * helper.balance.getOneTokenNominal();381 const amount = 42n * helper.balance.getOneTokenNominal();371382372 const balanceBefore = await helper.balance.getSubstrate(charlie.address);383 const balanceBefore = await helper.balance.getSubstrate(charlie.address);373384374 await helper.getSudo()385 await helper.getSudo()375 .scheduler.scheduleAfter(scheduledId, waitForBlocks, {priority: 42})386 .scheduler.scheduleAfter(waitForBlocks, {scheduledId, priority: 42})376 .balance.forceTransferToSubstrate(superuser, bob.address, charlie.address, amount);387 .balance.forceTransferToSubstrate(superuser, bob.address, charlie.address, amount);377 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;388 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;378389390 const collection = await helper.nft.mintCollection(bob, {tokenPrefix: 'schd'});401 const collection = await helper.nft.mintCollection(bob, {tokenPrefix: 'schd'});391 const token = await collection.mintToken(bob);402 const token = await collection.mintToken(bob);392403393 const scheduledId = await helper.arrange.makeScheduledId();404 const scheduledId = helper.arrange.makeScheduledId();394 const waitForBlocks = 6;405 const waitForBlocks = 6;395406396 await token.scheduleAfter(scheduledId, waitForBlocks)407 await token.scheduleAfter(waitForBlocks, {scheduledId})397 .transfer(bob, {Substrate: alice.address});408 .transfer(bob, {Substrate: alice.address});398 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;409 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;399410419 const [430 const [420 scheduledFirstId,431 scheduledFirstId,421 scheduledSecondId,432 scheduledSecondId,422 ] = await helper.arrange.makeScheduledIds(2);433 ] = helper.arrange.makeScheduledIds(2);423434424 const currentBlockNumber = await helper.chain.getLatestBlockNumber();435 const currentBlockNumber = await helper.chain.getLatestBlockNumber();425 const blocksBeforeExecution = 6;436 const blocksBeforeExecution = 6;436 const amount = 1n * helper.balance.getOneTokenNominal();447 const amount = 1n * helper.balance.getOneTokenNominal();437448438 // Scheduler a task with a lower priority first, then with a higher priority449 // Scheduler a task with a lower priority first, then with a higher priority439 await helper.getSudo().scheduler.scheduleAt(scheduledFirstId, firstExecutionBlockNumber, {priority: prioLow, periodic})450 await helper.getSudo().scheduler.scheduleAt(firstExecutionBlockNumber, {451 scheduledId: scheduledFirstId,452 priority: prioLow,453 periodic,440 .balance.forceTransferToSubstrate(superuser, alice.address, bob.address, amount);454 }).balance.forceTransferToSubstrate(superuser, alice.address, bob.address, amount);441455442 await helper.getSudo().scheduler.scheduleAt(scheduledSecondId, firstExecutionBlockNumber, {priority: prioHigh, periodic})456 await helper.getSudo().scheduler.scheduleAt(firstExecutionBlockNumber, {457 scheduledId: scheduledSecondId,458 priority: prioHigh,459 periodic,443 .balance.forceTransferToSubstrate(superuser, alice.address, bob.address, amount);460 }).balance.forceTransferToSubstrate(superuser, alice.address, bob.address, amount);444461445 const capture = await helper.arrange.captureEvents('scheduler', 'Dispatched');462 const capture = await helper.arrange.captureEvents('scheduler', 'Dispatched');467 expect(secondExecuctionIds[1]).to.be.equal(scheduledSecondId);484 expect(secondExecuctionIds[1]).to.be.equal(scheduledSecondId);468 });485 });469486470 itSub('Periodic operations always can be rescheduled', async ({helper}) => {487 itSched('Periodic operations always can be rescheduled', async (scheduleKind, {helper}) => {471 const maxScheduledPerBlock = 50;488 const maxScheduledPerBlock = 50;472 const numFilledBlocks = 3;489 const numFilledBlocks = 3;473 const ids = await helper.arrange.makeScheduledIds(numFilledBlocks * maxScheduledPerBlock + 1);490 const ids = helper.arrange.makeScheduledIds(numFilledBlocks * maxScheduledPerBlock + 1);474 const periodicId = ids[0];491 const periodicId = scheduleKind == 'named' ? ids[0] : undefined;475 const fillIds = ids.slice(1);492 const fillIds = ids.slice(1);493494 const fillScheduleFn = scheduleKind == 'named' ? 'scheduleNamed' : 'schedule';476495477 const initTestVal = 0;496 const initTestVal = 0;478 const firstExecTestVal = 1;497 const firstExecTestVal = 1;498 const scheduledTx = helper.constructApiCall('api.tx.balances.transfer', [bob.address, 1n]);517 const scheduledTx = helper.constructApiCall('api.tx.balances.transfer', [bob.address, 1n]);499518500 const when = firstExecutionBlockNumber + period + offset;519 const when = firstExecutionBlockNumber + period + offset;520 const mandatoryArgs = [when, null, null, scheduledTx];501 const tx = helper.constructApiCall('api.tx.scheduler.scheduleNamed', [fillIds[i + offset * maxScheduledPerBlock], 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);502526503 txs.push(tx);527 txs.push(tx);504 }528 }505 }529 }506 await helper.executeExtrinsic(alice, 'api.tx.testUtils.batchAll', [txs], true);530 await helper.executeExtrinsic(alice, 'api.tx.testUtils.batchAll', [txs], true);507531508 await helper.scheduler.scheduleAt<DevUniqueHelper>(periodicId, firstExecutionBlockNumber, {periodic})532 await helper.scheduler.scheduleAt<DevUniqueHelper>(firstExecutionBlockNumber, {533 scheduledId: periodicId,534 periodic,509 .testUtils.incTestValue(alice);535 }).testUtils.incTestValue(alice);510536511 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber);537 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber);522 expect(await helper.testUtils.testValue()).to.be.equal(secondExecTestVal);548 expect(await helper.testUtils.testValue()).to.be.equal(secondExecTestVal);523 });549 });524550525 itSub('scheduled operations does not change nonce', async ({helper}) => {551 itSched('scheduled operations does not change nonce', async (scheduleKind, {helper}) => {526 const scheduledId = await helper.arrange.makeScheduledId();552 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;527 const blocksBeforeExecution = 4;553 const blocksBeforeExecution = 4;528554529 await helper.scheduler555 await helper.scheduler530 .scheduleAfter<DevUniqueHelper>(scheduledId, blocksBeforeExecution)556 .scheduleAfter<DevUniqueHelper>(blocksBeforeExecution, {scheduledId})531 .balance.transferToSubstrate(alice, bob.address, 1n);557 .balance.transferToSubstrate(alice, bob.address, 1n);532 const executionBlock = await helper.chain.getLatestBlockNumber() + blocksBeforeExecution + 1;558 const executionBlock = await helper.chain.getLatestBlockNumber() + blocksBeforeExecution + 1;533559560 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});586 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});561 const token = await collection.mintToken(alice);587 const token = await collection.mintToken(alice);562588563 const scheduledId = await helper.arrange.makeScheduledId();589 const scheduledId = helper.arrange.makeScheduledId();564 const waitForBlocks = 4;590 const waitForBlocks = 4;565591566 await token.scheduleAfter(scheduledId, waitForBlocks)592 await token.scheduleAfter(waitForBlocks, {scheduledId})567 .transfer(alice, {Substrate: bob.address});593 .transfer(alice, {Substrate: bob.address});568 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;594 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;569595570 const scheduled = helper.scheduler.scheduleAfter(scheduledId, waitForBlocks);596 const scheduled = helper.scheduler.scheduleAfter(waitForBlocks, {scheduledId});571 await expect(scheduled.balance.transferToSubstrate(alice, bob.address, 1n * helper.balance.getOneTokenNominal()))597 await expect(scheduled.balance.transferToSubstrate(alice, bob.address, 1n * helper.balance.getOneTokenNominal()))572 .to.be.rejectedWith(/scheduler\.FailedToSchedule/);598 .to.be.rejectedWith(/scheduler\.FailedToSchedule/);573599582 });608 });583609584 itSub("Can't cancel an operation which is not scheduled", async ({helper}) => {610 itSub("Can't cancel an operation which is not scheduled", async ({helper}) => {585 const scheduledId = await helper.arrange.makeScheduledId();611 const scheduledId = helper.arrange.makeScheduledId();586 await expect(helper.scheduler.cancelScheduled(alice, scheduledId))612 await expect(helper.scheduler.cancelScheduled(alice, scheduledId))587 .to.be.rejectedWith(/scheduler\.NotFound/);613 .to.be.rejectedWith(/scheduler\.NotFound/);588 });614 });591 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});617 const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'schd'});592 const token = await collection.mintToken(alice);618 const token = await collection.mintToken(alice);593619594 const scheduledId = await helper.arrange.makeScheduledId();620 const scheduledId = helper.arrange.makeScheduledId();595 const waitForBlocks = 4;621 const waitForBlocks = 4;596622597 await token.scheduleAfter(scheduledId, waitForBlocks)623 await token.scheduleAfter(waitForBlocks, {scheduledId})598 .transfer(alice, {Substrate: bob.address});624 .transfer(alice, {Substrate: bob.address});599 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;625 const executionBlock = await helper.chain.getLatestBlockNumber() + waitForBlocks + 1;600626606 expect(await token.getOwner()).to.be.deep.equal({Substrate: bob.address});632 expect(await token.getOwner()).to.be.deep.equal({Substrate: bob.address});607 });633 });608634609 itSub("Regular user can't set prioritized scheduled operation", async ({helper}) => {635 itSched("Regular user can't set prioritized scheduled operation", async (scheduleKind, {helper}) => {610 const scheduledId = await helper.arrange.makeScheduledId();636 const scheduledId = scheduleKind == 'named' ? helper.arrange.makeScheduledId() : undefined;611 const waitForBlocks = 4;637 const waitForBlocks = 4;612638613 const amount = 42n * helper.balance.getOneTokenNominal();639 const amount = 42n * helper.balance.getOneTokenNominal();614640615 const balanceBefore = await helper.balance.getSubstrate(bob.address);641 const balanceBefore = await helper.balance.getSubstrate(bob.address);616642617 const scheduled = helper.scheduler.scheduleAfter(scheduledId, waitForBlocks, {priority: 42});643 const scheduled = helper.scheduler.scheduleAfter(waitForBlocks, {scheduledId, priority: 42});618 644 619 await expect(scheduled.balance.transferToSubstrate(alice, bob.address, amount))645 await expect(scheduled.balance.transferToSubstrate(alice, bob.address, amount))620 .to.be.rejectedWith(/BadOrigin/);646 .to.be.rejectedWith(/BadOrigin/);632 const collection = await helper.nft.mintCollection(bob, {tokenPrefix: 'schd'});658 const collection = await helper.nft.mintCollection(bob, {tokenPrefix: 'schd'});633 const token = await collection.mintToken(bob);659 const token = await collection.mintToken(bob);634660635 const scheduledId = await helper.arrange.makeScheduledId();661 const scheduledId = helper.arrange.makeScheduledId();636 const waitForBlocks = 4;662 const waitForBlocks = 4;637663638 await token.scheduleAfter(scheduledId, waitForBlocks)664 await token.scheduleAfter(waitForBlocks, {scheduledId})639 .transfer(bob, {Substrate: alice.address});665 .transfer(bob, {Substrate: alice.address});640666641 const priority = 112;667 const priority = 112;tests/src/util/index.tsdiffbeforeafterboth130itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});130itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});131itSub.ifWithPallets = itSubIfWithPallet;131itSub.ifWithPallets = itSubIfWithPallet;132133export type SchedKind = 'anon' | 'named';134135export function itSched(136 name: string,137 cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any,138 opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {},139) {140 itSub(name + ' (anonymous scheduling)', (apis) => cb('anon', apis), opts);141 itSub(name + ' (named scheduling)', (apis) => cb('named', apis), opts);142}143itSched.only = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {only: true});144itSched.skip = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {skip: true});145itSched.ifWithPallets = itSchedIfWithPallets;146147function itSchedIfWithPallets(name: string, required: string[], cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {148 return itSched(name, cb, {requiredPallets: required, ...opts});149}132150133export function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {151export function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {134 (process.env.RUN_XCM_TESTS && !opts.skip152 (process.env.RUN_XCM_TESTS && !opts.skiptests/src/util/playgrounds/types.tsdiffbeforeafterboth172}172}173173174export interface ISchedulerOptions {174export interface ISchedulerOptions {175 scheduledId?: string,175 priority?: number,176 priority?: number,176 periodic?: {177 periodic?: {177 period: number,178 period: number,tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth308 return encodeAddress(address);308 return encodeAddress(address);309 }309 }310310311 async makeScheduledIds(num: number): Promise<string[]> {311 makeScheduledIds(num: number): string[] {312 await this.helper.wait.noScheduledTasks();313314 function makeId(slider: number) {312 function makeId(slider: number) {315 const scheduledIdSize = 64;313 const scheduledIdSize = 64;330 return ids;328 return ids;331 }329 }332330333 async makeScheduledId(): Promise<string> {331 makeScheduledId(): string {334 return (await this.makeScheduledIds(1))[0];332 return (this.makeScheduledIds(1))[0];335 }333 }336334337 async captureEvents(eventSection: string, eventMethod: string): Promise<EventCapture> {335 async captureEvents(eventSection: string, eventMethod: string): Promise<EventCapture> {tests/src/util/playgrounds/unique.tsdiffbeforeafterboth2560 }2560 }256125612562 scheduleAt<T extends UniqueHelper>(2562 scheduleAt<T extends UniqueHelper>(2563 scheduledId: string,2564 executionBlockNumber: number,2563 executionBlockNumber: number,2565 options: ISchedulerOptions = {},2564 options: ISchedulerOptions = {},2566 ) {2565 ) {2567 return this.schedule<T>('scheduleNamed', scheduledId, executionBlockNumber, options);2566 return this.schedule<T>('schedule', executionBlockNumber, options);2568 }2567 }256925682570 scheduleAfter<T extends UniqueHelper>(2569 scheduleAfter<T extends UniqueHelper>(2571 scheduledId: string,2572 blocksBeforeExecution: number,2570 blocksBeforeExecution: number,2573 options: ISchedulerOptions = {},2571 options: ISchedulerOptions = {},2574 ) {2572 ) {2575 return this.schedule<T>('scheduleNamedAfter', scheduledId, blocksBeforeExecution, options);2573 return this.schedule<T>('scheduleAfter', blocksBeforeExecution, options);2576 }2574 }257725752578 schedule<T extends UniqueHelper>(2576 schedule<T extends UniqueHelper>(2579 scheduleFn: 'scheduleNamed' | 'scheduleNamedAfter',2577 scheduleFn: 'schedule' | 'scheduleAfter',2580 scheduledId: string,2581 blocksNum: number,2578 blocksNum: number,2582 options: ISchedulerOptions = {},2579 options: ISchedulerOptions = {},2583 ) {2580 ) {2584 // eslint-disable-next-line @typescript-eslint/naming-convention2581 // eslint-disable-next-line @typescript-eslint/naming-convention2585 const ScheduledHelperType = ScheduledUniqueHelper(this.helper.helperBase);2582 const ScheduledHelperType = ScheduledUniqueHelper(this.helper.helperBase);2586 return this.helper.clone(ScheduledHelperType, {2583 return this.helper.clone(ScheduledHelperType, {2587 scheduleFn,2584 scheduleFn,2588 scheduledId,2589 blocksNum,2585 blocksNum,2590 options,2586 options,2591 }) as T;2587 }) as T;2874// eslint-disable-next-line @typescript-eslint/naming-convention2870// eslint-disable-next-line @typescript-eslint/naming-convention2875function ScheduledUniqueHelper<T extends UniqueHelperConstructor>(Base: T) {2871function ScheduledUniqueHelper<T extends UniqueHelperConstructor>(Base: T) {2876 return class extends Base {2872 return class extends Base {2877 scheduleFn: 'scheduleNamed' | 'scheduleNamedAfter';2873 scheduleFn: 'schedule' | 'scheduleAfter';2878 scheduledId: string;2879 blocksNum: number;2874 blocksNum: number;2880 options: ISchedulerOptions;2875 options: ISchedulerOptions;288128762882 constructor(...args: any[]) {2877 constructor(...args: any[]) {2883 const logger = args[0] as ILogger;2878 const logger = args[0] as ILogger;2884 const options = args[1] as {2879 const options = args[1] as {2885 scheduleFn: 'scheduleNamed' | 'scheduleNamedAfter',2880 scheduleFn: 'schedule' | 'scheduleAfter',2886 scheduledId: string,2887 blocksNum: number,2881 blocksNum: number,2888 options: ISchedulerOptions2882 options: ISchedulerOptions2889 };2883 };289028842891 super(logger);2885 super(logger);289228862893 this.scheduleFn = options.scheduleFn;2887 this.scheduleFn = options.scheduleFn;2894 this.scheduledId = options.scheduledId;2895 this.blocksNum = options.blocksNum;2888 this.blocksNum = options.blocksNum;2896 this.options = options.options;2889 this.options = options.options;2897 }2890 }289828912899 executeExtrinsic(sender: IKeyringPair, scheduledExtrinsic: string, scheduledParams: any[], expectSuccess?: boolean): Promise<ITransactionResult> {2892 executeExtrinsic(sender: IKeyringPair, scheduledExtrinsic: string, scheduledParams: any[], expectSuccess?: boolean): Promise<ITransactionResult> {2900 const scheduledTx = this.constructApiCall(scheduledExtrinsic, scheduledParams);2893 const scheduledTx = this.constructApiCall(scheduledExtrinsic, scheduledParams);2894 2901 const extrinsic = 'api.tx.scheduler.' + this.scheduleFn;2895 const mandatorySchedArgs = [29022903 return super.executeExtrinsic(2904 sender,2905 extrinsic,2906 [2907 this.scheduledId,2908 this.blocksNum,2896 this.blocksNum,2909 this.options.periodic ? [this.options.periodic.period, this.options.periodic.repetitions] : null,2897 this.options.periodic ? [this.options.periodic.period, this.options.periodic.repetitions] : null,2910 this.options.priority ?? null,2898 this.options.priority ?? null,2911 scheduledTx,2899 scheduledTx,2912 ],2900 ];2913 expectSuccess,2901 2914 );2902 let schedArgs;2903 let scheduleFn;29042905 if (this.options.scheduledId) {2906 schedArgs = [this.options.scheduledId!, ...mandatorySchedArgs];29072908 if (this.scheduleFn == 'schedule') {2909 scheduleFn = 'scheduleNamed';2910 } else if (this.scheduleFn == 'scheduleAfter') {2911 scheduleFn = 'scheduleNamedAfter';2912 }2913 } else {2914 schedArgs = mandatorySchedArgs;2915 scheduleFn = this.scheduleFn;2916 }29172918 const extrinsic = 'api.tx.scheduler.' + scheduleFn;29192920 return super.executeExtrinsic(2921 sender,2922 extrinsic,2923 schedArgs,2924 expectSuccess,2925 );2915 }2926 }2916 };2927 };2917}2928}3046 }3057 }304730583048 scheduleAt<T extends UniqueHelper>(3059 scheduleAt<T extends UniqueHelper>(3049 scheduledId: string,3050 executionBlockNumber: number,3060 executionBlockNumber: number,3051 options: ISchedulerOptions = {},3061 options: ISchedulerOptions = {},3052 ) {3062 ) {3053 const scheduledHelper = this.helper.scheduler.scheduleAt<T>(scheduledId, executionBlockNumber, options);3063 const scheduledHelper = this.helper.scheduler.scheduleAt<T>(executionBlockNumber, options);3054 return new UniqueBaseCollection(this.collectionId, scheduledHelper);3064 return new UniqueBaseCollection(this.collectionId, scheduledHelper);3055 }3065 }305630663057 scheduleAfter<T extends UniqueHelper>(3067 scheduleAfter<T extends UniqueHelper>(3058 scheduledId: string,3059 blocksBeforeExecution: number,3068 blocksBeforeExecution: number,3060 options: ISchedulerOptions = {},3069 options: ISchedulerOptions = {},3061 ) {3070 ) {3062 const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);3071 const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(blocksBeforeExecution, options);3063 return new UniqueBaseCollection(this.collectionId, scheduledHelper);3072 return new UniqueBaseCollection(this.collectionId, scheduledHelper);3064 }3073 }306530743155 }3164 }315631653157 scheduleAt<T extends UniqueHelper>(3166 scheduleAt<T extends UniqueHelper>(3158 scheduledId: string,3159 executionBlockNumber: number,3167 executionBlockNumber: number,3160 options: ISchedulerOptions = {},3168 options: ISchedulerOptions = {},3161 ) {3169 ) {3162 const scheduledHelper = this.helper.scheduler.scheduleAt<T>(scheduledId, executionBlockNumber, options);3170 const scheduledHelper = this.helper.scheduler.scheduleAt<T>(executionBlockNumber, options);3163 return new UniqueNFTCollection(this.collectionId, scheduledHelper);3171 return new UniqueNFTCollection(this.collectionId, scheduledHelper);3164 }3172 }316531733166 scheduleAfter<T extends UniqueHelper>(3174 scheduleAfter<T extends UniqueHelper>(3167 scheduledId: string,3168 blocksBeforeExecution: number,3175 blocksBeforeExecution: number,3169 options: ISchedulerOptions = {},3176 options: ISchedulerOptions = {},3170 ) {3177 ) {3171 const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);3178 const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(blocksBeforeExecution, options);3172 return new UniqueNFTCollection(this.collectionId, scheduledHelper);3179 return new UniqueNFTCollection(this.collectionId, scheduledHelper);3173 }3180 }317431813260 }3267 }326132683262 scheduleAt<T extends UniqueHelper>(3269 scheduleAt<T extends UniqueHelper>(3263 scheduledId: string,3264 executionBlockNumber: number,3270 executionBlockNumber: number,3265 options: ISchedulerOptions = {},3271 options: ISchedulerOptions = {},3266 ) {3272 ) {3267 const scheduledHelper = this.helper.scheduler.scheduleAt<T>(scheduledId, executionBlockNumber, options);3273 const scheduledHelper = this.helper.scheduler.scheduleAt<T>(executionBlockNumber, options);3268 return new UniqueRFTCollection(this.collectionId, scheduledHelper);3274 return new UniqueRFTCollection(this.collectionId, scheduledHelper);3269 }3275 }327032763271 scheduleAfter<T extends UniqueHelper>(3277 scheduleAfter<T extends UniqueHelper>(3272 scheduledId: string,3273 blocksBeforeExecution: number,3278 blocksBeforeExecution: number,3274 options: ISchedulerOptions = {},3279 options: ISchedulerOptions = {},3275 ) {3280 ) {3276 const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);3281 const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(blocksBeforeExecution, options);3277 return new UniqueRFTCollection(this.collectionId, scheduledHelper);3282 return new UniqueRFTCollection(this.collectionId, scheduledHelper);3278 }3283 }327932843329 }3334 }333033353331 scheduleAt<T extends UniqueHelper>(3336 scheduleAt<T extends UniqueHelper>(3332 scheduledId: string,3333 executionBlockNumber: number,3337 executionBlockNumber: number,3334 options: ISchedulerOptions = {},3338 options: ISchedulerOptions = {},3335 ) {3339 ) {3336 const scheduledHelper = this.helper.scheduler.scheduleAt<T>(scheduledId, executionBlockNumber, options);3340 const scheduledHelper = this.helper.scheduler.scheduleAt<T>(executionBlockNumber, options);3337 return new UniqueFTCollection(this.collectionId, scheduledHelper);3341 return new UniqueFTCollection(this.collectionId, scheduledHelper);3338 }3342 }333933433340 scheduleAfter<T extends UniqueHelper>(3344 scheduleAfter<T extends UniqueHelper>(3341 scheduledId: string,3342 blocksBeforeExecution: number,3345 blocksBeforeExecution: number,3343 options: ISchedulerOptions = {},3346 options: ISchedulerOptions = {},3344 ) {3347 ) {3345 const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);3348 const scheduledHelper = this.helper.scheduler.scheduleAfter<T>(blocksBeforeExecution, options);3346 return new UniqueFTCollection(this.collectionId, scheduledHelper);3349 return new UniqueFTCollection(this.collectionId, scheduledHelper);3347 }3350 }334833513388 }3391 }338933923390 scheduleAt<T extends UniqueHelper>(3393 scheduleAt<T extends UniqueHelper>(3391 scheduledId: string,3392 executionBlockNumber: number,3394 executionBlockNumber: number,3393 options: ISchedulerOptions = {},3395 options: ISchedulerOptions = {},3394 ) {3396 ) {3395 const scheduledCollection = this.collection.scheduleAt<T>(scheduledId, executionBlockNumber, options);3397 const scheduledCollection = this.collection.scheduleAt<T>(executionBlockNumber, options);3396 return new UniqueBaseToken(this.tokenId, scheduledCollection);3398 return new UniqueBaseToken(this.tokenId, scheduledCollection);3397 }3399 }339834003399 scheduleAfter<T extends UniqueHelper>(3401 scheduleAfter<T extends UniqueHelper>(3400 scheduledId: string,3401 blocksBeforeExecution: number,3402 blocksBeforeExecution: number,3402 options: ISchedulerOptions = {},3403 options: ISchedulerOptions = {},3403 ) {3404 ) {3404 const scheduledCollection = this.collection.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);3405 const scheduledCollection = this.collection.scheduleAfter<T>(blocksBeforeExecution, options);3405 return new UniqueBaseToken(this.tokenId, scheduledCollection);3406 return new UniqueBaseToken(this.tokenId, scheduledCollection);3406 }3407 }340734083468 }3469 }346934703470 scheduleAt<T extends UniqueHelper>(3471 scheduleAt<T extends UniqueHelper>(3471 scheduledId: string,3472 executionBlockNumber: number,3472 executionBlockNumber: number,3473 options: ISchedulerOptions = {},3473 options: ISchedulerOptions = {},3474 ) {3474 ) {3475 const scheduledCollection = this.collection.scheduleAt<T>(scheduledId, executionBlockNumber, options);3475 const scheduledCollection = this.collection.scheduleAt<T>(executionBlockNumber, options);3476 return new UniqueNFToken(this.tokenId, scheduledCollection);3476 return new UniqueNFToken(this.tokenId, scheduledCollection);3477 }3477 }347834783479 scheduleAfter<T extends UniqueHelper>(3479 scheduleAfter<T extends UniqueHelper>(3480 scheduledId: string,3481 blocksBeforeExecution: number,3480 blocksBeforeExecution: number,3482 options: ISchedulerOptions = {},3481 options: ISchedulerOptions = {},3483 ) {3482 ) {3484 const scheduledCollection = this.collection.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);3483 const scheduledCollection = this.collection.scheduleAfter<T>(blocksBeforeExecution, options);3485 return new UniqueNFToken(this.tokenId, scheduledCollection);3484 return new UniqueNFToken(this.tokenId, scheduledCollection);3486 }3485 }348734863543 }3542 }354435433545 scheduleAt<T extends UniqueHelper>(3544 scheduleAt<T extends UniqueHelper>(3546 scheduledId: string,3547 executionBlockNumber: number,3545 executionBlockNumber: number,3548 options: ISchedulerOptions = {},3546 options: ISchedulerOptions = {},3549 ) {3547 ) {3550 const scheduledCollection = this.collection.scheduleAt<T>(scheduledId, executionBlockNumber, options);3548 const scheduledCollection = this.collection.scheduleAt<T>(executionBlockNumber, options);3551 return new UniqueRFToken(this.tokenId, scheduledCollection);3549 return new UniqueRFToken(this.tokenId, scheduledCollection);3552 }3550 }355335513554 scheduleAfter<T extends UniqueHelper>(3552 scheduleAfter<T extends UniqueHelper>(3555 scheduledId: string,3556 blocksBeforeExecution: number,3553 blocksBeforeExecution: number,3557 options: ISchedulerOptions = {},3554 options: ISchedulerOptions = {},3558 ) {3555 ) {3559 const scheduledCollection = this.collection.scheduleAfter<T>(scheduledId, blocksBeforeExecution, options);3556 const scheduledCollection = this.collection.scheduleAfter<T>(blocksBeforeExecution, options);3560 return new UniqueRFToken(this.tokenId, scheduledCollection);3557 return new UniqueRFToken(this.tokenId, scheduledCollection);3561 }3558 }35623559