Skip to content

Interface: JobsProgram

Jobs program interface

Methods

all()

ts
all(filters?, checkRuns?): Promise<Job[]>;

Fetch all job accounts

Parameters

ParameterType
filters?{ market?: Address; node?: Address; project?: Address; state?: JobState; }
filters.market?Address
filters.node?Address
filters.project?Address
filters.state?JobState
checkRuns?boolean

Returns

Promise<Job[]>


end()

ts
end(params): Promise<EndInstruction<Address, string, string, string, string, string, string, string, string, string, []>>;

Stop a running job

Parameters

ParameterType
params{ job: Address; }
params.jobAddress

Returns

Promise<EndInstruction<Address, string, string, string, string, string, string, string, string, string, []>>


get()

ts
get(addr, checkRun?): Promise<Job>;

Fetch a job account by address

Parameters

ParameterType
addrAddress
checkRun?boolean

Returns

Promise<Job>


market()

ts
market(addr): Promise<Market>;

Fetch a market account by address

Parameters

ParameterType
addrAddress

Returns

Promise<Market>


markets()

ts
markets(): Promise<Market[]>;

Fetch all market accounts

Returns

Promise<Market[]>


monitor()

ts
monitor(): Promise<[AsyncIterable<SimpleMonitorEvent, any, any>, () => void]>;

Monitor program account updates using async iterators. Automatically merges run account data into job account updates. Returns a tuple of [eventStream, stopFunction].

Returns

Promise<[AsyncIterable<SimpleMonitorEvent, any, any>, () => void]>

Example

typescript
const [eventStream, stop] = await jobsProgram.monitor();
for await (const event of eventStream) {
  if (event.type === MonitorEventType.JOB) {
    console.log('Job updated:', event.data.address);
  } else if (event.type === MonitorEventType.MARKET) {
    console.log('Market updated:', event.data.address);
  }
}

monitorDetailed()

ts
monitorDetailed(): Promise<[AsyncIterable<MonitorEvent, any, any>, () => void]>;

Monitor program account updates with detailed events for each account type. Provides separate events for job, market, and run accounts. Returns a tuple of [eventStream, stopFunction].

Returns

Promise<[AsyncIterable<MonitorEvent, any, any>, () => void]>

Example

typescript
const [eventStream, stop] = await jobsProgram.monitorDetailed();
for await (const event of eventStream) {
  switch (event.type) {
    case MonitorEventType.JOB:
      console.log('Job updated:', event.data.address);
      break;
    case MonitorEventType.MARKET:
      console.log('Market updated:', event.data.address);
      break;
    case MonitorEventType.RUN:
      console.log('Run updated:', event.data.address);
      break;
  }
}

multiple()

ts
multiple(addresses, checkRuns?): Promise<Job[]>;

Fetch multiple job accounts by address

Parameters

ParameterType
addressesAddress[]
checkRuns?boolean

Returns

Promise<Job[]>


run()

ts
run(addr): Promise<Run>;

Fetch a run account by address

Parameters

ParameterType
addrAddress

Returns

Promise<Run>


runs()

ts
runs(filters?): Promise<Run[]>;

Fetch all run accounts

Parameters

ParameterType
filters?{ job?: Address; node?: Address; }
filters.job?Address
filters.node?Address

Returns

Promise<Run[]>

Properties

PropertyTypeDescription
delistDelistDelist a job from the marketplace
extendExtendExtend an existing job's timeout
postPostPost a new job to the marketplace