Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Doing the check here because need to validate before doing parseInt
const tokensValue = valueStr*(10**hathorLib.constants.DECIMAL_PLACES);
if (tokensValue > hathorLib.constants.MAX_OUTPUT_VALUE) {
this.props.updateState({ errorMessage: `Token: ${this.state.selected.symbol}. Output: ${output.current.props.index}. Maximum output value is ${hathorLib.helpers.prettyValue(hathorLib.constants.MAX_OUTPUT_VALUE)}` });
return null;
}
let dataOutput = {'address': address, 'value': parseInt(tokensValue, 10), 'tokenData': hathorLib.tokens.getTokenIndex(this.state.selectedTokens, this.state.selected.uid)};
const hasTimelock = output.current.timelockCheckbox.current.checked;
if (hasTimelock) {
const timelock = output.current.timelock.current.value;
if (!timelock) {
this.props.updateState({ errorMessage: `Token: ${this.state.selected.symbol}. Output: ${output.current.props.index}. You need to fill a complete date and time` });
return null;
}
const timestamp = hathorLib.dateFormatter.dateToTimestamp(new Date(timelock));
dataOutput['timelock'] = timestamp;
}
data['outputs'].push(dataOutput);
}
}
const noInputs = this.noInputs.current.checked;
if (!noInputs) {
for (const input of this.inputs) {
const txId = input.current.txId.current.value;
const index = input.current.index.current.value;
if (txId && index) {
data['inputs'].push({'tx_id': txId, 'index': index, 'token': this.state.selected.uid });
}