Skip to content

Commit

Permalink
Merge pull request #2768 from near/master
Browse files Browse the repository at this point in the history
2022-06-20 Release
  • Loading branch information
andy-haynes authored Jun 20, 2022
2 parents b3eb602 + ec7a101 commit 64c0870
Show file tree
Hide file tree
Showing 41 changed files with 1,647 additions and 328 deletions.
1 change: 1 addition & 0 deletions features/features.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
export type Features = {
CREATE_USN_CONTRACT: boolean;
DONATE_TO_UKRAINE: boolean;
SHOW_MIGRATION_BANNER: boolean;
};
44 changes: 44 additions & 0 deletions features/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,49 @@
"lastEditedBy": "esaminu",
"lastEditedAt": "2022-05-10T17:07:20.351Z"
}
},
"SHOW_MIGRATION_BANNER": {
"createdBy": "gutsyphilip",
"createdAt": "2022-05-25T01:11:55.121Z",
"development": {
"enabled": false,
"lastEditedBy": "esaminu",
"lastEditedAt": "2022-06-20T18:11:26.582Z"
},
"testnet": {
"enabled": false,
"lastEditedBy": "esaminu",
"lastEditedAt": "2022-06-20T18:11:26.582Z"
},
"mainnet": {
"enabled": false,
"lastEditedBy": "gutsyphilip",
"lastEditedAt": "2022-05-25T01:11:55.121Z"
},
"mainnet_STAGING": {
"enabled": false,
"lastEditedBy": "gutsyphilip",
"lastEditedAt": "2022-05-25T01:11:55.121Z"
},
"testnet_STAGING": {
"enabled": false,
"lastEditedBy": "gutsyphilip",
"lastEditedAt": "2022-05-25T01:11:55.121Z"
},
"testnet_NEARORG": {
"enabled": false,
"lastEditedBy": "esaminu",
"lastEditedAt": "2022-06-20T18:11:26.582Z"
},
"mainnet_NEARORG": {
"enabled": false,
"lastEditedBy": "esaminu",
"lastEditedAt": "2022-06-20T18:11:26.582Z"
},
"mainnet_STAGING_NEARORG": {
"enabled": false,
"lastEditedBy": "esaminu",
"lastEditedAt": "2022-06-20T18:11:26.582Z"
}
}
}
4 changes: 4 additions & 0 deletions packages/frontend/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
setupFilesAfterEnv: ['./jest.setup.js'],
setupFiles: ['dotenv/config'],
testEnvironment: 'jsdom',
moduleNameMapper: {
'^.+\\.svg$': 'jest-svg-transformer'
}
};
2 changes: 1 addition & 1 deletion packages/frontend/netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
NETLIFY_USE_YARN = "true"

[context.production.environment]
BROWSER_MIXPANEL_TOKEN = "d5bbbbcc3a77ef8427f2b806b5689bf8"
BROWSER_MIXPANEL_TOKEN = "7c5730e5b3556a06b73829b3c3b40a86"
SENTRY_PROJECT = "mainnet-wallet"

