From 8de8e6a30b6cb0af2c4c11bf6d1f82fb65132e49 Mon Sep 17 00:00:00 2001 From: Spencer Ofwiti Date: Tue, 1 Jun 2021 20:34:41 +0300 Subject: [PATCH] Fix token list. --- src/app/_services/token.service.ts | 15 +++++++++++++-- src/app/pages/tokens/tokens.component.html | 2 +- src/app/pages/tokens/tokens.component.ts | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app/_services/token.service.ts b/src/app/_services/token.service.ts index 1444458..18d93e9 100644 --- a/src/app/_services/token.service.ts +++ b/src/app/_services/token.service.ts @@ -26,9 +26,20 @@ export class TokenService { }; } - async getTokens(): Promise>> { + async getTokens(): Promise> { const count: number = await this.tokenRegistry.totalTokens(); - return Array.from({ length: count }, async (v, i) => await this.tokenRegistry.entry(i)); + let tokens: Array = []; + for (let i = 0; i < count; i++) { + const tokenContract = await this.registry.addToken(await this.tokenRegistry.entry(i)); + let token: any = {}; + token.name = await tokenContract.methods.name().call(); + token.symbol = await tokenContract.methods.symbol().call(); + token.address = await this.tokenRegistry.entry(i); + token.totalSupply = await tokenContract.methods.totalSupply().call(); + token.decimals = await tokenContract.methods.decimals().call(); + tokens.push(token); + } + return tokens; } getTokenBySymbol(symbol: string): Observable { diff --git a/src/app/pages/tokens/tokens.component.html b/src/app/pages/tokens/tokens.component.html index 486e39a..3fc8f0e 100644 --- a/src/app/pages/tokens/tokens.component.html +++ b/src/app/pages/tokens/tokens.component.html @@ -48,7 +48,7 @@ Supply - {{token.supply | tokenRatio}} + {{token.totalSupply | tokenRatio}} diff --git a/src/app/pages/tokens/tokens.component.ts b/src/app/pages/tokens/tokens.component.ts index 3e76575..b300c20 100644 --- a/src/app/pages/tokens/tokens.component.ts +++ b/src/app/pages/tokens/tokens.component.ts @@ -17,7 +17,7 @@ export class TokensComponent implements OnInit { columnsToDisplay: Array = ['name', 'symbol', 'address', 'supply']; @ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; - tokens: Array>; + tokens: Array; constructor( private tokenService: TokenService,