getMethodSigature static method

List<int> getMethodSigature(
  1. Eip712TypedData typedData,
  2. String type
)

Generates the method signature hash for a given EIP-712 typed data and type. The method signature includes all dependencies and their corresponding types and names.

Implementation

static List<int> getMethodSigature(Eip712TypedData typedData, String type) {
  final List<String> dependencies =
      List.from(_getDependencies(typedData, type));
  final encode = dependencies
      .map((dependency) =>
          '$dependency(${typedData.types[dependency]!.map((t) => '${t.type} ${t.name}').join(',')})')
      .join('');
  return QuickCrypto.keccack256Hash(StringUtils.encode(encode));
}