Commit f57a4260 authored by Johan Nordberg's avatar Johan Nordberg

Version 0.8.0

parent 740e09cb
......@@ -430,7 +430,6 @@ declare module 'dsteem/utils' {
* in the design, construction, operation or maintenance of any military facility.
*/
import { EventEmitter } from 'events';
import * as https from 'https';
/**
* Return a promise that will resove when a specific event is emitted.
*/
......@@ -448,13 +447,9 @@ declare module 'dsteem/utils' {
*/
export function copy<T>(object: T): T;
/**
* Reads stream to memory and tries to parse the result as JSON.
* Fetch API wrapper that retries until timeout is reached.
*/
export function readJson(stream: NodeJS.ReadableStream): Promise<any>;
/**
* Sends JSON data to server and read JSON response.
*/
export function jsonRequest(options: https.RequestOptions, data: any): Promise<{}>;
export function retryingFetch(url: string, opts: any, timeout: number, backoff: (tries: number) => number): Promise<any>;
}
declare module 'dsteem/crypto' {
......@@ -1663,6 +1658,40 @@ declare module 'dsteem/steem/block' {
}
declare module 'dsteem/helpers/blockchain' {
/// <reference types="node" />
/**
* @file Steem blockchain 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.
*/
import { Client } from 'dsteem/client';
import { BlockHeader, SignedBlock } from 'dsteem/steem/block';
import { AppliedOperation } from 'dsteem/steem/operation';
......@@ -2025,8 +2054,6 @@ declare module 'dsteem/helpers/database' {
}
declare module 'dsteem/client' {
/// <reference types="node" />
import { EventEmitter } from 'events';
import * as https from 'https';
import { Blockchain } from 'dsteem/helpers/blockchain';
import { BroadcastAPI } from 'dsteem/helpers/broadcast';
import { DatabaseAPI } from 'dsteem/helpers/database';
......@@ -2058,42 +2085,30 @@ declare module 'dsteem/client' {
*/
addressPrefix?: string;
/**
* How long in milliseconds before a request times out, set to `0` to disable.
* Defaults to five seconds.
* Send timeout, how long to wait in milliseconds before giving
* up on a rpc call. Note that this is not an exact timeout,
* no in-flight requests will be aborted, they will just not
* be retried any more past the timeout.
* Can be set to 0 to retry forever. Defaults to 60 * 1000 ms.
*/
timeout?: number;
/**
* Retry backoff function, returns milliseconds. Default = {@link defaultBackoff}.
*/
sendTimeout?: number;
backoff?: (tries: number) => number;
/**
* Node.js http(s) agent, use if you want http keep-alive.
* Defaults to using https.globalAgent.
* @see https://nodejs.org/api/http.html#http_new_agent_options.
*/
agent?: https.Agent;
}
/**
* RPC Client events
* -----------------
*/
export interface ClientEvents {
/**
* Emitted when the connection closes/opens.
*/
on(event: 'open' | 'close', listener: () => void): this;
/**
* Emitted on error, throws if there is no listener.
*/
on(event: 'error', listener: (error: Error) => void): this;
/**
* Emitted when receiving a server notice message, typically only used for callbacks.
*/
on(event: 'notice', listener: (notice: any) => void): this;
on(event: string, listener: Function): this;
agent?: any;
}
/**
* RPC Client
* ----------
* Can be used in both node.js and the browser. Also see {@link ClientOptions}.
*/
export class Client extends EventEmitter implements ClientEvents {
export class Client {
/**
* Create a new client instance configured for the testnet.
*/
......@@ -2126,9 +2141,9 @@ declare module 'dsteem/client' {
* Address prefix for current network.
*/
readonly addressPrefix: string;
private pending;
private seqNo;
private rpcOptions;
private timeout;
private backoff;
/**
* @param address The address to the Steem RPC server, e.g. `https://steemd.steemit.com`.
* @param options Client options.
......@@ -2146,9 +2161,9 @@ declare module 'dsteem/client' {
}
}
declare module 'dsteem/index-browser' {
declare module 'dsteem' {
/**
* @file dsteem entry point for browsers.
* @file dsteem exports.
* @author Johan Nordberg <code@johan-nordberg.com>
* @license
* Copyright (c) 2017 Johan Nordberg. All Rights Reserved.
......@@ -2181,11 +2196,6 @@ declare module 'dsteem/index-browser' {
* 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 'core-js/es6/map';
import 'core-js/es6/promise';
import 'core-js/fn/array/from';
import 'core-js/modules/es7.symbol.async-iterator';
import 'regenerator-runtime/runtime';
import * as utils from 'dsteem/utils';
export { utils };
export * from 'dsteem/helpers/blockchain';
......@@ -2196,12 +2206,25 @@ declare module 'dsteem/index-browser' {
export * from 'dsteem/steem/comment';
export * from 'dsteem/steem/misc';
export * from 'dsteem/steem/operation';
export * from 'dsteem/steem/serializer';
export * from 'dsteem/steem/transaction';
export * from 'dsteem/client';
export * from 'dsteem/crypto';
}
declare module 'dsteem' {
declare module 'dsteem/index-browser' {
import 'core-js/es6/map';
import 'core-js/es6/number';
import 'core-js/es6/promise';
import 'core-js/es6/symbol';
import 'core-js/fn/array/from';
import 'core-js/modules/es7.symbol.async-iterator';
import 'regenerator-runtime/runtime';
import 'whatwg-fetch';
export * from 'dsteem';
}
declare module 'dsteem/index-node' {
/**
* @file dsteem entry point for node.js.
* @author Johan Nordberg <code@johan-nordberg.com>
......@@ -2237,18 +2260,6 @@ declare module 'dsteem' {
* in the design, construction, operation or maintenance of any military facility.
*/
import 'core-js/modules/es7.symbol.async-iterator';
import * as utils from 'dsteem/utils';
export { utils };
export * from 'dsteem/helpers/blockchain';
export * from 'dsteem/helpers/database';
export * from 'dsteem/steem/account';
export * from 'dsteem/steem/asset';
export * from 'dsteem/steem/block';
export * from 'dsteem/steem/comment';
export * from 'dsteem/steem/misc';
export * from 'dsteem/steem/operation';
export * from 'dsteem/steem/transaction';
export * from 'dsteem/client';
export * from 'dsteem/crypto';
export * from 'dsteem';
}
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.
......@@ -113,7 +113,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L71">helpers/blockchain.ts:71</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L68">helpers/blockchain.ts:68</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
......@@ -139,7 +139,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L135">helpers/blockchain.ts:135</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L132">helpers/blockchain.ts:132</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -167,7 +167,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L106">helpers/blockchain.ts:106</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L103">helpers/blockchain.ts:103</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -198,7 +198,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L151">helpers/blockchain.ts:151</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L148">helpers/blockchain.ts:148</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -226,7 +226,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L142">helpers/blockchain.ts:142</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L139">helpers/blockchain.ts:139</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -254,7 +254,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L98">helpers/blockchain.ts:98</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L95">helpers/blockchain.ts:95</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -282,7 +282,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L91">helpers/blockchain.ts:91</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L88">helpers/blockchain.ts:88</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -310,7 +310,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L78">helpers/blockchain.ts:78</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L75">helpers/blockchain.ts:75</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -338,7 +338,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L158">helpers/blockchain.ts:158</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L155">helpers/blockchain.ts:155</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -366,7 +366,7 @@
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L170">helpers/blockchain.ts:170</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L167">helpers/blockchain.ts:167</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......
This diff is collapsed.
......@@ -88,7 +88,7 @@
<div class="tsd-signature tsd-kind-icon">Irreversible<span class="tsd-signature-symbol">:</span> </div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L48">helpers/blockchain.ts:48</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L45">helpers/blockchain.ts:45</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -103,7 +103,7 @@
<div class="tsd-signature tsd-kind-icon">Latest<span class="tsd-signature-symbol">:</span> </div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L52">helpers/blockchain.ts:52</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/helpers/blockchain.ts#L49">helpers/blockchain.ts:49</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......
......@@ -108,7 +108,6 @@
<li class="tsd-kind-interface"><a href="interfaces/challengeauthorityoperation.html" class="tsd-kind-icon">Challenge<wbr>Authority<wbr>Operation</a></li>
<li class="tsd-kind-interface"><a href="interfaces/changerecoveryaccountoperation.html" class="tsd-kind-icon">Change<wbr>Recovery<wbr>Account<wbr>Operation</a></li>
<li class="tsd-kind-interface"><a href="interfaces/claimrewardbalanceoperation.html" class="tsd-kind-icon">Claim<wbr>Reward<wbr>Balance<wbr>Operation</a></li>
<li class="tsd-kind-interface"><a href="interfaces/clientevents.html" class="tsd-kind-icon">Client<wbr>Events</a></li>
<li class="tsd-kind-interface"><a href="interfaces/clientoptions.html" class="tsd-kind-icon">Client<wbr>Options</a></li>
<li class="tsd-kind-interface"><a href="interfaces/comment.html" class="tsd-kind-icon">Comment</a></li>
<li class="tsd-kind-interface"><a href="interfaces/commentoperation.html" class="tsd-kind-icon">Comment<wbr>Operation</a></li>
......@@ -190,6 +189,7 @@
<li class="tsd-kind-variable tsd-is-not-exported"><a href="globals.html#signedblockheaderserializer" class="tsd-kind-icon">Signed<wbr>Block<wbr>Header<wbr>Serializer</a></li>
<li class="tsd-kind-variable tsd-is-not-exported"><a href="globals.html#transactionserializer" class="tsd-kind-icon">Transaction<wbr>Serializer</a></li>
<li class="tsd-kind-variable"><a href="globals.html#version" class="tsd-kind-icon">VERSION</a></li>
<li class="tsd-kind-variable tsd-is-not-exported"><a href="globals.html#fetch" class="tsd-kind-icon">fetch</a></li>
</ul>
</section>
<section class="tsd-index-section ">
......@@ -215,14 +215,14 @@
<li class="tsd-kind-function tsd-has-type-parameter"><a href="globals.html#copy" class="tsd-kind-icon">copy</a></li>
<li class="tsd-kind-function tsd-is-not-exported"><a href="globals.html#decodeprivate" class="tsd-kind-icon">decode<wbr>Private</a></li>
<li class="tsd-kind-function tsd-is-not-exported"><a href="globals.html#decodepublic" class="tsd-kind-icon">decode<wbr>Public</a></li>
<li class="tsd-kind-function tsd-is-not-exported"><a href="globals.html#defaultbackoff" class="tsd-kind-icon">default<wbr>Backoff</a></li>
<li class="tsd-kind-function tsd-is-not-exported"><a href="globals.html#doublesha256" class="tsd-kind-icon">double<wbr>Sha256</a></li>
<li class="tsd-kind-function tsd-is-not-exported"><a href="globals.html#encodeprivate" class="tsd-kind-icon">encode<wbr>Private</a></li>
<li class="tsd-kind-function tsd-is-not-exported"><a href="globals.html#encodepublic" class="tsd-kind-icon">encode<wbr>Public</a></li>
<li class="tsd-kind-function"><a href="globals.html#getvestingshareprice" class="tsd-kind-icon">get<wbr>Vesting<wbr>Share<wbr>Price</a></li>
<li class="tsd-kind-function tsd-is-not-exported"><a href="globals.html#iscanonicalsignature" class="tsd-kind-icon">is<wbr>Canonical<wbr>Signature</a></li>
<li class="tsd-kind-function tsd-has-type-parameter"><a href="globals.html#iteratorstream" class="tsd-kind-icon">iterator<wbr>Stream</a></li>
<li class="tsd-kind-function"><a href="globals.html#jsonrequest" class="tsd-kind-icon">json<wbr>Request</a></li>
<li class="tsd-kind-function"><a href="globals.html#readjson" class="tsd-kind-icon">read<wbr>Json</a></li>
<li class="tsd-kind-function"><a href="globals.html#retryingfetch" class="tsd-kind-icon">retrying<wbr>Fetch</a></li>
<li class="tsd-kind-function tsd-is-not-exported"><a href="globals.html#ripemd160" class="tsd-kind-icon">ripemd160</a></li>
<li class="tsd-kind-function tsd-is-not-exported"><a href="globals.html#sha256" class="tsd-kind-icon">sha256</a></li>
<li class="tsd-kind-function"><a href="globals.html#signtransaction" class="tsd-kind-icon">sign<wbr>Transaction</a></li>
......@@ -402,7 +402,7 @@
<div class="tsd-signature tsd-kind-icon">DEFAULT_<wbr>ADDRESS_<wbr>PREFIX<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"STM"</span><span class="tsd-signature-symbol"> =&nbsp;&quot;STM&quot;</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/client.ts#L62">client.ts:62</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/client.ts#L58">client.ts:58</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -417,7 +417,7 @@
<div class="tsd-signature tsd-kind-icon">DEFAULT_<wbr>CHAIN_<wbr>ID<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Buffer</span><span class="tsd-signature-symbol"> =&nbsp;Buffer.from(&#x27;0000000000000000000000000000000000000000000000000000000000000000&#x27;, &#x27;hex&#x27;)</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/client.ts#L57">client.ts:57</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/client.ts#L53">client.ts:53</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -495,7 +495,7 @@
<div class="tsd-signature tsd-kind-icon">VERSION<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> =&nbsp;packageVersion</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/client.ts#L52">client.ts:52</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/client.ts#L48">client.ts:48</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
......@@ -504,6 +504,16 @@
</div>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-variable tsd-is-not-exported">
<a name="fetch" class="tsd-anchor"></a>
<h3>fetch</h3>
<div class="tsd-signature tsd-kind-icon">fetch<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> =&nbsp;global[&#x27;fetch&#x27;]</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/utils.ts#L40">utils.ts:40</a></li>
</ul>
</aside>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Functions</h2>
......@@ -1035,6 +1045,35 @@
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function tsd-is-not-exported">
<a name="defaultbackoff" class="tsd-anchor"></a>
<h3>default<wbr>Backoff</h3>
<ul class="tsd-signatures tsd-kind-function tsd-is-not-exported">
<li class="tsd-signature tsd-kind-icon">default<wbr>Backoff<span class="tsd-signature-symbol">(</span>tries<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/client.ts#L293">client.ts:293</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Default backoff function.
<code>min(tries*10^2, 10 seconds)</code></p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>tries: <span class="tsd-signature-type">number</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function tsd-is-not-exported">
<a name="doublesha256" class="tsd-anchor"></a>
<h3>double<wbr>Sha256</h3>
......@@ -1213,58 +1252,54 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="jsonrequest" class="tsd-anchor"></a>
<h3>json<wbr>Request</h3>
<a name="retryingfetch" class="tsd-anchor"></a>
<h3>retrying<wbr>Fetch</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">json<wbr>Request<span class="tsd-signature-symbol">(</span>options<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">RequestOptions</span>, data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol">&gt;</span></li>
<li class="tsd-signature tsd-kind-icon">retrying<wbr>Fetch<span class="tsd-signature-symbol">(</span>url<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, opts<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, timeout<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, backoff<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">function</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/utils.ts#L114">utils.ts:114</a></li>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/utils.ts#L91">utils.ts:91</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Sends JSON data to server and read JSON response.</p>
<p>Fetch API wrapper that retries until timeout is reached.</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>options: <span class="tsd-signature-type">RequestOptions</span></h5>
<h5>url: <span class="tsd-signature-type">string</span></h5>
</li>
<li>
<h5>data: <span class="tsd-signature-type">any</span></h5>
<h5>opts: <span class="tsd-signature-type">any</span></h5>
</li>
<li>
<h5>timeout: <span class="tsd-signature-type">number</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Object</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="readjson" class="tsd-anchor"></a>
<h3>read<wbr>Json</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">read<wbr>Json<span class="tsd-signature-symbol">(</span>stream<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">ReadableStream</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/jnordberg/dsteem/blob/master/src/utils.ts#L91">utils.ts:91</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Reads stream to memory and tries to parse the result as JSON.</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>stream: <span class="tsd-signature-type">ReadableStream</span></h5>
<h5>backoff: <span class="tsd-signature-type">function</span></h5>
<ul class="tsd-parameters">
<li class="tsd-parameter-siganture">
<ul class="tsd-signatures tsd-kind-type-literal tsd-is-not-exported">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>tries<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>tries: <span class="tsd-signature-type">number</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4>
......@@ -1742,9 +1777,6 @@
<li class=" tsd-kind-interface">
<a href="interfaces/claimrewardbalanceoperation.html" class="tsd-kind-icon">Claim<wbr>Reward<wbr>Balance<wbr>Operation</a>
</li>
<li class=" tsd-kind-interface">
<a href="interfaces/clientevents.html" class="tsd-kind-icon">Client<wbr>Events</a>
</li>
<li class=" tsd-kind-interface">
<a href="interfaces/clientoptions.html" class="tsd-kind-icon">Client<wbr>Options</a>
</li>
......@@ -1958,6 +1990,9 @@
<li class=" tsd-kind-variable">
<a href="globals.html#version" class="tsd-kind-icon">VERSION</a>
</li>
<li class=" tsd-kind-variable tsd-is-not-exported">
<a href="globals.html#fetch" class="tsd-kind-icon">fetch</a>
</li>
<li class=" tsd-kind-function tsd-is-not-exported">
<a href="globals.html#arrayserializer" class="tsd-kind-icon">Array<wbr>Serializer</a>
</li>
......@@ -2018,6 +2053,9 @@
<li class=" tsd-kind-function tsd-is-not-exported">
<a href="globals.html#decodepublic" class="tsd-kind-icon">decode<wbr>Public</a>
</li>
<li class=" tsd-kind-function tsd-is-not-exported">
<a href="globals.html#defaultbackoff" class="tsd-kind-icon">default<wbr>Backoff</a>
</li>
<li class=" tsd-kind-function tsd-is-not-exported">
<a href="globals.html#doublesha256" class="tsd-kind-icon">double<wbr>Sha256</a>
</li>
......@@ -2037,10 +2075,7 @@
<a href="globals.html#iteratorstream" class="tsd-kind-icon">iterator<wbr>Stream</a>
</li>
<li class=" tsd-kind-function">
<a href="globals.html#jsonrequest" class="tsd-kind-icon">json<wbr>Request</a>
</li>
<li class=" tsd-kind-function">
<a href="globals.html#readjson" class="tsd-kind-icon">read<wbr>Json</a>
<a href="globals.html#retryingfetch" class="tsd-kind-icon">retrying<wbr>Fetch</a>
</li>
<li class=" tsd-kind-function tsd-is-not-exported">
<a href="globals.html#ripemd160" class="tsd-kind-icon">ripemd160</a>
......
......@@ -73,6 +73,10 @@
<li><a href="https://github.com/jnordberg/dsteem/issues">Bug tracker</a></li>
</ul>
<hr>
<p><strong>note</strong> As of version 0.7.0 WebSocket support has been removed. The only transport provided now is HTTP(2). For most users the only change required is to swap <code>wss://</code> to <code>https://</code> in the address. If you run your own full node make sure to set the proper <a href="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">CORS headers</a> if you plan to access it from a browser.</p>
<hr>
<h2 id="browser-compatibility">Browser compatibility</h2>
<p><a href="https://saucelabs.com/open_sauce/user/jnordberg-dsteem"><img src="https://saucelabs.com/browser-matrix/jnordberg-dsteem.svg" alt="Build Status"></a></p>
<h2 id="installation">Installation</h2>
<h3 id="via-npm">Via npm</h3>
<p>For node.js or the browser with <a href="https://github.com/substack/node-browserify">browserify</a> or <a href="https://github.com/webpack/webpack">webpack</a>.</p>
......@@ -82,14 +86,14 @@
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"dsteem.js"</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<p>Or from the <a href="https://unpkg.com">unpkg</a> cdn:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/dsteem@^0.6.0/dist/dsteem.js"</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/dsteem@^0.8.0/dist/dsteem.js"</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<p>Make sure to set the version you want when including from the cdn, you can also use <code>dsteem@latest</code> but that is not always desirable. See <a href="https://unpkg.com">unpkg.com</a> for more information.</p>
<h2 id="usage">Usage</h2>
<h3 id="in-the-browser">In the browser</h3>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/dsteem@latest/dist/dsteem.js"</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-keyword">var</span> client = <span class="hljs-keyword">new</span> dsteem.Client(<span class="hljs-string">'wss://steemd.steemit.com'</span>)
<span class="hljs-keyword">var</span> client = <span class="hljs-keyword">new</span> dsteem.Client(<span class="hljs-string">'https://steemd.steemit.com'</span>)
client.database.getDiscussions(<span class="hljs-string">'trending'</span>, {<span class="hljs-attr">tag</span>: <span class="hljs-string">'writing'</span>, <span class="hljs-attr">limit</span>: <span class="hljs-number">1</span>}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">discussions</span>)</span>{
<span class="hljs-built_in">document</span>.body.innerHTML += <span class="hljs-string">'&lt;h1&gt;'</span> + discussions[<span class="hljs-number">0</span>].title + <span class="hljs-string">'&lt;/h1&gt;'</span>
<span class="hljs-built_in">document</span>.body.innerHTML += <span class="hljs-string">'&lt;h2&gt;by '</span> + discussions[<span class="hljs-number">0</span>].author + <span class="hljs-string">'&lt;/h2&gt;'</span>
......@@ -102,17 +106,16 @@
<p>With TypeScript:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> {Client} <span class="hljs-keyword">from</span> <span class="hljs-string">'dsteem'</span>
<span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> Client(<span class="hljs-string">'wss://steemd.steemit.com'</span>)
<span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> Client(<span class="hljs-string">'https://steemd.steemit.com'</span>)
<span class="hljs-keyword">for</span> <span class="hljs-keyword">await</span> (<span class="hljs-keyword">const</span> block of client.blockchain.getBlocks()) {
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`New block, id: <span class="hljs-subst">${ block.block_id }</span>`</span>)
}
</code></pre>
<p>With JavaScript:</p>
<pre><code class="lang-javascript">
<span class="hljs-keyword">var</span> dsteem = <span class="hljs-built_in">require</span>(<span class="hljs-string">'dsteem'</span>)
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> dsteem = <span class="hljs-built_in">require</span>(<span class="hljs-string">'dsteem'</span>)