UNPKG

ontology-ts-sdk

Version:

Comprehensive TypeScript library for the Ontology blockchain.

963 lines 54.8 kB
<!doctype html> <html class="default no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>&quot;utils&quot; | ontology-ts-sdk</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="../assets/css/main.css"> </head> <body> <header> <div class="tsd-page-toolbar"> <div class="container"> <div class="table-wrap"> <div class="table-cell" id="tsd-search" data-index="../assets/js/search.js" data-base=".."> <div class="field"> <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label> <input id="tsd-search-field" type="text" /> </div> <ul class="results"> <li class="state loading">Preparing search index...</li> <li class="state failure">The search index is not available</li> </ul> <a href="../index.html" class="title">ontology-ts-sdk</a> </div> <div class="table-cell" id="tsd-widgets"> <div id="tsd-filter"> <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a> <div class="tsd-filter-group"> <div class="tsd-select" id="tsd-filter-visibility"> <span class="tsd-select-label">All</span> <ul class="tsd-select-list"> <li data-value="public">Public</li> <li data-value="protected">Public/Protected</li> <li data-value="private" class="selected">All</li> </ul> </div> <input type="checkbox" id="tsd-filter-inherited" checked /> <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label> <input type="checkbox" id="tsd-filter-externals" checked /> <label class="tsd-widget" for="tsd-filter-externals">Externals</label> <input type="checkbox" id="tsd-filter-only-exported" /> <label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label> </div> </div> <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a> </div> </div> </div> </div> <div class="tsd-page-title"> <div class="container"> <ul class="tsd-breadcrumb"> <li> <a href="../globals.html">Globals</a> </li> <li> <a href="_utils_.html">&quot;utils&quot;</a> </li> </ul> <h1>External module &quot;utils&quot;</h1> </div> </div> </header> <div class="container container-main"> <div class="row"> <div class="col-8 col-content"> <section class="tsd-panel-group tsd-index-group"> <h2>Index</h2> <section class="tsd-panel tsd-index-panel"> <div class="tsd-index-content"> <section class="tsd-index-section "> <h3>Classes</h3> <ul class="tsd-index-list"> <li class="tsd-kind-class tsd-parent-kind-external-module"><a href="../classes/_utils_.eventemitter.html" class="tsd-kind-icon">Event<wbr>Emitter</a></li> <li class="tsd-kind-class tsd-parent-kind-external-module"><a href="../classes/_utils_.stringreader.html" class="tsd-kind-icon">String<wbr>Reader</a></li> </ul> </section> <section class="tsd-index-section "> <h3>Functions</h3> <ul class="tsd-index-list"> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#ab2hexstring" class="tsd-kind-icon">ab2hexstring</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#ab2str" class="tsd-kind-icon">ab2str</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#axiospost" class="tsd-kind-icon">axios<wbr>Post</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#bool2varbyte" class="tsd-kind-icon">bool2<wbr>Var<wbr>Byte</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#generatemnemonic" class="tsd-kind-icon">generate<wbr>Mnemonic</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#generaterandomarray" class="tsd-kind-icon">generate<wbr>Random<wbr>Array</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#hash160" class="tsd-kind-icon">hash160</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#hex2varbytes" class="tsd-kind-icon">hex2<wbr>Var<wbr>Bytes</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#hexxor" class="tsd-kind-icon">hex<wbr>Xor</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#hexstr2str" class="tsd-kind-icon">hexstr2str</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#hexstring2ab" class="tsd-kind-icon">hexstring2ab</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#isbase64" class="tsd-kind-icon">is<wbr>Base64</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#now" class="tsd-kind-icon">now</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#num2varint" class="tsd-kind-icon">num2<wbr>Var<wbr>Int</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#num2hexstring" class="tsd-kind-icon">num2hexstring</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#parsemnemonic" class="tsd-kind-icon">parse<wbr>Mnemonic</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#randombytes" class="tsd-kind-icon">random<wbr>Bytes</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#reversehex" class="tsd-kind-icon">reverse<wbr>Hex</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#ripemd160" class="tsd-kind-icon">ripemd160</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#sendbackresult2native" class="tsd-kind-icon">send<wbr>Back<wbr>Result2<wbr>Native</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#sha256" class="tsd-kind-icon">sha256</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#str2varbytes" class="tsd-kind-icon">str2<wbr>Var<wbr>Bytes</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#str2ab" class="tsd-kind-icon">str2ab</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#str2hexstr" class="tsd-kind-icon">str2hexstr</a></li> <li class="tsd-kind-function tsd-parent-kind-external-module"><a href="_utils_.html#varifypositiveint" class="tsd-kind-icon">varify<wbr>Positive<wbr>Int</a></li> </ul> </section> </div> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Functions</h2> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="ab2hexstring" class="tsd-anchor"></a> <h3>ab2hexstring</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">ab2hexstring<span class="tsd-signature-symbol">(</span>arr<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">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L44">utils.ts:44</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Turn array buffer into hex string</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>arr: <span class="tsd-signature-type">any</span></h5> <div class="tsd-comment tsd-typography"> <p>Array like value</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="ab2str" class="tsd-anchor"></a> <h3>ab2str</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">ab2str<span class="tsd-signature-symbol">(</span>buf<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">ArrayBuffer</span><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-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L63">utils.ts:63</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Turn ArrayBuffer or array-like oject into normal string</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>buf: <span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5> <div class="tsd-comment tsd-typography"> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="axiospost" class="tsd-anchor"></a> <h3><span class="tsd-flag ts-flagConst">Const</span> axios<wbr>Post</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">axios<wbr>Post<span class="tsd-signature-symbol">(</span>url<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, params<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">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/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L378">utils.ts:378</a></li> </ul> </aside> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>url: <span class="tsd-signature-type">string</span></h5> </li> <li> <h5>params: <span class="tsd-signature-type">any</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">any</span><span class="tsd-signature-symbol">&gt;</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="bool2varbyte" class="tsd-anchor"></a> <h3>bool2<wbr>Var<wbr>Byte</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">bool2<wbr>Var<wbr>Byte<span class="tsd-signature-symbol">(</span>v<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">"01"</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"00"</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L124">utils.ts:124</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>return the byte of boolean value</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>v: <span class="tsd-signature-type">boolean</span></h5> <div class="tsd-comment tsd-typography"> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">"01"</span> <span class="tsd-signature-symbol"> | </span> <span class="tsd-signature-type">"00"</span> </h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="generatemnemonic" class="tsd-anchor"></a> <h3>generate<wbr>Mnemonic</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">generate<wbr>Mnemonic<span class="tsd-signature-symbol">(</span>size<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">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L447">utils.ts:447</a></li> </ul> </aside> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5><span class="tsd-flag ts-flagDefault value">Default value</span> size: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> =&nbsp;16</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="generaterandomarray" class="tsd-anchor"></a> <h3>generate<wbr>Random<wbr>Array</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">generate<wbr>Random<wbr>Array<span class="tsd-signature-symbol">(</span>len<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">ArrayBuffer</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L434">utils.ts:434</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Generates random ArrayBuffer of specified length.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>len: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>Length of the array to generate</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">ArrayBuffer</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="hash160" class="tsd-anchor"></a> <h3>hash160</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">hash160<span class="tsd-signature-symbol">(</span>SignatureScript<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L425">utils.ts:425</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Computes ripemd-160 hash of sha-256 hash from hex encoded data.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>SignatureScript: <span class="tsd-signature-type">string</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="hex2varbytes" class="tsd-anchor"></a> <h3>hex2<wbr>Var<wbr>Bytes</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">hex2<wbr>Var<wbr>Bytes<span class="tsd-signature-symbol">(</span>hex<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L100">utils.ts:100</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>return the (length of bytes) + bytes</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>hex: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>Hex string</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="hexxor" class="tsd-anchor"></a> <h3>hex<wbr>Xor</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">hex<wbr>Xor<span class="tsd-signature-symbol">(</span>str1<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, str2<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L133">utils.ts:133</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Do xor operation with two strings</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>str1: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>Hex string</p> </div> </li> <li> <h5>str2: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>Hex string</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="hexstr2str" class="tsd-anchor"></a> <h3>hexstr2str</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">hexstr2str<span class="tsd-signature-symbol">(</span>str<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L92">utils.ts:92</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Turn hex string into normal string</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>str: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>Hex string</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="hexstring2ab" class="tsd-anchor"></a> <h3>hexstring2ab</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">hexstring2ab<span class="tsd-signature-symbol">(</span>str<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L29">utils.ts:29</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Turn hex string into array buffer</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>str: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>hex string</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="isbase64" class="tsd-anchor"></a> <h3>is<wbr>Base64</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">is<wbr>Base64<span class="tsd-signature-symbol">(</span>str<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L463">utils.ts:463</a></li> </ul> </aside> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>str: <span class="tsd-signature-type">string</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="now" class="tsd-anchor"></a> <h3>now</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">now<span class="tsd-signature-symbol">(</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/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L394">utils.ts:394</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Gets current time in unix timestamp format.</p> </div> </div> <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-parent-kind-external-module"> <a name="num2varint" class="tsd-anchor"></a> <h3><span class="tsd-flag ts-flagConst">Const</span> num2<wbr>Var<wbr>Int</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">num2<wbr>Var<wbr>Int<span class="tsd-signature-symbol">(</span>num<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">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L182">utils.ts:182</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Converts a number to a hex</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>num: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The number</p> </div> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> <p>hexstring of the variable Int.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="num2hexstring" class="tsd-anchor"></a> <h3><span class="tsd-flag ts-flagConst">Const</span> num2hexstring</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">num2hexstring<span class="tsd-signature-symbol">(</span>num<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, size<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, littleEndian<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L157">utils.ts:157</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Converts a number to a big endian hexstring of a suitable size, optionally little endian</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>num: <span class="tsd-signature-type">number</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagDefault value">Default value</span> size: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> =&nbsp;1</span></h5> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>The required size in bytes, eg 1 for Uint8, 2 for Uint16. Defaults to 1.</p> </div> </div> </li> <li> <h5><span class="tsd-flag ts-flagDefault value">Default value</span> littleEndian: <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> =&nbsp;false</span></h5> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Encode the hex in little endian form</p> </div> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="parsemnemonic" class="tsd-anchor"></a> <h3>parse<wbr>Mnemonic</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">parse<wbr>Mnemonic<span class="tsd-signature-symbol">(</span>str<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L452">utils.ts:452</a></li> </ul> </aside> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>str: <span class="tsd-signature-type">string</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="randombytes" class="tsd-anchor"></a> <h3>random<wbr>Bytes</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">random<wbr>Bytes<span class="tsd-signature-symbol">(</span>len<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">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L443">utils.ts:443</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Generates random ArrayBuffer of specified length encoded as hex string</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>len: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>Length of the array to generate</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="reversehex" class="tsd-anchor"></a> <h3><span class="tsd-flag ts-flagConst">Const</span> reverse<wbr>Hex</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">reverse<wbr>Hex<span class="tsd-signature-symbol">(</span>hex<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L204">utils.ts:204</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Reverses a hex string, 2 chars as 1 byte</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>hex: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>HEX string</p> </div> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> <p>reversed hex string.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="ripemd160" class="tsd-anchor"></a> <h3>ripemd160</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">ripemd160<span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L414">utils.ts:414</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Computes ripemd-160 hash from hex encoded data.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>data: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>Hex encoded data</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="sendbackresult2native" class="tsd-anchor"></a> <h3><span class="tsd-flag ts-flagConst">Const</span> send<wbr>Back<wbr>Result2<wbr>Native</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">send<wbr>Back<wbr>Result2<wbr>Native<span class="tsd-signature-symbol">(</span>result<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, callback<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L372">utils.ts:372</a></li> </ul> </aside> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>result: <span class="tsd-signature-type">string</span></h5> </li> <li> <h5>callback: <span class="tsd-signature-type">string</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="sha256" class="tsd-anchor"></a> <h3>sha256</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">sha256<span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L403">utils.ts:403</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Computes sha-256 hash from hex encoded data.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>data: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>Hex encoded data</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="str2varbytes" class="tsd-anchor"></a> <h3>str2<wbr>Var<wbr>Bytes</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">str2<wbr>Var<wbr>Bytes<span class="tsd-signature-symbol">(</span>str<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L111">utils.ts:111</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>return the length of string(bytes) + string(bytes)</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>str: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>Normal string</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="str2ab" class="tsd-anchor"></a> <h3>str2ab</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">str2ab<span class="tsd-signature-symbol">(</span>str<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">ArrayBuffer</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L71">utils.ts:71</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Turn normal string into ArrayBuffer</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>str: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>Normal string</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">ArrayBuffer</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="str2hexstr" class="tsd-anchor"></a> <h3>str2hexstr</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">str2hexstr<span class="tsd-signature-symbol">(</span>str<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L84">utils.ts:84</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Turn normal string into hex string</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>str: <span class="tsd-signature-type">string</span></h5> <div class="tsd-comment tsd-typography"> <p>Normal string</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-external-module"> <a name="varifypositiveint" class="tsd-anchor"></a> <h3>varify<wbr>Positive<wbr>Int</h3> <ul class="tsd-signatures tsd-kind-function tsd-parent-kind-external-module"> <li class="tsd-signature tsd-kind-icon">varify<wbr>Positive<wbr>Int<span class="tsd-signature-symbol">(</span>v<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">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/MickWang/ontology-ts-sdk/blob/f203ee8/src/utils.ts#L456">utils.ts:456</a></li> </ul> </aside> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>v: <span class="tsd-signature-type">number</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> </section> </div> <div class="col-4 col-menu menu-sticky-wrap menu-highlight"> <nav class="tsd-navigation primary"> <ul> <li class="globals "> <a href="../globals.html"><em>Globals</em></a> </li> <li class="current tsd-kind-external-module"> <a href="_utils_.html">"utils"</a> </li> </ul> </nav> <nav class="tsd-navigation secondary menu-sticky"> <ul class="before-current"> <li class=" tsd-kind-class tsd-parent-kind-external-module"> <a href="../classes/_utils_.eventemitter.html" class="tsd-kind-icon">Event<wbr>Emitter</a> </li> <li class=" tsd-kind-class tsd-parent-kind-external-module"> <a href="../classes/_utils_.stringreader.html" class="tsd-kind-icon">String<wbr>Reader</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#ab2hexstring" class="tsd-kind-icon">ab2hexstring</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#ab2str" class="tsd-kind-icon">ab2str</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#axiospost" class="tsd-kind-icon">axios<wbr>Post</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#bool2varbyte" class="tsd-kind-icon">bool2<wbr>Var<wbr>Byte</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#generatemnemonic" class="tsd-kind-icon">generate<wbr>Mnemonic</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#generaterandomarray" class="tsd-kind-icon">generate<wbr>Random<wbr>Array</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#hash160" class="tsd-kind-icon">hash160</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#hex2varbytes" class="tsd-kind-icon">hex2<wbr>Var<wbr>Bytes</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#hexxor" class="tsd-kind-icon">hex<wbr>Xor</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#hexstr2str" class="tsd-kind-icon">hexstr2str</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#hexstring2ab" class="tsd-kind-icon">hexstring2ab</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#isbase64" class="tsd-kind-icon">is<wbr>Base64</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#now" class="tsd-kind-icon">now</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#num2varint" class="tsd-kind-icon">num2<wbr>Var<wbr>Int</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#num2hexstring" class="tsd-kind-icon">num2hexstring</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#parsemnemonic" class="tsd-kind-icon">parse<wbr>Mnemonic</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#randombytes" class="tsd-kind-icon">random<wbr>Bytes</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#reversehex" class="tsd-kind-icon">reverse<wbr>Hex</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#ripemd160" class="tsd-kind-icon">ripemd160</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#sendbackresult2native" class="tsd-kind-icon">send<wbr>Back<wbr>Result2<wbr>Native</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#sha256" class="tsd-kind-icon">sha256</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#str2varbytes" class="tsd-kind-icon">str2<wbr>Var<wbr>Bytes</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#str2ab" class="tsd-kind-icon">str2ab</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#str2hexstr" class="tsd-kind-icon">str2hexstr</a> </li> <li class=" tsd-kind-function tsd-parent-kind-external-module"> <a href="_utils_.html#varifypositiveint" class="tsd-kind-icon">varify<wbr>Positive<wbr>Int</a> </li> </ul> </nav> </div> </div> </div> <foo