UNPKG

1.84 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.DaoService = void 0;
4class DaoService {
5 constructor(client) {
6 this.client = client;
7 /**
8 * Retrieve the DAO config
9 * @returns {Promise<DaoConfig>} Returns the DAO config
10 */
11 this.getConfig = async () => {
12 const { rows } = await this.client.eos.v1.chain.get_table_rows({
13 code: this.client.config.daoContract,
14 scope: this.client.config.daoContract,
15 table: 'config',
16 limit: 1
17 });
18 const [config] = rows;
19 return config;
20 };
21 }
22 /**
23 * Set the avatar asset for the given account
24 * @param asset
25 */
26 async setAvatarAsset(asset) {
27 const authorization = this.client.sessionAuth();
28 const response = await this.client.session.transact({
29 actions: [{
30 account: this.client.config.daoContract,
31 name: 'setavatar',
32 authorization,
33 data: {
34 account: this.client.session.actor,
35 asset_id: asset.asset_id
36 }
37 }]
38 });
39 return response;
40 }
41 /**
42 * Retrieve the avatar for the given account
43 * @param account
44 * @returns
45 * @example { type: 0, asset_id: '2199025109172' }
46 */
47 async getAvatar(account) {
48 const response = await this.client.eos.v1.chain.get_table_rows({
49 code: this.client.config.daoContract,
50 scope: account,
51 table: 'avatar',
52 limit: 1
53 });
54 const [avatar] = response.rows;
55 return avatar;
56 }
57}
58exports.DaoService = DaoService;
59//# sourceMappingURL=dao.js.map
\No newline at end of file