From 777f8123eba9999b30151889df64d48e26f640fc Mon Sep 17 00:00:00 2001 From: Overtorment Date: Sat, 17 Mar 2018 19:19:26 +0000 Subject: [PATCH] codestyle --- MainBottomTabs.js | 2 -- SecondaryBottomTabs.js | 14 -------------- class.js | 29 ++++++++++++++--------------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/MainBottomTabs.js b/MainBottomTabs.js index 3af558176..8c9061859 100644 --- a/MainBottomTabs.js +++ b/MainBottomTabs.js @@ -1,5 +1,3 @@ -import React from 'react' -import { Platform } from 'react-native' import { TabNavigator } from 'react-navigation' import transactions from './screen/transactions' diff --git a/SecondaryBottomTabs.js b/SecondaryBottomTabs.js index f5372f9ce..f4be41404 100644 --- a/SecondaryBottomTabs.js +++ b/SecondaryBottomTabs.js @@ -34,13 +34,6 @@ const MyHomeScreen = ({ navigation }) => ( ) -const MyProfileScreen = ({ navigation }) => ( - -) - const MyNotificationsSettingsScreen = ({ navigation }) => ( ) @@ -100,13 +93,6 @@ const SecondaryBottomTabs = StackNavigator({ navigationOptions: { title: 'Notifications' } - }, - Profile: { - screen: MyProfileScreen, - path: '/people/:name', - navigationOptions: ({ navigation }) => { - title: `${navigation.state.params.name}'s Profile!` - } } }) diff --git a/class.js b/class.js index 59b6541f0..992115fec 100644 --- a/class.js +++ b/class.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react' +/* global fetch */ import { AsyncStorage } from 'react-native' import Frisbee from 'frisbee' @@ -10,8 +10,6 @@ let BigNumber = require('bignumber.js') let isaac = require('isaac') // alternative https://github.com/pointbiz/bitaddress.org/blob/master/src/securerandom.js -let assert = require('assert') - class AbstractWallet { constructor () { this.type = 'abstract' @@ -84,12 +82,12 @@ export class LegacyWallet extends AbstractWallet { generate () { function myRng (c) { - let buf = new Buffer(c) + let buf = Buffer.alloc(c) let totalhex = '' for (let i = 0; i < c; i++) { - let random_number = isaac.random() - random_number = Math.floor(random_number * 255) - let n = new BigNumber(random_number) + let randomNumber = isaac.random() + randomNumber = Math.floor(randomNumber * 255) + let n = new BigNumber(randomNumber) let hex = n.toString(16) if (hex.length === 1) { hex = '0' + hex @@ -121,8 +119,9 @@ export class LegacyWallet extends AbstractWallet { } catch (err) { return false } + this._address = address - return this._address = address + return this._address } async fetchBalance () { @@ -142,7 +141,7 @@ export class LegacyWallet extends AbstractWallet { } let json = await response.json() if (typeof json.final_balance === 'undefined') { - throw 'Could not fetch balance from API' + throw new Error('Could not fetch balance from API') } this.balance = json.final_balance / 100000000 } catch (err) { @@ -169,7 +168,7 @@ export class LegacyWallet extends AbstractWallet { } let json = await response.json() if (typeof json.final_balance === 'undefined') { - throw 'Could not fetch UTXO from API' + throw new Error('Could not fetch UTXO from API') } json.txrefs = json.txrefs || [] // case when source address is empty this.utxo = json.txrefs @@ -202,7 +201,7 @@ export class LegacyWallet extends AbstractWallet { console.log(url) let json = await response.json() if (!json.txs) { - throw 'Could not fetch transactions from API' + throw new Error('Could not fetch transactions from API') } this.transactions = json.txs @@ -294,8 +293,9 @@ export class SegwitBech32Wallet extends LegacyWallet { } catch (err) { return false } + this._address = address - return this._address = address + return this._address } } @@ -321,8 +321,9 @@ export class SegwitP2SHWallet extends LegacyWallet { } catch (err) { return false } + this._address = address - return this._address = address + return this._address } createTx (utxos, amount, fee, address, memo, sequence) { @@ -409,10 +410,8 @@ export class AppStorage { saveToDisk () { let walletsToSave = [] - let c = 0 for (let key of this.wallets) { walletsToSave.push(JSON.stringify(key)) - c++ } let data = {