@steempro/dsteem
Version:
Steem blockchain RPC client library
1,292 lines (1,283 loc) • 116 kB
TypeScript
declare module 'dsteem/version' {
const _default: string;
export default _default;
}
declare module 'dsteem/chain/asset' {
/**
* @file Steem asset type definitions and helpers.
* @author Johan Nordberg <code@johan-nordberg.com>
* @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.
*/
export interface SMTAsset {
amount: string | number;
precision: number;
nai: string;
}
/**
* Asset symbol string.
*/
export type AssetSymbol = "VESTS" | "TESTS" | "TBD" | "STEEM" | "SBD";
/**
* Class representing a steem asset, e.g. `1.000 STEEM` or `12.112233 VESTS`.
*/
export class Asset {
readonly amount: number;
readonly symbol: AssetSymbol;
constructor(amount: number, symbol: AssetSymbol);
/**
* Create a new Asset instance from a string, e.g. `42.000 STEEM`.
*/
static fromString(string: string, expectedSymbol?: AssetSymbol): Asset;
/**
* Convenience to create new Asset.
* @param symbol Symbol to use when created from number. Will also be used to validate
* the asset, throws if the passed value has a different symbol than this.
*/
static from(value: string | Asset | number, symbol?: AssetSymbol): Asset;
/**
* Return the smaller of the two assets.
*/
static min(a: Asset, b: Asset): Asset;
/**
* Return the larger of the two assets.
*/
static max(a: Asset, b: Asset): Asset;
/**
* Return asset precision.
*/
getPrecision(): number;
/**
* returns a representation of this asset using only STEEM SBD for
* legacy purposes
*/
steem_symbols(): Asset;
/**
* Return a string representation of this asset, e.g. `42.000 STEEM`.
*/
toString(): string;
/**
* Return a new Asset instance with amount added.
*/
add(amount: Asset | string | number): Asset;
/**
* Return a new Asset instance with amount subtracted.
*/
subtract(amount: Asset | string | number): Asset;
/**
* Return a new Asset with the amount multiplied by factor.
*/
multiply(factor: Asset | string | number): Asset;
/**
* Return a new Asset with the amount divided.
*/
divide(divisor: Asset | string | number): Asset;
/**
* For JSON serialization, same as toString().
*/
toJSON(): string;
}
export type PriceType = Price | {
base: Asset | string;
quote: Asset | string;
};
/**
* Represents quotation of the relative value of asset against another asset.
* Similar to 'currency pair' used to determine value of currencies.
*
* For example:
* 1 EUR / 1.25 USD where:
* 1 EUR is an asset specified as a base
* 1.25 USD us an asset specified as a qute
*
* can determine value of EUR against USD.
*/
export class Price {
readonly base: Asset;
readonly quote: Asset;
/**
* @param base - represents a value of the price object to be expressed relatively to quote
* asset. Cannot have amount == 0 if you want to build valid price.
* @param quote - represents an relative asset. Cannot have amount == 0, otherwise
* asertion fail.
*
* Both base and quote shall have different symbol defined.
*/
constructor(base: Asset, quote: Asset);
/**
* Convenience to create new Price.
*/
static from(value: PriceType): Price;
/**
* Return a string representation of this price pair.
*/
toString(): string;
/**
* Return a new Asset with the price converted between the symbols in the pair.
* Throws if passed asset symbol is not base or quote.
*/
convert(asset: Asset): Asset;
}
}
declare module 'dsteem/chain/account' {
/**
* @file Steem account type definitions.
* @author Johan Nordberg <code@johan-nordberg.com>
* @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 'dsteem/crypto';
import { Asset } from 'dsteem/chain/asset';
export interface AuthorityType {
weight_threshold: number;
account_auths: [string, number][];
key_auths: [string | PublicKey, number][];
}
export class Authority implements AuthorityType {
weight_threshold: number;
account_auths: [string, number][];
key_auths: [string | PublicKey, number][];
constructor({ weight_threshold, account_auths, key_auths }: AuthorityType);
/**
* Convenience to create a new instance from PublicKey or authority object.
*/
static from(value: string | PublicKey | AuthorityType): Authority;
}
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;
sbd_balance: string | Asset;
sbd_seconds: string;
sbd_seconds_last_update: string;
sbd_last_interest_payment: string;
savings_sbd_balance: string | Asset;
savings_sbd_seconds: string;
savings_sbd_seconds_last_update: string;
savings_sbd_last_interest_payment: string;
savings_withdraw_requests: number;
reward_sbd_balance: string | Asset;
reward_steem_balance: string | Asset;
reward_vesting_balance: string | Asset;
reward_vesting_steem: 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;
}
export interface ExtendedAccount extends Account {
/**
* Convert vesting_shares to vesting steem.
*/
vesting_balance: string | Asset;
reputation: string | number;
/**
* Transfer to/from vesting.
*/
transfer_history: any[];
/**
* Limit order / cancel / fill.
*/
market_history: any[];
post_history: any[];
vote_history: any[];
other_history: any[];
witness_votes: string[];
tags_usage: string[];
guest_bloggers: string[];
open_orders?: any[];
comments?: any[];
blog?: any[];
feed?: any[];
recent_replies?: any[];
recommended?: any[];
}
}
declare module 'dsteem/chain/misc' {
/// <reference types="node" />
/**
* @file Misc steem type definitions.
* @author Johan Nordberg <code@johan-nordberg.com>
* @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 'dsteem/chain/account';
import { Asset, Price } from 'dsteem/chain/asset';
/**
* Large number that may be unsafe to represent natively in JavaScript.
*/
export type Bignum = string;
/**
* Buffer wrapper that serializes to a hex-encoded string.
*/
export class HexBuffer {
buffer: Buffer;
constructor(buffer: Buffer);
/**
* Convenience to create a new HexBuffer, does not copy data if value passed is already a buffer.
*/
static from(value: Buffer | HexBuffer | number[] | string): HexBuffer;
toString(encoding?: string): string;
toJSON(): string;
}
/**
* Chain roperties that are decided by the witnesses.
*/
export interface ChainProperties {
/**
* This fee, paid in STEEM, 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.
*
* @note This has to be multiplied by STEEMIT ? `CREATE_ACCOUNT_WITH_STEEM_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 SBD interest percentage rate decided by witnesses, expressed 0 to 10000.
*/
sbd_interest_rate: number;
}
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;
}
/**
* Node state.
*/
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_sbd_supply: Asset | string;
/**
* Total asset held in confidential balances.
*/
confidential_sbd_supply: Asset | string;
total_vesting_fund_steem: Asset | string;
total_vesting_shares: Asset | string;
total_reward_fund_steem: Asset | string;
/**
* The running total of REWARD^2.
*/
total_reward_shares2: string;
pending_rewarded_vesting_shares: Asset | string;
pending_rewarded_vesting_steem: Asset | string;
/**
* This property defines the interest rate that SBD deposits receive.
*/
sbd_interest_rate: number;
sbd_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.
*
* @note 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;
}
/**
* Return the vesting share price.
*/
export function getVestingSharePrice(props: DynamicGlobalProperties): Price;
/**
* Returns the vests of specified account. Default: Subtract delegated & add received
*/
export function getVests(account: Account, subtract_delegated?: boolean, add_received?: boolean): number;
}
declare module 'dsteem/chain/serializer' {
/**
* @file Steem protocol serialization.
* @author Johan Nordberg <code@johan-nordberg.com>
* @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.
*/
/// <reference types="node" />
import * as ByteBuffer from "@steempro/bytebuffer";
import { PublicKey } from 'dsteem/crypto';
import { Asset } from 'dsteem/chain/asset';
import { HexBuffer } from 'dsteem/chain/misc';
import { Operation } from 'dsteem/chain/operation';
export type Serializer = (buffer: ByteBuffer, data: any) => void;
export const Types: {
Array: (itemSerializer: Serializer) => (buffer: any, data: any[]) => void;
Asset: (buffer: any, data: Asset | string | number) => void;
Authority: (buffer: any, data: {
[key: string]: any;
}) => void;
Binary: (size?: number | undefined) => (buffer: any, data: Buffer | HexBuffer) => void;
Boolean: (buffer: any, data: boolean) => void;
Date: (buffer: any, data: string) => void;
EncryptedMemo: (buffer: any, data: {
[key: string]: any;
}) => void;
FlatMap: (keySerializer: Serializer, valueSerializer: Serializer) => (buffer: any, data: [any, any][]) => void;
Int16: (buffer: any, data: number) => void;
Int32: (buffer: any, data: number) => void;
Int64: (buffer: any, data: number) => void;
Int8: (buffer: any, data: number) => void;
Object: (keySerializers: [string, Serializer][]) => (buffer: any, data: {
[key: string]: any;
}) => void;
Operation: (buffer: any, operation: Operation) => void;
Optional: (valueSerializer: Serializer) => (buffer: any, data: any) => void;
Price: (buffer: any, data: {
[key: string]: any;
}) => void;
PublicKey: (buffer: any, data: PublicKey | string | null) => void;
StaticVariant: (itemSerializers: Serializer[]) => (buffer: any, data: [number, any]) => void;
String: (buffer: any, data: string) => void;
Transaction: (buffer: any, data: {
[key: string]: any;
}) => void;
UInt16: (buffer: any, data: number) => void;
UInt32: (buffer: any, data: number) => void;
UInt64: (buffer: any, data: number) => void;
UInt8: (buffer: any, data: number) => void;
Void: (buffer: any) => never;
};
}
declare module 'dsteem/chain/transaction' {
/**
* @file Steem transaction type definitions.
* @author Johan Nordberg <code@johan-nordberg.com>
* @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 { Operation } from 'dsteem/chain/operation';
export interface Transaction {
ref_block_num: number;
ref_block_prefix: number;
expiration: string;
operations: Operation[];
extensions: any[];
}
export interface SignedTransaction extends Transaction {
signatures: string[];
}
export interface TransactionConfirmation {
id: string;
block_num: number;
trx_num: number;
expired: boolean;
}
}
declare module 'dsteem/crypto' {
/**
* @file Steem crypto helpers.
* @author Johan Nordberg <code@johan-nordberg.com>
* @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.
*/
/// <reference types="node" />
import * as ByteBuffer from "@steempro/bytebuffer";
import { SignedTransaction, Transaction } from 'dsteem/chain/transaction';
/**
* Network id used in WIF-encoding.
*/
export const NETWORK_ID: Buffer; function ripemd160(input: Buffer | string): Buffer; function sha256(input: Buffer | string): Buffer; function doubleSha256(input: Buffer | string): Buffer; function encodePublic(key: Buffer, prefix: string): string; function encodePrivate(key: Buffer): string; function decodePrivate(encodedKey: string): Buffer; function isCanonicalSignature(signature: Buffer): boolean; function isWif(privWif: string | Buffer): boolean;
/**
* ECDSA (secp256k1) public key.
*/
export class PublicKey {
readonly key: any;
readonly prefix: string;
readonly uncompressed: Buffer;
constructor(key: any, prefix?: string);
static fromBuffer(key: ByteBuffer): {
key: any;
};
/**
* Create a new instance from a WIF-encoded key.
*/
static fromString(wif: string): PublicKey;
/**
* Create a new instance.
*/
static from(value: string | PublicKey): PublicKey;
/**
* Verify a 32-byte signature.
* @param message 32-byte message to verify.
* @param signature Signature to verify.
*/
verify(message: Buffer, signature: Signature): boolean;
/**
* Return a WIF-encoded representation of the key.
*/
toString(): string;
/**
* Return JSON representation of this key, same as toString().
*/
toJSON(): string;
/**
* Used by `utils.inspect` and `console.log` in node.js.
*/
inspect(): string;
}
export type KeyRole = "owner" | "active" | "posting" | "memo";
/**
* ECDSA (secp256k1) private key.
*/
export class PrivateKey {
private key;
secret: Buffer;
constructor(key: Buffer);
/**
* Convenience to create a new instance from WIF string or buffer.
*/
static from(value: string | Buffer): PrivateKey;
/**
* Create a new instance from a WIF-encoded key.
*/
static fromString(wif: string): PrivateKey;
/**
* Create a new instance from a seed.
*/
static fromSeed(seed: string): PrivateKey;
/**
* Create key from username and password.
*/
static fromLogin(username: string, password: string, role?: KeyRole): PrivateKey;
multiply(pub: any): Buffer;
/**
* Sign message.
* @param message 32-byte message.
*/
sign(message: Buffer): Signature;
/**
* Derive the public key for this private key.
*/
createPublic(prefix?: string): PublicKey;
/**
* Return a WIF-encoded representation of the key.
*/
toString(): string;
/**
* Used by `utils.inspect` and `console.log` in node.js. Does not show the full key
* to get the full encoded key you need to explicitly call {@link toString}.
*/
inspect(): string;
/**
* Get shared secret for memo cryptography
*/
get_shared_secret(public_key: PublicKey): Buffer;
}
/**
* ECDSA (secp256k1) signature.
*/
export class Signature {
data: Buffer;
recovery: number;
constructor(data: Buffer, recovery: number);
static fromBuffer(buffer: Buffer): Signature;
static fromString(string: string): Signature;
/**
* Recover public key from signature by providing original signed message.
* @param message 32-byte message that was used to create the signature.
*/
recover(message: Buffer, prefix?: string): PublicKey;
toBuffer(): Buffer;
toString(): string;
} function transactionDigest(transaction: Transaction | SignedTransaction, chainId?: Buffer): Buffer; function signTransaction(transaction: Transaction, keys: PrivateKey | PrivateKey[], chainId?: Buffer): SignedTransaction; function generateTrxId(transaction: Transaction): string;
/** Misc crypto utility functions. */
export const cryptoUtils: {
decodePrivate: typeof decodePrivate;
doubleSha256: typeof doubleSha256;
encodePrivate: typeof encodePrivate;
encodePublic: typeof encodePublic;
generateTrxId: typeof generateTrxId;
isCanonicalSignature: typeof isCanonicalSignature;
isWif: typeof isWif;
ripemd160: typeof ripemd160;
sha256: typeof sha256;
signTransaction: typeof signTransaction;
transactionDigest: typeof transactionDigest;
};
export {};
}
declare module 'dsteem/chain/block' {
/**
* @file Steem block type definitions.
* @author Johan Nordberg <code@johan-nordberg.com>
* @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 { Transaction } from 'dsteem/chain/transaction';
/**
* Unsigned block header.
*/
export interface BlockHeader {
previous: string;
timestamp: string;
witness: string;
transaction_merkle_root: string;
extensions: any[];
}
/**
* Signed block header.
*/
export interface SignedBlockHeader extends BlockHeader {
witness_signature: string;
}
/**
* Full signed block.
*/
export interface SignedBlock extends SignedBlockHeader {
block_id: string;
signing_key: string;
transaction_ids: string[];
transactions: Transaction[];
}
}
declare module 'dsteem/chain/comment' {
/**
* @file Steem type definitions related to comments and posting.
* @author Johan Nordberg <code@johan-nordberg.com>
* @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 { Asset } from 'dsteem/chain/asset';
export interface Comment {
id: number;
category: string;
parent_author: string;
parent_permlink: string;
author: string;
permlink: string;
title: string;
body: string;
json_metadata: string;
last_update: string;
created: string;
active: string;
last_payout: string;
depth: number;
children: number;
net_rshares: string;
abs_rshares: string;
vote_rshares: string;
children_abs_rshares: string;
cashout_time: string;
max_cashout_time: string;
total_vote_weight: number;
reward_weight: number;
total_payout_value: Asset | string;
curator_payout_value: Asset | string;
author_rewards: string;
net_votes: number;
root_comment: number;
max_accepted_payout: string;
percent_steem_dollars: number;
allow_replies: boolean;
allow_votes: boolean;
allow_curation_rewards: boolean;
beneficiaries: BeneficiaryRoute[];
}
/**
* Discussion a.k.a. Post.
*/
export interface Discussion extends Comment {
url: string;
root_title: string;
pending_payout_value: Asset | string;
total_pending_payout_value: Asset | string;
active_votes: any[];
replies: string[];
author_reputation: number;
promoted: Asset | string;
body_length: string;
reblogged_by: any[];
first_reblogged_by?: any;
first_reblogged_on?: any;
}
export interface BeneficiaryRoute {
account: string;
weight: number;
}
}
declare module 'dsteem/chain/operation' {
/**
* @file Steem operation type definitions.
* @author Johan Nordberg <code@johan-nordberg.com>
* @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.
*/
/// <reference types="node" />
import { PublicKey } from 'dsteem/crypto';
import { AuthorityType } from 'dsteem/chain/account';
import { Asset, PriceType } from 'dsteem/chain/asset';
import { SignedBlockHeader } from 'dsteem/chain/block';
import { BeneficiaryRoute } from 'dsteem/chain/comment';
import { ChainProperties, HexBuffer } from 'dsteem/chain/misc';
/**
* Operation name.
* Ref: https://github.com/steemit/steem/blob/main/libraries/protocol/include/steem/protocol/operations.hpp
*/
export type OperationName = "vote" | "comment" | "transfer" | "transfer_to_vesting" | "withdraw_vesting" | "limit_order_create" | "limit_order_cancel" | "feed_publish" | "convert" | "account_create" | "account_update" | "witness_update" | "account_witness_vote" | "account_witness_proxy" | "pow" | "custom" | "report_over_production" | "delete_comment" | "custom_json" | "comment_options" | "set_withdraw_vesting_route" | "limit_order_create2" | "claim_account" | "create_claimed_account" | "request_account_recovery" | "recover_account" | "change_recovery_account" | "escrow_transfer" | "escrow_dispute" | "escrow_release" | "pow2" | "escrow_approve" | "transfer_to_savings" | "transfer_from_savings" | "cancel_transfer_from_savings" | "custom_binary" | "decline_voting_rights" | "reset_account" | "set_reset_account" | "claim_reward_balance" | "delegate_vesting_shares" | "account_create_with_delegation" | "witness_set_properties" | "account_update2" | "create_proposal" | "update_proposal_votes" | "remove_proposal" | "update_proposal";
/**
* Virtual operation name.
*/
export type VirtualOperationName = "fill_convert_request" | "author_reward" | "curation_reward" | "comment_reward" | "liquidity_reward" | "interest" | "fill_vesting_withdraw" | "fill_order" | "shutdown_witness" | "fill_transfer_from_savings" | "hardfork" | "comment_payout_update" | "return_vesting_delegation" | "comment_benefactor_reward" | "producer_reward" | "clear_null_account_balance" | "proposal_pay" | "sps_fund";
/**
* Generic operation.
*/
export interface Operation {
0: OperationName | VirtualOperationName;
1: {
[key: string]: any;
};
}
export interface AppliedOperation {
trx_id: string;
block: number;
trx_in_block: number;
op_in_trx: number;
virtual_op: number;
timestamp: string;
op: Operation;
}
export interface AccountCreateOperation extends Operation {
0: "account_create";
1: {
fee: string | Asset;
creator: string;
new_account_name: string;
owner: AuthorityType;
active: AuthorityType;
posting: AuthorityType;
memo_key: string | PublicKey;
json_metadata: string;
};
}
export interface AccountCreateWithDelegationOperation extends Operation {
0: "account_create_with_delegation";
1: {
fee: string | Asset;
delegation: string | Asset;
creator: string;
new_account_name: string;
owner: AuthorityType;
active: AuthorityType;
posting: AuthorityType;
memo_key: string | PublicKey;
json_metadata: string;
/**
* Extensions. Not currently used.
*/
extensions: any[];
};
}
export interface AccountUpdateOperation extends Operation {
0: "account_update";
1: {
account: string;
owner?: AuthorityType;
active?: AuthorityType;
posting?: AuthorityType;
memo_key: string | PublicKey;
json_metadata: string;
};
}
export interface AccountWitnessProxyOperation extends Operation {
0: "account_witness_proxy";
1: {
account: string;
proxy: string;
};
}
export interface AccountWitnessVoteOperation extends Operation {
0: "account_witness_vote";
1: {
account: string;
witness: string;
approve: boolean;
};
}
export interface CancelTransferFromSavingsOperation extends Operation {
0: "cancel_transfer_from_savings";
1: {
from: string;
request_id: number;
};
}
/**
* Each account lists another account as their recovery account.
* The recovery account has the ability to create account_recovery_requests
* for the account to recover. An account can change their recovery account
* at any time with a 30 day delay. This delay is to prevent
* an attacker from changing the recovery account to a malicious account
* during an attack. These 30 days match the 30 days that an
* owner authority is valid for recovery purposes.
*
* On account creation the recovery account is set either to the creator of
* the account (The account that pays the creation fee and is a signer on the transaction)
* or to the empty string if the account was mined. An account with no recovery
* has the top voted witness as a recovery account, at the time the recover
* request is created. Note: This does mean the effective recovery account
* of an account with no listed recovery account can change at any time as
* witness vote weights. The top voted witness is explicitly the most trusted
* witness according to stake.
*/
export interface ChangeRecoveryAccountOperation extends Operation {
0: "change_recovery_account";
1: {
/**
* The account that would be recovered in case of compromise.
*/
account_to_recover: string;
/**
* The account that creates the recover request.
*/
new_recovery_account: string;
/**
* Extensions. Not currently used.
*/
extensions: any[];
};
}
export interface ClaimRewardBalanceOperation extends Operation {
0: "claim_reward_balance";
1: {
account: string;
reward_steem: string | Asset;
reward_sbd: string | Asset;
reward_vests: string | Asset;
};
}
export interface ClaimAccountOperation extends Operation {
0: "claim_account";
1: {
creator: string;
fee: string | Asset;
/**
* Extensions. Not currently used.
*/
extensions: any[];
};
}
export interface CommentOperation extends Operation {
0: "comment";
1: {
parent_author: string;
parent_permlink: string;
author: string;
permlink: string;
title: string;
body: string;
json_metadata: string;
};
}
export interface CommentOptionsOperation extends Operation {
0: "comment_options";
1: {
author: string;
permlink: string;
/** SBD value of the maximum payout this post will receive. */
max_accepted_payout: Asset | string;
/** The percent of Steem Dollars to key, unkept amounts will be received as Steem Power. */
percent_steem_dollars: number;
/** Whether to allow post to receive votes. */
allow_votes: boolean;
/** Whether to allow post to recieve curation rewards. */
allow_curation_rewards: boolean;
extensions: [0, {
beneficiaries: BeneficiaryRoute[];
}][];
};
}
export interface ConvertOperation extends Operation {
0: "convert";
1: {
owner: string;
requestid: number;
amount: Asset | string;
};
}
export interface CreateClaimedAccountOperation extends Operation {
0: "create_claimed_account";
1: {
creator: string;
new_account_name: string;
owner: AuthorityType;
active: AuthorityType;
posting: AuthorityType;
memo_key: string | PublicKey;
json_metadata: string;
/**
* Extensions. Not currently used.
*/
extensions: any[];
};
}
export interface CustomOperation extends Operation {
0: "custom";
1: {
required_auths: string[];
id: number;
data: Buffer | HexBuffer | number[];
};
}
export interface CustomBinaryOperation extends Operation {
0: "custom_binary";
1: {
required_owner_auths: string[];
required_active_auths: string[];
required_posting_auths: string[];
required_auths: AuthorityType[];
/**
* ID string, must be less than 32 characters long.
*/
id: string;
data: Buffer | HexBuffer | number[];
};
}
export interface CustomJsonOperation extends Operation {
0: "custom_json";
1: {
required_auths: string[];
required_posting_auths: string[];
/**
* ID string, must be less than 32 characters long.
*/
id: string;
/**
* JSON encoded string, must be valid JSON.
*/
json: string;
};
}
export interface DeclineVotingRightsOperation extends Operation {
0: "decline_voting_rights";
1: {
account: string;
decline: boolean;
};
}
export interface DelegateVestingSharesOperation extends Operation {
0: "delegate_vesting_shares";
1: {
/**
* The account delegating vesting shares.
*/
delegator: string;
/**
* The account receiving vesting shares.
*/
delegatee: string;
/**
* The amount of vesting shares delegated.
*/
vesting_shares: string | Asset;
};
}
export interface DeleteCommentOperation extends Operation {
0: "delete_comment";
1: {
author: string;
permlink: string;
};
}
/**
* The agent and to accounts must approve an escrow transaction for it to be valid on
* the blockchain. Once a part approves the escrow, the cannot revoke their approval.
* Subsequent escrow approve operations, regardless of the approval, will be rejected.
*/
export interface EscrowApproveOperation extends Operation {
0: "escrow_approve";
1: {
from: str