From 69f479280b1b7c6202ac0340b7659fe4cbd4d05d Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Mon, 14 May 2018 10:45:04 +0200 Subject: [PATCH] code cleaning --- src/js/actions/Web3Actions.js | 14 +--------- src/js/components/modal/ConfirmAddress.js | 2 +- src/js/components/modal/Passphrase.js | 2 +- src/js/components/modal/Pin.js | 2 +- .../components/wallet/account/AccountTabs.js | 6 ++--- src/js/components/wallet/send/SendForm.js | 26 ++++++++----------- src/js/flowtype/trezor-connect.js | 7 +---- src/js/reducers/AccountsReducer.js | 4 --- 8 files changed, 19 insertions(+), 44 deletions(-) diff --git a/src/js/actions/Web3Actions.js b/src/js/actions/Web3Actions.js index bcaa2c75..6ba3ff13 100644 --- a/src/js/actions/Web3Actions.js +++ b/src/js/actions/Web3Actions.js @@ -322,14 +322,6 @@ export const getTransactionReceipt = (tx: PendingTx): AsyncAction => { } } - -// export function updateLastBlock(hash: string): Action { -// return { -// type: 'web3__update_last_block', -// hash -// } -// } - export const getTransaction = (web3: Web3, txid: string): Promise => { return new Promise((resolve, reject) => { web3.eth.getTransaction(txid, (error, result) => { @@ -342,8 +334,6 @@ export const getTransaction = (web3: Web3, txid: string): Promise => { }); } - - export const getBalanceAsync = (web3: Web3, address: string): Promise => { return new Promise((resolve, reject) => { web3.eth.getBalance(address, (error: Error, result: BigNumber) => { @@ -356,8 +346,6 @@ export const getBalanceAsync = (web3: Web3, address: string): Promise }); } - - export const getTokenBalanceAsync = (erc20: ContractFactory, token: Token): Promise => { return new Promise((resolve, reject) => { @@ -451,4 +439,4 @@ export const pushTx = (web3: Web3, tx: any): Promise => { } }); }) -} +} \ No newline at end of file diff --git a/src/js/components/modal/ConfirmAddress.js b/src/js/components/modal/ConfirmAddress.js index 64265942..15b98b73 100644 --- a/src/js/components/modal/ConfirmAddress.js +++ b/src/js/components/modal/ConfirmAddress.js @@ -29,7 +29,7 @@ const ConfirmAddress = (props: Props) => { } export default ConfirmAddress; -export const ConfirmUnverifiedAddress = (props: Props): any => { +export const ConfirmUnverifiedAddress = (props: Props) => { if (!props.modal.opened) return null; const { diff --git a/src/js/components/modal/Passphrase.js b/src/js/components/modal/Passphrase.js index db226fa3..dc893ea5 100644 --- a/src/js/components/modal/Passphrase.js +++ b/src/js/components/modal/Passphrase.js @@ -210,7 +210,7 @@ export default class PinModal extends Component { raf(() => onPassphraseSubmit(empty ? '' : passphrase)); } - render(): any { + render() { if (!this.props.modal.opened) return null; diff --git a/src/js/components/modal/Pin.js b/src/js/components/modal/Pin.js index cb5e018d..d53beb24 100644 --- a/src/js/components/modal/Pin.js +++ b/src/js/components/modal/Pin.js @@ -103,7 +103,7 @@ export default class Pin extends Component { window.removeEventListener('keydown', this.keyboardHandler, false); } - render(): any { + render() { if (!this.props.modal.opened) return null; diff --git a/src/js/components/wallet/account/AccountTabs.js b/src/js/components/wallet/account/AccountTabs.js index cf511200..03c8bd4b 100644 --- a/src/js/components/wallet/account/AccountTabs.js +++ b/src/js/components/wallet/account/AccountTabs.js @@ -20,7 +20,7 @@ class Indicator extends Component { reposition: () => void; state: State; - constructor(props: any) { + constructor(props: Props) { super(props); this.state = { @@ -46,7 +46,7 @@ class Indicator extends Component { window.removeEventListener('resize', this.reposition, false); } - componentDidUpdate(newProps: any) { + componentDidUpdate(newProps: Props) { this.reposition(); } @@ -76,7 +76,7 @@ class Indicator extends Component { } } -const AccountTabs = (props: any): any => { +const AccountTabs = (props: any) => { const urlParams = props.match.params; //const urlParams = props.match ? props.match.params : { address: '0' }; diff --git a/src/js/components/wallet/send/SendForm.js b/src/js/components/wallet/send/SendForm.js index 9a16567c..fba3e97e 100644 --- a/src/js/components/wallet/send/SendForm.js +++ b/src/js/components/wallet/send/SendForm.js @@ -95,22 +95,18 @@ const _render = (props: Props, state: AccountState): React$Element => { } else if (coinSymbol === selectedCurrency && total !== '0') { buttonLabel += ` ${total} ${ selectedCoin.symbol }`; } - - //if (device) { - - if (!device.connected){ - buttonLabel = 'Device is not connected'; - buttonDisabled = true; - } else if (!device.available) { - buttonLabel = 'Device is unavailable'; - buttonDisabled = true; - } else if (!discovery.completed) { - buttonLabel = 'Loading accounts'; - buttonDisabled = true; - } - - //} + if (!device.connected){ + buttonLabel = 'Device is not connected'; + buttonDisabled = true; + } else if (!device.available) { + buttonLabel = 'Device is unavailable'; + buttonDisabled = true; + } else if (!discovery.completed) { + buttonLabel = 'Loading accounts'; + buttonDisabled = true; + } + let notification = null; return ( diff --git a/src/js/flowtype/trezor-connect.js b/src/js/flowtype/trezor-connect.js index 6c3cbce5..1ac79c18 100644 --- a/src/js/flowtype/trezor-connect.js +++ b/src/js/flowtype/trezor-connect.js @@ -218,7 +218,6 @@ declare module 'trezor-connect' { declare module.exports: { init: (options: Object) => Promise; - // on: (type: string, handler: (event: any) => void) => void; on: DeviceEventListener & DeviceEventListenerByType & UiEventListener & TransportEventListener; off: (type: string, handler: (event: any) => void) => void; getVersion: () => any; @@ -228,13 +227,9 @@ declare module 'trezor-connect' { getFeatures: (options: Object) => Promise; getPublicKey: (options: Object) => Promise; ethereumGetAddress: (options: Object) => Promise; - uiResponse: (options: Object) => Promise; + uiResponse: (options: Object) => void; ethereumSignTransaction: (options: Object) => Promise; - - - // export const RESPONSE_EVENT: string = 'RESPONSE_EVENT'; - // export const ERROR_EVENT: string = 'ERROR_EVENT'; DEVICE_EVENT: T_DEVICE_EVENT; DEVICE: T_DEVICE; diff --git a/src/js/reducers/AccountsReducer.js b/src/js/reducers/AccountsReducer.js index 150b0bc6..7ac1721f 100644 --- a/src/js/reducers/AccountsReducer.js +++ b/src/js/reducers/AccountsReducer.js @@ -70,10 +70,6 @@ const removeAccounts = (state: State, device: TrezorDevice): State => { return state.filter(account => account.deviceState !== device.state); } -// const forgetAccounts = (state: State, action: any): State => { -// return state.filter(account => action.accounts.indexOf(account) === -1); -// } - const setBalance = (state: State, action: AccountSetBalanceAction): State => { const index: number = state.findIndex(account => account.address === action.address && account.network === action.network && account.deviceState === action.deviceState); const newState: State = [ ...state ];