UNPKG

@ledgerhq/live-common

Version:
28 lines 1.07 kB
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