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: Maximum call stack size exceeded with array.push #302

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
16 changes: 8 additions & 8 deletions src/providers/starknet/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class StarknetProvider extends BaseProvider {
}

let lastSources = this.instance.getCurrentSources(blockNumber);
const sourcesQueue = [...lastSources];
let sourcesQueue = [...lastSources];

let source: ContractSourceConfig | undefined;
while ((source = sourcesQueue.shift())) {
Expand Down Expand Up @@ -299,15 +299,15 @@ export class StarknetProvider extends BaseProvider {
nextSource => !lastSources.find(lastSource => lastSource.contract === nextSource.contract)
);

sourcesQueue.push(...newSources);
sourcesQueue = sourcesQueue.concat(newSources);
lastSources = nextSources;
}

this.log.debug({ txIndex }, 'handling transaction done');
}

private async getEvents(blockNumber: number): Promise<EventsMap> {
const events: Event[] = [];
let events: Event[] = [];

let continuationToken: string | undefined;
do {
Expand All @@ -318,7 +318,7 @@ export class StarknetProvider extends BaseProvider {
continuation_token: continuationToken
});

events.push(...result.events);
events = events.concat(result.events);

continuationToken = result.continuation_token;
} while (continuationToken);
Expand All @@ -345,7 +345,7 @@ export class StarknetProvider extends BaseProvider {
toBlock: number,
address: string
): Promise<CheckpointRecord[]> {
const events: Event[] = [];
let events: Event[] = [];

let continuationToken: string | undefined;
do {
Expand All @@ -357,7 +357,7 @@ export class StarknetProvider extends BaseProvider {
continuation_token: continuationToken
});

events.push(...result.events);
events = events.concat(result.events);

continuationToken = result.continuation_token;
} while (continuationToken);
Expand All @@ -369,15 +369,15 @@ export class StarknetProvider extends BaseProvider {
}

async getCheckpointsRange(fromBlock: number, toBlock: number): Promise<CheckpointRecord[]> {
const events: CheckpointRecord[] = [];
let events: CheckpointRecord[] = [];

for (const source of this.instance.getCurrentSources(fromBlock)) {
const addressEvents = await this.getCheckpointsRangeForAddress(
fromBlock,
toBlock,
source.contract
);
events.push(...addressEvents);
events = events.concat(addressEvents);
}

return events;
Expand Down
Loading