iexec / Exports / IExecDealModule
module exposing deal methods
-
↳
IExecDealModule
- claim
- computeTaskId
- fetchDealsByApporder
- fetchDealsByDatasetorder
- fetchDealsByRequestorder
- fetchDealsByWorkerpoolorder
- fetchRequesterDeals
- obsDeal
- show
- fromConfig
• new IExecDealModule(configOrArgs
, options?
): IExecDealModule
Create an IExecModule instance
Name | Type |
---|---|
configOrArgs |
IExecConfig | IExecConfigArgs |
options? |
IExecConfigOptions |
• config: IExecConfig
current IExecConfig
▸ 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}`);
});
Name | Type |
---|---|
dealid |
string |
Promise
<{ claimed
: Record
<number
, string
> ; transactions
: { txHash
: string
; type
: string
}[] }>
▸ 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)
Name | Type |
---|---|
dealid |
string |
taskIdx |
BNish |
Promise
<string
>
▸ 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]);
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 |
Promise
<PaginableDeals
>
▸ 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]);
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 |
Promise
<PaginableDeals
>
▸ 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]);
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 |
Promise
<PaginableDeals
>
▸ 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]);
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 |
Promise
<PaginableDeals
>
▸ 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]);
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 |
Promise
<PaginableDeals
>
▸ 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
Name | Type |
---|---|
dealid |
string |
Promise
<DealObservable
>
▸ 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);
Name | Type |
---|---|
dealid |
string |
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(config
): IExecDealModule
Create an IExecDealModule instance using an IExecConfig instance
Name | Type |
---|---|
config |
IExecConfig |