Skip to content

Refactor remote connection session establishment logic #1210

Merged
Funkatronics merged 15 commits intomainfrom
refactor-reflector-not-found
Jul 18, 2025
Merged

Refactor remote connection session establishment logic #1210
Funkatronics merged 15 commits intomainfrom
refactor-reflector-not-found

Conversation

@Funkatronics
Copy link
Collaborator

@Funkatronics Funkatronics commented Jul 11, 2025

Breaking change: Scenario.start has been deprecated and repalced with Scenario.startAsync. Any classes implementing the Scenario interface must implement this new method.

/**
 * Start the scenario
 * <p>
 * This method starts the connection process but returns immediately with a
 * {@link NotifyingCompletableFuture}. The returned future will be completed
 * once the scenario has successfully established a session.
 * </p>
 *
 * @return a Future that completes when the session is established
 */
NotifyingCompletableFuture<Boolean> startAsync();

@Funkatronics Funkatronics requested a review from J909 July 11, 2025 22:03
@Funkatronics Funkatronics marked this pull request as ready for review July 17, 2025 14:52
override fun onScenarioComplete() = Unit
override fun onScenarioError() = Unit
override fun onScenarioTeardownComplete() {
if (sessionId == null) return
Copy link

Choose a reason for hiding this comment

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

Is it safe to skip emitting SessionTerminated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is, as long as the wallet knows when to close itself - this is fakewallet keep in mind. This logic isnt very clean tho - I'll see if I can improve it.

<string name="label_failed_session_establishment">Connection Failed</string>
<string name="str_failed_session_establishment">
Could not establish a session with the dapp, the connection failed.
Check your network connection
Copy link

Choose a reason for hiding this comment

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

"Check your network connection and try again"?

protected String mActiveSessionId = null;
@Nullable
@GuardedBy("mLock")
private NotifyingCompletableFuture<String> mSessionEstablishedFuture;
Copy link

Choose a reason for hiding this comment

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

Initialize with null like other nullable members?


@Override
@Nullable
@GuardedBy("mLock")
Copy link

Choose a reason for hiding this comment

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

Can the API caller hold this lock?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no mLock is private

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh wait I see what you are saying, this is the getter. probably shouldnt be listed as guarded

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I decided to remove the getter entirely. I realized there were many states where the session id would be null and it would be confusing to the consumer. We can add getters in the future if there is a need.

@Funkatronics Funkatronics merged commit e145e53 into main Jul 18, 2025
5 checks passed
@Funkatronics Funkatronics deleted the refactor-reflector-not-found branch July 18, 2025 18:26
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