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,