signMessageRequest method

  1. @override
Future<String> signMessageRequest(
  1. String message, {
  2. required ReownAppKitModalSession session,
})
override

Implementation

@override
Future<String> signMessageRequest(
  String message, {
  required ReownAppKitModalSession session,
}) async {
  if (!enabled) throw Exception('siweConfig not enabled');
  //
  final chainId = AuthSignature.getChainIdFromMessage(message);
  final caip2Chain = ReownAppKitModalNetworks.getCaip2Chain(chainId);
  final address = AuthSignature.getAddressFromMessage(message);
  final bytes = utf8.encode(message);
  final encoded = hex.encode(bytes);
  //
  _appKit.core.logger.d('[$runtimeType] signMessageRequest() called');
  if (session.sessionService.isMagic) {
    return await _magicService.request(
      chainId: caip2Chain,
      request: SessionRequestParams(
        method: 'personal_sign',
        params: ['0x$encoded', address],
      ),
    );
  }
  if (session.sessionService.isCoinbase) {
    return await _coinbaseService.request(
      chainId: caip2Chain,
      request: SessionRequestParams(
        method: 'personal_sign',
        params: ['0x$encoded', address],
      ),
    );
  }
  return await _appKit.request(
    topic: session.topic!,
    chainId: caip2Chain,
    request: SessionRequestParams(
      method: 'personal_sign',
      params: ['0x$encoded', address],
    ),
  );
}