beginExternalWalletConnect method

  1. @override
Future<ExternalWalletConnectionHandle> beginExternalWalletConnect(
  1. List<String> chains, [
  2. String? walletKey
])
override

Starts a connection for SDK chain codes or CAIP-2 IDs. walletKey selects a wallet; null uses generic pairing. The URI can be null, but awaitExternalWalletConnection is still required.

Implementation

@override
Future<ExternalWalletConnectionHandle> beginExternalWalletConnect(List<String> chains, [String? walletKey]) async {
  Future<ExternalWalletConnectionHandle> instrumentationOperation() async {
    final operationScope = _state.flowScope.capture(replace: false);
    await operationScope.ready();
    if (!_state.initialized) {
      throw DynamicStateException("call initialize() before using the client");
    }
    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();
    operationScope.check();
    final handle = await _externalWalletProvider.beginConnect(chains, walletKey);
    operationScope.check();
    return handle;
  }
  return await _api.instrumentation.runAsync("externalWallet.beginExternalWalletConnect", instrumentationOperation);
}