mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
Generic enhancements (#1435)
* Disable Ledger for MacOS * increase update duration for Solana [skip ci] * change tron default Node Update build number * Add disabling tron grid to privacy settings * update monero.com versions [skip ci]
This commit is contained in:
parent
baad7f7469
commit
12e3001b3a
51 changed files with 217 additions and 138 deletions
|
@ -22,14 +22,14 @@ class DefaultTronTokens {
|
|||
symbol: "BTC",
|
||||
contractAddress: "TN3W4H6rK2ce4vX9YnFQHwKENnHjoxb3m9",
|
||||
decimal: 8,
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
),
|
||||
TronToken(
|
||||
name: "Ethereum",
|
||||
symbol: "ETH",
|
||||
contractAddress: "TRFe3hT5oYhjSZ6f3ji5FJ7YCfrkWnHRvh",
|
||||
decimal: 18,
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
),
|
||||
TronToken(
|
||||
name: "Wrapped BTC",
|
||||
|
|
|
@ -19,7 +19,7 @@ class TronHTTPProvider implements TronServiceProvider {
|
|||
Future<Map<String, dynamic>> get(TronRequestDetails params, [Duration? timeout]) async {
|
||||
final response = await client.get(Uri.parse(params.url(url)), headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'TRON-PRO-API-KEY': secrets.tronGridApiKey,
|
||||
if (url.contains("trongrid")) 'TRON-PRO-API-KEY': secrets.tronGridApiKey,
|
||||
}).timeout(timeout ?? defaultRequestTimeout);
|
||||
final data = json.decode(response.body) as Map<String, dynamic>;
|
||||
return data;
|
||||
|
@ -31,7 +31,7 @@ class TronHTTPProvider implements TronServiceProvider {
|
|||
.post(Uri.parse(params.url(url)),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'TRON-PRO-API-KEY': secrets.tronGridApiKey,
|
||||
if (url.contains("trongrid")) 'TRON-PRO-API-KEY': secrets.tronGridApiKey,
|
||||
},
|
||||
body: params.toRequestBody())
|
||||
.timeout(timeout ?? defaultRequestTimeout);
|
||||
|
|
|
@ -31,7 +31,6 @@ import 'package:cw_tron/tron_wallet_addresses.dart';
|
|||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:on_chain/on_chain.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
part 'tron_wallet.g.dart';
|
||||
|
||||
|
@ -61,8 +60,6 @@ abstract class TronWalletBase
|
|||
if (!CakeHive.isAdapterRegistered(TronToken.typeId)) {
|
||||
CakeHive.registerAdapter(TronTokenAdapter());
|
||||
}
|
||||
|
||||
sharedPrefs.complete(SharedPreferences.getInstance());
|
||||
}
|
||||
|
||||
final String? _mnemonic;
|
||||
|
@ -81,7 +78,7 @@ abstract class TronWalletBase
|
|||
|
||||
late String _tronAddress;
|
||||
|
||||
late TronClient _client;
|
||||
late final TronClient _client;
|
||||
|
||||
Timer? _transactionsUpdateTimer;
|
||||
|
||||
|
@ -102,8 +99,6 @@ abstract class TronWalletBase
|
|||
@observable
|
||||
late ObservableMap<CryptoCurrency, TronBalance> balance;
|
||||
|
||||
Completer<SharedPreferences> sharedPrefs = Completer();
|
||||
|
||||
Future<void> init() async {
|
||||
await initTronTokensBox();
|
||||
|
||||
|
@ -464,6 +459,7 @@ abstract class TronWalletBase
|
|||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void>? updateBalance() async => await _updateBalance();
|
||||
|
||||
List<TronToken> get tronTokenCurrencies => tronTokensBox.values.toList();
|
||||
|
@ -543,7 +539,7 @@ abstract class TronWalletBase
|
|||
_transactionsUpdateTimer!.cancel();
|
||||
}
|
||||
|
||||
_transactionsUpdateTimer = Timer.periodic(const Duration(seconds: 20), (_) async {
|
||||
_transactionsUpdateTimer = Timer.periodic(const Duration(seconds: 30), (_) async {
|
||||
_updateBalance();
|
||||
await fetchTransactions();
|
||||
fetchTrc20ExcludedTransactions();
|
||||
|
@ -557,4 +553,14 @@ abstract class TronWalletBase
|
|||
String getTronBase58AddressFromHex(String hexAddress) {
|
||||
return TronAddress(hexAddress).toAddress();
|
||||
}
|
||||
|
||||
void updateScanProviderUsageState(bool isEnabled) {
|
||||
if (isEnabled) {
|
||||
fetchTransactions();
|
||||
fetchTrc20ExcludedTransactions();
|
||||
_setTransactionUpdateTimer();
|
||||
} else {
|
||||
_transactionsUpdateTimer?.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue