2021-01-27 13:51:51 +00:00
|
|
|
import 'package:cake_wallet/entities/transaction_priority.dart';
|
2021-02-01 18:12:37 +00:00
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2021-01-27 13:51:51 +00:00
|
|
|
|
|
|
|
class BitcoinTransactionPriority extends TransactionPriority {
|
2021-02-12 22:38:34 +00:00
|
|
|
const BitcoinTransactionPriority({String title, int raw})
|
2021-01-27 13:51:51 +00:00
|
|
|
: super(title: title, raw: raw);
|
|
|
|
|
2021-02-12 22:38:34 +00:00
|
|
|
static const List<BitcoinTransactionPriority> all = [fast, medium, slow];
|
2021-02-01 18:12:37 +00:00
|
|
|
static const BitcoinTransactionPriority slow =
|
2021-02-12 22:38:34 +00:00
|
|
|
BitcoinTransactionPriority(title: 'Slow', raw: 0);
|
2021-02-01 18:12:37 +00:00
|
|
|
static const BitcoinTransactionPriority medium =
|
2021-02-12 22:38:34 +00:00
|
|
|
BitcoinTransactionPriority(title: 'Medium', raw: 1);
|
2021-02-01 18:12:37 +00:00
|
|
|
static const BitcoinTransactionPriority fast =
|
2021-02-12 22:38:34 +00:00
|
|
|
BitcoinTransactionPriority(title: 'Fast', raw: 2);
|
2021-01-27 13:51:51 +00:00
|
|
|
|
|
|
|
static BitcoinTransactionPriority deserialize({int raw}) {
|
|
|
|
switch (raw) {
|
|
|
|
case 0:
|
|
|
|
return slow;
|
2021-02-12 22:38:34 +00:00
|
|
|
case 1:
|
2021-01-27 13:51:51 +00:00
|
|
|
return medium;
|
2021-02-12 22:38:34 +00:00
|
|
|
case 2:
|
2021-01-27 13:51:51 +00:00
|
|
|
return fast;
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-11 13:52:48 +00:00
|
|
|
String get units => 'sat';
|
|
|
|
|
2021-01-27 13:51:51 +00:00
|
|
|
@override
|
2021-02-01 18:12:37 +00:00
|
|
|
String toString() {
|
|
|
|
var label = '';
|
|
|
|
|
|
|
|
switch (this) {
|
|
|
|
case BitcoinTransactionPriority.slow:
|
2021-04-21 08:59:13 +00:00
|
|
|
label = '${S.current.transaction_priority_slow} ~24hrs';
|
2021-02-01 18:12:37 +00:00
|
|
|
break;
|
|
|
|
case BitcoinTransactionPriority.medium:
|
|
|
|
label = S.current.transaction_priority_medium;
|
|
|
|
break;
|
|
|
|
case BitcoinTransactionPriority.fast:
|
|
|
|
label = S.current.transaction_priority_fast;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-02-12 22:38:34 +00:00
|
|
|
return label;
|
2021-02-01 18:12:37 +00:00
|
|
|
}
|
2021-05-11 13:52:48 +00:00
|
|
|
|
|
|
|
String labelWithRate(int rate) => '${toString()} ($rate ${units}/byte)';
|
|
|
|
}
|
|
|
|
|
|
|
|
class LitecoinTransactionPriority extends BitcoinTransactionPriority {
|
|
|
|
const LitecoinTransactionPriority({String title, int raw})
|
|
|
|
: super(title: title, raw: raw);
|
|
|
|
|
|
|
|
static const List<LitecoinTransactionPriority> all = [fast, medium, slow];
|
|
|
|
static const LitecoinTransactionPriority slow =
|
|
|
|
LitecoinTransactionPriority(title: 'Slow', raw: 0);
|
|
|
|
static const LitecoinTransactionPriority medium =
|
|
|
|
LitecoinTransactionPriority(title: 'Medium', raw: 1);
|
|
|
|
static const LitecoinTransactionPriority fast =
|
|
|
|
LitecoinTransactionPriority(title: 'Fast', raw: 2);
|
|
|
|
|
|
|
|
static LitecoinTransactionPriority deserialize({int raw}) {
|
|
|
|
switch (raw) {
|
|
|
|
case 0:
|
|
|
|
return slow;
|
|
|
|
case 1:
|
|
|
|
return medium;
|
|
|
|
case 2:
|
|
|
|
return fast;
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String get units => 'Latoshi';
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
var label = '';
|
|
|
|
|
|
|
|
switch (this) {
|
|
|
|
case LitecoinTransactionPriority.slow:
|
|
|
|
label = S.current.transaction_priority_slow;
|
|
|
|
break;
|
|
|
|
case LitecoinTransactionPriority.medium:
|
|
|
|
label = S.current.transaction_priority_medium;
|
|
|
|
break;
|
|
|
|
case LitecoinTransactionPriority.fast:
|
|
|
|
label = S.current.transaction_priority_fast;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return label;
|
|
|
|
}
|
2021-01-27 13:51:51 +00:00
|
|
|
}
|