* Refactor babel/types * Refactor entry point * Refactor actions * Refactor api * Full project refactor -- Broad type fixing sweep * - completely fix merge conflicts - handle various type errors * Add tslint to package.json * Dependency cleanup * Fix module resolution * Work on type definitions for untyped libs * progress commit * Add more definition typing * various type additions * Add unit types * Fix sagaiterator + unit types * various types added * additional type additions * Fix typing on Sagas * remove flowfixmes; swap translate for translateRaw * Get rid of contracts - awaiting Henry's contract PR * Remove contracts from routing * Fix most of actions/reducers * refactor actions directory structure * fix reducer action type imports * Fix most of type errors pre-actions refactor * fix action creator imports in containers * Refactor more * Refactor index of actions * fix action imports; use module level index export * package-lock.json updated * Use action types in props * Type up action creators * Fix most of connect errors * Typefixing progress * More types * Fix run-time errors * Caching improvements for webpack * Remove path resolve from webpack * Update non-breaking packages to latest version * Fix token typing * Remove unused color code * Fix wallet decrypt dispatch * Set redux-form related props/functions to ANY, since we're stripping it out later on * Revert BigNumber.js package changes * Extend window to custom object for Perf * Format Navigation * Typecase keystore errors as any (since we shouldnt touch this) * Push wallet context fix * - find/replace value->payload in swap - properly type swap state properties - extract inline reducer into reducer function * - type local storage retrieved items as generic * - bind all RPCClient methods with fat arrow * - reformat * Change to enums for constants * Change state into any * Fix swap errors * ensure that seconds are passed into state as integers * Fix rest of errors * use parseInt explicitly instead of type coercion * Fix derivation-checker, remove flow command, add tslint command, add tslint-react, tell travis to use tslint instead of flow. * Whoops, remove those tests. * Remove unsupported (yet) config option. * Fix precommit to target ts and tsx files. * Fix some errors, ignore some silly rules. * Revert jest to v19, use ts-jest and make all tests typescript. Fixes all but one. * Get rid of saga tests * Fix tslint errors
MyEtherWallet V4+ (ALPHA - VISIT V3 for the production site)
Run:
npm run dev # run app in dev mode
Build:
npm run build # build app
It generates app in dist
folder.
Test:
npm run test # run tests with Jest
Dev (HTTPS):
- Create your own SSL Certificate (Heroku has a nice guide here)
- Move the
.key
and.crt
files intowebpack_config/server.*
- Run the following command:
npm run dev:https
Derivation Check:
The derivation checker utility assumes that you have:
- Docker installed/available
- dternyak/eth-priv-to-addr pulled from DockerHub
Docker setup instructions:
- Install docker (on macOS, I suggest Docker for Mac)
docker pull dternyak/eth-priv-to-addr
Run Derivation Checker
npm run derivation-checker
Folder structure:
│
├── common - Your App
│ ├── actions - application actions
│ ├── api - Services and XHR utils(also custom form validation, see InputComponent from components/common)
│ ├── components - components according to "Redux philosophy"
│ ├── config - frontend config depending on REACT_WEBPACK_ENV
│ ├── containers - containers according to "Redux philosophy"
│ ├── reducers - application reducers
│ ├── routing - application routing
│ ├── index.jsx - entry
│ ├── index.html
├── static
├── webpack_config - Webpack configuration
├── jest_config - Jest configuration
Docker setup
You should already have docker and docker-compose setup for your platform as a pre-req.
docker-compose up
Style Guides and Philosophies
The following are guides for developers to follow for writing compliant code.
Redux and Actions
Each reducer has one file in reducers/[namespace].js
that contains the reducer
and initial state, one file in actions/[namespace].js
that contains the action
creators and their return types, and optionally one file in
sagas/[namespace].js
that handles action side effects using
redux-saga
.
The files should be laid out as follows:
Reducer
- State should be explicitly defined and exported
- Initial state should match state flow typing, define every key
- Reducer function should handle all cases for actions. If state does not change as a result of an action (Because it merely kicks off side-effects in saga) then define the case above default, and have it fall through.
// @flow
import type { NamespaceAction } from "actions/namespace";
export type State = { /* Flowtype definition for state object */ };
export const INITIAL_STATE: State = { /* Initial state shape */ };
export function namespace(
state: State = INITIAL_STATE,
action: NamespaceAction
): State {
switch (action.type) {
case 'NAMESPACE_NAME_OF_ACTION':
return {
...state,
// Alterations to state
};
case 'NAMESPACE_NAME_OF_SAGA_ACTION':
default:
// Ensures every action was handled in reducer
// Unhandled actions should just fall into default
(action: empty);
return state;
}
}
Actions
- Define each action object type beside the action creator
- Export a union of all of the action types for use by the reducer
/*** Name of action ***/
export type NameOfActionAction = {
type: 'NAMESPACE_NAME_OF_ACTION',
/* Rest of the action object shape */
};
export function nameOfAction(): NameOfActionAction {
return {
type: 'NAMESPACE_NAME_OF_ACTION',
/* Rest of the action object */
};
};
/*** Action Union ***/
export type NamespaceAction =
| ActionOneAction
| ActionTwoAction
| ActionThreeAction;
Action Constants
Action constants are not used thanks to flow type checking. To avoid typos, we
use (action: empty)
in the default case which assures every case is accounted
for. If you need to use another reducer's action, import that action type into
your reducer, and create a new action union of your actions, and the other
action types used.
Styling
Legacy styles are housed under common/assets/styles
and written with LESS.
However, going forward, each styled component should create a a .scss
file of
the same name in the same folder, and import it like so:
import React from "react";
import "./MyComponent.scss";
export default class MyComponent extends React.component {
render() {
return (
<div className="MyComponent">
<div className="MyComponent-child">Hello!</div>
</div>
);
}
}
These style modules adhere to SuitCSS naming convention:
.MyComponent {
/* Styles */
&-child {
/* Styles */
&.is-hidden {
display: none;
}
}
}
All elements inside of a component should extend its parent class namespace, or create a new namespace (Potentially breaking that out into its own component.)
Variables and mixins can be imported from the files in common/styles
:
@import "sass/colors";
code {
color: $code-color;
}
Converting Styles
When working on a module that has styling in Less, try to do the following:
- Screenshot the component in question
- Create a new SCSS file in the same directory
- Remove styling from LESS file, convert it to the SCSS file (Mostly s/@/$)
- Convert class names to SuitCSS naming convention
- Convert any utility classes from
etherewallet-utilities.less
into mixins - Convert as many element selectors to class name selectors as possible
- Convert as many
<br/>
tags or
s to margins - Ensure that there has been little to no deviation from screenshot