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

feat: reuse signed request when reading state #584

Merged
merged 3 commits into from Jul 11, 2022

Conversation

lmuntaner
Copy link
Contributor

@lmuntaner lmuntaner commented Jun 28, 2022

Description

Enable the readState of the Agent to reuse the request.

Motivation

Signing with the hardware wallet requires the user to accept from the device. Reusing the signed request will improve the user experience for hardware wallet users.

How Has This Been Tested?

I linked a branch of nns-dapp to the changes in this PR and validated that everything worked, not just the new feature.

Checklist:

  • My changes follow the guidelines in CONTRIBUTING.md.
  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@lmuntaner lmuntaner requested a review from krpeacock June 28, 2022 13:09
@lmuntaner
Copy link
Contributor Author

@krpeacock could you review these changes?

I would love to remove the any type. Yet, the transform returns unknwon so not sure how I can go around that. Do you have any idea?

@lmuntaner lmuntaner changed the title Feat: Reuse signed request when reading state feat: Reuse signed request when reading state Jun 28, 2022
@lmuntaner lmuntaner changed the title feat: Reuse signed request when reading state feat: reuse signed request when reading state Jun 28, 2022
@@ -386,8 +385,19 @@ export class HttpAgent implements Agent {
});

// Apply transform for identity.
transformedRequest = await id?.transformRequest(transformedRequest);
return id?.transformRequest(transformedRequest);
Copy link
Contributor

Choose a reason for hiding this comment

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

@lmuntaner is removing this await intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, just because I am returning the value, I don't think it's needed.

If we had a try/catch then yes, but since we don't, then I don't think so.

@lmuntaner lmuntaner requested a review from krpeacock June 29, 2022 07:01
@lmuntaner lmuntaner force-pushed the feat_LM_reuse-signed-request branch from 90b744e to bce0d41 Compare July 1, 2022 13:54
@lmuntaner
Copy link
Contributor Author

@krpeacock can you review again please?

@krpeacock
Copy link
Contributor

@lmuntaner I think the approach here is good, and I see the usefulness for hardware wallets where each request requires another prompt.

It's unfortunate to expand the use of any, but you're using it in the same way it's already being used, so I'm not going to make you refactor the script to get this feature in.

I'm ready to approve, if we add a new e2e test and document the new feature in the changelog

@lmuntaner
Copy link
Contributor Author

Yes, I agree the use of any is very ugly. I haven't found a better way unfortunately.

The test and docs sound good, when I have some time I will get to it. Thanks.

@lmuntaner lmuntaner marked this pull request as ready for review July 6, 2022 08:41
@lmuntaner lmuntaner requested a review from a team as a code owner July 6, 2022 08:41
@lmuntaner lmuntaner force-pushed the feat_LM_reuse-signed-request branch from cfdc19e to d996dac Compare July 6, 2022 08:42
@lmuntaner
Copy link
Contributor Author

@krpeacock ready for another review

I added an e2e tests to read_state to make sure it also works when the request is passed. I also added a few points to the changelog.

Let me know what you think.

@lmuntaner
Copy link
Contributor Author

@krpeacock is the e2e test and the docs that I added what you needed??

Copy link
Contributor

@krpeacock krpeacock left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the work on this one!

@krpeacock krpeacock merged commit f004871 into main Jul 11, 2022
@krpeacock krpeacock deleted the feat_LM_reuse-signed-request branch July 11, 2022 16:31
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.

None yet

2 participants