Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const validateRequiredInputs = ({
recipientId,
recipientPublicKey,
senderPublicKey,
type,
}) => {
if (!(recipientId || recipientPublicKey)) {
throw new Error(
'Either recipientId or recipientPublicKey must be provided.',
);
}
if (typeof recipientId !== 'undefined') {
validateAddress(recipientId);
}
if (typeof recipientPublicKey !== 'undefined') {
validatePublicKey(recipientPublicKey);
}
if (
recipientId &&
recipientPublicKey &&
recipientId !== getAddressFromPublicKey(recipientPublicKey)
) {
throw new Error('recipientId does not match recipientPublicKey.');
}
if (!senderPublicKey) {
throw new Error(
recipientPublicKey,
senderPublicKey,
data,
}) => {
if (!validateTransferAmount(amount)) {
throw new Error('Amount must be a valid number in string format.');
}
if (!recipientId && !recipientPublicKey) {
throw new Error(
'Either recipientId or recipientPublicKey must be provided.',
);
}
if (typeof recipientId !== 'undefined') {
validateAddress(recipientId);
}
if (typeof senderPublicKey !== 'undefined') {
validatePublicKey(senderPublicKey);
}
if (typeof recipientPublicKey !== 'undefined') {
validatePublicKey(recipientPublicKey);
}
if (
recipientId &&
recipientPublicKey &&
recipientId !== getAddressFromPublicKey(recipientPublicKey)
) {
throw new Error('recipientId does not match recipientPublicKey.');
flags: {
networkIdentifier: networkIdentifierSource,
passphrase: passphraseSource,
'second-passphrase': secondPassphraseSource,
'no-signature': noSignature,
data: dataString,
},
} = this.parse(TransferCommand);
const { amount, address }: Args = args;
const networkIdentifier = getNetworkIdentifierWithInput(
networkIdentifierSource,
this.userConfig.api.network,
);
validateAddress(address);
const normalizedAmount = transactionUtils.convertLSKToBeddows(amount);
const processFunction = processInputs(
networkIdentifier,
normalizedAmount,
address,
dataString,
);
if (noSignature) {
const noSignatureResult = processFunction({
passphrase: undefined,
secondPassphrase: undefined,
});
this.print(noSignatureResult);