fix metadata on init when its value is u32 max (#6043)

* fix metadata on init when its value is u32 max

* Fix comment
This commit is contained in:
Tarik Gul
2024-12-13 21:28:42 +02:00
committed by GitHub
parent 42b9735c32
commit 651d651213
+2 -1
View File
@@ -412,7 +412,8 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
: await firstValueFrom(this._rpcCore.state.call('Metadata_metadata_versions', '0x'));
const versions = typeRegistry.createType('Vec<u32>', metadataVersionsAsBytes);
metadataVersion = versions.reduce((largest, current) => current.gt(largest) ? current : largest);
// For unstable versions of the metadata the last value is set to u32 MAX in the runtime. This ensures only supported stable versions are used.
metadataVersion = versions.filter((ver) => SUPPORTED_METADATA_VERSIONS.includes(ver.toNumber())).reduce((largest, current) => current.gt(largest) ? current : largest);
} catch (e) {
l.debug((e as Error).message);
l.warn('error with state_call::Metadata_metadata_versions, rpc::state::get_metadata will be used');