CW-415 add coin control for xmr (#985)

* Added CoinsInfo to monero_api_cpp

* Add struct on dart

* Add struct on dart

* Set coins value

* CW-415 Use add-coin-to-monero branch

* CW-415 Add get Coin and build Monero Deps using Docker

* CW-415 Fix Typo

* CW-415 add debug log info

* CW-415 Add preferred key Images for coin control to Monero

* CW-415 Fix generation

* CW-415 Skip GA Cache Externals

* CW-415 Skip GA Cache Externals

* CW-415 Coin Control: remove Block Explorer for Monero, Add Tx hash, save note on field exit

* CW-415 Coin Control: Throw Exception when all outputs are deselected

* CW-415 Coin Control: Show Frozen Balance on Dashboard

* CW-415 Coin Control: Show Frozen Balance on Dashboard

* CW-415 Ignore cached Monero deps in Workflow

* CW-415 Fix displaying frozen Balance

* Use own Translator with http 1.1.0

* CW-415 Resolve requested Changes

* CW-415 Resolve requested Changes

* CW-415 Resolve requested Changes

* CW-415 Apply requested Changes

* CW-415 Apply requested Changes

* CW-415 Ensure opening of UnspentCoinsInfo Box, even for Monero.com

---------

Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
This commit is contained in:
Godwin Asuquo
2023-08-24 16:54:05 +03:00
committed by GitHub
co-authored by Konstantin Ullrich
parent 3577730de8
commit f6670c0236
56 changed files with 1584 additions and 545 deletions
+66 -66
View File
@@ -1,66 +1,66 @@
// import 'dart:convert';
// import 'dart:io';
//
// import 'package:translator/translator.dart';
//
// const defaultLang = "en";
// const langs = [
// "ar", "bg", "cs", "de", "en", "es", "fr", "ha", "hi", "hr", "id", "it",
// "ja", "ko", "my", "nl", "pl", "pt", "ru", "th", "tr", "uk", "ur", "yo",
// "zh-cn" // zh, but Google Translate uses zh-cn for Chinese (Simplified)
// ];
// final translator = GoogleTranslator();
//
// void main(List<String> args) async {
// if (args.length != 2) {
// throw Exception(
// 'Insufficient arguments!\n\nTry to run `./append_translation.dart greetings "Hello World!"`');
// }
//
// final name = args.first;
// final text = args.last;
//
// print('Appending "$name": "$text"');
//
// for (var lang in langs) {
// final fileName = getFileName(lang);
// final translation = await getTranslation(text, lang);
//
// appendArbFile(fileName, name, translation);
// }
// }
//
// void appendArbFile(String fileName, String name, String text) {
// final file = File(fileName);
// final inputContent = file.readAsStringSync();
// final arbObj = json.decode(inputContent) as Map<String, dynamic>;
//
// if (arbObj.containsKey(name)) {
// print("String $name already exists in $fileName!");
// return;
// }
//
// arbObj.addAll({name: text});
//
// final outputContent = json
// .encode(arbObj)
// .replaceAll('","', '",\n "')
// .replaceAll('{"', '{\n "')
// .replaceAll('"}', '"\n}')
// .replaceAll('":"', '": "');
//
// file.writeAsStringSync(outputContent);
// }
//
//
// Future<String> getTranslation(String text, String lang) async {
// if (lang == defaultLang) return text;
// return (await translator.translate(text, from: defaultLang, to: lang)).text;
// }
//
// String getFileName(String lang) {
// final shortLang = lang
// .split("-")
// .first;
// return "./res/values/strings_$shortLang.arb";
// }
import 'dart:convert';
import 'dart:io';
import 'package:translator/translator.dart';
const defaultLang = "en";
const langs = [
"ar", "bg", "cs", "de", "en", "es", "fr", "ha", "hi", "hr", "id", "it",
"ja", "ko", "my", "nl", "pl", "pt", "ru", "th", "tr", "uk", "ur", "yo",
"zh-cn" // zh, but Google Translate uses zh-cn for Chinese (Simplified)
];
final translator = GoogleTranslator();
void main(List<String> args) async {
if (args.length != 2) {
throw Exception(
'Insufficient arguments!\n\nTry to run `./append_translation.dart greetings "Hello World!"`');
}
final name = args.first;
final text = args.last;
print('Appending "$name": "$text"');
for (var lang in langs) {
final fileName = getFileName(lang);
final translation = await getTranslation(text, lang);
appendArbFile(fileName, name, translation);
}
}
void appendArbFile(String fileName, String name, String text) {
final file = File(fileName);
final inputContent = file.readAsStringSync();
final arbObj = json.decode(inputContent) as Map<String, dynamic>;
if (arbObj.containsKey(name)) {
print("String $name already exists in $fileName!");
return;
}
arbObj.addAll({name: text});
final outputContent = json
.encode(arbObj)
.replaceAll('","', '",\n "')
.replaceAll('{"', '{\n "')
.replaceAll('"}', '"\n}')
.replaceAll('":"', '": "');
file.writeAsStringSync(outputContent);
}
Future<String> getTranslation(String text, String lang) async {
if (lang == defaultLang) return text;
return (await translator.translate(text, from: defaultLang, to: lang)).text;
}
String getFileName(String lang) {
final shortLang = lang
.split("-")
.first;
return "./res/values/strings_$shortLang.arb";
}
+9 -20
View File
@@ -25,6 +25,7 @@ Future<void> main(List<String> args) async {
Future<void> generateBitcoin(bool hasImplementation) async {
final outputFile = File(bitcoinOutputPath);
const bitcoinCommonHeaders = """
import 'package:cake_wallet/entities/unspent_transaction_output.dart';
import 'package:cw_core/wallet_credentials.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/transaction_priority.dart';
@@ -48,24 +49,6 @@ import 'package:cw_bitcoin/litecoin_wallet_service.dart';
""";
const bitcoinCwPart = "part 'cw_bitcoin.dart';";
const bitcoinContent = """
class Unspent {
Unspent(this.address, this.hash, this.value, this.vout)
: isSending = true,
isFrozen = false,
note = '';
final String address;
final String hash;
final int value;
final int vout;
bool isSending;
bool isFrozen;
String note;
bool get isP2wpkh => address.startsWith('bc') || address.startsWith('ltc');
}
abstract class Bitcoin {
TransactionPriority getMediumTransactionPriority();
@@ -122,6 +105,9 @@ abstract class Bitcoin {
Future<void> generateMonero(bool hasImplementation) async {
final outputFile = File(moneroOutputPath);
const moneroCommonHeaders = """
import 'package:cake_wallet/entities/unspent_transaction_output.dart';
import 'package:cw_core/unspent_coins_info.dart';
import 'package:cw_monero/monero_unspent.dart';
import 'package:mobx/mobx.dart';
import 'package:flutter/foundation.dart';
import 'package:cw_core/wallet_credentials.dart';
@@ -231,6 +217,9 @@ abstract class Monero {
TransactionPriority deserializeMoneroTransactionPriority({required int raw});
List<TransactionPriority> getTransactionPriorities();
List<String> getMoneroWordList(String language);
List<Unspent> getUnspents(Object wallet);
void updateUnspents(Object wallet);
WalletCredentials createMoneroRestoreWalletFromKeysCredentials({
required String name,
@@ -252,7 +241,7 @@ abstract class Monero {
void setCurrentAccount(Object wallet, int id, String label, String? balance);
void onStartup();
int getTransactionInfoAccountId(TransactionInfo tx);
WalletService createMoneroWalletService(Box<WalletInfo> walletInfoSource);
WalletService createMoneroWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
Map<String, String> pendingTransactionInfo(Object transaction);
}
@@ -650,4 +639,4 @@ Future<void> generateWalletTypes({required bool hasMonero, required bool hasBitc
outputContent += '];\n';
await walletTypesFile.writeAsString(outputContent);
}
}