Skip to content

Commit eeb315c

Browse files
authored
Merge pull request #747 from MyEtherWallet/develop
Release 0.0.7
2 parents 6944889 + ff6747b commit eeb315c

File tree

291 files changed

+7702
-2600
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+7702
-2600
lines changed

.prettierrc

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
"useTabs": false,
55
"semi": true,
66
"tabWidth": 2,
7-
"trailingComma":
8-
"none"
7+
"trailingComma": "none"
98
}

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ install:
2020

2121
jobs:
2222
include:
23+
- stage: test
24+
script: npm run prettier:diff
2325
- stage: test
2426
script: npm run test
2527
- stage: test

README.md

+76-92
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,25 @@ npm run dev:https
3939
```
4040

4141
#### Address Derivation Checker:
42+
4243
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/).
4344

44-
As a reactionary measure, the address derivation checker was created.
45+
As a reactionary measure, the address derivation checker was created.
4546

4647
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.
4748

4849
##### The derivation checker utility assumes that you have:
50+
4951
1. Docker installed/available
5052
2. [dternyak/eth-priv-to-addr](https://hub.docker.com/r/dternyak/eth-priv-to-addr/) pulled from DockerHub
5153

5254
##### Docker setup instructions:
55+
5356
1. Install docker (on macOS, [Docker for Mac](https://docs.docker.com/docker-for-mac/) is suggested)
5457
2. `docker pull dternyak/eth-priv-to-addr`
5558

56-
5759
##### Run Derivation Checker
60+
5861
The derivation checker utility runs as part of the integration test suite.
5962

6063
```bash
@@ -84,7 +87,6 @@ npm run test:int
8487

8588
The following are guides for developers to follow for writing compliant code.
8689

87-
8890
### Redux and Actions
8991

9092
Each reducer has one file in `reducers/[namespace].ts` that contains the reducer
@@ -116,19 +118,20 @@ export function [namespace](
116118
return {
117119
...state,
118120
// Alterations to state
119-
};
121+
};
120122
default:
121123
return state;
122124
}
123125
}
124126
```
125127

126128
#### Actions
129+
127130
* Define each action creator in `actionCreator.ts`
128131
* Define each action object type in `actionTypes.ts`
129-
* Export a union of all of the action types for use by the reducer
130-
* Define each action type as a string enum in `constants.ts`
131-
* Export `actionCreators` and `actionTypes` from module file `index.ts`
132+
* Export a union of all of the action types for use by the reducer
133+
* Define each action type as a string enum in `constants.ts`
134+
* Export `actionCreators` and `actionTypes` from module file `index.ts`
132135

133136
```
134137
├── common
@@ -139,27 +142,30 @@ export function [namespace](
139142
├── constants.ts - string enum
140143
├── index.ts - exports all action creators and action object types
141144
```
145+
142146
##### constants.ts
147+
143148
```ts
144149
export enum TypeKeys {
145150
NAMESPACE_NAME_OF_ACTION = 'NAMESPACE_NAME_OF_ACTION'
146151
}
147152
```
153+
148154
##### actionTypes.ts
155+
149156
```ts
150157
/*** Name of action ***/
151158
export interface NameOfActionAction {
152-
type: TypeKeys.NAMESPACE_NAME_OF_ACTION,
153-
/* Rest of the action object shape */
154-
};
159+
type: TypeKeys.NAMESPACE_NAME_OF_ACTION;
160+
/* Rest of the action object shape */
161+
}
155162

156163
/*** Action Union ***/
157-
export type NamespaceAction =
158-
| ActionOneAction
159-
| ActionTwoAction
160-
| ActionThreeAction;
164+
export type NamespaceAction = ActionOneAction | ActionTwoAction | ActionThreeAction;
161165
```
166+
162167
##### actionCreators.ts
168+
163169
```ts
164170
import * as interfaces from './actionTypes';
165171
import { TypeKeys } from './constants';
@@ -172,7 +178,9 @@ export function nameOfAction(): interfaces.NameOfActionAction {
172178
};
173179
};
174180
```
181+
175182
##### index.ts
183+
176184
```ts
177185
export * from './actionCreators';
178186
export * from './actionTypes';
@@ -215,60 +223,34 @@ conditional render.)
215223
### Higher Order Components
216224

217225
#### Typing Injected Props
218-
Props made available through higher order components can be tricky to type. Normally, if a component requires a prop, you add it to the component's interface and it just works. However, working with injected props from [higher order components](https://medium.com/@DanHomola/react-higher-order-components-in-typescript-made-simple-6f9b55691af1), you will be forced to supply all required props whenever you compose the component.
219-
220-
```ts
221-
interface MyComponentProps {
222-
name: string;
223-
countryCode?: string;
224-
routerLocation: { pathname: string };
225-
}
226226

227-
...
228-
229-
class OtherComponent extends React.Component<{}, {}> {
230-
render() {
231-
return (
232-
<MyComponent
233-
name="foo"
234-
countryCode="CA"
235-
// Error: 'routerLocation' is missing!
236-
/>
237-
);
238-
}
239-
```
240-
241-
Instead of tacking the injected props on the MyComponentProps interface, put them in another interface called `InjectedProps`:
227+
Props made available through higher order components can be tricky to type. You can inherit the injected props, and in the case of react router, specialize the generic in `withRouter` so it can omit all of its injected props from the component.
242228

