Skip to content

Latest commit

 

History

History
1083 lines (699 loc) · 30.4 KB

IExecOrderModule.md

File metadata and controls

1083 lines (699 loc) · 30.4 KB

iexec / Exports / IExecOrderModule

Class: IExecOrderModule

module exposing order methods

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new IExecOrderModule(configOrArgs, options?): IExecOrderModule

Create an IExecModule instance

Parameters

Name Type
configOrArgs IExecConfig | IExecConfigArgs
options? IExecConfigOptions

Returns

IExecOrderModule

Inherited from

IExecModule.constructor

Properties

config

config: IExecConfig

current IExecConfig

Inherited from

IExecModule.config

Methods

cancelApporder

cancelApporder(apporder): Promise<{ order: SignedApporder ; txHash: string }>

SIGNER REQUIRED, ONLY APP OWNER

cancel an apporder on the blockchain making it invalid

example:

const { txHash } = await cancelApporder(apporder);
console.log('cancel tx:', txHash);

Parameters

Name Type
apporder ConsumableApporder

Returns

Promise<{ order: SignedApporder ; txHash: string }>


cancelDatasetorder

cancelDatasetorder(datasetorder): Promise<{ order: SignedDatasetorder ; txHash: string }>

SIGNER REQUIRED, ONLY DATASET OWNER

cancel a datasetorder on the blockchain making it invalid

example:

const { txHash } = await cancelDatasetorder(datasetorder);
console.log('cancel tx:', txHash);

Parameters

Name Type
datasetorder ConsumableDatasetorder

Returns

Promise<{ order: SignedDatasetorder ; txHash: string }>


cancelRequestorder

cancelRequestorder(requestorder): Promise<{ order: SignedRequestorder ; txHash: string }>

SIGNER REQUIRED, ONLY REQUESTER

cancel a requestorder on the blockchain making it invalid

example:

const { txHash } = await cancelRequestorder(requestorder);
console.log('cancel tx:', txHash);

Parameters

Name Type
requestorder ConsumableRequestorder

Returns

Promise<{ order: SignedRequestorder ; txHash: string }>


cancelWorkerpoolorder

cancelWorkerpoolorder(workerpoolorder): Promise<{ order: SignedWorkerpoolorder ; txHash: string }>

SIGNER REQUIRED, ONLY WORKERPOOL OWNER

cancel a workerpoolorder on the blockchain making it invalid

example:

const { txHash } = await cancelWorkerpoolorder(workerpoolorder);
console.log('cancel tx:', txHash);

Parameters

Name Type
workerpoolorder ConsumableWorkerpoolorder

Returns

Promise<{ order: SignedWorkerpoolorder ; txHash: string }>


createApporder

createApporder(overrides): Promise<ApporderTemplate>

create an apporder template with specified parameters

example:

const apporderTemplate = await createApporder({app: appAddress});

Parameters

Name Type Description
overrides Object -
overrides.app string -
overrides.appprice? NRLCAmount price per task default 0
overrides.datasetrestrict? string restrict usage to a specific dataset default no restrict
overrides.requesterrestrict? string restrict usage to a specific requester default no restrict
overrides.tag? Tag | string[] restrict usage to runtime with specified tags default []
overrides.volume? BNish volume of tasks executable with the order default 1
overrides.workerpoolrestrict? string restrict usage to a specific workerpool default no restrict

Returns

Promise<ApporderTemplate>


createDatasetorder

createDatasetorder(overrides): Promise<DatasetorderTemplate>

create a datasetorder template with specified parameters

example:

const datasetorderTemplate = await createDatasetorder({dataset: datasetAddress});

Parameters

Name Type Description
overrides Object -
overrides.apprestrict? string restrict usage to a specific app default no restrict
overrides.dataset string -
overrides.datasetprice? NRLCAmount price per task default 0
overrides.requesterrestrict? string restrict usage to a specific requester default no restrict
overrides.tag? Tag | string[] restrict usage to runtime with specified tags default []
overrides.volume? BNish volume of tasks executable with the order default 1
overrides.workerpoolrestrict? string restrict usage to a specific workerpool default no restrict

Returns

Promise<DatasetorderTemplate>


createRequestorder

createRequestorder(overrides): Promise<RequestorderTemplate>

create a requestorder template with specified parameters

example:

const requestorderTemplate = await createRequestorder({
  app: appAddress,
  category: 0,
  params: { iexec_args: 'hello world'}
 });

Parameters

