2023-01-11 02:57:59 +00:00
|
|
|
import 'package:cw_core/transaction_priority.dart';
|
|
|
|
|
|
|
|
class EthereumTransactionPriority extends TransactionPriority {
|
2023-01-12 13:53:20 +00:00
|
|
|
final int tip;
|
2023-01-11 02:57:59 +00:00
|
|
|
|
2023-01-12 13:53:20 +00:00
|
|
|
const EthereumTransactionPriority({required String title, required int raw, required this.tip})
|
2023-01-11 02:57:59 +00:00
|
|
|
: super(title: title, raw: raw);
|
|
|
|
|
|
|
|
static const List<EthereumTransactionPriority> all = [fast, medium, slow];
|
|
|
|
static const EthereumTransactionPriority slow =
|
2023-07-21 16:58:44 +00:00
|
|
|
EthereumTransactionPriority(title: 'slow', raw: 0, tip: 50);
|
2023-01-11 02:57:59 +00:00
|
|
|
static const EthereumTransactionPriority medium =
|
2023-04-28 02:02:49 +00:00
|
|
|
EthereumTransactionPriority(title: 'Medium', raw: 1, tip: 75);
|
2023-01-11 02:57:59 +00:00
|
|
|
static const EthereumTransactionPriority fast =
|
2023-04-28 02:02:49 +00:00
|
|
|
EthereumTransactionPriority(title: 'Fast', raw: 2, tip: 100);
|
2023-01-11 02:57:59 +00:00
|
|
|
|
|
|
|
static EthereumTransactionPriority deserialize({required int raw}) {
|
|
|
|
switch (raw) {
|
|
|
|
case 0:
|
|
|
|
return slow;
|
|
|
|
case 1:
|
|
|
|
return medium;
|
|
|
|
case 2:
|
|
|
|
return fast;
|
|
|
|
default:
|
|
|
|
throw Exception('Unexpected token: $raw for EthereumTransactionPriority deserialize');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String get units => 'gas';
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
var label = '';
|
|
|
|
|
|
|
|
switch (this) {
|
|
|
|
case EthereumTransactionPriority.slow:
|
|
|
|
label = 'slow';
|
|
|
|
break;
|
|
|
|
case EthereumTransactionPriority.medium:
|
|
|
|
label = 'Medium';
|
|
|
|
break;
|
|
|
|
case EthereumTransactionPriority.fast:
|
|
|
|
label = 'Fast';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
}
|