decode method
Implementation
@override
UncheckedExtrinsic decode(final Input input) {
// Read version byte and extract the actual version and type
final int versionByte = input.read();
final (int version, ExtrinsicType type) = _parseVersionByte(versionByte);
// Validate version - accept both v4 and v5
// Note: Metadata may report v4 even when v5 extrinsics are used (known issue)
if (version != _extrinsicV4 && version != _extrinsicV5) {
throw MetadataException(
'Unsupported extrinsic version: $version (supported: $_extrinsicV4, $_extrinsicV5)',
);
}
ExtrinsicSignature? signature;
Map<String, dynamic>? extensions;
switch (type) {
case ExtrinsicType.signed:
// Signed extrinsic: signature (address + sig + extra) followed by call
signature = _signatureCodec.decode(input);
break;
case ExtrinsicType.general:
// General extrinsic (v5): extension version byte + extensions followed by call
final extensionVersion = input.read();
extensions = {'extensionVersion': extensionVersion, ..._extensionsCodec.decode(input)};
break;
case ExtrinsicType.bare:
// Bare extrinsic: just the call, no signature or extensions
break;
}
final call = _callCodec.decode(input);
return UncheckedExtrinsic(
version: version,
type: type,
signature: signature,
extensions: extensions,
call: call,
);
}