Browse Source

resolved conflict

snyk-fix-84644e4a03e171e392ba652f3dc364b5
Overtorment 5 years ago
parent
commit
b142ea45fc
  1. 1
      analytics.js
  2. 4
      class/hd-segwit-p2sh-wallet.js
  3. 2
      package.json
  4. 14
      screen/wallets/export.js
  5. 133
      screen/wallets/hodlHodl.js
  6. 6
      screen/wallets/list.js
  7. 4
      screen/wallets/transactions.js
  8. 2
      shim.js
  9. 12
      tests/e2e/bluewallet.spec.js
  10. 18
      tests/e2e/selftest.spec.js

1
analytics.js

@ -24,6 +24,7 @@ A.ENUM = {
CREATED_WALLET: 'CREATED_WALLET',
CREATED_LIGHTNING_WALLET: 'CREATED_LIGHTNING_WALLET',
APP_UNSUSPENDED: 'APP_UNSUSPENDED',
NAVIGATED_TO_WALLETS_HODLHODL: 'NAVIGATED_TO_WALLETS_HODLHODL',
};
module.exports = A;

4
class/hd-segwit-p2sh-wallet.js

@ -154,4 +154,8 @@ export class HDSegwitP2SHWallet extends AbstractHDElectrumWallet {
});
return address;
}
allowHodlHodlTrading() {
return true;
}
}

2
package.json

@ -39,7 +39,7 @@
"postinstall": "./node_modules/.bin/rn-nodeify --install buffer,events,process,stream,util,inherits,fs,path --hack; npm run releasenotes2json; npm run podinstall; npx jetify",
"test": "npm run unit && npm run jest && npm run lint",
"jest": "node node_modules/jest/bin/jest.js tests/integration/*",
"e2e:release": "detox build -c android.emu.release; detox test -c android.emu.release --record-videos all --take-screenshots all --headless --cleanup",
"e2e:release": "detox build -c android.emu.release; detox test -c android.emu.release --record-videos all --take-screenshots all --headless",
"e2e:debug": "test -f android/app/build/outputs/apk/debug/app-debug.apk || detox build -c android.emu.debug; detox test -c android.emu.debug --cleanup",
"lint": "./node_modules/.bin/eslint *.js screen/**/*.js screen/ class/ models/ loc/ tests/integration/ tests/e2e/ tests/unit/",
"lint:fix": "./node_modules/.bin/eslint *.js screen/**/*.js screen/ class/ models/ loc/ tests/integration/ tests/e2e/ tests/unit/ --fix",

14
screen/wallets/export.js

