mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 19:26:37 +00:00
add userID to quotes and don't init userID in main
TODO test what happens for a fresh install, I already have a userID set in my prefs
This commit is contained in:
parent
8b6fcd23b4
commit
82f89966bc
2 changed files with 14 additions and 5 deletions
|
@ -318,9 +318,10 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
|
|||
}
|
||||
}
|
||||
|
||||
ref
|
||||
.read(prefsChangeNotifierProvider)
|
||||
.userID; // Just reading the ref should set it if it's not already set
|
||||
// ref
|
||||
// .read(prefsChangeNotifierProvider)
|
||||
// .userID; // Just reading the ref should set it if it's not already set
|
||||
// We shouldn't need to do this, instead only generating an ID when (or if) the userID is looked up when creating a quote
|
||||
} catch (e, s) {
|
||||
Logger.print("$e $s", normalLength: false);
|
||||
}
|
||||
|
|
|
@ -13,12 +13,15 @@ import 'package:stackwallet/models/buy/response_objects/quote.dart';
|
|||
import 'package:stackwallet/services/buy/buy_response.dart';
|
||||
import 'package:stackwallet/utilities/enums/fiat_enum.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/prefs.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class SimplexAPI {
|
||||
static const String scheme = "https";
|
||||
static const String authority = "sandbox-api.stackwallet.com";
|
||||
|
||||
final _prefs = Prefs.instance;
|
||||
|
||||
SimplexAPI._();
|
||||
static final SimplexAPI _instance = SimplexAPI._();
|
||||
static SimplexAPI get instance => _instance;
|
||||
|
@ -149,6 +152,9 @@ class SimplexAPI {
|
|||
|
||||
Future<BuyResponse<SimplexQuote>> getQuote(SimplexQuote quote) async {
|
||||
try {
|
||||
await _prefs.init();
|
||||
String? userID = _prefs.userID;
|
||||
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
};
|
||||
|
@ -163,7 +169,9 @@ class SimplexAPI {
|
|||
? "${quote.youPayFiatPrice}"
|
||||
: "${quote.youReceiveCryptoAmount}",
|
||||
};
|
||||
// TODO add USER_ID
|
||||
if (userID != null) {
|
||||
data['USER_ID'] = userID;
|
||||
}
|
||||
Uri url = Uri.https('simplex-sandbox.stackwallet.com', 'api.php', data);
|
||||
// TODO update to stackwallet.com hosted API and use HTTPS
|
||||
|
||||
|
@ -175,7 +183,7 @@ class SimplexAPI {
|
|||
|
||||
jsonArray['quote'] = quote; // Add and pass this on
|
||||
|
||||
return await compute(_parseQuote, jsonArray);
|
||||
return await _parseQuote(jsonArray);
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("getQuote exception: $e\n$s", level: LogLevel.Error);
|
||||
return BuyResponse(
|
||||
|
|
Loading…
Reference in a new issue