@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
19 lines • 1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccountTuplesForCurrency = void 0;
const helpers_1 = require("@ledgerhq/coin-framework/account/helpers");
function getAccountTuplesForCurrency(currency, allAccounts, accountIds) {
const isToken = currency.type === "TokenCurrency";
const targetCurrencyId = isToken ? currency.parentCurrency.id : currency.id;
return allAccounts
.filter(account => account.currency.id === targetCurrencyId &&
(isToken ? true : accountIds ? accountIds.has(account.id) : true))
.map(account => {
const subAccount = isToken
? account.subAccounts?.find((subAcc) => subAcc.type === "TokenAccount" && subAcc.token.id === currency.id) || (0, helpers_1.makeEmptyTokenAccount)(account, currency)
: null;
return { account, subAccount };
});
}
exports.getAccountTuplesForCurrency = getAccountTuplesForCurrency;
//# sourceMappingURL=getAccountTuplesForCurrency.js.map