1 | import { Reservation, Batch, Campaign, TasksSettings, InitCampaign, InitBatch, RepsDone } from './../types/campaign';
|
2 | import { Client } from '../client';
|
3 | import { TransactResult } from '@wharfkit/session';
|
4 | export declare class TasksService {
|
5 | private client;
|
6 | constructor(client: Client);
|
7 | /**
|
8 | * Retrieve all campaigns published to Effect Network
|
9 | * @returns {Campaign[]} Promise<Campaign[]>
|
10 | */
|
11 | getAllCampaigns(ipfsFetch?: boolean): Promise<Campaign[]>;
|
12 | /**
|
13 | * Retrieve campaign by id
|
14 | * @param id id of the campaign
|
15 | * @returns {Promise<Campaign>} Campaign
|
16 | */
|
17 | getCampaign(id: number, fetchIpfs?: boolean): Promise<Campaign>;
|
18 | /**
|
19 | * Create a new campaign
|
20 | * @param campaign InitCampaign
|
21 | */
|
22 | makeCampaign(campaign: InitCampaign): Promise<TransactResult>;
|
23 | /**
|
24 | * Retrieve Batch by id
|
25 | * @param id id of the batch
|
26 | * @returns {Promise<Batch>} Batch
|
27 | */
|
28 | getBatch(batchId: number): Promise<Batch>;
|
29 | /**
|
30 | * Create batch
|
31 | */
|
32 | makeBatch(initBatch: InitBatch): Promise<any>;
|
33 | /**
|
34 | * Fetch the task data
|
35 | * Load the batch the task is in (get _task_.batch_id from the batch table)
|
36 | * Get the batch IPFS hash from batch.content.value
|
37 | * Load the IPFS object and confirm it is a JSON array. Get the _task_.task_idxth item from the array
|
38 | * Render the campaign template with that task data
|
39 | */
|
40 | getTaskData(reservation: Reservation): Promise<any>;
|
41 | /**
|
42 | * Task availability
|
43 | * TODO: This is a WIP
|
44 | */
|
45 | taskAvailable(reservation: Reservation): Promise<boolean>;
|
46 | /**
|
47 | * Get repitions done for a task in a campaign.
|
48 | */
|
49 | getAllRepsDone(): Promise<RepsDone[]>;
|
50 | /**
|
51 | * Submit task
|
52 | * Call submittask(camapign_id, task_idx, data, account_id, sig). Note to use _task_.task_idx for the task_idx parameter (not the ID).
|
53 | * sig (for BSC only): to avoid replay attacks, the signature is (mark)(campaign_id)(task_idx)(data). The mark value is 5.
|
54 | */
|
55 | submitTask(reservation: Reservation, data: any): Promise<TransactResult>;
|
56 | /**
|
57 | *
|
58 | */
|
59 | getAllAccTaskIdx: () => Promise<any>;
|
60 | /**
|
61 | * Retrieve all reservations
|
62 | * @returns {Promise<Reservation[]>} Reservation[]
|
63 | */
|
64 | getAllReservations(): Promise<Reservation[]>;
|
65 | /**
|
66 | * Get Campaign Reservation for user
|
67 | * @param campaignId id of the campaign
|
68 | * @param accountId id of the account
|
69 | * @returns {Promise<Reservation>} Reservation
|
70 | */
|
71 | getCampaignReservation(campaignId: number, accountId: number): Promise<Reservation>;
|
72 | /**
|
73 | * Get the reservation of logged in user for a campaign.
|
74 | * @param campaignId id of the campaign
|
75 | * @returns {Promise<Reservation>} Reservation
|
76 | */
|
77 | getMyReservation(campaignId: number): Promise<Reservation>;
|
78 | /**
|
79 | * 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.
|
80 | * @param campaignId id of the campaign
|
81 | * @param qualiAssets can be null, then the smart contract will search through all the assets of the user.
|
82 | * @returns {Promise<Reservation>} Reservation
|
83 | *
|
84 | * ```mermaid
|
85 | * sequenceDiagram
|
86 | * participant User
|
87 | * participant Client
|
88 | * participant Smart Contract
|
89 | * User->>Client: Login
|
90 | * Client->>Smart Contract: reserveTask(campaignId, qualiAssets)
|
91 | * Smart Contract->>Smart Contract: Check if user already has a reservation for this campaign
|
92 | * Smart Contract->>Smart Contract: If not, create a new reservation
|
93 | * Smart Contract->>Client: Return reservation
|
94 | * Client->>User: Return reservation
|
95 | * ```
|
96 | */
|
97 | reserveTask(campaignId: number, qualiAssets?: string[]): Promise<Reservation>;
|
98 | /**
|
99 | * Retrieve Effect Network Qualification NFT for user.
|
100 | * @param accountId id of the account
|
101 | * @returns {Promise<Qualification>} Qualification NFT
|
102 | */
|
103 | getQualifications(accountId: number): Promise<any[]>;
|
104 | /**
|
105 | * TODO: Figure out the interface for a Qualification NFT Asset
|
106 | * Retrieve Effect Network Qualification NFT Collection
|
107 | *
|
108 | */
|
109 | getQualificationCollection(): Promise<any>;
|
110 | /**
|
111 | * Get payout delay
|
112 | * @returns the payout delay in seconds
|
113 | * @throws error if the payout delay is not available
|
114 | */
|
115 | getForceSettings: () => Promise<TasksSettings>;
|
116 | }
|