Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
: BigNumber(t.amount);
if (amount.gt(0) && estimatedFees.times(10).gt(amount)) {
warnings.feeTooHigh = new FeeTooHigh();
}
// Fill up transaction errors...
if (totalSpent.gt(account.balance)) {
errors.amount = new NotEnoughBalance();
}
// Fill up recipient errors...
if (!t.recipient) {
errors.recipient = new RecipientRequired("");
} else if (isInvalidRecipient(t.recipient)) {
errors.recipient = new InvalidAddress("");
}
return Promise.resolve({
errors,
warnings,
estimatedFees,
amount,
totalSpent
});
};
: BigNumber(t.amount);
if (amount.gt(0) && estimatedFees.times(10).gt(amount)) {
warnings.feeTooHigh = new FeeTooHigh();
}
// Fill up transaction errors...
if (totalSpent.gt(account.balance)) {
errors.amount = new NotEnoughBalance();
}
// Fill up recipient errors...
if (!t.recipient) {
errors.recipient = new RecipientRequired("");
} else if (isInvalidRecipient(t.recipient)) {
errors.recipient = new InvalidAddress("");
}
return Promise.resolve({
errors,
warnings,
estimatedFees,
amount,
totalSpent
});
};
errors.amount = new NotEnoughSpendableBalance();
} else if (
minimalBaseAmount &&
t.recipient.includes("new") &&
amount.lt(minimalBaseAmount)
) {
// mimic XRP base minimal for new addresses
errors.amount = new NotEnoughBalanceBecauseDestinationNotCreated(null, {
minimalAmount: `XRP Minimum reserve`
});
}
if (!t.recipient) {
errors.recipient = new RecipientRequired("");
} else if (isInvalidRecipient(t.recipient)) {
errors.recipient = new InvalidAddress("");
} else if (a.freshAddress === t.recipient) {
errors.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
}
return Promise.resolve({
errors,
warnings,
estimatedFees,
amount,
totalSpent
});
};
test("Lowercase recipient address should have a recipientError", async () => {
let t = {
...bridge.createTransaction(account),
recipient: "dcovduyafuefmk2qvuw5xdtaunla2lp72n"
};
let status = await bridge.getTransactionStatus(account, t);
expect(status.errors.recipient).toEqual(new InvalidAddress());
});
return Promise.reject(new RecipientRequired(""));
}
const custom = customAddressValidationByFamily[arg.currency.family];
if (custom) {
const res = await custom(core, arg);
return res;
}
const poolInstance = core.getPoolInstance();
const currencyCore = await poolInstance.getCurrency(currency.id);
const value = await core.Address.isValid(recipient, currencyCore);
if (value) {
return Promise.resolve(null);
}
return Promise.reject(
new InvalidAddress(null, { currencyName: currency.name })
);
});
(account, recipient) => {
if (!recipient)
return Promise.reject(
new InvalidAddress("", { currencyName: account.currency.name })
);
return isValidRecipient({ currency: account.currency, recipient });
},
(currency, recipient) => `${currency.id}_${recipient}`
(account, recipient) => {
if (!recipient)
return Promise.reject(
new InvalidAddress("", { currencyName: account.currency.name })
);
return isValidRecipient({ currency: account.currency, recipient });
},
(currency, recipient) => `${currency.id}_${recipient}`
(account, recipient) => {
if (!recipient)
return Promise.reject(new InvalidAddress('', { currencyName: account.currency.name }))
return libcoreValidAddress
.send({
address: recipient,
currencyId: account.currency.id,
})
.toPromise()
},
(currency, recipient) => `${currency.id}_${recipient}`,
(account, recipient) => {
if (!recipient)
return Promise.reject(
new InvalidAddress("", { currencyName: account.currency.name }),
);
return isValidRecipient({ currency: account.currency, recipient });
},
(currency, recipient) => `${currency.id}_${recipient}`,
checkValidRecipient: (account, recipient) =>
isRecipientValid(account.currency, recipient)
? Promise.resolve(getRecipientWarning(account.currency, recipient))
: Promise.reject(new InvalidAddress('', { currencyName: account.currency.name })),