Skip to content

Commit

Permalink
Merge pull request #623 from MyEtherWallet/develop
Browse files Browse the repository at this point in the history
Tag Release 0.0.6
  • Loading branch information
dternyak authored Dec 19, 2017
2 parents 38f09e2 + 820f545 commit 6944889
Show file tree
Hide file tree
Showing 420 changed files with 10,741 additions and 6,520 deletions.
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 100,
"singleQuote": true,
"useTabs": false,
"semi": true,
"tabWidth": 2,
"trailingComma":
"none"
}
30 changes: 22 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,36 @@ dist: trusty
sudo: required
language: node_js

cache:
directories:
- node_modules

services:
- docker

before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- docker pull dternyak/eth-priv-to-addr:latest

install:
- npm install --silent

jobs:
include:
- stage: test
script: npm run test
- stage: test
script: npm run tslint
- stage: test
script: npm run tscheck
- stage: test
script: npm run freezer
- stage: test
script: npm run freezer:validate

notifications:
email:
on_success: never
on_failure: never

script:
- npm run test
- npm run tslint
- npm run tscheck
- npm run freezer
- npm run freezer:validate
on_failure: never
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ npm run build # build app

It generates app in `dist` folder.

#### Test:
#### Unit Tests:

```bash
npm run test # run tests with Jest
```

#### Integration Tests:

```bash
npm run test:int # run tests with Jest
```

#### Dev (HTTPS):

