encodeDigest static method

Uint8List encodeDigest(
  1. TypedData typedData
)

Implementation

static Uint8List encodeDigest(TypedData typedData) {
  final eip191HeaderHex = "1901";
  final eip191Header = hexToBytes(eip191HeaderHex);
  final domainHash = hashStruct(typedData, 'EIP712Domain', typedData.domain);
  final messageHash = zeroPad(
      hashStruct(typedData, typedData.primaryType, typedData.message), 32);

  final bytesBuilder = BytesBuilder();
  bytesBuilder.add(eip191Header);
  bytesBuilder.add(domainHash);
  bytesBuilder.add(messageHash);

  final h = bytesBuilder.toBytes();

  return h;
}