243229
```ts
244-
interface MyComponentProps {
230+
import { RouteComponentProps } from 'react-router-dom';
231+
232+
interface MyComponentProps extends RouteComponentProps<{}> {
245233
name: string;
246234
countryCode?: string;
247235
}
248-
249-
interface InjectedProps {
250-
routerLocation: { pathname: string };
251-
}
252236
```
253237

254-
Now add a [getter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get) to cast `this.props` as the original props - `MyComponentProps` and the injected props - `InjectedProps`:
255-
256238
```ts
257239
class MyComponent extends React.Component<MyComponentProps, {}> {
258-
get injected() {
259-
return this.props as MyComponentProps & InjectedProps;
260-
}
261240

262241
render() {
263-
const { name, countryCode, routerLocation } = this.props;
242+
const { name, countryCode, location } = this.props; // location being the one of the injected props from the withRouter HOC
264243
...
265244
}
266245
}
246+
247+
export default withRouter<Props>(MyComponent);
267248
```
268249

269250
## Event Handlers
270251

271252
Event handlers such as `onChange` and `onClick`, should be properly typed. For example, if you have an event listener on an input element inside a form:
253+
272254
```ts
273255
public onValueChange = (e: React.FormEvent<HTMLInputElement>) => {
274256
if (this.props.onChange) {
@@ -279,6 +261,7 @@ public onValueChange = (e: React.FormEvent<HTMLInputElement>) => {
279261
}
280262
};
281263
```
264+
282265
Where you type the event as a `React.FormEvent` of type `HTML<TYPE>Element`.
283266

284267
## Class names
@@ -292,34 +275,34 @@ However, going forward, each styled component should create a a `.scss` file of
292275
the same name in the same folder, and import it like so:
293276

294277
```ts
295-
import React from "react";
278+
import React from 'react';
296279

297-
import "./MyComponent.scss";
280+
import './MyComponent.scss';
298281

299282
export default class MyComponent extends React.component<{}, {}> {
300-
render() {
301-
return (
302-
<div className="MyComponent">
303-
<div className="MyComponent-child">Hello!</div>
304-
</div>
305-
);
306-
}
283+
render() {
284+
return (
285+
<div className="MyComponent">
286+
<div className="MyComponent-child">Hello!</div>
287+
</div>
288+
);
289+
}
307290
}
308291
```
309292

310293
These style modules adhere to [SuitCSS naming convention](https://github.com/suitcss/suit/blob/master/doc/naming-conventions.md):
311294

312295
```scss
313296
.MyComponent {
314-
/* Styles */
297+
/* Styles */
315298

316-
&-child {
317-
/* Styles */
299+
&-child {
300+
/* Styles */
318301

319-
&.is-hidden {
320-
display: none;
321-
}
322-
}
302+
&.is-hidden {
303+
display: none;
304+
}
305+
}
323306
}
324307
```
325308

@@ -329,10 +312,10 @@ create a new namespace (Potentially breaking that out into its own component.)
329312
Variables and mixins can be imported from the files in `common/styles`:
330313

331314
```scss
332-
@import "sass/colors";
315+
@import 'sass/colors';
333316

334317
code {
335-
color: $code-color;
318+
color: $code-color;
336319
}
337320
```
338321

@@ -350,35 +333,36 @@ When working on a module that has styling in Less, try to do the following:
350333
* Ensure that there has been little to no deviation from screenshot
351334

352335
#### Adding Icon-fonts
336+
353337
1. Download chosen icon-font
354-
1. Declare css font-family:
355-
```
356-
@font-face {
357-
font-family: 'social-media';
358-
src: url('../assets/fonts/social-media.eot');
359-
src: url('../assets/fonts/social-media.eot') format('embedded-opentype'),
360-
url('../assets/fonts/social-media.woff2') format('woff2'),
361-
url('../assets/fonts/social-media.woff') format('woff'),
362-
url('../assets/fonts/social-media.ttf') format('truetype'),
363-
url('../assets/fonts/social-media.svg') format('svg');
364-
font-weight: normal;
365-
font-style: normal;
366-
}
367-
```
338+
1. Declare css font-family:
339+
```
340+
@font-face {
341+
font-family: 'social-media';
342+
src: url('../assets/fonts/social-media.eot');
343+
src: url('../assets/fonts/social-media.eot') format('embedded-opentype'),
344+
url('../assets/fonts/social-media.woff2') format('woff2'),
345+
url('../assets/fonts/social-media.woff') format('woff'),
346+
url('../assets/fonts/social-media.ttf') format('truetype'),
347+
url('../assets/fonts/social-media.svg') format('svg');
348+
font-weight: normal;
349+
font-style: normal;
350+
}
351+
```
368352
1. Create classes for each icon using their unicode character
369-
```
370-
.sm-logo-facebook:before {
371-
content: '\ea02';
372-
}
373-
```
374-
* [How to get unicode icon values?](https://stackoverflow.com/questions/27247145/get-the-unicode-icon-value-from-a-custom-font)
353+
```
354+
.sm-logo-facebook:before {
355+
content: '\ea02';
356+
}
357+
```
358+
* [How to get unicode icon values?](https://stackoverflow.com/questions/27247145/get-the-unicode-icon-value-from-a-custom-font)
375359
1. Write some markup:
376-
```
377-
<a href="/">
378-
<i className={`sm-icon sm-logo-${text} sm-24px`} />
379-
Hello World
380-
</a>
381-
```
360+
```
361+
<a href="/">
362+
<i className={`sm-icon sm-logo-${text} sm-24px`} />
363+
Hello World
364+
</a>
365+
```
382366

383367
## Thanks & Support
384368

0 commit comments

Comments
 (0)