change now token contract "fix"

This commit is contained in:
julian 2023-04-10 14:14:03 -06:00
parent bc90723c86
commit 051eb6c924
2 changed files with 11 additions and 1 deletions

View file

@ -149,6 +149,8 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
currency.ticker, currency.ticker,
caseSensitive: false, caseSensitive: false,
) )
.and()
.tokenContractEqualTo(currency.tokenContract)
.findAll(); .findAll();
final items = [Tuple2(currency.exchangeName, currency)]; final items = [Tuple2(currency.exchangeName, currency)];
@ -631,6 +633,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
.getAggregateCurrency( .getAggregateCurrency(
widget.contract == null ? coin!.ticker : widget.contract!.symbol, widget.contract == null ? coin!.ticker : widget.contract!.symbol,
ExchangeRateType.estimated, ExchangeRateType.estimated,
widget.contract == null ? null : widget.contract!.address,
) )
.then((value) { .then((value) {
if (value != null) { if (value != null) {

View file

@ -61,10 +61,12 @@ class ExchangeDataLoadingService {
final sendCurrency = await getAggregateCurrency( final sendCurrency = await getAggregateCurrency(
"BTC", "BTC",
state.exchangeRateType, state.exchangeRateType,
null,
); );
final receiveCurrency = await getAggregateCurrency( final receiveCurrency = await getAggregateCurrency(
"XMR", "XMR",
state.exchangeRateType, state.exchangeRateType,
null,
); );
state.setCurrencies(sendCurrency, receiveCurrency); state.setCurrencies(sendCurrency, receiveCurrency);
} }
@ -72,7 +74,10 @@ class ExchangeDataLoadingService {
} }
Future<AggregateCurrency?> getAggregateCurrency( Future<AggregateCurrency?> getAggregateCurrency(
String ticker, ExchangeRateType rateType) async { String ticker,
ExchangeRateType rateType,
String? contract,
) async {
final currencies = await ExchangeDataLoadingService.instance.isar.currencies final currencies = await ExchangeDataLoadingService.instance.isar.currencies
.filter() .filter()
.group((q) => rateType == ExchangeRateType.fixed .group((q) => rateType == ExchangeRateType.fixed
@ -89,6 +94,8 @@ class ExchangeDataLoadingService {
ticker, ticker,
caseSensitive: false, caseSensitive: false,
) )
.and()
.tokenContractEqualTo(contract)
.findAll(); .findAll();
final items = currencies final items = currencies