/** * @file Misc hive 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 { Account } from "./account.js"; import { Asset, Price } from "./asset.js"; /** * Large integer returned as a string to avoid JavaScript precision loss. * * @example * ```ts * const value: Bignum = props.max_virtual_bandwidth * ``` */ export type Bignum = string; /** * Byte wrapper that serializes to a hex-encoded string. * * @remarks * Hive APIs frequently represent binary values as hex strings. `HexBuffer` * now stores a native `Uint8Array`, keeping protocol bytes available for * serializers without reintroducing Node `Buffer` as a core byte container. * * @example * ```ts * const bytes = HexBuffer.from('deadbeef') * console.log(bytes.toJSON()) * ``` */ export declare class HexBuffer { buffer: Uint8Array; /** * Creates a hex-buffer wrapper around native bytes. * * @param buffer - Raw binary data as a `Uint8Array`. */ constructor(buffer: Uint8Array); /** * Normalizes hex, bytes, or an existing wrapper into a {@link HexBuffer}. * * @param value - `Uint8Array`, existing wrapper, byte array, or hex string. * @returns A hex-buffer wrapper. * * @example * ```ts * const buffer = HexBuffer.from([0xde, 0xad, 0xbe, 0xef]) * ``` */ static from(value: Uint8Array | HexBuffer | number[] | string): HexBuffer; toString(encoding?: string): string; toJSON(): string; } /** * Chain properties voted on by Hive witnesses. * * @remarks * Witnesses publish these values and the chain uses the median active-witness * values for account creation fee, block capacity, and HBD interest. * * @example * ```ts * const props = await client.database.getChainProperties() * console.log(props.account_creation_fee) * ``` */ export interface ChainProperties { /** * This fee, paid in HIVE, is converted into VESTING SHARES for the new account. Accounts * without vesting shares cannot earn usage rations and therefore are powerless. This minimum * fee requires all accounts to have some kind of commitment to the network that includes the * ability to vote and make transactions. * * @remarks * This has to be multiplied by STEEMIT ? `CREATE_ACCOUNT_WITH_HIVE_MODIFIER` * (defined as 30 on the main chain) to get the minimum fee needed to create an account. * */ account_creation_fee: string | Asset; /** * This witnesses vote for the maximum_block_size which is used by the network * to tune rate limiting and capacity. */ maximum_block_size: number; /** * The HBD interest percentage rate decided by witnesses, expressed 0 to 10000. */ hbd_interest_rate: number; } /** * Vesting-share delegation from one account to another. * * @remarks * Delegated VESTS remain owned by the delegator but transfer voting influence * and RC capacity to the delegatee until removed and cooled down. * * @example * ```ts * const delegations = await client.database.getVestingDelegations('srbde') * console.log(delegations[0]?.delegatee) * ``` */ export interface VestingDelegation { /** * Delegation id. */ id: number; /** * Account that is delegating vests to delegatee. */ delegator: string; /** * Account that is receiving vests from delegator. */ delegatee: string; /** * Amount of VESTS delegated. */ vesting_shares: Asset | string; /** * Earliest date delegation can be removed. */ min_delegation_time: string; } /** * Dynamic global chain state reported by a Hive RPC node. * * @remarks * These values drive transaction TAPOS fields, stream cursors, supply displays, * voting-power calculations, witness participation dashboards, and bandwidth * estimates. * * @example * ```ts * const props = await client.database.getDynamicGlobalProperties() * console.log(props.head_block_number, props.last_irreversible_block_num) * ``` */ export interface DynamicGlobalProperties { id: number; /** * Current block height. */ head_block_number: number; head_block_id: string; /** * UTC Server time, e.g. 2020-01-15T00:42:00 */ time: string; /** * Currently elected witness. */ current_witness: string; /** * The total POW accumulated, aka the sum of num_pow_witness at the time * new POW is added. */ total_pow: number; /** * The current count of how many pending POW witnesses there are, determines * the difficulty of doing pow. */ num_pow_witnesses: number; virtual_supply: Asset | string; current_supply: Asset | string; /** * Total asset held in confidential balances. */ confidential_supply: Asset | string; current_hbd_supply: Asset | string; /** * Total asset held in confidential balances. */ confidential_hbd_supply: Asset | string; total_vesting_fund_hive: Asset | string; total_vesting_shares: Asset | string; total_reward_fund_hive: Asset | string; /** * The running total of REWARD^2. */ total_reward_shares2: string; pending_rewarded_vesting_shares: Asset | string; pending_rewarded_vesting_hive: Asset | string; /** * This property defines the interest rate that HBD deposits receive. */ hbd_interest_rate: number; hbd_print_rate: number; /** * Average block size is updated every block to be: * * average_block_size = (99 * average_block_size + new_block_size) / 100 * * This property is used to update the current_reserve_ratio to maintain * approximately 50% or less utilization of network capacity. */ average_block_size: number; /** * Maximum block size is decided by the set of active witnesses which change every round. * Each witness posts what they think the maximum size should be as part of their witness * properties, the median size is chosen to be the maximum block size for the round. * * @remarks * The minimum value for maximum_block_size is defined by the protocol to prevent the * network from getting stuck by witnesses attempting to set this too low. */ maximum_block_size: number; /** * The current absolute slot number. Equal to the total * number of slots since genesis. Also equal to the total * number of missed slots plus head_block_number. */ current_aslot: number; /** * Used to compute witness participation. */ recent_slots_filled: Bignum; participation_count: number; last_irreversible_block_num: number; /** * The maximum bandwidth the blockchain can support is: * * max_bandwidth = maximum_block_size * BANDWIDTH_AVERAGE_WINDOW_SECONDS / BLOCK_INTERVAL * * The maximum virtual bandwidth is: * * max_bandwidth * current_reserve_ratio */ max_virtual_bandwidth: Bignum; /** * Any time average_block_size <= 50% maximum_block_size this value grows by 1 until it * reaches MAX_RESERVE_RATIO. Any time average_block_size is greater than * 50% it falls by 1%. Upward adjustments happen once per round, downward adjustments * happen every block. */ current_reserve_ratio: number; /** * The number of votes regenerated per day. Any user voting slower than this rate will be * "wasting" voting power through spillover; any user voting faster than this rate will have * their votes reduced. */ vote_power_reserve_rate: number; } /** * Calculates the HIVE/VESTS conversion price from global properties. * * @param props - Dynamic global properties containing total vesting fund and * total vesting shares. * @returns A price that converts between VESTS and HIVE. * * @remarks * Hive expresses influence in VESTS while users often reason about powered-up * HIVE. If either side of the vesting pool is zero, Pollen returns a neutral * 1:1 fallback price to keep downstream math defined. * * @example * ```ts * const props = await client.database.getDynamicGlobalProperties() * const vestingPrice = getVestingSharePrice(props) * ``` */ export declare function getVestingSharePrice(props: DynamicGlobalProperties): Price; /** * Calculates an account's effective vesting shares. * * @param account - Account containing vesting, delegation, and withdrawal * fields. * @param subtract_delegated - Whether outgoing delegations should reduce the * result. * @param add_received - Whether incoming delegations should increase the * result. * @returns Effective VESTS amount as a number. * * @remarks * The calculation subtracts pending power-down withdrawals, then optionally * adjusts for delegated and received vesting shares. RC and voting mana helpers * use this to derive maximum voting mana. * * @example * ```ts * const [account] = await client.database.getAccounts(['srbde']) * const effectiveVests = getVests(account) * ``` */ export declare function getVests(account: Account, subtract_delegated?: boolean, add_received?: boolean): number;