diff --git a/src/app/_eth/accountIndex.ts b/src/app/_eth/accountIndex.ts index c8c94a7..42b115d 100644 --- a/src/app/_eth/accountIndex.ts +++ b/src/app/_eth/accountIndex.ts @@ -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]; } } diff --git a/src/app/_services/auth.service.ts b/src/app/_services/auth.service.ts index 30f2fe8..bc26bd7 100644 --- a/src/app/_services/auth.service.ts +++ b/src/app/_services/auth.service.ts @@ -82,15 +82,14 @@ export class AuthService { return fetch(environment.cicMetaUrl, options); } - getChallenge(): Promise { - return fetch(environment.cicMetaUrl) - .then(response => { - if (response.status === 401) { - const authHeader: string = response.headers.get('WWW-Authenticate'); - return hobaParseChallengeHeader(authHeader); - } - }); - } + getChallenge(): Promise { + return fetch(environment.cicMetaUrl).then((response) => { + if (response.status === 401) { + const authHeader: string = response.headers.get('WWW-Authenticate'); + return hobaParseChallengeHeader(authHeader); + } + }); + } async login(): Promise { if (this.getSessionToken()) { diff --git a/src/app/_services/registry.service.ts b/src/app/_services/registry.service.ts index 467f76a..39dd58d 100644 --- a/src/app/_services/registry.service.ts +++ b/src/app/_services/registry.service.ts @@ -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 { - 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 { + 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 { + 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 { - 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 { - 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 { + 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); + }); + } } diff --git a/src/app/_services/user.service.ts b/src/app/_services/user.service.ts index 1bce78f..914e73f 100644 --- a/src/app/_services/user.service.ts +++ b/src/app/_services/user.service.ts @@ -179,21 +179,21 @@ export class UserService { async loadAccounts(limit: number = 100, offset: number = 0): Promise { 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 = await accountIndexQuery.last(limit); - try{ - const accountRegistry = await RegistryService.getAccountRegistry(); - const accountAddresses: Array = 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 = await accountIndexQuery.last(limit); + try { + const accountRegistry = await RegistryService.getAccountRegistry(); + const accountAddresses: Array = 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; } }