Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions asset_sources/svg/campfire/rsfiro.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions asset_sources/svg/stack_duo/rsfiro.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions asset_sources/svg/stack_wallet/rsfiro.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions lib/app_config.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// ignore: unused_import
import 'dart:io';

import 'models/isar/models/ethereum/eth_contract.dart';
import 'utilities/default_eth_tokens.dart';
import 'wallets/crypto_currency/crypto_currency.dart';
import 'wallets/crypto_currency/intermediate/frost_currency.dart';

Expand Down Expand Up @@ -28,6 +30,8 @@ abstract class AppConfig {

static List<CryptoCurrency> get coins => _supportedCoins;

static List<EthContract> get defaultEthTokens => _defaultEthTokens;

static ({String from, String fromFuzzyNet, String to, String toFuzzyNet})
get swapDefaults => _swapDefaults;

Expand Down
30 changes: 27 additions & 3 deletions lib/db/db_version_migration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import '../services/mixins/wallet_db.dart';
import '../services/wallets_service.dart';
import '../utilities/amount/amount.dart';
import '../utilities/constants.dart';
import '../utilities/default_eth_tokens.dart';
import '../utilities/flutter_secure_storage_interface.dart';
import '../utilities/logger.dart';
import '../utilities/prefs.dart';
Expand Down Expand Up @@ -379,9 +380,8 @@ class DbVersionMigrator with WalletDB {
final mwcMigrationWalletsService = WalletsService();
final mwcMigrationWalletNames =
await mwcMigrationWalletsService.walletNames;
final mwcIdentifier = Mimblewimblecoin(
CryptoCurrencyNetwork.main,
).identifier;
final mwcIdentifier = Mimblewimblecoin(CryptoCurrencyNetwork.main)
.identifier;
for (final walletId in mwcMigrationWalletNames.keys) {
if (mwcMigrationWalletNames[walletId]!.coinIdentifier ==
mwcIdentifier) {
Expand All @@ -399,6 +399,30 @@ class DbVersionMigrator with WalletDB {
// try to continue migrating
return await migrate(16, secureStore: secureStore);

case 16:
if (AppConfig.defaultEthTokens.contains(DefaultTokens.rsFiro)) {
final db = MainDB.instance;
await db.initMainDB();
if (await db.getEthContracts().isNotEmpty() &&
await db
.getEthContracts()
.filter()
.addressEqualTo(
DefaultTokens.rsFiro.address,
caseSensitive: false,
)
.isEmpty()) {
await db.putEthContract(DefaultTokens.rsFiro);
}
}

await DB.instance.put<dynamic>(
boxName: DB.boxNameDBInfo,
key: "hive_data_version",
value: 17,
);
return await migrate(17, secureStore: secureStore);

default:
// finally return
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:isar_community/isar.dart';

import '../../../app_config.dart';
import '../../../db/isar/main_db.dart';
import '../../../models/isar/models/ethereum/eth_contract.dart';
import '../../../models/isar/models/solana/sol_contract.dart';
Expand All @@ -25,7 +26,6 @@ import '../../../providers/global/wallets_provider.dart';
import '../../../themes/stack_colors.dart';
import '../../../utilities/assets.dart';
import '../../../utilities/constants.dart';
import '../../../utilities/default_eth_tokens.dart';
import '../../../utilities/default_sol_tokens.dart';
import '../../../utilities/text_styles.dart';
import '../../../utilities/util.dart';
Expand Down Expand Up @@ -100,11 +100,10 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
}

Future<void> onNextPressed() async {
final selectedTokens =
tokenEntities
.where((e) => e.selected)
.map((e) => e.token.address)
.toList();
final selectedTokens = tokenEntities
.where((e) => e.selected)
.map((e) => e.token.address)
.toList();

final wallet = ref.read(pWallets).getWallet(widget.walletId);

Expand All @@ -119,13 +118,11 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
Navigator.of(context).pop(42);
} else {
if (isDesktop) {
Navigator.of(
context,
).popUntil(ModalRoute.withName(DesktopHomeView.routeName));
Navigator.of(context)
.popUntil(ModalRoute.withName(DesktopHomeView.routeName));
} else {
await Navigator.of(
context,
).pushNamedAndRemoveUntil(HomeView.routeName, (route) => false);
await Navigator.of(context)
.pushNamedAndRemoveUntil(HomeView.routeName, (route) => false);
}
if (mounted) {
unawaited(
Expand Down Expand Up @@ -160,9 +157,8 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
),
);
} else {
final result = await Navigator.of(
context,
).pushNamed(AddCustomTokenView.routeName);
final result = await Navigator.of(context)
.pushNamed(AddCustomTokenView.routeName);
contract = result as EthContract?;
}

Expand All @@ -177,7 +173,9 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
tokenEntities.add(
AddTokenListElementData(contract!)..selected = true,
);
tokenEntities.sort((a, b) => a.token.name.compareTo(b.token.name));
tokenEntities.sort(
(a, b) => a.token.name.compareTo(b.token.name),
);
}
});
}
Expand All @@ -199,9 +197,7 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
),
);
} else {
final result = await Navigator.of(
context,
).pushNamed(
final result = await Navigator.of(context).pushNamed(
AddCustomSolanaTokenView.routeName,
arguments: widget.walletId,
);
Expand All @@ -228,9 +224,7 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
if (tokenEntities
.where((e) => e.token.address == token!.address)
.isEmpty) {
tokenEntities.add(
AddTokenListElementData(token!)..selected = true,
);
tokenEntities.add(AddTokenListElementData(token!)..selected = true);
tokenEntities.sort((a, b) => a.token.name.compareTo(b.token.name));
}
});
Expand Down Expand Up @@ -268,7 +262,7 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
.findAllSync();

