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

View file

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