mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
* feat(zcash): initial commit - initial work on cw_zcash - use single .db for everything zcash to speed up sync and scanning - implement silent autoshielding of non-orchard funds - use FFI for everything to fetch the data - add support for passphrase by adding extra word to seed phrase - enforce lints on CI for cw_zcash directory - use correct zcash name, and call transparent zcash tZEC - minor cleanups outsite of cw_zcash - gitmodules, gitignore - db debug - fix broken addressPageType in WalletInfo - enable debug options in kDebugMode and kProfileMode * feat: T address rotation (and cache) wip: minor fixes * wip: shield tx list * fix fiat amounts fix derrivation of rotation account addresses screen for zcash block height fix T address shields improvements Amount in disposable T shields UI improvements show pending outgoing tx in tx history * fix null check on passphrase page fix tx showing as pending rename auto shield txs fixed send all to include fee use rotating address in addressForExchange wrap all calls of WarpApi.getLatestHeight in try catch to prevent leaking errors other minor fixes from notion * wallet group debug cache sent tx address wallet T address rotation fixes automatically pick the fee for auto-shield * fix T address cache deserialization fix autoshield icon fix autoshield text getCachedDestinationAddress fix send address cache * address comments from review * wip: iOS fix * fix swap * Allow cakepay payment from zcash wallet * fix: ios (I'm stupid) fix: reorder addresses to make orchard default fix: send all balance * 5.6.6 bump fix: ios apple review add transport error to ignored exceptions * fix: leaving dust behind when sweeping all * Change wallets order * fix: reflect balance of pending out txs fix: restore height support * linux support (disabled) * fix: date picker for zcash on restore screen fix: build script for linux match WarpApi.warpSync args with upstream * fix: linter script * ensure all exchange providers support ZEC (#2802) * ensure all exchange providers support ZEC * remove zaddr and tzec currencies and refactor providers * Update lib/exchange/provider/near_Intents_exchange_provider.dart * add back old zcash currencies for backward compatibility, thanks Czarek * minor fix [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * Update android/app/src/main/AndroidManifestBase.xml [skip ci] * Update ios/Runner/InfoBase.plist [skip ci] * fix: remove unused code fix: macos fix: disable on linux and macos * update build numbers [skip ci] * Add zcash to birdpay --------- Co-authored-by: Czarek Nakamoto <cyjan@mrcyjanek.net> Co-authored-by: Serhii <borodenko.sv@gmail.com>
185 lines
4.7 KiB
Dart
Executable File
185 lines
4.7 KiB
Dart
Executable File
import 'dart:async';
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
import 'package:http/http.dart' as http; // very_insecure_http_do_not_use
|
|
import 'package:cake_wallet/.secrets.g.dart' as secrets;
|
|
import './print_verbose_dummy.dart';
|
|
|
|
// 1. Configuration
|
|
const _fiatApiClearNetAuthority = 'fiat-api.cakewallet.com';
|
|
const _fiatApiPath = '/v2/rates';
|
|
const _apiKey = secrets.fiatApiKey;
|
|
|
|
// 2. Define Lists
|
|
const List<String> cryptoCurrencies = [
|
|
'btc',
|
|
'ltc',
|
|
'xmr',
|
|
'bch',
|
|
'doge',
|
|
'eth',
|
|
'pol',
|
|
'sol',
|
|
'xno',
|
|
'trx',
|
|
'dcr',
|
|
'zano',
|
|
'wow',
|
|
'arb',
|
|
'usdt',
|
|
'pepe',
|
|
'zec',
|
|
'bnb',
|
|
'xrp',
|
|
'ada',
|
|
'avax',
|
|
'shib',
|
|
'ton',
|
|
'dot',
|
|
'link',
|
|
'uni',
|
|
'near',
|
|
'atom',
|
|
'xlm',
|
|
'stx',
|
|
'kas',
|
|
'dai',
|
|
];
|
|
|
|
const List<String> fiatCurrencies = [
|
|
'usd',
|
|
'eur',
|
|
'aud',
|
|
'gbp',
|
|
'jpy',
|
|
'cad',
|
|
'chf',
|
|
'cny',
|
|
'inr',
|
|
'brl',
|
|
'zar',
|
|
'mxn',
|
|
'krw',
|
|
'hkd',
|
|
'sgd',
|
|
'nzd',
|
|
'sek',
|
|
'try'
|
|
];
|
|
|
|
void main() {
|
|
// --- A. Setup the Output File ---
|
|
final logFile = File('fiat-check-output.txt');
|
|
// Write a header to start fresh (overwrite old file)
|
|
logFile.writeAsStringSync('--- Starting Verified Price Check at ${DateTime.now()} ---\n');
|
|
|
|
// --- B. Run App in a Zone to Capture Prints ---
|
|
runZoned(
|
|
() async {
|
|
printV('--- Starting Verified Price Check ---');
|
|
|
|
final Map<String, List<String>> workingPairs = {};
|
|
final Map<String, List<String>> failedPairs = {};
|
|
final client = http.Client();
|
|
|
|
try {
|
|
for (final crypto in cryptoCurrencies) {
|
|
workingPairs[crypto] = [];
|
|
failedPairs[crypto] = [];
|
|
|
|
for (final fiat in fiatCurrencies) {
|
|
// Clean ticker logic
|
|
String cleanCrypto = crypto.split(".").first;
|
|
|
|
final Map<String, String> queryParams = {
|
|
'interval_count': '1',
|
|
'base': cleanCrypto,
|
|
'quote': fiat,
|
|
};
|
|
|
|
final uri = Uri.https(_fiatApiClearNetAuthority, _fiatApiPath, queryParams);
|
|
bool isSuccess = false;
|
|
String logPrefix = "❌";
|
|
String logMessage = "";
|
|
|
|
try {
|
|
final response = await client.get(uri, headers: {"x-api-key": _apiKey});
|
|
|
|
if (response.statusCode == 200) {
|
|
final data = jsonDecode(response.body) as Map<String, dynamic>;
|
|
final Map<String, dynamic> results = data['results'] as Map<String, dynamic>? ?? {};
|
|
final Map<String, dynamic> errors = data['errors'] as Map<String, dynamic>? ?? {};
|
|
|
|
if (results.isNotEmpty && errors.isEmpty) {
|
|
isSuccess = true;
|
|
logPrefix = "✅";
|
|
final price = results.values.first;
|
|
logMessage = "${cleanCrypto.toUpperCase()}/${fiat.toUpperCase()} = $price";
|
|
} else {
|
|
isSuccess = false;
|
|
logPrefix = "❌";
|
|
logMessage =
|
|
"${cleanCrypto.toUpperCase()}/${fiat.toUpperCase()} returned empty results or error.";
|
|
}
|
|
} else {
|
|
logMessage =
|
|
"${cleanCrypto.toUpperCase()}/${fiat.toUpperCase()} HTTP ${response.statusCode}";
|
|
}
|
|
} catch (e) {
|
|
logMessage = "${cleanCrypto.toUpperCase()}/${fiat.toUpperCase()} Error: $e";
|
|
}
|
|
|
|
// Print immediate status (Captured by Zone)
|
|
printV('$logPrefix $logMessage');
|
|
|
|
// Aggregate
|
|
if (isSuccess) {
|
|
workingPairs[crypto]!.add(fiat);
|
|
} else {
|
|
failedPairs[crypto]!.add(fiat);
|
|
}
|
|
|
|
// 50ms delay to prevent rate limiting
|
|
await Future.delayed(Duration(milliseconds: 50));
|
|
}
|
|
}
|
|
} finally {
|
|
client.close();
|
|
}
|
|
|
|
// --- FINAL SUMMARY ---
|
|
printV('\n\n=== SUMMARY ===\n');
|
|
|
|
// Print Successful
|
|
workingPairs.forEach((crypto, fiats) {
|
|
if (fiats.isNotEmpty) {
|
|
printV('✅ ${crypto.toUpperCase()}: ${fiats.join(", ")}');
|
|
}
|
|
});
|
|
|
|
printV('\n--------------------------------------------------\n');
|
|
|
|
// Print Failed
|
|
failedPairs.forEach((crypto, fiats) {
|
|
if (fiats.isNotEmpty) {
|
|
printV('❌ ${crypto.toUpperCase()}: ${fiats.join(", ")}');
|
|
}
|
|
});
|
|
|
|
printV('\n=== DONE ===');
|
|
},
|
|
|
|
// --- C. The Interceptor ---
|
|
zoneSpecification: ZoneSpecification(
|
|
print: (self, parent, zone, line) {
|
|
// 1. Print to Standard Console
|
|
parent.print(zone, line);
|
|
|
|
// 2. Append to Text File
|
|
// We use Sync to ensure data isn't lost if the script crashes
|
|
logFile.writeAsStringSync('$line\n', mode: FileMode.append);
|
|
},
|
|
),
|
|
);
|
|
}
|