/
setAccountInfo.ts
36 lines (32 loc) · 1.33 KB
/
setAccountInfo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Copyright (c) 2021 Burst Apps Team
*/
import {ChainService} from '../../../service/chainService';
import {TransactionId} from '../../../typings/transactionId';
import {TransactionResponse} from '../../../typings/transactionResponse';
import {signAndBroadcastTransaction} from '../transaction/signAndBroadcastTransaction';
import {DefaultDeadline} from '../../../constants';
import {SetAccountInfoArgs} from '../../../typings/args/setAccountInfoArgs';
/**
* Use with [[ApiComposer]] and belongs to [[AccountApi]].
*
* See details at [[AccountApi.setAccountInfo]]
* @module core.api.factories
*/
export const setAccountInfo = (service: ChainService):
(args: SetAccountInfoArgs) => Promise<TransactionId> =>
async (args: SetAccountInfoArgs): Promise<TransactionId> => {
const parameters = {
name: args.name,
description: args.description,
deadline: DefaultDeadline,
feeNQT: args.feePlanck,
publicKey: args.senderPublicKey
};
const {unsignedTransactionBytes: unsignedHexMessage} = await service.send<TransactionResponse>('setAccountInfo', parameters);
return signAndBroadcastTransaction(service)({
senderPrivateKey: args.senderPrivateKey,
senderPublicKey: args.senderPublicKey,
unsignedHexMessage
});
};