mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
rename to shorter name
This commit is contained in:
parent
7550b334ec
commit
5d1989bd94
43 changed files with 84 additions and 91 deletions
|
@ -560,7 +560,7 @@ class DbVersionMigrator with WalletDB {
|
|||
|
||||
final count = await MainDB.instance.getTransactions(walletId).count();
|
||||
|
||||
final crypto = SupportedCoins.getCryptoCurrencyFor(info.coinIdentifier);
|
||||
final crypto = Coins.getCryptoCurrencyFor(info.coinIdentifier);
|
||||
|
||||
for (var i = 0; i < count; i += 50) {
|
||||
final txns = await MainDB.instance
|
||||
|
|
|
@ -164,7 +164,7 @@ class DB {
|
|||
names.removeWhere((name, dyn) {
|
||||
final jsonObject = Map<String, dynamic>.from(dyn as Map);
|
||||
try {
|
||||
SupportedCoins.getCryptoCurrencyFor(jsonObject["coin"] as String);
|
||||
Coins.getCryptoCurrencyFor(jsonObject["coin"] as String);
|
||||
return false;
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
|
|
|
@ -171,7 +171,7 @@ Future<void> migrateWalletsToIsar({
|
|||
coinName: old.coinIdentifier,
|
||||
walletId: old.walletId,
|
||||
name: old.name,
|
||||
mainAddressType: SupportedCoins.getCryptoCurrencyFor(old.coinIdentifier)
|
||||
mainAddressType: Coins.getCryptoCurrencyFor(old.coinIdentifier)
|
||||
.primaryAddressType,
|
||||
favouriteOrderIndex: favourites.indexOf(old.walletId),
|
||||
cachedChainHeight: walletBox.get(
|
||||
|
|
|
@ -43,7 +43,7 @@ class ContactAddressEntry {
|
|||
|
||||
factory ContactAddressEntry.fromJson(Map<String, dynamic> jsonObject) {
|
||||
return ContactAddressEntry(
|
||||
coin: SupportedCoins.getCryptoCurrencyFor(jsonObject["coin"] as String),
|
||||
coin: Coins.getCryptoCurrencyFor(jsonObject["coin"] as String),
|
||||
address: jsonObject["address"] as String,
|
||||
label: jsonObject["label"] as String,
|
||||
other: jsonObject["other"] as String?,
|
||||
|
|
|
@ -161,7 +161,7 @@ class Currency {
|
|||
|
||||
static bool checkIsStackCoin(String ticker) {
|
||||
try {
|
||||
SupportedCoins.getCryptoCurrencyForTicker(ticker);
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
|
|
|
@ -31,7 +31,7 @@ class TransactionBlockExplorer {
|
|||
@ignore
|
||||
CryptoCurrency? get coin {
|
||||
try {
|
||||
return SupportedCoins.getCryptoCurrencyForTicker(ticker);
|
||||
return Coins.getCryptoCurrencyForTicker(ticker);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class ContactEntry {
|
|||
@ignore
|
||||
List<ContactAddressEntry> get addressesSorted {
|
||||
final List<ContactAddressEntry> sorted = [];
|
||||
for (final coin in SupportedCoins.cryptocurrencies) {
|
||||
for (final coin in Coins.cryptocurrencies) {
|
||||
final slice = addresses.where((e) => e.coin == coin).toList();
|
||||
if (slice.isNotEmpty) {
|
||||
slice.sort(
|
||||
|
@ -102,7 +102,7 @@ class ContactAddressEntry {
|
|||
late final String? other;
|
||||
|
||||
@ignore
|
||||
CryptoCurrency get coin => SupportedCoins.getCryptoCurrencyFor(coinName);
|
||||
CryptoCurrency get coin => Coins.getCryptoCurrencyFor(coinName);
|
||||
|
||||
ContactAddressEntry();
|
||||
|
||||
|
|
|
@ -1858,7 +1858,7 @@ class StackTheme {
|
|||
final Map<String, Color> result = {};
|
||||
|
||||
for (final mainNetId
|
||||
in SupportedCoins.cryptocurrencies.map((e) => e.mainNetId)) {
|
||||
in Coins.cryptocurrencies.map((e) => e.mainNetId)) {
|
||||
if (map[mainNetId] is String) {
|
||||
result[mainNetId] = Color(
|
||||
(map[mainNetId] as String).toBigIntFromHex.toInt(),
|
||||
|
@ -2176,7 +2176,7 @@ class ThemeAssetsV2 implements IThemeAssets {
|
|||
|
||||
final Map<String, String> result = {};
|
||||
|
||||
for (final coin in SupportedCoins.cryptocurrencies) {
|
||||
for (final coin in Coins.cryptocurrencies) {
|
||||
result[coin.mainNetId] = map[coin.mainNetId] as String? ?? placeHolder;
|
||||
}
|
||||
|
||||
|
@ -2511,7 +2511,7 @@ class ThemeAssetsV3 implements IThemeAssets {
|
|||
|
||||
final Map<String, String> result = {};
|
||||
|
||||
for (final coin in SupportedCoins.cryptocurrencies) {
|
||||
for (final coin in Coins.cryptocurrencies) {
|
||||
result[coin.mainNetId] = map[coin.mainNetId] as String? ?? placeHolder;
|
||||
result[coin.mainNetId] = prependIfNeeded(result[coin.mainNetId]!);
|
||||
}
|
||||
|
|
|
@ -44,8 +44,7 @@ class NotificationCard extends ConsumerWidget {
|
|||
|
||||
String coinIconPath(IThemeAssets assets, WidgetRef ref) {
|
||||
try {
|
||||
final coin =
|
||||
SupportedCoins.getCryptoCurrencyByPrettyName(notification.coinName);
|
||||
final coin = Coins.getCryptoCurrencyByPrettyName(notification.coinName);
|
||||
return ref.read(coinIconProvider(coin));
|
||||
} catch (_) {
|
||||
return notification.iconAssetName;
|
||||
|
|
|
@ -66,11 +66,11 @@ class _AddWalletViewState extends ConsumerState<AddWalletView> {
|
|||
String _searchTerm = "";
|
||||
|
||||
final _coinsTestnet = [
|
||||
...SupportedCoins.cryptocurrencies
|
||||
...Coins.cryptocurrencies
|
||||
.where((e) => e.network == CryptoCurrencyNetwork.test),
|
||||
];
|
||||
final _coins = [
|
||||
...SupportedCoins.cryptocurrencies
|
||||
...Coins.cryptocurrencies
|
||||
.where((e) => e.network == CryptoCurrencyNetwork.main),
|
||||
];
|
||||
final List<AddWalletListEntity> coinEntities = [];
|
||||
|
|
|
@ -67,7 +67,7 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
|||
ref.refresh(addressBookFilterProvider);
|
||||
|
||||
if (widget.coin == null) {
|
||||
final coins = [...SupportedCoins.cryptocurrencies];
|
||||
final coins = [...Coins.cryptocurrencies];
|
||||
coins.removeWhere(
|
||||
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
|
||||
);
|
||||
|
|
|
@ -41,7 +41,7 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
final coins = [...SupportedCoins.cryptocurrencies];
|
||||
final coins = [...Coins.cryptocurrencies];
|
||||
coins.removeWhere(
|
||||
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
|
||||
);
|
||||
|
|
|
@ -28,7 +28,7 @@ class CoinSelectSheet extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final maxHeight = MediaQuery.of(context).size.height * 0.60;
|
||||
final coins_ = [...SupportedCoins.cryptocurrencies];
|
||||
final coins_ = [...Coins.cryptocurrencies];
|
||||
coins_.removeWhere(
|
||||
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
|
||||
);
|
||||
|
|
|
@ -74,7 +74,7 @@ class _NewContactAddressEntryFormState
|
|||
..text = ref.read(addressEntryDataProvider(widget.id)).address ?? "";
|
||||
addressLabelFocusNode = FocusNode();
|
||||
addressFocusNode = FocusNode();
|
||||
coins = [...SupportedCoins.cryptocurrencies];
|
||||
coins = [...Coins.cryptocurrencies];
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ class _NewContactAddressEntryFormState
|
|||
Widget build(BuildContext context) {
|
||||
final isDesktop = Util.isDesktop;
|
||||
if (isDesktop) {
|
||||
coins = [...SupportedCoins.cryptocurrencies];
|
||||
coins = [...Coins.cryptocurrencies];
|
||||
coins.removeWhere(
|
||||
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
|
||||
);
|
||||
|
|
|
@ -413,7 +413,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
|||
if (ticker == null) return false;
|
||||
|
||||
try {
|
||||
SupportedCoins.getCryptoCurrencyForTicker(ticker);
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
@ -1168,7 +1168,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
|||
text: "Choose from Stack",
|
||||
onTap: () {
|
||||
try {
|
||||
final coin = SupportedCoins.getCryptoCurrencyForTicker(
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
selectedCrypto!.ticker,
|
||||
);
|
||||
Navigator.of(context)
|
||||
|
@ -1331,7 +1331,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
|||
),
|
||||
Expanded(
|
||||
child: AddressBookAddressChooser(
|
||||
coin: SupportedCoins
|
||||
coin: Coins
|
||||
.cryptocurrencies
|
||||
.firstWhere(
|
||||
(e) =>
|
||||
|
|
|
@ -70,7 +70,7 @@ class _CryptoSelectionViewState extends ConsumerState<CryptoSelectionView> {
|
|||
coins.sort(
|
||||
(a, b) => a.ticker.toLowerCase().compareTo(b.ticker.toLowerCase()),
|
||||
);
|
||||
for (final coin in SupportedCoins.cryptocurrencies.reversed) {
|
||||
for (final coin in Coins.cryptocurrencies.reversed) {
|
||||
final index = coins.indexWhere(
|
||||
(element) => element.ticker.toLowerCase() == coin.ticker.toLowerCase(),
|
||||
);
|
||||
|
@ -270,7 +270,7 @@ bool isStackCoin(String? ticker) {
|
|||
if (ticker == null) return false;
|
||||
|
||||
try {
|
||||
SupportedCoins.getCryptoCurrencyForTicker(ticker);
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
@ -305,7 +305,7 @@ class CoinIconForTicker extends ConsumerWidget {
|
|||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
try {
|
||||
final coin = SupportedCoins.getCryptoCurrencyForTicker(ticker);
|
||||
final coin = Coins.getCryptoCurrencyForTicker(ticker);
|
||||
return SvgPicture.file(
|
||||
File(
|
||||
ref.watch(coinIconProvider(coin)),
|
||||
|
|
|
@ -365,7 +365,7 @@ class _ExchangeCurrencySelectionViewState
|
|||
Flexible(
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
final coins = SupportedCoins.cryptocurrencies.where(
|
||||
final coins = Coins.cryptocurrencies.where(
|
||||
(e) =>
|
||||
e.ticker.toLowerCase() !=
|
||||
widget.pairedTicker?.toLowerCase(),
|
||||
|
|
|
@ -72,7 +72,7 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
|
||||
bool isStackCoin(String ticker) {
|
||||
try {
|
||||
SupportedCoins.getCryptoCurrencyForTicker(ticker);
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
@ -207,8 +207,7 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
text: "Choose from Stack",
|
||||
onTap: () {
|
||||
try {
|
||||
final coin = SupportedCoins
|
||||
.cryptocurrencies
|
||||
final coin = Coins.cryptocurrencies
|
||||
.firstWhere((e) =>
|
||||
e.ticker.toLowerCase() ==
|
||||
model.receiveTicker
|
||||
|
@ -483,8 +482,7 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
text: "Choose from Stack",
|
||||
onTap: () {
|
||||
try {
|
||||
final coin = SupportedCoins
|
||||
.cryptocurrencies
|
||||
final coin = Coins.cryptocurrencies
|
||||
.firstWhere((e) =>
|
||||
e.ticker.toLowerCase() ==
|
||||
model.sendTicker.toLowerCase());
|
||||
|
|
|
@ -75,7 +75,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
|
||||
bool _isWalletCoinAndHasWallet(String ticker, WidgetRef ref) {
|
||||
try {
|
||||
final coin = SupportedCoins.getCryptoCurrencyForTicker(ticker);
|
||||
final coin = Coins.getCryptoCurrencyForTicker(ticker);
|
||||
return ref
|
||||
.read(pWallets)
|
||||
.wallets
|
||||
|
@ -853,7 +853,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
.useMaterialPageRoute,
|
||||
builder:
|
||||
(BuildContext context) {
|
||||
final coin = SupportedCoins
|
||||
final coin = Coins
|
||||
.cryptocurrencies
|
||||
.firstWhere(
|
||||
(e) =>
|
||||
|
|
|
@ -94,7 +94,7 @@ class _ExchangeOptionState extends ConsumerState<ExchangeOption> {
|
|||
|
||||
int decimals;
|
||||
try {
|
||||
decimals = SupportedCoins.getCryptoCurrencyForTicker(
|
||||
decimals = Coins.getCryptoCurrencyForTicker(
|
||||
receivingCurrency.ticker,
|
||||
).fractionDigits;
|
||||
} catch (_) {
|
||||
|
@ -113,7 +113,7 @@ class _ExchangeOptionState extends ConsumerState<ExchangeOption> {
|
|||
|
||||
CryptoCurrency? coin;
|
||||
try {
|
||||
coin = SupportedCoins.getCryptoCurrencyForTicker(
|
||||
coin = Coins.getCryptoCurrencyForTicker(
|
||||
receivingCurrency.ticker,
|
||||
);
|
||||
} catch (_) {
|
||||
|
|
|
@ -88,9 +88,9 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
bool isStackCoin(String ticker) {
|
||||
try {
|
||||
try {
|
||||
SupportedCoins.getCryptoCurrencyForTicker(ticker);
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
} catch (_) {}
|
||||
SupportedCoins.getCryptoCurrencyByPrettyName(ticker);
|
||||
Coins.getCryptoCurrencyByPrettyName(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
@ -279,11 +279,11 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
onPressed: () {
|
||||
CryptoCurrency coin;
|
||||
try {
|
||||
coin = SupportedCoins.getCryptoCurrencyForTicker(
|
||||
coin = Coins.getCryptoCurrencyForTicker(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
} catch (_) {
|
||||
coin = SupportedCoins.getCryptoCurrencyByPrettyName(
|
||||
coin = Coins.getCryptoCurrencyByPrettyName(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
}
|
||||
|
@ -379,8 +379,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
builder: (context) {
|
||||
String text;
|
||||
try {
|
||||
final coin =
|
||||
SupportedCoins.getCryptoCurrencyForTicker(
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
final amount = sendAmount.toAmount(
|
||||
|
@ -629,7 +628,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
text: "View transaction",
|
||||
onTap: () {
|
||||
final CryptoCurrency coin =
|
||||
SupportedCoins.getCryptoCurrencyForTicker(
|
||||
Coins.getCryptoCurrencyForTicker(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
|
||||
|
@ -1382,11 +1381,11 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
onPressed: () {
|
||||
CryptoCurrency coin;
|
||||
try {
|
||||
coin = SupportedCoins.getCryptoCurrencyForTicker(
|
||||
coin = Coins.getCryptoCurrencyForTicker(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
} catch (_) {
|
||||
coin = SupportedCoins.getCryptoCurrencyByPrettyName(
|
||||
coin = Coins.getCryptoCurrencyByPrettyName(
|
||||
trade.payInCurrency,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class ManageCoinUnitsView extends ConsumerWidget {
|
|||
prefsChangeNotifierProvider.select((value) => value.showTestNetCoins),
|
||||
);
|
||||
|
||||
final _coins = SupportedCoins.cryptocurrencies
|
||||
final _coins = Coins.cryptocurrencies
|
||||
.where((e) => e is! Firo && e.network != CryptoCurrencyNetwork.test)
|
||||
.toList();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class ManageNodesView extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _ManageNodesViewState extends ConsumerState<ManageNodesView> {
|
||||
List<CryptoCurrency> _coins = [...SupportedCoins.cryptocurrencies];
|
||||
List<CryptoCurrency> _coins = [...Coins.cryptocurrencies];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
|
@ -774,7 +774,7 @@ abstract class SWB {
|
|||
return false;
|
||||
}
|
||||
|
||||
final coin = SupportedCoins.getCryptoCurrencyFor(
|
||||
final coin = Coins.getCryptoCurrencyFor(
|
||||
walletbackup['coinName'] as String,
|
||||
);
|
||||
|
||||
|
@ -1036,7 +1036,7 @@ abstract class SWB {
|
|||
for (final node in primaryNodes) {
|
||||
try {
|
||||
await nodeService.setPrimaryNodeFor(
|
||||
coin: SupportedCoins.getCryptoCurrencyByPrettyName(
|
||||
coin: Coins.getCryptoCurrencyByPrettyName(
|
||||
node['coinName'] as String,
|
||||
),
|
||||
node: nodeService.getNodeById(id: node['id'] as String)!,
|
||||
|
@ -1226,7 +1226,7 @@ abstract class SWB {
|
|||
for (final node in primaryNodes) {
|
||||
try {
|
||||
await nodeService.setPrimaryNodeFor(
|
||||
coin: SupportedCoins.getCryptoCurrencyByPrettyName(
|
||||
coin: Coins.getCryptoCurrencyByPrettyName(
|
||||
node['coinName'] as String,
|
||||
),
|
||||
node: nodeService.getNodeById(id: node['id'] as String)!,
|
||||
|
|
|
@ -99,7 +99,7 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
|
|||
ref.refresh(addressBookFilterProvider);
|
||||
|
||||
// if (widget.coin == null) {
|
||||
final coins = SupportedCoins.cryptocurrencies.toList();
|
||||
final coins = Coins.cryptocurrencies.toList();
|
||||
coins.removeWhere(
|
||||
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test,
|
||||
);
|
||||
|
|
|
@ -194,7 +194,7 @@ class _StepScaffoldState extends ConsumerState<StepScaffold> {
|
|||
void sendFromStack() {
|
||||
final trade = ref.read(desktopExchangeModelProvider)!.trade!;
|
||||
final address = trade.payInAddress;
|
||||
final coin = SupportedCoins.getCryptoCurrencyForTicker(trade.payInCurrency);
|
||||
final coin = Coins.getCryptoCurrencyForTicker(trade.payInCurrency);
|
||||
final amount = Decimal.parse(trade.payInAmount).toAmount(
|
||||
fractionDigits: coin.fractionDigits,
|
||||
);
|
||||
|
|
|
@ -59,7 +59,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
|
|||
|
||||
bool isStackCoin(String ticker) {
|
||||
try {
|
||||
SupportedCoins.getCryptoCurrencyForTicker(ticker);
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
@ -68,7 +68,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
|
|||
|
||||
void selectRecipientAddressFromStack() async {
|
||||
try {
|
||||
final coin = SupportedCoins.getCryptoCurrencyForTicker(
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
ref.read(desktopExchangeModelProvider)!.receiveTicker,
|
||||
);
|
||||
|
||||
|
@ -101,7 +101,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
|
|||
|
||||
void selectRefundAddressFromStack() async {
|
||||
try {
|
||||
final coin = SupportedCoins.getCryptoCurrencyForTicker(
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
ref.read(desktopExchangeModelProvider)!.sendTicker,
|
||||
);
|
||||
|
||||
|
@ -131,7 +131,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
|
|||
}
|
||||
|
||||
void selectRecipientFromAddressBook() async {
|
||||
final coin = SupportedCoins.getCryptoCurrencyForTicker(
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
ref.read(desktopExchangeModelProvider)!.receiveTicker,
|
||||
);
|
||||
|
||||
|
@ -178,7 +178,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
|
|||
}
|
||||
|
||||
void selectRefundFromAddressBook() async {
|
||||
final coin = SupportedCoins.getCryptoCurrencyForTicker(
|
||||
final coin = Coins.getCryptoCurrencyForTicker(
|
||||
ref.read(desktopExchangeModelProvider)!.sendTicker,
|
||||
);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class _DesktopStep4State extends ConsumerState<DesktopStep4> {
|
|||
|
||||
bool _isWalletCoinAndHasWallet(String ticker) {
|
||||
try {
|
||||
final coin = SupportedCoins.getCryptoCurrencyForTicker(ticker);
|
||||
final coin = Coins.getCryptoCurrencyForTicker(ticker);
|
||||
return ref
|
||||
.read(pWallets)
|
||||
.wallets
|
||||
|
|
|
@ -40,8 +40,8 @@ class DesktopManageBlockExplorersDialog extends ConsumerWidget {
|
|||
);
|
||||
|
||||
final coins = showTestNet
|
||||
? SupportedCoins.cryptocurrencies
|
||||
: SupportedCoins.cryptocurrencies
|
||||
? Coins.cryptocurrencies
|
||||
: Coins.cryptocurrencies
|
||||
.where(
|
||||
(e) => e.network == CryptoCurrencyNetwork.main,
|
||||
)
|
||||
|
|
|
@ -42,7 +42,7 @@ class NodesSettings extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _NodesSettings extends ConsumerState<NodesSettings> {
|
||||
List<CryptoCurrency> _coins = [...SupportedCoins.cryptocurrencies];
|
||||
List<CryptoCurrency> _coins = [...Coins.cryptocurrencies];
|
||||
|
||||
late final TextEditingController searchNodeController;
|
||||
late final FocusNode searchNodeFocusNode;
|
||||
|
|
|
@ -405,7 +405,7 @@ bool isStackCoin(String? ticker) {
|
|||
if (ticker == null) return false;
|
||||
|
||||
try {
|
||||
SupportedCoins.getCryptoCurrencyForTicker(ticker);
|
||||
Coins.getCryptoCurrencyForTicker(ticker);
|
||||
return true;
|
||||
} on ArgumentError catch (_) {
|
||||
return false;
|
||||
|
|
|
@ -31,7 +31,7 @@ class NodeService extends ChangeNotifier {
|
|||
});
|
||||
|
||||
Future<void> updateDefaults() async {
|
||||
for (final defaultNode in SupportedCoins.cryptocurrencies.map(
|
||||
for (final defaultNode in Coins.cryptocurrencies.map(
|
||||
(e) => e.defaultNode,
|
||||
)) {
|
||||
final savedNode = DB.instance
|
||||
|
@ -39,7 +39,7 @@ class NodeService extends ChangeNotifier {
|
|||
if (savedNode == null) {
|
||||
// save the default node to hive only if no other nodes for the specific coin exist
|
||||
if (getNodesFor(
|
||||
SupportedCoins.getCryptoCurrencyByPrettyName(
|
||||
Coins.getCryptoCurrencyByPrettyName(
|
||||
defaultNode.coinName,
|
||||
),
|
||||
).isEmpty) {
|
||||
|
@ -64,8 +64,7 @@ class NodeService extends ChangeNotifier {
|
|||
|
||||
// check if a default node is the primary node for the crypto currency
|
||||
// and update it if needed
|
||||
final coin =
|
||||
SupportedCoins.getCryptoCurrencyByPrettyName(defaultNode.coinName);
|
||||
final coin = Coins.getCryptoCurrencyByPrettyName(defaultNode.coinName);
|
||||
final primaryNode = getPrimaryNodeFor(currency: coin);
|
||||
if (primaryNode != null && primaryNode.id == defaultNode.id) {
|
||||
await setPrimaryNodeFor(
|
||||
|
@ -206,8 +205,7 @@ class NodeService extends ChangeNotifier {
|
|||
bool shouldNotifyListeners,
|
||||
) async {
|
||||
// check if the node being edited is the primary one; if it is, setPrimaryNodeFor coin
|
||||
final coin =
|
||||
SupportedCoins.getCryptoCurrencyByPrettyName(editedNode.coinName);
|
||||
final coin = Coins.getCryptoCurrencyByPrettyName(editedNode.coinName);
|
||||
final primaryNode = getPrimaryNodeFor(currency: coin);
|
||||
if (primaryNode?.id == editedNode.id) {
|
||||
await setPrimaryNodeFor(
|
||||
|
@ -240,7 +238,7 @@ class NodeService extends ChangeNotifier {
|
|||
final map = jsonDecode(result as String);
|
||||
Logging.instance.log(map, level: LogLevel.Info);
|
||||
|
||||
for (final coin in SupportedCoins.cryptocurrencies) {
|
||||
for (final coin in Coins.cryptocurrencies) {
|
||||
final nodeList = List<Map<String, dynamic>>.from(
|
||||
map["nodes"][coin.identifier] as List? ?? [],
|
||||
);
|
||||
|
|
|
@ -129,7 +129,7 @@ class NotificationsService extends ChangeNotifier {
|
|||
for (final notification in _watchedTransactionNotifications) {
|
||||
try {
|
||||
final CryptoCurrency coin =
|
||||
SupportedCoins.getCryptoCurrencyByPrettyName(notification.coinName);
|
||||
Coins.getCryptoCurrencyByPrettyName(notification.coinName);
|
||||
final txid = notification.txid!;
|
||||
final wallet = Wallets.sharedInstance.getWallet(notification.walletId);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class PriceAPI {
|
|||
) async {
|
||||
final Map<String, dynamic> map = {};
|
||||
|
||||
for (final coin in SupportedCoins.cryptocurrencies) {
|
||||
for (final coin in Coins.cryptocurrencies) {
|
||||
final entry = data[coin];
|
||||
if (entry == null) {
|
||||
map[coin.prettyName] = ["0", 0.0];
|
||||
|
@ -68,12 +68,12 @@ class PriceAPI {
|
|||
{};
|
||||
// init with 0
|
||||
final result = {
|
||||
for (final coin in SupportedCoins.cryptocurrencies)
|
||||
for (final coin in Coins.cryptocurrencies)
|
||||
coin: Tuple2(Decimal.zero, 0.0),
|
||||
};
|
||||
|
||||
for (final entry in map.entries) {
|
||||
result[SupportedCoins.getCryptoCurrencyByPrettyName(
|
||||
result[Coins.getCryptoCurrencyByPrettyName(
|
||||
entry.key as String,
|
||||
)] = Tuple2(
|
||||
Decimal.parse(entry.value[0] as String),
|
||||
|
@ -126,7 +126,7 @@ class PriceAPI {
|
|||
|
||||
for (final map in coinGeckoData) {
|
||||
final String coinName = map["name"] as String;
|
||||
final coin = SupportedCoins.getCryptoCurrencyByPrettyName(coinName);
|
||||
final coin = Coins.getCryptoCurrencyByPrettyName(coinName);
|
||||
|
||||
final price = Decimal.parse(map["current_price"].toString());
|
||||
final change24h = map["price_change_percentage_24h"] != null
|
||||
|
|
|
@ -30,8 +30,7 @@ class PriceService extends ChangeNotifier {
|
|||
|
||||
Timer? _timer;
|
||||
final Map<CryptoCurrency, Tuple2<Decimal, double>> _cachedPrices = {
|
||||
for (final coin in SupportedCoins.cryptocurrencies)
|
||||
coin: Tuple2(Decimal.zero, 0.0)
|
||||
for (final coin in Coins.cryptocurrencies) coin: Tuple2(Decimal.zero, 0.0)
|
||||
};
|
||||
|
||||
final Map<String, Tuple2<Decimal, double>> _cachedTokenPrices = {};
|
||||
|
|
|
@ -90,7 +90,7 @@ class WalletsService extends ChangeNotifier {
|
|||
mapped.removeWhere((name, dyn) {
|
||||
final jsonObject = Map<String, dynamic>.from(dyn as Map);
|
||||
try {
|
||||
SupportedCoins.getCryptoCurrencyFor(jsonObject["coin"] as String);
|
||||
Coins.getCryptoCurrencyFor(jsonObject["coin"] as String);
|
||||
return false;
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
|
|
|
@ -21,7 +21,7 @@ import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
|||
import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart';
|
||||
|
||||
/// The supported coins. Eventually move away from the Coin enum
|
||||
class SupportedCoins {
|
||||
class Coins {
|
||||
/// A List of our supported coins.
|
||||
static final List<CryptoCurrency> cryptocurrencies = [
|
||||
Bitcoin(CryptoCurrencyNetwork.main),
|
||||
|
|
|
@ -867,7 +867,7 @@ class Prefs extends ChangeNotifier {
|
|||
}
|
||||
|
||||
Future<void> _setAmountUnits() async {
|
||||
for (final coin in SupportedCoins.cryptocurrencies) {
|
||||
for (final coin in Coins.cryptocurrencies) {
|
||||
final unitIndex = await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "amountUnitFor${coin.identifier}",
|
||||
|
@ -900,7 +900,7 @@ class Prefs extends ChangeNotifier {
|
|||
}
|
||||
|
||||
Future<void> _setMaxDecimals() async {
|
||||
for (final coin in SupportedCoins.cryptocurrencies) {
|
||||
for (final coin in Coins.cryptocurrencies) {
|
||||
final decimals = await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "maxDecimalsFor${coin.identifier}",
|
||||
|
|
|
@ -96,7 +96,7 @@ class WalletInfo implements IsarId {
|
|||
}
|
||||
|
||||
@ignore
|
||||
CryptoCurrency get coin => SupportedCoins.getCryptoCurrencyFor(coinName);
|
||||
CryptoCurrency get coin => Coins.getCryptoCurrencyFor(coinName);
|
||||
|
||||
@ignore
|
||||
Balance get cachedBalance {
|
||||
|
@ -407,7 +407,7 @@ class WalletInfo implements IsarId {
|
|||
this.cachedBalanceTertiaryString,
|
||||
this.otherDataJsonString,
|
||||
}) : assert(
|
||||
SupportedCoins.cryptocurrencies
|
||||
Coins.cryptocurrencies
|
||||
.map((e) => e.identifier)
|
||||
.contains(coinName),
|
||||
);
|
||||
|
@ -466,7 +466,7 @@ class WalletInfo implements IsarId {
|
|||
Map<String, dynamic> jsonObject,
|
||||
AddressType mainAddressType,
|
||||
) {
|
||||
final coin = SupportedCoins.getCryptoCurrencyFor(
|
||||
final coin = Coins.getCryptoCurrencyFor(
|
||||
jsonObject["coin"] as String,
|
||||
);
|
||||
return WalletInfo(
|
||||
|
|
|
@ -27,7 +27,7 @@ final pAllWalletsInfoByCoin = Provider((ref) {
|
|||
}
|
||||
|
||||
final List<({CryptoCurrency coin, List<WalletInfo> wallets})> results = [];
|
||||
for (final coin in SupportedCoins.cryptocurrencies) {
|
||||
for (final coin in Coins.cryptocurrencies) {
|
||||
if (map[coin] != null) {
|
||||
results.add(map[coin]!);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ class _AddressBookCardState extends ConsumerState<AddressBookCard> {
|
|||
|
||||
final List<CryptoCurrency> coins = [];
|
||||
|
||||
for (final coin in SupportedCoins.cryptocurrencies) {
|
||||
for (final coin in Coins.cryptocurrencies) {
|
||||
if (contact.addresses.where((e) => e.coin == coin).isNotEmpty) {
|
||||
coins.add(coin);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ class ChooseCoinView extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _ChooseCoinViewState extends ConsumerState<ChooseCoinView> {
|
||||
List<CryptoCurrency> _coins = [...SupportedCoins.cryptocurrencies];
|
||||
List<CryptoCurrency> _coins = [...Coins.cryptocurrencies];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
|
@ -114,7 +114,7 @@ void main() {
|
|||
await service.updateDefaults();
|
||||
expect(
|
||||
service.nodes.length,
|
||||
SupportedCoins.cryptocurrencies.map((e) => e.defaultNode).length,
|
||||
Coins.cryptocurrencies.map((e) => e.defaultNode).length,
|
||||
);
|
||||
expect(fakeStore.interactions, 0);
|
||||
});
|
||||
|
@ -208,7 +208,7 @@ void main() {
|
|||
final service = NodeService(secureStorageInterface: fakeStore);
|
||||
final nodes = service.nodes;
|
||||
final defaults =
|
||||
SupportedCoins.cryptocurrencies.map((e) => e.defaultNode).toList();
|
||||
Coins.cryptocurrencies.map((e) => e.defaultNode).toList();
|
||||
|
||||
nodes.sort((a, b) => a.host.compareTo(b.host));
|
||||
defaults.sort((a, b) => a.host.compareTo(b.host));
|
||||
|
@ -224,7 +224,7 @@ void main() {
|
|||
await service.add(nodeA, null, true);
|
||||
expect(
|
||||
service.nodes.length,
|
||||
SupportedCoins.cryptocurrencies.map((e) => e.defaultNode).length + 1,
|
||||
Coins.cryptocurrencies.map((e) => e.defaultNode).length + 1,
|
||||
);
|
||||
expect(fakeStore.interactions, 0);
|
||||
});
|
||||
|
@ -235,7 +235,7 @@ void main() {
|
|||
await service.add(nodeA, "some password", true);
|
||||
expect(
|
||||
service.nodes.length,
|
||||
SupportedCoins.cryptocurrencies.map((e) => e.defaultNode).length + 1,
|
||||
Coins.cryptocurrencies.map((e) => e.defaultNode).length + 1,
|
||||
);
|
||||
expect(fakeStore.interactions, 1);
|
||||
expect(fakeStore.writes, 1);
|
||||
|
@ -293,7 +293,7 @@ void main() {
|
|||
|
||||
expect(
|
||||
service.nodes.length,
|
||||
SupportedCoins.cryptocurrencies.map((e) => e.defaultNode).length + 2,
|
||||
Coins.cryptocurrencies.map((e) => e.defaultNode).length + 2,
|
||||
);
|
||||
expect(
|
||||
service.nodes.where((element) => element.id == nodeB.id).length,
|
||||
|
|
Loading…
Reference in a new issue