Skip to content

Latest commit

 

History

History
319 lines (181 loc) · 5.89 KB

File metadata and controls

319 lines (181 loc) · 5.89 KB

iexec


iexec / IExecWorkerpoolModule

Class: IExecWorkerpoolModule

module exposing workerpool methods

Extends

Constructors

Constructor

new IExecWorkerpoolModule(configOrArgs, options?): IExecWorkerpoolModule

Create an IExecModule instance

Parameters

configOrArgs

IExecConfigArgs | IExecConfig

options?

IExecConfigOptions

Returns

IExecWorkerpoolModule

Inherited from

IExecModule.constructor

Properties

config

config: IExecConfig

current IExecConfig

Inherited from

IExecModule.config

Methods

checkDeployedWorkerpool()

checkDeployedWorkerpool(workerpoolAddress): Promise<Boolean>

check if an workerpool is deployed at a given address

example:

const isDeployed = await checkDeployedWorkerpool(address);
console.log('workerpool deployed', isDeployed);

Parameters

workerpoolAddress

string

Returns

Promise<Boolean>


countUserWorkerpools()

countUserWorkerpools(userAddress): Promise<BN>

count the workerpools owned by an address.

example:

const count = await countUserWorkerpools(userAddress);
console.log('workerpool count:', count);

Parameters

userAddress

string

Returns

Promise<BN>


deployWorkerpool()

deployWorkerpool(workerpool): Promise<{ address: string; txHash: string; }>

SIGNER REQUIRED

deploy a workerpool contract on the blockchain

example:

const { address } = await deployWorkerpool({
 owner: address,
 description: 'My workerpool',
});
console.log('deployed at', address);

Parameters

workerpool

WorkerpoolDeploymentArgs

Returns

Promise<{ address: string; txHash: string; }>


getWorkerpoolApiUrl()

getWorkerpoolApiUrl(workerpoolAddress): Promise<string | undefined>

read the workerpool API url on the blockchain

NB: resolve to undefined if the workerpool API url was not declared.

example:

const url = await getWorkerpoolApiUrl('my-workerpool.eth');
console.log('workerpool API url:', url);

Parameters

workerpoolAddress

string

Returns

Promise<string | undefined>


predictWorkerpoolAddress()

predictWorkerpoolAddress(workerpool): Promise<string>

predict the workerpool contract address given the workerpool deployment arguments

example:

const address = await predictWorkerpoolAddress({
 owner: address,
 description: 'My workerpool',
});
console.log('address', address);

Parameters

workerpool

WorkerpoolDeploymentArgs

Returns

Promise<string>


setWorkerpoolApiUrl()

setWorkerpoolApiUrl(workerpoolAddress, url): Promise<string>

ONLY WORKERPOOL ENS NAME OWNER

declare the workerpool API url on the blockchain

NB: declaring the workerpool API url require an ENS name with a configured reverse resolution on the workerpool address (see: IExecENSModule obsConfigureResolution/configureResolution)

example:

const txHash = await setWorkerpoolApiUrl('my-workerpool.eth', 'my-workerpool.com');
console.log('txHash:', txHash);

Parameters

workerpoolAddress

string

url

string

Returns

Promise<string>


showUserWorkerpool()

showUserWorkerpool(index, address): Promise<{ objAddress: string; workerpool: Workerpool; }>

show deployed workerpool details by index for specified user user

example:

const { workerpool } = await showUserWorkerpool(0, userAddress);
console.log('workerpool:', workerpool);

Parameters

index

BNish

address

string

Returns

Promise<{ objAddress: string; workerpool: Workerpool; }>


showWorkerpool()

showWorkerpool(workerpoolAddress): Promise<{ objAddress: string; workerpool: Workerpool; }>

show a deployed workerpool details

example:

const { workerpool } = await showWorkerpool('0x86F2102532d9d01DA8084c96c1D1Bdb90e12Bf07');
console.log('workerpool:', workerpool);

Parameters

workerpoolAddress

string

Returns

Promise<{ objAddress: string; workerpool: Workerpool; }>


transferWorkerpool()

transferWorkerpool(workerpoolAddress, to): Promise<{ address: string; to: string; txHash: string; }>

ONLY WORKERPOOL OWNER

transfer the ownership of a workerpool to the specified address

NB: when transferring the ownership to a contract, the receiver contract must implement the ERC721 token receiver interface

example:

const { address, to, txHash } = await transferWorkerpool(workerpoolAddress, receiverAddress);
console.log(`workerpool ${address} ownership transferred to ${address} in tx ${txHash}`);

Parameters

workerpoolAddress

string

to

string

Returns

Promise<{ address: string; to: string; txHash: string; }>


fromConfig()

static fromConfig(config): IExecWorkerpoolModule

Create an IExecWorkerpoolModule instance using an IExecConfig instance

Parameters

config

IExecConfig

Returns

IExecWorkerpoolModule

Overrides

IExecModule.fromConfig