Fix Sign Engines's session request logic #269
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
There was a bad decision-making process inside Sign Engine in regards of session requests where a wallet could use methods handlers AND
onSessionRequest
events but not separately.The data carried by both logics didn't change, method handler will still make use of
topic
andparameters
andonSessionRequest
event will still make use ofSessionRequestEvent
object which containsid
,topic
,method
,chainId
andparams
but by fixing the decision-making logic inside Sign Engine we now resolve this issue #258APPROVE SESSIONS:
BEFORE PR:
generatedNamespaces
object inside ofSessionProposalEvent
's params, which is a handy object that determines automatically which methods are supported based on which handlers are registered withregisterRequestHandler()
AFTER PR:
generatedNamespaces
is still a valid object to be used to approve a session but if the wallet developer wants to handle session requests usingonSessionRequest
events (without registering a handler) then they will need to pass toapproveSession()
a custom set of namespaces that would include those methods without a registered handler. (This is similar to any other SDK)HANDLING SESSION REQUESTS:
BEFORE PR:
onSessionRequest
event was emitted (which was useless since the request was already being responded at that point).onSessionRequest
since theonSessionRequest
's event was being emitted only if a request handler was registered before and if a request handler was not registered for a given method then that method was considered unsupported. This is wrong!AFTER PR:
onSessionRequest
event (which was anyway useless before, as mentioned above)onSessionRequest
event will be emitted for that request and the request would have to be handled in theonSessionRequest
subscription method. If there are no methods handlers registered then every request will emit anonSessionRequest
event to be handled.How Has This Been Tested?
Due Dilligence