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

Remove store usage related to ledger from wallet.js #2422

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

marcinbodnar
Copy link
Contributor

With this PR we are removing all usage of store related to ledger from wallet.js.

@render
Copy link

render bot commented Jan 28, 2022

@marcinbodnar marcinbodnar linked an issue Jan 28, 2022 that may be closed by this pull request
@marcinbodnar marcinbodnar changed the title [WIP] Remove store usage related to ledger from wallet.js Remove store usage related to ledger from wallet.js Feb 5, 2022
@marcinbodnar
Copy link
Contributor Author

@stefanopepe
Could you please test it regarding the ledger? The most important things are:

  • does ledger related functionalities are working well
  • does ledger modals appears and hides properly
  • does disable request on the ledger device is properly closing ledger modals.
    Thank you.

Copy link
Contributor

@andy-haynes andy-haynes left a comment

Choose a reason for hiding this comment

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

Looking good, just a few comments inline.

@@ -140,6 +144,9 @@ const SetupLedger = (props) => {
(e) => {
setConnect('fail');
throw e;
},
() => {
dispatch(checkAndHideLedgerModal());
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this have an await? I see that the createAsyncThunk call that creates checkAndHideLedgerModal has synchronous logic in its payloadCreator argument but since that function is declared async it will still return a Promise. If an await were added to that payloadCreator body later on, an await would need to be added here anyway to avoid fire-and-forgetting a Promise that needed to be waited on. Even worse would be if an error were thrown from checkAndHideLedgerModal then this would potentially lead to an unhandled Promise rejection.

Alternatively we could omit createAsyncThunk for synchronous thunks if we don't think they'll be extended in the future and it doesn't introduce inconsistencies in our action handling.

async ({ path } = {}, { dispatch }) => {
const { createLedgerU2FClient } = await import('../../../utils/ledger.js');
const client = await createLedgerU2FClient();
dispatch(handleShowLedgerModal({ show: true })).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the .unwrap() necessary here if we're not interested in the return value?

`${SLICE_NAME}/handleShowLedgerModal`,
async ({ show }, { dispatch, getState }) => {
const actionStatus = selectStatusActionStatus(getState());
const actions = Object.keys(actionStatus).filter((action) => actionStatus[action]?.pending === true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can pending be truthy without being explicitly true? Just curious if the explicit true check is required here

@Patrick1904
Copy link
Contributor

@marcinbodnar are these changes still relevant after the new Ledger connection implementation?

@marcinbodnar
Copy link
Contributor Author

@marcinbodnar are these changes still relevant after the new Ledger connection implementation?

@Patrick1904 yes, but I will probably have to do it again because there are too much conflicts now.

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.

Remove store usage related to ledger from wallet.js
3 participants