Name Type Description
overrides Object -
overrides.app string app to run
overrides.appmaxprice? NRLCAmount app max price per task default 0
overrides.beneficiary? string beneficiary default connected wallet address
overrides.callback? string address of the smart contract for on-chain callback with the execution result
overrides.category BNish computation category
overrides.dataset? string dataset to use default none
overrides.datasetmaxprice? NRLCAmount dataset max price per task default 0
overrides.params? string | RequestorderParams execution parameters
overrides.requester? string requester default connected wallet address
overrides.tag? Tag | string[] restrict usage to runtime with specified tags default []
overrides.trust? BNish required trust default 0
overrides.volume? BNish volume of tasks executable with the order default 1
overrides.workerpool? string run one specified workerpool default run on any workerpool
overrides.workerpoolmaxprice? NRLCAmount workerpool max price per task default 0

Returns

Promise<RequestorderTemplate>


createWorkerpoolorder

createWorkerpoolorder(overrides): Promise<WorkerpoolorderTemplate>

create a workerpoolorder template with specified parameters

example:

const workerpoolorderTemplate = await createWorkerpoolorder({workerpool: workerpoolAddress, category: 0});

Parameters

Name Type Description
overrides Object -
overrides.apprestrict? string restrict usage to a specific app default no restrict
overrides.category BNish computation category
overrides.datasetrestrict? string restrict usage to a specific dataset default no restrict
overrides.requesterrestrict? string restrict usage to a specific requester default no restrict
overrides.tag? Tag | string[] proposed tags default []
overrides.trust? BNish proposed trust default 0
overrides.volume? BNish volume of tasks executable with the order default 1
overrides.workerpool string -
overrides.workerpoolprice? NRLCAmount price per task default 0

Returns

Promise<WorkerpoolorderTemplate>


estimateMatchOrders

estimateMatchOrders(orders, options?): Promise<{ sponsored: NRlcAmount ; total: NRlcAmount }>

estimates the cost of matching the provided orders

example:

const orders = {
  apporder,
  datasetorder
  workerpoolorder,
  requestorder,
};
const result = await estimateMatchOrders(orders, {useVoucher: true});
console.log(`total cost for matching orders: ${result.total} nRLC`);
console.log(`sponsored cost covered by voucher: ${result.sponsored} nRLC`);

Parameters

Name Type
orders Object
orders.apporder ConsumableApporder
orders.datasetorder? ConsumableDatasetorder
orders.requestorder ConsumableRequestorder
orders.workerpoolorder ConsumableWorkerpoolorder
options? Object
options.useVoucher? boolean

Returns

Promise<{ sponsored: NRlcAmount ; total: NRlcAmount }>


hashApporder

hashApporder(apporder): Promise<string>

compute the hash of an apporder

example:

const orderHash = await hashApporder(apporder);
console.log('order hash:', orderHash);

Parameters

Name Type
apporder HashableApporder

Returns

Promise<string>


hashDatasetorder

hashDatasetorder(datasetorder): Promise<string>

compute the hash of a datasetorder

example:

const orderHash = await hashDatasetorder(datasetorder);
console.log('order hash:', orderHash);

Parameters

Name Type
datasetorder HashableDatasetorder

Returns

Promise<string>


hashRequestorder

hashRequestorder(requestorder): Promise<string>

compute the hash of a requestorder

example:

const orderHash = await hashRequestorder(requestorder);
console.log('order hash:', orderHash);

Parameters

Name Type
requestorder HashableRequestorder

Returns

Promise<string>


hashWorkerpoolorder

hashWorkerpoolorder(workerpoolorder): Promise<string>

compute the hash of a workerpoolorder

example:

const orderHash = await hashWorkerpoolorder(workerpoolorder);
console.log('order hash:', orderHash);

Parameters

Name Type
workerpoolorder HashableWorkerpoolorder

Returns

Promise<string>


matchOrders

matchOrders(orders, options?): Promise<{ dealid: string ; txHash: string ; volume: BN }>

SIGNER REQUIRED

make a deal on-chain with compatible orders to trigger the off-chain computation.

NB: preflight checks are performed on the orders before signing (this helps detecting inconsistencies and prevent creating always failing tasks). these checks can be disabled by passing the option preflightCheck: false

const { dealid, txHash } = await matchOrders({
  apporder,
  workerpoolorder,
  requestorder,
});
console.log(`created deal ${dealid} in tx ${txHash}`);

Parameters

Name Type
orders Object
orders.apporder ConsumableApporder
orders.datasetorder? ConsumableDatasetorder
orders.requestorder ConsumableRequestorder
orders.workerpoolorder ConsumableWorkerpoolorder
options? Object
options.preflightCheck? boolean
options.useVoucher? boolean

Returns

Promise<{ dealid: string ; txHash: string ; volume: BN }>


publishApporder

publishApporder(apporder, options?): Promise<string>

SIGNER REQUIRED, ONLY APP OWNER

publish an apporder on the off-chain marketplace making it available for other users

