buildNwcWalletAuthUri function

Uri buildNwcWalletAuthUri({
  1. required String appPubkey,
  2. required AlbyGoConnectConfig config,
  3. required String state,
  4. String scheme = 'nostr+walletauth',
  5. bool includeReturnTo = true,
})

Builds standard NWC wallet-auth URI handled by compatible wallet apps.

Implementation

Uri buildNwcWalletAuthUri({
  required String appPubkey,
  required AlbyGoConnectConfig config,
  required String state,
  String scheme = 'nostr+walletauth',
  bool includeReturnTo = true,
}) {
  return Uri(
    scheme: scheme,
    host: appPubkey,
    queryParameters: {
      'relay': config.discoveryRelay,
      'state': state,
      'name': config.appName,
      'request_methods': config.requestMethods
          .map((method) => method.name)
          .join(' '),
      'icon': config.appIconUrl,
      if (includeReturnTo) 'return_to': config.callback,
    },
  );
}