diff --git a/app/agents/AbstractAgent.ts b/app/agents/AbstractAgent.ts index 7e02bbf..1b82e9a 100644 --- a/app/agents/AbstractAgent.ts +++ b/app/agents/AbstractAgent.ts @@ -379,7 +379,7 @@ export abstract class AbstractAgent implements IAgent { * @private */ private async resyncAllJobs(): Promise { - const latestBock = await this.network.getLatestBlockNumber(); + const latestBock = this.network.getLatestBlockNumber(); // 1. init jobs let newJobs = new Map(); newJobs = await this.dataSource.getRegisteredJobs(this); @@ -543,7 +543,6 @@ export abstract class AbstractAgent implements IAgent { const job = this.jobs.get(jobKey); job.applyJobCreditsDeposit(BigNumber.from(amount)); - job.finalizeInitialization(); job.watch(); }); @@ -573,7 +572,6 @@ export abstract class AbstractAgent implements IAgent { if (this.ownerJobs.has(jobOwner)) { for (const jobKey of this.ownerJobs.get(jobOwner)) { - this.jobs.get(jobKey).finalizeInitialization(); this.jobs.get(jobKey).watch(); } } @@ -628,6 +626,18 @@ export abstract class AbstractAgent implements IAgent { job.watch(); }); + this.contract.on('SetJobPreDefinedCalldata', event => { + const { jobKey, preDefinedCalldata } = event.args; + + this.clog( + `'SetJobPreDefinedCalldata' event: (block=${event.blockNumber},jobKey=${jobKey},preDefinedCalldata=${preDefinedCalldata})`, + ); + + const job = this.jobs.get(jobKey); + job.applyPreDefinedCalldata(preDefinedCalldata); + job.watch(); + }); + this.contract.on('SetJobResolver', event => { const { jobKey, resolverAddress, resolverCalldata } = event.args; diff --git a/app/agents/Agent.2.3.0.randao.ts b/app/agents/Agent.2.3.0.randao.ts index 832ed5b..c04b496 100644 --- a/app/agents/Agent.2.3.0.randao.ts +++ b/app/agents/Agent.2.3.0.randao.ts @@ -223,6 +223,7 @@ export class AgentRandao_2_3_0 extends AbstractAgent implements IRandaoAgent { this.clog('Updating binJob to', binJob); job.applyBinJobData(binJob); } + job.finalizeInitialization(); job.watch(); }); diff --git a/app/jobs/AbstractJob.ts b/app/jobs/AbstractJob.ts index c7d4fb9..3e22bcc 100644 --- a/app/jobs/AbstractJob.ts +++ b/app/jobs/AbstractJob.ts @@ -61,6 +61,7 @@ export abstract class AbstractJob { protected config: ParsedJobConfig; private jobLevelMinKeeperCvp: BigNumber; protected resolver: Resolver; + protected preDefinedCalldata: string; private averageBlockTimeSeconds: number; private network: Network; @@ -175,6 +176,7 @@ export abstract class AbstractJob { public applyJob(job: GetJobResponse): boolean { this.resolver = { resolverAddress: job.resolver.resolverAddress, resolverCalldata: job.resolver.resolverCalldata }; + this.preDefinedCalldata = job.preDefinedCalldata; if (typeof job.details !== 'object') { throw this.err(`applyJob(): job.details is not an object: ${job.details}`); @@ -255,6 +257,10 @@ export abstract class AbstractJob { this.resolver = { resolverAddress, resolverCalldata }; } + public applyPreDefinedCalldata(preDefinedCalldata: string) { + this.preDefinedCalldata = preDefinedCalldata; + } + public applyConfig(isActive: boolean, useJobOwnerCredits: boolean, assertResolverSelector: boolean) { this.config.isActive = isActive; this.config.useJobOwnerCredits = useJobOwnerCredits;