Format docs using linter and prettier.

This commit is contained in:
Spencer Ofwiti
2021-05-11 20:51:48 +03:00
parent 5228842e61
commit 208c448984
309 changed files with 11327 additions and 3307 deletions

View File

@@ -268,8 +268,8 @@
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="89"
class="link-to-prism">src/app/_services/transaction.service.ts:89</a></div>
<div class="io-line">Defined in <a href="" data-line="111"
class="link-to-prism">src/app/_services/transaction.service.ts:111</a></div>
</td>
</tr>
@@ -349,8 +349,8 @@
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="102"
class="link-to-prism">src/app/_services/transaction.service.ts:102</a></div>
<div class="io-line">Defined in <a href="" data-line="124"
class="link-to-prism">src/app/_services/transaction.service.ts:124</a></div>
</td>
</tr>
@@ -595,8 +595,8 @@
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="97"
class="link-to-prism">src/app/_services/transaction.service.ts:97</a></div>
<div class="io-line">Defined in <a href="" data-line="119"
class="link-to-prism">src/app/_services/transaction.service.ts:119</a></div>
</td>
</tr>
@@ -636,8 +636,8 @@
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="73"
class="link-to-prism">src/app/_services/transaction.service.ts:73</a></div>
<div class="io-line">Defined in <a href="" data-line="87"
class="link-to-prism">src/app/_services/transaction.service.ts:87</a></div>
</td>
</tr>
@@ -796,8 +796,8 @@
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="108"
class="link-to-prism">src/app/_services/transaction.service.ts:108</a></div>
<div class="io-line">Defined in <a href="" data-line="130"
class="link-to-prism">src/app/_services/transaction.service.ts:130</a></div>
</td>
</tr>
@@ -1059,28 +1059,28 @@
<div class="tab-pane fade tab-source-code" id="c-source">
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from &#x27;@angular/core&#x27;;
import {first} from &#x27;rxjs/operators&#x27;;
import {BehaviorSubject, Observable} from &#x27;rxjs&#x27;;
import {environment} from &#x27;@src/environments/environment&#x27;;
import {Envelope, User} from &#x27;cic-client-meta&#x27;;
import {UserService} from &#x27;@app/_services/user.service&#x27;;
import { first } from &#x27;rxjs/operators&#x27;;
import { BehaviorSubject, Observable } from &#x27;rxjs&#x27;;
import { environment } from &#x27;@src/environments/environment&#x27;;
import { Envelope, User } from &#x27;cic-client-meta&#x27;;
import { UserService } from &#x27;@app/_services/user.service&#x27;;
import { Keccak } from &#x27;sha3&#x27;;
import { utils } from &#x27;ethers&#x27;;
import {add0x, fromHex, strip0x, toHex} from &#x27;@src/assets/js/ethtx/dist/hex&#x27;;
import {Tx} from &#x27;@src/assets/js/ethtx/dist&#x27;;
import {toValue} from &#x27;@src/assets/js/ethtx/dist/tx&#x27;;
import { add0x, fromHex, strip0x, toHex } from &#x27;@src/assets/js/ethtx/dist/hex&#x27;;
import { Tx } from &#x27;@src/assets/js/ethtx/dist&#x27;;
import { toValue } from &#x27;@src/assets/js/ethtx/dist/tx&#x27;;
import * as secp256k1 from &#x27;secp256k1&#x27;;
import {AuthService} from &#x27;@app/_services/auth.service&#x27;;
import {defaultAccount} from &#x27;@app/_models&#x27;;
import {LoggingService} from &#x27;@app/_services/logging.service&#x27;;
import {HttpClient} from &#x27;@angular/common/http&#x27;;
import {CICRegistry} from &#x27;cic-client&#x27;;
import {RegistryService} from &#x27;@app/_services/registry.service&#x27;;
import { AuthService } from &#x27;@app/_services/auth.service&#x27;;
import { defaultAccount } from &#x27;@app/_models&#x27;;
import { LoggingService } from &#x27;@app/_services/logging.service&#x27;;
import { HttpClient } from &#x27;@angular/common/http&#x27;;
import { CICRegistry } from &#x27;cic-client&#x27;;
import { RegistryService } from &#x27;@app/_services/registry.service&#x27;;
import Web3 from &#x27;web3&#x27;;
const vCard &#x3D; require(&#x27;vcard-parser&#x27;);
@Injectable({
providedIn: &#x27;root&#x27;
providedIn: &#x27;root&#x27;,
})
export class TransactionService {
transactions: any[] &#x3D; [];
@@ -1095,7 +1095,7 @@ export class TransactionService {
private authService: AuthService,
private userService: UserService,
private loggingService: LoggingService,
private registryService: RegistryService,
private registryService: RegistryService
) {
this.web3 &#x3D; this.registryService.getWeb3();
this.registry &#x3D; registryService.getRegistry();
@@ -1111,36 +1111,58 @@ export class TransactionService {
}
async setTransaction(transaction, cacheSize: number): Promise&lt;void&gt; {
if (this.transactions.find(cachedTx &#x3D;&gt; cachedTx.tx.txHash &#x3D;&#x3D;&#x3D; transaction.tx.txHash)) { return; }
if (this.transactions.find((cachedTx) &#x3D;&gt; cachedTx.tx.txHash &#x3D;&#x3D;&#x3D; transaction.tx.txHash)) {
return;
}
transaction.value &#x3D; Number(transaction.value);
transaction.type &#x3D; &#x27;transaction&#x27;;
try {
this.userService.getAccountDetailsFromMeta(await User.toKey(transaction.from)).pipe(first()).subscribe((res) &#x3D;&gt; {
transaction.sender &#x3D; this.getAccountInfo(res.body);
}, error &#x3D;&gt; {
transaction.sender &#x3D; defaultAccount;
});
this.userService.getAccountDetailsFromMeta(await User.toKey(transaction.to)).pipe(first()).subscribe((res) &#x3D;&gt; {
transaction.recipient &#x3D; this.getAccountInfo(res.body);
}, error &#x3D;&gt; {
transaction.recipient &#x3D; defaultAccount;
});
this.userService
.getAccountDetailsFromMeta(await User.toKey(transaction.from))
.pipe(first())
.subscribe(
(res) &#x3D;&gt; {
transaction.sender &#x3D; this.getAccountInfo(res.body);
},
(error) &#x3D;&gt; {
transaction.sender &#x3D; defaultAccount;
}
);
this.userService
.getAccountDetailsFromMeta(await User.toKey(transaction.to))
.pipe(first())
.subscribe(
(res) &#x3D;&gt; {
transaction.recipient &#x3D; this.getAccountInfo(res.body);
},
(error) &#x3D;&gt; {
transaction.recipient &#x3D; defaultAccount;
}
);
} finally {
this.addTransaction(transaction, cacheSize);
}
}
async setConversion(conversion, cacheSize): Promise&lt;void&gt; {
if (this.transactions.find(cachedTx &#x3D;&gt; cachedTx.tx.txHash &#x3D;&#x3D;&#x3D; conversion.tx.txHash)) { return; }
if (this.transactions.find((cachedTx) &#x3D;&gt; cachedTx.tx.txHash &#x3D;&#x3D;&#x3D; conversion.tx.txHash)) {
return;
}
conversion.type &#x3D; &#x27;conversion&#x27;;
conversion.fromValue &#x3D; Number(conversion.fromValue);
conversion.toValue &#x3D; Number(conversion.toValue);
try {
this.userService.getAccountDetailsFromMeta(await User.toKey(conversion.trader)).pipe(first()).subscribe((res) &#x3D;&gt; {
conversion.sender &#x3D; conversion.recipient &#x3D; this.getAccountInfo(res.body);
}, error &#x3D;&gt; {
conversion.sender &#x3D; conversion.recipient &#x3D; defaultAccount;
});
this.userService
.getAccountDetailsFromMeta(await User.toKey(conversion.trader))
.pipe(first())
.subscribe(
(res) &#x3D;&gt; {
conversion.sender &#x3D; conversion.recipient &#x3D; this.getAccountInfo(res.body);
},
(error) &#x3D;&gt; {
conversion.sender &#x3D; conversion.recipient &#x3D; defaultAccount;
}
);
} finally {
this.addTransaction(conversion, cacheSize);
}
@@ -1160,19 +1182,29 @@ export class TransactionService {
}
getAccountInfo(account: string): any {
let accountInfo &#x3D; Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data;
const accountInfo &#x3D; Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data;
accountInfo.vcard &#x3D; vCard.parse(atob(accountInfo.vcard));
return accountInfo;
}
async transferRequest(tokenAddress: string, senderAddress: string, recipientAddress: string, value: number): Promise&lt;any&gt; {
const transferAuthAddress &#x3D; await this.registry.getContractAddressByName(&#x27;TransferAuthorization&#x27;);
async transferRequest(
tokenAddress: string,
senderAddress: string,
recipientAddress: string,
value: number
): Promise&lt;any&gt; {
const transferAuthAddress &#x3D; await this.registry.getContractAddressByName(
&#x27;TransferAuthorization&#x27;
);
const hashFunction &#x3D; new Keccak(256);
hashFunction.update(&#x27;createRequest(address,address,address,uint256)&#x27;);
const hash &#x3D; hashFunction.digest();
const methodSignature &#x3D; hash.toString(&#x27;hex&#x27;).substring(0, 8);
const abiCoder &#x3D; new utils.AbiCoder();
const abi &#x3D; await abiCoder.encode([&#x27;address&#x27;, &#x27;address&#x27;, &#x27;address&#x27;, &#x27;uint256&#x27;], [senderAddress, recipientAddress, tokenAddress, value]);
const abi &#x3D; await abiCoder.encode(
[&#x27;address&#x27;, &#x27;address&#x27;, &#x27;address&#x27;, &#x27;uint256&#x27;],
[senderAddress, recipientAddress, tokenAddress, value]
);
const data &#x3D; fromHex(methodSignature + strip0x(abi));
const tx &#x3D; new Tx(environment.bloxbergChainId);
tx.nonce &#x3D; await this.web3.eth.getTransactionCount(senderAddress);
@@ -1182,7 +1214,7 @@ export class TransactionService {
tx.value &#x3D; toValue(value);
tx.data &#x3D; data;
const txMsg &#x3D; tx.message();
const privateKey &#x3D; this.authService.mutableKeyStore.getPrivateKey();
const privateKey &#x3D; this.authService.mutableKeyStore.getPrivateKey();
if (!privateKey.isDecrypted()) {
const password &#x3D; window.prompt(&#x27;password&#x27;);
await privateKey.decrypt(password);