diff --git a/src/app/_models/account.ts b/src/app/_models/account.ts index 0140bd8..aee0574 100644 --- a/src/app/_models/account.ts +++ b/src/app/_models/account.ts @@ -129,7 +129,7 @@ const defaultAccount: AccountDetails = { meta: { TYP: [], }, - value: '', + value: '+254700000000', }, ], version: [ diff --git a/src/app/_services/transaction.service.ts b/src/app/_services/transaction.service.ts index 3f39f33..1977c3e 100644 --- a/src/app/_services/transaction.service.ts +++ b/src/app/_services/transaction.service.ts @@ -62,30 +62,46 @@ export class TransactionService { transaction.value = Number(transaction.value); transaction.type = 'transaction'; try { - this.userService - .getAccountDetailsFromMeta(await User.toKey(transaction.from)) - .pipe(first()) - .subscribe( - (res) => { - transaction.sender = this.getAccountInfo(res, cacheSize); - }, - (error) => { - transaction.sender = defaultAccount; - this.userService.addAccount(defaultAccount, cacheSize); - } - ); - this.userService - .getAccountDetailsFromMeta(await User.toKey(transaction.to)) - .pipe(first()) - .subscribe( - (res) => { - transaction.recipient = this.getAccountInfo(res, cacheSize); - }, - (error) => { - transaction.recipient = defaultAccount; - this.userService.addAccount(defaultAccount, cacheSize); - } - ); + if (transaction.from === environment.trustedDeclaratorAddress) { + transaction.sender = defaultAccount; + this.userService.addAccount(defaultAccount, cacheSize); + } else { + this.userService + .getAccountDetailsFromMeta(await User.toKey(transaction.from)) + .pipe(first()) + .subscribe( + (res) => { + transaction.sender = this.getAccountInfo(res, cacheSize); + }, + (error) => { + this.loggingService.sendErrorLevelMessage( + `Account with address ${transaction.from} not found`, + this, + { error } + ); + } + ); + } + if (transaction.to === environment.trustedDeclaratorAddress) { + transaction.recipient = defaultAccount; + this.userService.addAccount(defaultAccount, cacheSize); + } else { + this.userService + .getAccountDetailsFromMeta(await User.toKey(transaction.to)) + .pipe(first()) + .subscribe( + (res) => { + transaction.recipient = this.getAccountInfo(res, cacheSize); + }, + (error) => { + this.loggingService.sendErrorLevelMessage( + `Account with address ${transaction.to} not found`, + this, + { error } + ); + } + ); + } } finally { this.addTransaction(transaction, cacheSize); } @@ -99,18 +115,26 @@ export class TransactionService { conversion.fromValue = Number(conversion.fromValue); conversion.toValue = Number(conversion.toValue); try { - this.userService - .getAccountDetailsFromMeta(await User.toKey(conversion.trader)) - .pipe(first()) - .subscribe( - (res) => { - conversion.sender = conversion.recipient = this.getAccountInfo(res); - }, - (error) => { - conversion.sender = conversion.recipient = defaultAccount; - this.userService.addAccount(defaultAccount, cacheSize); - } - ); + if (conversion.trader === environment.trustedDeclaratorAddress) { + conversion.sender = conversion.recipient = defaultAccount; + this.userService.addAccount(defaultAccount, cacheSize); + } else { + this.userService + .getAccountDetailsFromMeta(await User.toKey(conversion.trader)) + .pipe(first()) + .subscribe( + (res) => { + conversion.sender = conversion.recipient = this.getAccountInfo(res); + }, + (error) => { + this.loggingService.sendErrorLevelMessage( + `Account with address ${conversion.trader} not found`, + this, + { error } + ); + } + ); + } } finally { this.addTransaction(conversion, cacheSize); }