Skip to content

Conversation

@lealobanov
Copy link
Collaborator

@lealobanov lealobanov commented May 5, 2025

Related Issue

Closes #???

Summary of Changes

Need Regression Testing

  • Yes
  • No

Risk Assessment

  • Low
  • Medium
  • High

Additional Notes

Screenshots (if applicable)

@github-actions
Copy link

github-actions bot commented May 5, 2025

PR Summary

Integrated Flow Wallet Kit SDK and migrated crypto provider implementations. Resolved dependency conflicts in Gradle and updated transaction handling to use new Flow SDK models. Improved account management with better error handling and logging.

Changes

File Summary
app/build.gradle Added Trust Wallet Core dependency, configured GitHub packages repository, and resolved dependency conflicts by forcing specific versions and excluding conflicting modules. Added pickFirst rules for native libraries.
app/src/main/java/com/flowfoundation/wallet/manager/account/AccountManager.kt Migrated account management to use Flow Wallet Kit, improved error handling and added better state management with separate listeners for account, wallet and user info updates.
app/src/main/java/com/flowfoundation/wallet/manager/backup/BackupCryptoProvider.kt Rewrote BackupCryptoProvider to use Flow Wallet Kit's cryptographic operations, implementing CryptoProvider interface with proper key management and signing capabilities.
app/src/main/java/com/flowfoundation/wallet/manager/key/CryptoProviderManager.kt Refactored CryptoProviderManager to use Flow Wallet Kit for key management, added comprehensive error handling and logging for different account types.
app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt Updated transaction handling to use new Flow SDK models, improved error handling and added support for transaction sealing and monitoring.
app/src/main/java/com/flowfoundation/wallet/manager/account/AccountWalletManager.kt Migrated wallet management to use Flow Wallet Kit's KeyWallet and SeedPhraseKey implementations, replacing HDWallet usage.

autogenerated by presubmit.ai

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (2)
  • 51969d9: Key + account integration
  • 94b2eee: Key + account integration
