@effectai/effect-js
Version:
Effect Network Javscript/Typescript SDK (for [https://effect.network](https://effect.network))
117 lines (116 loc) • 4.44 kB
TypeScript
import { Reservation, Batch, Campaign, TasksSettings, InitCampaign, InitBatch, RepsDone } from './../types/campaign';
import { Client } from '../client';
import { TransactResult } from '@wharfkit/session';
export declare class TasksService {
private client;
constructor(client: Client);
/**
* Retrieve all campaigns published to Effect Network
* @returns {Campaign[]} Promise<Campaign[]>
*/
getAllCampaigns(ipfsFetch?: boolean): Promise<Campaign[]>;
/**
* Retrieve campaign by id
* @param id id of the campaign
* @returns {Promise<Campaign>} Campaign
*/
getCampaign(id: number, fetchIpfs?: boolean): Promise<Campaign>;
/**
* Create a new campaign
* @param campaign InitCampaign
*/
makeCampaign(campaign: InitCampaign): Promise<TransactResult>;
/**
* Retrieve Batch by id
* @param id id of the batch
* @returns {Promise<Batch>} Batch
*/
getBatch(batchId: number): Promise<Batch>;
/**
* Create batch
*/
makeBatch(initBatch: InitBatch): Promise<any>;
/**
* Fetch the task data
* Load the batch the task is in (get _task_.batch_id from the batch table)
* Get the batch IPFS hash from batch.content.value
* Load the IPFS object and confirm it is a JSON array. Get the _task_.task_idxth item from the array
* Render the campaign template with that task data
*/
getTaskData(reservation: Reservation): Promise<any>;
/**
* Task availability
* TODO: This is a WIP
*/
taskAvailable(reservation: Reservation): Promise<boolean>;
/**
* Get repitions done for a task in a campaign.
*/
getAllRepsDone(): Promise<RepsDone[]>;
/**
* Submit task
* Call submittask(camapign_id, task_idx, data, account_id, sig). Note to use _task_.task_idx for the task_idx parameter (not the ID).
* sig (for BSC only): to avoid replay attacks, the signature is (mark)(campaign_id)(task_idx)(data). The mark value is 5.
*/
submitTask(reservation: Reservation, data: any): Promise<TransactResult>;
/**
*
*/
getAllAccTaskIdx: () => Promise<any>;
/**
* Retrieve all reservations
* @returns {Promise<Reservation[]>} Reservation[]
*/
getAllReservations(): Promise<Reservation[]>;
/**
* Get Campaign Reservation for user
* @param campaignId id of the campaign
* @param accountId id of the account
* @returns {Promise<Reservation>} Reservation
*/
getCampaignReservation(campaignId: number, accountId: number): Promise<Reservation>;
/**
* Get the reservation of logged in user for a campaign.
* @param campaignId id of the campaign
* @returns {Promise<Reservation>} Reservation
*/
getMyReservation(campaignId: number): Promise<Reservation>;
/**
* Reserve a task, will check if the user already has a reservation for this campaign and return it, if not will create a new reservation and return it.
* @param campaignId id of the campaign
* @param qualiAssets can be null, then the smart contract will search through all the assets of the user.
* @returns {Promise<Reservation>} Reservation
*
* ```mermaid
* sequenceDiagram
* participant User
* participant Client
* participant Smart Contract
* User->>Client: Login
* Client->>Smart Contract: reserveTask(campaignId, qualiAssets)
* Smart Contract->>Smart Contract: Check if user already has a reservation for this campaign
* Smart Contract->>Smart Contract: If not, create a new reservation
* Smart Contract->>Client: Return reservation
* Client->>User: Return reservation
* ```
*/
reserveTask(campaignId: number, qualiAssets?: string[]): Promise<Reservation>;
/**
* Retrieve Effect Network Qualification NFT for user.
* @param accountId id of the account
* @returns {Promise<Qualification>} Qualification NFT
*/
getQualifications(accountId: number): Promise<any[]>;
/**
* TODO: Figure out the interface for a Qualification NFT Asset
* Retrieve Effect Network Qualification NFT Collection
*
*/
getQualificationCollection(): Promise<any>;
/**
* Get payout delay
* @returns the payout delay in seconds
* @throws error if the payout delay is not available
*/
getForceSettings: () => Promise<TasksSettings>;
}