diff --git a/packages/komodo_defi_framework/app_build/build_config.json b/packages/komodo_defi_framework/app_build/build_config.json index 2416d230..242e92d5 100644 --- a/packages/komodo_defi_framework/app_build/build_config.json +++ b/packages/komodo_defi_framework/app_build/build_config.json @@ -63,7 +63,7 @@ "coins": { "fetch_at_build_enabled": true, "update_commit_on_build": true, - "bundled_coins_repo_commit": "de34ec7af46a0512ea4a107a6f9c9f18d2191536", + "bundled_coins_repo_commit": "57c196726f67cabb242bfce9b39ab04b10001ec5", "coins_repo_api_url": "https://api.github.com/repos/KomodoPlatform/coins", "coins_repo_content_url": "https://komodoplatform.github.io/coins", "coins_repo_branch": "master", diff --git a/packages/komodo_defi_framework/lib/src/operations/kdf_operations_native.dart b/packages/komodo_defi_framework/lib/src/operations/kdf_operations_native.dart index 7b2c8ff3..132b1184 100644 --- a/packages/komodo_defi_framework/lib/src/operations/kdf_operations_native.dart +++ b/packages/komodo_defi_framework/lib/src/operations/kdf_operations_native.dart @@ -174,9 +174,32 @@ class KdfOperationsNativeLibrary implements IKdfOperations { ).whenComplete(() => calloc.free(startParamsPtr)); if (kDebugMode) _log('KDF started in ${timer.elapsedMilliseconds}ms'); - await Future.delayed(const Duration(milliseconds: 500)); - if (kDebugMode) _log('KDF started with result: $result'); - if (kDebugMode) _log('Status after starting KDF: ${_kdfMainStatus()}'); + + // Wait for RPC to be fully up instead of just a fixed delay + // This is a workaround for the race condition where KDF is started but + // the RPC server is not yet ready to accept requests. + bool isRpcReady = false; + for (int i = 0; i < 20; i++) { + await Future.delayed(const Duration(milliseconds: 500)); + if (_kdfMainStatus() == MainStatus.rpcIsUp) { + isRpcReady = true; + if (kDebugMode) { + _log('RPC server ready after ${timer.elapsedMilliseconds}ms'); + } + break; + } + } + + if (!isRpcReady && kDebugMode) { + _log( + 'Warning: RPC server not ready after ${timer.elapsedMilliseconds}ms', + ); + } + + if (kDebugMode) { + _log('KDF started with result: $result'); + _log('Status after starting KDF: ${_kdfMainStatus()}'); + } return KdfStartupResult.fromDefaultInt(result); } diff --git a/packages/komodo_defi_local_auth/lib/src/auth/auth_service_kdf_extension.dart b/packages/komodo_defi_local_auth/lib/src/auth/auth_service_kdf_extension.dart index 9e93a604..c50ed268 100644 --- a/packages/komodo_defi_local_auth/lib/src/auth/auth_service_kdf_extension.dart +++ b/packages/komodo_defi_local_auth/lib/src/auth/auth_service_kdf_extension.dart @@ -76,35 +76,17 @@ extension KdfExtensions on KdfAuthService { // consider moving to kdf api Future _restartKdf(KdfStartupConfig config) async { - final foundAuthExceptions = []; - late StreamSubscription sub; + await _stopKdf(); + final kdfResult = await _kdfFramework.startKdf(config); - sub = _kdfFramework.logStream.listen((log) { - final exceptions = AuthException.findExceptionsInLog(log); - if (exceptions.isNotEmpty) { - foundAuthExceptions.addAll(exceptions); - } - }); - - try { - await _stopKdf(); - final kdfResult = await _kdfFramework.startKdf(config); - - if (!kdfResult.isStartingOrAlreadyRunning()) { - throw AuthException( - 'Failed to start KDF: ${kdfResult.name}', - type: AuthExceptionType.generalAuthError, - ); - } - - await _waitUntilKdfRpcIsUp(); - - if (foundAuthExceptions.isNotEmpty) { - throw foundAuthExceptions.first; - } - } finally { - await sub.cancel(); + if (!kdfResult.isStartingOrAlreadyRunning()) { + throw AuthException( + 'Failed to start KDF: ${kdfResult.name}', + type: AuthExceptionType.generalAuthError, + ); } + + await _waitUntilKdfRpcIsUp(); } Future _waitUntilKdfRpcIsUp({ diff --git a/packages/komodo_defi_sdk/example/ios/Runner.xcodeproj/project.pbxproj b/packages/komodo_defi_sdk/example/ios/Runner.xcodeproj/project.pbxproj index d13a7f16..014f36a1 100644 --- a/packages/komodo_defi_sdk/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/komodo_defi_sdk/example/ios/Runner.xcodeproj/project.pbxproj @@ -294,10 +294,14 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", ); + inputPaths = ( + ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; @@ -370,10 +374,14 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); + inputPaths = ( + ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; diff --git a/packages/komodo_defi_sdk/example/ios/Runner/Info.plist b/packages/komodo_defi_sdk/example/ios/Runner/Info.plist index 9b9939dc..ef960df4 100644 --- a/packages/komodo_defi_sdk/example/ios/Runner/Info.plist +++ b/packages/komodo_defi_sdk/example/ios/Runner/Info.plist @@ -26,12 +26,6 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS - UIApplicationSupportsIndirectInputEvents - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main NSAppTransportSecurity NSAllowsLocalNetworking @@ -39,6 +33,12 @@ NSDocumentsFolderUsageDescription This app needs access to documents folder to store database files. + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/packages/komodo_defi_sdk/example/web/kdf/res/kdf_wrapper.dart b/packages/komodo_defi_sdk/example/web/kdf/res/kdf_wrapper.dart index 17c6b88a..46dc6b66 100644 --- a/packages/komodo_defi_sdk/example/web/kdf/res/kdf_wrapper.dart +++ b/packages/komodo_defi_sdk/example/web/kdf/res/kdf_wrapper.dart @@ -1,5 +1,6 @@ // NB! This file is not currently used and will possibly be removed in the -// future. +// future. We can consider migrating the KDF JS bootstrapper to Dart and +// compile to JavaScript. // ignore_for_file: avoid_dynamic_calls diff --git a/packages/komodo_defi_types/lib/src/utils/security_utils.dart b/packages/komodo_defi_types/lib/src/utils/security_utils.dart index ecd25423..31651f25 100644 --- a/packages/komodo_defi_types/lib/src/utils/security_utils.dart +++ b/packages/komodo_defi_types/lib/src/utils/security_utils.dart @@ -71,6 +71,7 @@ extension CensoredJsonMap on JsonMap { JsonMap censored() { // Search recursively for the following keys and replace their values // with "*" characters. + // TODO: consider adding regex or wildcard support for "*password*" or "*key*" const sensitive = [ 'seed', 'userpass', @@ -86,6 +87,7 @@ extension CensoredJsonMap on JsonMap { 'privkey', 'userpass', 'rpc_password', + 'wallet_password', ]; return censorKeys(sensitive);