decode method

  1. @override
Map<String, dynamic> decode(
  1. Input input
)
override

Implementation

@override
Map<String, dynamic> decode(Input input) {
  final result = <String, dynamic>{};

  result['hash'] = ExtrinsicsCodec.computeHash(input.buffer);

  result['extrinsic_length'] = CompactCodec.codec.decode(input);

  if (result['extrinsic_length'] != input.remainingLength) {
    result['extrinsic_length'] = 0;
    input.resetOffset();
  }

  final meta = input.read();

  //
  // 0b01111111 ~ 127 in BigInt
  final version = meta & BigInt.from(127).toInt();

  assertion(version == 4, 'unsupported extrinsic version');

  result['version'] = 4;

  //
  // 0b10000000 ~ 128 in BigInt
  final signed = meta & BigInt.from(128).toInt();

  if (signed != 0) {
    result['signature'] =
        chainInfo.scaleCodec.decode('ExtrinsicSignatureCodec', input);
  }

  result['calls'] = chainInfo.scaleCodec.decode('Call', input);

  return result;
}