Prettier Reformat (#619)

* Add repo wide prettier command to prepush

* Make config file explict, remove formatAll to prepush
This commit is contained in:
HenryNguyen5 2017-12-18 18:29:26 -05:00 committed by Daniel Ternyak
parent 882d7ca164
commit da93fb1684
61 changed files with 158 additions and 480 deletions

View File

@ -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
@ -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

View File

@ -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

View File

@ -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(),

View File

@ -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

View File

@ -23,6 +23,4 @@ export interface ShowNotificationAction {
}
/*** Union Type ***/
export type NotificationsAction =
| ShowNotificationAction
| CloseNotificationAction;
export type NotificationsAction = ShowNotificationAction | CloseNotificationAction;

View File

@ -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

View File

@ -17,7 +17,4 @@ export interface FetchCCRatesFailed {
}
/*** Union Type ***/
export type RatesAction =
| FetchCCRates
| FetchCCRatesSucceeded
| FetchCCRatesFailed;
export type RatesAction = FetchCCRates | FetchCCRatesSucceeded | FetchCCRatesFailed;

View File

@ -25,23 +25,19 @@ export default class AlphaAgreement extends React.Component<{}, State> {
<div className="AlphaAgreement-content">
<h2>This is an Unstable Version of MEW</h2>
<p>
You are about to access an alpha version of MyEtherWallet that is
currently in development. In its current state, it should only be
used for testing, not for important transactions.
You are about to access an alpha version of MyEtherWallet that is currently in
development. In its current state, it should only be used for testing, not for important
transactions.
</p>
<p>
Any wallets you generate should not hold a significant value, and
any transactions you make should be for small amounts. MEW does not
claim responsibility for any issues that happen while using the
alpha version.
Any wallets you generate should not hold a significant value, and any transactions you
make should be for small amounts. MEW does not claim responsibility for any issues that
happen while using the alpha version.
</p>
<p>Are you sure you would like to continue?</p>
<div className="AlphaAgreement-content-buttons">
<button
className="AlphaAgreement-content-buttons-btn is-reject"
onClick={this.reject}
>
<button className="AlphaAgreement-content-buttons-btn is-reject" onClick={this.reject}>
No, Take Me to v3
</button>
<button

View File

@ -1,30 +1,20 @@
import { BlockExplorerConfig } from 'config/data';
import React from 'react';
import {translateRaw} from 'translations';
import { translateRaw } from 'translations';
export interface TransactionSucceededProps {
txHash: string;
blockExplorer: BlockExplorerConfig;
}
const TransactionSucceeded = ({
txHash,
blockExplorer
}: TransactionSucceededProps) => {
const TransactionSucceeded = ({ txHash, blockExplorer }: TransactionSucceededProps) => {
// const checkTxLink = `https://www.myetherwallet.com?txHash=${txHash}/#check-tx-status`;
const txHashLink = blockExplorer.tx(txHash);
return (
<div>
<p>
{translateRaw('SUCCESS_3') + txHash}
</p>
<a
className="btn btn-xs btn-info string"
href={txHashLink}
target="_blank"
rel="noopener"
>
<p>{translateRaw('SUCCESS_3') + txHash}</p>
<a className="btn btn-xs btn-info string" href={txHashLink} target="_blank" rel="noopener">
Verify Transaction
</a>
</div>

View File

@ -6,9 +6,9 @@ const PreFooter = () => {
<section className="pre-footer">
<div className="container">
<p>
MyEtherWallet.com does not hold your keys for you. We cannot access
accounts, recover keys, reset passwords, nor reverse transactions.
Protect your keys &amp; always check that you are on correct URL.
MyEtherWallet.com does not hold your keys for you. We cannot access accounts, recover
keys, reset passwords, nor reverse transactions. Protect your keys &amp; always check that
you are on correct URL.
<a href="#"> You are responsible for your security.</a>
</p>
</div>

View File

@ -139,9 +139,7 @@ export default class PaperWallet extends React.Component<Props, {}> {
<div style={{ float: 'left' }}>
<Identicon address={address} size={'42px'} />
</div>
<p style={styles.identiconText}>
Always look for this icon when sending to this wallet
</p>
<p style={styles.identiconText}>Always look for this icon when sending to this wallet</p>
</div>
</div>
);

View File

@ -42,21 +42,14 @@ export default class KeystoreDecrypt extends Component {
onChange={this.handleFileSelection}
/>
<label htmlFor="fselector" style={{ width: '100%' }}>
<a
className="btn btn-default btn-block"
id="aria1"
tabIndex={0}
role="button"
>
<a className="btn btn-default btn-block" id="aria1" tabIndex={0} role="button">
{translate('ADD_Radio_2_short')}
</a>
</label>
<div className={file.length && passReq ? '' : 'hidden'}>
<p>{translate('ADD_Label_3')}</p>
<input
className={`form-control ${
password.length > 0 ? 'is-valid' : 'is-invalid'
}`}
className={`form-control ${password.length > 0 ? 'is-valid' : 'is-invalid'}`}
value={password}
onChange={this.onPasswordChange}
onKeyDown={this.onKeyDown}

View File

@ -84,18 +84,14 @@ export class WalletDecrypt extends Component<Props, State> {
password: ''
},
unlock: this.props.unlockKeystore,
helpLink: `${
knowledgeBaseURL
}/private-keys-passwords/difference-beween-private-key-and-keystore-file.html`
helpLink: `${knowledgeBaseURL}/private-keys-passwords/difference-beween-private-key-and-keystore-file.html`
},
'mnemonic-phrase': {
lid: 'x_Mnemonic',
component: MnemonicDecrypt,
initialParams: {},
unlock: this.props.unlockMnemonic,
helpLink: `${
knowledgeBaseURL
}/private-keys-passwords/difference-beween-private-key-and-keystore-file.html`
helpLink: `${knowledgeBaseURL}/private-keys-passwords/difference-beween-private-key-and-keystore-file.html`
},
'private-key': {
lid: 'x_PrivKey2',
@ -105,9 +101,7 @@ export class WalletDecrypt extends Component<Props, State> {
password: ''
},
unlock: this.props.unlockPrivateKey,
helpLink: `${
knowledgeBaseURL
}/private-keys-passwords/difference-beween-private-key-and-keystore-file.html`
helpLink: `${knowledgeBaseURL}/private-keys-passwords/difference-beween-private-key-and-keystore-file.html`
},
'view-only': {
lid: 'View with Address Only',

View File

@ -17,9 +17,7 @@ export const withConditional = <WrappedComponentProps extends {}>(
public render() {
const { condition, conditionalProps, ...passedProps } = this.props as any;
return condition ? (
<PassedComponent
{...{ ...passedProps, ...(conditionalProps as object) }}
/>
<PassedComponent {...{ ...passedProps, ...(conditionalProps as object) }} />
) : (
<PassedComponent {...passedProps} />
);

View File

@ -8,8 +8,6 @@ interface Props {
export const GasQuery: React.SFC<Props> = ({ withQuery }) => (
<Query
params={['limit', 'gaslimit']}
withQuery={({ limit, gaslimit }) =>
withQuery({ gasLimit: limit || gaslimit })
}
withQuery={({ limit, gaslimit }) => withQuery({ gasLimit: limit || gaslimit })}
/>
);

View File

@ -14,16 +14,12 @@ class TokenQueryClass extends Component<Props, {}> {
return (
<Query
params={['tokenSymbol']}
withQuery={({ tokenSymbol }) =>
this.props.withQuery(this.paramGetter(tokenSymbol))
}
withQuery={({ tokenSymbol }) => this.props.withQuery(this.paramGetter(tokenSymbol))}
/>
);
}
private paramGetter = (unit: string | null) =>
unit
? { token: this.props.tokens.find(t => t.symbol === unit) }
: { token: null };
unit ? { token: this.props.tokens.find(t => t.symbol === unit) } : { token: null };
}
export const TokenQuery = connect((state: AppState) => ({

View File

@ -5,21 +5,11 @@ interface Props {
whenQueryExists: React.ReactElement<any> | null;
}
const params: Param[] = [
'to',
'data',
'tokenSymbol',
'value',
'gaslimit',
'limit',
'readOnly'
];
const params: Param[] = ['to', 'data', 'tokenSymbol', 'value', 'gaslimit', 'limit', 'readOnly'];
export const WhenQueryExists: React.SFC<Props> = ({ whenQueryExists }) => (
<Query
params={params}
withQuery={queries =>
Object.values(queries).some(v => !!v) ? whenQueryExists : null
}
withQuery={queries => (Object.values(queries).some(v => !!v) ? whenQueryExists : null)}
/>
);

View File

@ -58,16 +58,14 @@ export default class ColorDropdown<T> extends Component<Props<T>, {}> {
private renderOptions = () => {
const { options, value, menuAlign, extra } = this.props;
const listItems = options
.filter(opt => !opt.hidden)
.reduce((prev: any[], opt) => {
const prevOpt = prev.length ? prev[prev.length - 1] : null;
if (prevOpt && !prevOpt.divider && prevOpt.color !== opt.color) {
prev.push({ divider: true });
}
prev.push(opt);
return prev;
}, []);
const listItems = options.filter(opt => !opt.hidden).reduce((prev: any[], opt) => {
const prevOpt = prev.length ? prev[prev.length - 1] : null;
if (prevOpt && !prevOpt.divider && prevOpt.color !== opt.color) {
prev.push({ divider: true });
}
prev.push(opt);
return prev;
}, []);
const menuClass = classnames({
ColorDropdown: true,
@ -82,11 +80,7 @@ export default class ColorDropdown<T> extends Component<Props<T>, {}> {
return <li key={i} role="separator" className="divider" />;
} else {
return (
<li
key={i}
className="ColorDropdown-item"
style={{ borderColor: option.color }}
>
<li key={i} className="ColorDropdown-item" style={{ borderColor: option.color }}>
<a
className={option.value === value ? 'active' : ''}
onClick={this.onChange.bind(null, option.value)}
@ -118,10 +112,7 @@ export default class ColorDropdown<T> extends Component<Props<T>, {}> {
}
};
private onRemove(
onRemove: () => void,
ev?: React.SyntheticEvent<HTMLButtonElement>
) {
private onRemove(onRemove: () => void, ev?: React.SyntheticEvent<HTMLButtonElement>) {
if (ev) {
ev.preventDefault();
ev.stopPropagation();

View File

@ -1,7 +1,5 @@
import React from 'react';
import { withConditional } from 'components/hocs';
const Input: React.SFC<React.InputHTMLAttributes<any>> = props => (
<input {...props} />
);
const Input: React.SFC<React.InputHTMLAttributes<any>> = props => <input {...props} />;
export const ConditionalInput = withConditional(Input);

View File

@ -35,21 +35,9 @@ export default class DropdownComponent extends Component<Props, State> {
}
public render() {
const {
ariaLabel,
color,
disabled,
size,
renderOptions,
renderLabel
} = this.props;
const { ariaLabel, color, disabled, size, renderOptions, renderLabel } = this.props;
const { expanded } = this.state;
const toggleClasses = classnames([
'dropdown-toggle',
'btn',
`btn-${color}`,
`btn-${size}`
]);
const toggleClasses = classnames(['dropdown-toggle', 'btn', `btn-${color}`, `btn-${size}`]);
return (
<span

View File

@ -12,14 +12,7 @@ const Spinner = ({ size = 'x1', light = false }: SpinnerProps) => {
const color = light ? 'Spinner-light' : 'Spinner-dark';
return (
<svg className={`Spinner Spinner-${size} ${color}`} viewBox="0 0 50 50">
<circle
className="path"
cx="25"
cy="25"
r="20"
fill="none"
strokeWidth="5"
/>
<circle className="path" cx="25" cy="25" r="20" fill="none" strokeWidth="5" />
</svg>
);
};

View File

@ -35,14 +35,7 @@ const EXPANSE = {
const TREZOR = [ETH_TREZOR, ETC_TREZOR, TESTNET];
const MNEMONIC = [
ETH_DEFAULT,
ETH_LEDGER,
ETC_LEDGER,
ETC_TREZOR,
TESTNET,
EXPANSE
];
const MNEMONIC = [ETH_DEFAULT, ETH_LEDGER, ETC_LEDGER, ETC_TREZOR, TESTNET, EXPANSE];
const LEDGER = [ETH_LEDGER, ETC_LEDGER, TESTNET];

View File

@ -21,11 +21,7 @@ export default class NotificationRow extends Component<Props, {}> {
<div className={notifClass} role="alert" aria-live="assertive">
<span className="sr-only">{level}</span>
<div className="Notification-message">{msg}</div>
<button
className="Notification-close"
aria-label="dismiss"
onClick={this.onClose}
/>
<button className="Notification-close" aria-label="dismiss" onClick={this.onClose} />
</div>
);
}

View File

@ -1,8 +1,4 @@
import {
closeNotification,
Notification,
TCloseNotification
} from 'actions/notifications';
import { closeNotification, Notification, TCloseNotification } from 'actions/notifications';
import React from 'react';
import { connect } from 'react-redux';
import { TransitionGroup, CSSTransition } from 'react-transition-group';
@ -29,10 +25,7 @@ export class Notifications extends React.Component<Props, {}> {
{this.props.notifications.map(n => {
return (
<Transition key={n.id}>
<NotificationRow
notification={n}
onClose={this.props.closeNotification}
/>
<NotificationRow notification={n} onClose={this.props.closeNotification} />
</Transition>
);
})}

View File

@ -1,44 +1,28 @@
import React from 'react';
import { HeaderProps, ListProps, NodeProps, NodeState } from './types';
const InfoHeader = ({ children, onClickHandler }: HeaderProps) =>
const InfoHeader = ({ children, onClickHandler }: HeaderProps) => (
<h6 onClick={onClickHandler}>
<span>+</span> {children}
</h6>;
</h6>
);
const InfoList = ({ children, isOpen }: ListProps) =>
isOpen
? <ul>
{children}
</ul>
: null;
const InfoList = ({ children, isOpen }: ListProps) => (isOpen ? <ul>{children}</ul> : null);
export default class GeneralInfoNode extends React.Component<
NodeProps,
NodeState
> {
export default class GeneralInfoNode extends React.Component<NodeProps, NodeState> {
public state = {
isOpen: false
};
public toggleVisibility = () =>
this.setState(prevState => ({ isOpen: !prevState.isOpen }));
public toggleVisibility = () => this.setState(prevState => ({ isOpen: !prevState.isOpen }));
public render() {
const {
toggleVisibility,
props: { innerList, headerContent },
state: { isOpen }
} = this;
const { toggleVisibility, props: { innerList, headerContent }, state: { isOpen } } = this;
return (
<section>
<InfoHeader onClickHandler={toggleVisibility}>
{headerContent}
</InfoHeader>
<InfoList isOpen={isOpen}>
{innerList}
</InfoList>
<InfoHeader onClickHandler={toggleVisibility}>{headerContent}</InfoHeader>
<InfoList isOpen={isOpen}>{innerList}</InfoList>
</section>
);
}

View File

@ -2,23 +2,23 @@ import { NewTabLink } from 'components/ui';
import React from 'react';
import translate from 'translations';
const ENSDocsLink = () =>
const ENSDocsLink = () => (
<NewTabLink
href="http://ens.readthedocs.io/en/latest/introduction.html"
content="Ethereum Name Service"
/>;
/>
);
const ENSTitle = () =>
const ENSTitle = () => (
<article className="cont-md">
<h1 className="text-center">
{translate('NAV_ENS')}
</h1>
<h1 className="text-center">{translate('NAV_ENS')}</h1>
<p>
The <ENSDocsLink /> is a distributed, open, and extensible naming system
based on the Ethereum blockchain. Once you have a name, you can tell your
friends to send ETH to <code>mewtopia.eth</code> instead of
The <ENSDocsLink /> is a distributed, open, and extensible naming system based on the Ethereum
blockchain. Once you have a name, you can tell your friends to send ETH to{' '}
<code>mewtopia.eth</code> instead of
<code>0x7cB57B5A97eAbe942.....</code>.
</p>
</article>;
</article>
);
export default ENSTitle;

View File

@ -28,9 +28,7 @@ const BROWSERS = [
const CryptoWarning: React.SFC<{}> = () => (
<div className="Tab-content-pane">
<div className="CryptoWarning">
<h2 className="CryptoWarning-title">
Your Browser Cannot Generate a Wallet
</h2>
<h2 className="CryptoWarning-title">Your Browser Cannot Generate a Wallet</h2>
<p className="CryptoWarning-text">
{isMobile
? `
@ -55,13 +53,8 @@ const CryptoWarning: React.SFC<{}> = () => (
className="CryptoWarning-browsers-browser"
>
<div>
<img
className="CryptoWarning-browsers-browser-icon"
src={browser.icon}
/>
<div className="CryptoWarning-browsers-browser-name">
{browser.name}
</div>
<img className="CryptoWarning-browsers-browser-icon" src={browser.icon} />
<div className="CryptoWarning-browsers-browser-name">{browser.name}</div>
</div>
</NewTabLink>
))}

View File

@ -104,9 +104,7 @@ export default class DownloadWallet extends Component<Props, State> {
</li>
<li>
<NewTabLink
href={`${
knowledgeBaseURL
}/private-keys-passwords/difference-beween-private-key-and-keystore-file`}
href={`${knowledgeBaseURL}/private-keys-passwords/difference-beween-private-key-and-keystore-file`}
>
<strong>{translate('GEN_Help_14')}</strong>
</NewTabLink>

View File

@ -66,9 +66,7 @@ const help = (
</li>
<li>
<NewTabLink
href={`${
knowledgeBaseURL
}/private-keys-passwords/difference-beween-private-key-and-keystore-file`}
href={`${knowledgeBaseURL}/private-keys-passwords/difference-beween-private-key-and-keystore-file`}
>
<strong>{translate('GEN_Help_16')}</strong>
</NewTabLink>

View File

@ -12,15 +12,11 @@ export default class GenerateWalletTemplate extends React.Component<Props, {}> {
return (
<div className="GenerateWallet row">
<div className="GenerateWallet-column col-md-9">
<main className="GenerateWallet-column-content Tab-content-pane">
{content}
</main>
<main className="GenerateWallet-column-content Tab-content-pane">{content}</main>
</div>
<div className="GenerateWallet-column col-md-3">
<aside className="GenerateWallet-column-help Tab-content-pane">
{help}
</aside>
<aside className="GenerateWallet-column-help Tab-content-pane">{help}</aside>
</div>
</div>
);

View File

@ -15,16 +15,13 @@ export default class Donate extends React.Component<Props, State> {
public render() {
return (
<div className="well">
<p>
{translate('sidebar_donation')}
</p>
<p>{translate('sidebar_donation')}</p>
<a className="btn btn-primary btn-block" onClick={this.onClick}>
{translate('sidebar_donate')}
</a>
{this.state.clicked &&
<div className="text-success text-center marg-v-sm">
{translate('sidebar_thanks')}
</div>}
{this.state.clicked && (
<div className="text-success text-center marg-v-sm">{translate('sidebar_thanks')}</div>
)}
</div>
);
}

View File

@ -14,10 +14,7 @@ interface Props {
export default class SignMessageButton extends React.Component<Props, {}> {
public render() {
return (
<button
className="SignMessage-sign btn btn-primary btn-lg"
onClick={this.handleSignMessage}
>
<button className="SignMessage-sign btn btn-primary btn-lg" onClick={this.handleSignMessage}>
{translate('NAV_SignMsg')}
</button>
);

View File

@ -9,34 +9,21 @@ export interface SwapInfoHeaderTitleProps {
restartSwap(): RestartSwapAction;
}
export default class SwapInfoHeaderTitle extends Component<
SwapInfoHeaderTitleProps,
{}
> {
export default class SwapInfoHeaderTitle extends Component<SwapInfoHeaderTitleProps, {}> {
public render() {
return (
<section className="SwapInfo-top row text-center">
<div className="col-xs-3 text-left">
<button
className="SwapInfo-top-back"
onClick={this.props.restartSwap}
>
<button className="SwapInfo-top-back" onClick={this.props.restartSwap}>
<i className="fa fa-arrow-left" />
Start New Swap
</button>
</div>
<div className="col-xs-6">
<h3 className="SwapInfo-top-title">
{translate('SWAP_information')}
</h3>
<h3 className="SwapInfo-top-title">{translate('SWAP_information')}</h3>
</div>
<div className="col-xs-3">
<a
className="SwapInfo-top-logo"
href={bityReferralURL}
target="_blank"
rel="noopener"
>
<a className="SwapInfo-top-logo" href={bityReferralURL} target="_blank" rel="noopener">
<img className="SwapInfo-top-logo-img" src={bityLogo} />
</a>
</div>

View File

@ -17,11 +17,7 @@ const start = async () => {
const { frozen } = JSON.parse(packageStr);
if (frozen === undefined) {
console.log(
`Freezer: No config found in package.json on branch ${
ORACLE_BRANCH
}. Exiting.`
);
console.log(`Freezer: No config found in package.json on branch ${ORACLE_BRANCH}. Exiting.`);
return;
}
@ -119,11 +115,7 @@ const validateConfig = () => {
const { frozen } = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
if (frozen === undefined) {
console.log(
`Freezer: No config found in package.json on branch ${
ORACLE_BRANCH
}. Exiting.`
);
console.log(`Freezer: No config found in package.json on branch ${ORACLE_BRANCH}. Exiting.`);
return;
}

View File

@ -20,10 +20,10 @@ export interface Input {
export type Output = Input;
/**
*
*
* @export
* @interface ABIFunction
* @template T
* @template T
*/
export interface ContractOutputMappings {
[key: string]: string[];

View File

@ -13,10 +13,7 @@ export function decryptPrivKey(encprivkey: string, password: string): Buffer {
ivsize: 16
});
const decipher = createDecipheriv('aes-256-cbc', evp.key, evp.iv);
const privKey = decipherBuffer(
decipher,
new Buffer(decryptedCipher.ciphertext)
);
const privKey = decipherBuffer(decipher, new Buffer(decryptedCipher.ciphertext));
return new Buffer(privKey.toString(), 'hex');
}

View File

@ -14,10 +14,7 @@ export interface INode {
ping(): Promise<boolean>;
getBalance(address: string): Promise<Wei>;
getTokenBalance(address: string, token: Token): Promise<TokenBalanceResult>;
getTokenBalances(
address: string,
tokens: Token[]
): Promise<TokenBalanceResult[]>;
getTokenBalances(address: string, tokens: Token[]): Promise<TokenBalanceResult[]>;
estimateGas(tx: Partial<IHexStrTransaction>): Promise<Wei>;
getTransactionCount(address: string): Promise<string>;
sendRawTx(tx: string): Promise<string>;

View File

@ -58,10 +58,7 @@ export default class EtherscanRequests extends RPCRequests {
};
}
public getTokenBalance(
address: string,
token: Token
): GetTokenBalanceRequest {
public getTokenBalance(address: string, token: Token): GetTokenBalanceRequest {
return this.ethCall({
to: token.address,
data: ERC20.balanceOf.encodeInput({ _owner: address })

View File

@ -44,19 +44,14 @@ export default class RPCRequests {
};
}
public getTransactionCount(
address: string
): GetTransactionCountRequest | any {
public getTransactionCount(address: string): GetTransactionCountRequest | any {
return {
method: 'eth_getTransactionCount',
params: [address, 'pending']
};
}
public getTokenBalance(
address: string,
token: Token
): GetTokenBalanceRequest | any {
public getTokenBalance(address: string, token: Token): GetTokenBalanceRequest | any {
return {
method: 'eth_call',
params: [

View File

@ -39,23 +39,15 @@ export interface ISignedMessage {
// adapted from:
// https://github.com/kvhnuke/etherwallet/blob/2a5bc0db1c65906b14d8c33ce9101788c70d3774/app/scripts/controllers/signMsgCtrl.js#L118
export function verifySignedMessage({
address,
message,
signature,
version
}: ISignedMessage) {
export function verifySignedMessage({ address, message, signature, version }: ISignedMessage) {
const sig = new Buffer(stripHexPrefixAndLower(signature), 'hex');
if (sig.length !== 65) {
return false;
}
//TODO: explain what's going on here
sig[64] = sig[64] === 0 || sig[64] === 1 ? sig[64] + 27 : sig[64];
const hash =
version === '2' ? hashPersonalMessage(toBuffer(message)) : sha3(message);
const hash = version === '2' ? hashPersonalMessage(toBuffer(message)) : sha3(message);
const pubKey = ecrecover(hash, sig[64], sig.slice(0, 32), sig.slice(32, 64));
return (
stripHexPrefixAndLower(address) === pubToAddress(pubKey).toString('hex')
);
return stripHexPrefixAndLower(address) === pubToAddress(pubKey).toString('hex');
}

View File

@ -54,22 +54,18 @@ export class LedgerWallet extends DeterministicWallet implements IFullWallet {
const msgHex = Buffer.from(msg).toString('hex');
return new Promise((resolve, reject) => {
this.ethApp.signPersonalMessage_async(
this.getPath(),
msgHex,
async (signed, error) => {
if (error) {
return reject(this.ethApp.getError(error));
}
try {
const combined = signed.r + signed.s + signed.v;
resolve(bufferToHex(combined));
} catch (err) {
reject(err);
}
this.ethApp.signPersonalMessage_async(this.getPath(), msgHex, async (signed, error) => {
if (error) {
return reject(this.ethApp.getError(error));
}
);
try {
const combined = signed.r + signed.s + signed.v;
resolve(bufferToHex(combined));
} catch (err) {
reject(err);
}
});
});
}
}

View File

@ -2,12 +2,5 @@ import { decryptMnemonicToPrivKey } from 'libs/decrypt';
import { fromPrivateKey } from 'ethereumjs-wallet';
import { signWrapper } from 'libs/wallet';
export const MnemonicWallet = (
phrase: string,
pass: string,
path: string,
address: string
) =>
signWrapper(
fromPrivateKey(decryptMnemonicToPrivKey(phrase, pass, path, address))
);
export const MnemonicWallet = (phrase: string, pass: string, path: string, address: string) =>
signWrapper(fromPrivateKey(decryptMnemonicToPrivKey(phrase, pass, path, address)));

View File

@ -15,10 +15,7 @@ export class TrezorWallet extends DeterministicWallet implements IFullWallet {
return new Promise((resolve, reject) => {
const { chainId, ...strTx } = getTransactionFields(tx);
// stripHexPrefixAndLower identical to ethFuncs.getNakedAddress
const cleanedTx = mapValues(
mapValues(strTx, stripHexPrefixAndLower),
padLeftEven
);
const cleanedTx = mapValues(mapValues(strTx, stripHexPrefixAndLower), padLeftEven);
(TrezorConnect as any).ethereumSignTx(
// Args
@ -52,8 +49,7 @@ export class TrezorWallet extends DeterministicWallet implements IFullWallet {
});
}
public signMessage = () =>
Promise.reject(new Error('Signing via Trezor not yet supported.'));
public signMessage = () => Promise.reject(new Error('Signing via Trezor not yet supported.'));
// works, but returns a signature that can only be verified with a Trezor device
/*

View File

@ -27,10 +27,8 @@ export type WrappedWallet = IFullWallet & ISignWrapper;
export const signWrapper = (walletToWrap: IFullWallet): WrappedWallet =>
Object.assign(walletToWrap, {
signRawTransaction: (t: Tx) =>
signRawTxWithPrivKey(walletToWrap.getPrivateKey(), t),
signMessage: (msg: string) =>
signMessageWithPrivKeyV2(walletToWrap.getPrivateKey(), msg),
signRawTransaction: (t: Tx) => signRawTxWithPrivKey(walletToWrap.getPrivateKey(), t),
signMessage: (msg: string) => signMessageWithPrivKeyV2(walletToWrap.getPrivateKey(), msg),
unlock: () => Promise.resolve()
});

View File

@ -5,10 +5,8 @@ import { decryptPrivKey } from 'libs/decrypt';
import Web3Wallet from './web3';
import AddressOnlyWallet from './address';
const EncryptedPrivateKeyWallet = (
encryptedPrivateKey: string,
password: string
) => signWrapper(fromPrivateKey(decryptPrivKey(encryptedPrivateKey, password)));
const EncryptedPrivateKeyWallet = (encryptedPrivateKey: string, password: string) =>
signWrapper(fromPrivateKey(decryptPrivKey(encryptedPrivateKey, password)));
const PresaleWallet = (keystore: string, password: string) =>
signWrapper(fromEthSale(keystore, password));

View File

@ -70,9 +70,9 @@ export default class Web3Wallet implements IFullWallet {
const netName = networkIdToName(netId);
if (this.network !== netName) {
throw new Error(
`Expected MetaMask / Mist network to be ${this.network}, but got ${
netName
}. Please change the network or restart MyEtherWallet.`
`Expected MetaMask / Mist network to be ${
this.network
}, but got ${netName}. Please change the network or restart MyEtherWallet.`
);
}
}

View File

@ -17,17 +17,11 @@ function addCustomToken(state: State, action: AddCustomTokenAction): State {
return [...state, action.payload];
}
function removeCustomToken(
state: State,
action: RemoveCustomTokenAction
): State {
function removeCustomToken(state: State, action: RemoveCustomTokenAction): State {
return state.filter(token => token.symbol !== action.payload);
}
export function customTokens(
state: State = INITIAL_STATE,
action: CustomTokenAction
): State {
export function customTokens(state: State = INITIAL_STATE, action: CustomTokenAction): State {
switch (action.type) {
case TypeKeys.CUSTOM_TOKEN_ADD:
return addCustomToken(state, action);

View File

@ -1,7 +1,4 @@
import {
DeterministicWalletAction,
DeterministicWalletData
} from 'actions/deterministicWallets';
import { DeterministicWalletAction, DeterministicWalletData } from 'actions/deterministicWallets';
import { TypeKeys } from 'actions/deterministicWallets/constants';
export interface State {

View File

@ -14,10 +14,7 @@ export const INITIAL_STATE: State = {
password: null
};
export function generateWallet(
state: State = INITIAL_STATE,
action: GenerateWalletAction
): State {
export function generateWallet(state: State = INITIAL_STATE, action: GenerateWalletAction): State {
switch (action.type) {
case TypeKeys.GENERATE_WALLET_GENERATE_WALLET: {
return {

View File

@ -2,10 +2,7 @@ import { routerReducer } from 'react-router-redux';
import { combineReducers } from 'redux';
import { config, State as ConfigState } from './config';
import { customTokens, State as CustomTokensState } from './customTokens';
import {
deterministicWallets,
State as DeterministicWalletsState
} from './deterministicWallets';
import { deterministicWallets, State as DeterministicWalletsState } from './deterministicWallets';
import { ens, State as EnsState } from './ens';
import { generateWallet, State as GenerateWalletState } from './generateWallet';
import { notifications, State as NotificationsState } from './notifications';

View File

@ -19,10 +19,7 @@ function closeNotification(state, action: CloseNotificationAction): State {
return state;
}
export function notifications(
state: State = INITIAL_STATE,
action: NotificationsAction
): State {
export function notifications(state: State = INITIAL_STATE, action: NotificationsAction): State {
switch (action.type) {
case TypeKeys.SHOW_NOTIFICATION:
return showNotification(state, action);

View File

@ -12,10 +12,7 @@ export const INITIAL_STATE: State = {
ratesError: null
};
function fetchCCRatesSucceeded(
state: State,
action: FetchCCRatesSucceeded
): State {
function fetchCCRatesSucceeded(state: State, action: FetchCCRatesSucceeded): State {
return {
...state,
rates: {
@ -33,10 +30,7 @@ function fetchCCRatesFailed(state: State): State {
};
}
export function rates(
state: State = INITIAL_STATE,
action: RatesAction
): State {
export function rates(state: State = INITIAL_STATE, action: RatesAction): State {
switch (action.type) {
case TypeKeys.RATES_FETCH_CC_SUCCEEDED:
return fetchCCRatesSucceeded(state, action);

View File

@ -10,24 +10,14 @@ import { publicToAddress, toChecksumAddress } from 'ethereumjs-util';
import HDKey from 'hdkey';
import { INode } from 'libs/nodes/INode';
import { SagaIterator } from 'redux-saga';
import {
all,
apply,
fork,
put,
select,
takeEvery,
takeLatest
} from 'redux-saga/effects';
import { all, apply, fork, put, select, takeEvery, takeLatest } from 'redux-saga/effects';
import { getNodeLib } from 'selectors/config';
import { getDesiredToken, getWallets } from 'selectors/deterministicWallets';
import { getTokens } from 'selectors/wallet';
import translate from 'translations';
import { TokenValue } from 'libs/units';
export function* getDeterministicWallets(
action: GetDeterministicWalletsAction
): SagaIterator {
export function* getDeterministicWallets(action: GetDeterministicWalletsAction): SagaIterator {
const { seed, dPath, publicKey, chainCode, limit, offset } = action.payload;
let pathBase;
let hdk;

View File

@ -1,13 +1,8 @@
import {
closeNotification,
ShowNotificationAction
} from 'actions/notifications';
import { closeNotification, ShowNotificationAction } from 'actions/notifications';
import { delay, SagaIterator } from 'redux-saga';
import { call, put, takeEvery } from 'redux-saga/effects';
export function* handleNotification(
action: ShowNotificationAction
): SagaIterator {
export function* handleNotification(action: ShowNotificationAction): SagaIterator {
const { duration } = action.payload;
// show forever
if (duration === 0 || duration === Infinity) {

View File

@ -17,16 +17,7 @@ import moment from 'moment';
import { AppState } from 'reducers';
import { State as SwapState } from 'reducers/swap';
import { delay, SagaIterator } from 'redux-saga';
import {
call,
cancel,
cancelled,
fork,
put,
select,
take,
takeEvery
} from 'redux-saga/effects';
import { call, cancel, cancelled, fork, put, select, take, takeEvery } from 'redux-saga/effects';
export const getSwap = (state: AppState): SwapState => state.swap;
const ONE_SECOND = 1000;
@ -45,13 +36,7 @@ export function* pollBityOrderStatus(): SagaIterator {
yield put(orderStatusRequestedSwap());
const orderStatus = yield call(getOrderStatus, swap.orderId);
if (orderStatus.error) {
yield put(
showNotification(
'danger',
`Bity Error: ${orderStatus.msg}`,
TEN_SECONDS
)
);
yield put(showNotification('danger', `Bity Error: ${orderStatus.msg}`, TEN_SECONDS));
} else {
yield put(orderStatusSucceededSwap(orderStatus.data));
yield call(delay, ONE_SECOND * 5);
@ -81,9 +66,7 @@ export function* pollBityOrderStatusSaga(): SagaIterator {
}
}
export function* postBityOrderCreate(
action: BityOrderCreateRequestedSwapAction
): SagaIterator {
export function* postBityOrderCreate(action: BityOrderCreateRequestedSwapAction): SagaIterator {
const payload = action.payload;
try {
yield put(stopLoadBityRatesSwap());
@ -96,9 +79,7 @@ export function* postBityOrderCreate(
);
if (order.error) {
// TODO - handle better / like existing site?
yield put(
showNotification('danger', `Bity Error: ${order.msg}`, TEN_SECONDS)
);
yield put(showNotification('danger', `Bity Error: ${order.msg}`, TEN_SECONDS));
yield put(bityOrderCreateFailedSwap());
} else {
yield put(bityOrderCreateSucceededSwap(order.data));
@ -127,9 +108,7 @@ export function* bityTimeRemaining(): SagaIterator {
yield call(delay, ONE_SECOND);
const swap = yield select(getSwap);
// if (swap.bityOrder.status === 'OPEN') {
const createdTimeStampMoment = moment(
swap.orderTimestampCreatedISOString
);
const createdTimeStampMoment = moment(swap.orderTimestampCreatedISOString);
const validUntil = moment(createdTimeStampMoment).add(swap.validFor, 's');
const now = moment();
if (validUntil.isAfter(now)) {
@ -145,9 +124,7 @@ export function* bityTimeRemaining(): SagaIterator {
yield put({ type: 'SWAP_STOP_LOAD_BITY_RATES' });
if (!hasShownNotification) {
hasShownNotification = true;
yield put(
showNotification('danger', BITY_TIMEOUT_MESSAGE, Infinity)
);
yield put(showNotification('danger', BITY_TIMEOUT_MESSAGE, Infinity));
}
break;
case 'CANC':
@ -155,17 +132,13 @@ export function* bityTimeRemaining(): SagaIterator {
yield put({ type: 'SWAP_STOP_LOAD_BITY_RATES' });
if (!hasShownNotification) {
hasShownNotification = true;
yield put(
showNotification('danger', BITY_TIMEOUT_MESSAGE, Infinity)
);
yield put(showNotification('danger', BITY_TIMEOUT_MESSAGE, Infinity));
}
break;
case 'RCVE':
if (!hasShownNotification) {
hasShownNotification = true;
yield put(
showNotification('warning', BITY_TIMEOUT_MESSAGE, Infinity)
);
yield put(showNotification('warning', BITY_TIMEOUT_MESSAGE, Infinity));
}
break;
case 'FILL':

View File

@ -27,27 +27,11 @@ declare module 'ethereumjs-util' {
export function zeros(bytes: number): Buffer;
export function setLength(
msg: Buffer,
length: number,
right: boolean
): Buffer;
export function setLength(
msg: number[],
length: number,
right: boolean
): number[];
export function setLength(msg: Buffer, length: number, right: boolean): Buffer;
export function setLength(msg: number[], length: number, right: boolean): number[];
export function setLengthLeft(
msg: Buffer,
length: number,
right: boolean
): Buffer;
export function setLengthLeft(
msg: number[],
length: number,
right: boolean
): number[];
export function setLengthLeft(msg: Buffer, length: number, right: boolean): Buffer;
export function setLengthLeft(msg: number[], length: number, right: boolean): number[];
export function setLengthRight(msg: Buffer, length: number): Buffer;
export function setLengthRight(msg: number[], length: number): number[];
@ -66,17 +50,11 @@ declare module 'ethereumjs-util' {
export function toUnsigned(num: BN): Buffer;
export function sha3(
a: Buffer | string | number | number[],
bits?: number
): Buffer;
export function sha3(a: Buffer | string | number | number[], bits?: number): Buffer;
export function sha256(a: Buffer | string | number | number[]): Buffer;
export function ripemd160(
a: Buffer | string | number | number[],
padded?: boolean
): Buffer;
export function ripemd160(a: Buffer | string | number | number[], padded?: boolean): Buffer;
export function rlphash(a: Buffer | string | number | number[]): Buffer;
@ -85,10 +63,7 @@ declare module 'ethereumjs-util' {
export function isValidPublic(publicKey: Buffer, sanitize?: boolean): boolean;
export function pubToAddress(publicKey: Buffer, sanitize?: boolean): Buffer;
export function publicToAddress(
publicKey: Buffer,
sanitize?: boolean
): Buffer;
export function publicToAddress(publicKey: Buffer, sanitize?: boolean): Buffer;
export function privateToPublic(privateKey: Buffer): Buffer;
@ -98,12 +73,7 @@ declare module 'ethereumjs-util' {
export function hashPersonalMessage(message: Buffer | string): Buffer;
export function ecrecover(
msgHash: Buffer,
v: number,
r: Buffer,
s: Buffer
): Buffer;
export function ecrecover(msgHash: Buffer, v: number, r: Buffer, s: Buffer): Buffer;
export function toRpcSig(v: number, r: Buffer, s: Buffer): string;

View File

@ -293,10 +293,7 @@ declare module 'ethereumjs-wallet' {
* @param input
* @param nonStrict
*/
function fromPublicKey(
input: Buffer,
nonStrict?: boolean
): IPublicKeyOnlyWallet;
function fromPublicKey(input: Buffer, nonStrict?: boolean): IPublicKeyOnlyWallet;
/**
* @description create an instance based on a BIP32 extended public key (xpub)
@ -317,19 +314,12 @@ declare module 'ethereumjs-wallet' {
* @param password
* @param nonStrict
*/
function fromV3(
input: IV3Wallet | string,
password: string,
nonStrict: boolean
): IFullWallet;
function fromV3(input: IV3Wallet | string, password: string, nonStrict: boolean): IFullWallet;
/**
* @description import an Ethereum Pre Sale wallet
* @param input
* @param password
*/
function fromEthSale(
input: IPresaleWallet | string,
password: string
): IFullWallet;
function fromEthSale(input: IPresaleWallet | string, password: string): IFullWallet;
}

View File

@ -1,6 +1,4 @@
const isMobile =
window && window.navigator
? /iPhone|iPad|iPod|Android/i.test(window.navigator.userAgent)
: false;
window && window.navigator ? /iPhone|iPad|iPod|Android/i.test(window.navigator.userAgent) : false;
export default isMobile;

View File

@ -26,9 +26,7 @@ export function getNodeConfigFromId(
}
}
export function makeNodeConfigFromCustomConfig(
config: CustomNodeConfig
): NodeConfig {
export function makeNodeConfigFromCustomConfig(config: CustomNodeConfig): NodeConfig {
return {
network: config.network,
lib: new CustomNode(config),

View File

@ -7,10 +7,7 @@ interface PrintOptions {
popupFeatures?: object;
}
export default function(
element: React.ReactElement<any>,
opts: PrintOptions = {}
) {
export default function(element: React.ReactElement<any>, opts: PrintOptions = {}) {
const options = {
styles: '',
printTimeout: 500,

View File

@ -134,11 +134,13 @@
"postinstall": "webpack --config=./webpack_config/webpack.dll.js",
"start": "npm run dev",
"precommit": "lint-staged",
"formatAll":
"find ./common/ -name '*.ts*' | xargs prettier --write --config ./.prettierrc --config-precedence file-override",
"prepush": "npm run tslint && npm run tscheck"
},
"lint-staged": {
"*.{ts,tsx}": [
"prettier --write",
"prettier --write --config ./.prettierrc --config-precedence file-override",
"git add"
]
}