Fix token list.
This commit is contained in:
parent
384071d3db
commit
8de8e6a30b
@ -26,9 +26,20 @@ export class TokenService {
|
||||
};
|
||||
}
|
||||
|
||||
async getTokens(): Promise<Array<Promise<string>>> {
|
||||
async getTokens(): Promise<Array<any>> {
|
||||
const count: number = await this.tokenRegistry.totalTokens();
|
||||
return Array.from({ length: count }, async (v, i) => await this.tokenRegistry.entry(i));
|
||||
let tokens: Array<any> = [];
|
||||
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<any> {
|
||||
|
@ -48,7 +48,7 @@
|
||||
|
||||
<ng-container matColumnDef="supply">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> Supply </mat-header-cell>
|
||||
<mat-cell *matCellDef="let token"> {{token.supply | tokenRatio}} </mat-cell>
|
||||
<mat-cell *matCellDef="let token"> {{token.totalSupply | tokenRatio}} </mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="columnsToDisplay"></mat-header-row>
|
||||
|
@ -17,7 +17,7 @@ export class TokensComponent implements OnInit {
|
||||
columnsToDisplay: Array<string> = ['name', 'symbol', 'address', 'supply'];
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
tokens: Array<Promise<string>>;
|
||||
tokens: Array<any>;
|
||||
|
||||
constructor(
|
||||
private tokenService: TokenService,
|
||||
|
Loading…
Reference in New Issue
Block a user