-
Notifications
You must be signed in to change notification settings - Fork 176
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
base: master
Are you sure you want to change the base?
Conversation
Your Render PR Server URL is https://near-wallet-pr-2422.onrender.com. Follow its progress at https://dashboard.render.com/static/srv-c7q5p4n6d9kt3cffucsg. |
@stefanopepe
|
There was a problem hiding this 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()); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
@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. |
With this PR we are removing all usage of
store
related to ledger from wallet.js.