Skip to content

Commit

Permalink
fix: add missing overrides to the keys fetch method
Browse files Browse the repository at this point in the history
  • Loading branch information
eddort committed Oct 20, 2023
1 parent d502c1e commit 4e9e126
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/common/registry/fetch/key-batch.fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,40 @@ export class RegistryKeyBatchFetchService {
}

const [offset, limit] = this.convertIndicesToOffsetAndTotal(fromIndex, toIndex);
const unformattedKeys = await this.fetchSigningKeysInBatches(moduleAddress, operatorIndex, offset, limit);
const unformattedKeys = await this.fetchSigningKeysInBatches(
moduleAddress,
operatorIndex,
offset,
limit,
overrides,
);

return unformattedKeys;
}

public async fetchSigningKeysInBatches(
moduleAddress: string,
operatorIndex: number,
fromIndex: number,
offset: number,
totalAmount: number,
overrides: CallOverrides,
) {
const batchSize = this.options.keysBatchSize || KEYS_BATCH_SIZE;

const numberOfBatches = Math.ceil(totalAmount / batchSize);
const promises: Promise<RegistryKey[]>[] = [];

for (let i = 0; i < numberOfBatches; i++) {
const currentFromIndex = fromIndex + i * batchSize;
const currentOffset = offset + i * batchSize;
const currentBatchSize = Math.min(batchSize, totalAmount - i * batchSize);

const promise = (async () => {
const keys = await this.getContract(moduleAddress).getSigningKeys(
operatorIndex,
currentFromIndex,
currentOffset,
currentBatchSize,
overrides as any,
);
return this.formatKeys(moduleAddress, operatorIndex, keys, currentFromIndex);
return this.formatKeys(moduleAddress, operatorIndex, keys, currentOffset);
})();

promises.push(promise);
Expand All @@ -143,7 +150,6 @@ export class RegistryKeyBatchFetchService {
protected convertIndicesToOffsetAndTotal(fromIndex: number, toIndex: number) {
const offset = fromIndex;
const total = toIndex - fromIndex;

return [offset, total];
}
}

0 comments on commit 4e9e126

Please sign in to comment.