-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Apply translations to lnurl_webview - Update deprecated launch method with launchUrl - Add "webLN" identifier for lnurl vendors - Parse endpointURI - Remove unnecessary params & unused imports - Correct indentation - Display a loader while handling LNURL-Auth - Run "dart format -l 110 ." - Use localization message on lnurl-auth's error dialog title
- Loading branch information
1 parent
d265b20
commit 2f5bade
Showing
7 changed files
with
101 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
|
||
import 'dart:convert'; | ||
|
||
import 'package:breez/bloc/blocs_provider.dart'; | ||
import 'package:breez/bloc/lnurl/lnurl_actions.dart'; | ||
import 'package:breez/bloc/lnurl/lnurl_bloc.dart'; | ||
import 'package:breez/bloc/lnurl/lnurl_model.dart'; | ||
import 'package:breez/bloc/marketplace/vendor_model.dart'; | ||
import 'package:breez_translations/breez_translations_locales.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
Future<String> handleLNUrlAuth(VendorModel vendor, LNUrlBloc lnurlBloc, String responsdID) async { | ||
Uri uri = Uri.parse(vendor.url); | ||
var response = await http.get(uri); | ||
if (response.statusCode != 200 && response.statusCode != 201) { | ||
throw Exception("Failed to call ${vendor.displayName} API"); | ||
} | ||
Map<String, dynamic> decoded = json.decode(response.body); | ||
String lnUrl = decoded[responsdID] as String; | ||
Fetch fetchAction = Fetch(lnUrl); | ||
lnurlBloc.actionsSink.add(fetchAction); | ||
var fetchResponse = await fetchAction.future; | ||
if (fetchResponse.runtimeType != AuthFetchResponse) { | ||
throw "Invalid URL"; | ||
} | ||
AuthFetchResponse authResponse = fetchResponse as AuthFetchResponse; | ||
var action = Login(authResponse, jwt: true); | ||
lnurlBloc.actionsSink.add(action); | ||
return await action.future; | ||
} | ||
Future<String> handleLNUrlAuth(BuildContext context, {VendorModel vendor}) async { | ||
final LNUrlBloc lnurlBloc = AppBlocsProvider.of<LNUrlBloc>(context); | ||
final texts = context.texts(); | ||
Uri endpointURI = Uri.parse(vendor.endpointURI); | ||
var response = vendor.id == "lnmarkets" ? await http.post(endpointURI) : await http.get(endpointURI); | ||
|
||
if (response.statusCode != 200 && response.statusCode != 201) { | ||
throw Exception(texts.lnurl_webview_error_message(vendor.displayName)); | ||
} | ||
Map<String, dynamic> decoded = json.decode(response.body); | ||
String lnUrl = decoded[vendor.responseID] as String; | ||
Fetch fetchAction = Fetch(lnUrl); | ||
lnurlBloc.actionsSink.add(fetchAction); | ||
var fetchResponse = await fetchAction.future; | ||
if (fetchResponse.runtimeType != AuthFetchResponse) { | ||
throw texts.lnurl_webview_error_invalid_url; | ||
} | ||
AuthFetchResponse authResponse = fetchResponse as AuthFetchResponse; | ||
var action = Login(authResponse, jwt: true); | ||
lnurlBloc.actionsSink.add(action); | ||
return await action.future; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters