UNPKG

@ledgerhq/coin-stacks

Version:
26 lines 896 B
import { getMainAccount, isTokenAccount } from "@ledgerhq/coin-framework/account/index"; import { getSubAccount } from "./token"; export const getAccountInfo = ({ account, parentAccount, transaction, }) => { const mainAccount = getMainAccount(account, parentAccount); const isTokenType = isTokenAccount(account); if (transaction && !transaction.subAccountId) { transaction.subAccountId = isTokenType ? account.id : null; } let tokenAccountTxn = false; let subAccount; if (isTokenType) { tokenAccountTxn = true; subAccount = account; } if (transaction?.subAccountId && !subAccount) { tokenAccountTxn = true; subAccount = getSubAccount(mainAccount, transaction) ?? null; } return { mainAccount, subAccount, isTokenType, tokenAccountTxn, }; }; //# sourceMappingURL=account.js.map