Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async getBalance(address: string): Promise {
if (!Utils.isValidXAddress(address)) {
return Promise.reject(
new Error(XpringClientErrorMessages.xAddressRequired)
);
}
return this.getAccountInfo(address).then(async accountInfo => {
const balance = accountInfo.getBalance();
if (balance === undefined) {
return Promise.reject(
new Error(XpringClientErrorMessages.malformedResponse)
);
}
return BigInt(balance.getDrops());
});
}
public async send(
amount: BigInt | number | string,
destination: string,
sender: Wallet
): Promise {
if (!Utils.isValidXAddress(destination)) {
return Promise.reject(
new Error(XpringClientErrorMessages.xAddressRequired)
);
}
const normalizedAmount = this.toBigInt(amount);
return this.getFee().then(async fee => {
return this.getAccountInfo(sender.getAddress()).then(
async accountInfo => {
return this.getLastValidatedLedgerSequence().then(
async ledgerSequence => {
if (accountInfo.getSequence() === undefined) {
return Promise.reject(
new Error(XpringClientErrorMessages.malformedResponse)
);