Add documentation to eth modules.
This commit is contained in:
@@ -63,9 +63,22 @@
|
||||
<code>src/app/_eth/accountIndex.ts</code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Description</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<p>Provides an instance of the accounts registry contract.
|
||||
Allows querying of accounts that have been registered as valid accounts in the network.</p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<p class="comment">
|
||||
<h3>Example</h3>
|
||||
</p>
|
||||
<div class="io-description">
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
@@ -143,12 +156,14 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="10" class="link-to-prism">src/app/_eth/accountIndex.ts:10</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="25" class="link-to-prism">src/app/_eth/accountIndex.ts:25</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Create a connection to the deployed account registry contract.</p>
|
||||
</div>
|
||||
<div>
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
@@ -157,6 +172,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -171,6 +187,12 @@
|
||||
No
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<code><ul>
|
||||
<li>The deployed account registry contract's address.</li>
|
||||
</ul>
|
||||
</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>signerAddress</td>
|
||||
@@ -183,6 +205,12 @@
|
||||
Yes
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<code><ul>
|
||||
<li>The account address of the account that deployed the account registry contract.</li>
|
||||
</ul>
|
||||
</code>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -218,10 +246,16 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="10" class="link-to-prism">src/app/_eth/accountIndex.ts:10</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="21" class="link-to-prism">src/app/_eth/accountIndex.ts:21</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>The instance of the account registry contract. </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -245,10 +279,16 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="8" class="link-to-prism">src/app/_eth/accountIndex.ts:8</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="23" class="link-to-prism">src/app/_eth/accountIndex.ts:23</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>The deployed account registry contract's address. </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -272,10 +312,16 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="9" class="link-to-prism">src/app/_eth/accountIndex.ts:9</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="25" class="link-to-prism">src/app/_eth/accountIndex.ts:25</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>The account address of the account that deployed the account registry contract. </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -311,14 +357,17 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="44"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:44</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="57"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:57</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Registers an account to the accounts registry.
|
||||
Requires availability of the signer address.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
@@ -328,6 +377,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -342,18 +392,34 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The account address to be registered to the accounts registry contract.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<b>Example :</b>
|
||||
<div>
|
||||
<pre class="line-numbers"><code class="language-html">Prints &quot;true&quot; for registration of &#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39;:</p>
|
||||
<p>```typescript</p>
|
||||
<ul>
|
||||
<li>console.log(await addToAccountRegistry(&#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39;));</li>
|
||||
<li>```</li>
|
||||
</ul></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<boolean></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
|
||||
<p>true - If registration is successful or account had already been registered.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -384,14 +450,17 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="26"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:26</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="78"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:78</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Checks whether a specific account address has been registered in the accounts registry.
|
||||
Returns "true" for available and "false" otherwise.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
@@ -401,6 +470,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -415,18 +485,34 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The account address to be validated.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<b>Example :</b>
|
||||
<div>
|
||||
<pre class="line-numbers"><code class="language-html">Prints &quot;true&quot; or &quot;false&quot; depending on whether &#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39; has been registered:</p>
|
||||
<p>```typescript</p>
|
||||
<ul>
|
||||
<li>console.log(await haveAccount(&#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39;));</li>
|
||||
<li>```</li>
|
||||
</ul></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<boolean></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
|
||||
<p>true - If the address has been registered in the accounts registry.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -457,14 +543,16 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="30"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:30</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="95"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:95</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Returns a specified number of the most recently registered accounts.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
@@ -474,6 +562,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -488,18 +577,34 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The number of accounts to return from the accounts registry.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<b>Example :</b>
|
||||
<div>
|
||||
<pre class="line-numbers"><code class="language-html">Prints an array of accounts:</p>
|
||||
<p>```typescript</p>
|
||||
<ul>
|
||||
<li>console.log(await last(5));</li>
|
||||
<li>```</li>
|
||||
</ul></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<Array<string>></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
|
||||
<p>An array of registered account addresses.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -530,19 +635,36 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="22"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:22</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="121"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:121</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Returns the total number of accounts that have been registered in the network.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<b>Example :</b>
|
||||
<div>
|
||||
<pre class="line-numbers"><code class="language-html">Prints the total number of registered accounts:</p>
|
||||
<p>```typescript</p>
|
||||
<ul>
|
||||
<li>console.log(await totalAccounts());</li>
|
||||
<li>```</li>
|
||||
</ul></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<number></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<p>The total number of registered accounts.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -557,17 +679,37 @@
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {environment} from '@src/environments/environment';
|
||||
import Web3 from 'web3';
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import Web3 from 'web3';
|
||||
|
||||
// Application imports
|
||||
import {environment} from '@src/environments/environment';
|
||||
|
||||
/** Fetch the account registry contract's ABI. */
|
||||
const abi: Array<any> = require('@src/assets/js/block-sync/data/AccountRegistry.json');
|
||||
/** Establish a connection to the blockchain network. */
|
||||
const web3: Web3 = new Web3(environment.web3Provider);
|
||||
|
||||
/**
|
||||
* Provides an instance of the accounts registry contract.
|
||||
* Allows querying of accounts that have been registered as valid accounts in the network.
|
||||
*
|
||||
* @remarks
|
||||
* This is our interface to the accounts registry contract.
|
||||
*/
|
||||
export class AccountIndex {
|
||||
contractAddress: string;
|
||||
signerAddress: string;
|
||||
/** The instance of the account registry contract. */
|
||||
contract: any;
|
||||
/** The deployed account registry contract's address. */
|
||||
contractAddress: string;
|
||||
/** The account address of the account that deployed the account registry contract. */
|
||||
signerAddress: string;
|
||||
|
||||
/**
|
||||
* Create a connection to the deployed account registry contract.
|
||||
*
|
||||
* @param contractAddress - The deployed account registry contract's address.
|
||||
* @param signerAddress - The account address of the account that deployed the account registry contract.
|
||||
*/
|
||||
constructor(contractAddress: string, signerAddress?: string) {
|
||||
this.contractAddress = contractAddress;
|
||||
this.contract = new web3.eth.Contract(abi, this.contractAddress);
|
||||
@@ -578,14 +720,58 @@ export class AccountIndex {
|
||||
}
|
||||
}
|
||||
|
||||
public async totalAccounts(): Promise<number> {
|
||||
return await this.contract.methods.count().call();
|
||||
/**
|
||||
* Registers an account to the accounts registry.
|
||||
* Requires availability of the signer address.
|
||||
*
|
||||
* @async
|
||||
* @example
|
||||
* Prints "true" for registration of '0xc0ffee254729296a45a3885639AC7E10F9d54979':
|
||||
* ```typescript
|
||||
* console.log(await addToAccountRegistry('0xc0ffee254729296a45a3885639AC7E10F9d54979'));
|
||||
* ```
|
||||
*
|
||||
* @param address - The account address to be registered to the accounts registry contract.
|
||||
* @returns true - If registration is successful or account had already been registered.
|
||||
*/
|
||||
public async addToAccountRegistry(address: string): Promise<boolean> {
|
||||
if (!await this.haveAccount(address)) {
|
||||
return await this.contract.methods.add(address).send({from: this.signerAddress});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a specific account address has been registered in the accounts registry.
|
||||
* Returns "true" for available and "false" otherwise.
|
||||
*
|
||||
* @async
|
||||
* @example
|
||||
* Prints "true" or "false" depending on whether '0xc0ffee254729296a45a3885639AC7E10F9d54979' has been registered:
|
||||
* ```typescript
|
||||
* console.log(await haveAccount('0xc0ffee254729296a45a3885639AC7E10F9d54979'));
|
||||
* ```
|
||||
*
|
||||
* @param address - The account address to be validated.
|
||||
* @returns true - If the address has been registered in the accounts registry.
|
||||
*/
|
||||
public async haveAccount(address: string): Promise<boolean> {
|
||||
return await this.contract.methods.accountIndex(address).call() !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specified number of the most recently registered accounts.
|
||||
*
|
||||
* @async
|
||||
* @example
|
||||
* Prints an array of accounts:
|
||||
* ```typescript
|
||||
* console.log(await last(5));
|
||||
* ```
|
||||
*
|
||||
* @param numberOfAccounts - The number of accounts to return from the accounts registry.
|
||||
* @returns An array of registered account addresses.
|
||||
*/
|
||||
public async last(numberOfAccounts: number): Promise<Array<string>> {
|
||||
const count: number = await this.totalAccounts();
|
||||
let lowest: number = count - numberOfAccounts - 1;
|
||||
@@ -600,11 +786,20 @@ export class AccountIndex {
|
||||
return accounts;
|
||||
}
|
||||
|
||||
public async addToAccountRegistry(address: string): Promise<boolean> {
|
||||
if (!await this.haveAccount(address)) {
|
||||
return await this.contract.methods.add(address).send({from: this.signerAddress});
|
||||
}
|
||||
return true;
|
||||
/**
|
||||
* Returns the total number of accounts that have been registered in the network.
|
||||
*
|
||||
* @async
|
||||
* @example
|
||||
* Prints the total number of registered accounts:
|
||||
* ```typescript
|
||||
* console.log(await totalAccounts());
|
||||
* ```
|
||||
*
|
||||
* @returns The total number of registered accounts.
|
||||
*/
|
||||
public async totalAccounts(): Promise<number> {
|
||||
return await this.contract.methods.count().call();
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
@@ -269,6 +269,11 @@ export class GlobalErrorHandler extends ErrorHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param errorTraceString
|
||||
* @private
|
||||
*/
|
||||
private isWarning(errorTraceString: string): boolean {
|
||||
let isWarning: boolean = true;
|
||||
if (errorTraceString.includes('/src/app/')) {
|
||||
|
||||
@@ -72,6 +72,11 @@
|
||||
<code><a href="../interfaces/MutableKeyStore.html" target="_self" >MutableKeyStore</a></code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Example</h3>
|
||||
</p>
|
||||
<div class="io-description">
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
@@ -208,8 +213,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="142"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:142</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="148"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:148</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -247,8 +252,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="66"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:66</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="72"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:72</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -286,8 +291,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="94"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:94</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="100"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:100</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -325,8 +330,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="100"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:100</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="106"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:106</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -395,8 +400,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="109"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:109</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="115"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:115</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -465,8 +470,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="74"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:74</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="80"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:80</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -504,8 +509,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="117"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:117</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="123"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:123</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -570,8 +575,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="104"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:104</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="110"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:110</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -609,8 +614,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="70"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:70</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="76"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:76</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -648,8 +653,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="113"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:113</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="119"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:119</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -714,8 +719,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="121"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:121</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="127"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:127</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -780,8 +785,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="54"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:54</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="60"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:60</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -819,8 +824,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="125"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:125</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="131"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:131</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -885,8 +890,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="62"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:62</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="68"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:68</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -924,8 +929,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="58"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:58</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="64"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:64</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -965,8 +970,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="41"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:41</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="47"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:47</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1049,8 +1054,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="50"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:50</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="56"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:56</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1119,8 +1124,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="46"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:46</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="52"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:52</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1191,8 +1196,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="84"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:84</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="90"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:90</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1263,8 +1268,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="78"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:78</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="84"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:84</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1331,8 +1336,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="36"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:36</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="42"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:42</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1370,8 +1375,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="129"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:129</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="135"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:135</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1436,8 +1441,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="137"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:137</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="143"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:143</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1506,8 +1511,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="133"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:133</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="139"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:139</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1574,8 +1579,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="146"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:146</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="152"
|
||||
class="link-to-prism">src/app/_pgp/pgp-key-store.ts:152</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1633,6 +1638,9 @@
|
||||
import * as openpgp from 'openpgp';
|
||||
const keyring = new openpgp.Keyring();
|
||||
|
||||
/**
|
||||
* @extends
|
||||
*/
|
||||
interface MutableKeyStore extends KeyStore {
|
||||
loadKeyring(): void;
|
||||
importKeyPair(publicKey: any, privateKey: any): Promise<void>;
|
||||
@@ -1661,6 +1669,9 @@ interface MutableKeyStore extends KeyStore {
|
||||
sign(plainText: string): Promise<any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @implements
|
||||
*/
|
||||
class MutablePgpKeyStore implements MutableKeyStore{
|
||||
|
||||
async loadKeyring(): Promise<void> {
|
||||
|
||||
@@ -63,9 +63,22 @@
|
||||
<code>src/app/_eth/token-registry.ts</code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Description</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<p>Provides an instance of the token registry contract.
|
||||
Allows querying of tokens that have been registered as valid tokens in the network.</p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<p class="comment">
|
||||
<h3>Example</h3>
|
||||
</p>
|
||||
<div class="io-description">
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
@@ -138,12 +151,14 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="10" class="link-to-prism">src/app/_eth/token-registry.ts:10</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="26" class="link-to-prism">src/app/_eth/token-registry.ts:26</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Create a connection to the deployed token registry contract.</p>
|
||||
</div>
|
||||
<div>
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
@@ -152,6 +167,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -166,6 +182,12 @@
|
||||
No
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<code><ul>
|
||||
<li>The deployed token registry contract's address.</li>
|
||||
</ul>
|
||||
</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>signerAddress</td>
|
||||
@@ -178,6 +200,12 @@
|
||||
Yes
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<code><ul>
|
||||
<li>The account address of the account that deployed the token registry contract.</li>
|
||||
</ul>
|
||||
</code>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -213,10 +241,16 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="10" class="link-to-prism">src/app/_eth/token-registry.ts:10</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="22" class="link-to-prism">src/app/_eth/token-registry.ts:22</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>The instance of the token registry contract. </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -240,10 +274,16 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="8" class="link-to-prism">src/app/_eth/token-registry.ts:8</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="24" class="link-to-prism">src/app/_eth/token-registry.ts:24</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>The deployed token registry contract's address. </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -267,10 +307,16 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="9" class="link-to-prism">src/app/_eth/token-registry.ts:9</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="26" class="link-to-prism">src/app/_eth/token-registry.ts:26</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>The account address of the account that deployed the token registry contract. </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -306,14 +352,16 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="30"
|
||||
class="link-to-prism">src/app/_eth/token-registry.ts:30</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="57"
|
||||
class="link-to-prism">src/app/_eth/token-registry.ts:57</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Returns the address of the token with a given identifier.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
@@ -323,6 +371,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -337,18 +386,34 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The name or identifier of the token to be fetched from the token registry.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<b>Example :</b>
|
||||
<div>
|
||||
<pre class="line-numbers"><code class="language-html">Prints the address of the token with the identifier &#39;sarafu&#39;:</p>
|
||||
<p>```typescript</p>
|
||||
<ul>
|
||||
<li>console.log(await addressOf(&#39;sarafu&#39;));</li>
|
||||
<li>```</li>
|
||||
</ul></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<string></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
|
||||
<p>The address of the token assigned the specified identifier in the token registry.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -379,14 +444,16 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="26"
|
||||
class="link-to-prism">src/app/_eth/token-registry.ts:26</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="75"
|
||||
class="link-to-prism">src/app/_eth/token-registry.ts:75</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Returns the address of a token with the given serial in the token registry.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
@@ -396,6 +463,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -410,18 +478,34 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The serial number of the token to be fetched.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<b>Example :</b>
|
||||
<div>
|
||||
<pre class="line-numbers"><code class="language-html">Prints the address of the token with the serial &#39;2&#39;:</p>
|
||||
<p>```typescript</p>
|
||||
<ul>
|
||||
<li>console.log(await entry(2));</li>
|
||||
<li>```</li>
|
||||
</ul></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<string></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
|
||||
<p>The address of the token with the specified serial number.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -452,19 +536,36 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="22"
|
||||
class="link-to-prism">src/app/_eth/token-registry.ts:22</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="91"
|
||||
class="link-to-prism">src/app/_eth/token-registry.ts:91</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Returns the total number of tokens that have been registered in the network.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<b>Example :</b>
|
||||
<div>
|
||||
<pre class="line-numbers"><code class="language-html">Prints the total number of registered tokens:</p>
|
||||
<p>```typescript</p>
|
||||
<ul>
|
||||
<li>console.log(await totalTokens());</li>
|
||||
<li>```</li>
|
||||
</ul></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<number></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<p>The total number of registered tokens.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -480,16 +581,37 @@
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import Web3 from 'web3';
|
||||
|
||||
// Application imports
|
||||
import {environment} from '@src/environments/environment';
|
||||
|
||||
|
||||
/** Fetch the token registry contract's ABI. */
|
||||
const abi: Array<any> = require('@src/assets/js/block-sync/data/TokenUniqueSymbolIndex.json');
|
||||
/** Establish a connection to the blockchain network. */
|
||||
const web3: Web3 = new Web3(environment.web3Provider);
|
||||
|
||||
/**
|
||||
* Provides an instance of the token registry contract.
|
||||
* Allows querying of tokens that have been registered as valid tokens in the network.
|
||||
*
|
||||
* @remarks
|
||||
* This is our interface to the token registry contract.
|
||||
*/
|
||||
export class TokenRegistry {
|
||||
contractAddress: string;
|
||||
signerAddress: string;
|
||||
/** The instance of the token registry contract. */
|
||||
contract: any;
|
||||
/** The deployed token registry contract's address. */
|
||||
contractAddress: string;
|
||||
/** The account address of the account that deployed the token registry contract. */
|
||||
signerAddress: string;
|
||||
|
||||
/**
|
||||
* Create a connection to the deployed token registry contract.
|
||||
*
|
||||
* @param contractAddress - The deployed token registry contract's address.
|
||||
* @param signerAddress - The account address of the account that deployed the token registry contract.
|
||||
*/
|
||||
constructor(contractAddress: string, signerAddress?: string) {
|
||||
this.contractAddress = contractAddress;
|
||||
this.contract = new web3.eth.Contract(abi, this.contractAddress);
|
||||
@@ -500,17 +622,55 @@ export class TokenRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
public async totalTokens(): Promise<number> {
|
||||
return await this.contract.methods.entryCount().call();
|
||||
/**
|
||||
* Returns the address of the token with a given identifier.
|
||||
*
|
||||
* @async
|
||||
* @example
|
||||
* Prints the address of the token with the identifier 'sarafu':
|
||||
* ```typescript
|
||||
* console.log(await addressOf('sarafu'));
|
||||
* ```
|
||||
*
|
||||
* @param identifier - The name or identifier of the token to be fetched from the token registry.
|
||||
* @returns The address of the token assigned the specified identifier in the token registry.
|
||||
*/
|
||||
public async addressOf(identifier: string): Promise<string> {
|
||||
const id: string = web3.eth.abi.encodeParameter('bytes32', web3.utils.toHex(identifier));
|
||||
return await this.contract.methods.addressOf(id).call();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address of a token with the given serial in the token registry.
|
||||
*
|
||||
* @async
|
||||
* @example
|
||||
* Prints the address of the token with the serial '2':
|
||||
* ```typescript
|
||||
* console.log(await entry(2));
|
||||
* ```
|
||||
*
|
||||
* @param serial - The serial number of the token to be fetched.
|
||||
* @return The address of the token with the specified serial number.
|
||||
*/
|
||||
public async entry(serial: number): Promise<string> {
|
||||
return await this.contract.methods.entry(serial).call();
|
||||
}
|
||||
|
||||
public async addressOf(identifier: string): Promise<string> {
|
||||
const id: string = web3.eth.abi.encodeParameter('bytes32', web3.utils.toHex(identifier));
|
||||
return await this.contract.methods.addressOf(id).call();
|
||||
/**
|
||||
* Returns the total number of tokens that have been registered in the network.
|
||||
*
|
||||
* @async
|
||||
* @example
|
||||
* Prints the total number of registered tokens:
|
||||
* ```typescript
|
||||
* console.log(await totalTokens());
|
||||
* ```
|
||||
*
|
||||
* @returns The total number of registered tokens.
|
||||
*/
|
||||
public async totalTokens(): Promise<number> {
|
||||
return await this.contract.methods.entryCount().call();
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
Reference in New Issue
Block a user