@ledgerhq/coin-aptos
Version:
Ledger Aptos Coin integration
88 lines • 3.08 kB
JavaScript
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/formatCurrencyUnit";
import { getAccountCurrency, getMainAccount } from "@ledgerhq/coin-framework/account/helpers";
async function getDeviceTransactionConfig({ account, parentAccount, transaction, }) {
const { mode } = transaction;
const fields = [];
const mainAccount = getMainAccount(account, parentAccount);
const { fees } = transaction;
if (fees) {
fields.push({
type: "text",
label: "Transaction Fee",
value: formatCurrencyUnit(getAccountCurrency(mainAccount).units[0], fees, {
showCode: true,
disableRounding: true,
}),
});
}
if (mode === "send") {
if (account.type === "TokenAccount") {
fields.push({
type: "text",
label: "Type",
value: "Token transfer",
});
fields.push({
type: "text",
label: "Amount",
value: formatCurrencyUnit(getAccountCurrency(account).units[0], transaction.amount, {
showCode: true,
disableRounding: true,
}),
});
}
else if (account.type === "Account") {
fields.push({
type: "text",
label: "Amount",
value: formatCurrencyUnit(getAccountCurrency(account).units[0], transaction.amount, {
showCode: true,
disableRounding: true,
}),
});
}
}
else if ((mode === "stake" || mode === "restake") && account.type === "Account") {
fields.push({
type: "text",
label: "Delegate to",
value: transaction.recipient,
});
fields.push({
type: "text",
label: "Amount",
value: formatCurrencyUnit(getAccountCurrency(account).units[0], transaction.amount, {
showCode: true,
disableRounding: true,
}),
});
}
else if (mode === "unstake" && account.type === "Account") {
fields.push({
type: "text",
label: "Undelegate from",
value: transaction.recipient,
});
fields.push({
type: "text",
label: "Amount",
value: formatCurrencyUnit(getAccountCurrency(account).units[0], transaction.amount, {
showCode: true,
disableRounding: true,
}),
});
}
else if (mode === "withdraw" && account.type === "Account") {
fields.push({
type: "text",
label: "Amount",
value: formatCurrencyUnit(getAccountCurrency(account).units[0], transaction.amount, {
showCode: true,
disableRounding: true,
}),
});
}
return fields;
}
export default getDeviceTransactionConfig;
//# sourceMappingURL=deviceTransactionConfig.js.map