Skip to content

Commit 1adc17b

Browse files
authored
Workaround for regenerator runtime + private callback (#4514)
* Workaround for regenerator runtime + private callback * CHANGELOG
1 parent a55256a commit 1adc17b

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Changes:
1818
- Adjust bounty derive, return empty on no `{treasury, bounties}.bounties`
1919
- Ensure handling of all `TypeDefInfo` keys in extraction
2020
- Add support for `rpc.contracts.uploadCode`
21+
- Workaround for generators where `#private = { this... }` yields undefined
2122
- Update to latest Substrate, Kusama & Polkadot static metadata
2223

2324

packages/api/src/base/Init.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
6565
this._rpcCore.setRegistrySwap((blockHash: Uint8Array) => this.getBlockRegistry(blockHash));
6666

6767
if (this.hasSubscriptions) {
68-
this._rpcCore.provider.on('disconnected', this.#onProviderDisconnect);
69-
this._rpcCore.provider.on('error', this.#onProviderError);
70-
this._rpcCore.provider.on('connected', this.#onProviderConnect);
68+
this._rpcCore.provider.on('disconnected', () => this.#onProviderDisconnect());
69+
this._rpcCore.provider.on('error', (e: Error) => this.#onProviderError(e));
70+
this._rpcCore.provider.on('connected', () => this.#onProviderConnect());
7171
} else {
7272
l.warn('Api will be available in a limited mode since the provider does not support subscriptions');
7373
}
@@ -380,7 +380,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
380380
this._unsubscribeUpdates();
381381
}
382382

383-
#onProviderConnect = async (): Promise<void> => {
383+
async #onProviderConnect (): Promise<void> {
384384
this._isConnected.next(true);
385385
this.emit('connected');
386386

@@ -406,15 +406,15 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
406406

407407
this.emit('error', error);
408408
}
409-
};
409+
}
410410

411-
#onProviderDisconnect = (): void => {
411+
#onProviderDisconnect (): void {
412412
this._isConnected.next(false);
413413
this._unsubscribeHealth();
414414
this.emit('disconnected');
415-
};
415+
}
416416

417-
#onProviderError = (error: Error): void => {
417+
#onProviderError (error: Error): void {
418418
this.emit('error', error);
419-
};
419+
}
420420
}

0 commit comments

Comments
 (0)