[[headers]]
Expand Down
4 changes: 3 additions & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"regenerator-runtime": "^0.13.5",
"reselect": "^4.0.0",
"styled-components": "^5.3.0",
"timeago.js": "^4.0.2"
"timeago.js": "^4.0.2",
"use-immer": "^0.7.0"
},
"scripts": {
"predeploy": "yarn build",
Expand Down Expand Up @@ -105,6 +106,7 @@
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.23.2",
"jest": "^27.0.1",
"jest-svg-transformer": "^1.0.0",
"parcel-bundler": "^1.12.4",
"parcel-plugin-bundle-visualiser": "^1.2.0",
"react-is": "^17.0.2"
Expand Down
22 changes: 21 additions & 1 deletion packages/frontend/src/components/Routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { ConnectedRouter, getRouter } from 'connected-react-router';
import isString from 'lodash.isstring';
import { parseSeedPhrase } from 'near-seed-phrase';
import PropTypes from 'prop-types';
import { stringify } from 'query-string';
import { parse, stringify } from 'query-string';
import React, { Component } from 'react';
import ReactDOMServer from 'react-dom/server';
import { withLocalize } from 'react-localize-redux';
import { connect } from 'react-redux';
import { Redirect, Switch } from 'react-router-dom';
import styled, { ThemeProvider } from 'styled-components';

import { SHOW_MIGRATION_BANNER } from '../../../../features';
import favicon from '../../src/images/mynearwallet-cropped.svg';
import TwoFactorVerifyModal from '../components/accounts/two_factor/TwoFactorVerifyModal';
import {
Expand Down Expand Up @@ -54,6 +55,7 @@ import {
} from '../utils/wallet';
import AccessKeysWrapper from './access-keys/v2/AccessKeysWrapper';
import { AutoImportWrapper } from './accounts/auto_import/AutoImportWrapper';
import BatchImportAccounts from './accounts/batch_import_accounts';
import { ExistingAccountWrapper } from './accounts/create/existing_account/ExistingAccountWrapper';
import { InitialDepositWrapper } from './accounts/create/initial_deposit/InitialDepositWrapper';
import { CreateAccountLanding } from './accounts/create/landing/CreateAccountLanding';
Expand All @@ -75,6 +77,7 @@ import { BuyNear } from './buy/BuyNear';
import Footer from './common/Footer';
import GlobalAlert from './common/GlobalAlert';
import GuestLandingRoute from './common/GuestLandingRoute';
import MigrationBanner from './common/MigrationBanner';
import NetworkBanner from './common/NetworkBanner';
import PrivateRoute from './common/routing/PrivateRoute';
import PublicRoute from './common/routing/PublicRoute';
Expand Down Expand Up @@ -338,6 +341,8 @@ class Routing extends Component {
>
<ThemeProvider theme={theme}>
<ScrollToTop />
{SHOW_MIGRATION_BANNER && <MigrationBanner account={account}/>}

<NetworkBanner account={account} />
<NavigationWrapper />
<GlobalAlert />
Expand Down Expand Up @@ -559,6 +564,21 @@ class Routing extends Component {
);
}}
/>
<Route exact path="/batch-import" render={(({location}) => {
let { keys, accounts, ledgerHdPaths } = parse(location.hash, {arrayFormat: 'comma'});
if (!keys || !accounts) return <PageNotFound />;

// if single key or account param make an array of it
keys = Array.isArray(keys) ? keys : [keys];
accounts = Array.isArray(accounts) ? accounts : [accounts];
ledgerHdPaths = Array.isArray(ledgerHdPaths) ? ledgerHdPaths : [ledgerHdPaths];

const accountIdToKeyMap = accounts.reduce((acc, curr) => {
const [ accountId, keyIndex, ledgerHdPathIndex ] = curr.split('*');
return { ...acc, [accountId]: {key: keys[keyIndex], ledgerHdPath: ledgerHdPaths?.[ledgerHdPathIndex]} };
}, {});
return <BatchImportAccounts accountIdToKeyMap={accountIdToKeyMap} onCancel={() => this.props.history.replace('/')}/>;
})} />
<Route
exact
path="/sign-in-ledger"
Expand Down
215 changes: 215 additions & 0 deletions packages/frontend/src/components/accounts/AccountListImport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
import React from 'react';
import { Translate } from 'react-localize-redux';
import styled from 'styled-components';

import IconArrowRight from '../../images/IconArrowRight';
import IconCheck from '../../images/IconCheck';
import IconClose from '../../images/IconClose';
import UserIconGrey from '../../images/UserIconGrey';

const UserIcon = styled.div`
background-size: 21px;
flex: 0 0 40px;
height: 40px;
border-radius: 50%;
background-color: #f8f8f8;
text-align: center;
margin: 0 12px 0 0;
svg {
width: 26px;
height: 26px;
margin: 7px;
}
@media (min-width: 940px) {
display: inline-block;
}
`;

const AnimateList = styled.div`
margin-top: 10px;
overflow: hidden;
height: unset;
& > div:first-of-type {
margin-top: ${(props) => `-${props.animate * 60}px`};
transition: 1s;
}
.accountId {
overflow: hidden;
font-size: 14px;
text-overflow: ellipsis;
}
.status {
> svg {
width: 12px;
height: 12px;
}
}
.row {
border-top: 2px solid #f5f5f5;
display: flex;
height: 60px;
align-items: center;
&.success .status {
> svg {
width: 24px;
height: 24px;
}
&.onclick {
> svg {
width: 12px;
height: 12px;
}
}
}
&.rejected .status {
background: #f4f4f4;
color: #de2e32;
}
&.confirm .status {
background: #f4c898;
color: #ae6816;
text-align: left;
padding: 0 0 0 10px;
flex: 0 0 140px;
:after {
content: '.';
animation: dots 1s steps(5, end) infinite;
@keyframes dots {
0%, 20% {
color: rgba(0,0,0,0);
text-shadow:
.3em 0 0 rgba(0,0,0,0),
.6em 0 0 rgba(0,0,0,0);
}
40% {
color: #ae6816;
text-shadow:
.3em 0 0 rgba(0,0,0,0),
.6em 0 0 rgba(0,0,0,0);
}
60% {
text-shadow:
.3em 0 0 #ae6816,
.6em 0 0 rgba(0,0,0,0);
}
80%, 100% {
text-shadow:
.3em 0 0 #ae6816,
.6em 0 0 #ae6816;
}
}
}
}
&.pending .status {
background: #f4c898;
color: #ae6816;
text-align: left;
padding: 0 0 0 10px;
flex: 0 0 82px;
:after {
content: '.';
animation: dots 1s steps(5, end) infinite;
@keyframes dots {
0%, 20% {
color: rgba(0,0,0,0);
text-shadow:
.3em 0 0 rgba(0,0,0,0),
.6em 0 0 rgba(0,0,0,0);
}
40% {
color: #ae6816;
text-shadow:
.3em 0 0 rgba(0,0,0,0),
.6em 0 0 rgba(0,0,0,0);
}
60% {
text-shadow:
.3em 0 0 #ae6816,
.6em 0 0 rgba(0,0,0,0);
}
80%, 100% {
text-shadow:
.3em 0 0 #ae6816,
.6em 0 0 #ae6816;
}
}
}
}
&.waiting {
.status {
background: #f8f8f8;
color: #aaaaaa;
}
> div:first-of-type {
opacity: 0.4;
}
h3 {
color: #aaaaaa !important;
}
}
.right-arrow {
width: 24px;
height: 24px;
}
.status {
flex: 0 0 72px;
margin-left: auto;
height: 24px;
border-radius: 12px;
text-align: center;
font-size: 12px;
line-height: 24px;
}
}
`;

const AccountListImport = ({ accounts = [], animationScope = 0, onClickAccount }) => (
<AnimateList animate={animationScope}>
{accounts.map((account) => (
<div
key={account.accountId}
className={`row ${account.status}`}
onClick={() => onClickAccount ? onClickAccount(account) : null}
style={{ cursor: onClickAccount ? 'pointer' : 'default' }}
>
<UserIcon>
<UserIconGrey color='#9a9a9a' />
</UserIcon>
<div className='accountId'>
{account.accountId}
</div>
{onClickAccount ? <div className='status onclick'><IconArrowRight stroke="#0072CE" /></div> : null}
{account.status && !onClickAccount ?
<div className='status'>
<StatusIcon status={account.status}/>
</div>
: null}
</div>
))}
</AnimateList>
);

const StatusIcon = ({status}) => {
if (status === 'success') {
return <IconCheck color='#5ace84' stroke='3px' />;
} else if (status === 'error') {
return <IconClose stroke="#FC5B5B" />;
}
return <Translate id={`signInLedger.modal.status.${status}`}/>;
};

export default AccountListImport;
Loading

0 comments on commit 64c0870

Please sign in to comment.