Skip to content

Commit

Permalink
REF: prettier: line width 120
Browse files Browse the repository at this point in the history
  • Loading branch information
Overtorment committed Jul 7, 2018
1 parent 8fbd2c6 commit b369a1b
Show file tree
Hide file tree
Showing 40 changed files with 205 additions and 769 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'warn',
{
singleQuote: true,
printWidth: 120,
trailingComma: 'all'
}
]
Expand Down
10 changes: 2 additions & 8 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ const appjson = require('./app.json');

const CustomDrawerContentComponent = props => (
<ScrollView>
<SafeAreaView
style={styles.container}
forceInset={{ top: 'always', horizontal: 'never' }}
>
<Text
onPress={() => props.navigation.navigate('About')}
style={styles.heading}
>
<SafeAreaView style={styles.container} forceInset={{ top: 'always', horizontal: 'never' }}>
<Text onPress={() => props.navigation.navigate('About')} style={styles.heading}>
{' '}
{pkg.name} v{pkg.version} (build {appjson.expo.ios.buildNumber})
</Text>
Expand Down
10 changes: 3 additions & 7 deletions App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ it('Appstorage - encryptStorage & load encrypted storage works', async () => {
assert.equal(Storage2.wallets[1].getLabel(), 'testlabel2');

// next, adding new `fake` storage which should be unlocked with `fake` password
let createFakeStorageResult = await Storage2.createFakeStorage(
'fakePassword',
);
let createFakeStorageResult = await Storage2.createFakeStorage('fakePassword');
assert.ok(createFakeStorageResult);
assert.equal(Storage2.wallets.length, 0);
assert.equal(Storage2.cachedPassword, 'fakePassword');
Expand Down Expand Up @@ -194,8 +192,7 @@ it('bip38 decodes', async () => {
const bip38 = require('./bip38');
const wif = require('wif');

let encryptedKey =
'6PRVWUbkzq2VVjRuv58jpwVjTeN46MeNmzUHqUjQptBJUHGcBakduhrUNc';
let encryptedKey = '6PRVWUbkzq2VVjRuv58jpwVjTeN46MeNmzUHqUjQptBJUHGcBakduhrUNc';
let decryptedKey = await bip38.decrypt(
encryptedKey,
'TestingOneTwoThree',
Expand All @@ -218,8 +215,7 @@ it('bip38 decodes slow', async () => {
const bip38 = require('bip38');
const wif = require('wif');

let encryptedKey =
'6PnU5voARjBBykwSddwCdcn6Eu9EcsK24Gs5zWxbJbPZYW7eiYQP8XgKbN';
let encryptedKey = '6PnU5voARjBBykwSddwCdcn6Eu9EcsK24Gs5zWxbJbPZYW7eiYQP8XgKbN';
let decryptedKey = await bip38.decrypt(encryptedKey, 'qwerty', status =>
process.stdout.write(parseInt(status.percent) + '%\r'),
);
Expand Down
10 changes: 2 additions & 8 deletions BlueApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ async function startAndDecrypt(retry) {
let password = false;
if (await BlueApp.storageIsEncrypted()) {
do {
password = await prompt(
(retry && loc._.bad_password) || loc._.enter_password,
loc._.storage_is_encrypted,
);
password = await prompt((retry && loc._.bad_password) || loc._.enter_password, loc._.storage_is_encrypted);
} while (!password);
}
let success = await BlueApp.loadFromDisk(password);
Expand All @@ -35,10 +32,7 @@ async function startAndDecrypt(retry) {
console.log('time to refresh wallet #0');
let oldBalance = wallets[0].getBalance();
await wallets[0].fetchBalance();
if (
oldBalance !== wallets[0].getBalance() ||
wallets[0].getUnconfirmedBalance() !== 0
) {
if (oldBalance !== wallets[0].getBalance() || wallets[0].getUnconfirmedBalance() !== 0) {
// balance changed, thus txs too
await wallets[0].fetchTransactions();
hadToRefresh = true;
Expand Down
68 changes: 9 additions & 59 deletions BlueComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,8 @@ import React, { Component } from 'react';
import { SafeAreaView } from 'react-navigation';
import Ionicons from 'react-native-vector-icons/Ionicons';
import { LinearGradient } from 'expo';
import {
Icon,
Button,
FormLabel,
FormInput,
Card,
Text,
Header,
List,
ListItem,
} from 'react-native-elements';
import {
TouchableOpacity,
ActivityIndicator,
View,
StyleSheet,
Dimensions,
Image,
} from 'react-native';
import { Icon, Button, FormLabel, FormInput, Card, Text, Header, List, ListItem } from 'react-native-elements';
import { TouchableOpacity, ActivityIndicator, View, StyleSheet, Dimensions, Image } from 'react-native';
import Carousel from 'react-native-snap-carousel';
let loc = require('./loc/');
/** @type {AppStorage} */
Expand Down Expand Up @@ -91,12 +74,7 @@ export class BlueCard extends Component {

export class BlueText extends Component {
render() {
return (
<Text
{...this.props}
style={{ color: BlueApp.settings.foregroundColor }}
/>
);
return <Text {...this.props} style={{ color: BlueApp.settings.foregroundColor }} />;
}
}

Expand All @@ -123,12 +101,7 @@ export class BlueListItem extends Component {

export class BlueFormLabel extends Component {
render() {
return (
<FormLabel
{...this.props}
labelStyle={{ color: BlueApp.settings.foregroundColor }}
/>
);
return <FormLabel {...this.props} labelStyle={{ color: BlueApp.settings.foregroundColor }} />;
}
}

Expand Down Expand Up @@ -215,12 +188,7 @@ export class BlueHeaderDefaultSub extends Component {
>
<View style={stylesBlueIcon.box}>
<View style={stylesBlueIcon.ballTransparrent}>
<Icon
name="times"
size={16}
type="font-awesome"
color={BlueApp.settings.foregroundColor}
/>
<Icon name="times" size={16} type="font-awesome" color={BlueApp.settings.foregroundColor} />
</View>
</View>
</TouchableOpacity>
Expand Down Expand Up @@ -264,12 +232,7 @@ export class BlueHeaderDefaultMain extends Component {
>
<View style={stylesBlueIcon.box}>
<View style={stylesBlueIcon.ballTransparrent}>
<Icon
name="kebab-horizontal"
size={22}
type="octicon"
color={BlueApp.settings.foregroundColor}
/>
<Icon name="kebab-horizontal" size={22} type="octicon" color={BlueApp.settings.foregroundColor} />
</View>
</View>
</TouchableOpacity>
Expand All @@ -281,23 +244,13 @@ export class BlueHeaderDefaultMain extends Component {

export class BlueSpacing extends Component {
render() {
return (
<View
{...this.props}
style={{ height: 60, backgroundColor: BlueApp.settings.brandingColor }}
/>
);
return <View {...this.props} style={{ height: 60, backgroundColor: BlueApp.settings.brandingColor }} />;
}
}

export class BlueSpacing40 extends Component {
render() {
return (
<View
{...this.props}
style={{ height: 50, backgroundColor: BlueApp.settings.brandingColor }}
/>
);
return <View {...this.props} style={{ height: 50, backgroundColor: BlueApp.settings.brandingColor }} />;
}
}

Expand Down Expand Up @@ -773,10 +726,7 @@ export class WalletsCarousel extends Component {
}
}}
>
<LinearGradient
colors={['#65ceef', '#68bbe1']}
style={{ padding: 15, borderRadius: 10, height: 145 }}
>
<LinearGradient colors={['#65ceef', '#68bbe1']} style={{ padding: 15, borderRadius: 10, height: 145 }}>
<Image
source={require('./img/btc-shape.png')}
style={{
Expand Down
34 changes: 7 additions & 27 deletions HDWallet.test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
/* global it, jasmine */
import {
SegwitP2SHWallet,
SegwitBech32Wallet,
HDSegwitP2SHWallet,
HDLegacyBreadwalletWallet,
} from './class';
import { SegwitP2SHWallet, SegwitBech32Wallet, HDSegwitP2SHWallet, HDLegacyBreadwalletWallet } from './class';
let assert = require('assert');

it('can convert witness to address', () => {
let address = SegwitP2SHWallet.witnessToAddress(
'035c618df829af694cb99e664ce1b34f80ad2c3b49bcd0d9c0b1836c66b2d25fd8',
);
let address = SegwitP2SHWallet.witnessToAddress('035c618df829af694cb99e664ce1b34f80ad2c3b49bcd0d9c0b1836c66b2d25fd8');
assert.equal(address, '34ZVGb3gT8xMLT6fpqC6dNVqJtJmvdjbD7');

address = SegwitBech32Wallet.witnessToAddress(
'035c618df829af694cb99e664ce1b34f80ad2c3b49bcd0d9c0b1836c66b2d25fd8',
);
address = SegwitBech32Wallet.witnessToAddress('035c618df829af694cb99e664ce1b34f80ad2c3b49bcd0d9c0b1836c66b2d25fd8');
assert.equal(address, 'bc1quhnve8q4tk3unhmjts7ymxv8cd6w9xv8wy29uv');
});

Expand All @@ -35,10 +26,7 @@ it('can create a BIP49', function() {
let scriptSig = bitcoin.script.witnessPubKeyHash.output.encode(keyhash);
let addressBytes = bitcoin.crypto.hash160(scriptSig);
let outputScript = bitcoin.script.scriptHash.output.encode(addressBytes);
let address = bitcoin.address.fromOutputScript(
outputScript,
bitcoin.networks.bitcoin,
);
let address = bitcoin.address.fromOutputScript(outputScript, bitcoin.networks.bitcoin);

assert.equal(address, '3GcKN7q7gZuZ8eHygAhHrvPa5zZbG5Q1rK');

Expand All @@ -59,19 +47,11 @@ it('can create a BIP49', function() {
it('HD breadwallet works', async function() {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 300 * 1000;
let hdBread = new HDLegacyBreadwalletWallet();
hdBread.setSecret(
'high relief amount witness try remember adult destroy puppy fox giant peace',
);
hdBread.setSecret('high relief amount witness try remember adult destroy puppy fox giant peace');

assert.equal(hdBread.validateMnemonic(), true);
assert.equal(
hdBread._getExternalAddressByIndex(0),
'1ARGkNMdsBE36fJhddSwf8PqBXG3s4d2KU',
);
assert.equal(
hdBread._getInternalAddressByIndex(0),
'1JLvA5D7RpWgChb4A5sFcLNrfxYbyZdw3V',
);
assert.equal(hdBread._getExternalAddressByIndex(0), '1ARGkNMdsBE36fJhddSwf8PqBXG3s4d2KU');
assert.equal(hdBread._getInternalAddressByIndex(0), '1JLvA5D7RpWgChb4A5sFcLNrfxYbyZdw3V');

assert.equal(
hdBread.getXpub(),
Expand Down
8 changes: 2 additions & 6 deletions MockStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export default class MockStorage {

getItem = jest.fn(key => {
return new Promise(resolve => {
return this.storageCache.hasOwnProperty(key)
? resolve(this.storageCache[key])
: resolve(null);
return this.storageCache.hasOwnProperty(key) ? resolve(this.storageCache[key]) : resolve(null);
});
});

Expand All @@ -33,8 +31,6 @@ export default class MockStorage {
});

getAllKeys = jest.fn(key => {
return new Promise((resolve, reject) =>
resolve(Object.keys(this.storageCache)),
);
return new Promise((resolve, reject) => resolve(Object.keys(this.storageCache)));
});
}
4 changes: 1 addition & 3 deletions class/app-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ export class AppStorage {
} else {
// decrypted ok, this is our bucket
// we serialize our object's data, encrypt it, and add it to buckets
newData.push(
encryption.encrypt(JSON.stringify(data), this.cachedPassword),
);
newData.push(encryption.encrypt(JSON.stringify(data), this.cachedPassword));
await AsyncStorage.setItem(AppStorage.FLAG_ENCRYPTED, '1');
}
}
Expand Down
32 changes: 7 additions & 25 deletions class/hd-segwit-p2sh-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ export class HDSegwitP2SHWallet extends LegacyWallet {
let c;
for (c = -1; c < 5; c++) {
let Segwit = new SegwitP2SHWallet();
Segwit.setSecret(
this._getExternalWIFByIndex(this.next_free_address_index + c),
);
Segwit.setSecret(this._getExternalWIFByIndex(this.next_free_address_index + c));
await Segwit.fetchTransactions();
if (Segwit.transactions.length === 0) {
// found free address
Expand All @@ -53,9 +51,7 @@ export class HDSegwitP2SHWallet extends LegacyWallet {

if (!freeAddress) {
// could not find in cycle above, give up
freeAddress = this._getExternalAddressByIndex(
this.next_free_address_index + c,
); // we didnt check this one, maybe its free
freeAddress = this._getExternalAddressByIndex(this.next_free_address_index + c); // we didnt check this one, maybe its free
this.next_free_address_index += c + 1; // now points to the one _after_
}

Expand Down Expand Up @@ -94,10 +90,7 @@ export class HDSegwitP2SHWallet extends LegacyWallet {
let scriptSig = bitcoin.script.witnessPubKeyHash.output.encode(keyhash);
let addressBytes = bitcoin.crypto.hash160(scriptSig);
let outputScript = bitcoin.script.scriptHash.output.encode(addressBytes);
let address = bitcoin.address.fromOutputScript(
outputScript,
bitcoin.networks.bitcoin,
);
let address = bitcoin.address.fromOutputScript(outputScript, bitcoin.networks.bitcoin);

return address;
}
Expand All @@ -115,10 +108,7 @@ export class HDSegwitP2SHWallet extends LegacyWallet {
let scriptSig = bitcoin.script.witnessPubKeyHash.output.encode(keyhash);
let addressBytes = bitcoin.crypto.hash160(scriptSig);
let outputScript = bitcoin.script.scriptHash.output.encode(addressBytes);
return bitcoin.address.fromOutputScript(
outputScript,
bitcoin.networks.bitcoin,
);
return bitcoin.address.fromOutputScript(outputScript, bitcoin.networks.bitcoin);
}

async fetchBalance() {
Expand All @@ -141,9 +131,7 @@ export class HDSegwitP2SHWallet extends LegacyWallet {
let offset = 0;

while (1) {
let response = await api.get(
'/multiaddr?active=' + this.getXpub() + '&n=100&offset=' + offset,
);
let response = await api.get('/multiaddr?active=' + this.getXpub() + '&n=100&offset=' + offset);

if (response && response.body) {
if (response.body.txs && response.body.txs.length === 0) {
Expand Down Expand Up @@ -173,10 +161,7 @@ export class HDSegwitP2SHWallet extends LegacyWallet {
}
if (path[path.length - 2] === '0') {
// main (aka external) address
this.next_free_address_index = Math.max(
path[path.length - 1] * 1 + 1,
this.next_free_address_index,
);
this.next_free_address_index = Math.max(path[path.length - 1] * 1 + 1, this.next_free_address_index);
// setting to point to last maximum known main address + 1
}
// done with cache
Expand All @@ -201,10 +186,7 @@ export class HDSegwitP2SHWallet extends LegacyWallet {
}
if (path[path.length - 2] === '0') {
// main (aka external) address
this.next_free_address_index = Math.max(
path[path.length - 1] * 1 + 1,
this.next_free_address_index,
);
this.next_free_address_index = Math.max(path[path.length - 1] * 1 + 1, this.next_free_address_index);
// setting to point to last maximum known main address + 1
}
// done with cache
Expand Down
Loading

0 comments on commit b369a1b

Please sign in to comment.