@ -68,14 +68,10 @@ export default class WalletExport extends Component {
}
return (
<SafeBlueArea style={{ flex: 1, paddingTop: 20 }}>
<ScrollView
centerContent
contentContainerStyle={{ alignItems: 'center', justifyContent: 'center', flexGrow: 1 }}
onLayout={this.onLayout}
>
<SafeBlueArea style={{ flex: 1 }}>
<ScrollView contentContainerStyle={{ alignItems: 'center', justifyContent: 'center', flexGrow: 1 }} onLayout={this.onLayout}>
<View>
<BlueText>{this.state.wallet.typeReadable}</BlueText>
<BlueText style={{ fontSize: 17, fontWeight: '700', color: '#0c2550' }}>{this.state.wallet.typeReadable}</BlueText>
</View>
{(() => {
@ -103,7 +99,9 @@ export default class WalletExport extends Component {
{this.state.wallet.type === LightningCustodianWallet.type ? (
<BlueCopyTextToClipboard text={this.state.wallet.getSecret()} />
) : (
<BlueText style={{ alignItems: 'center', paddingHorizontal: 8 }}>{this.state.wallet.getSecret()}</BlueText>
<BlueText style={{ alignItems: 'center', paddingHorizontal: 16, fontSize: 16, color: '#0C2550', lineHeight: 24 }}>
{this.state.wallet.getSecret()}
</BlueText>
)}
</ScrollView>
</SafeBlueArea>

133
screen/wallets/hodlHodl.js

@ -13,12 +13,14 @@ import {
Platform,
Image,
TextInput,
ScrollView,
} from 'react-native';
import { BlueNavigationStyle, BlueLoading, BlueCard } from '../../BlueComponents';
import { BlueNavigationStyle, BlueLoading, BlueCard, SafeBlueArea } from '../../BlueComponents';
import PropTypes from 'prop-types';
import { HodlHodlApi } from '../../class/hodl-hodl-api';
import Modal from 'react-native-modal';
import { Icon } from 'react-native-elements';
const A = require('../../analytics');
const CURRENCY_CODE_ANY = '_any';
const METHOD_ANY = '_any';
@ -26,7 +28,8 @@ const METHOD_ANY = '_any';
const styles = StyleSheet.create({
grayDropdownText: {
fontSize: 17,
color: 'gray',
fontWeight: '600',
color: '#9AA0AA',
},
modalContent: {
backgroundColor: '#FFFFFF',
@ -47,8 +50,8 @@ const styles = StyleSheet.create({
borderTopLeftRadius: 16,
borderTopRightRadius: 16,
borderColor: 'rgba(0, 0, 0, 0.1)',
minHeight: 150,
height: 150,
minHeight: 200,
height: 200,
},
bottomModal: {
justifyContent: 'flex-end',
@ -68,11 +71,15 @@ const styles = StyleSheet.create({
},
grayDropdownTextContainer: {
backgroundColor: '#ebebeb',
backgroundColor: '#EEF0F4',
borderRadius: 20,
width: 100,
height: 35,
top: 10,
top: 3,
paddingLeft: 2,
paddingBottom: 6,
paddingTop: 6,
paddingRight: 0,
justifyContent: 'center',
alignItems: 'center',
flex: 0.65,
@ -80,9 +87,9 @@ const styles = StyleSheet.create({
},
grayTextContainerContainer: {
backgroundColor: '#ebebeb',
backgroundColor: '#EEF0F4',
borderRadius: 20,
height: 40,
height: 44,
justifyContent: 'center',
alignItems: 'center',
marginTop: 15,
@ -96,10 +103,11 @@ const styles = StyleSheet.create({
blueText: {
color: '#2f5fb3',
fontSize: 18,
fontWeight: '600',
},
allOffersText: {
fontSize: 12,
color: 'gray',
color: '#9AA0AA',
position: 'absolute',
top: 0,
left: 15,
@ -109,20 +117,21 @@ const styles = StyleSheet.create({
left: 5,
color: '#0c2550',
fontSize: 20,
fontWeight: '100',
fontWeight: '500',
},
nicknameText: {
color: '#0c2550',
fontSize: 16,
fontWeight: '700',
fontSize: 18,
fontWeight: '600',
},
blueTextContainer: {
backgroundColor: '#ccddf9',
backgroundColor: '#CCDDF9',
borderRadius: 20,
width: 110,
flex: 1,
flexDirection: 'row',
height: 34,
height: 36,
paddingLeft: 8,
justifyContent: 'center',
alignItems: 'center',
right: 4,
@ -131,17 +140,17 @@ const styles = StyleSheet.create({
searchInputContainer: {
flexDirection: 'row',
borderColor: '#d2d2d2',
borderBottomColor: '#d2d2d2',
borderColor: '#EEF0F4',
borderBottomColor: '#EEF0F4',
borderWidth: 1.0,
borderBottomWidth: 0.5,
backgroundColor: '#f5f5f5',
minHeight: 44,
height: 44,
backgroundColor: '#EEF0F4',
minHeight: 48,
height: 48,
marginHorizontal: 20,
alignItems: 'center',
marginVertical: 8,
borderRadius: 22,
borderRadius: 26,
width: '100%',
},
});
@ -255,6 +264,7 @@ export default class HodlHodl extends Component {
async componentDidMount() {
console.log('wallets/hodlHodl - componentDidMount');
A(A.ENUM.NAVIGATED_TO_WALLETS_HODLHODL);
try {
await this.fetchMyCountry();
@ -424,6 +434,7 @@ export default class HodlHodl extends Component {
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'position' : null}>
<View style={styles.modalContentShort}>
<FlatList
scrollEnabled={false}
style={{ width: '100%' }}
ItemSeparatorComponent={() => <View style={{ height: 0.5, width: '100%', backgroundColor: '#C8C8C8' }} />}
data={[
@ -437,8 +448,10 @@ export default class HodlHodl extends Component {
onHideUnderlay={separators.unhighlight}
onPress={() => this._onSidePress(item)}
>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row', paddingTop: 20 }}>
<Text style={{ color: '#0c2550', fontWeight: this.state.side === item.code ? 'bold' : 'normal' }}>{item.name}</Text>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row', paddingTop: 20, paddingBottom: 20 }}>
<Text style={{ fontSize: 20, color: '#0c2550', fontWeight: this.state.side === item.code ? 'bold' : 'normal' }}>
{item.name}
</Text>
</View>
</TouchableHighlight>
)}
@ -471,6 +484,7 @@ export default class HodlHodl extends Component {
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'position' : null}>
<View style={styles.modalContentShort}>
<FlatList
scrollEnabled={false}
style={{ width: '100%' }}
ItemSeparatorComponent={() => <View style={{ height: 0.5, width: '100%', backgroundColor: '#C8C8C8' }} />}
data={[
@ -488,17 +502,20 @@ export default class HodlHodl extends Component {
}}
>
<View style={{ backgroundColor: 'white' }}>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row', paddingTop: 20 }}>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row', paddingTop: 20, paddingBottom: 20 }}>
<View style={{ paddingLeft: 10, flex: 1, flexDirection: 'row' }}>
<Text style={{ color: '#0c2550' }}>{item.native_name}</Text>
<View style={{ color: 'gray', right: 0, position: 'absolute' }}>
<Text style={{ fontSize: 20, color: '#0c2550' }}>{item.native_name}</Text>
<View style={{ color: '#9AA0AA', right: 0, position: 'absolute' }}>
{item.code === 'currency' && (
<Text style={{ color: 'gray' }}> {this.state.currency ? this.state.currency + ' >' : 'Detail >'} </Text>
<Text style={{ fontSize: 18, color: '#9AA0AA' }}>
{' '}
{this.state.currency ? this.state.currency + ' ❯' : 'Detail ❯'}{' '}
</Text>
)}
{item.code === 'method' && (
<Text style={{ color: 'gray' }}>
<Text style={{ fontSize: 20, color: '#9AA0AA' }}>
{' '}
{this.state.method ? this.getMethodName(this.state.method) + ' >' : 'Detail >'}
{this.state.method ? this.getMethodName(this.state.method) + ' ❯' : 'Detail ❯'}
</Text>
)}
</View>
@ -565,9 +582,10 @@ export default class HodlHodl extends Component {
<TextInput
onChangeText={text => this.setState({ countrySearchInput: text })}
placeholder={'Search..'}
placeholderTextColor="#9AA0AA"
value={this.state.countrySearchInput || ''}
numberOfLines={1}
style={{ flex: 1, marginHorizontal: 8, minHeight: 33 }}
style={{ fontSize: 17, flex: 1, marginHorizontal: 8, minHeight: 33, paddingLeft: 6, paddingRight: 6 }}
/>
<Icon name="search" type="material" size={20} color="gray" containerStyle={{ left: -10 }} />
</View>
@ -583,9 +601,9 @@ export default class HodlHodl extends Component {
onHideUnderlay={separators.unhighlight}
>
<View style={{ backgroundColor: 'white' }}>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row', paddingTop: 20 }}>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row', paddingTop: 20, paddingBottom: 20 }}>
<View style={{ paddingLeft: 10 }}>
<Text style={{ color: '#0c2550', fontWeight: item.code === this.state.country ? 'bold' : 'normal' }}>
<Text style={{ fontSize: 20, color: '#0c2550', fontWeight: item.code === this.state.country ? 'bold' : 'normal' }}>
{item.native_name}
</Text>
</View>
@ -640,9 +658,10 @@ export default class HodlHodl extends Component {
<TextInput
onChangeText={text => this.setState({ currencySearchInput: text })}
placeholder={'Search..'}
placeholderTextColor="#9AA0AA"
value={this.state.currencySearchInput || ''}
numberOfLines={1}
style={{ flex: 1, marginHorizontal: 8, minHeight: 33 }}
style={{ flex: 1, marginHorizontal: 8, minHeight: 33, paddingLeft: 6, paddingRight: 6 }}
/>
<Icon name="search" type="material" size={20} color="gray" containerStyle={{ left: -10 }} />
</View>
@ -658,10 +677,11 @@ export default class HodlHodl extends Component {
onHideUnderlay={separators.unhighlight}
>
<View style={{ backgroundColor: 'white' }}>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row', paddingTop: 20 }}>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row', paddingTop: 20, paddingBottom: 20 }}>
<View style={{ paddingLeft: 10 }}>
<Text
style={{
fontSize: 20,
color: '#0c2550',
fontWeight:
item.code === this.state.currency || (item.code === CURRENCY_CODE_ANY && this.state.currency === false)
@ -723,9 +743,10 @@ export default class HodlHodl extends Component {
<TextInput
onChangeText={text => this.setState({ methodSearchInput: text })}
placeholder={'Search..'}
placeholderTextColor="#9AA0AA"
value={this.state.methodSearchInput || ''}
numberOfLines={1}
style={{ flex: 1, marginHorizontal: 8, minHeight: 33 }}
style={{ flex: 1, marginHorizontal: 8, minHeight: 33, paddingLeft: 6, paddingRight: 6 }}
/>
<Icon name="search" type="material" size={20} color="gray" containerStyle={{ left: -10 }} />
</View>
@ -741,10 +762,11 @@ export default class HodlHodl extends Component {
onHideUnderlay={separators.unhighlight}
>
<View style={{ backgroundColor: 'white' }}>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row', paddingTop: 20 }}>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row', paddingTop: 20, paddingBottom: 20 }}>
<View style={{ paddingLeft: 10 }}>
<Text
style={{
fontSize: 20,
color: '#0c2550',
fontWeight:
item.id === this.state.method || (item.id === METHOD_ANY && this.state.method === false) ? 'bold' : 'normal',
@ -766,7 +788,7 @@ export default class HodlHodl extends Component {
render() {
return (
<View>
<SafeBlueArea>
<BlueCard style={{ alignItems: 'center', flex: 1 }}>
<View style={{ flexDirection: 'row' }}>
<Text style={styles.BottomLine}>Powered by HodlHodl®</Text>
@ -778,7 +800,7 @@ export default class HodlHodl extends Component {
}}
>
<Text style={styles.grayDropdownText}>{this.state.side === HodlHodlApi.FILTERS_SIDE_VALUE_SELL ? 'Buying' : 'Selling'}</Text>
<Icon name="expand-more" type="material" size={22} color="gray" containerStyle={{ paddingLeft: 0 }} />
<Icon name="expand-more" type="material" size={22} color="#9AA0AA" containerStyle={{ paddingLeft: 0, paddingRight: 0 }} />
</TouchableOpacity>
</View>
@ -797,29 +819,35 @@ export default class HodlHodl extends Component {
this.setState({ isFiltersModalVisible: true });
}}
>
<Text style={styles.blueText}> Filters</Text>
<Text style={styles.blueText}>Filters</Text>
<Icon name="filter-list" type="material" size={24} color="#2f5fb3" containerStyle={{ paddingLeft: 10 }} />
</TouchableOpacity>
</View>
</View>
</BlueCard>
{(this.state.isLoading && <BlueLoading />) || (
<ScrollView style={{ paddingHorizontal: 24 }}>
<FlatList
onRefresh={() => this._refresh()}
refreshing={this.state.isLoading}
style={{ height: '80%', marginTop: 10 }}
contentContainerStyle={{ flex: 1, justifyContent: 'center', paddingHorizontal: 0 }}
style={{ marginTop: 24, flex: 1 }}
ItemSeparatorComponent={() => <View style={{ height: 0.5, width: '100%', backgroundColor: '#C8C8C8' }} />}
data={this.state.offers}
ListEmptyComponent={() => <Text>No offers. Try changing country or filters!</Text>}
ListEmptyComponent={() => (
<Text style={{ textAlign: 'center', color: '#9AA0AA', paddingHorizontal: 16 }}>
No offers. Try to change "Near me" to Global offers!
</Text>
)}
renderItem={({ item, index, separators }) => (
<TouchableHighlight
onPress={() => this._onPress(item)}
onShowUnderlay={separators.highlight}
onHideUnderlay={separators.unhighlight}
>
<View style={{ backgroundColor: 'white' }}>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row', paddingTop: 20 }}>
<View style={{ backgroundColor: 'white', paddingTop: 16, paddingBottom: 16 }}>
<View style={{ backgroundColor: 'white', flex: 1, flexDirection: 'row' }}>
<View>
<Image
style={{ width: 40, height: 40, borderRadius: 40 }}
@ -831,29 +859,30 @@ export default class HodlHodl extends Component {
</View>
<View style={{ paddingLeft: 10 }}>
<Text style={styles.nicknameText}>{item.trader.login}</Text>
<Text style={{ color: 'grey' }}>
<Text style={{ color: '#9AA0AA' }}>
{item.trader.trades_count > 0 ? Math.round(item.trader.rating * 100) + '%' : 'No rating'}
</Text>
</View>
</View>
<Text style={{ color: 'grey', paddingTop: 10 }}>{this.getItemText(item)}</Text>
<Text style={{ color: '#9AA0AA', paddingTop: 10 }}>{this.getItemText(item)}</Text>
<View style={{ flex: 1, flexDirection: 'row', paddingTop: 10, paddingBottom: 10, alignItems: 'center' }}>
<View
style={{
backgroundColor: '#ebebeb',
backgroundColor: '#EEF0F4',
borderRadius: 20,
width: 95,
height: 22,
paddingLeft: 8,
paddingRight: 8,
height: 26,
justifyContent: 'center',
alignItems: 'center',
}}
>
<Text style={{ fontSize: 14, color: 'gray' }}>{this.getItemPrice(item)}</Text>
<Text style={{ fontWeight: '600', fontSize: 14, color: '#9AA0AA' }}>{this.getItemPrice(item)}</Text>
</View>
<Text style={{ color: 'grey', fontSize: 12, paddingLeft: 10 }}>
<Text style={{ color: '#9AA0AA', fontSize: 12, paddingLeft: 10 }}>
Min/Max: {item.min_amount.replace('.00', '')} - {item.max_amount.replace('.00', '')} {item.currency_code}
</Text>
</View>
@ -861,8 +890,8 @@ export default class HodlHodl extends Component {
</TouchableHighlight>
)}
/>
</ScrollView>
)}
</BlueCard>
{this.renderChooseSideModal()}
@ -873,7 +902,7 @@ export default class HodlHodl extends Component {
{this.renderChooseCurrencyModal()}
{this.renderChooseMethodModal()}
</View>
</SafeBlueArea>
);
}
}

6
screen/wallets/list.js

@ -311,7 +311,11 @@ export default class WalletsList extends Component {
};
_renderItem = data => {
return <BlueTransactionListItem item={data.item} itemPriceUnit={data.item.walletPreferredBalanceUnit} />;
return (
<View style={{ marginHorizontal: 4 }}>
<BlueTransactionListItem item={data.item} itemPriceUnit={data.item.walletPreferredBalanceUnit} />
</View>
);
};
renderNavigationHeader = () => {

4
screen/wallets/transactions.js

@ -228,7 +228,7 @@ export default class WalletTransactions extends Component {
style={{
flex: 1,
marginLeft: 16,
marginTop: 24,
marginTop: 8,
marginBottom: 8,
fontWeight: 'bold',
fontSize: 24,
@ -444,11 +444,13 @@ export default class WalletTransactions extends Component {
renderItem = item => {
return (
<View style={{ marginHorizontal: 4 }}>
<BlueTransactionListItem
item={item.item}
itemPriceUnit={this.state.wallet.getPreferredBalanceUnit()}
shouldRefresh={this.state.timeElapsed}
/>
</View>
);
};

2
shim.js

@ -1,4 +1,5 @@
/* global __DEV__, localStorage */
if (typeof Buffer === 'undefined') global.Buffer = require('buffer').Buffer;
if (typeof __dirname === 'undefined') global.__dirname = '/';
if (typeof __filename === 'undefined') global.__filename = '';
if (typeof process === 'undefined') {
@ -13,7 +14,6 @@ if (typeof process === 'undefined') {
}
process.browser = false;
if (typeof Buffer === 'undefined') global.Buffer = require('buffer').Buffer;
global.net = require('react-native-tcp');
global.tls = require('react-native-tcp/tls');

12
tests/e2e/bluewallet.spec.js

@ -5,17 +5,6 @@ describe('BlueWallet UI Tests', () => {
await yo('WalletsList');
});
it('selftest passes', async () => {
await yo('WalletsList');
// go to settings, press SelfTest and wait for OK
await element(by.id('SettingsButton')).tap();
await element(by.id('AboutButton')).tap();
await element(by.id('AboutScrollView')).swipe('up', 'fast', 1); // in case emu screen is small and it doesnt fit
await element(by.id('RunSelfTestButton')).tap();
await yo('SelfTestOk', 600 * 1000);
});
it('can encrypt storage, with plausible deniability', async () => {
await yo('WalletsList');
@ -221,6 +210,7 @@ describe('BlueWallet UI Tests', () => {
it('can encrypt storage, and decrypt storage, but this time the fake one', async () => {
// this test mostly repeats previous one, except in the end it logins with FAKE password to unlock FAKE
// storage bucket, and then decrypts it. effectively, everything from MAIN storage bucket is lost
if (process.env.TRAVIS) return; // skipping on CI to not take time (plus it randomly fails)
await yo('WalletsList');
await helperCreateWallet();
await element(by.id('SettingsButton')).tap();

18
tests/e2e/selftest.spec.js

@ -0,0 +1,18 @@
/* global it, describe, element, by, waitFor */
describe('BlueWallet Selftest', () => {
it('passes', async () => {
await waitFor(element(by.id('WalletsList')))
.toBeVisible()
.withTimeout(1200 * 1000);
// go to settings, press SelfTest and wait for OK
await element(by.id('SettingsButton')).tap();
await element(by.id('AboutButton')).tap();
await element(by.id('AboutScrollView')).swipe('up', 'fast', 1); // in case emu screen is small and it doesnt fit
await element(by.id('RunSelfTestButton')).tap();
await waitFor(element(by.id('SelfTestOk')))
.toBeVisible()
.withTimeout(1200 * 1000);
});
});
Loading…
Cancel
Save