Skip to content

Latest commit

 

History

History
414 lines (235 loc) · 9.73 KB

File metadata and controls

414 lines (235 loc) · 9.73 KB

iexec


iexec / IExecDealModule

Class: IExecDealModule

module exposing deal methods

Extends

Constructors

Constructor

new IExecDealModule(configOrArgs, options?): IExecDealModule

Create an IExecModule instance

Parameters

configOrArgs

IExecConfigArgs | IExecConfig

options?

IExecConfigOptions

Returns

IExecDealModule

Inherited from

IExecModule.constructor

Properties

config

config: IExecConfig

current IExecConfig

Inherited from

IExecModule.config

Methods

claim()

claim(dealid): Promise<{ claimed: Record<TaskIndex, Taskid>; transactions: object[]; }>

SIGNER REQUIRED

claim all the failed task from a deal

depending the number and the status of task to claim, this may involve several transactions in order to fit in the blockchain gasLimit per block. (for example a 10_000_000 gas block size allows to claim 180 initialized task or 40 non-initialized tasks in one block)

example:

const { claimed, transactions } = await claim(dealid);
console.log(`transaction count ${transactions.length}`);
Object.entries(claimed).forEach(([idx, taskid]) => {
 console.log(`claimed task: idx ${idx} taskid ${taskid}`);
});

Parameters

dealid

string

Returns

Promise<{ claimed: Record<TaskIndex, Taskid>; transactions: object[]; }>


computeTaskId()

computeTaskId(dealid, taskIdx): Promise<string>

compute the taskid of the task at specified index of specified deal.

example:

const taskid = await computeTaskId('0x4246d0ddf4c4c728cedd850890ee9a6781a88e5d3c46098c0774af3b7963879b', 0);
console.log('taskid:', taskid)

Parameters

dealid

string

taskIdx

BNish

Returns

Promise<string>


fetchDealsByApporder()

fetchDealsByApporder(apporderHash, options?): Promise<PaginableDeals>

fetch the latest deals sealed with a specified apporder.

NB: this method can return a subset of the complete result set, in this case, a more() method is also returned and enable getting the next subset.

example:

const { deals, count } = await fetchDealsByApporder('0x7fbbbf7ab1c4571111db8d4e3f7ba3fe29c1eb916453f9fbdce4b426e05cbbfb');
console.log('deals count:', count);
console.log('last deal:', deals[0]);

Parameters

apporderHash

string

options?
page?

number

index of the page to fetch

pageSize?

number

size of the page to fetch

Returns

Promise<PaginableDeals>


fetchDealsByDatasetorder()

fetchDealsByDatasetorder(datasetorderHash, options?): Promise<PaginableDeals>

fetch the latest deals sealed with a specified datasetorder.

NB: this method can return a subset of the complete result set, in this case, a more() method is also returned and enable getting the next subset.

example:

const { deals, count } = await fetchDealsByDatasetorder('0x60a810f4876fc9173bac74f7cff3c4cdc86f4aff66a72c2011f6e33e0dc8d3d0');
console.log('deals count:', count);
console.log('last deal:', deals[0]);

Parameters

datasetorderHash

string

options?
page?

number

index of the page to fetch

pageSize?

number

size of the page to fetch

Returns

Promise<PaginableDeals>


fetchDealsByRequestorder()

fetchDealsByRequestorder(requestorderHash, options?): Promise<PaginableDeals>

fetch the latest deals sealed with a specified requestorder.

NB: this method can return a subset of the complete result set, in this case, a more() method is also returned and enable getting the next subset.

example:

const { deals, count } = await fetchDealsByRequestorder('0x5de0bc9e5604685e96e4031e3815dac55648254fd7b033b59b78c49de8b384b0');
console.log('deals count:', count);
console.log('last deal:', deals[0]);

Parameters

requestorderHash

string

options?
page?

number

index of the page to fetch

pageSize?

number

size of the page to fetch

Returns

Promise<PaginableDeals>


fetchDealsByWorkerpoolorder()

fetchDealsByWorkerpoolorder(workerpoolorderHash, options?): Promise<PaginableDeals>

fetch the latest deals sealed with a specified workerpoolorder.

NB: this method can return a subset of the complete result set, in this case, a more() method is also returned and enable getting the next subset.

example:

const { deals, count } = await fetchDealsByWorkerpoolorder('0x2887965ec57500471593852e10e97e9e99ea81a9a0402be68a24683d6cd2b697');
console.log('deals count:', count);
console.log('last deal:', deals[0]);

Parameters

workerpoolorderHash

string

options?
page?

number

index of the page to fetch

pageSize?

number

size of the page to fetch

Returns

Promise<PaginableDeals>


fetchRequesterDeals()

fetchRequesterDeals(requesterAddress, options?): Promise<PaginableDeals>

fetch the latest deals of the requester optionally filtered by specified filters.

NB: this method can return a subset of the complete result set, in this case, a more() method is also returned and enable getting the next subset.

example:

const { deals, count } = await fetchRequesterDeals(userAddress);
console.log('deals count:', count);
console.log('last deal:', deals[0]);

Parameters

requesterAddress

string

options?
appAddress?

string

filter by app

datasetAddress?

string

filter by dataset

page?

number

index of the page to fetch

pageSize?

number

size of the page to fetch

workerpoolAddress?

string

filter by workerpool

Returns

Promise<PaginableDeals>


obsDeal()

obsDeal(dealid): Promise<DealObservable>

return an Observable with a subscribe method to monitor the deal status changes.

example:

const dealObservable = await obsDeal('0x4246d0ddf4c4c728cedd850890ee9a6781a88e5d3c46098c0774af3b7963879b');
const unsubscribe = dealObservable.subscribe({
 next: (data) =>
   console.log(
     data.message,
     `completed tasks ${data.completedTasksCount}/${data.tasksCount}`,
   ),
 error: (e) => console.error(e),
 complete: () => console.log('final state reached'),
});
// call unsubscribe() to unsubscribe from dealObservable

Parameters

dealid

string

Returns

Promise<DealObservable>


show()

show(dealid): Promise<{ app: { owner: string; pointer: string; price: BN; }; beneficiary: string; botFirst: BN; botSize: BN; callback: string; category: BN; dataset: { owner: string; pointer: string; price: BN; }; deadlineReached: boolean; dealid: string; finalTime: BN; params: string; requester: string; schedulerRewardRatio: BN; startTime: BN; tag: string; tasks: Record<TaskIndex, Taskid>; trust: BN; workerpool: { owner: string; pointer: string; price: BN; }; workerStake: BN; }>

show the details of a deal.

example:

const deal = await show(
 '0x4246d0ddf4c4c728cedd850890ee9a6781a88e5d3c46098c0774af3b7963879b',
);
console.log('deal:', deal);

Parameters

dealid

string

Returns

Promise<{ app: { owner: string; pointer: string; price: BN; }; beneficiary: string; botFirst: BN; botSize: BN; callback: string; category: BN; dataset: { owner: string; pointer: string; price: BN; }; deadlineReached: boolean; dealid: string; finalTime: BN; params: string; requester: string; schedulerRewardRatio: BN; startTime: BN; tag: string; tasks: Record<TaskIndex, Taskid>; trust: BN; workerpool: { owner: string; pointer: string; price: BN; }; workerStake: BN; }>


fromConfig()

static fromConfig(config): IExecDealModule

Create an IExecDealModule instance using an IExecConfig instance

Parameters

config

IExecConfig

Returns

IExecDealModule

Overrides

IExecModule.fromConfig