if (contracts.isEmpty) {
contracts.addAll(DefaultTokens.list);
contracts.addAll(AppConfig.defaultEthTokens);
MainDB.instance
.putEthContracts(contracts)
.then(
Expand Down Expand Up @@ -448,9 +442,8 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
_searchTerm = value;
});
},
style: STextStyles.desktopTextMedium(
context,
).copyWith(height: 2),
style: STextStyles.desktopTextMedium(context)
.copyWith(height: 2),
decoration:
standardInputDecoration(
"Search",
Expand Down Expand Up @@ -516,9 +509,9 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
} else {
return Background(
child: Scaffold(
backgroundColor: Theme.of(
context,
).extension<StackColors>()!.background,
backgroundColor: Theme.of(context)
.extension<StackColors>()!
.background,
appBar: AppBar(
leading: AppBarBackButton(
onPressed: () {
Expand All @@ -533,14 +526,14 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
child: AppBarIconButton(
size: 36,
shadows: const [],
color: Theme.of(
context,
).extension<StackColors>()!.background,
color: Theme.of(context)
.extension<StackColors>()!
.background,
icon: SvgPicture.asset(
Assets.svg.circlePlusFilled,
color: Theme.of(
context,
).extension<StackColors>()!.topNavIconPrimary,
color: Theme.of(context)
.extension<StackColors>()!
.topNavIconPrimary,
width: 20,
height: 20,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import '../../../../services/exchange/change_now/change_now_exchange.dart';
import '../../../../services/exchange/exchange_data_loading_service.dart';
import '../../../../themes/stack_colors.dart';
import '../../../../utilities/assets.dart';
import '../../../../utilities/default_eth_tokens.dart';
import '../../../../utilities/text_styles.dart';
import '../../../../utilities/util.dart';
import '../../../../widgets/app_icon.dart';
Expand Down Expand Up @@ -54,18 +55,14 @@ class _AddTokenListElementState extends ConsumerState<AddTokenListElement> {
super.initState();

ExchangeDataLoadingService.instance.isar.then((isar) async {
final currency =
await isar.currencies
.where()
.exchangeNameEqualTo(ChangeNowExchange.exchangeName)
.filter()
.tokenContractEqualTo(
widget.data.token.address,
caseSensitive: false,
)
.and()
.imageIsNotEmpty()
.findFirst();
final currency = await isar.currencies
.where()
.exchangeNameEqualTo(ChangeNowExchange.exchangeName)
.filter()
.tokenContractEqualTo(widget.data.token.address, caseSensitive: false)
.and()
.imageIsNotEmpty()
.findFirst();

if (mounted) {
WidgetsBinding.instance.addPostFrameCallback((_) {
Expand All @@ -86,50 +83,54 @@ class _AddTokenListElementState extends ConsumerState<AddTokenListElement> {

return RoundedWhiteContainer(
padding: EdgeInsets.all(isDesktop ? 16 : 12),
borderColor:
isDesktop
? Theme.of(context).extension<StackColors>()!.backgroundAppBar
: null,
borderColor: isDesktop
? Theme.of(context).extension<StackColors>()!.backgroundAppBar
: null,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
currency != null
? SvgPicture.network(
currency!.image,
width: iconSize,
height: iconSize,
placeholderBuilder:
(_) => AppIcon(width: iconSize, height: iconSize),
)
: AppIcon(width: iconSize, height: iconSize),
if (widget.data.token is EthContract &&
widget.data.token.address.toLowerCase() ==
DefaultTokens.rsFiro.address)
SvgPicture.asset(
Assets.svg.rsFiro,
width: iconSize,
height: iconSize,
)
else
currency != null
? SvgPicture.network(
currency!.image,
width: iconSize,
height: iconSize,
placeholderBuilder: (_) =>
AppIcon(width: iconSize, height: iconSize),
)
: AppIcon(width: iconSize, height: iconSize),
const SizedBox(width: 12),
ConditionalParent(
condition: isDesktop,
builder:
(child) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
child,
const SizedBox(height: 2),
Text(
widget.data.token.symbol,
style: STextStyles.desktopTextExtraExtraSmall(
context,
),
overflow: TextOverflow.ellipsis,
),
],
builder: (child) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
child,
const SizedBox(height: 2),
Text(
widget.data.token.symbol,
style: STextStyles.desktopTextExtraExtraSmall(context),
overflow: TextOverflow.ellipsis,
),
],
),
child: Text(
isDesktop
? mainLabel
: "$mainLabel (${widget.data.token.symbol})",
style:
isDesktop
? STextStyles.desktopTextSmall(context)
: STextStyles.w600_14(context),
style: isDesktop
? STextStyles.desktopTextSmall(context)
: STextStyles.w600_14(context),
overflow: TextOverflow.ellipsis,
),
),
Expand All @@ -138,21 +139,20 @@ class _AddTokenListElementState extends ConsumerState<AddTokenListElement> {
const SizedBox(width: 4),
isDesktop
? Checkbox(
value: widget.data.selected,
onChanged:
(newValue) =>
setState(() => widget.data.selected = newValue!),
)
value: widget.data.selected,
onChanged: (newValue) =>
setState(() => widget.data.selected = newValue!),
)
: SizedBox(
height: 20,
width: 40,
child: DraggableSwitchButton(
isOn: widget.data.selected,
onValueChanged: (newValue) {
widget.data.selected = newValue;
},
height: 20,
width: 40,
child: DraggableSwitchButton(
isOn: widget.data.selected,
onValueChanged: (newValue) {
widget.data.selected = newValue;
},
),
),
),
],
),
);
Expand Down
Loading
Loading