Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async checkNodeStatus() {
const { errorToastDisplayed, history, liskAPIClient } = this.props;
// istanbul ignore else
if (liskAPIClient) {
const [error, response] = await to(liskAPIClient.node.getConstants());
if (response) history.push(routes.dashboard.path);
if (error) errorToastDisplayed({ label: `Unable to connect to the node, Error: ${error.message}` });
}
}
(async function() {
const [error1, data] = await to(fs.readJson('./package.json'));
if (error1) return console.error(error1);
data.dependencies = _.omit(data.dependencies, [
'expo',
'react',
'react-native',
]);
data.private = false;
const [error2] = await to(
fs.writeJson('./dist/package.json', data, { spaces: 2 })
);
if (error2) return console.error(error2);
})();
(async function() {
const [error1, data] = await to(fs.readJson('./package.json'));
if (error1) return console.error(error1);
data.dependencies = _.omit(data.dependencies, [
'expo',
'react',
'react-native',
]);
data.private = false;
const [error2] = await to(
fs.writeJson('./dist/package.json', data, { spaces: 2 })
);
if (error2) return console.error(error2);
})();
export const login = ({ passphrase, publicKey, hwInfo }) => async (dispatch, getState) => {
const { network: networkConfig, settings } = getState();
dispatch(accountLoading());
const expireTime = (passphrase && settings.autoLog)
? Date.now() + accountConfig.lockDuration
: 0;
const activeTokens = Object.keys(settings.token.list)
.filter(key => settings.token.list[key]);
const [error, info] = await to(getAccounts(activeTokens, {
networkConfig, publicKey, passphrase,
}));
if (error) {
dispatch(errorToastDisplayed({ label: getConnectionErrorMessage(error) }));
dispatch(accountLoggedOut());
} else {
dispatch(accountLoggedIn({
passphrase,
loginType: hwInfo ? loginType[hwInfo.deviceModel.replace(/\s.+$/, '').toLowerCase()] : loginType.normal,
hwInfo: hwInfo || {},
expireTime,
info,
}));
}
};
async checkNodeStatus(showErrorToaster = true) {
const {
liskAPIClient, errorToastDisplayed, network,
} = this.props;
if (liskAPIClient) {
this.setState({
network: network.networks.LSK.code,
activeNetwork: network.networks.LSK.code,
});
const [error] = await to(liskAPIClient.node.getConstants());
if (error) {
if (network.name === networks.customNode.name) {
this.setValidationError();
} else {
this.setState(({ validationError: '' }));
}
if (showErrorToaster) {
errorToastDisplayed({ label: `Unable to connect to the node, Error: ${error.message}` });
}
}
}
}
export default async function LoadTags(client) {
let database, err;
[ err , database ] = await to(getDB());
if (err) {
setTimeout(LoadTags, 5 * 1000);
return;
}
database.query("SELECT `name`, `created_at` FROM `tags`", (err, results) => {
if (err) {
throw err;
}
for (const result of results) {
let tag = new Tag(result.name);
tag.setCreatedAt(result.created_at);
async run() {
const stmt = format(
"DELETE FROM advertisements WHERE `expiration` < ?",
Math.floor(Date.now() / 1000),
);
let database, err;
[ err , database ] = await to(getDB());
if (err) {
return;
}
database.query(stmt, (err, results) => {
if (err) {
return;
}
/**
* Emitted when sweeping is complete
*
* @event GrouperClient#sweeped
* @param {number} results.affectedRows Number of rows affected or deleted
*/
export const updateEnabledTokenAccount = token => async (dispatch, getState) => {
const { network: networkConfig, account } = getState();
if (token !== tokenMap.LSK.key) {
const [error, result] = await to(getAccount({
token,
networkConfig,
passphrase: account.passphrase,
}));
if (error) {
dispatch(errorToastDisplayed({ label: getConnectionErrorMessage(error) }));
} else {
dispatch(accountUpdated(result));
}
}
};
async onSubmitPin(e) {
e.preventDefault();
const { pin } = this.state;
const { deviceId, t, nextStep } = this.props;
this.setState({ isLoading: true });
const [error] = await to(validatePin({ deviceId, pin }));
if (error) {
this.setState({
isLoading: false, error: true, feedback: t('Invalid PIN'), pin: '',
});
} else {
nextStep({ deviceId });
}
}
async getAccountsFromDevice() {
const { device, networkConfig, errorToastDisplayed } = this.props;
const [error, accounts] = await to(getAccountsFromDevice({ device, networkConfig }));
if (error) {
errorToastDisplayed({ label: `Error retrieving accounts from device: ${error}` });
} else {
const hwAccounts = accounts.map((account, index) => ({
...account,
name: this.getNameFromAccount(account.address),
shouldShow: !!account.balance || index === 0,
}));
this.setState({ hwAccounts });
}
}