mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-05-02 19:02:17 +00:00
WIP:Add onchain notes for Epic
This commit is contained in:
parent
f1bcb05ff8
commit
ca27f13d7b
5 changed files with 168 additions and 7 deletions
crypto_plugins
lib
pages
send_view
wallet_view/transaction_views
services/coins/epiccash
|
@ -1 +1 @@
|
||||||
Subproject commit 3f94722254d1c9ad54036e39a620ccc0bb53863b
|
Subproject commit 899f70f1f6709eba9b47dfa652085ae552bf3b73
|
|
@ -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(
|
const SizedBox(
|
||||||
height: 12,
|
height: 12,
|
||||||
),
|
),
|
||||||
|
|
|
@ -101,12 +101,14 @@ class _SendViewState extends ConsumerState<SendView> {
|
||||||
late TextEditingController cryptoAmountController;
|
late TextEditingController cryptoAmountController;
|
||||||
late TextEditingController baseAmountController;
|
late TextEditingController baseAmountController;
|
||||||
late TextEditingController noteController;
|
late TextEditingController noteController;
|
||||||
|
late TextEditingController onChainNoteController;
|
||||||
late TextEditingController feeController;
|
late TextEditingController feeController;
|
||||||
|
|
||||||
late final SendViewAutoFillData? _data;
|
late final SendViewAutoFillData? _data;
|
||||||
|
|
||||||
final _addressFocusNode = FocusNode();
|
final _addressFocusNode = FocusNode();
|
||||||
final _noteFocusNode = FocusNode();
|
final _noteFocusNode = FocusNode();
|
||||||
|
final _onChainNoteFocusNode = FocusNode();
|
||||||
final _cryptoFocus = FocusNode();
|
final _cryptoFocus = FocusNode();
|
||||||
final _baseFocus = FocusNode();
|
final _baseFocus = FocusNode();
|
||||||
|
|
||||||
|
@ -546,6 +548,7 @@ class _SendViewState extends ConsumerState<SendView> {
|
||||||
// pop building dialog
|
// pop building dialog
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
txData["note"] = noteController.text;
|
txData["note"] = noteController.text;
|
||||||
|
txData["onChainNote"] = onChainNoteController.text;
|
||||||
if (isPaynymSend) {
|
if (isPaynymSend) {
|
||||||
txData["paynymAccountLite"] = widget.accountLite!;
|
txData["paynymAccountLite"] = widget.accountLite!;
|
||||||
} else {
|
} else {
|
||||||
|
@ -624,6 +627,7 @@ class _SendViewState extends ConsumerState<SendView> {
|
||||||
cryptoAmountController = TextEditingController();
|
cryptoAmountController = TextEditingController();
|
||||||
baseAmountController = TextEditingController();
|
baseAmountController = TextEditingController();
|
||||||
noteController = TextEditingController();
|
noteController = TextEditingController();
|
||||||
|
onChainNoteController = TextEditingController();
|
||||||
feeController = TextEditingController();
|
feeController = TextEditingController();
|
||||||
|
|
||||||
onCryptoAmountChanged = _cryptoAmountChanged;
|
onCryptoAmountChanged = _cryptoAmountChanged;
|
||||||
|
@ -698,9 +702,11 @@ class _SendViewState extends ConsumerState<SendView> {
|
||||||
cryptoAmountController.dispose();
|
cryptoAmountController.dispose();
|
||||||
baseAmountController.dispose();
|
baseAmountController.dispose();
|
||||||
noteController.dispose();
|
noteController.dispose();
|
||||||
|
onChainNoteController.dispose();
|
||||||
feeController.dispose();
|
feeController.dispose();
|
||||||
|
|
||||||
_noteFocusNode.dispose();
|
_noteFocusNode.dispose();
|
||||||
|
_onChainNoteFocusNode.dispose();
|
||||||
_addressFocusNode.dispose();
|
_addressFocusNode.dispose();
|
||||||
_cryptoFocus.dispose();
|
_cryptoFocus.dispose();
|
||||||
_baseFocus.dispose();
|
_baseFocus.dispose();
|
||||||
|
@ -1794,6 +1800,58 @@ class _SendViewState extends ConsumerState<SendView> {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 12,
|
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(
|
Text(
|
||||||
"Note (optional)",
|
"Note (optional)",
|
||||||
style: STextStyles.smallMed12(context),
|
style: STextStyles.smallMed12(context),
|
||||||
|
|
|
@ -358,6 +358,9 @@ class _TransactionDetailsViewState
|
||||||
final currentHeight = ref.watch(walletsChangeNotifierProvider
|
final currentHeight = ref.watch(walletsChangeNotifierProvider
|
||||||
.select((value) => value.getManager(walletId).currentHeight));
|
.select((value) => value.getManager(walletId).currentHeight));
|
||||||
|
|
||||||
|
|
||||||
|
print("THIS TRANSACTION IS $_transaction");
|
||||||
|
|
||||||
return ConditionalParent(
|
return ConditionalParent(
|
||||||
condition: !isDesktop,
|
condition: !isDesktop,
|
||||||
builder: (child) => Background(
|
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
|
isDesktop
|
||||||
? const _Divider()
|
? const _Divider()
|
||||||
: const SizedBox(
|
: const SizedBox(
|
||||||
|
@ -792,7 +867,7 @@ class _TransactionDetailsViewState
|
||||||
MainAxisAlignment.spaceBetween,
|
MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Note",
|
(coin == Coin.epicCash) ? "Local Note" : "Note ",
|
||||||
style: isDesktop
|
style: isDesktop
|
||||||
? STextStyles
|
? STextStyles
|
||||||
.desktopTextExtraExtraSmall(
|
.desktopTextExtraExtraSmall(
|
||||||
|
@ -861,7 +936,7 @@ class _TransactionDetailsViewState
|
||||||
notesServiceChangeNotifierProvider(
|
notesServiceChangeNotifierProvider(
|
||||||
walletId)
|
walletId)
|
||||||
.select((value) => value.getNoteFor(
|
.select((value) => value.getNoteFor(
|
||||||
txid: _transaction.txid))),
|
txid: (coin == Coin.epicCash)? _transaction.slateId! : _transaction.txid ))),
|
||||||
builder: (builderContext,
|
builder: (builderContext,
|
||||||
AsyncSnapshot<String> snapshot) {
|
AsyncSnapshot<String> snapshot) {
|
||||||
if (snapshot.connectionState ==
|
if (snapshot.connectionState ==
|
||||||
|
|
|
@ -156,6 +156,7 @@ Future<void> executeNative(Map<String, dynamic> arguments) async {
|
||||||
final secretKeyIndex = arguments['secretKeyIndex'] as int?;
|
final secretKeyIndex = arguments['secretKeyIndex'] as int?;
|
||||||
final epicboxConfig = arguments['epicboxConfig'] as String?;
|
final epicboxConfig = arguments['epicboxConfig'] as String?;
|
||||||
final minimumConfirmations = arguments['minimumConfirmations'] as int?;
|
final minimumConfirmations = arguments['minimumConfirmations'] as int?;
|
||||||
|
final onChainNote = arguments['onChainNote'] as String?;
|
||||||
|
|
||||||
Map<String, dynamic> result = {};
|
Map<String, dynamic> result = {};
|
||||||
if (!(wallet == null ||
|
if (!(wallet == null ||
|
||||||
|
@ -165,7 +166,7 @@ Future<void> executeNative(Map<String, dynamic> arguments) async {
|
||||||
epicboxConfig == null ||
|
epicboxConfig == null ||
|
||||||
minimumConfirmations == null)) {
|
minimumConfirmations == null)) {
|
||||||
var res = await createTransaction(wallet, amount, address,
|
var res = await createTransaction(wallet, amount, address,
|
||||||
secretKeyIndex, epicboxConfig, minimumConfirmations);
|
secretKeyIndex, epicboxConfig, minimumConfirmations, onChainNote!);
|
||||||
result['result'] = res;
|
result['result'] = res;
|
||||||
sendPort.send(result);
|
sendPort.send(result);
|
||||||
return;
|
return;
|
||||||
|
@ -175,7 +176,7 @@ Future<void> executeNative(Map<String, dynamic> arguments) async {
|
||||||
final selectionStrategyIsAll =
|
final selectionStrategyIsAll =
|
||||||
arguments['selectionStrategyIsAll'] as int?;
|
arguments['selectionStrategyIsAll'] as int?;
|
||||||
final minimumConfirmations = arguments['minimumConfirmations'] 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 amount = arguments['amount'] as int?;
|
||||||
final address = arguments['address'] as String?;
|
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.
|
// TODO determine whether it is worth sending change to a change address.
|
||||||
dynamic message;
|
dynamic message;
|
||||||
|
print("THIS TX DATA IS $txData");
|
||||||
|
|
||||||
String receiverAddress = txData['addresss'] as String;
|
String receiverAddress = txData['addresss'] as String;
|
||||||
|
|
||||||
|
@ -480,7 +482,7 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
"wallet": wallet!,
|
"wallet": wallet!,
|
||||||
"selectionStrategyIsAll": selectionStrategyIsAll,
|
"selectionStrategyIsAll": selectionStrategyIsAll,
|
||||||
"minimumConfirmations": MINIMUM_CONFIRMATIONS,
|
"minimumConfirmations": MINIMUM_CONFIRMATIONS,
|
||||||
"message": "",
|
"message": txData['onChainNote'],
|
||||||
"amount": (txData['recipientAmt'] as Amount).raw.toInt(),
|
"amount": (txData['recipientAmt'] as Amount).raw.toInt(),
|
||||||
"address": txData['addresss'] as String,
|
"address": txData['addresss'] as String,
|
||||||
}, name: walletName);
|
}, name: walletName);
|
||||||
|
@ -504,6 +506,7 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
"secretKeyIndex": 0,
|
"secretKeyIndex": 0,
|
||||||
"epicboxConfig": epicboxConfig.toString(),
|
"epicboxConfig": epicboxConfig.toString(),
|
||||||
"minimumConfirmations": MINIMUM_CONFIRMATIONS,
|
"minimumConfirmations": MINIMUM_CONFIRMATIONS,
|
||||||
|
"onChainNote": txData['onChainNote'],
|
||||||
}, name: walletName);
|
}, name: walletName);
|
||||||
|
|
||||||
message = await receivePort.first;
|
message = await receivePort.first;
|
||||||
|
@ -1721,6 +1724,8 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
"";
|
"";
|
||||||
String? commitId = slatesToCommits[slateId]?['commitId'] as String?;
|
String? commitId = slatesToCommits[slateId]?['commitId'] as String?;
|
||||||
tx['numberOfMessages'] = tx['messages']?['messages']?.length;
|
tx['numberOfMessages'] = tx['messages']?['messages']?.length;
|
||||||
|
tx['onChainNote'] = tx['messages']?['messages']?[0]?['message'];
|
||||||
|
print("ON CHAIN MESSAGE IS ${tx['onChainNote']}");
|
||||||
|
|
||||||
int? height;
|
int? height;
|
||||||
|
|
||||||
|
@ -1754,7 +1759,8 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
isLelantus: false,
|
isLelantus: false,
|
||||||
slateId: slateId,
|
slateId: slateId,
|
||||||
nonce: null,
|
nonce: null,
|
||||||
otherData: tx["id"].toString(),
|
// otherData: tx["id"].toString(),
|
||||||
|
otherData: tx['onChainNote'].toString(),
|
||||||
inputs: [],
|
inputs: [],
|
||||||
outputs: [],
|
outputs: [],
|
||||||
numberOfMessages: ((tx["numberOfMessages"] == null) ? 0 : tx["numberOfMessages"]) as int,
|
numberOfMessages: ((tx["numberOfMessages"] == null) ? 0 : tx["numberOfMessages"]) as int,
|
||||||
|
|
Loading…
Reference in a new issue