@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
35 lines • 1.45 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUpdateAccountWithUpdaterParams = void 0;
const addToSwapHistory_1 = __importDefault(require("./addToSwapHistory"));
const index_1 = require("../../account/index");
const getUpdateAccountWithUpdaterParams = ({ result, exchange, transaction, magnitudeAwareRate, provider, }) => {
const { operation, swapId } = result;
const mainAccount = exchange.fromAccount && (0, index_1.getMainAccount)(exchange.fromAccount, exchange.fromParentAccount);
if (!mainAccount)
return [];
const accountUpdater = (account) => {
if (!transaction)
return account;
const accountWithUpdatedHistory = (0, addToSwapHistory_1.default)({
account,
operation,
transaction,
swap: {
exchange,
exchangeRate: {
magnitudeAwareRate,
provider,
},
},
swapId,
});
return (0, index_1.addPendingOperation)(accountWithUpdatedHistory, operation);
};
return [mainAccount.id, accountUpdater];
};
exports.getUpdateAccountWithUpdaterParams = getUpdateAccountWithUpdaterParams;
//# sourceMappingURL=getUpdateAccountWithUpdaterParams.js.map