Skip to content

Commit

Permalink
fix metadata on init when its value is u32 max (#6043)
Browse files Browse the repository at this point in the history
* fix metadata on init when its value is u32 max

* Fix comment
  • Loading branch information
TarikGul authored Dec 13, 2024
1 parent 42b9735 commit 651d651
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);
// 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');
Expand Down

0 comments on commit 651d651

Please sign in to comment.