Merge branch 'spencer/refactor-accounts-query' into 'master'

Refactor accounts query.

See merge request grassrootseconomics/cic-staff-client!21
This commit is contained in:
Blair Vanderlugt 2021-05-13 16:38:35 +00:00
commit babf3e4687

View File

@ -29,12 +29,12 @@ export class AccountIndex {
public async last(numberOfAccounts: number): Promise<Array<string>> {
const count: number = await this.totalAccounts();
let lowest: number = count - numberOfAccounts - 1;
let lowest: number = count - numberOfAccounts;
if (lowest < 0) {
lowest = 0;
}
const accounts: Array<string> = [];
for (let i = count - 1; i > lowest; i--) {
for (let i = count; i > lowest; i--) {
const account: string = await this.contract.methods.entry(i).call();
accounts.push(account);
}