Skip to content

Additional WC debugging#1071

Merged
lmcmz merged 21 commits intodevelopfrom
wc-debugging-2
May 26, 2025
Merged

Additional WC debugging#1071
lmcmz merged 21 commits intodevelopfrom
wc-debugging-2

Conversation

@lealobanov
Copy link
Copy Markdown
Contributor

@lealobanov lealobanov commented May 15, 2025

Related Issue

Summary of Changes

  • Ensure that the session request isn't stale by checking that session topic is still valid; isSessionTopicValid() rejects any SessionRequest whose topic isn’t in SignClient.getActiveSessionByTopic()
  • Instead of manually generating namespaces, use the reown generateApprovedNamespaces method which already implements this logic

Need Regression Testing

  • Yes
  • No

Risk Assessment

  • Low
  • Medium
  • High

Additional Notes

Screenshots (if applicable)

@lealobanov lealobanov requested a review from a team as a code owner May 15, 2025 08:27
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2025

PR Summary

Enhanced WalletConnect implementation by improving session management and error handling. Added session topic validation, improved namespace approval process, and reorganized error messages. The changes focus on preventing stale session issues and providing better error feedback.

Changes

File Summary
app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/Utils.kt Enhanced session approval by implementing generateApprovedNamespaces for better namespace validation. Restructured the approveSession function to use proper parameter naming and improved error handling.
app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnect.kt Removed unnecessary empty line and maintained class structure with BuildConfig constant definition.
app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectDelegate.kt Implemented isSessionTopicValid to verify session topics before processing requests. Enhanced request handling with better logging and session validation checks. Added safety checks for stale sessions.
app/src/main/res/values/strings.xml Reorganized WalletConnect-related error messages by removing duplicate strings and grouping them together in a more logical order within the resource file.

autogenerated by presubmit.ai

Copy link
Copy Markdown

@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 (18)
Files Processed (6)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnect.kt (4 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectDelegate.kt (9 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectRequestDispatcher.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/component/deeplinking/DeepLinkingActivity.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/component/deeplinking/Utils.kt (2 hunks)
  • app/src/main/res/values/strings.xml (2 hunks)
Actionable Comments (0)
Skipped Comments (3)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnect.kt [55-57]

    possible issue: "Potential timeout issue in initialization wait logic"

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

    enhancement: "Improve error logging for missing authentication parameters"

  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectDelegate.kt [424-431]

    enhancement: "Improve session topic validation error logging"

Copy link
Copy Markdown

@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)
Files Processed (7)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/Utils.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnect.kt (4 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectDelegate.kt (9 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectRequestDispatcher.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/component/deeplinking/DeepLinkingActivity.kt (3 hunks)
  • app/src/main/java/com/flowfoundation/wallet/page/component/deeplinking/Utils.kt (2 hunks)
  • app/src/main/res/values/strings.xml (2 hunks)
Actionable Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectRequestDispatcher.kt [318-354]

    possible issue: "Potential infinite retry loop in response sending"

Skipped Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnectDelegate.kt [40-41]

    best practice: "Consider using atomic boolean for thread safety"

  • app/src/main/java/com/flowfoundation/wallet/manager/walletconnect/WalletConnect.kt [51-70]

    possible issue: "Potential memory leak in initialization wait loop"

Comment on lines +318 to +354
var retryCount = 0
val maxRetries = 3
var success = false

while (!success && retryCount < maxRetries) {
try {
SignClient.respond(response, onSuccess = { result ->
logd(TAG, "Response sent successfully: $result")
success = true
ioScope {
try {
delay(1000)
logd(TAG, "Authn response sent, proceeding with session settlement")
// Try to get the redirect URL from the session
val session = SignClient.getActiveSessionByTopic(topic)
if (session?.metaData?.redirect.isNullOrEmpty()) {
logd(TAG, "No redirect URL found in session metadata")
} else {
logd(TAG, "Found redirect URL in session metadata: ${session?.metaData?.redirect}")
}
} catch (e: Exception) {
loge(TAG, "Error during authn response cleanup: ${e.message}")
loge(e)
// Don't reject here since the response was already sent successfully
}
}
}) { error ->
loge(TAG, "Failed to send response (attempt ${retryCount + 1}): ${error.throwable.message}")
loge(error.throwable)
retryCount++
if (retryCount >= maxRetries) {
reject()
}
}
if (!success) {
delay(1000L * (retryCount + 1))
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The retry mechanism for sending responses could potentially continue indefinitely if success is never set to true and no exception is thrown. Consider adding a timeout or maximum duration for the entire retry process.

Copy link
Copy Markdown

@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)
Files Processed (1)
  • app/src/main/res/values/strings.xml (2 hunks)
Actionable Comments (0)
Skipped Comments (1)
  • app/src/main/res/values/strings.xml [767-769]

    enhancement: "Consider consolidating error messages into a single string resource with formatting"

@lealobanov lealobanov changed the title Wc debugging 2 Additional WC debugging May 19, 2025
Copy link
Copy Markdown

@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)
Files Processed (1)
  • app/src/main/res/values/strings.xml (2 hunks)
Actionable Comments (0)
Skipped Comments (0)

@lealobanov lealobanov requested review from jaymengxy and lmcmz May 19, 2025 06:46
@lealobanov lealobanov self-assigned this May 19, 2025
@lealobanov lealobanov added this to the Release 2.8.6 milestone May 19, 2025
@lmcmz lmcmz merged commit a85856d into develop May 26, 2025
8 checks passed
@lmcmz lmcmz deleted the wc-debugging-2 branch May 26, 2025 05:15
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.

2 participants