Skip to content

Commit

Permalink
fix metadata on init when its value is u32 max
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul committed Dec 13, 2024
1 parent 42b9735 commit 7b11611
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/api/src/base/Init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
// Previously, for unstable versions of the metadata, it was set to u32 MAX in the runtime. This ensures on 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');
Expand Down

0 comments on commit 7b11611

Please sign in to comment.