Let's try following
const author = this.userConnected as string;
const tags = this.draft.tags;
/** JSON METADATA */
const json_metadata = {
app: `beblurt/${this.core.version}`,
description: this.draft.description,
format: 'markdown',
image: images,
links: await this.retrieveLinks(),
tags,
users: await this.retrieveUser(this.draft.markdown)
};
/** COMMENT OPERATION */
const commentOperation: CommentOperation[1] = {
parent_author: '',
parent_permlink: tags[0],
author,
permlink,
title: this.draft.title,
body: this.draft.markdown,
json_metadata: JSON.stringify(json_metadata)
};
const reward = this.draft.reward;
const b: { account: string; weight: number }[] = this.draft.beneficiaries;
const beneficiaries: { account: string; weight: number }[] = reward === 'burn' ?
[{ account: 'null', weight: 10000 }] :
b.sort((a, b) => a.account < b.account ? -1 : 1);
/** COMMENT OPTION OPERATION */
const commentOptionsOperation: CommentOptionsOperation[1] = {
author,
permlink,
allow_curation_rewards: reward === '0%' ? false : true,
allow_votes: reward === '0%' ? false : true,
max_accepted_payout: reward === '0%' ? '0.000 BLURT' : '1000000.000 BLURT',
extensions: []
};
if(reward !== '0%') {
commentOptionsOperation.extensions.push([
commentOptionsOperation.extensions.length,
{ beneficiaries }
]);
if(reward !== '75%') {
commentOptionsOperation.extensions.push([
commentOptionsOperation.extensions.length,
{ percent_blurt: reward === '100%' ? 0 : 5000 }
]);
}
}
const ops: Operation[] = [
['comment', op.commentOperation],
['comment_options', op.commentOptionsOperation]
];
/** blurt_keychain **/
window.blurt_keychain.requestBroadcast(author, ops, 'Posting', (response: BROADCAST_RESULT) => {
console.log('%c[KEYCHAIN sign & broadcast Operations]', 'color: blueviolet', response);
}, 'https://blurt-rpc.saboin.com');