diff --git a/crypto_plugins/flutter_libepiccash b/crypto_plugins/flutter_libepiccash index 3f9472225..899f70f1f 160000 --- a/crypto_plugins/flutter_libepiccash +++ b/crypto_plugins/flutter_libepiccash @@ -1 +1 @@ -Subproject commit 3f94722254d1c9ad54036e39a620ccc0bb53863b +Subproject commit 899f70f1f6709eba9b47dfa652085ae552bf3b73 diff --git a/lib/pages/send_view/confirm_transaction_view.dart b/lib/pages/send_view/confirm_transaction_view.dart index e50d15193..2037eb158 100644 --- a/lib/pages/send_view/confirm_transaction_view.dart +++ b/lib/pages/send_view/confirm_transaction_view.dart @@ -493,6 +493,28 @@ class _ConfirmTransactionViewState ], ), ), + if (coin == Coin.epicCash) + const SizedBox( + height: 12, + ), + RoundedWhiteContainer( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + "On chain note", + style: STextStyles.smallMed12(context), + ), + const SizedBox( + height: 4, + ), + Text( + transactionInfo["onChainNote"] as String, + style: STextStyles.itemSubtitle12(context), + ), + ], + ), + ), const SizedBox( height: 12, ), diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index 0f503588c..9f264773e 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -101,12 +101,14 @@ class _SendViewState extends ConsumerState { late TextEditingController cryptoAmountController; late TextEditingController baseAmountController; late TextEditingController noteController; + late TextEditingController onChainNoteController; late TextEditingController feeController; late final SendViewAutoFillData? _data; final _addressFocusNode = FocusNode(); final _noteFocusNode = FocusNode(); + final _onChainNoteFocusNode = FocusNode(); final _cryptoFocus = FocusNode(); final _baseFocus = FocusNode(); @@ -546,6 +548,7 @@ class _SendViewState extends ConsumerState { // pop building dialog Navigator.of(context).pop(); txData["note"] = noteController.text; + txData["onChainNote"] = onChainNoteController.text; if (isPaynymSend) { txData["paynymAccountLite"] = widget.accountLite!; } else { @@ -624,6 +627,7 @@ class _SendViewState extends ConsumerState { cryptoAmountController = TextEditingController(); baseAmountController = TextEditingController(); noteController = TextEditingController(); + onChainNoteController = TextEditingController(); feeController = TextEditingController(); onCryptoAmountChanged = _cryptoAmountChanged; @@ -698,9 +702,11 @@ class _SendViewState extends ConsumerState { cryptoAmountController.dispose(); baseAmountController.dispose(); noteController.dispose(); + onChainNoteController.dispose(); feeController.dispose(); _noteFocusNode.dispose(); + _onChainNoteFocusNode.dispose(); _addressFocusNode.dispose(); _cryptoFocus.dispose(); _baseFocus.dispose(); @@ -1794,6 +1800,58 @@ class _SendViewState extends ConsumerState { const SizedBox( height: 12, ), + if (coin == Coin.epicCash) + Text( + "On chain Note (optional)", + style: STextStyles.smallMed12(context), + textAlign: TextAlign.left, + ), + const SizedBox( + height: 8, + ), + ClipRRect( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + child: TextField( + autocorrect: Util.isDesktop ? false : true, + enableSuggestions: Util.isDesktop ? false : true, + maxLength: 256, + controller: onChainNoteController, + focusNode: _onChainNoteFocusNode, + style: STextStyles.field(context), + onChanged: (_) => setState(() {}), + decoration: standardInputDecoration( + "Type something...", + _onChainNoteFocusNode, + context, + ).copyWith( + suffixIcon: onChainNoteController.text.isNotEmpty + ? Padding( + padding: + const EdgeInsets.only(right: 0), + child: UnconstrainedBox( + child: Row( + children: [ + TextFieldIconButton( + child: const XIcon(), + onTap: () async { + setState(() { + onChainNoteController.text = ""; + }); + }, + ), + ], + ), + ), + ) + : null, + ), + ), + ), + const SizedBox( + height: 12, + ), Text( "Note (optional)", style: STextStyles.smallMed12(context), diff --git a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart index cba8f5e5f..32d83e641 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart @@ -358,6 +358,9 @@ class _TransactionDetailsViewState final currentHeight = ref.watch(walletsChangeNotifierProvider .select((value) => value.getManager(walletId).currentHeight)); + + print("THIS TRANSACTION IS $_transaction"); + return ConditionalParent( condition: !isDesktop, builder: (child) => Background( @@ -774,6 +777,78 @@ class _TransactionDetailsViewState ], ), ), + if (coin == Coin.epicCash) + isDesktop + ? const _Divider() + : const SizedBox( + height: 12, + ), + RoundedWhiteContainer( + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + ConditionalParent( + condition: kDebugMode, + builder: (child) { + return Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + child, + ], + ); + }, + child: Text( + "On chain note", + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context) + : STextStyles.itemSubtitle( + context), + ), + ), + const SizedBox( + height: 8, + ), + SelectableText( + _transaction.otherData!, + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context) + .copyWith( + color: Theme.of( + context) + .extension< + StackColors>()! + .textDark, + ) + : STextStyles + .itemSubtitle12( + context), + ), + ], + ), + ), + if (isDesktop) + IconCopyButton( + data: _transaction.address.value!.value, + ), + ], + ), + ), isDesktop ? const _Divider() : const SizedBox( @@ -792,7 +867,7 @@ class _TransactionDetailsViewState MainAxisAlignment.spaceBetween, children: [ Text( - "Note", + (coin == Coin.epicCash) ? "Local Note" : "Note ", style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( @@ -861,7 +936,7 @@ class _TransactionDetailsViewState notesServiceChangeNotifierProvider( walletId) .select((value) => value.getNoteFor( - txid: _transaction.txid))), + txid: (coin == Coin.epicCash)? _transaction.slateId! : _transaction.txid ))), builder: (builderContext, AsyncSnapshot snapshot) { if (snapshot.connectionState == diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 1cf75396b..b62129248 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -156,6 +156,7 @@ Future executeNative(Map arguments) async { final secretKeyIndex = arguments['secretKeyIndex'] as int?; final epicboxConfig = arguments['epicboxConfig'] as String?; final minimumConfirmations = arguments['minimumConfirmations'] as int?; + final onChainNote = arguments['onChainNote'] as String?; Map result = {}; if (!(wallet == null || @@ -165,7 +166,7 @@ Future executeNative(Map arguments) async { epicboxConfig == null || minimumConfirmations == null)) { var res = await createTransaction(wallet, amount, address, - secretKeyIndex, epicboxConfig, minimumConfirmations); + secretKeyIndex, epicboxConfig, minimumConfirmations, onChainNote!); result['result'] = res; sendPort.send(result); return; @@ -175,7 +176,7 @@ Future executeNative(Map arguments) async { final selectionStrategyIsAll = arguments['selectionStrategyIsAll'] as int?; final minimumConfirmations = arguments['minimumConfirmations'] as int?; - final message = arguments['message'] as String?; + final message = arguments['onChainNote'] as String?; final amount = arguments['amount'] as int?; final address = arguments['address'] as String?; @@ -459,6 +460,7 @@ class EpicCashWallet extends CoinServiceAPI // TODO determine whether it is worth sending change to a change address. dynamic message; + print("THIS TX DATA IS $txData"); String receiverAddress = txData['addresss'] as String; @@ -480,7 +482,7 @@ class EpicCashWallet extends CoinServiceAPI "wallet": wallet!, "selectionStrategyIsAll": selectionStrategyIsAll, "minimumConfirmations": MINIMUM_CONFIRMATIONS, - "message": "", + "message": txData['onChainNote'], "amount": (txData['recipientAmt'] as Amount).raw.toInt(), "address": txData['addresss'] as String, }, name: walletName); @@ -504,6 +506,7 @@ class EpicCashWallet extends CoinServiceAPI "secretKeyIndex": 0, "epicboxConfig": epicboxConfig.toString(), "minimumConfirmations": MINIMUM_CONFIRMATIONS, + "onChainNote": txData['onChainNote'], }, name: walletName); message = await receivePort.first; @@ -1721,6 +1724,8 @@ class EpicCashWallet extends CoinServiceAPI ""; String? commitId = slatesToCommits[slateId]?['commitId'] as String?; tx['numberOfMessages'] = tx['messages']?['messages']?.length; + tx['onChainNote'] = tx['messages']?['messages']?[0]?['message']; + print("ON CHAIN MESSAGE IS ${tx['onChainNote']}"); int? height; @@ -1754,7 +1759,8 @@ class EpicCashWallet extends CoinServiceAPI isLelantus: false, slateId: slateId, nonce: null, - otherData: tx["id"].toString(), + // otherData: tx["id"].toString(), + otherData: tx['onChainNote'].toString(), inputs: [], outputs: [], numberOfMessages: ((tx["numberOfMessages"] == null) ? 0 : tx["numberOfMessages"]) as int,