Skip to content

Commit

Permalink
Merge branch 'master' into encryptprompt
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosrdz committed Aug 11, 2024
2 parents 6326f5c + 0db76c6 commit f46406f
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 30 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
"test": "npm run tslint && npm run lint && npm run unit && npm run jest",
"jest": "jest tests/integration/*",
"e2e:debug-build": "detox build -c android.debug",
"e2e:debug-test": "detox test -c android.debug -d 200000 -l info",
"e2e:debug-test": "detox test -c android.debug -d 200000 --loglevel error --reuse",
"e2e:debug": "(test -f android/app/build/outputs/apk/debug/app-debug.apk && test -f android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk) || npm run e2e:debug-build; npm run e2e:debug-test",
"e2e:release-build": "detox build -c android.release",
"e2e:release-test": "detox test -c android.release",
"e2e:release-test": "detox test -c android.release --loglevel error",
"tslint": "tsc",
"lint": " npm run tslint && node scripts/find-unused-loc.js && eslint --ext .js,.ts,.tsx '*.@(js|ts|tsx)' screen 'blue_modules/*.@(js|ts|tsx)' class models loc tests components navigation typings",
"lint:fix": "npm run lint -- --fix",
Expand Down
6 changes: 5 additions & 1 deletion screen/receive/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,11 @@ const ReceiveDetails = () => {

return (
<>
<ScrollView contentContainerStyle={[styles.root, stylesHook.root]} keyboardShouldPersistTaps="always">
<ScrollView
testID="ReceiveDetailsScrollView"
contentContainerStyle={[styles.root, stylesHook.root]}
keyboardShouldPersistTaps="always"
>
{wallet?.allowBIP47() && wallet.isBIP47Enabled() && (
<View style={styles.tabsContainer}>
<SegmentedControl
Expand Down
22 changes: 16 additions & 6 deletions screen/wallets/PaymentCodesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default function PaymentCodesList() {
if (!(await confirm(loc.wallets.details_are_you_sure))) {
return;
}
counterpartyMetadata[pc] = { label: counterpartyMetadata[pc]?.label ?? '', hidden: true };
counterpartyMetadata[pc] = { label: counterpartyMetadata[pc]?.label, hidden: true };
setReload(Math.random());
await saveToDisk();
break;
Expand All @@ -191,20 +191,22 @@ export default function PaymentCodesList() {
});
};

const renderItem = (pc: string) => {
const renderItem = (pc: string, index: number) => {
if (counterpartyMetadata?.[pc]?.hidden) return null; // hidden contact, do not render

const color = createHash('sha256').update(pc).digest().toString('hex').substring(0, 6);

const displayName = shortenContactName(counterpartyMetadata?.[pc]?.label ?? pc);
const displayName = shortenContactName(counterpartyMetadata?.[pc]?.label || pc);

if (previousRouteName === 'SendDetails') {
return (
<TouchableOpacity onPress={() => onToolTipPress(Actions.pay, pc)}>
<View style={styles.contactRowContainer}>
<View style={[styles.circle, { backgroundColor: '#' + color }]} />
<View style={styles.contactRowBody}>
<Text style={[styles.contactRowNameText, { color: colors.labelText }]}>{displayName}</Text>
<Text testID={`ContactListItem${index}`} style={[styles.contactRowNameText, { color: colors.labelText }]}>
{displayName}
</Text>
</View>
</View>
<View style={styles.stick} />
Expand All @@ -222,7 +224,9 @@ export default function PaymentCodesList() {
<View style={styles.contactRowContainer}>
<View style={[styles.circle, { backgroundColor: '#' + color }]} />
<View style={styles.contactRowBody}>
<Text style={[styles.contactRowNameText, { color: colors.labelText }]}>{displayName}</Text>
<Text testID={`ContactListItem${index}`} style={[styles.contactRowNameText, { color: colors.labelText }]}>
{displayName}
</Text>
</View>
</View>
<View style={styles.stick} />
Expand Down Expand Up @@ -260,6 +264,7 @@ export default function PaymentCodesList() {
if (cl.isAddressValid(newPc)) {
// this is not a payment code but a regular onchain address. pretending its a payment code and adding it
foundWallet.addBIP47Receiver(newPc);
await saveToDisk();
setReload(Math.random());
return;
}
Expand All @@ -272,6 +277,7 @@ export default function PaymentCodesList() {
if (cl.isBip352PaymentCodeValid(newPc)) {
// ok its a SilentPayments code, notification tx is not needed, just add it to recipients:
foundWallet.addBIP47Receiver(newPc);
await saveToDisk();
setReload(Math.random());
return;
}
Expand Down Expand Up @@ -354,7 +360,11 @@ export default function PaymentCodesList() {
<Text>Internal error</Text>
) : (
<View style={styles.sectionListContainer}>
<SectionList sections={data} keyExtractor={(item, index) => item + index} renderItem={({ item }) => renderItem(item)} />
<SectionList
sections={data}
keyExtractor={(item, index) => item + index}
renderItem={({ item, index }) => renderItem(item, index)}
/>
</View>
)}

Expand Down
11 changes: 8 additions & 3 deletions screen/wallets/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const WalletDetails = () => {
const [useWithHardwareWallet, setUseWithHardwareWallet] = useState(wallet.useWithHardwareWalletEnabled());
const { isAdvancedModeEnabled } = useSettings();
const [isBIP47Enabled, setIsBIP47Enabled] = useState(wallet.isBIP47Enabled());
const [isContactsVisible, setIsContactsVisible] = useState(wallet.allowBIP47() && wallet.isBIP47Enabled());
const [hideTransactionsInWalletsList, setHideTransactionsInWalletsList] = useState(!wallet.getHideTransactionsInWalletsList());
const { goBack, setOptions, navigate } = useExtendedNavigation();
const { colors } = useTheme();
Expand All @@ -135,6 +136,10 @@ const WalletDetails = () => {
const onMenuWillShow = () => setIsToolTipMenuVisible(true);
const onMenuWillHide = () => setIsToolTipMenuVisible(false);

useEffect(() => {
setIsContactsVisible(isBIP47Enabled);
}, [isBIP47Enabled]);

useEffect(() => {
if (isAdvancedModeEnabled && wallet.allowMasterFingerprint()) {
InteractionManager.runAfterInteractions(() => {
Expand Down Expand Up @@ -523,7 +528,7 @@ const WalletDetails = () => {
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.bip47.payment_code}</Text>
<View style={styles.hardware}>
<BlueText>{loc.bip47.purpose}</BlueText>
<Switch value={isBIP47Enabled} onValueChange={setIsBIP47Enabled} />
<Switch value={isBIP47Enabled} onValueChange={setIsBIP47Enabled} testID="BIP47Switch" />
</View>
</>
) : null}
Expand Down Expand Up @@ -563,9 +568,9 @@ const WalletDetails = () => {
{(wallet instanceof AbstractHDElectrumWallet || (wallet.type === WatchOnlyWallet.type && wallet.isHd())) && (
<ListItem disabled={isToolTipMenuVisible} onPress={navigateToAddresses} title={loc.wallets.details_show_addresses} chevron />
)}
{wallet.allowBIP47() && wallet.isBIP47Enabled() && (
{isContactsVisible ? (
<ListItem disabled={isToolTipMenuVisible} onPress={navigateToContacts} title={loc.bip47.contacts} chevron />
)}
) : null}
<BlueCard style={styles.address}>
<View>
<BlueSpacing20 />
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/bluewallet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ describe('BlueWallet UI Tests - no wallets', () => {
const feeRate = 3;
await element(by.id('chooseFee')).tap();
await element(by.id('feeCustom')).tap();
await element(by.type('android.widget.EditText')).typeText(feeRate + '');
await element(by.type('android.widget.EditText')).typeText(feeRate + '\n');
await element(by.text('OK')).tap();

if (process.env.TRAVIS) await sleep(5000);
Expand Down
Loading

0 comments on commit f46406f

Please sign in to comment.