Update cic-client library.

This commit is contained in:
Spencer Ofwiti 2021-06-10 18:40:45 +03:00
parent aebb0bdd4d
commit d90ab9f375
7 changed files with 800 additions and 775 deletions

1469
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -33,10 +33,10 @@
"@angular/platform-browser-dynamic": "~10.2.0", "@angular/platform-browser-dynamic": "~10.2.0",
"@angular/router": "~10.2.0", "@angular/router": "~10.2.0",
"@angular/service-worker": "~10.2.0", "@angular/service-worker": "~10.2.0",
"@cicnet/cic-client": "^0.1.6",
"@cicnet/schemas-data-validator": "*", "@cicnet/schemas-data-validator": "*",
"@popperjs/core": "^2.5.4", "@popperjs/core": "^2.5.4",
"bootstrap": "^4.5.3", "bootstrap": "^4.5.3",
"cic-client": "0.1.4",
"cic-client-meta": "0.0.7-alpha.6", "cic-client-meta": "0.0.7-alpha.6",
"ethers": "^5.0.31", "ethers": "^5.0.31",
"http-server": "^0.12.3", "http-server": "^0.12.3",

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Settings } from '@app/_models'; import { Settings } from '@app/_models';
import { TransactionHelper } from 'cic-client'; import { TransactionHelper } from '@cicnet/cic-client';
import { first } from 'rxjs/operators'; import { first } from 'rxjs/operators';
import { TransactionService } from '@app/_services/transaction.service'; import { TransactionService } from '@app/_services/transaction.service';
import { environment } from '@src/environments/environment'; import { environment } from '@src/environments/environment';
@ -39,10 +39,6 @@ export class BlockSyncService {
settings.txHelper.onconversion = async (transaction: any): Promise<any> => { settings.txHelper.onconversion = async (transaction: any): Promise<any> => {
window.dispatchEvent(this.newEvent(transaction, 'cic_convert')); window.dispatchEvent(this.newEvent(transaction, 'cic_convert'));
}; };
// settings.registry.onload = (addressReturned: string): void => {
// this.loggingService.sendInfoLevelMessage(`Loaded network contracts ${addressReturned}`);
// this.readyStateProcessor(settings, readyStateElements.network, address, offset, limit);
// };
this.readyStateProcessor(settings, readyStateElements.network, address, offset, limit); this.readyStateProcessor(settings, readyStateElements.network, address, offset, limit);
} }

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { environment } from '@src/environments/environment'; import { environment } from '@src/environments/environment';
import { CICRegistry, FileGetter } from 'cic-client'; import { CICRegistry, FileGetter } from '@cicnet/cic-client';
import { HttpGetter } from '@app/_helpers'; import { HttpGetter } from '@app/_helpers';
import { Web3Service } from '@app/_services/web3.service'; import { Web3Service } from '@app/_services/web3.service';

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CICRegistry } from 'cic-client'; import { CICRegistry } from '@cicnet/cic-client';
import { TokenRegistry } from '@app/_eth'; import { TokenRegistry } from '@app/_eth';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { RegistryService } from '@app/_services/registry.service'; import { RegistryService } from '@app/_services/registry.service';
@ -23,12 +23,10 @@ export class TokenService {
async init(): Promise<void> { async init(): Promise<void> {
this.registry = await RegistryService.getRegistry(); this.registry = await RegistryService.getRegistry();
this.registry.onload = async (address: string): Promise<void> => {
this.tokenRegistry = new TokenRegistry( this.tokenRegistry = new TokenRegistry(
await this.registry.getContractAddressByName('TokenRegistry') await this.registry.getContractAddressByName('TokenRegistry')
); );
this.load.next(true); this.load.next(true);
};
} }
addToken(token: Token): void { addToken(token: Token): void {
@ -73,17 +71,17 @@ export class TokenService {
} }
async getTokenBalance(address: string): Promise<(address: string) => Promise<number>> { async getTokenBalance(address: string): Promise<(address: string) => Promise<number>> {
const token = await this.registry.getTokenBySymbol('TokenRegistry', 'GFT'); const token = await this.registry.addToken(await this.tokenRegistry.entry(0));
return await token.methods.balanceOf(address).call(); return await token.methods.balanceOf(address).call();
} }
async getTokenName(): Promise<string> { async getTokenName(): Promise<string> {
const token = await this.registry.getTokenBySymbol('TokenRegistry', 'GFT'); const token = await this.registry.addToken(await this.tokenRegistry.entry(0));
return await token.methods.name().call(); return await token.methods.name().call();
} }
async getTokenSymbol(): Promise<string> { async getTokenSymbol(): Promise<string> {
const token = await this.registry.getTokenBySymbol('TokenRegistry', 'GFT'); const token = await this.registry.addToken(await this.tokenRegistry.entry(0));
return await token.methods.symbol().call(); return await token.methods.symbol().call();
} }
} }

View File

@ -14,7 +14,7 @@ import { AuthService } from '@app/_services/auth.service';
import { defaultAccount } from '@app/_models'; import { defaultAccount } from '@app/_models';
import { LoggingService } from '@app/_services/logging.service'; import { LoggingService } from '@app/_services/logging.service';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { CICRegistry } from 'cic-client'; import { CICRegistry } from '@cicnet/cic-client';
import { RegistryService } from '@app/_services/registry.service'; import { RegistryService } from '@app/_services/registry.service';
import Web3 from 'web3'; import Web3 from 'web3';
import { Web3Service } from '@app/_services/web3.service'; import { Web3Service } from '@app/_services/web3.service';
@ -148,7 +148,6 @@ export class TransactionService {
recipientAddress: string, recipientAddress: string,
value: number value: number
): Promise<any> { ): Promise<any> {
this.registry.onload = async (addressReturned: string): Promise<void> => {
const transferAuthAddress = await this.registry.getContractAddressByName( const transferAuthAddress = await this.registry.getContractAddressByName(
'TransferAuthorization' 'TransferAuthorization'
); );
@ -185,6 +184,5 @@ export class TransactionService {
this.loggingService.sendInfoLevelMessage(`Result: ${result}`); this.loggingService.sendInfoLevelMessage(`Result: ${result}`);
const transaction = await this.web3.eth.getTransaction(result.transactionHash); const transaction = await this.web3.eth.getTransaction(result.transactionHash);
this.loggingService.sendInfoLevelMessage(`Transaction: ${transaction}`); this.loggingService.sendInfoLevelMessage(`Transaction: ${transaction}`);
};
} }
} }

View File

@ -10,7 +10,7 @@ import { TokenService } from '@app/_services/token.service';
import { AccountIndex } from '@app/_eth'; import { AccountIndex } from '@app/_eth';
import { MutableKeyStore, PGPSigner, Signer } from '@app/_pgp'; import { MutableKeyStore, PGPSigner, Signer } from '@app/_pgp';
import { RegistryService } from '@app/_services/registry.service'; import { RegistryService } from '@app/_services/registry.service';
import { CICRegistry } from 'cic-client'; import { CICRegistry } from '@cicnet/cic-client';
import { AuthService } from '@app/_services/auth.service'; import { AuthService } from '@app/_services/auth.service';
import { personValidation, vcardValidation } from '@app/_helpers'; import { personValidation, vcardValidation } from '@app/_helpers';
import { add0x } from '@src/assets/js/ethtx/dist/hex'; import { add0x } from '@src/assets/js/ethtx/dist/hex';