Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
itemTestsuite.att('name', suiteName);
itemTestsuite.att('tests', nbrTests);
itemTestsuite.att('failures', nbrFailures);
itemTestsuite.att('timestamp', "2016-01-22T14:40:44.874443-05:00");//TODO use real timestamp
}
// export unit tests results
let xmlString = rootXml.end({
pretty: true,
indent: ' ',
newline: '\n',
});
// write the unit tests reports
const path = RNFS.MainBundlePath + "/tests.xml";
await RNFS.writeFile(path, xmlString, 'utf8');
//using console.log output is not shown in Release builds. using console.warn
console.warn(xmlString);
console.warn('__REALM_JS_TESTS_COMPLETED__');
if (failingTests.length !== 0) {
console.error('\n\nREALM_FAILING_TESTS\n');
console.error(failingTests);
}
}
catch (e) {
console.error(e);
}
finally {
console.warn("Realm Tests App finished. Exiting. Disable this to debug the app locally");
RNExitApp.exitApp();
}
shareMessage = () => {
const { currencyCode, publicAddress } = this.props
let sharedAddress = this.state.encodedURI
// if encoded (like XTZ), only share the public address
if (currencyCode && Constants.getSpecialCurrencyInfo(currencyCode).isUriEncodedStructure) {
sharedAddress = publicAddress
}
const title = sprintf(s.strings.request_qr_email_title, s.strings.app_name, currencyCode)
const message = sprintf(s.strings.request_qr_email_title, s.strings.app_name, currencyCode) + ': ' + sharedAddress
const path = Platform.OS === Constants.IOS ? RNFS.DocumentDirectoryPath + '/' + title + '.txt' : RNFS.ExternalDirectoryPath + '/' + title + '.txt'
RNFS.writeFile(path, message, 'utf8')
.then(success => {
const url = Platform.OS === Constants.IOS ? 'file://' + path : ''
const shareOptions = {
url,
title,
message: sharedAddress
}
Share.open(shareOptions).catch(e => console.log(e))
})
.catch(showError)
}
async function saveFileInDocumentsFolder(data) {
const path = `${RNFS.DocumentDirectoryPath}/${BINARY_ATTACHMENT_STORAGE_FILENAME}`;
RNFS.writeFile(path, data, DEFAULT_ENCODING)
.then(() => console.log('Binary attachment saved'))
.catch(err => console.error(err.message));
}
const queries = [];
for (const [index, amount] of amounts.entries()) {
const result = await measureQueries(amount);
queries.push(result);
setState({
progress: `queries: ${Math.round(index * 100 / amounts.length)}%`,
});
}
const report = {
writes,
reads,
queries,
};
await RNFS.writeFile(path, JSON.stringify(report), 'utf8');
running = false;
return path;
} catch (e) {
console.error(e);
running = false;
return 'Error';
}
}
static callback(dataURL) {
RNFS.writeFile(qrPath, dataURL, 'base64');
}
async function savePrivateKeyToLocalDisk(
account: string,
privateKey: string,
encryptionPassword: string
) {
ensureAddressAndKeyMatch(account, privateKey)
const filePath = getPrivateKeyFilePath(account)
const plainTextData = privateKey
const encryptedData: Buffer = getEncryptedData(plainTextData, encryptionPassword)
Logger.debug('savePrivateKeyToLocalDisk', `Writing encrypted private key to ${filePath}`)
await RNFS.writeFile(getPrivateKeyFilePath(account), encryptedData.toString('hex'))
}
writeFile(path, string, encoding = 'base64') {
return RNFS.writeFile(path, string, encoding);
}
svg.toDataURL(async (data: string) => {
const path = RNFS.DocumentDirectoryPath + QRFileName
try {
await RNFS.writeFile(path, data, 'base64')
Share.open({
url: 'file://' + path,
type: 'image/png',
}).catch((err: Error) => {
throw err
})
} catch (e) {
Logger.warn(TAG, e)
}
})
}
async function writeGenesisBlock(nodeDir: string, genesisBlock: string) {
Logger.debug(`writeGenesisBlock genesis block is: "${genesisBlock}"`)
const genesisBlockFile = getGenesisBlockFile(nodeDir)
await RNFS.mkdir(getFolder(genesisBlockFile))
await RNFS.writeFile(genesisBlockFile, genesisBlock, 'utf8')
}