SolanaTransactionRequest.parse constructor

SolanaTransactionRequest.parse(
  1. String url
)

Implementation

factory SolanaTransactionRequest.parse(String url) {
  final uri = Uri.tryParse(url);
  if (uri == null) {
    throw const ParseUrlException('Link invalid');
  }

  if (uri.scheme != 'solana') {
    throw const ParseUrlException('Protocol invalid');
  }

  final link = Uri.tryParse(Uri.decodeComponent(uri.path));
  if (link == null) {
    throw const ParseUrlException('Link invalid');
  }

  if (link.scheme != 'https') {
    throw const ParseUrlException('Protocol invalid');
  }

  final String? label = uri.queryParameters['label'];
  final String? message = uri.queryParameters['message'];

  return SolanaTransactionRequest(
    link: link,
    label: label,
    message: message,
  );
}