WIP
This commit is contained in:
parent
49c41fa3f7
commit
9cae1845fd
|
@ -29,8 +29,7 @@ class _AddAccountPageState extends State<AddAccountPage> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.firstAccount)
|
||||
_nameController.text = "Main";
|
||||
if (widget.firstAccount) _nameController.text = "Main";
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -100,8 +99,7 @@ class _AddAccountPageState extends State<AddAccountPage> {
|
|||
maxLines: 4,
|
||||
controller: _keyController,
|
||||
validator: (String? key) {
|
||||
if (!_checkKey(key))
|
||||
return s.invalidKey;
|
||||
if (!_checkKey(key)) return s.invalidKey;
|
||||
return null;
|
||||
},
|
||||
onChanged: _checkKey,
|
||||
|
@ -113,10 +111,14 @@ class _AddAccountPageState extends State<AddAccountPage> {
|
|||
onPressed: _onScan))
|
||||
],
|
||||
),
|
||||
if (_restore)
|
||||
ElevatedButton(
|
||||
onPressed: _importLedger,
|
||||
child: Text('Connect Ledger')),
|
||||
if (_restore && _showIndex)
|
||||
TextFormField(
|
||||
decoration:
|
||||
InputDecoration(labelText: s.accountIndex),
|
||||
InputDecoration(labelText: s.accountIndex),
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.digitsOnly
|
||||
|
@ -129,12 +131,13 @@ class _AddAccountPageState extends State<AddAccountPage> {
|
|||
},
|
||||
),
|
||||
ButtonBar(children: [
|
||||
if (!widget.firstAccount) ElevatedButton.icon(
|
||||
icon: Icon(Icons.cancel),
|
||||
label: Text(s.cancel),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
if (!widget.firstAccount)
|
||||
ElevatedButton.icon(
|
||||
icon: Icon(Icons.cancel),
|
||||
label: Text(s.cancel),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
ElevatedButton.icon(
|
||||
icon: Icon(Icons.add),
|
||||
label: Text(_restore ? s.import : s.newLabel),
|
||||
|
@ -186,11 +189,9 @@ class _AddAccountPageState extends State<AddAccountPage> {
|
|||
syncStatus.setAccountRestored(true);
|
||||
if (widget.firstAccount) {
|
||||
final height = await rescanDialog(context);
|
||||
if (height != null)
|
||||
syncStatus.rescan(height);
|
||||
if (height != null) syncStatus.rescan(height);
|
||||
nav.pushReplacementNamed('/account');
|
||||
}
|
||||
else
|
||||
} else
|
||||
nav.pop();
|
||||
} else {
|
||||
nav.pushReplacementNamed('/backup',
|
||||
|
@ -225,6 +226,14 @@ class _AddAccountPageState extends State<AddAccountPage> {
|
|||
_showIndex = !_showIndex;
|
||||
});
|
||||
}
|
||||
|
||||
_importLedger() {
|
||||
setState(() {
|
||||
WarpApi.ledgerBuildKeys();
|
||||
// TODO: Show some waiting indicator ... this takes 1 mn!
|
||||
_keyController.text = WarpApi.ledgerGetFVK(active.coin);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
final _keyRe = RegExp(r"(.*) \[(\d+)\]$");
|
||||
|
|
|
@ -107,7 +107,7 @@ class TxPlanPage extends StatelessWidget {
|
|||
}
|
||||
|
||||
_onSend() async {
|
||||
if (active.canPay) {
|
||||
if (true || active.canPay) {
|
||||
if (signOnly)
|
||||
await _sign();
|
||||
else {
|
||||
|
@ -115,8 +115,9 @@ class TxPlanPage extends StatelessWidget {
|
|||
active.setBanner(S.current.paymentInProgress);
|
||||
final player = AudioPlayer();
|
||||
try {
|
||||
final txid =
|
||||
await WarpApi.signAndBroadcast(active.coin, active.id, plan);
|
||||
// final txid =
|
||||
// await WarpApi.signAndBroadcast(active.coin, active.id, plan);
|
||||
final txid = await WarpApi.ledgerSend(active.coin, plan);
|
||||
showSnackBar(S.current.txId(txid));
|
||||
await player.play(AssetSource("success.mp3"));
|
||||
active.setDraftRecipient(null);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit f39dd6c2af20662fd1aaa9e00172efebd3435ff4
|
||||
Subproject commit e2fe0b8d386fad99e00d6135c5caf3cc04045646
|
|
@ -72,6 +72,7 @@
|
|||
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
|
||||
3ABAA4F74E9B840322C571A2 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
|
||||
3B7C926528AE6FF000777DAD /* libwarp_api_ffi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libwarp_api_ffi.dylib; path = ../target/universal/release/libwarp_api_ffi.dylib; sourceTree = "<group>"; };
|
||||
3BD6E01629DA5FC4008FE892 /* RunnerDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RunnerDebug.entitlements; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
|
||||
8D0D09BA27FFDEBE0DB78C1C /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
|
||||
|
@ -146,6 +147,7 @@
|
|||
33FAB671232836740065AC1E /* Runner */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3BD6E01629DA5FC4008FE892 /* RunnerDebug.entitlements */,
|
||||
33CC10F02044A3C60003C045 /* AppDelegate.swift */,
|
||||
33CC11122044BFA00003C045 /* MainFlutterWindow.swift */,
|
||||
33E51913231747F40026EE4D /* DebugProfile.entitlements */,
|
||||
|
@ -551,7 +553,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/RunnerDebug.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NAME)";
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
<true/>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.device.usb</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.device.usb</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c46f4ad78420c5a3891429212d8522d91fd5d81b
|
||||
Subproject commit 2e118feceeaa31ef68fb83d1fc94a1a46db4569c
|
|
@ -1 +1 @@
|
|||
Subproject commit 945cf8941e1a9495b19afc03740b4ee728d479d4
|
||||
Subproject commit bbfad744a5d492285b6db655706cf65f6bf1e53a
|
|
@ -117,6 +117,10 @@ class WarpApi {
|
|||
name.toNativeUtf8().cast<Int8>(), index, count);
|
||||
}
|
||||
|
||||
static String ledgerGetFVK(int coin) {
|
||||
return unwrapResultString(warp_api_lib.ledger_get_fvk(coin));
|
||||
}
|
||||
|
||||
static void convertToWatchOnly(int coin, int id) {
|
||||
warp_api_lib.convert_to_watchonly(coin, id);
|
||||
}
|
||||
|
@ -447,6 +451,21 @@ class WarpApi {
|
|||
return kp;
|
||||
}
|
||||
|
||||
static void ledgerBuildKeys() {
|
||||
unwrapResultU8(warp_api_lib.ledger_build_keys());
|
||||
}
|
||||
|
||||
static String ledgerGetAddress() {
|
||||
return unwrapResultString(warp_api_lib.ledger_get_address());
|
||||
}
|
||||
|
||||
static Future<String> ledgerSend(int coin, String txPlan) async {
|
||||
return await compute((_) {
|
||||
return unwrapResultString(
|
||||
warp_api_lib.ledger_send(coin, toNative(txPlan)));
|
||||
}, null);
|
||||
}
|
||||
|
||||
static bool hasCuda() {
|
||||
return warp_api_lib.has_cuda() != 0;
|
||||
}
|
||||
|
|
|
@ -424,6 +424,37 @@ class NativeLibrary {
|
|||
late final _dart_get_latest_height _get_latest_height =
|
||||
_get_latest_height_ptr.asFunction<_dart_get_latest_height>();
|
||||
|
||||
CResult_u8 ledger_build_keys() {
|
||||
return _ledger_build_keys();
|
||||
}
|
||||
|
||||
late final _ledger_build_keys_ptr =
|
||||
_lookup<ffi.NativeFunction<_c_ledger_build_keys>>('ledger_build_keys');
|
||||
late final _dart_ledger_build_keys _ledger_build_keys =
|
||||
_ledger_build_keys_ptr.asFunction<_dart_ledger_build_keys>();
|
||||
|
||||
CResult_____c_char ledger_get_fvk(
|
||||
int coin,
|
||||
) {
|
||||
return _ledger_get_fvk(
|
||||
coin,
|
||||
);
|
||||
}
|
||||
|
||||
late final _ledger_get_fvk_ptr =
|
||||
_lookup<ffi.NativeFunction<_c_ledger_get_fvk>>('ledger_get_fvk');
|
||||
late final _dart_ledger_get_fvk _ledger_get_fvk =
|
||||
_ledger_get_fvk_ptr.asFunction<_dart_ledger_get_fvk>();
|
||||
|
||||
CResult_____c_char ledger_get_address() {
|
||||
return _ledger_get_address();
|
||||
}
|
||||
|
||||
late final _ledger_get_address_ptr =
|
||||
_lookup<ffi.NativeFunction<_c_ledger_get_address>>('ledger_get_address');
|
||||
late final _dart_ledger_get_address _ledger_get_address =
|
||||
_ledger_get_address_ptr.asFunction<_dart_ledger_get_address>();
|
||||
|
||||
void skip_to_last_height(
|
||||
int coin,
|
||||
) {
|
||||
|
@ -1398,6 +1429,21 @@ class NativeLibrary {
|
|||
late final _dart_set_property _set_property =
|
||||
_set_property_ptr.asFunction<_dart_set_property>();
|
||||
|
||||
CResult_____c_char ledger_send(
|
||||
int coin,
|
||||
ffi.Pointer<ffi.Int8> tx_plan,
|
||||
) {
|
||||
return _ledger_send(
|
||||
coin,
|
||||
tx_plan,
|
||||
);
|
||||
}
|
||||
|
||||
late final _ledger_send_ptr =
|
||||
_lookup<ffi.NativeFunction<_c_ledger_send>>('ledger_send');
|
||||
late final _dart_ledger_send _ledger_send =
|
||||
_ledger_send_ptr.asFunction<_dart_ledger_send>();
|
||||
|
||||
int has_cuda() {
|
||||
return _has_cuda();
|
||||
}
|
||||
|
@ -1895,6 +1941,22 @@ typedef _c_get_latest_height = CResult_u32 Function();
|
|||
|
||||
typedef _dart_get_latest_height = CResult_u32 Function();
|
||||
|
||||
typedef _c_ledger_build_keys = CResult_u8 Function();
|
||||
|
||||
typedef _dart_ledger_build_keys = CResult_u8 Function();
|
||||
|
||||
typedef _c_ledger_get_fvk = CResult_____c_char Function(
|
||||
ffi.Uint8 coin,
|
||||
);
|
||||
|
||||
typedef _dart_ledger_get_fvk = CResult_____c_char Function(
|
||||
int coin,
|
||||
);
|
||||
|
||||
typedef _c_ledger_get_address = CResult_____c_char Function();
|
||||
|
||||
typedef _dart_ledger_get_address = CResult_____c_char Function();
|
||||
|
||||
typedef _c_skip_to_last_height = ffi.Void Function(
|
||||
ffi.Uint8 coin,
|
||||
);
|
||||
|
@ -2547,6 +2609,16 @@ typedef _dart_set_property = CResult_u8 Function(
|
|||
ffi.Pointer<ffi.Int8> value,
|
||||
);
|
||||
|
||||
typedef _c_ledger_send = CResult_____c_char Function(
|
||||
ffi.Uint8 coin,
|
||||
ffi.Pointer<ffi.Int8> tx_plan,
|
||||
);
|
||||
|
||||
typedef _dart_ledger_send = CResult_____c_char Function(
|
||||
int coin,
|
||||
ffi.Pointer<ffi.Int8> tx_plan,
|
||||
);
|
||||
|
||||
typedef _c_has_cuda = ffi.Int8 Function();
|
||||
|
||||
typedef _dart_has_cuda = int Function();
|
||||
|
|
Loading…
Reference in New Issue