mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-02-02 03:06:35 +00:00
Add limit query to trocador
This commit is contained in:
parent
891a9d3368
commit
8419767c4f
1 changed files with 28 additions and 2 deletions
|
@ -40,6 +40,7 @@ class TrocadorExchangeProvider extends ExchangeProvider {
|
||||||
static const newRatePath = '/api/new_rate';
|
static const newRatePath = '/api/new_rate';
|
||||||
static const createTradePath = 'api/new_trade';
|
static const createTradePath = 'api/new_trade';
|
||||||
static const tradePath = 'api/trade';
|
static const tradePath = 'api/trade';
|
||||||
|
static const coinPath = 'api/coin';
|
||||||
String _lastUsedRateId;
|
String _lastUsedRateId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -134,9 +135,34 @@ class TrocadorExchangeProvider extends ExchangeProvider {
|
||||||
{required CryptoCurrency from,
|
{required CryptoCurrency from,
|
||||||
required CryptoCurrency to,
|
required CryptoCurrency to,
|
||||||
required bool isFixedRateMode}) async {
|
required bool isFixedRateMode}) async {
|
||||||
//TODO: implement limits from trocador api
|
|
||||||
|
final params = <String, String> {
|
||||||
|
'api_key': apiKey,
|
||||||
|
'ticker': from.title.toLowerCase(),
|
||||||
|
'name': from.name,
|
||||||
|
};
|
||||||
|
|
||||||
|
final String apiAuthority = shouldUseOnionAddress ? await _getAuthority() : clearNetAuthority;
|
||||||
|
final uri = Uri.https(apiAuthority, coinPath, params);
|
||||||
|
|
||||||
|
final response = await get(uri);
|
||||||
|
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
throw Exception('Unexpected http status: ${response.statusCode}');
|
||||||
|
}
|
||||||
|
|
||||||
|
final responseJSON = json.decode(response.body) as List<dynamic>;
|
||||||
|
|
||||||
|
if (responseJSON.isEmpty) {
|
||||||
|
throw Exception('No data');
|
||||||
|
}
|
||||||
|
|
||||||
|
final coinJson = responseJSON.first as Map<String, dynamic>;
|
||||||
|
|
||||||
|
|
||||||
return Limits(
|
return Limits(
|
||||||
min: 0.0,
|
min: coinJson['minimum'] as double,
|
||||||
|
max: coinJson['maximum'] as double,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue