mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
Merge pull request #604 from cypherstack/add-onchain-notes-for-epic
Add onchain notes for epic
This commit is contained in:
commit
aa026ef33c
5 changed files with 163 additions and 9 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 3f94722254d1c9ad54036e39a620ccc0bb53863b
|
||||
Subproject commit e1df088733695ad06d377087d069eae1746d55a7
|
|
@ -493,6 +493,29 @@ class _ConfirmTransactionViewState
|
|||
],
|
||||
),
|
||||
),
|
||||
if (coin == Coin.epicCash)
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
if (coin == Coin.epicCash)
|
||||
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,
|
||||
),
|
||||
|
@ -501,6 +524,7 @@ class _ConfirmTransactionViewState
|
|||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
(coin == Coin.epicCash) ? "Local Note" :
|
||||
"Note",
|
||||
style: STextStyles.smallMed12(context),
|
||||
),
|
||||
|
|
|
@ -101,12 +101,14 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
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<SendView> {
|
|||
// 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<SendView> {
|
|||
cryptoAmountController = TextEditingController();
|
||||
baseAmountController = TextEditingController();
|
||||
noteController = TextEditingController();
|
||||
onChainNoteController = TextEditingController();
|
||||
feeController = TextEditingController();
|
||||
|
||||
onCryptoAmountChanged = _cryptoAmountChanged;
|
||||
|
@ -698,9 +702,11 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
cryptoAmountController.dispose();
|
||||
baseAmountController.dispose();
|
||||
noteController.dispose();
|
||||
onChainNoteController.dispose();
|
||||
feeController.dispose();
|
||||
|
||||
_noteFocusNode.dispose();
|
||||
_onChainNoteFocusNode.dispose();
|
||||
_addressFocusNode.dispose();
|
||||
_cryptoFocus.dispose();
|
||||
_baseFocus.dispose();
|
||||
|
@ -1794,8 +1800,64 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
if (coin == Coin.epicCash)
|
||||
Text(
|
||||
"On chain Note (optional)",
|
||||
style: STextStyles.smallMed12(context),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
if (coin == Coin.epicCash)
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
if (coin == Coin.epicCash)
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (coin == Coin.epicCash)
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Text(
|
||||
"Note (optional)",
|
||||
(coin == Coin.epicCash) ? "Local Note (optional)"
|
||||
: "Note (optional)",
|
||||
style: STextStyles.smallMed12(context),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
|
|
|
@ -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,12 +777,71 @@ class _TransactionDetailsViewState
|
|||
],
|
||||
),
|
||||
),
|
||||
if (coin == Coin.epicCash)
|
||||
isDesktop
|
||||
? const _Divider()
|
||||
: const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
if (coin == Coin.epicCash)
|
||||
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: [
|
||||
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(
|
||||
height: 12,
|
||||
),
|
||||
|
||||
RoundedWhiteContainer(
|
||||
padding: isDesktop
|
||||
? const EdgeInsets.all(16)
|
||||
|
@ -792,7 +854,7 @@ class _TransactionDetailsViewState
|
|||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Note",
|
||||
(coin == Coin.epicCash) ? "Local Note" : "Note ",
|
||||
style: isDesktop
|
||||
? STextStyles
|
||||
.desktopTextExtraExtraSmall(
|
||||
|
@ -861,7 +923,7 @@ class _TransactionDetailsViewState
|
|||
notesServiceChangeNotifierProvider(
|
||||
walletId)
|
||||
.select((value) => value.getNoteFor(
|
||||
txid: _transaction.txid))),
|
||||
txid: (coin == Coin.epicCash)? _transaction.slateId! : _transaction.txid ))),
|
||||
builder: (builderContext,
|
||||
AsyncSnapshot<String> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
|
|
|
@ -156,6 +156,7 @@ Future<void> executeNative(Map<String, dynamic> 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<String, dynamic> result = {};
|
||||
if (!(wallet == null ||
|
||||
|
@ -165,7 +166,7 @@ Future<void> executeNative(Map<String, dynamic> 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<void> executeNative(Map<String, dynamic> 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,
|
||||
|
|
Loading…
Reference in a new issue