@ledgerhq/coin-cardano
Version:
Ledger Cardano Coin integration
35 lines • 1.1 kB
JavaScript
import { BigNumber } from "bignumber.js";
import { buildTransaction } from "../buildTransaction";
import { CardanoNotEnoughFunds } from "../errors";
export async function getUndelegateTransactionStatus(account, transaction) {
const errors = {};
const warnings = {};
const cardanoResources = account.cardanoResources;
const estimatedFees = transaction.fees || new BigNumber(0);
if (!cardanoResources.delegation?.status) {
throw new Error("StakeKey is not registered");
}
if (account.balance.eq(0)) {
throw new CardanoNotEnoughFunds();
}
try {
await buildTransaction(account, transaction);
}
catch (e) {
if (e.message.toLowerCase() === "not enough ada" ||
e.message.toLowerCase() === "not enough tokens") {
errors.amount = new CardanoNotEnoughFunds();
}
else {
throw e;
}
}
return {
errors,
warnings,
estimatedFees,
amount: new BigNumber(0),
totalSpent: estimatedFees,
};
}
//# sourceMappingURL=undelegate.js.map