Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing overrides to the keys fetch method #190

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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];
}
}
Loading