Add noInitWarn to API options (#5125)

This commit is contained in:
Jaco
2022-08-02 09:16:17 +03:00
committed by GitHub
parent 37033f5068
commit b0109c1c83
4 changed files with 17 additions and 7 deletions
+4
View File
@@ -6,6 +6,10 @@ Contributed:
- Update `@substrate/connect` to latest (Thanks to https://github.com/wirednkod)
Changes:
- Add `noInitWarn: boolean` flag to API options, disabling runtime & RPC warning availability displays
## 9.0.1 Jul 30, 2022
+8 -6
View File
@@ -385,7 +385,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
const filterKey = (k: string) => !allKeys.includes(k);
const unknown = exposed.filter(filterKey);
if (unknown.length) {
if (unknown.length && !this._options.noInitWarn) {
l.warn(`RPC methods not decorated: ${unknown.join(', ')}`);
}
@@ -540,12 +540,14 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
.filter(([a]) => !hashes[a])
.map(([a, v]) => `${this._runtimeMap[a] || a}/${v}`);
if (older.length) {
l.warn(`Not decorating runtime apis without matching versions: ${older.join(', ')}`);
}
if (!this._options.noInitWarn) {
if (older.length) {
l.warn(`Not decorating runtime apis without matching versions: ${older.join(', ')}`);
}
if (notFound.length) {
l.warn(`Not decorating unknown runtime apis: ${notFound.join(', ')}`);
if (notFound.length) {
l.warn(`Not decorating unknown runtime apis: ${notFound.join(', ')}`);
}
}
const stateCall = blockHash
+1 -1
View File
@@ -70,7 +70,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
this._rpcCore.provider.on('disconnected', () => this.#onProviderDisconnect());
this._rpcCore.provider.on('error', (e: Error) => this.#onProviderError(e));
this._rpcCore.provider.on('connected', () => this.#onProviderConnect());
} else {
} else if (!this._options.noInitWarn) {
l.warn('Api will be available in a limited mode since the provider does not support subscriptions');
}
+4
View File
@@ -49,6 +49,10 @@ export interface ApiOptions extends RegisteredTypes {
* if genesis hash and runtime spec version matches, then use metadata, else fetch it from chain
*/
metadata?: Record<string, HexString>;
/**
* @description Don't display any warnings on initialization (missing RPC methods & runtime calls)
*/
noInitWarn?: boolean;
/**
* @description Transport Provider from rpc-provider. If not specified, it will default to
* connecting to a WsProvider connecting localhost with the default port, i.e. `ws://127.0.0.1:9944`