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[]>


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[]>


post()

ts
post(params): Promise<
  | AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []>
| ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>>;

Post a new job to the marketplace (can list or assign based on params)

Parameters

ParameterType
params| AssignParams | ListParams

Returns

Promise< | AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []> | ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>>


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
assignAssignAssign a job directly to a host node
closeCloseClose a market
closeMarketCloseClose a market (synonym for close)
completeCompletePost the result for a JobAccount to finish it and get paid.
createMarketOpenCreate a new market (synonym for open)
delistDelistDelist a job from the marketplace
endEndStop a running job
extendExtendExtend an existing job's timeout
finishFinishComplete a job that has been stopped.
listListList a new job to the marketplace
openOpenCreate a new market
quitQuitQuit a JobAccount that you have started.
stopStopExit the node queue
workWorkEnters the MarketAccount queue, or create a RunAccount.