-
Notifications
You must be signed in to change notification settings - Fork 148
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
fix: fix bug with sending ordinals from ledger, #ref 5253 #5268
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,11 @@ export function useLedgerNavigate() { | |
return navigate(RouteUrls.ConnectLedger, { | ||
replace: true, | ||
relative: 'route', | ||
state: { tx: bytesToHex(psbt), inputsToSign }, | ||
state: { | ||
tx: bytesToHex(psbt), | ||
inputsToSign, | ||
backgroundLocation: { pathname: RouteUrls.Home }, | ||
}, | ||
}); | ||
}, | ||
|
||
|
@@ -59,55 +63,101 @@ export function useLedgerNavigate() { | |
}, | ||
|
||
toConnectionSuccessStep(chain: SupportedBlockchains) { | ||
return navigate(RouteUrls.ConnectLedgerSuccess, { replace: true, state: { chain } }); | ||
return navigate(RouteUrls.ConnectLedgerSuccess, { | ||
replace: true, | ||
state: { | ||
chain, | ||
backgroundLocation: { pathname: RouteUrls.Home }, | ||
}, | ||
}); | ||
}, | ||
|
||
toErrorStep(chain: SupportedBlockchains, errorMessage?: string) { | ||
return navigate(RouteUrls.ConnectLedgerError, { | ||
replace: true, | ||
state: { latestLedgerError: errorMessage, chain }, | ||
state: { | ||
latestLedgerError: errorMessage, | ||
chain, | ||
backgroundLocation: { pathname: RouteUrls.Home }, | ||
}, | ||
}); | ||
}, | ||
|
||
toAwaitingDeviceOperation({ hasApprovedOperation }: { hasApprovedOperation: boolean }) { | ||
return navigate(RouteUrls.AwaitingDeviceUserAction, { | ||
replace: true, | ||
state: { hasApprovedOperation }, | ||
state: { | ||
hasApprovedOperation, | ||
backgroundLocation: { pathname: RouteUrls.Home }, | ||
}, | ||
}); | ||
}, | ||
|
||
toPublicKeyMismatchStep() { | ||
return navigate(RouteUrls.LedgerPublicKeyMismatch, { replace: true }); | ||
return navigate(RouteUrls.LedgerPublicKeyMismatch, { | ||
replace: true, | ||
state: { | ||
backgroundLocation: { pathname: RouteUrls.Home }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This overlay modal isn't always on homepage fyi. It might show in on send tokens page, signPsbt RPC call etc |
||
}, | ||
}); | ||
}, | ||
|
||
toDevicePayloadInvalid() { | ||
return navigate(RouteUrls.LedgerDevicePayloadInvalid, { replace: true }); | ||
return navigate(RouteUrls.LedgerDevicePayloadInvalid, { | ||
replace: true, | ||
state: { | ||
backgroundLocation: { pathname: RouteUrls.Home }, | ||
}, | ||
}); | ||
}, | ||
|
||
toOperationRejectedStep(description?: string) { | ||
return navigate(RouteUrls.LedgerOperationRejected, { | ||
replace: true, | ||
state: { description }, | ||
state: { | ||
backgroundLocation: { pathname: RouteUrls.Home }, | ||
description, | ||
}, | ||
}); | ||
}, | ||
|
||
toDeviceDisconnectStep() { | ||
return navigate(RouteUrls.LedgerDisconnected, { replace: true }); | ||
return navigate(RouteUrls.LedgerDisconnected, { | ||
replace: true, | ||
state: { | ||
backgroundLocation: { pathname: RouteUrls.Home }, | ||
}, | ||
}); | ||
}, | ||
|
||
toBroadcastErrorStep(error: string) { | ||
return navigate(RouteUrls.LedgerBroadcastError, { replace: true, state: { error } }); | ||
return navigate(RouteUrls.LedgerBroadcastError, { | ||
replace: true, | ||
state: { | ||
backgroundLocation: { pathname: RouteUrls.Home }, | ||
error, | ||
}, | ||
}); | ||
}, | ||
|
||
cancelLedgerAction() { | ||
return navigate('..', { relative: 'path', replace: true, state: { ...location.state } }); | ||
// for send ordinal '..' brings you back to the `choose-fee` step but you lose context of the ordinal | ||
const backLocation = location.pathname.match(RouteUrls.SendOrdinalInscription) | ||
? RouteUrls.Home | ||
: '..'; | ||
Comment on lines
+144
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we have to add logic like this, we might as well just write a switch statement to each possible case. The idea is that Is it too late to just revert the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's never too late to revert anything. And this is a real pain I agree. Unfortunately There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I understand the problem, with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pete-watters wonder if you can try something: We're missing a path on the outer route. I wonder if that means it thinks
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. I'll test that now and try see if I can both fix this and change the pattern to be a bit cleaner. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kyranjamie if I add this route wrapper the whole APP won't even load, crashing with: I think it would be prudent to merge this fix for a P1 bug first, then continue efforts refactoring the routes to implement a more permanent solution for this and all of our routes. The routing setup now is also proving tricky when implementing the Approval UX so I think it's worth re-reviewing it as a hole. I checked back and I originally added the I will take a look at the suggestions that provides to use It could be better to remove the |
||
|
||
return navigate(backLocation, { | ||
relative: 'path', | ||
replace: true, | ||
state: { ...location.state }, | ||
}); | ||
}, | ||
|
||
cancelLedgerActionAndReturnHome() { | ||
return navigate(RouteUrls.Home); | ||
}, | ||
}), | ||
|
||
[location.state, navigate] | ||
[location, navigate] | ||
); | ||
} |
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.
I tested pre 6262267 and we didn't need to do this before and I'm honestly not certain why we do now.
I have done local testing and confirmed I can send an ordinal from my ledger to my software wallet. Once it has arrived I will open this for review.
Other flows like
send/btc/
don't need thisbackgroundLocation
as they are page based rather than dialog based so I need to test them now.Likely I will need to add some other code to ensure they have the correct background but that is a lesser issue than not being able to send ordinals at all on Ledger
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.
MM, just read this. How can we set bg location dynamically?
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.
I've tested sending BTC and PSBT signing on Gamma from ledger and it's working.
I have a hook from before that re-directs if there is no background location so we could use that or else try and have a set location it takes from global state.