Format files using linter.

This commit is contained in:
Spencer Ofwiti 2021-06-14 16:50:04 +03:00
parent 1edf3e50ae
commit 472d9b2cd1
4 changed files with 72 additions and 73 deletions

View File

@ -35,12 +35,12 @@ export class AccountIndex {
this.contractAddress = contractAddress;
this.contract = new web3.eth.Contract(abi, this.contractAddress);
// TODO this signer logic should be part of the web3service
// if signer address is not passed (for example in user service) then
// if signer address is not passed (for example in user service) then
// this fallsback to a web3 wallet that is not even connected???
if (signerAddress) {
this.signerAddress = signerAddress;
this.signerAddress = signerAddress;
} else {
this.signerAddress = web3.eth.accounts[0];
this.signerAddress = web3.eth.accounts[0];
}
}

View File

@ -82,15 +82,14 @@ export class AuthService {
return fetch(environment.cicMetaUrl, options);
}
getChallenge(): Promise<any> {
return fetch(environment.cicMetaUrl)
.then(response => {
if (response.status === 401) {
const authHeader: string = response.headers.get('WWW-Authenticate');
return hobaParseChallengeHeader(authHeader);
}
});
}
getChallenge(): Promise<any> {
return fetch(environment.cicMetaUrl).then((response) => {
if (response.status === 401) {
const authHeader: string = response.headers.get('WWW-Authenticate');
return hobaParseChallengeHeader(authHeader);
}
});
}
async login(): Promise<boolean> {
if (this.getSessionToken()) {

View File

@ -9,58 +9,58 @@ import { Web3Service } from '@app/_services/web3.service';
providedIn: 'root',
})
export class RegistryService {
static fileGetter: FileGetter = new HttpGetter();
private static registry: CICRegistry;
private static tokenRegistry: TokenRegistry;
private static accountRegistry: AccountIndex;
static fileGetter: FileGetter = new HttpGetter();
private static registry: CICRegistry;
private static tokenRegistry: TokenRegistry;
private static accountRegistry: AccountIndex;
public static async getRegistry(): Promise<CICRegistry> {
if (!RegistryService.registry) {
RegistryService.registry = new CICRegistry(
Web3Service.getInstance(),
environment.registryAddress,
'Registry',
RegistryService.fileGetter,
['../../assets/js/block-sync/data']
);
RegistryService.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress);
await RegistryService.registry.load()
public static async getRegistry(): Promise<CICRegistry> {
if (!RegistryService.registry) {
RegistryService.registry = new CICRegistry(
Web3Service.getInstance(),
environment.registryAddress,
'Registry',
RegistryService.fileGetter,
['../../assets/js/block-sync/data']
);
RegistryService.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress);
await RegistryService.registry.load();
}
return RegistryService.registry;
}
public static async getTokenRegistry(): Promise<TokenRegistry> {
return new Promise(async (resolve, reject) => {
if (!RegistryService.tokenRegistry) {
const registry = await RegistryService.getRegistry();
const tokenRegistryAddress = await RegistryService.registry.getContractAddressByName(
'TokenRegistry'
);
if (!tokenRegistryAddress) {
return reject('Unable to initialize Token Registry');
}
return RegistryService.registry;
}
RegistryService.tokenRegistry = new TokenRegistry(tokenRegistryAddress);
return resolve(RegistryService.tokenRegistry);
}
return resolve(RegistryService.tokenRegistry);
});
}
public static async getTokenRegistry(): Promise<TokenRegistry> {
return new Promise(async (resolve, reject) => {
if (!RegistryService.tokenRegistry) {
const registry = await RegistryService.getRegistry()
const tokenRegistryAddress = await RegistryService.registry.getContractAddressByName('TokenRegistry')
if (!tokenRegistryAddress) {
return reject("Unable to initialize Token Registry")
}
RegistryService.tokenRegistry = new TokenRegistry(tokenRegistryAddress);
return resolve(RegistryService.tokenRegistry)
}
return resolve(RegistryService.tokenRegistry);
})
}
public static async getAccountRegistry(): Promise<AccountIndex> {
return new Promise(async (resolve, reject) => {
if (!RegistryService.accountRegistry) {
const registry = await RegistryService.getRegistry()
const accountRegistryAddress = await RegistryService
.registry
.getContractAddressByName('AccountRegistry')
if (!accountRegistryAddress) {
return reject("Unable to initialize Account Registry")
}
RegistryService.accountRegistry = new AccountIndex(accountRegistryAddress);
return resolve(RegistryService.accountRegistry)
}
return resolve(RegistryService.accountRegistry);
})
}
public static async getAccountRegistry(): Promise<AccountIndex> {
return new Promise(async (resolve, reject) => {
if (!RegistryService.accountRegistry) {
const registry = await RegistryService.getRegistry();
const accountRegistryAddress = await RegistryService.registry.getContractAddressByName(
'AccountRegistry'
);
if (!accountRegistryAddress) {
return reject('Unable to initialize Account Registry');
}
RegistryService.accountRegistry = new AccountIndex(accountRegistryAddress);
return resolve(RegistryService.accountRegistry);
}
return resolve(RegistryService.accountRegistry);
});
}
}

View File

@ -179,21 +179,21 @@ export class UserService {
async loadAccounts(limit: number = 100, offset: number = 0): Promise<void> {
this.resetAccountsList();
//const accountIndexAddress: string = await this.registry.getContractAddressByName(
// const accountIndexAddress: string = await this.registry.getContractAddressByName(
// 'AccountRegistry'
//);
//const accountIndexQuery = new AccountIndex(accountIndexAddress);
//const accountAddresses: Array<string> = await accountIndexQuery.last(limit);
try{
const accountRegistry = await RegistryService.getAccountRegistry();
const accountAddresses: Array<string> = await accountRegistry.last(limit);
this.loggingService.sendInfoLevelMessage(accountAddresses);
for (const accountAddress of accountAddresses.slice(offset, offset + limit)) {
// );
// const accountIndexQuery = new AccountIndex(accountIndexAddress);
// const accountAddresses: Array<string> = await accountIndexQuery.last(limit);
try {
const accountRegistry = await RegistryService.getAccountRegistry();
const accountAddresses: Array<string> = await accountRegistry.last(limit);
this.loggingService.sendInfoLevelMessage(accountAddresses);
for (const accountAddress of accountAddresses.slice(offset, offset + limit)) {
await this.getAccountByAddress(accountAddress, limit);
}
}
} catch (error) {
this.loggingService.sendErrorLevelMessage("Unable to load accounts.", "user.service", error)
throw error
this.loggingService.sendErrorLevelMessage('Unable to load accounts.', 'user.service', error);
throw error;
}
}