NB: preflight checks are performed on the order before signing (this helps detecting inconsistencies and prevent creating always failing tasks). these checks can be disabled by passing the option preflightCheck: false

example:

const orderHash = await publishApporder(apporder);
console.log('published order hash:', orderHash);

Parameters

Name Type
apporder ConsumableApporder
options? Object
options.preflightCheck? boolean

Returns

Promise<string>


publishDatasetorder

publishDatasetorder(datasetorder, options?): Promise<string>

SIGNER REQUIRED, ONLY DATASET OWNER

publish a datasetorder on the off-chain marketplace making it available for other users

NB: preflight checks are performed on the order before signing (this helps detecting inconsistencies and prevent creating always failing tasks). these checks can be disabled by passing the option preflightCheck: false

example:

const orderHash = await publishDatasetorder(datasetorder);
console.log('published order hash:', orderHash);

Parameters

Name Type
datasetorder ConsumableDatasetorder
options? Object
options.preflightCheck? boolean

Returns

Promise<string>


publishRequestorder

publishRequestorder(requestorder, options?): Promise<string>

SIGNER REQUIRED, ONLY REQUESTER

publish a requestorder on the off-chain marketplace making it available for other users

NB: preflight checks are performed on the order before signing (this helps detecting inconsistencies and prevent creating always failing tasks). these checks can be disabled by passing the option preflightCheck: false

example:

const orderHash = await publishRequestorder(requestorder);
console.log('published order hash:', orderHash);

Parameters

Name Type
requestorder ConsumableRequestorder
options? Object
options.preflightCheck? boolean

Returns

Promise<string>


publishWorkerpoolorder

publishWorkerpoolorder(workerpoolorder): Promise<string>

SIGNER REQUIRED, ONLY WORKERPOOL OWNER

publish a workerpoolorder on the off-chain marketplace making it available for other users

example:

const orderHash = await publishWorkerpoolorder(workerpoolorder);
console.log('published order hash:', orderHash);

Parameters

Name Type
workerpoolorder ConsumableWorkerpoolorder

Returns

Promise<string>


signApporder

signApporder(apporder, options?): Promise<SignedApporder>

ONLY APP OWNER

sign an apporder template to create a valid order

NB: preflight checks are performed on the order before signing (this helps detecting inconsistencies and prevent creating always failing tasks). these checks can be disabled by passing the option preflightCheck: false

example:

const apporderTemplate = await createApporder({app: appAddress});
const apporder = await signApporder(apporderTemplate);

Parameters

Name Type
apporder SignableApporder
options? Object
options.preflightCheck? boolean

Returns

Promise<SignedApporder>


signDatasetorder

signDatasetorder(datasetorder, options?): Promise<SignedDatasetorder>

SIGNER REQUIRED, ONLY DATASET OWNER

sign a datasetorder template to create a valid order

NB: preflight checks are performed on the order before signing (this helps detecting inconsistencies and prevent creating always failing tasks). these checks can be disabled by passing the option preflightCheck: false

example:

const datasetorderTemplate = await createDatasetorder({dataset: datasetAddress});
const datasetorder = await signDatasetorder(datasetorderTemplate);

Parameters

Name Type
datasetorder SignableDatasetorder
options? Object
options.preflightCheck? boolean

Returns

Promise<SignedDatasetorder>


signRequestorder

signRequestorder(requestorder, options?): Promise<SignedRequestorder>

SIGNER REQUIRED, ONLY REQUESTER

sign a requestorder template to create a valid order

NB: preflight checks are performed on the order before signing (this helps detecting inconsistencies and prevent creating always failing tasks). these checks can be disabled by passing the option preflightCheck: false

example:

const requestorderTemplate = await createRequestorder({
  app: appAddress,
  category: 0,
  params: { iexec_args: 'hello world'}
 });
const requestorder = await signRequestorder(requestorderTemplate);

Parameters

Name Type
requestorder SignableRequestorder
options? Object
options.preflightCheck? boolean

Returns

Promise<SignedRequestorder>


signWorkerpoolorder

signWorkerpoolorder(workerpoolorder): Promise<SignedWorkerpoolorder>

SIGNER REQUIRED, ONLY WORKERPOOL OWNER

sign a workerpoolorder template to create a valid order

const workerpoolorderTemplate = await createWorkerpoolorder({workerpool: workerpoolAddress, category: 0});
const workerpoolorder = await signWorkerpoolorder(workerpoolorderTemplate);

Parameters

Name Type
workerpoolorder SignableWorkerpoolorder

Returns

Promise<SignedWorkerpoolorder>


unpublishAllApporders

unpublishAllApporders(appAddress): Promise<string[]>

SIGNER REQUIRED, ONLY APPORDER SIGNER

unpublish all the published app's apporders from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHashes = await unpublishAllApporders(appAddress);
console.log('published orders count:', orderHashes.length);

