Commit b51c2533 authored by Johan Nordberg's avatar Johan Nordberg

Version 0.11.0

parent 641aedb2
......@@ -38,6 +38,11 @@ declare module 'dsteem/steem/asset' {
* 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.
*/
......@@ -138,8 +143,156 @@ declare module 'dsteem/steem/asset' {
convert(asset: Asset): Asset;
}
}
declare module 'dsteem/steem/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/steem/asset';
export interface AuthorityType {
weight_threshold: number;
account_auths: Array<[string, number]>;
key_auths: Array<[string | PublicKey, number]>;
}
export class Authority implements AuthorityType {
/**
* Convenience to create a new instance from PublicKey or authority object.
*/
static from(value: string | PublicKey | AuthorityType): Authority;
weight_threshold: number;
account_auths: Array<[string, number]>;
key_auths: Array<[string | PublicKey, number]>;
constructor({ weight_threshold, account_auths, key_auths }: AuthorityType);
}
export interface Account {
id: number;
name: string;
owner: Authority;
active: Authority;
posting: Authority;
memo_key: string;
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/steem/misc' {
/// <reference types="node" />
/**
* @file Misc steem type definitions.
* @author Johan Nordberg <code@johan-nordberg.com>
......@@ -174,7 +327,7 @@ declare module 'dsteem/steem/misc' {
* 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 { Account } from 'dsteem/steem/account';
import { Asset, Price } from 'dsteem/steem/asset';
/**
* Large number that may be unsafe to represent natively in JavaScript.
......@@ -351,6 +504,10 @@ declare module 'dsteem/steem/misc' {
* 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/steem/serializer' {
......@@ -653,149 +810,6 @@ declare module 'dsteem/crypto' {
};
export {};
}
declare module 'dsteem/steem/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/steem/asset';
export interface AuthorityType {
weight_threshold: number;
account_auths: Array<[string, number]>;
key_auths: Array<[string | PublicKey, number]>;
}
export class Authority implements AuthorityType {
/**
* Convenience to create a new instance from PublicKey or authority object.
*/
static from(value: string | PublicKey | AuthorityType): Authority;
weight_threshold: number;
account_auths: Array<[string, number]>;
key_auths: Array<[string | PublicKey, number]>;
constructor({ weight_threshold, account_auths, key_auths }: AuthorityType);
}
export interface Account {
id: number;
name: string;
owner: Authority;
active: Authority;
posting: Authority;
memo_key: string;
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;
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/steem/comment' {
/**
......@@ -2227,6 +2241,108 @@ declare module 'dsteem/helpers/database' {
verifyAuthority(stx: SignedTransaction): Promise<boolean>;
}
}
declare module 'dsteem/steem/rc' {
import { SMTAsset } from 'dsteem/steem/asset';
import { Bignum } from 'dsteem/steem/misc';
export interface RCParams {
resource_history_bytes: Resource;
resource_new_accounts: Resource;
resource_market_bytes: Resource;
resource_state_bytes: Resource;
resource_execution_time: Resource;
}
export interface Resource {
resource_dynamics_params: DynamicParam;
price_curve_params: PriceCurveParam;
}
export interface DynamicParam {
resource_unit: number;
budget_per_time_unit: number;
pool_eq: Bignum;
max_pool_size: Bignum;
decay_params: {
decay_per_time_unit: Bignum;
decay_per_time_unit_denom_shift: number;
};
min_decay: number;
}
export interface PriceCurveParam {
coeff_a: Bignum;
coeff_b: Bignum;
shift: number;
}
export interface RCPool {
resource_history_bytes: Pool;
resource_new_accounts: Pool;
resource_market_bytes: Pool;
resource_state_bytes: Pool;
resource_execution_time: Pool;
}
export interface Pool {
pool: Bignum;
}
export interface RCAccount {
account: string;
rc_manabar: {
current_mana: Bignum;
last_update_time: number;
};
max_rc_creation_adjustment: SMTAsset | string;
max_rc: Bignum;
}
export interface Manabar {
current_mana: number;
max_mana: number;
percentage: number;
}
}
declare module 'dsteem/helpers/rc' {
import { Client } from 'dsteem/client';
import { Account } from 'dsteem/steem/account';
import { Manabar, RCAccount, RCParams, RCPool } from 'dsteem/steem/rc';
export class RCAPI {
readonly client: Client;
constructor(client: Client);
/**
* Convenience for calling `rc_api`.
*/
call(method: string, params?: any): Promise<any>;
/**
* Returns RC data for array of usernames
*/
findRCAccounts(usernames: string[]): Promise<RCAccount[]>;
/**
* Returns the global resource params
*/
getResourceParams(): Promise<RCParams>;
/**
* Returns the global resource pool
*/
getResourcePool(): Promise<RCPool>;
/**
* Makes a API call and returns the RC mana-data for a specified username
*/
getRCMana(username: string): Promise<Manabar>;
/**
* Makes a API call and returns the VP mana-data for a specified username
*/
getVPMana(username: string): Promise<Manabar>;
/**
* Calculates the RC mana-data based on an RCAccount - findRCAccounts()
*/
calculateRCMana(rc_account: RCAccount): Manabar;
/**
* Calculates the RC mana-data based on an Account - getAccounts()
*/
calculateVPMana(account: Account): Manabar;
/**
* Internal convenience method to reduce redundant code
*/
private _calculateManabar;
}
}
declare module 'dsteem/client' {
/**
......@@ -2267,6 +2383,7 @@ declare module 'dsteem/client' {
import { Blockchain } from 'dsteem/helpers/blockchain';
import { BroadcastAPI } from 'dsteem/helpers/broadcast';
import { DatabaseAPI } from 'dsteem/helpers/database';
import { RCAPI } from 'dsteem/helpers/rc';
/**
* Library version.
*/
......@@ -2335,6 +2452,10 @@ declare module 'dsteem/client' {
* Database API helper.
*/
readonly database: DatabaseAPI;
/**
* RC API helper.
*/
readonly rc: RCAPI;
/**
* Broadcast API helper.
*/
......@@ -2410,6 +2531,7 @@ declare module 'dsteem' {
export { utils };
export * from 'dsteem/helpers/blockchain';
export * from 'dsteem/helpers/database';
export * from 'dsteem/helpers/rc';
export * from 'dsteem/steem/account';
export * from 'dsteem/steem/asset';
export * from 'dsteem/steem/block';
......
This diff is collapsed.
No preview for this file type
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -129,7 +129,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L101">steem/asset.ts:101</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L107">steem/asset.ts:107</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
......@@ -154,7 +154,7 @@
<div class="tsd-signature tsd-kind-icon">amount<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L103">steem/asset.ts:103</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L109">steem/asset.ts:109</a></li>
</ul>
</aside>
</section>
......@@ -164,7 +164,7 @@
<div class="tsd-signature tsd-kind-icon">symbol<span class="tsd-signature-symbol">:</span> <a href="../globals.html#assetsymbol" class="tsd-signature-type">AssetSymbol</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L103">steem/asset.ts:103</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L109">steem/asset.ts:109</a></li>
</ul>
</aside>
</section>
......@@ -181,7 +181,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L130">steem/asset.ts:130</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L136">steem/asset.ts:136</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -209,7 +209,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L157">steem/asset.ts:157</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L163">steem/asset.ts:163</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -237,7 +237,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L108">steem/asset.ts:108</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L114">steem/asset.ts:114</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -259,7 +259,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L148">steem/asset.ts:148</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L154">steem/asset.ts:154</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -287,7 +287,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L139">steem/asset.ts:139</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L145">steem/asset.ts:145</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -315,7 +315,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L166">steem/asset.ts:166</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L172">steem/asset.ts:172</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -337,7 +337,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L123">steem/asset.ts:123</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L129">steem/asset.ts:129</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -359,7 +359,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L72">steem/asset.ts:72</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L78">steem/asset.ts:78</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -394,7 +394,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L52">steem/asset.ts:52</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L58">steem/asset.ts:58</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -425,7 +425,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L98">steem/asset.ts:98</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L104">steem/asset.ts:104</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -456,7 +456,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L90">steem/asset.ts:90</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/steem/asset.ts#L96">steem/asset.ts:96</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......
......@@ -103,6 +103,7 @@
<li class="tsd-kind-property tsd-parent-kind-class"><a href="client.html#chainid" class="tsd-kind-icon">chain<wbr>Id</a></li>
<li class="tsd-kind-property tsd-parent-kind-class"><a href="client.html#database" class="tsd-kind-icon">database</a></li>
<li class="tsd-kind-property tsd-parent-kind-class"><a href="client.html#options" class="tsd-kind-icon">options</a></li>
<li class="tsd-kind-property tsd-parent-kind-class"><a href="client.html#rc" class="tsd-kind-icon">rc</a></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><a href="client.html#seqno" class="tsd-kind-icon">seq<wbr>No</a></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><a href="client.html#timeout" class="tsd-kind-icon">timeout</a></li>
</ul>
......@@ -129,7 +130,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/client.ts#L203">client.ts:203</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/client.ts#L209">client.ts:209</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -166,7 +167,7 @@
<div class="tsd-signature tsd-kind-icon">address<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>