take into account tickers and coin names as possible pay in currencies

This commit is contained in:
julian 2023-12-10 13:13:55 -06:00
parent 0ce0b1d30e
commit 1387a71f4a

View file

@ -87,8 +87,11 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
String _note = ""; String _note = "";
bool isStackCoin(String ticker) { bool isStackCoin(String ticker) {
try {
try { try {
coinFromTickerCaseInsensitive(ticker); coinFromTickerCaseInsensitive(ticker);
} catch (_) {}
coinFromPrettyName(ticker);
return true; return true;
} on ArgumentError catch (_) { } on ArgumentError catch (_) {
return false; return false;
@ -272,8 +275,13 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
label: "Send from Stack", label: "Send from Stack",
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.l,
onPressed: () { onPressed: () {
final coin = Coin coin;
coinFromTickerCaseInsensitive(trade.payInCurrency); try {
coin = coinFromTickerCaseInsensitive(
trade.payInCurrency);
} catch (_) {
coin = coinFromPrettyName(trade.payInCurrency);
}
final amount = Amount.fromDecimal( final amount = Amount.fromDecimal(
sendAmount, sendAmount,
fractionDigits: coin.decimals, fractionDigits: coin.decimals,
@ -1349,8 +1357,12 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
SecondaryButton( SecondaryButton(
label: "Send from Stack", label: "Send from Stack",
onPressed: () { onPressed: () {
final coin = Coin coin;
coinFromTickerCaseInsensitive(trade.payInCurrency); try {
coin = coinFromTickerCaseInsensitive(trade.payInCurrency);
} catch (_) {
coin = coinFromPrettyName(trade.payInCurrency);
}
final amount = Amount.fromDecimal( final amount = Amount.fromDecimal(
sendAmount, sendAmount,
fractionDigits: coin.decimals, fractionDigits: coin.decimals,