Files Processed (15)
  • app/build.gradle (3 hunks)
  • app/src/main/AndroidManifest.xml (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/flowkit/FlowKitAdapter.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/flowkit/FlowKitKeyAdapter.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/manager/account/AccountManager.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/backup/BackupCryptoProvider.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt (9 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/key/CryptoProviderManager.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/key/HDWalletCryptoProvider.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/network/UserRegisterUtils.kt (5 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/restore/keystore/PrivateKeyStoreCryptoProvider.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/restore/multirestore/viewmodel/MultiRestoreViewModel.kt (12 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/wallet/confirm/presenter/WalletConfirmPresenter.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/wallet/proxy/WalletProxyConfirmationDialog.kt (2 hunks)
  • build.gradle (2 hunks)
Actionable Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/flowkit/FlowKitAdapter.kt [23-23]

    best practice: "Potential issue with temporary directory usage on Android"

  • app/src/main/java/com/flowfoundation/wallet/flowkit/FlowKitKeyAdapter.kt [72-74]

    security: "Missing signature validation implementation"

Skipped Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/page/wallet/proxy/WalletProxyConfirmationDialog.kt [78-105]

    best practice: "Potential memory leak in coroutine usage"

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • a812318: Key + account integration
Files Processed (21)
  • app/src/main/java/com/flowfoundation/wallet/flowkit/FlowKitAdapter.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/flowkit/FlowKitKeyAdapter.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/manager/account/AccountManager.kt (5 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/backup/BackupCryptoProvider.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/manager/backup/GoogleDriveBackupUtils.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/manager/dropbox/DropboxBackupUtils.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt (9 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/key/CryptoProviderManager.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/key/HDWalletCryptoProvider.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/network/UserRegisterUtils.kt (7 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/backup/multibackup/viewmodel/BackupDropboxViewModel.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/backup/multibackup/viewmodel/BackupGoogleDriveViewModel.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/backup/multibackup/viewmodel/BackupRecoveryPhraseViewModel.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/backup/viewmodel/BackupSeedPhraseViewModel.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/restore/keystore/PrivateKeyStoreCryptoProvider.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/restore/multirestore/viewmodel/MultiRestoreViewModel.kt (11 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/security/recovery/SecurityPrivateKeyActivity.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/page/security/recovery/SecurityPublicKeyActivity.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/page/wallet/confirm/presenter/WalletConfirmPresenter.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/wallet/proxy/WalletProxyConfirmationDialog.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/walletrestore/Utils.kt (1 hunk)
Actionable Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/flowkit/FlowKitKeyAdapter.kt [73-76]

    security: "Signature validation is not implemented"

  • app/src/main/java/com/flowfoundation/wallet/flowkit/FlowKitAdapter.kt [90-93]

    possible issue: "Missing data migration implementation"

Skipped Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/page/wallet/proxy/WalletProxyConfirmationDialog.kt [78-79]

    best practice: "Potential memory leak in coroutine scope"

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • 4659101: Key + account integration
Files Processed (14)
  • app/src/main/java/com/flowfoundation/wallet/manager/account/AccountWalletManager.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/backup/BackupCryptoProvider.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/manager/drive/GoogleDriveAuthActivity.kt (4 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/dropbox/DropboxAuthActivity.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/evm/Utils.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/key/CryptoProviderManager.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectResponse.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletDappDelegate.kt (4 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/backup/multibackup/fragment/BackupCompletedFragment.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/backup/multibackup/viewmodel/BackupDropboxViewModel.kt (4 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/backup/multibackup/viewmodel/BackupGoogleDriveViewModel.kt (4 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/backup/multibackup/viewmodel/BackupRecoveryPhraseViewModel.kt (5 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/profile/subpage/claimdomain/ClaimDomainViewModel.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/restore/multirestore/viewmodel/MultiRestoreViewModel.kt (11 hunks)
Actionable Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/account/AccountWalletManager.kt [52-57]

    security: "Potential security risk with hardcoded empty passphrase"

Skipped Comments (3)
  • app/src/main/java/com/flowfoundation/wallet/page/restore/multirestore/viewmodel/MultiRestoreViewModel.kt [241-248]

    possible issue: "Potential memory leak with multiple key instances"

  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletDappDelegate.kt [193-194]

    maintainability: "Incomplete TODO comment"

  • app/src/main/java/com/flowfoundation/wallet/page/profile/subpage/claimdomain/ClaimDomainViewModel.kt [94-94]

    maintainability: "Incomplete TODO comment"

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • 0b9aec0: Key + account integration
Files Processed (11)
  • app/src/main/AndroidManifest.xml (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/account/AccountManager.kt (5 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectRequestDispatcher.kt (8 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletDappDelegate.kt (4 hunks)
  • app/src/main/java/com/flowfoundation/wallet/network/UserRegisterUtils.kt (7 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/backup/multibackup/viewmodel/BackupRecoveryPhraseViewModel.kt (5 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/backup/viewmodel/BackupSeedPhraseViewModel.kt (4 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/profile/subpage/claimdomain/ClaimDomainActivity.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/page/profile/subpage/claimdomain/ClaimDomainViewModel.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/page/profile/subpage/claimdomain/Utils.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/page/profile/subpage/wallet/WalletSettingActivity.kt (2 hunks)
Actionable Comments (3)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectRequestDispatcher.kt [241-241]

    best practice: "Function should be marked as suspend since it performs asynchronous operations"

  • app/src/main/java/com/flowfoundation/wallet/manager/account/AccountManager.kt [200-202]

    possible bug: "Potential null pointer exception in public key handling"

  • app/src/main/java/com/flowfoundation/wallet/page/backup/multibackup/viewmodel/BackupRecoveryPhraseViewModel.kt [176-176]

    possible issue: "Missing input validation for mnemonic phrase"

Skipped Comments (0)

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • 98c0dfa: Key + account integration
Files Processed (12)
  • app/src/androidTest/java/com/flowfoundation/wallet/TestApi.kt (1 hunk)
  • app/src/androidTest/java/com/flowfoundation/wallet/TestKeyStore.kt (1 hunk)
  • app/src/androidTest/java/com/flowfoundation/wallet/TestWallet.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/manager/account/AccountKeyManager.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/account/AccountMigrate.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/manager/evm/COALinkCheckManager.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/evm/EVMWalletManager.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/evm/Utils.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateManager.kt (7 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateWatcher.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/Utils.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectRequestDispatcher.kt (9 hunks)
Actionable Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectRequestDispatcher.kt [461-477]

    possible issue: "Missing error handling in coroutine block"

  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectRequestDispatcher.kt [470-470]

    possible bug: "Potential null pointer exception in message handling"

Skipped Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/evm/Utils.kt [191-191]

    enhancement: "Add timeout handling for cryptographic operation"

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • 07357b3: Transactions integration
Files Processed (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt (15 hunks)
Actionable Comments (3)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt [55-56]

    possible bug: "Potential null pointer exception in transaction ID logging"

  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt [166-169]

    possible issue: "Missing error handling in transaction submission"

  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt [367-371]

    possible bug: "Potential null reference in authorizers list"

Skipped Comments (0)

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • e724ea2: Transactions integration
Files Processed (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt (14 hunks)
Actionable Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt [346-350]

    possible bug: "Potential null reference in authorizers list"

Skipped Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt [55-56]

    possible issue: "Missing error handling for transaction ID"

Comment on lines 346 to 350
authorizers = if (transaction.authorizers.isNullOrEmpty()) {
listOf(transaction.proposalKey.address.orEmpty())
} else {
authorizers(transaction.authorizers.map { FlowAddress(it) }.toMutableList())
}

payerAddress = FlowAddress(transaction.payer.orEmpty())
}
transaction.authorizers
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code doesn't validate the transaction.proposalKey.address before using it as a fallback for authorizers. Consider adding null checks:

authorizers = if (transaction.authorizers.isNullOrEmpty()) {
    transaction.proposalKey.address?.takeIf { it.isNotEmpty() }?.let { listOf(it) } ?: emptyList()
} else {
    transaction.authorizers
}


<!-- presubmit.ai: comment -->

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary

Commits Considered (1)
  • ed41495: Transactions integration
Files Processed (6)
  • app/src/main/java/com/flowfoundation/wallet/manager/flow/FlowCadenceApi.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/CadenceExecutor.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/FlowAddressRegistry.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt (13 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateManager.kt (8 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateWatcher.kt (2 hunks)
Actionable Comments (0)
Skipped Comments (3)
  • app/src/main/java/com/flowfoundation/wallet/manager/flow/FlowCadenceApi.kt [57-57]

    best practice: "Generic error wrapping may hide important details"

  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateManager.kt [104-105]

    readability: "Variable declaration could be moved closer to usage"

  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateWatcher.kt [24-25]

    maintainability: "Unused variable declaration"

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • 9cd6d1a: Transactions integration
Files Processed (8)
  • app/src/main/java/com/flowfoundation/wallet/manager/LaunchManager.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/backup/GoogleDriveBackupUtils.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/dropbox/DropboxBackupUtils.kt (4 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/flow/FlowCadenceApi.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/Utils.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt (13 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateWatcher.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/Utils.kt (1 hunk)
Actionable Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/manager/backup/GoogleDriveBackupUtils.kt [82-83]

    possible bug: "Potential null pointer exception when accessing block account"

  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/Utils.kt [12-14]

    possible bug: "Potential null pointer exception in transaction status check"

Skipped Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateWatcher.kt [28-31]

    best practice: "Missing error handling for transaction result"

Comment on lines 82 to 83
val blockAccount = FlowAddress(wallet?.walletAddress().orEmpty()).lastBlockAccount()
val keyExist = blockAccount?.keys?.firstOrNull { provider.getPublicKey() == it.publicKey.base16Value } != null
val keyExist = blockAccount?.keys?.firstOrNull { provider.getPublicKey() == it.publicKey } != null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code accesses blockAccount.keys directly without checking if blockAccount is null first. This could lead to a null pointer exception. Consider adding a null check:

val keyExist = blockAccount?.keys?.firstOrNull { provider.getPublicKey() == it.publicKey } != null

Comment on lines 12 to 14
fun TransactionResult.isExecuteFinished(): Boolean {
return !status.ordinal.isProcessing() && errorMessage.isBlank()
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isExecuteFinished() function accesses status.ordinal and errorMessage without checking if they are null. Consider adding null safety checks:

fun TransactionResult.isExecuteFinished(): Boolean {
    return !status?.ordinal?.isProcessing() ?: false && (errorMessage?.isBlank() ?: true)
}

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • fe8a557: Transactions integration
Files Processed (3)
  • app/src/main/java/com/flowfoundation/wallet/manager/flow/CadenceScriptBuilder.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateManager.kt (8 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateWatcher.kt (2 hunks)
Actionable Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/manager/flow/CadenceScriptBuilder.kt [33-37]

    possible issue: "Incomplete error handling in chain ID mapping"

  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateManager.kt [117-119]

    possible bug: "Potential null safety issue in transaction status check"

Skipped Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/transaction/TransactionStateManager.kt [112-116]

    best practice: "Missing error handling for transaction result check"

Comment on lines +33 to 37
private fun getFlowChainId(chainId: ChainId): ChainId {
return when (chainId) {
ChainId.Testnet -> FlowChainId.TESTNET
else -> FlowChainId.MAINNET
ChainId.Testnet -> ChainId.Testnet
else -> ChainId.Mainnet
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getFlowChainId function only handles Testnet explicitly and uses Mainnet as a catch-all default. This could silently handle invalid chain IDs incorrectly. Consider adding an else branch that throws an exception for unhandled chain IDs to fail fast on invalid inputs.

Comment on lines 117 to 119
if (ret.status!!.ordinal != state.state) {
state.state = ret.status!!.ordinal
state.errorMsg = ret.errorMessage
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code assumes ret.status is non-null by using the !! operator. This could lead to a runtime crash if the status is null. Consider adding a null check or using a safe call operator ?. with appropriate fallback handling.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • 608846e: Transactions integration
Files Processed (4)
  • app/build.gradle (4 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/backup/GoogleDriveBackupUtils.kt (5 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/dropbox/DropboxBackupUtils.kt (5 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt (13 hunks)
Actionable Comments (2)
  • app/build.gradle [26-27]

    security: "Potential security risk in credentials handling"

  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt [273-275]

    possible bug: "Potential data loss in argument handling"

Skipped Comments (1)
  • app/build.gradle [254-256]

    possible issue: "Potential version conflict in dependencies"

app/build.gradle Outdated
Comment on lines 26 to 27
username = properties.getProperty("gpr.user") as String?: System.getenv("GITHUB_USER")
password = properties.getProperty("gpr.key") as String?: System.getenv("GITHUB_TOKEN")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GitHub credentials are being read from properties or environment variables. Consider using a more secure secret management solution for production builds, and ensure these credentials have minimal required permissions. Also add validation to handle cases where both property and environment variable are missing.

Comment on lines 273 to 275
type = it.getTypeName(),
value = it.value ?: "" // to-do : is empty string ok here?
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code uses an empty string as a fallback when argument value is null. This could mask actual issues and lead to invalid transactions. Consider throwing an exception or handling null values more explicitly:

value = it.value ?: throw IllegalArgumentException("Transaction argument value cannot be null")

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • 1ed692d: Transactions integration
Files Processed (3)
  • app/src/main/java/com/flowfoundation/wallet/manager/evm/Utils.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/FlowApi.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt (7 hunks)
Actionable Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt [209-209]

    possible issue: "Missing error handling for failed transaction signing"

  • app/src/main/java/com/flowfoundation/wallet/manager/evm/Utils.kt [190-190]

    possible issue: "Function returns empty string on error"

Skipped Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt [313-313]

    best practice: "Hardcoded gas limit value"

val signer = createSigner(
address = payer,
keyIndex = currentKey.index.toInt(),
signer = cryptoProvider.getSigner()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signEthereumMessage function should include error handling and validation for the case when signing fails. Consider wrapping the signing operation in a try-catch block and returning an appropriate error message or throwing a specific exception.

}

fun signTypedData(data: ByteArray): String {
suspend fun signTypedData(data: ByteArray): String {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signTypedData function returns an empty string when the crypto provider or wallet address is not available. Consider throwing an exception or returning a Result type to better handle error cases.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • d5e31dc: Transactions integration
Files Processed (4)
  • app/src/main/java/com/flowfoundation/wallet/manager/flow/FlowCadenceApi.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/PayerSignable.kt (1 hunk)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt (6 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Utils.kt (2 hunks)
Actionable Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt [242-242]

    possible bug: "Potential null pointer exception in sign method"

Skipped Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/manager/flow/FlowCadenceApi.kt [57-57]

    best practice: "Generic error message may hide important details"

  • app/src/main/java/com/flowfoundation/wallet/manager/flowjvm/transaction/Transaction.kt [367-367]

    maintainability: "Magic number in gas limit default value"

override var address: String = address
override var keyIndex: Int = keyIndex

override suspend fun sign(transaction: Transaction?, bytes: ByteArray): ByteArray {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sign method accepts a nullable Transaction parameter but doesn't handle the null case. Consider adding null checks or documenting why null is acceptable here.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • c7eea31: Transactions integration + key integration
Files Processed (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/backup/BackupCryptoProvider.kt (1 hunk)
Actionable Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/manager/backup/BackupCryptoProvider.kt [20-22]

    possible bug: "Potential null pointer exception in public key conversion"

  • app/src/main/java/com/flowfoundation/wallet/manager/backup/BackupCryptoProvider.kt [29-31]

    possible issue: "Potential failure in signature generation"

Skipped Comments (0)

Comment on lines 20 to 22
@OptIn(ExperimentalStdlibApi::class)
override fun getPublicKey(): String {
val privateKey = wallet.getCurveKey(Curve.NIST256P1, DERIVATION_PATH)
val publicKey = privateKey.publicKeyNist256p1.uncompressed().data().bytesToHex()
return publicKey.removePrefix("04")
return seedPhraseKey.publicKey(SigningAlgorithm.ECDSA_P256)?.toHexString()?.removePrefix("04") ?: ""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The publicKey() call can return null, and while there's a null-safe operator, the empty string fallback could lead to issues downstream. Consider throwing an exception or handling the null case more explicitly to fail fast if the public key cannot be generated.

Comment on lines 29 to 31
@OptIn(ExperimentalStdlibApi::class)
override suspend fun signData(data: ByteArray): String {
return seedPhraseKey.sign(data, SigningAlgorithm.ECDSA_P256, HashingAlgorithm.SHA2_256).toHexString()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sign() method might throw exceptions in case of signing failures. Consider wrapping this in a try-catch block to handle potential cryptographic operation failures gracefully.

@lealobanov lealobanov requested a review from a team June 25, 2025 11:00
setOf(ChainId.Mainnet, ChainId.Testnet),
getStorage()
)
return BackupCryptoProvider(seedPhraseKey, wallet as KeyWallet)
Copy link
Collaborator

@jaymengxy jaymengxy Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember that HDWallet here is used to handle the original 12-word mnemonic key, which has a weight of 1000. The BackupCryptoProvider, on the other hand, is specifically designed to handle multi-backup keys, all of which have a weight of 500. This needs to be confirmed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the same logic is currently applied:

  • HDWalletCryptoProvider (Original 12-word mnemonic, Weight: 1000)
  • BackupCryptoProvider (Multi-backup keys, Weight: 500)
    @jaymengxy

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that BackupCryptoProvider is used here, Shouldn't we use the HDWalletCryptoProvider here?

Copy link
Collaborator Author

@lealobanov lealobanov Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this one - re-testing

// Fallback to sensible defaults based on signing algorithm
when (signingAlgorithm) {
SigningAlgorithm.ECDSA_secp256k1 -> HashingAlgorithm.SHA2_256
SigningAlgorithm.ECDSA_P256 -> HashingAlgorithm.SHA3_256
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hash algorithm used for our multi-backup was previously SHA2-256. Please check if it can be synchronized with iOS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaymengxy ok - should we always fallback to SHA2-256 if the hashing algorithm isn't found on the provider?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would be to throw an error instead of falling back to a default algorithm

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My question is why the SigningAlgorithm.ECDSA_P256 was changed to use the HashingAlgorithm.SHA3_256 instead of SHA2_256.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see what you mean. I think it is using SHA2_256, this is just a fallback in case the hashing algorithm isn't found on the provider. I can update it to SHA2_256 in the fallback.

@lealobanov lealobanov merged commit 80a4761 into develop Jun 30, 2025
2 of 3 checks passed
@lealobanov lealobanov deleted the sdk-int-2 branch June 30, 2025 01:21
@github-actions github-actions bot mentioned this pull request Jul 15, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants