Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/bloc/coins_bloc/asset_coin_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ extension CoinTypeExtension on CoinSubClass {
return CoinType.avx20;
case CoinSubClass.smartChain:
return CoinType.smartChain;
case CoinSubClass.sia:
return CoinType.sia;
case CoinSubClass.moonriver:
return CoinType.mvr20;
case CoinSubClass.ethereumClassic:
Expand Down Expand Up @@ -155,6 +157,8 @@ extension CoinSubClassExtension on CoinType {
return CoinSubClass.avx20;
case CoinType.smartChain:
return CoinSubClass.smartChain;
case CoinType.sia:
return CoinSubClass.sia;
case CoinType.mvr20:
return CoinSubClass.moonriver;
case CoinType.etc:
Expand Down
1 change: 1 addition & 0 deletions lib/bloc/fiat/models/i_currency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class CryptoCurrency extends ICurrency {
// "ETH-ERC20", which is not how it is stored in our coins configuration
// files. "ETH" is the expected abbreviation, which would just be `symbol`.
if (chainType == CoinType.utxo ||
chainType == CoinType.sia ||
(chainType == CoinType.tendermint && symbol == 'ATOM') ||
(chainType == CoinType.erc20 && symbol == 'ETH') ||
(chainType == CoinType.bep20 && symbol == 'BNB') ||
Expand Down
1 change: 1 addition & 0 deletions lib/model/coin_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
enum CoinType {
utxo,
smartChain,
sia,
etc,
erc20,
bep20,
Expand Down
6 changes: 6 additions & 0 deletions lib/model/coin_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ bool compareCoinByPhrase(Coin coin, String phrase) {
}

String getCoinTypeName(CoinType type, [String? symbol]) {
if (type == CoinType.sia) {
return 'SIA';
}
// Override for parent chain coins like ETH, AVAX etc.
if (symbol != null && isParentCoin(type, symbol)) {
return 'Native';
Expand All @@ -143,6 +146,8 @@ String getCoinTypeName(CoinType type, [String? symbol]) {
return 'Native';
case CoinType.smartChain:
return 'Smart Chain';
case CoinType.sia:
return 'SIA';
case CoinType.ftm20:
return 'FTM-20';
case CoinType.arb20:
Expand Down Expand Up @@ -181,6 +186,7 @@ String getCoinTypeName(CoinType type, [String? symbol]) {
bool isParentCoin(CoinType type, String symbol) {
switch (type) {
case CoinType.utxo:
case CoinType.sia:
case CoinType.tendermint:
return true;
case CoinType.erc20:
Expand Down
53 changes: 26 additions & 27 deletions lib/shared/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Future<void> copyToClipBoard(
await Clipboard.setData(ClipboardData(text: payload));

if (!context.mounted) return;
final scaffoldMessenger = ScaffoldMessenger.maybeOf(context) ??
final scaffoldMessenger =
ScaffoldMessenger.maybeOf(context) ??
ScaffoldMessenger.of(scaffoldKey.currentContext!);
scaffoldMessenger.showSnackBar(
SnackBar(
Expand All @@ -57,9 +58,7 @@ Future<void> copyToClipBoard(
color: themeData.colorScheme.onPrimaryContainer,
),
const SizedBox(width: 12.0),
Text(
message ?? LocaleKeys.clipBoard.tr(),
),
Text(message ?? LocaleKeys.clipBoard.tr()),
],
),
duration: const Duration(seconds: 2),
Expand Down Expand Up @@ -141,10 +140,7 @@ Rational? fract2rat(Map<String, dynamic>? fract, [bool willLog = true]) {
try {
final String numerStr = fract['numer'].toString();
final String denomStr = fract['denom'].toString();
final rat = Rational(
BigInt.parse(numerStr),
BigInt.parse(denomStr),
);
final rat = Rational(BigInt.parse(numerStr), BigInt.parse(denomStr));
return rat;
} catch (e) {
if (willLog) {
Expand Down Expand Up @@ -198,8 +194,8 @@ String getTxExplorerUrl(Coin coin, String txHash) {

final hash =
coin.type == CoinType.tendermint || coin.type == CoinType.tendermintToken
? txHash.toUpperCase()
: txHash;
? txHash.toUpperCase()
: txHash;

return coin.need0xPrefixForTxHash && !hash.startsWith('0x')
? '$explorerUrl${explorerTxUrl}0x$hash'
Expand Down Expand Up @@ -247,8 +243,8 @@ Future<void> openUrl(Uri uri, {bool? inSeparateTab}) async {
mode: inSeparateTab == null
? LaunchMode.platformDefault
: inSeparateTab == true
? LaunchMode.externalApplication
: LaunchMode.inAppWebView,
? LaunchMode.externalApplication
: LaunchMode.inAppWebView,
);
}

Expand All @@ -261,8 +257,8 @@ Future<void> launchURLString(String url, {bool? inSeparateTab}) async {
mode: inSeparateTab == null
? LaunchMode.platformDefault
: inSeparateTab == true
? LaunchMode.externalApplication
: LaunchMode.inAppWebView,
? LaunchMode.externalApplication
: LaunchMode.inAppWebView,
);
} else {
throw 'Could not launch $url';
Expand Down Expand Up @@ -400,6 +396,8 @@ Color getProtocolColor(CoinType type) {
return const Color.fromRGBO(108, 147, 237, 1);
case CoinType.smartChain:
return const Color.fromRGBO(32, 22, 49, 1);
case CoinType.sia:
return const Color(0xFF29F06F);
case CoinType.bep20:
return const Color.fromRGBO(255, 199, 0, 1);
case CoinType.qrc20:
Expand Down Expand Up @@ -447,6 +445,7 @@ bool hasTxHistorySupport(Coin coin) {
case CoinType.tendermint:
case CoinType.tendermintToken:
case CoinType.utxo:
case CoinType.sia:
case CoinType.erc20:
case CoinType.smartChain:
case CoinType.bep20:
Expand Down Expand Up @@ -481,6 +480,7 @@ String getNativeExplorerUrlByCoin(Coin coin, String? address) {
case CoinType.utxo:
case CoinType.smartChain:
case CoinType.erc20:
case CoinType.sia:
case CoinType.bep20:
case CoinType.qrc20:
case CoinType.ftm20:
Expand Down Expand Up @@ -571,10 +571,7 @@ Future<void> pauseWhile(
}
}

enum HashExplorerType {
address,
tx,
}
enum HashExplorerType { address, tx }

Future<bool> confirmParentCoinDisable(
BuildContext context, {
Expand Down Expand Up @@ -615,8 +612,9 @@ Future<bool> confirmCoinDisableWithOrders(
builder: (context) => AlertDialog(
title: Text(LocaleKeys.disable.tr()),
content: Text(
LocaleKeys.coinDisableOpenOrdersWarning
.tr(args: [ordersCount.toString(), coin]),
LocaleKeys.coinDisableOpenOrdersWarning.tr(
args: [ordersCount.toString(), coin],
),
),
actions: [
TextButton(
Expand All @@ -638,27 +636,28 @@ void confirmBeforeDisablingCoin(
BuildContext context, {
void Function()? onConfirm,
}) {
final tradingEntitiesBloc =
RepositoryProvider.of<TradingEntitiesBloc>(context);
final tradingEntitiesBloc = RepositoryProvider.of<TradingEntitiesBloc>(
context,
);
final bloc = context.read<CoinsBloc>();

final childCoins = bloc.state.walletCoins.values
.where((c) => c.parentCoin?.abbr == coin.abbr)
.toList();

final hasSwap = tradingEntitiesBloc.hasActiveSwap(coin.abbr) ||
final hasSwap =
tradingEntitiesBloc.hasActiveSwap(coin.abbr) ||
childCoins.any((c) => tradingEntitiesBloc.hasActiveSwap(c.abbr));

if (hasSwap) {
InformationPopup(
context: context,
)
InformationPopup(context: context)
..text = LocaleKeys.coinDisableSpan1.tr(args: [coin.abbr])
..show();
return;
}

final int openOrders = tradingEntitiesBloc.openOrdersCount(coin.abbr) +
final int openOrders =
tradingEntitiesBloc.openOrdersCount(coin.abbr) +
childCoins.fold<int>(
0,
(sum, c) => sum + tradingEntitiesBloc.openOrdersCount(c.abbr),
Expand Down
Loading