Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swap order of event subscriptions in keystone keyring constructor #2204

Closed
wants to merge 1 commit into from

Conversation

Zarigis
Copy link

@Zarigis Zarigis commented Apr 16, 2024

calling 'getMemStore().subscribe' before the AcquireMemeStoreData event is fired caused the 'request' variable to be stale

fixes #2203

this.getInteraction().emit(MemStoreDataReady, request);
}
});
const data = this.getMemStore().getState();
Copy link
Contributor

Choose a reason for hiding this comment

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

This commit doesn't work for me. Is that working for you?

Copy link
Author

Choose a reason for hiding this comment

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

No, I did some more testing and ran into some issues that I'm trying to work out. I think I don't quite understand the event interactions well enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

#2202 This fix doesn't work for you?

Copy link
Author

Choose a reason for hiding this comment

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

No it doesn't. That change fixes it so that the first signing attempt is valid, but afterwards it starts sending old transactions to the wallet.
I pushed some more changes to this branch that seem to resolve the issue (without the changes from #2022 even).

Copy link
Contributor

@heisenberg-2077 heisenberg-2077 left a comment

Choose a reason for hiding this comment

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

Signed transactions require a 100ms delay after the call to wait for the UI to be mounted.
(Fixed in the previous version https://github.com/RabbyHub/Rabby/pull/2192/files#diff-8b4639172afdc1cf22ddb09ec5ef9d896214d458eacab485742333ec0dd668dbR443)

So the bug with keystone is that getting the data comes before signing the request.(https://github.com/RabbyHub/Rabby/blob/develop/src/background/controller/wallet.ts#L2564-L2572)
So each time the UI gets the same result as the previous one.

Maybe we just need to subscribe to the memStore changes and then call MemStoreDataReady to pass the data.

this.getInteraction().on(AcquireMemeStoreData, () => {
const request = this.getMemStore().getState().sign?.request;
if (request) {
this.getInteraction().emit(MemStoreDataReady, request);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this.getInteraction().on(AcquireMemeStoreData, () => {
const request = this.getMemStore().getState().sign?.request;
if (request) {
this.getInteraction().emit(MemStoreDataReady, request);
}

@heisenberg-2077
Copy link
Contributor

@Zarigis Please try this latest fix #2202

@Zarigis
Copy link
Author

Zarigis commented Apr 16, 2024

#2202 seems to resolve the issue

@Zarigis Zarigis closed this Apr 16, 2024
@Zarigis Zarigis reopened this Apr 16, 2024
@Zarigis
Copy link
Author

Zarigis commented Apr 16, 2024

apparently not. It seemed to work better but after some testing I still managed to end up getting a stale transaction request instead of the one I wanted using only #2202.

Disabling the exportCurrentSignRequestIdIfExist function again seems to avoid the issue.

@Zarigis
Copy link
Author

Zarigis commented Apr 16, 2024

Okay it might be working and I've now conflated this bug with #2209. I'll keep testing the latest release.

@Zarigis Zarigis closed this Apr 17, 2024
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.

Incorrectly submitting cancelled transaction to be signed when using Keystone Pro 3
2 participants