/** * @file Hive account type definitions. * @author Johan Nordberg * @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 { PublicKey } from "../crypto.js"; import { Asset } from "./asset.js"; import { AppliedOperation } from "./operation.js"; /** * Raw Hive authority object. * * @remarks * Hive authorities combine weighted account references and public-key * references. A transaction is authorized when collected signatures and nested * authorities meet `weight_threshold`. * * @example * ```ts * const authority: AuthorityType = { * weight_threshold: 1, * account_auths: [], * key_auths: [[publicKey, 1]] * } * ``` */ export interface AuthorityType { weight_threshold: number; account_auths: [string, number][]; key_auths: [string | PublicKey, number][]; } /** * Convenience wrapper for Hive owner, active, and posting authorities. * * @remarks * `Authority` can be created from a single public key for simple one-signature * accounts or from a full weighted authority object for multisig setups. * * @example * ```ts * const posting = Authority.from(postingPublicKey) * ``` */ export declare class Authority implements AuthorityType { weight_threshold: number; account_auths: [string, number][]; key_auths: [string | PublicKey, number][]; /** * Creates an authority from explicit threshold and auth lists. * * @param authority - Raw authority fields from Hive. */ constructor({ weight_threshold, account_auths, key_auths }: AuthorityType); /** * Normalizes a public key or raw authority into an {@link Authority}. * * @param value - Public key string, {@link PublicKey}, existing authority, or * raw authority object. * @returns A normalized authority. * * @example * ```ts * const authority = Authority.from('STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA') * ``` */ static from(value: string | PublicKey | AuthorityType): Authority; } /** * Core Hive account object returned by condenser account lookups. * * @remarks * This shape includes authority keys, balances, savings balances, vesting * state, voting state, recovery metadata, and historical counters. Use * {@link ExtendedAccount} when condenser returns augmented social/history * fields. * * @example * ```ts * const [account] = await client.database.getAccounts(['srbde']) * console.log(account.balance, account.vesting_shares) * ``` */ export interface Account { id: number; name: string; owner: Authority; active: Authority; posting: Authority; memo_key: string; json_metadata: string; posting_json_metadata: string; proxy: string; last_owner_update: string; last_account_update: string; created: string; mined: boolean; owner_challenged: boolean; active_challenged: boolean; last_owner_proved: string; last_active_proved: string; recovery_account: string; reset_account: string; last_account_recovery: string; comment_count: number; lifetime_vote_count: number; post_count: number; can_vote: boolean; voting_power: number; last_vote_time: string; voting_manabar: { current_mana: string | number; last_update_time: number; }; balance: string | Asset; savings_balance: string | Asset; hbd_balance: string | Asset; hbd_seconds: string; hbd_seconds_last_update: string; hbd_last_interest_payment: string; savings_hbd_balance: string | Asset; savings_hbd_seconds: string; savings_hbd_seconds_last_update: string; savings_hbd_last_interest_payment: string; savings_withdraw_requests: number; reward_hbd_balance: string | Asset; reward_hive_balance: string | Asset; reward_vesting_balance: string | Asset; reward_vesting_hive: string | Asset; curation_rewards: number | string; posting_rewards: number | string; vesting_shares: string | Asset; delegated_vesting_shares: string | Asset; received_vesting_shares: string | Asset; vesting_withdraw_rate: string | Asset; next_vesting_withdrawal: string; withdrawn: number | string; to_withdraw: number | string; withdraw_routes: number; proxied_vsf_votes: number[]; witnesses_voted_for: number; average_bandwidth: number | string; lifetime_bandwidth: number | string; last_bandwidth_update: string; average_market_bandwidth: number | string; lifetime_market_bandwidth: number | string; last_market_bandwidth_update: string; last_post: string; last_root_post: string; } /** * Augmented account object returned by condenser `get_accounts`. * * @remarks * Extended accounts add reputation, converted vesting balance, witness votes, * and several legacy history collections used by social applications. * * @example * ```ts * const [account] = await client.database.getAccounts(['srbde']) * console.log(account.reputation, account.witness_votes) * ``` */ export interface ExtendedAccount extends Account { /** * Vesting shares converted to vesting HIVE for display. */ vesting_balance: string | Asset; reputation: string | number; /** * Transfer and vesting operation history. */ transfer_history: [number, AppliedOperation][]; /** * Limit order, cancel, and fill history. */ market_history: [number, AppliedOperation][]; post_history: [number, AppliedOperation][]; vote_history: [number, AppliedOperation][]; other_history: [number, AppliedOperation][]; witness_votes: string[]; tags_usage: string[]; guest_bloggers: string[]; open_orders?: unknown[]; comments?: string[]; blog?: string[]; feed?: string[]; recent_replies?: string[]; recommended?: string[]; }