1. Create your own SSL Certificate (Heroku has a [nice guide here](https://devcenter.heroku.com/articles/ssl-certificate-self))
Expand All @@ -32,7 +38,13 @@ npm run test # run tests with Jest
npm run dev:https
```

#### Derivation Check:
#### Address Derivation Checker:
EthereumJS-Util previously contained a bug that would incorrectly derive addresses from private keys with a 1/128 probability of occurring. A summary of this issue can be found [here](https://www.reddit.com/r/ethereum/comments/48rt6n/using_myetherwalletcom_just_burned_me_for/d0m4c6l/).

As a reactionary measure, the address derivation checker was created.

To test for correct address derivation, the address derivation checker uses multiple sources of address derivation (EthereumJS and PyEthereum) to ensure that multiple official implementations derive the same address for any given private key.

##### The derivation checker utility assumes that you have:
1. Docker installed/available
2. [dternyak/eth-priv-to-addr](https://hub.docker.com/r/dternyak/eth-priv-to-addr/) pulled from DockerHub
Expand All @@ -41,9 +53,12 @@ npm run dev:https
1. Install docker (on macOS, [Docker for Mac](https://docs.docker.com/docker-for-mac/) is suggested)
2. `docker pull dternyak/eth-priv-to-addr`


##### Run Derivation Checker
The derivation checker utility runs as part of the integration test suite.

```bash
npm run derivation-checker
npm run test:int
```

## Folder structure:
Expand Down
37 changes: 27 additions & 10 deletions common/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,53 @@ import GenerateWallet from 'containers/Tabs/GenerateWallet';
import Help from 'containers/Tabs/Help';
import SendTransaction from 'containers/Tabs/SendTransaction';
import Swap from 'containers/Tabs/Swap';
import ViewWallet from 'containers/Tabs/ViewWallet';
import SignAndVerifyMessage from 'containers/Tabs/SignAndVerifyMessage';
import BroadcastTx from 'containers/Tabs/BroadcastTx';
import RestoreKeystore from 'containers/Tabs/RestoreKeystore';
import ErrorScreen from 'components/ErrorScreen';

// TODO: fix this
interface Props {
store: any;
history: any;
}

export default class Root extends Component<Props, {}> {
interface State {
error: Error | null;
}

export default class Root extends Component<Props, State> {
public state = {
error: null
};

public componentDidCatch(error) {
this.setState({ error });
}

public render() {
const { store, history } = this.props;
const { error } = this.state;

if (error) {
return <ErrorScreen error={error} />;
}

// key={Math.random()} = hack for HMR from https://github.com/webpack/webpack-dev-server/issues/395
return (
<Provider store={store} key={Math.random()}>
<Router history={history} key={Math.random()}>
<div>
<Route exact={true} path="/" component={GenerateWallet} />
<Route path="/view-wallet" component={ViewWallet} />
<Route path="/help" component={Help} />
<Route path="/swap" component={Swap} />
<Route path="/account" component={SendTransaction}>
<Route path="send" component={SendTransaction} />
<Route path="info" component={SendTransaction} />
</Route>
<Route path="/send-transaction" component={SendTransaction} />
<Route path="/contracts" component={Contracts} />
<Route path="/ens" component={ENS} />
<Route path="/utilities" component={RestoreKeystore} />
<Route
path="/sign-and-verify-message"
component={SignAndVerifyMessage}
/>
<Route path="/sign-and-verify-message" component={SignAndVerifyMessage} />
<Route path="/pushTx" component={BroadcastTx} />
<LegacyRoutes />
</div>
Expand Down Expand Up @@ -71,7 +87,7 @@ const LegacyRoutes = withRouter(props => {
history.push('/ens');
break;
case '#view-wallet-info':
history.push('/view-wallet');
history.push('/account/info');
break;
case '#check-tx-status':
history.push('/check-tx-status');
Expand All @@ -83,6 +99,7 @@ const LegacyRoutes = withRouter(props => {
<Switch>
<Redirect from="/signmsg.html" to="/sign-and-verify-message" />
<Redirect from="/helpers.html" to="/helpers" />
<Redirect from="/send-transaction" to="/account/send" />
</Switch>
);
});
33 changes: 6 additions & 27 deletions common/actions/config/actionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,13 @@ export function changeLanguage(sign: string): interfaces.ChangeLanguageAction {
}

export type TChangeNode = typeof changeNode;
export function changeNode(
nodeSelection: string,
node: NodeConfig
): interfaces.ChangeNodeAction {
export function changeNode(nodeSelection: string, node: NodeConfig): interfaces.ChangeNodeAction {
return {
type: TypeKeys.CONFIG_NODE_CHANGE,
payload: { nodeSelection, node }
};
}

export type TChangeGasPrice = typeof changeGasPrice;
export function changeGasPrice(value: number): interfaces.ChangeGasPriceAction {
return {
type: TypeKeys.CONFIG_GAS_PRICE,
payload: value
};
}

export type TPollOfflineStatus = typeof pollOfflineStatus;
export function pollOfflineStatus(): interfaces.PollOfflineStatus {
return {
Expand All @@ -51,39 +40,31 @@ export function pollOfflineStatus(): interfaces.PollOfflineStatus {
}

export type TChangeNodeIntent = typeof changeNodeIntent;
export function changeNodeIntent(
payload: string
): interfaces.ChangeNodeIntentAction {
export function changeNodeIntent(payload: string): interfaces.ChangeNodeIntentAction {
return {
type: TypeKeys.CONFIG_NODE_CHANGE_INTENT,
payload
};
}

export type TAddCustomNode = typeof addCustomNode;
export function addCustomNode(
payload: CustomNodeConfig
): interfaces.AddCustomNodeAction {
export function addCustomNode(payload: CustomNodeConfig): interfaces.AddCustomNodeAction {
return {
type: TypeKeys.CONFIG_ADD_CUSTOM_NODE,
payload
};
}

export type TRemoveCustomNode = typeof removeCustomNode;
export function removeCustomNode(
payload: CustomNodeConfig
): interfaces.RemoveCustomNodeAction {
export function removeCustomNode(payload: CustomNodeConfig): interfaces.RemoveCustomNodeAction {
return {
type: TypeKeys.CONFIG_REMOVE_CUSTOM_NODE,
payload
};
}

export type TAddCustomNetwork = typeof addCustomNetwork;
export function addCustomNetwork(
payload: CustomNetworkConfig
): interfaces.AddCustomNetworkAction {
export function addCustomNetwork(payload: CustomNetworkConfig): interfaces.AddCustomNetworkAction {
return {
type: TypeKeys.CONFIG_ADD_CUSTOM_NETWORK,
payload
Expand All @@ -101,9 +82,7 @@ export function removeCustomNetwork(
}

export type TSetLatestBlock = typeof setLatestBlock;
export function setLatestBlock(
payload: string
): interfaces.SetLatestBlockAction {
export function setLatestBlock(payload: string): interfaces.SetLatestBlockAction {
return {
type: TypeKeys.CONFIG_SET_LATEST_BLOCK,
payload
Expand Down
7 changes: 0 additions & 7 deletions common/actions/config/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ export interface ChangeNodeAction {
};
}

/*** Change gas price ***/
export interface ChangeGasPriceAction {
type: TypeKeys.CONFIG_GAS_PRICE;
payload: number;
}

/*** Poll offline status ***/
export interface PollOfflineStatus {
type: TypeKeys.CONFIG_POLL_OFFLINE_STATUS;
Expand Down Expand Up @@ -83,7 +77,6 @@ export interface Web3UnsetNodeAction {
export type ConfigAction =
| ChangeNodeAction
| ChangeLanguageAction
| ChangeGasPriceAction
| ToggleOfflineAction
| PollOfflineStatus
| ForceOfflineAction
Expand Down
1 change: 0 additions & 1 deletion common/actions/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export enum TypeKeys {
CONFIG_LANGUAGE_CHANGE = 'CONFIG_LANGUAGE_CHANGE',
CONFIG_NODE_CHANGE = 'CONFIG_NODE_CHANGE',
CONFIG_NODE_CHANGE_INTENT = 'CONFIG_NODE_CHANGE_INTENT',
CONFIG_GAS_PRICE = 'CONFIG_GAS_PRICE',
CONFIG_TOGGLE_OFFLINE = 'CONFIG_TOGGLE_OFFLINE',
CONFIG_FORCE_OFFLINE = 'CONFIG_FORCE_OFFLINE',
CONFIG_POLL_OFFLINE_STATUS = 'CONFIG_POLL_OFFLINE_STATUS',
Expand Down
1 change: 1 addition & 0 deletions common/actions/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './actionCreators';
export * from './actionTypes';
export * from './constants';
8 changes: 2 additions & 6 deletions common/actions/customTokens/actionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import * as interfaces from './actionTypes';
import { TypeKeys } from './constants';

export type TAddCustomToken = typeof addCustomToken;
export function addCustomToken(
payload: Token
): interfaces.AddCustomTokenAction {
export function addCustomToken(payload: Token): interfaces.AddCustomTokenAction {
return {
type: TypeKeys.CUSTOM_TOKEN_ADD,
payload
Expand All @@ -14,9 +12,7 @@ export function addCustomToken(

export type TRemoveCustomToken = typeof removeCustomToken;

export function removeCustomToken(
payload: string
): interfaces.RemoveCustomTokenAction {
export function removeCustomToken(payload: string): interfaces.RemoveCustomTokenAction {
return {
type: TypeKeys.CUSTOM_TOKEN_REMOVE,
payload
Expand Down
1 change: 1 addition & 0 deletions common/actions/customTokens/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './actionCreators';
export * from './actionTypes';
export * from './constants';
4 changes: 1 addition & 3 deletions common/actions/deterministicWallets/actionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ export function setDeterministicWallets(
};
}

export function setDesiredToken(
token: string | undefined
): interfaces.SetDesiredTokenAction {
export function setDesiredToken(token: string | undefined): interfaces.SetDesiredTokenAction {
return {
type: TypeKeys.DW_SET_DESIRED_TOKEN,
payload: token
Expand Down
4 changes: 1 addition & 3 deletions common/actions/generateWallet/actionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import * as interfaces from './actionTypes';
import { TypeKeys } from './constants';

export type TGenerateNewWallet = typeof generateNewWallet;
export function generateNewWallet(
password: string
): interfaces.GenerateNewWalletAction {
export function generateNewWallet(password: string): interfaces.GenerateNewWalletAction {
return {
type: TypeKeys.GENERATE_WALLET_GENERATE_WALLET,
wallet: generate(),
Expand Down
4 changes: 1 addition & 3 deletions common/actions/notifications/actionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export function showNotification(
}

export type TCloseNotification = typeof closeNotification;
export function closeNotification(
notification: types.Notification
): types.CloseNotificationAction {
export function closeNotification(notification: types.Notification): types.CloseNotificationAction {
return {
type: TypeKeys.CLOSE_NOTIFICATION,
payload: notification
Expand Down
4 changes: 1 addition & 3 deletions common/actions/notifications/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ export interface ShowNotificationAction {
}

/*** Union Type ***/
export type NotificationsAction =
| ShowNotificationAction
| CloseNotificationAction;
export type NotificationsAction = ShowNotificationAction | CloseNotificationAction;
4 changes: 1 addition & 3 deletions common/actions/rates/actionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ export function fetchCCRates(symbols: string[] = []): interfaces.FetchCCRates {
}

export type TFetchCCRatesSucceeded = typeof fetchCCRatesSucceeded;
export function fetchCCRatesSucceeded(
payload: CCResponse
): interfaces.FetchCCRatesSucceeded {
export function fetchCCRatesSucceeded(payload: CCResponse): interfaces.FetchCCRatesSucceeded {
return {
type: TypeKeys.RATES_FETCH_CC_SUCCEEDED,
payload
Expand Down
10 changes: 6 additions & 4 deletions common/actions/rates/actionPayloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ export const fetchRates = (symbols: string[] = []): Promise<CCResponse> =>
// to their respective rates via ETH.
return symbols.reduce(
(eqRates, sym) => {
eqRates[sym] = rateSymbols.reduce((symRates, rateSym) => {
symRates[rateSym] = 1 / rates[sym] * rates[rateSym];
return symRates;
}, {});
if (rates[sym]) {
eqRates[sym] = rateSymbols.reduce((symRates, rateSym) => {
symRates[rateSym] = 1 / rates[sym] * rates[rateSym];
return symRates;
}, {});
}
return eqRates;
},
{
Expand Down
Loading

0 comments on commit 6944889

Please sign in to comment.