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: email recovery link to redirect to my near wallet #3138

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/frontend/src/components/Routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import { PageNotFound } from './page-not-found/PageNotFound';
import Privacy from './privacy/Privacy';
import Terms from './terms/Terms';
import { initAnalytics } from './wallet-migration/metrics';
import RecoveryRedirect from './wallet-migration/RecoveryRedirect';
import { getMigrationStep } from './wallet-migration/utils';
import WalletMigration, { WALLET_MIGRATION_VIEWS } from './wallet-migration/WalletMigration';
import '../index.css';
Expand Down Expand Up @@ -420,6 +421,11 @@ class Routing extends Component {
component={VerifyOwnerWrapper}
/>
)}
<Route
exact
path="/recover-with-link/:accountId/:seedPhrase"
component={RecoveryRedirect}
/>
<PrivateRoute component={PageNotFound} />
</Switch>
<Footer />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

import { IS_MAINNET } from '../../config';

const RedirectToTestnet = () => {
const location = useLocation();

useEffect(() => {
// Function to reconstruct the URL
const reconstructUrl = (url) => {
const urlObj = new URL(url);
const myNearWalletUrl = IS_MAINNET ? 'https://app.mynearwallet.com/' : 'https://testnet.mynearwallet.com';
const newUrl = new URL(myNearWalletUrl);
newUrl.pathname = urlObj.pathname;
newUrl.search = urlObj.search;
newUrl.hash = urlObj.hash;
return newUrl.toString();
};

// Get the current URL
const currentUrl = window.location.href;

// Reconstruct the URL
const newUrl = reconstructUrl(currentUrl);

// Redirect to the new URL
window.location.replace(newUrl);
}, [location]);

return null;
};

export default RedirectToTestnet;
Loading