-
Notifications
You must be signed in to change notification settings - Fork 146
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/4028/leather wallet modal routing #4325
Conversation
b3042d0
to
8bff6a8
Compare
@kyranjamie - I need to work on setting the BG location on the |
src/app/routes/app-routes.tsx
Outdated
return createHashRouter( | ||
createRoutesFromElements( | ||
<Route element={<Container />}> | ||
<Route | ||
path={RouteUrls.Home} | ||
path={`/${RouteUrls.Receive}/${RouteUrls.ReceiveStx}`} |
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.
To go direct to /receive/stx
for example in Ledger mode, we need this declaration also.
Doing this outside of <Home />
means we bypass the check for <Routes location={backgroundLocation || location}>
We can't do that check in this file without moving from createHashRouter
-> <HashRouter>
or introducing another wrapper which I can investigate
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.
Confused by this. What's ledger mode got to do with it?
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 had a test failing in the ledger.spec.ts
as direct access to this route was not available.
// ledger.spec.ts
test('that receive modal opens', async ({ homePage }) => {
const address = await homePage.getReceiveStxAddress();
test.expect(address).toEqual('SPSDM5RXY2E3V7JTFYKPFNRPDHG1B85788FKG2KN');
});
That calls homePage.getReceiveStxAddress()
in home.page.ts
which has this code:
async getReceiveStxAddress() {
await this.goToReceiveModal();
// In Ledger mode, this element isn't visible, so clicking is conditional
const qrCodeBtn = this.page.getByTestId(HomePageSelectors.ReceiveStxQrCodeBtn);
if (await qrCodeBtn.isVisible()) await qrCodeBtn.click();
const displayerAddress = await this.page
.getByTestId(SharedComponentsSelectors.AddressDisplayer)
.innerText();
return displayerAddress.replaceAll('\n', '');
}
Basically, here its trying to go direct to /receive/stx
but it crashes. The same issue occured on the onboarding.spec.ts
that restoring a wallet generates the correct stacks address
I think it's more to do with the route than with ledger mode specifically. It's just that in most of the other tests we first open the receive
modal then click the QR code
import { ReceiveModal } from '@app/pages/receive/receive-modal'; | ||
import { ReceiveOrdinalModal } from '@app/pages/receive/receive-ordinal'; | ||
import { ReceiveStxModal } from '@app/pages/receive/receive-stx'; | ||
|
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 split app-routes
up as it was difficult to work with.
I could refactor further to change this to object config:
export const receiveRoutesArray = [
{
path: RouteUrls.Receive,
element: <ReceiveModal />,
routes: [
{
path: RouteUrls.ReceiveStx,
element: <ReceiveStxModal />,
},
…vent double modal
…l and maintain direct access
efb3843
to
341a6a6
Compare
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.
Nice work here, @pete-watters! 👍
This PR fixes: #4086 & #4028.
Some work was performed on this before rebranding as Leather in this PR and this PR
The changes introduced here:
ModalBackgroundWrapper
which allows us to overlay modals above other routesuseBackgroundLocationRedirect
so that when pages are visited directly or opened in new tabs we can properly set the content behind themThis video shows how it's working:
Kapture.2023-10-13.at.13.12.40.mp4
I found two bugs that I haven't fixed yet and are present on
dev
:/receive/collectible/ordinal
(new tab or copy paste)TypeError: Cannot read properties of null (reading 'btcAddressTaproot')