signToSignature method

  1. @Deprecated('Please use [signToSignatureSync]')
  2. @override
Future<MsgSignature> signToSignature(
  1. Uint8List payload, {
  2. int? chainId,
  3. bool isEIP1559 = false,
})
override

Signs the payload with a private key and returns the obtained signature.

Implementation

@Deprecated('Please use [signToSignatureSync]')
@override
Future<MsgSignature> signToSignature(
  Uint8List payload, {
  int? chainId,
  bool isEIP1559 = false,
}) async {
  final signature = secp256k1.sign(keccak256(payload), privateKey);

  // https://github.com/ethereumjs/ethereumjs-util/blob/8ffe697fafb33cefc7b7ec01c11e3a7da787fe0e/src/signature.ts#L26
  // be aware that signature.v already is recovery + 27
  int chainIdV;
  if (isEIP1559) {
    chainIdV = signature.v - 27;
  } else {
    chainIdV = chainId != null
        ? (signature.v - 27 + (chainId * 2 + 35))
        : signature.v;
  }
  return MsgSignature(signature.r, signature.s, chainIdV);
}