Skip to content

Latest commit

 

History

History
359 lines (233 loc) · 10.9 KB

IExecDealModule.md

File metadata and controls

359 lines (233 loc) · 10.9 KB

iexec / Exports / IExecDealModule

Class: IExecDealModule

module exposing deal methods

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new IExecDealModule(configOrArgs, options?): IExecDealModule

Create an IExecModule instance

Parameters

Name Type
configOrArgs IExecConfig | IExecConfigArgs
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<number, string> ; transactions: { txHash: string ; type: string }[] }>

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

Name Type
dealid string

Returns

Promise<{ claimed: Record<number, string> ; transactions: { txHash: string ; type: string }[] }>


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

Name Type
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

Name Type Description
apporderHash string -
options? Object -
options.page? number index of the page to fetch
options.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

Name Type Description
datasetorderHash string -
options? Object -
options.page? number index of the page to fetch
options.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

Name Type Description
requestorderHash string -
options? Object -
options.page? number index of the page to fetch
options.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

Name Type Description
workerpoolorderHash string -
options? Object -
options.page? number index of the page to fetch
options.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

Name Type Description
requesterAddress string -
options? Object -
options.appAddress? string filter by app
options.datasetAddress? string filter by dataset
options.page? number index of the page to fetch
options.pageSize? number size of the page to fetch
options.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

Name Type
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<number, string> ; trust: BN ; workerStake: BN ; workerpool: { owner: string ; pointer: string ; price: BN } }>

show the details of a deal.

example:

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

Parameters

Name Type
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<number, string> ; trust: BN ; workerStake: BN ; workerpool: { owner: string ; pointer: string ; price: BN } }>


fromConfig

fromConfig(config): IExecDealModule

Create an IExecDealModule instance using an IExecConfig instance

Parameters

Name Type
config IExecConfig

Returns

IExecDealModule

Overrides

IExecModule.fromConfig