crossmintAssertBridgeHosted function

void crossmintAssertBridgeHosted(
  1. HiddenSignerBridge bridge
)

Throws if bridge is the SDK's default runtime controller and no HiddenSignerBridgeHost has ever attached a port to it.

Surfaces the missing-host condition at the moment the caller selects or constructs a non-custodial signer, instead of deferring failure to the first bridge request during approval polling.

Custom HiddenSignerBridge implementations (e.g. test fakes) skip the check — the SDK only knows how to inspect attachment state on its own runtime controller.

Implementation

void crossmintAssertBridgeHosted(HiddenSignerBridge bridge) {
  if (bridge is HiddenSignerBridgeRuntimeController &&
      !bridge.hasEverBeenHosted) {
    throw const CrossmintSignerException(
      'Non-custodial signer selected but no CrossmintWalletHost or '
      'CrossmintWalletProvider has been mounted in the widget tree, so the '
      'hidden signer WebView bridge has no place to run. Mount one of those '
      'widgets around your app, or use the headless HiddenSignerBridgeHost '
      're-exported from '
      'package:crossmint_flutter/crossmint_flutter_controllers.dart.',
      code: CrossmintErrorCode.nonCustodialBridgeHostNotMounted,
    );
  }
}