Skip to content

Feature Request: state management issue #1580

@cleancommits

Description

@cleancommits

Is your feature request related to a problem?

The issue in the provided code lies in the request method, specifically in the wallet_sendCalls case. After the ephemeralSigner.cleanup() method is called, the ephemeralSigner is cleaned up, but the method still attempts to return the result of the ephemeralSigner.request(args) call. This could lead to unexpected behavior if the cleanup invalidates the ephemeralSigner state.

Suggested Fix:

Store the result of ephemeralSigner.request(args) in a variable before calling ephemeralSigner.cleanup(). Then, return the stored result.

Updated Code:

case 'wallet_sendCalls': {
  const ephemeralSigner = this.initSigner('scw');
  await ephemeralSigner.handshake({ method: 'handshake' }); // exchange session keys
  const result = await ephemeralSigner.request(args); // send diffie-hellman encrypted request
  await ephemeralSigner.cleanup(); // clean up (rotate) the ephemeral session keys
  return result as T; // return the stored result
}

Explanation:

  • The result is stored in a variable before calling ephemeralSigner.cleanup().
  • This ensures that the cleanup process does not interfere with the returned value.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions