cast extra id as optional string

This commit is contained in:
Godwin Asuquo 2022-10-18 16:18:55 +03:00
parent 842b120f8f
commit da14f04422

View file

@ -31,8 +31,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
static const apiKey = secrets.simpleSwapApiKey;
@override
ExchangeProviderDescription get description =>
ExchangeProviderDescription.simpleSwap;
ExchangeProviderDescription get description => ExchangeProviderDescription.simpleSwap;
@override
Future<double> calculateAmount(
@ -74,8 +73,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
@override
Future<Trade> createTrade({TradeRequest request, bool isFixedRateMode}) async {
final _request = request as SimpleSwapRequest;
final headers = {
'Content-Type': 'application/json'};
final headers = {'Content-Type': 'application/json'};
final params = <String, String>{
'api_key': apiKey,
};
@ -106,7 +104,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
final id = responseJSON['id'] as String;
final inputAddress = responseJSON['address_from'] as String;
final settleAddress = responseJSON['user_refund_address'] as String;
final extraId = responseJSON['extra_id_from'] as String;
final extraId = responseJSON['extra_id_from'] as String?;
return Trade(
id: id,
provider: description,
@ -114,7 +112,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
to: _request.to,
inputAddress: inputAddress,
refundAddress: settleAddress,
extraId: extraId,
extraId: extraId ?? '',
state: TradeState.created,
amount: _request.amount,
createdAt: DateTime.now(),