@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
28 lines • 1.07 kB
JavaScript
import addToSwapHistory from "./addToSwapHistory";
import { addPendingOperation, getMainAccount } from "../../account/index";
export const getUpdateAccountWithUpdaterParams = ({ result, exchange, transaction, magnitudeAwareRate, provider, }) => {
const { operation, swapId } = result;
const mainAccount = exchange.fromAccount && getMainAccount(exchange.fromAccount, exchange.fromParentAccount);
if (!mainAccount)
return [];
const accountUpdater = (account) => {
if (!transaction)
return account;
const accountWithUpdatedHistory = addToSwapHistory({
account,
operation,
transaction,
swap: {
exchange,
exchangeRate: {
magnitudeAwareRate,
provider,
},
},
swapId,
});
return addPendingOperation(accountWithUpdatedHistory, operation);
};
return [mainAccount.id, accountUpdater];
};
//# sourceMappingURL=getUpdateAccountWithUpdaterParams.js.map