Toggle ledger account binding
This commit is contained in:
parent
944be471a7
commit
703d4fd55b
|
@ -42,6 +42,10 @@ class DevPageState extends State<DevPage> {
|
|||
title: Text('Import YFVK'),
|
||||
trailing: Icon(Icons.chevron_right),
|
||||
onTap: _importYFVK),
|
||||
ListTile(
|
||||
title: Text('Bind/Unbind from Ledger'),
|
||||
trailing: Icon(Icons.chevron_right),
|
||||
onTap: _toggleLedgerBinding),
|
||||
ListTile(
|
||||
title: Text('Revoke Dev mode'),
|
||||
trailing: Icon(Icons.chevron_right),
|
||||
|
@ -53,24 +57,24 @@ class DevPageState extends State<DevPage> {
|
|||
Navigator.of(context).pushNamed('/syncstats');
|
||||
}
|
||||
|
||||
_resetScan() {
|
||||
void _resetScan() {
|
||||
WarpApi.truncateSyncData();
|
||||
syncStatus.reset();
|
||||
}
|
||||
|
||||
_reorg() async {
|
||||
void _reorg() async {
|
||||
await syncStatus.reorg();
|
||||
}
|
||||
|
||||
_markAsSynced() {
|
||||
void _markAsSynced() {
|
||||
WarpApi.skipToLastHeight(active.coin);
|
||||
}
|
||||
|
||||
_clearTxDetails() {
|
||||
void _clearTxDetails() {
|
||||
WarpApi.clearTxDetails(active.coin, active.id);
|
||||
}
|
||||
|
||||
_importYFVK() async {
|
||||
Future<void> _importYFVK() async {
|
||||
final nameController = TextEditingController();
|
||||
final keyController = TextEditingController();
|
||||
final formKey = GlobalKey<FormBuilderState>();
|
||||
|
@ -113,6 +117,10 @@ class DevPageState extends State<DevPage> {
|
|||
return null;
|
||||
}
|
||||
|
||||
void _toggleLedgerBinding() {
|
||||
WarpApi.ledgerToggleBinding(active.coin, active.id);
|
||||
}
|
||||
|
||||
_resetDevMode() {
|
||||
showSnackBar('Dev mode disabled');
|
||||
settings.resetDevMode();
|
||||
|
|
|
@ -14,7 +14,12 @@ class DualMoneyInputWidget extends StatefulWidget {
|
|||
final Function(int)? onChange;
|
||||
|
||||
DualMoneyInputWidget(
|
||||
{Key? key, this.initialValue, this.spendable, String? fiat, this.max = false, this.onChange})
|
||||
{Key? key,
|
||||
this.initialValue,
|
||||
this.spendable,
|
||||
String? fiat,
|
||||
this.max = false,
|
||||
this.onChange})
|
||||
: super(key: key) {
|
||||
this.fiat = fiat ?? settings.currency;
|
||||
}
|
||||
|
@ -66,7 +71,6 @@ class DualMoneyInputState extends State<DualMoneyInputWidget> {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
priceAutorunDispose?.call();
|
||||
|
@ -80,24 +84,24 @@ class DualMoneyInputState extends State<DualMoneyInputWidget> {
|
|||
Row(children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
style: !inputInCoin
|
||||
? TextStyle(fontWeight: FontWeight.w200)
|
||||
: TextStyle(),
|
||||
decoration: InputDecoration(
|
||||
labelText: s.amountInSettingscurrency(active.coinDef.ticker)),
|
||||
controller: coinAmountController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [makeInputFormatter(_useMillis)],
|
||||
onTap: () => setState(() {
|
||||
inputInCoin = true;
|
||||
}),
|
||||
validator: _checkAmount,
|
||||
onChanged: (_) {
|
||||
_updateFiatAmount();
|
||||
_updateSlider();
|
||||
_onChanged();
|
||||
},
|
||||
onSaved: _onAmount,
|
||||
style: !inputInCoin
|
||||
? TextStyle(fontWeight: FontWeight.w200)
|
||||
: TextStyle(),
|
||||
decoration: InputDecoration(
|
||||
labelText: s.amountInSettingscurrency(active.coinDef.ticker)),
|
||||
controller: coinAmountController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [makeInputFormatter(_useMillis)],
|
||||
onTap: () => setState(() {
|
||||
inputInCoin = true;
|
||||
}),
|
||||
validator: _checkAmount,
|
||||
onChanged: (_) {
|
||||
_updateFiatAmount();
|
||||
_updateSlider();
|
||||
_onChanged();
|
||||
},
|
||||
onSaved: _onAmount,
|
||||
)),
|
||||
if (widget.max) TextButton(child: Text(s.max), onPressed: _onMax),
|
||||
]),
|
||||
|
@ -171,8 +175,7 @@ class DualMoneyInputState extends State<DualMoneyInputWidget> {
|
|||
_onMax();
|
||||
} else {
|
||||
final a = (widget.spendable! * v / 100).round();
|
||||
coinAmountController.text =
|
||||
amountToString(a, precision(_useMillis));
|
||||
coinAmountController.text = amountToString(a, precision(_useMillis));
|
||||
_updateFiatAmount();
|
||||
_onChanged();
|
||||
}
|
||||
|
@ -214,7 +217,7 @@ class DualMoneyInputState extends State<DualMoneyInputWidget> {
|
|||
});
|
||||
}
|
||||
|
||||
void _updateFiatAmount(){
|
||||
void _updateFiatAmount() {
|
||||
final amount = parseNumber(coinAmountController.text);
|
||||
final otherAmount = decimalFormat(amount * _fxRate, precision(_useMillis));
|
||||
setState(() {
|
||||
|
@ -229,7 +232,6 @@ class DualMoneyInputState extends State<DualMoneyInputWidget> {
|
|||
if (spendable != null) {
|
||||
sliderValue = (amount / spendable * 100).clamp(0, 100);
|
||||
if (isMax) _useMillis = false;
|
||||
print(_useMillis);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -238,18 +240,22 @@ class DualMoneyInputState extends State<DualMoneyInputWidget> {
|
|||
amount = stringToAmount(vs);
|
||||
}
|
||||
|
||||
Future<void> restore(int amount, double amountInFiat, bool feeIncluded, String? fiat) async {
|
||||
final rate = await getFxRate(active.coinDef.currency, fiat ?? settings.currency) ?? 0.0;
|
||||
Future<void> restore(
|
||||
int amount, double amountInFiat, bool feeIncluded, String? fiat) async {
|
||||
final rate =
|
||||
await getFxRate(active.coinDef.currency, fiat ?? settings.currency) ??
|
||||
0.0;
|
||||
setState(() {
|
||||
_fxRate = rate;
|
||||
if (fiat != null) {
|
||||
_fiat = fiat;
|
||||
fiatAmountController.text = decimalFormat(amountInFiat, precision(_useMillis));
|
||||
fiatAmountController.text =
|
||||
decimalFormat(amountInFiat, precision(_useMillis));
|
||||
inputInCoin = false;
|
||||
_updateAmount();
|
||||
}
|
||||
else {
|
||||
coinAmountController.text = amountToString(amount, precision(_useMillis));
|
||||
} else {
|
||||
coinAmountController.text =
|
||||
amountToString(amount, precision(_useMillis));
|
||||
inputInCoin = true;
|
||||
_updateFiatAmount();
|
||||
_onChanged();
|
||||
|
|
|
@ -34,7 +34,6 @@ class PoolsState extends State<PoolsPage> {
|
|||
];
|
||||
|
||||
final availableAddrs = active.availabeAddrs;
|
||||
print(availableAddrs);
|
||||
_pools = availablePools
|
||||
.asMap()
|
||||
.entries
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d3c4f2818daa99cb390cb32adb1f0a8d64d525d0
|
||||
Subproject commit 99973aa6949a39b3100b1911ed6ad99f1617fd5f
|
|
@ -326,6 +326,10 @@ class WarpApi {
|
|||
warp_api_lib.import_uvk(coin, toNative(name), toNative(yfvk)));
|
||||
}
|
||||
|
||||
static void ledgerToggleBinding(int coin, int account) {
|
||||
unwrapResultU8(warp_api_lib.ledger_toggle_binding(coin, account));
|
||||
}
|
||||
|
||||
static DateTime getActivationDate() {
|
||||
final res = unwrapResultU32(warp_api_lib.get_activation_date());
|
||||
return DateTime.fromMillisecondsSinceEpoch(res * 1000);
|
||||
|
@ -566,7 +570,6 @@ class WarpApi {
|
|||
subject: t.subject,
|
||||
body: t.body,
|
||||
).toBytes();
|
||||
print("templ $t");
|
||||
final data = toNativeBytes(template);
|
||||
|
||||
return unwrapResultU32(
|
||||
|
|
|
@ -1492,6 +1492,22 @@ class NativeLibrary {
|
|||
late final _dart_ledger_has_account _ledger_has_account =
|
||||
_ledger_has_account_ptr.asFunction<_dart_ledger_has_account>();
|
||||
|
||||
CResult_u8 ledger_toggle_binding(
|
||||
int coin,
|
||||
int account,
|
||||
) {
|
||||
return _ledger_toggle_binding(
|
||||
coin,
|
||||
account,
|
||||
);
|
||||
}
|
||||
|
||||
late final _ledger_toggle_binding_ptr =
|
||||
_lookup<ffi.NativeFunction<_c_ledger_toggle_binding>>(
|
||||
'ledger_toggle_binding');
|
||||
late final _dart_ledger_toggle_binding _ledger_toggle_binding =
|
||||
_ledger_toggle_binding_ptr.asFunction<_dart_ledger_toggle_binding>();
|
||||
|
||||
int has_cuda() {
|
||||
return _has_cuda();
|
||||
}
|
||||
|
@ -2701,6 +2717,16 @@ typedef _dart_ledger_has_account = CResult_bool Function(
|
|||
int account,
|
||||
);
|
||||
|
||||
typedef _c_ledger_toggle_binding = CResult_u8 Function(
|
||||
ffi.Uint8 coin,
|
||||
ffi.Uint32 account,
|
||||
);
|
||||
|
||||
typedef _dart_ledger_toggle_binding = CResult_u8 Function(
|
||||
int coin,
|
||||
int account,
|
||||
);
|
||||
|
||||
typedef _c_has_cuda = ffi.Int8 Function();
|
||||
|
||||
typedef _dart_has_cuda = int Function();
|
||||
|
|
Loading…
Reference in New Issue