Skip to content

Commit

Permalink
Merge pull request #3015 from near/master
Browse files Browse the repository at this point in the history
Release 2023-02-27
  • Loading branch information
andy-haynes authored Feb 27, 2023
2 parents f7b422e + ff2707a commit 7b7f715
Show file tree
Hide file tree
Showing 18 changed files with 2,996 additions and 435 deletions.
1 change: 1 addition & 0 deletions features/features.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export type Features = {
RENDER_MIGRATION: boolean;
SHOW_MIGRATION_BANNER: boolean;
WEB3AUTH: boolean;
WEP_DISABLE_ACCOUNT_CREATION: boolean;
WEP_PHASE_ONE: boolean;
};
60 changes: 52 additions & 8 deletions features/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,50 @@
"lastEditedAt": "2022-07-19T05:34:11.690Z"
}
},
"WEP_DISABLE_ACCOUNT_CREATION": {
"createdBy": "Andy Haynes",
"createdAt": "2023-02-13T18:46:04.151Z",
"development": {
"enabled": true,
"lastEditedBy": "Andy Haynes",
"lastEditedAt": "2023-02-13T18:46:04.150Z"
},
"testnet": {
"enabled": false,
"lastEditedBy": "Andy Haynes",
"lastEditedAt": "2023-02-13T18:46:04.151Z"
},
"mainnet": {
"enabled": false,
"lastEditedBy": "Andy Haynes",
"lastEditedAt": "2023-02-13T18:46:04.151Z"
},
"mainnet_STAGING": {
"enabled": false,
"lastEditedBy": "Andy Haynes",
"lastEditedAt": "2023-02-13T18:46:04.151Z"
},
"testnet_STAGING": {
"enabled": false,
"lastEditedBy": "Andy Haynes",
"lastEditedAt": "2023-02-13T18:46:04.151Z"
},
"testnet_NEARORG": {
"enabled": false,
"lastEditedBy": "Andy Haynes",
"lastEditedAt": "2023-02-13T18:46:04.151Z"
},
"mainnet_NEARORG": {
"enabled": false,
"lastEditedBy": "Andy Haynes",
"lastEditedAt": "2023-02-13T18:46:04.151Z"
},
"mainnet_STAGING_NEARORG": {
"enabled": false,
"lastEditedBy": "Andy Haynes",
"lastEditedAt": "2023-02-13T18:46:04.151Z"
}
},
"WEP_PHASE_ONE": {
"createdBy": "roshaans",
"createdAt": "2022-09-29T12:47:40.121Z",
Expand Down Expand Up @@ -336,19 +380,19 @@
"lastEditedAt": "2022-09-29T12:47:40.121Z"
},
"testnet_NEARORG": {
"enabled": false,
"lastEditedBy": "roshaans",
"lastEditedAt": "2022-09-29T12:47:40.121Z"
"enabled": true,
"lastEditedBy": "Andy Haynes",
"lastEditedAt": "2023-02-13T22:23:12.644Z"
},
"mainnet_NEARORG": {
"enabled": false,
"lastEditedBy": "roshaans",
"lastEditedAt": "2022-09-29T12:47:40.121Z"
"lastEditedBy": "Andy Haynes",
"lastEditedAt": "2023-02-23T00:04:07.742Z"
},
"mainnet_STAGING_NEARORG": {
"enabled": false,
"lastEditedBy": "roshaans",
"lastEditedAt": "2022-09-29T12:47:40.121Z"
"enabled": true,
"lastEditedBy": "Andy Haynes",
"lastEditedAt": "2023-02-21T18:13:15.474Z"
}
}
}
35 changes: 19 additions & 16 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@
},
"dependencies": {
"@ledgerhq/hw-transport-u2f": "^5.34.0",
"@near-wallet-selector/coin98-wallet": "^7.2.0",
"@near-wallet-selector/default-wallets": "^7.2.0",
"@near-wallet-selector/here-wallet": "^7.2.0",
"@near-wallet-selector/ledger": "^7.2.0",
"@near-wallet-selector/math-wallet": "^7.2.0",
"@near-wallet-selector/meteor-wallet": "^7.2.0",
"@near-wallet-selector/modal-ui": "^7.2.0",
"@near-wallet-selector/near-wallet": "^7.2.0",
"@near-wallet-selector/nearfi": "^7.2.0",
"@near-wallet-selector/neth": "^7.2.0",
"@near-wallet-selector/nightly": "^7.2.0",
"@near-wallet-selector/nightly-connect": "^7.2.0",
"@near-wallet-selector/opto-wallet": "^7.2.0",
"@near-wallet-selector/sender": "^7.2.0",
"@near-wallet-selector/wallet-connect": "^7.2.0",
"@near-wallet-selector/welldone-wallet": "^7.2.0",
"@near-wallet-selector/account-export": "^7.8.2",
"@near-wallet-selector/coin98-wallet": "^7.8.2",
"@near-wallet-selector/core": "^7.8.2",
"@near-wallet-selector/default-wallets": "^7.8.2",
"@near-wallet-selector/here-wallet": "^7.8.2",
"@near-wallet-selector/ledger": "^7.8.2",
"@near-wallet-selector/math-wallet": "^7.8.2",
"@near-wallet-selector/meteor-wallet": "^7.8.2",
"@near-wallet-selector/modal-ui": "^7.8.2",
"@near-wallet-selector/my-near-wallet": "^7.8.2",
"@near-wallet-selector/near-wallet": "^7.8.2",
"@near-wallet-selector/nearfi": "^7.8.2",
"@near-wallet-selector/neth": "^7.8.2",
"@near-wallet-selector/nightly": "^7.8.2",
"@near-wallet-selector/nightly-connect": "^7.8.2",
"@near-wallet-selector/opto-wallet": "^7.8.2",
"@near-wallet-selector/sender": "^7.8.2",
"@near-wallet-selector/wallet-connect": "^7.8.2",
"@near-wallet-selector/welldone-wallet": "^7.8.2",
"@near-wallet/feature-flags": "^0.2.0",
"@reduxjs/toolkit": "1.6.2",
"@sentry/browser": "^6.4.1",
Expand Down
7 changes: 5 additions & 2 deletions packages/frontend/src/components/Routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { connect } from 'react-redux';
import { Redirect, Switch } from 'react-router-dom';
import styled, { ThemeProvider } from 'styled-components';

import { SHOW_MIGRATION_BANNER, WEB3AUTH, WEP_PHASE_ONE } from '../../../../features';
import { SHOW_MIGRATION_BANNER, WEB3AUTH, WEP_DISABLE_ACCOUNT_CREATION, WEP_PHASE_ONE } from '../../../../features';
import favicon from '../../src/images/mynearwallet-cropped.svg';
import TwoFactorVerifyModal from '../components/accounts/two_factor/TwoFactorVerifyModal';
import {
Expand All @@ -37,6 +37,7 @@ import { VerifyOwnerWrapper } from '../routes/VerifyOwnerWrapper';
import { WalletWrapper } from '../routes/WalletWrapper';
import translations_en from '../translations/en.global.json';
import translations_it from '../translations/it.global.json';
import translations_kr from '../translations/kr.global.json';
import translations_pt from '../translations/pt.global.json';
import translations_ru from '../translations/ru.global.json';
import translations_tr from '../translations/tr.global.json';
Expand Down Expand Up @@ -162,6 +163,7 @@ class Routing extends Component {
{ name: '繁體中文', code: 'zh-hant' },
{ name: 'Türkçe', code: 'tr' },
{ name: 'Українська', code: 'ua' },
{ name: '한국어', code: 'kr' }
];

const browserLanguage = getBrowserLocale(languages.map((l) => l.code));
Expand Down Expand Up @@ -203,6 +205,7 @@ class Routing extends Component {
this.props.addTranslationForLanguage(translations_zh_hant, 'zh-hant');
this.props.addTranslationForLanguage(translations_tr, 'tr');
this.props.addTranslationForLanguage(translations_ua, 'ua');
this.props.addTranslationForLanguage(translations_kr, 'kr');

this.props.setActiveLanguage(activeLang);
// this.addTranslationsForActiveLanguage(defaultLanguage)
Expand Down Expand Up @@ -457,7 +460,7 @@ class Routing extends Component {
exact
path="/create"
render={(props) => {
if (WEP_PHASE_ONE) {
if (WEP_DISABLE_ACCOUNT_CREATION) {
return this.props.history.push('/');
} else {
if (accountFound || !DISABLE_CREATE_ACCOUNT) {
Expand Down
22 changes: 15 additions & 7 deletions packages/frontend/src/components/common/MigrationBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styled from 'styled-components';

import IconOffload from '../../images/IconOffload';
import { selectAvailableAccounts, selectAvailableAccountsIsLoading } from '../../redux/slices/availableAccounts';
import { getMyNearWalletUrl } from '../../utils/getWalletURL';
import { getNearOrgWalletUrl } from '../../utils/getWalletURL';
import AlertTriangleIcon from '../svg/AlertTriangleIcon';
import InfoIcon from '../svg/InfoIcon';
import FormButton from './FormButton';
Expand Down Expand Up @@ -80,7 +80,7 @@ const ContentWrapper = styled(Container)`
flex-wrap: none;
color: #CD2B31;
> span > a {
> div > span > a {
color: #CD2B31;
text-decoration: underline;
}
Expand Down Expand Up @@ -113,6 +113,8 @@ const MigrationBanner = ({ account, onTransfer }) => {
const availableAccounts = useSelector(selectAvailableAccounts);
const availableAccountsIsLoading = useSelector(selectAvailableAccountsIsLoading);

const walletUrl = getNearOrgWalletUrl().replace('https://', '');

const onTransferClick = useCallback(() => {
if (availableAccounts.length) {
onTransfer();
Expand All @@ -134,11 +136,17 @@ const MigrationBanner = ({ account, onTransfer }) => {
<div className='alert-container'>
<AlertTriangleIcon color={'#E5484D'} />
</div>
{
availableAccounts.length
? <Translate id='migration.message'/>
: <Translate id='migration.redirect' data={{ url: getMyNearWalletUrl() }}/>
}
<div>
{
availableAccounts.length
? <Translate id='migration.message' data={{ walletUrl }}/>
: <Translate id='migration.redirect' data={{ walletUrl }}/>
}
<br />
<br />
{availableAccounts.length > 0 && <Translate id='migration.readMore' />}

</div>
</div>

<CustomButton onClick={onTransferClick}>
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/components/landing/GuestLanding.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { Translate } from 'react-localize-redux';
import styled from 'styled-components';

import { WEP_PHASE_ONE } from '../../../../../features';
import { WEP_DISABLE_ACCOUNT_CREATION, WEP_PHASE_ONE } from '../../../../../features';
import iPhoneMockup from '../../images/iphone-mockup.png';
import FormButton from '../common/FormButton';
import Container from '../common/styled/Container.css';
Expand Down Expand Up @@ -164,7 +164,7 @@ export function GuestLanding({ history }) {
<div className='buttons'>
<FormButton
onClick={() => {
if (WEP_PHASE_ONE) {
if (WEP_DISABLE_ACCOUNT_CREATION) {
setShowModal('more-near-wallets');
} else {
history.push('/create');
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/components/navigation/Navigation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useEffect, useCallback } from 'react';
import styled from 'styled-components';

import { WEP_PHASE_ONE } from '../../../../../features';
import { WEP_DISABLE_ACCOUNT_CREATION } from '../../../../../features';
import { WalletSelectorGetAWallet } from '../common/wallet_selector/WalletSelectorGetAWallet';
import DesktopContainer from './DesktopContainer';
import MobileContainer from './MobileContainer';
Expand Down Expand Up @@ -89,7 +89,7 @@ export default ({
}, []);

const handleOnClickCreateNewAccount = () => {
if (WEP_PHASE_ONE) {
if (WEP_DISABLE_ACCOUNT_CREATION) {
setShowModal('more-near-wallets');
} else {
history.push('/create');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { MigrationModal } from './CommonComponents';
import CleanKeysModal from './modals/CleanKeysModal/CleanKeysModal';
import Disable2FAModal from './modals/Disable2faModal/Disable2FA';
import LogoutModal from './modals/LogoutModal/LogoutModal';
import MigrateAccountsModal from './modals/MigrateAccountsModal/MigrateAccountsModal';
import RedirectingModal from './modals/RedirectingModal/RedirectingModal';
import RotateKeysModal from './modals/RotateKeysModal/RotateKeysModal';
import VerifyingModal from './modals/VerifyingModal/VerifyingModal';
import { WalletSelectorModal } from './modals/WalletSelectorModal/WalletSelectorModal';
import { deleteMigrationStep, getAccountDetails, getMigrationStep, setMigrationStep } from './utils';


Expand Down Expand Up @@ -59,10 +59,6 @@ const WalletMigration = ({ open, onClose }) => {
setState({...state, ...newState});
};

const handleSetWallet = (wallet) => {
handleStateUpdate({ wallet });
};

const handleSetActiveView = useCallback((activeView) => {
handleStateUpdate({ activeView });
}, [handleStateUpdate]);
Expand Down Expand Up @@ -91,6 +87,7 @@ const WalletMigration = ({ open, onClose }) => {

const navigateToVerifying = () => {
handleSetActiveView(WALLET_MIGRATION_VIEWS.VERIFYING);
setMigrationStep(WALLET_MIGRATION_VIEWS.VERIFYING);
};

const navigateToLogOut = () => {
Expand All @@ -99,6 +96,7 @@ const WalletMigration = ({ open, onClose }) => {
};

const navigateToMigrateAccounts = () => {
setMigrationStep(WALLET_MIGRATION_VIEWS.MIGRATE_ACCOUNTS);
handleSetActiveView(WALLET_MIGRATION_VIEWS.MIGRATE_ACCOUNTS);
};

Expand Down Expand Up @@ -172,15 +170,10 @@ const WalletMigration = ({ open, onClose }) => {
/>
)}
{state.activeView === WALLET_MIGRATION_VIEWS.MIGRATE_ACCOUNTS && (
<MigrateAccountsModal
onClose={onClose}
handleSetActiveView={handleSetActiveView}
handleSetWallet={handleSetWallet}
state={state}
data-test-id="migrateAccountsModal"
rotatedKeys={rotatedKeys}
onNext={navigateToRedirect}
accountWithDetails={accountWithDetails}
<WalletSelectorModal
onComplete={navigateToRedirect}
migrationAccounts={accountWithDetails}
network={NETWORK_ID === 'default' ? 'testnet': NETWORK_ID}
/>
)}
{state.activeView === WALLET_MIGRATION_VIEWS.REDIRECTING && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ async function getAccountDetails({ accountId, publicKeyBlacklist, wallet }) {
}, {});

const allAccessKeys = await wallet.getAccessKeys(accountId);
const publicKey = await wallet.getPublicKey(accountId);
const signingPublicKey = await wallet.getPublicKey();
const accessKeys = allAccessKeys
.filter(({ public_key }) =>
!publicKeyBlacklist.some((key) => key === public_key)
&& public_key !== publicKey.toString()
&& public_key !== signingPublicKey.toString()
&& recoveryMethods[public_key] !== 'ledger'
)
.map(({ public_key }) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useEffect } from 'react';

import { useExportAccountSelector } from './WalletSelectorExportContext';

export const WalletSelectorContent = () => {
const { ExportModal } = useExportAccountSelector();

useEffect(() => {
//TODO: this is to mute css class injected from WalletSelectorGetAWallet component
const walletWrapperDiv = document.getElementById('near-wallet-selector-modal');
walletWrapperDiv?.classList.remove('wallet-selector-get-a-wallet-modal');
ExportModal?.show();
});
return null;
};
Loading

0 comments on commit 7b7f715

Please sign in to comment.