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: 0 additions & 1 deletion asset_sources/svg/campfire/socials/twitter-brands.svg

This file was deleted.

1 change: 1 addition & 0 deletions asset_sources/svg/campfire/socials/x.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: 0 additions & 1 deletion asset_sources/svg/stack_duo/socials/twitter-brands.svg

This file was deleted.

1 change: 1 addition & 0 deletions asset_sources/svg/stack_duo/socials/x.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: 0 additions & 1 deletion asset_sources/svg/stack_wallet/socials/twitter-brands.svg

This file was deleted.

1 change: 1 addition & 0 deletions asset_sources/svg/stack_wallet/socials/x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions lib/models/isar/models/blockchain_data/v2/transaction_v2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ class TransactionV2 {
bool isCoinbase() =>
type == TransactionType.incoming && inputs.any((e) => e.coinbase != null);

@ignore
bool get isInstantLock =>
_getFromOtherData(key: TxV2OdKeys.isInstantLock) == true;

@override
String toString() {
return 'TransactionV2(\n'
Expand Down Expand Up @@ -362,4 +366,5 @@ abstract final class TxV2OdKeys {
static const moneroAmount = "moneroAmount";
static const moneroAccountIndex = "moneroAccountIndex";
static const isMoneroTransaction = "isMoneroTransaction";
static const isInstantLock = "isInstantLock";
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,40 @@ class AddTokenListElement extends ConsumerStatefulWidget {
class _AddTokenListElementState extends ConsumerState<AddTokenListElement> {
final bool isDesktop = Util.isDesktop;

Currency? currency;

@override
Widget build(BuildContext context) {
final currency =
ExchangeDataLoadingService.instance.isar.currencies
.where()
.exchangeNameEqualTo(ChangeNowExchange.exchangeName)
.filter()
.tokenContractEqualTo(
widget.data.token.address,
caseSensitive: false,
)
.and()
.imageIsNotEmpty()
.findFirstSync();
void initState() {
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();

if (mounted) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
setState(() {
this.currency = currency;
});
}
});
}
});
}

