import createTransaction from "@ledgerhq/coin-polkadot/bridge/createTransaction";
const CAN_EDIT_FEES = true;
const areFeesProvided = tx => !!tx.fee;
const convertToLiveTransaction = ({ account, walletApiTransaction }) => {
    const hasFeesProvided = areFeesProvided(walletApiTransaction);
    const liveTx = createTransaction(account);
    if (walletApiTransaction.amount) {
        liveTx.amount = walletApiTransaction.amount;
    }
    if (walletApiTransaction.recipient) {
        liveTx.recipient = walletApiTransaction.recipient;
    }
    if (walletApiTransaction.mode) {
        liveTx.mode = walletApiTransaction.mode;
    }
    if (walletApiTransaction.fee) {
        liveTx.fees = walletApiTransaction.fee;
    }
    if (walletApiTransaction.era) {
        liveTx.era = `${walletApiTransaction.era}`;
    }
    if (walletApiTransaction.rewardDestination) {
        liveTx.rewardDestination = walletApiTransaction.rewardDestination;
    }
    if (walletApiTransaction.validators) {
        liveTx.validators = walletApiTransaction.validators;
    }
    if (walletApiTransaction.numOfSlashingSpans) {
        liveTx.numSlashingSpans = walletApiTransaction.numOfSlashingSpans;
    }
    if (hasFeesProvided) {
        liveTx.feesStrategy = null;
    }
    return liveTx;
};
const getWalletAPITransactionSignFlowInfos = ({ walletApiTransaction, account }) => {
    return {
        canEditFees: CAN_EDIT_FEES,
        liveTx: convertToLiveTransaction({ walletApiTransaction, account }),
        hasFeesProvided: areFeesProvided(walletApiTransaction),
    };
};
export default { getWalletAPITransactionSignFlowInfos };
//# sourceMappingURL=walletApiAdapter.js.map