Interface: JobsProgram
Jobs program interface
Methods
all()
all(filters?, checkRuns?): Promise<Job[]>;Fetch all job accounts
Parameters
| Parameter | Type |
|---|---|
filters? | { market?: Address; node?: Address; project?: Address; state?: JobState; } |
filters.market? | Address |
filters.node? | Address |
filters.project? | Address |
filters.state? | JobState |
checkRuns? | boolean |
Returns
end()
end(params): Promise<EndInstruction<Address, string, string, string, string, string, string, string, string, string, []>>;Stop a running job
Parameters
| Parameter | Type |
|---|---|
params | { job: Address; } |
params.job | Address |
Returns
Promise<EndInstruction<Address, string, string, string, string, string, string, string, string, string, []>>
get()
get(addr, checkRun?): Promise<Job>;Fetch a job account by address
Parameters
| Parameter | Type |
|---|---|
addr | Address |
checkRun? | boolean |
Returns
market()
market(addr): Promise<Market>;Fetch a market account by address
Parameters
| Parameter | Type |
|---|---|
addr | Address |
Returns
markets()
markets(): Promise<Market[]>;Fetch all market accounts
Returns
monitor()
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
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()
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
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()
multiple(addresses, checkRuns?): Promise<Job[]>;Fetch multiple job accounts by address
Parameters
| Parameter | Type |
|---|---|
addresses | Address[] |
checkRuns? | boolean |
Returns
run()
run(addr): Promise<Run>;Fetch a run account by address
Parameters
| Parameter | Type |
|---|---|
addr | Address |
Returns
runs()
runs(filters?): Promise<Run[]>;Fetch all run accounts
Parameters
| Parameter | Type |
|---|---|
filters? | { job?: Address; node?: Address; } |
filters.job? | Address |
filters.node? | Address |
Returns
Properties
| Property | Type | Description |
|---|---|---|
delist | Delist | Delist a job from the marketplace |
extend | Extend | Extend an existing job's timeout |
post | Post | Post a new job to the marketplace |