Parameters

Name Type
appAddress string

Returns

Promise<string[]>


unpublishAllDatasetorders

unpublishAllDatasetorders(datasetAddress): Promise<string[]>

SIGNER REQUIRED, ONLY DATASETORDER SIGNER

unpublish all the published dataset's datasetorders from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHashes = await unpublishAllDatasetorders(datasetAddress);
console.log('unpublished orders count:', orderHashes.length);

Parameters

Name Type
datasetAddress string

Returns

Promise<string[]>


unpublishAllRequestorders

unpublishAllRequestorders(): Promise<string[]>

SIGNER REQUIRED, ONLY REQUESTER

unpublish all the published requester's requestorders from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHashes = await unpublishAllRequestorders();
console.log('unpublished orders count:', orderHashes.length);

Returns

Promise<string[]>


unpublishAllWorkerpoolorders

unpublishAllWorkerpoolorders(workerpoolAddress): Promise<string[]>

SIGNER REQUIRED, ONLY WORKERPOOLORDER SIGNER

unpublish all the published workerpool's workerpoolorders from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHashes = await unpublishAllWorkerpoolorders(workerpoolAddress);
console.log('unpublished orders count:', orderHashes.length);

Parameters

Name Type
workerpoolAddress string

Returns

Promise<string[]>


unpublishApporder

unpublishApporder(apporderHash): Promise<string>

SIGNER REQUIRED, ONLY APPORDER SIGNER

unpublish an apporder from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHash = await unpublishApporder(apporderHash);
console.log(unpublished order hash:', orderHash);

Parameters

Name Type
apporderHash string

Returns

Promise<string>


unpublishDatasetorder

unpublishDatasetorder(datasetorderHash): Promise<string>

SIGNER REQUIRED, ONLY DATASETORDER SIGNER

unpublish a datasetorder from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHash = await unpublishDatasetorder(datasetorderHash);
console.log('unpublished order hash:', orderHash);

Parameters

Name Type
datasetorderHash string

Returns

Promise<string>


unpublishLastApporder

unpublishLastApporder(appAddress): Promise<string>

SIGNER REQUIRED, ONLY APPORDER SIGNER

unpublish the last published app's apporder from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHash = await unpublishLastApporder(appAddress);
console.log('published order hash:', orderHash);

Parameters

Name Type
appAddress string

Returns

Promise<string>


unpublishLastDatasetorder

unpublishLastDatasetorder(datasetAddress): Promise<string>

SIGNER REQUIRED, ONLY DATASETORDER SIGNER

unpublish the last published dataset's datasetorder from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHash = await unpublishLastDatasetorder(datasetAddress);
console.log('unpublished order hash:', orderHash);

Parameters

Name Type
datasetAddress string

Returns

Promise<string>


unpublishLastRequestorder

unpublishLastRequestorder(): Promise<string>

SIGNER REQUIRED, ONLY REQUESTER

unpublish the last published requester's requestorder from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHash = await unpublishLastRequestorder();
console.log('unpublished order hash:', orderHash);

Returns

Promise<string>


unpublishLastWorkerpoolorder

unpublishLastWorkerpoolorder(workerpoolAddress): Promise<string>

**SIGNER REQUIRED, ONLY WORKERPOOLORDER SIGNER

unpublish the last published workerpool's workerpoolorder from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHash = await unpublishLastWorkerpoolorder(workerpoolAddress);
console.log('unpublished order hash:', orderHash);

Parameters

Name Type
workerpoolAddress string

Returns

Promise<string>


unpublishRequestorder

unpublishRequestorder(requestorderHash): Promise<string>

SIGNER REQUIRED, ONLY REQUESTER

unpublish a requestorder from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHash = await unpublishRequestorder(requestorderHash);
console.log('unpublished order hash:', orderHash);

Parameters

Name Type
requestorderHash string

Returns

Promise<string>


unpublishWorkerpoolorder

unpublishWorkerpoolorder(workerpoolorderHash): Promise<string>

SIGNER REQUIRED, ONLY WORKERPOOLORDER SIGNER

unpublish a workerpoolorder from the off-chain marketplace

NB: this is a transaction free off-chain operation, unpublished orders are no longer exposed to other users but are still valid, use the cancel method if you want to invalidate them

example:

const orderHash = await unpublishWorkerpoolorder(workerpoolorderHash);
console.log('unpublished order hash:', orderHash);

Parameters

Name Type
workerpoolorderHash string

Returns

Promise<string>


fromConfig

fromConfig(config): IExecOrderModule

Create an IExecOrderModule instance using an IExecConfig instance

Parameters

Name Type
config IExecConfig

Returns

IExecOrderModule

Overrides

IExecModule.fromConfig