mirror of
https://github.com/Instadapp/Swap-Aggregator-Subgraph.git
synced 2024-07-29 21:57:12 +00:00
686 lines
17 KiB
HTML
686 lines
17 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset='utf-8'>
|
|
<title>ipld-dag-cbor 0.15.3 | Documentation</title>
|
|
<meta name='description' content='JavaScript implementation of the IPLD (InterpPlanetary Linked Data)'>
|
|
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
|
<link href='assets/bass.css' rel='stylesheet'>
|
|
<link href='assets/style.css' rel='stylesheet'>
|
|
<link href='assets/github.css' rel='stylesheet'>
|
|
<link href='assets/split.css' rel='stylesheet'>
|
|
</head>
|
|
<body class='documentation m0'>
|
|
<div class='flex'>
|
|
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
|
|
<div class='py1 px2'>
|
|
<h3 class='mb0 no-anchor'>ipld-dag-cbor</h3>
|
|
<div class='mb1'><code>0.15.3</code></div>
|
|
<input
|
|
placeholder='Filter'
|
|
id='filter-input'
|
|
class='col12 block input'
|
|
type='text' />
|
|
<div id='toc'>
|
|
<ul class='list-reset h5 py1-ul'>
|
|
|
|
|
|
<li><a
|
|
href='#intro'
|
|
class="h5 bold black caps">
|
|
Intro
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#configuredecoder'
|
|
class="">
|
|
configureDecoder
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#serialize'
|
|
class="">
|
|
serialize
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#deserialize'
|
|
class="">
|
|
deserialize
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#cid'
|
|
class="">
|
|
cid
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#resolve'
|
|
class="">
|
|
resolve
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#tree'
|
|
class="">
|
|
tree
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</div>
|
|
<div class='mt1 h6 quiet'>
|
|
<a href='https://documentation.js.org/reading-documentation.html'>Need help reading this?</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id='split-right' class='relative overflow-auto height-viewport-100'>
|
|
|
|
|
|
<div class='keyline-top-not py2'><section class='py2 clearfix'>
|
|
|
|
<h2 id='intro' class='mt0'>
|
|
Intro
|
|
</h2>
|
|
|
|
|
|
<p>Installable via <code>npm install --save ipld-dag-cbor</code>, it can also be used directly in the browser.</p>
|
|
<h2>Download</h2>
|
|
<p>The source is available for download from <a href="https://github.com/ipld/js-ipld-dag-cbor.git">GitHub</a>. Alternatively, you can install using npm:</p>
|
|
<pre class='hljs'>$ npm install --save ipld-dag-cbor</pre>
|
|
<p>You can then <code>require()</code> ipld-dag-cbor as normal:</p>
|
|
<pre class='hljs'><span class="hljs-keyword">const</span> ipldDagCbor = <span class="hljs-built_in">require</span>(<span class="hljs-string">'ipld-dag-cbor'</span>)</pre>
|
|
<h2>In the Browser</h2>
|
|
<p>Ipld-dag-cbor should work in any ES2015 environment out of the box.</p>
|
|
<p>Usage:</p>
|
|
<pre class='hljs'><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text/javascript"</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"index.js"</span>></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></pre>
|
|
<p>The portable versions of ipld-dag-cbor, including <code>index.js</code> and <code>index.min.js</code>, are included in the <code>/dist</code> folder. Ipld-dag-cbor can also be found on <a href="https://unpkg.com">unpkg.com</a> under</p>
|
|
<ul>
|
|
<li><a href="https://unpkg.com/ipld-dag-cbor/dist/index.min.js">https://unpkg.com/ipld-dag-cbor/dist/index.min.js</a></li>
|
|
<li><a href="https://unpkg.com/ipld-dag-cbor/dist/index.js">https://unpkg.com/ipld-dag-cbor/dist/index.js</a></li>
|
|
</ul>
|
|
|
|
|
|
</section></div>
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='configuredecoder'>
|
|
configureDecoder
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://git@github.com/:ipld/js-ipld-dag-cbor/blob/242576f616dd3763868f3c6b119a1d266faead79/src/util.js#L97-L124'>
|
|
<span>src/util.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Configure the underlying CBOR decoder.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>configureDecoder(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?)</code>
|
|
The options the decoder takes. The decoder will reset to the defaul values if no options are given.
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.size</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
|
|
|
|
(default <code>65536</code>)
|
|
</td>
|
|
<td class='break-word'><span>The current heap size used in CBOR parsing, this may grow automatically as larger blocks are encountered up to
|
|
<code>maxSize</code>
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.maxSize</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
|
|
|
|
(default <code>67108864</code>)
|
|
</td>
|
|
<td class='break-word'><span>The maximum size the CBOR parsing heap is allowed to grow to before
|
|
<code>dagCBOR.util.deserialize()</code>
|
|
returns an error
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.tags</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?</code>
|
|
</td>
|
|
<td class='break-word'><span>An object whose keys are CBOR tag numbers and values are transform functions that accept a
|
|
<code>value</code>
|
|
and return a decoded representation of that
|
|
<code>value</code>
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='serialize'>
|
|
serialize
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://git@github.com/:ipld/js-ipld-dag-cbor/blob/242576f616dd3763868f3c6b119a1d266faead79/src/util.js#L134-L139'>
|
|
<span>src/util.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Serialize internal representation into a binary CBOR block.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>serialize(node: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): <a href="https://nodejs.org/api/buffer.html">Buffer</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>node</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
Internal representation of a CBOR block
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://nodejs.org/api/buffer.html">Buffer</a></code>:
|
|
The encoded binary representation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='deserialize'>
|
|
deserialize
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://git@github.com/:ipld/js-ipld-dag-cbor/blob/242576f616dd3763868f3c6b119a1d266faead79/src/util.js#L147-L159'>
|
|
<span>src/util.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Deserialize CBOR block into the internal representation.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>deserialize(data: <a href="https://nodejs.org/api/buffer.html">Buffer</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>data</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code>
|
|
Binary representation of a CBOR block
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code>:
|
|
An object that conforms to the IPLD Data Model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='cid'>
|
|
cid
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://git@github.com/:ipld/js-ipld-dag-cbor/blob/242576f616dd3763868f3c6b119a1d266faead79/src/util.js#L170-L179'>
|
|
<span>src/util.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Calculate the CID of the binary blob.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>cid(binaryBlob: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, userOptions: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><CID></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>binaryBlob</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
Encoded IPLD Node
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>userOptions</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?)</code>
|
|
Options to create the CID
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>userOptions.cidVersion</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
|
|
|
|
(default <code>1</code>)
|
|
</td>
|
|
<td class='break-word'><span>CID version number
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><CID></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='resolve'>
|
|
resolve
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://git@github.com/:ipld/js-ipld-dag-cbor/blob/242576f616dd3763868f3c6b119a1d266faead79/src/resolver.js#L21-L44'>
|
|
<span>src/resolver.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Resolves a path within a CBOR block.</p>
|
|
<p>Returns the value or a link and the partial mising path. This way the
|
|
IPLD Resolver can fetch the link and continue to resolve.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>resolve(binaryBlob: <a href="https://nodejs.org/api/buffer.html">Buffer</a>, path: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>binaryBlob</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code>
|
|
Binary representation of a CBOR block
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>path</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
|
|
= <code>'/'</code>)</code>
|
|
Path that should be resolved
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code>:
|
|
result - Result of the path it it was resolved successfully
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>any</code>:
|
|
result.value - Value the path resolves to
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code>:
|
|
result.remainderPath - If the path resolves half-way to a
|
|
link, then the
|
|
<code>remainderPath</code>
|
|
is the part after the link that can be used
|
|
for further resolving
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='tree'>
|
|
tree
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://git@github.com/:ipld/js-ipld-dag-cbor/blob/242576f616dd3763868f3c6b119a1d266faead79/src/resolver.js#L66-L70'>
|
|
<span>src/resolver.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Return all available paths of a block.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>tree(binaryBlob: <a href="https://nodejs.org/api/buffer.html">Buffer</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>binaryBlob</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code>
|
|
Binary representation of a CBOR block
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<script src='assets/anchor.js'></script>
|
|
<script src='assets/split.js'></script>
|
|
<script src='assets/site.js'></script>
|
|
</body>
|
|
</html>
|