signMessage method

  1. @override
Future<String> signMessage(
  1. String chain,
  2. String accountAddress,
  3. String message
)
override

Signs message for accountAddress on chain, through the connected external wallet.

Implementation

@override
Future<String> signMessage(String chain, String accountAddress, String message) async {
  Future<String> instrumentationOperation() async {
    final operationScope = _state.flowScope.capture(replace: false);
    await operationScope.ready();
    final walletConnectProjectId = _state.projectSettings?.sdk?.walletConnect?.projectId;
    if (walletConnectProjectId == null) {
      throw DynamicStateException("This environment has no WalletConnect projectId — enable WalletConnect for it in the Dynamic dashboard");
    }
    operationScope.check();
    await _externalWalletProvider.initialize(walletConnectProjectId, _config.appName, _config.appLogoUrl, _config.nativeLink, _config.universalLink);
    operationScope.check();
    _state.externalWalletActionRequested.emit(ExternalWalletActionRequest(action: "signMessage", walletName: (_externalWalletState.externalWalletAccounts == null ? null : firstWhereOrNull<ExternalWalletAccount>(_externalWalletState.externalWalletAccounts!, (item) => item.address == accountAddress))?.displayName, address: accountAddress, chain: chain));
    operationScope.check();
    final signature = await _externalWalletProvider.signMessage(chain, accountAddress, message);
    operationScope.check();
    return signature;
  }
  return await _api.instrumentation.runAsync("externalWallet.signMessage", instrumentationOperation);
}