Update cic-client library.
This commit is contained in:
parent
aebb0bdd4d
commit
d90ab9f375
1469
package-lock.json
generated
1469
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -33,10 +33,10 @@
|
||||
"@angular/platform-browser-dynamic": "~10.2.0",
|
||||
"@angular/router": "~10.2.0",
|
||||
"@angular/service-worker": "~10.2.0",
|
||||
"@cicnet/cic-client": "^0.1.6",
|
||||
"@cicnet/schemas-data-validator": "*",
|
||||
"@popperjs/core": "^2.5.4",
|
||||
"bootstrap": "^4.5.3",
|
||||
"cic-client": "0.1.4",
|
||||
"cic-client-meta": "0.0.7-alpha.6",
|
||||
"ethers": "^5.0.31",
|
||||
"http-server": "^0.12.3",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Settings } from '@app/_models';
|
||||
import { TransactionHelper } from 'cic-client';
|
||||
import { TransactionHelper } from '@cicnet/cic-client';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { TransactionService } from '@app/_services/transaction.service';
|
||||
import { environment } from '@src/environments/environment';
|
||||
@ -39,10 +39,6 @@ export class BlockSyncService {
|
||||
settings.txHelper.onconversion = async (transaction: any): Promise<any> => {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
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 { Web3Service } from '@app/_services/web3.service';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CICRegistry } from 'cic-client';
|
||||
import { CICRegistry } from '@cicnet/cic-client';
|
||||
import { TokenRegistry } from '@app/_eth';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { RegistryService } from '@app/_services/registry.service';
|
||||
@ -23,12 +23,10 @@ export class TokenService {
|
||||
|
||||
async init(): Promise<void> {
|
||||
this.registry = await RegistryService.getRegistry();
|
||||
this.registry.onload = async (address: string): Promise<void> => {
|
||||
this.tokenRegistry = new TokenRegistry(
|
||||
await this.registry.getContractAddressByName('TokenRegistry')
|
||||
);
|
||||
this.load.next(true);
|
||||
};
|
||||
this.tokenRegistry = new TokenRegistry(
|
||||
await this.registry.getContractAddressByName('TokenRegistry')
|
||||
);
|
||||
this.load.next(true);
|
||||
}
|
||||
|
||||
addToken(token: Token): void {
|
||||
@ -73,17 +71,17 @@ export class TokenService {
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import { AuthService } from '@app/_services/auth.service';
|
||||
import { defaultAccount } from '@app/_models';
|
||||
import { LoggingService } from '@app/_services/logging.service';
|
||||
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 Web3 from 'web3';
|
||||
import { Web3Service } from '@app/_services/web3.service';
|
||||
@ -148,43 +148,41 @@ export class TransactionService {
|
||||
recipientAddress: string,
|
||||
value: number
|
||||
): Promise<any> {
|
||||
this.registry.onload = async (addressReturned: string): Promise<void> => {
|
||||
const transferAuthAddress = await this.registry.getContractAddressByName(
|
||||
'TransferAuthorization'
|
||||
);
|
||||
const hashFunction = new Keccak(256);
|
||||
hashFunction.update('createRequest(address,address,address,uint256)');
|
||||
const hash = hashFunction.digest();
|
||||
const methodSignature = hash.toString('hex').substring(0, 8);
|
||||
const abiCoder = new utils.AbiCoder();
|
||||
const abi = await abiCoder.encode(
|
||||
['address', 'address', 'address', 'uint256'],
|
||||
[senderAddress, recipientAddress, tokenAddress, value]
|
||||
);
|
||||
const data = fromHex(methodSignature + strip0x(abi));
|
||||
const tx = new Tx(environment.bloxbergChainId);
|
||||
tx.nonce = await this.web3.eth.getTransactionCount(senderAddress);
|
||||
tx.gasPrice = Number(await this.web3.eth.getGasPrice());
|
||||
tx.gasLimit = 8000000;
|
||||
tx.to = fromHex(strip0x(transferAuthAddress));
|
||||
tx.value = toValue(value);
|
||||
tx.data = data;
|
||||
const txMsg = tx.message();
|
||||
const privateKey = this.authService.mutableKeyStore.getPrivateKey();
|
||||
if (!privateKey.isDecrypted()) {
|
||||
const password = window.prompt('password');
|
||||
await privateKey.decrypt(password);
|
||||
}
|
||||
const signatureObject = secp256k1.ecdsaSign(txMsg, privateKey.keyPacket.privateParams.d);
|
||||
const r = signatureObject.signature.slice(0, 32);
|
||||
const s = signatureObject.signature.slice(32);
|
||||
const v = signatureObject.recid;
|
||||
tx.setSignature(r, s, v);
|
||||
const txWire = add0x(toHex(tx.serializeRLP()));
|
||||
const result = await this.web3.eth.sendSignedTransaction(txWire);
|
||||
this.loggingService.sendInfoLevelMessage(`Result: ${result}`);
|
||||
const transaction = await this.web3.eth.getTransaction(result.transactionHash);
|
||||
this.loggingService.sendInfoLevelMessage(`Transaction: ${transaction}`);
|
||||
};
|
||||
const transferAuthAddress = await this.registry.getContractAddressByName(
|
||||
'TransferAuthorization'
|
||||
);
|
||||
const hashFunction = new Keccak(256);
|
||||
hashFunction.update('createRequest(address,address,address,uint256)');
|
||||
const hash = hashFunction.digest();
|
||||
const methodSignature = hash.toString('hex').substring(0, 8);
|
||||
const abiCoder = new utils.AbiCoder();
|
||||
const abi = await abiCoder.encode(
|
||||
['address', 'address', 'address', 'uint256'],
|
||||
[senderAddress, recipientAddress, tokenAddress, value]
|
||||
);
|
||||
const data = fromHex(methodSignature + strip0x(abi));
|
||||
const tx = new Tx(environment.bloxbergChainId);
|
||||
tx.nonce = await this.web3.eth.getTransactionCount(senderAddress);
|
||||
tx.gasPrice = Number(await this.web3.eth.getGasPrice());
|
||||
tx.gasLimit = 8000000;
|
||||
tx.to = fromHex(strip0x(transferAuthAddress));
|
||||
tx.value = toValue(value);
|
||||
tx.data = data;
|
||||
const txMsg = tx.message();
|
||||
const privateKey = this.authService.mutableKeyStore.getPrivateKey();
|
||||
if (!privateKey.isDecrypted()) {
|
||||
const password = window.prompt('password');
|
||||
await privateKey.decrypt(password);
|
||||
}
|
||||
const signatureObject = secp256k1.ecdsaSign(txMsg, privateKey.keyPacket.privateParams.d);
|
||||
const r = signatureObject.signature.slice(0, 32);
|
||||
const s = signatureObject.signature.slice(32);
|
||||
const v = signatureObject.recid;
|
||||
tx.setSignature(r, s, v);
|
||||
const txWire = add0x(toHex(tx.serializeRLP()));
|
||||
const result = await this.web3.eth.sendSignedTransaction(txWire);
|
||||
this.loggingService.sendInfoLevelMessage(`Result: ${result}`);
|
||||
const transaction = await this.web3.eth.getTransaction(result.transactionHash);
|
||||
this.loggingService.sendInfoLevelMessage(`Transaction: ${transaction}`);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import { TokenService } from '@app/_services/token.service';
|
||||
import { AccountIndex } from '@app/_eth';
|
||||
import { MutableKeyStore, PGPSigner, Signer } from '@app/_pgp';
|
||||
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 { personValidation, vcardValidation } from '@app/_helpers';
|
||||
import { add0x } from '@src/assets/js/ethtx/dist/hex';
|
||||
|
Loading…
Reference in New Issue
Block a user