ADD: Test for file import

This commit is contained in:
Marcos Rodriguez Velez 2024-01-09 11:40:29 -04:00
parent d6d905a3bf
commit c3f8b9ac81
No known key found for this signature in database
GPG key ID: 6030B2F48CCE86D7
3 changed files with 26 additions and 11 deletions

View file

@ -322,7 +322,11 @@ const AztecoRedeemRoot = () => {
const ScanQRCodeStack = createNativeStackNavigator();
const ScanQRCodeRoot = () => (
<ScanQRCodeStack.Navigator initialRouteName='ScanQRCode' name="ScanQRCodeRoot" screenOptions={{ headerShown: false, presentation: 'fullScreenModal' }}>
<ScanQRCodeStack.Navigator
initialRouteName="ScanQRCode"
name="ScanQRCodeRoot"
screenOptions={{ headerShown: false, presentation: 'fullScreenModal' }}
>
<ScanQRCodeStack.Screen name="ScanQRCode" component={ScanQRCode} initialParams={ScanQRCode.initialParams} />
</ScanQRCodeStack.Navigator>
);

View file

@ -1,6 +1,6 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { ScrollView, View, StyleSheet, Linking, Platform } from 'react-native';
import { ScrollView, View, StyleSheet, Linking } from 'react-native';
import wif from 'wif';
import bip38 from 'bip38';
import BIP32Factory from 'bip32';
@ -19,6 +19,7 @@ import {
import ecc from '../blue_modules/noble_ecc';
import Button from '../components/Button';
import SafeArea from '../components/SafeArea';
import alert from '../components/Alert';
const bitcoin = require('bitcoinjs-lib');
const BlueCrypto = require('react-native-blue-crypto');
const encryption = require('../blue_modules/encryption');
@ -44,6 +45,20 @@ export default class Selftest extends Component {
fs.writeFileAndExport('bluewallet-storagesave-test.txt', 'Success');
};
onPressImportDocument = async () => {
try {
fs.showFilePickerAndReadFile().then(file => {
if (file && file.data && file.data.length > 0) {
alert(file.data);
} else {
alert('Error reading file');
}
});
} catch (err) {
console.log(err);
}
};
async componentDidMount() {
let errorMessage = '';
let isOk = true;
@ -300,12 +315,10 @@ export default class Selftest extends Component {
);
}
})()}
{Platform.OS === 'android' && (
<>
<BlueSpacing20 />
<Button title="Test Save to Storage" onPress={this.onPressSaveToStorage} />
</>
)}
<BlueSpacing20 />
<Button title="Test Save to Storage" onPress={this.onPressSaveToStorage} />
<BlueSpacing20 />
<Button title="Test Save to File Import" onPress={this.onPressImportDocument} />
</ScrollView>
</BlueCard>
</SafeArea>

View file

@ -461,9 +461,7 @@ const WalletsAddMultisigStep2 = () => {
fs.showActionSheet({ anchor: findNodeHandle(openScannerButton.current) }).then(onBarScanned);
} else {
setIsProvideMnemonicsModalVisible(false);
InteractionManager.runAfterInteractions(() =>
scanQrHelper(navigation.navigate, onBarScanned)
);
InteractionManager.runAfterInteractions(() => scanQrHelper(navigation.navigate, onBarScanned));
}
};