morphit/node_modules/@beblurt/dblurt/lib/helpers/broadcast.d.ts
Morphit Team 24240cef4c
Some checks failed
morphit-release / Build + publish release tarball (push) Has been cancelled
Reputation flags clearable across all four signals; names and avatars stop vanishing
2026-07-23 14:28:04 -07:00

403 lines
24 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file Blurt Broadcast API helpers.
* @author BeBlurt <https://beblurt.com/@beblurt>
* @description adaptation from Johan Nordberg <code@johan-nordberg.com> Broadcast API helpers.
* @license
* Copyright (c) 2017 Johan Nordberg. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* You acknowledge that this software is not designed, licensed or intended for use
* in the design, construction, operation or maintenance of any military facility.
*/
import { AccountCreateOperation, AccountUpdateOperation, AccountWitnessProxyOperation, AccountWitnessVoteOperation, CancelTransferFromSavingsOperation, ChangeRecoveryAccountOperation, ClaimAccountOperation, ClaimRewardBalanceOperation, CommentOperation, CommentOptionsOperation, CreateClaimedAccountOperation, CreateProposalOperation, CustomJsonOperation, DelegateVestingSharesOperation, DeleteCommentOperation, EscrowApproveOperation, EscrowDisputeOperation, EscrowReleaseOperation, EscrowTransferOperation, Operation, RecoverAccountOperation, RemoveProposalOperation, RequestAccountRecoveryOperation, SetWithdrawVestingRouteOperation, TransferFromSavingsOperation, TransferOperation, TransferToSavingsOperation, TransferToVestingOperation, UpdateProposalVotesOperation, VoteOperation, WithdrawVestingOperation, WitnessSetPropertiesOperation, WitnessUpdateOperation } from '../chain/operation';
import { NexusUpdateProps } from '../chain/nexus';
import { SignedTransaction, Transaction, TransactionConfirmation } from '../chain/transaction';
import { Client } from '../client';
import { PrivateKey } from '../crypto';
export declare class BroadcastAPI {
readonly client: Client;
/**
* How many milliseconds in the future to set the expiry time to when
* broadcasting a transaction, defaults to 1 minute.
*/
expireTime: number;
constructor(client: Client);
/** Convenience for calling `condenser_api`. */
call(method: string, params?: any[]): Promise<any>;
/**
* Create account.
* Broadcasted to the blockchain to create a new account.
* @param data The account_create payload. See {@link AccountCreateOperation}
* @param key The Active or Owner private key of the account creator.
*/
accountCreate(data: AccountCreateOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Update account.
* Updates account information.
* @param data The account_update payload. See {@link AccountUpdateOperation}
* @param key The Active or Owner private key of the account.
*/
accountUpdate(data: AccountUpdateOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Set witness voting proxy.
* @param data The account_witness_proxy payload. See {@link AccountWitnessProxyOperation}
* @param key The private key of the account, should be the Active key at least.
* @deprecated Current Blurt Layer 1 rejects witness proxies after hardfork 0.8
* (`account_witness_proxy_evaluator` asserts that proxies were disabled). Use direct
* witness votes instead.
*/
accountWitnessProxy(data: AccountWitnessProxyOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Witness vote.
* Vote from an account to a witness.
* @param data The account_witness_vote payload. See {@link AccountWitnessVoteOperation}
* @param key The private key of the account, should be the Active key at least.
* @remarks Since HF 0.8 the formula VS/N where VP is the Vesting Share of the account and N the number of witnesses upvoted by the account is applied.
*/
accountWitnessVote(data: AccountWitnessVoteOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Cancel transfer from saving.
* Funds withdrawals from the savings can be canceled at any time before it is executed.
* @param data The cancel_transfer_from_savings payload. See {@link CancelTransferFromSavingsOperation}
* @param key The private key of the account, should be the Active key at least.
*/
cancelTransferFromSavings(data: CancelTransferFromSavingsOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Change recovery account.
* Funds withdrawals from the savings can be canceled at any time before it is executed.
* @param data The change_recovery_account payload. See {@link ChangeRecoveryAccountOperation}
* @param key The Owner private key of the account.
*/
changeRecoveryAccount(data: ChangeRecoveryAccountOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Claim account.
* Requests from users or dApps to get an account creation ticket in order to create new accounts.
* These operations are issued before the actual creation of the account on the blockchain.
* @param data The claim_account payload. See {@link ClaimAccountOperation}
* @param key The Active or Owner private key of the account.
* @deprecated Current Blurt Layer 1 rejects `claim_account` after hardfork 0.2
* (`claim_account_evaluator` asserts that this operation is disabled). Use regular
* account creation flows supported by current chain rules instead.
*/
claimAccount(data: ClaimAccountOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Claim reward balance.
* Author and curator rewards are not automatically transferred to the accounts balances.
* One has to issue a `claim_reward_balance` operation to trigger the transfer from the reward pool to its balance.
* @param data The claim_reward_balance payload. See {@link ClaimRewardBalanceOperation}
* @param key The Posting, Active or Owner private key of the account.
*/
claimRewardBalance(data: ClaimRewardBalanceOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Comment.
* Creates a post/comment.
* @param data The comment payload. See {@link CommentOperation}
* @param key The Posting, Active or Owner private key of the account.
* @param options The comment_options payload [optional]. See {@link CommentOptionsOperation}
* @remarks
* Rules:
* - The “title” must not be longer than 256 bytes
* - The “title” must be UTF-8
* - The “body” must be larger than 0 bytes
* - The “body” much also be UTF-8
*
* json_metadata: There is no blockchain enforced validation on `json_metadata`, but the community has adopted a particular structure:
* - tags - An array of up to 5 strings. Although the blockchain will accept more than 5, the tags plugin only looks at the first five
* - app - A user agent style application identifier. Typically app_name/version, e.g. beblurt/0.1
* - format - The format of the body, e.g. markdown
*
* In addition to the above keys, application developers are free to add any other keys they want to help manage the content they broadcast.
*
* When a comment is first broadcast, the permlink must be unique for the author. Otherwise, it is interpreted as an update operation.
* Updating will either replace the entire body with the latest operation or patch the body if using diff-match-patch.
*/
comment(data: CommentOperation[1], key: PrivateKey, options?: CommentOptionsOperation[1]): Promise<TransactionConfirmation>;
/**
* Comment options.
* Authors of posts may not want all of the benefits that come from creating a post. This operation allows authors to update properties associated with their post.
* Typically, these options will accompany a comment operation in the same transaction.
* @param data The comment_options payload. See {@link CommentOptionsOperation}
* @param key The Active or Owner private key of the account creator.
*/
commentOptions(data: CommentOptionsOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Delete a post or comment by author/permlink.
* @param data The delete_comment payload. See {@link DeleteCommentOperation}.
* @param key Private posting key of the author.
*/
deleteComment(data: DeleteCommentOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Transfer liquid BLURT into vesting shares.
* @param data The transfer_to_vesting payload. See {@link TransferToVestingOperation}.
* @param key Private active key of the source account.
*/
transferToVesting(data: TransferToVestingOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Start or update a vesting withdrawal schedule.
* @param data The withdraw_vesting payload. See {@link WithdrawVestingOperation}.
* @param key Private active key of the withdrawing account.
*/
withdrawVesting(data: WithdrawVestingOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Route vesting withdrawals to another account.
* @param data The set_withdraw_vesting_route payload. See {@link SetWithdrawVestingRouteOperation}.
* @param key Private active key of the source account.
*/
setWithdrawVestingRoute(data: SetWithdrawVestingRouteOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Transfer liquid BLURT into savings.
* @param data The transfer_to_savings payload. See {@link TransferToSavingsOperation}.
* @param key Private active key of the source account.
*/
transferToSavings(data: TransferToSavingsOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Request a transfer from savings.
* @param data The transfer_from_savings payload. See {@link TransferFromSavingsOperation}.
* @param key Private active key of the source account.
*/
transferFromSavings(data: TransferFromSavingsOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Create claimed account.
* When used with `claim_account`, works identically to `account_create` See {@link accountCreate}.
* @param data The create_claimed_account payload. See {@link CreateClaimedAccountOperation}
* @param key The Active or Owner private key of the account creator.
* @deprecated Current Blurt Layer 1 rejects `create_claimed_account` after hardfork 0.2
* (`create_claimed_account_evaluator` asserts that this operation is disabled). Use regular
* account creation flows supported by current chain rules instead.
*/
createClaimedAccount(data: CreateClaimedAccountOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Create an account recovery request.
* @param data The request_account_recovery payload. See {@link RequestAccountRecoveryOperation}.
* @param key Private owner key of the recovery account.
*/
requestAccountRecovery(data: RequestAccountRecoveryOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Recover an account using current and recent owner authorities.
* @param data The recover_account payload. See {@link RecoverAccountOperation}.
* @param key Private owner key or keys required by the recovery authorities.
*/
recoverAccount(data: RecoverAccountOperation[1], key: PrivateKey | PrivateKey[]): Promise<TransactionConfirmation>;
/**
* Create an escrow transfer.
* @param data The escrow_transfer payload. See {@link EscrowTransferOperation}.
* @param key Private active key of the sender.
*/
escrowTransfer(data: EscrowTransferOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Approve or reject an escrow transfer.
* @param data The escrow_approve payload. See {@link EscrowApproveOperation}.
* @param key Private active key of `data.who`.
*/
escrowApprove(data: EscrowApproveOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Dispute an escrow transfer.
* @param data The escrow_dispute payload. See {@link EscrowDisputeOperation}.
* @param key Private active key of `data.who`.
*/
escrowDispute(data: EscrowDisputeOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Release funds from an escrow transfer.
* @param data The escrow_release payload. See {@link EscrowReleaseOperation}.
* @param key Private active key of `data.who`.
*/
escrowRelease(data: EscrowReleaseOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/** Register or update witness metadata. */
witnessUpdate(data: WitnessUpdateOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/** Set low-level witness properties. */
witnessSetProperties(data: WitnessSetPropertiesOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/** Create a governance proposal. */
createProposal(data: CreateProposalOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/** Vote for or against governance proposals. */
updateProposalVotes(data: UpdateProposalVotesOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/** Remove governance proposals owned by an account. */
removeProposal(data: RemoveProposalOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Broadcast custom JSON.
* Serves the same purpose as custom but also supports required posting authorities. Unlike custom, this operation is designed to be human readable/developer friendly.
* @param data The custom_json operation payload. See {@link CustomJsonOperation}
* @param key The Posting, Active or Owner private key of the account.
*/
customJson(data: CustomJsonOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Delegate vesting shares from one account to the other. The vesting shares are still owned
* by the original account, but content voting rights and bandwidth allocation are transferred
* to the receiving account. This sets the delegation to `vesting_shares`, increasing it or
* decreasing it as needed. (i.e. a delegation of 0 removes the delegation)
*
* When a delegation is removed the shares are placed in limbo for a week to prevent a satoshi
* of VESTS from voting on the same content twice.
*
* @param options Delegation options. See {@link DelegateVestingSharesOperation}
* @param key Private active key of the delegator.
*/
delegateVestingShares(options: DelegateVestingSharesOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Prepare transaction with operations for Sign and broadcast to the network.
* @param operations List of operations to send.
*/
prepareTransaction(operations: Operation[]): Promise<Transaction>;
/**
* Reblurt/Undo Reblurt a post
* @param account The account submitting the custom_json operation.
* @param author The author of the post.
* @param permlink The permlink of the post.
* @param undo if true Undo Reblurt else Reblurt
* @param key The Posting, Active or Owner private key of the account.
**/
reblurt(account: string, author: string, permlink: string, undo: boolean | undefined, key: PrivateKey): Promise<TransactionConfirmation>;
/** Broadcast a reblog custom_json operation. */
reblog(account: string, author: string, permlink: string, key: PrivateKey): Promise<TransactionConfirmation>;
/** Broadcast an undo-reblog custom_json operation. */
undoReblog(account: string, author: string, permlink: string, key: PrivateKey): Promise<TransactionConfirmation>;
/** Broadcast a follow custom_json operation. */
follow(follower: string, following: string, key: PrivateKey): Promise<TransactionConfirmation>;
/** Broadcast an unfollow custom_json operation. */
unfollow(follower: string, following: string, key: PrivateKey): Promise<TransactionConfirmation>;
/** Broadcast a mute custom_json operation using the follow/ignore convention. */
mute(follower: string, following: string, key: PrivateKey): Promise<TransactionConfirmation>;
/** Broadcast an unmute custom_json operation using the empty follow-list convention. */
unmute(follower: string, following: string, key: PrivateKey): Promise<TransactionConfirmation>;
/** Broadcast a read notification to the network. */
readNotification(account: string, date: string, key: PrivateKey): Promise<TransactionConfirmation>;
/** Broadcast a signed transaction to the network. */
send(transaction: SignedTransaction): Promise<TransactionConfirmation>;
/**
* Sign and broadcast transaction with operations to the network. Throws if the transaction expires.
* @param operations List of operations to send.
* @param key Private key(s) used to sign transaction.
*/
sendOperations(operations: Operation[], key: PrivateKey | PrivateKey[]): Promise<TransactionConfirmation>;
/** Sign a transaction with key(s) */
sign(transaction: Transaction, key: PrivateKey | PrivateKey[]): SignedTransaction;
/**
* Broadcast a transfer.
* @param data The transfer operation payload.
* @param key Private active key of sender.
*/
transfer(data: TransferOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Broadcast a vote.
* @param vote The vote to send.
* @param key Private posting key of the voter.
*/
vote(vote: VoteOperation[1], key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Mute a post (Mods or higher). Can be a topic or a comment.
* @param community The community account concerned.
* @param authority The account submitting the custom_json operation.
* @param account The author of the post.
* @param permlink The permlink of the post.
* @param notes short notes
* @param key The Posting, Active or Owner private key of the account.
*/
nexusMutePost(community: string, authority: string, account: string, permlink: string, notes: string, key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Stickies a post to the top of the community homepage (Mods or higher). If multiple posts are stickied, the newest ones are shown first.
* @param community The community account concerned.
* @param authority The account submitting the custom_json operation.
* @param account The author of the post.
* @param permlink The permlink of the post.
* @param key The Posting, Active or Owner private key of the account.
*/
nexusPinPost(community: string, authority: string, account: string, permlink: string, key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Stickies a post to the top of the community homepage (Mods or higher). If multiple posts are stickied, the newest ones are shown first.
* @param community The community account concerned.
* @param authority The account submitting the custom_json operation.
* @param account The account submitting the custom_json operation.
* @param role The author of the post.
* @param key The Posting, Active or Owner private key of the account.
*/
nexusSetRole(community: string, authority: string, account: string, role: 'admin' | 'mod' | 'member' | 'guest' | 'muted', key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Stickies a post to the top of the community homepage (Mods or higher). If multiple posts are stickied, the newest ones are shown first.
* @param community The community account concerned.
* @param authority The account submitting the custom_json operation.
* @param account The account submitting the custom_json operation.
* @param title title for the account
* @param key The Posting, Active or Owner private key of the account.
*/
nexusSetUserTitle(community: string, authority: string, account: string, title: string, key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Unmute a post (Mods or higher).
* @param community The community account concerned.
* @param authority The account submitting the custom_json operation.
* @param account The author of the post.
* @param permlink The permlink of the post.
* @param notes short notes
* @param key The Posting, Active or Owner private key of the account.
*/
nexusUnmutePost(community: string, authority: string, account: string, permlink: string, notes: string, key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Removes a post to the top of the community homepage (Mods or higher).
* @param community The community account concerned.
* @param authority The account submitting the custom_json operation.
* @param account The author of the post.
* @param permlink The permlink of the post.
* @param key The Posting, Active or Owner private key of the account.
*/
nexusUnpinPost(community: string, authority: string, account: string, permlink: string, key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Broadcast Nexus update properties (Admin Operations).
* Update display settings of a Community.
* @param data The custom_json operation payload. See {@link NexusUpdateProps}
* @param authority The account submitting the custom_json operation.
* @param key The Posting, Active or Owner private key of the account.
*/
nexusUpdateProps(data: NexusUpdateProps, authority: string, key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Used by guests to suggest a post for the review queue. Its up to the community to define what constitutes flagging.
* @param community The community account concerned.
* @param authority The account submitting the custom_json operation.
* @param account The author of the post.
* @param permlink The permlink of the post.
* @param notes short notes
* @param key The Posting, Active or Owner private key of the account.
*/
nexusFlagPost(community: string, authority: string, account: string, permlink: string, notes: string, key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Un/subscribe to a community (Guest Operations)
* @param community The community account concerned.
* @param action Un/subscribe to a community.
* @param account The account submitting the custom_json operation.
* @param key The Posting, Active or Owner private key of the account.
**/
nexusSubscription(community: string, action: 'subscribe' | 'unsubscribe', account: string, key: PrivateKey): Promise<TransactionConfirmation>;
/** Broadcast a community subscribe custom_json operation. */
communitySubscribe(account: string, community: string, key: PrivateKey): Promise<TransactionConfirmation>;
/** Broadcast a community unsubscribe custom_json operation. */
communityUnsubscribe(account: string, community: string, key: PrivateKey): Promise<TransactionConfirmation>;
/**
* Stickies a post to the top of the community homepage (Mods or higher). If multiple posts are stickied, the newest ones are shown first.
* @param authority The account submitting the custom_json operation.
* @param referrer The referrer of the account.
* @param campaign The campaign id of the referrer.
* @param key The Posting, Active or Owner private key of the account.
*/
nexusAddReferrer(authority: string, referrer: string, campaign: string, key: PrivateKey): Promise<TransactionConfirmation>;
}