UNPKG

3.06 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.ActionService = void 0;
4const antelope_1 = require("@wharfkit/antelope");
5class ActionService {
6 constructor(client) {
7 this.client = client;
8 this.makeBatchAction = async (initBatch, hash) => {
9 const { force_vaccount_id } = await this.client.tasks.getForceSettings();
10 return {
11 account: this.client.config.tasksContract,
12 name: 'mkbatch',
13 authorization: [{
14 actor: this.client.session.actor,
15 permission: this.client.session.permission,
16 }],
17 data: {
18 id: force_vaccount_id,
19 campaign_id: initBatch.campaign_id,
20 content: { field_0: 0, field_1: hash },
21 repetitions: initBatch.repetitions,
22 payer: this.client.session.actor,
23 sig: null,
24 },
25 };
26 };
27 this.vTransferAction = async (vacc, batchPrice) => {
28 const settings = await this.client.tasks.getForceSettings();
29 return {
30 account: this.client.config.vaccountContract,
31 name: 'vtransfer',
32 authorization: [{
33 actor: this.client.session.actor,
34 permission: this.client.session.permission,
35 }],
36 data: {
37 from_id: vacc.id,
38 to_id: settings.force_vaccount_id,
39 quantity: {
40 quantity: batchPrice,
41 contract: this.client.config.tokenContract,
42 },
43 memo: '',
44 payer: this.client.session.actor,
45 sig: null,
46 fee: null,
47 },
48 };
49 };
50 this.publishBatchAction = (batchId, numTasks) => ({
51 account: this.client.config.tasksContract,
52 name: 'publishbatch',
53 authorization: [{
54 actor: this.client.session.actor,
55 permission: this.client.session.permission,
56 }],
57 data: {
58 batch_id: batchId,
59 num_tasks: numTasks,
60 sig: null,
61 }
62 });
63 this.depositAction = (amount, vacc) => ({
64 account: this.client.config.tokenContract,
65 name: 'transfer',
66 authorization: [{
67 actor: this.client.session.actor,
68 permission: this.client.session.permission,
69 }],
70 data: {
71 from: this.client.session.actor,
72 to: this.client.config.vaccountContract,
73 quantity: antelope_1.Asset.from(amount, '4,EFX'),
74 memo: `${vacc.id}`,
75 },
76 });
77 }
78}
79exports.ActionService = ActionService;
80//# sourceMappingURL=actions.js.map
\No newline at end of file