decode method

  1. @override
RuntimeVersion decode(
  1. Input input
)
override

Implementation

@override
RuntimeVersion decode(Input input) {
  final specName = StrCodec.codec.decode(input);
  final implName = StrCodec.codec.decode(input);
  final authoringVersion = U32Codec.codec.decode(input);
  final specVersion = U32Codec.codec.decode(input);
  final implVersion = U32Codec.codec.decode(input);
  final apis =
      const SequenceCodec<ApiVersion>(ApiVersion.codec).decode(input);

  // - `Core` version < 3 is a runtime version without a transaction version and state version.
  // - `Core` version 3 is a runtime version without a state version.
  // - `Core` version 4 is the latest runtime version.
  final int? coreVersion = coreVersionFromApis(apis);
  final int transactionVersion = coreVersion == null || coreVersion >= 3
      ? U32Codec.codec.decode(input)
      : 1;
  final int stateVersion = coreVersion == null || coreVersion >= 4
      ? U8Codec.codec.decode(input)
      : 0;

  return RuntimeVersion(
    specName: specName,
    implName: implName,
    authoringVersion: authoringVersion,
    specVersion: specVersion,
    implVersion: implVersion,
    apis: apis,
    transactionVersion: transactionVersion,
    stateVersion: stateVersion,
  );
}