encodeTo method

  1. @override
void encodeTo(
  1. RuntimeVersion value,
  2. Output output
)
override

Convert self to a slice and append it to the destination.

Implementation

@override
void encodeTo(
  RuntimeVersion value,
  Output output,
) {
  StrCodec.codec.encodeTo(
    value.specName,
    output,
  );
  StrCodec.codec.encodeTo(
    value.implName,
    output,
  );
  U32Codec.codec.encodeTo(
    value.authoringVersion,
    output,
  );
  U32Codec.codec.encodeTo(
    value.specVersion,
    output,
  );
  U32Codec.codec.encodeTo(
    value.implVersion,
    output,
  );
  const SequenceCodec<ApiVersion>(ApiVersion.codec).encodeTo(
    value.apis,
    output,
  );

  // - `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(value.apis);

  if (coreVersion == null || coreVersion >= 3) {
    U32Codec.codec.encodeTo(
      value.transactionVersion,
      output,
    );
  }

  if (coreVersion == null || coreVersion >= 4) {
    U8Codec.codec.encodeTo(
      value.stateVersion,
      output,
    );
  }
}