@override
Widget build(BuildContext context) {
final String mainLabel = widget.data.token.name;
final double iconSize = isDesktop ? 32 : 24;

Expand All @@ -77,7 +96,7 @@ class _AddTokenListElementState extends ConsumerState<AddTokenListElement> {
children: [
currency != null
? SvgPicture.network(
currency.image,
currency!.image,
width: iconSize,
height: iconSize,
placeholderBuilder:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,71 @@ import '../../../../utilities/constants.dart';
import '../../../../utilities/text_styles.dart';
import '../../../../utilities/util.dart';

class CoinSelectItem extends ConsumerWidget {
class CoinSelectItem extends ConsumerStatefulWidget {
const CoinSelectItem({super.key, required this.entity});

final AddWalletListEntity entity;

@override
Widget build(BuildContext context, WidgetRef ref) {
debugPrint("BUILD: CoinSelectItem for ${entity.name}");
final selectedEntity = ref.watch(addWalletSelectedEntityStateProvider);
ConsumerState<CoinSelectItem> createState() => _CoinSelectItemState();
}

final isDesktop = Util.isDesktop;
class _CoinSelectItemState extends ConsumerState<CoinSelectItem> {
String? tokenImageUri;

String? tokenImageUri;
if (entity is EthTokenEntity) {
final currency =
ExchangeDataLoadingService.instance.isar.currencies
.where()
.exchangeNameEqualTo(ChangeNowExchange.exchangeName)
.filter()
.tokenContractEqualTo(
(entity as EthTokenEntity).token.address,
caseSensitive: false,
)
.and()
.imageIsNotEmpty()
.findFirstSync();
tokenImageUri = currency?.image;
@override
void initState() {
super.initState();

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

if (mounted) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
setState(() {
tokenImageUri = currency?.image;
});
}
});
}
});
}
}

@override
Widget build(BuildContext context) {
debugPrint("BUILD: CoinSelectItem for ${widget.entity.name}");
final selectedEntity = ref.watch(addWalletSelectedEntityStateProvider);

final isDesktop = Util.isDesktop;

return Container(
decoration: BoxDecoration(
color:
selectedEntity == entity
selectedEntity == widget.entity
? Theme.of(context).extension<StackColors>()!.textFieldActiveBG
: Theme.of(context).extension<StackColors>()!.popupBG,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
child: MaterialButton(
key: Key("coinSelectItemButtonKey_${entity.name}${entity.ticker}"),
key: Key(
"coinSelectItemButtonKey_${widget.entity.name}${widget.entity.ticker}",
),
padding:
isDesktop
? const EdgeInsets.only(left: 24)
Expand All @@ -84,24 +108,26 @@ class CoinSelectItem extends ConsumerWidget {
child: Row(
children: [
tokenImageUri != null
? SvgPicture.network(tokenImageUri, width: 26, height: 26)
? SvgPicture.network(tokenImageUri!, width: 26, height: 26)
: SvgPicture.file(
File(ref.watch(coinIconProvider(entity.cryptoCurrency))),
File(
ref.watch(coinIconProvider(widget.entity.cryptoCurrency)),
),
width: 26,
height: 26,
),
SizedBox(width: isDesktop ? 12 : 10),
Text(
"${entity.name} (${entity.ticker})",
"${widget.entity.name} (${widget.entity.ticker})",
style:
isDesktop
? STextStyles.desktopTextMedium(context)
: STextStyles.subtitle600(
context,
).copyWith(fontSize: 14),
),
if (isDesktop && selectedEntity == entity) const Spacer(),
if (isDesktop && selectedEntity == entity)
if (isDesktop && selectedEntity == widget.entity) const Spacer(),
if (isDesktop && selectedEntity == widget.entity)
Padding(
padding: const EdgeInsets.only(right: 18),
child: SizedBox(
Expand All @@ -120,7 +146,8 @@ class CoinSelectItem extends ConsumerWidget {
),
),
onPressed: () {
ref.read(addWalletSelectedEntityStateProvider.state).state = entity;
ref.read(addWalletSelectedEntityStateProvider.state).state =
widget.entity;
},
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ExpandingSubListItem extends StatefulWidget {
double? animationDurationMultiplier,
this.curve = Curves.easeInOutCubicEmphasized,
}) : animationDurationMultiplier =
animationDurationMultiplier ?? entities.length * 0.11;
animationDurationMultiplier ?? entities.length * 0.11;

final String title;
final List<AddWalletListEntity> entities;
Expand Down Expand Up @@ -85,33 +85,32 @@ class _ExpandingSubListItemState extends State<ExpandingSubListItem> {
header: Container(
color: Colors.transparent,
child: Padding(
padding: const EdgeInsets.only(
top: 8.0,
bottom: 8.0,
right: 10,
),
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0, right: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
widget.title,
style: isDesktop
? STextStyles.desktopTextMedium(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark3,
)
: STextStyles.smallMed12(context),
style:
isDesktop
? STextStyles.desktopTextMedium(context).copyWith(
color:
Theme.of(
context,
).extension<StackColors>()!.textDark3,
)
: STextStyles.smallMed12(context),
textAlign: TextAlign.left,
),
RotateIcon(
icon: SvgPicture.asset(
Assets.svg.chevronDown,
width: isDesktop ? 20 : 12,
height: isDesktop ? 10 : 6,
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveSearchIconRight,
color:
Theme.of(context)
.extension<StackColors>()!
.textFieldActiveSearchIconRight,
),
curve: widget.curve,
animationDurationMultiplier: widget.animationDurationMultiplier,
Expand Down
35 changes: 32 additions & 3 deletions lib/pages/buy_view/buy_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:intl/intl.dart';
import 'package:isar/isar.dart';

import '../../app_config.dart';
import '../../models/buy/response_objects/crypto.dart';
import '../../models/buy/response_objects/fiat.dart';
import '../../models/buy/response_objects/quote.dart';
import '../../models/contact_address_entry.dart';
import '../../models/isar/models/blockchain_data/address.dart';
import '../../models/isar/models/ethereum/eth_contract.dart';
import '../../pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart';
import '../../providers/providers.dart';
Expand All @@ -33,10 +35,12 @@ import '../../utilities/assets.dart';
import '../../utilities/barcode_scanner_interface.dart';
import '../../utilities/clipboard_interface.dart';
import '../../utilities/constants.dart';
import '../../utilities/enums/derive_path_type_enum.dart';
import '../../utilities/logger.dart';
import '../../utilities/text_styles.dart';
import '../../utilities/util.dart';
import '../../wallets/crypto_currency/crypto_currency.dart';
import '../../wallets/wallet/intermediate/bip39_hd_wallet.dart';
import '../../widgets/conditional_parent.dart';
import '../../widgets/custom_buttons/blue_text_button.dart';
import '../../widgets/custom_loading_overlay.dart';
Expand Down Expand Up @@ -1204,9 +1208,34 @@ class _BuyFormState extends ConsumerState<BuyForm> {
// _toController.text = manager.walletName;
// model.recipientAddress =
// await manager.currentReceivingAddress;
_receiveAddressController.text =
(await wallet.getCurrentReceivingAddress())!
.value;

final address =
await wallet.getCurrentReceivingAddress();

if (address!.type == AddressType.p2tr &&
wallet is Bip39HDWallet) {
// lets assume any wallet that has taproot also has segwit. WCGW
final address =
await ref
.read(mainDBProvider)
.isar
.addresses
.where()
.walletIdEqualTo(wallet.walletId)
.filter()
.typeEqualTo(AddressType.p2wpkh)
.sortByDerivationIndexDesc()
.findFirst() ??
await wallet.generateNextReceivingAddress(
derivePathType: DerivePathType.bip84,
);

_receiveAddressController.text =
address.value;
} else {
_receiveAddressController.text =
address.value;
}

setState(() {
_addressToggleFlag =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ class _ExchangeCurrencySelectionViewState

Future<List<AggregateCurrency>> _loadCurrencies() async {
await ExchangeDataLoadingService.instance.initDB();
final isar = await ExchangeDataLoadingService.instance.isar;
final currencies =
await ExchangeDataLoadingService.instance.isar.currencies
await isar.currencies
.where()
.filter()
.isFiatEqualTo(false)
Expand Down
Loading
Loading