From 872bf657869fbe63e7fed6e608048bc373613ce8 Mon Sep 17 00:00:00 2001 From: Spencer Ofwiti Date: Tue, 18 May 2021 22:10:08 +0300 Subject: [PATCH] Refactor services to handle data from meta service. --- src/app/_services/transaction.service.ts | 10 +++++----- src/app/_services/user.service.ts | 1 + .../data/{Declarator.json => AddressDeclarator.json} | 0 src/assets/js/block-sync/driver.js | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) rename src/assets/js/block-sync/data/{Declarator.json => AddressDeclarator.json} (100%) diff --git a/src/app/_services/transaction.service.ts b/src/app/_services/transaction.service.ts index bcd4ca6..f3a271c 100644 --- a/src/app/_services/transaction.service.ts +++ b/src/app/_services/transaction.service.ts @@ -46,7 +46,7 @@ export class TransactionService { } getAddressTransactions(address: string, offset: number, limit: number): Observable { - return this.httpClient.get(`${environment.cicCacheUrl}/tx/${address}/${offset}/${limit}`); + return this.httpClient.get(`${environment.cicCacheUrl}/tx/user/${address}/${offset}/${limit}`); } async setTransaction(transaction, cacheSize: number): Promise { @@ -61,7 +61,7 @@ export class TransactionService { .pipe(first()) .subscribe( (res) => { - transaction.sender = this.getAccountInfo(res.body); + transaction.sender = this.getAccountInfo(res); }, (error) => { transaction.sender = defaultAccount; @@ -72,7 +72,7 @@ export class TransactionService { .pipe(first()) .subscribe( (res) => { - transaction.recipient = this.getAccountInfo(res.body); + transaction.recipient = this.getAccountInfo(res); }, (error) => { transaction.recipient = defaultAccount; @@ -96,7 +96,7 @@ export class TransactionService { .pipe(first()) .subscribe( (res) => { - conversion.sender = conversion.recipient = this.getAccountInfo(res.body); + conversion.sender = conversion.recipient = this.getAccountInfo(res); }, (error) => { conversion.sender = conversion.recipient = defaultAccount; @@ -126,7 +126,7 @@ export class TransactionService { } getAccountInfo(account: string): any { - const accountInfo = Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data; + const accountInfo = JSON.parse(Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data); accountInfo.vcard = vCard.parse(atob(accountInfo.vcard)); return accountInfo; } diff --git a/src/app/_services/user.service.ts b/src/app/_services/user.service.ts index f632866..68941fa 100644 --- a/src/app/_services/user.service.ts +++ b/src/app/_services/user.service.ts @@ -103,6 +103,7 @@ export class UserService { .subscribe( async (res) => { const syncableAccount: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap(); + syncableAccount.m.data = JSON.parse(syncableAccount.m.data); const update: Array = []; for (const prop of Object.keys(accountInfo)) { update.push(new ArgPair(prop, accountInfo[prop])); diff --git a/src/assets/js/block-sync/data/Declarator.json b/src/assets/js/block-sync/data/AddressDeclarator.json similarity index 100% rename from src/assets/js/block-sync/data/Declarator.json rename to src/assets/js/block-sync/data/AddressDeclarator.json diff --git a/src/assets/js/block-sync/driver.js b/src/assets/js/block-sync/driver.js index 3f65340..f6f8bf7 100644 --- a/src/assets/js/block-sync/driver.js +++ b/src/assets/js/block-sync/driver.js @@ -42,7 +42,7 @@ Driver.prototype.sync = function (n) { const processor = async (b, t) => { return await self.process(b, t); }; - self.syncer(self, self.lo, self.hi, self.filters[0], self.filters[1], countGetter, processor); + self.syncer(self.lo, self.hi, self.filters[0], self.filters[1], countGetter, processor); }; Driver.prototype.process = function (b, t) {