UNPKG

@ledgerhq/coin-hedera

Version:
68 lines (66 loc) 1.98 kB
import { formatCurrencyUnit } from "@ledgerhq/coin-module-framework/currencies/index"; import { getAccountCurrency } from "@ledgerhq/ledger-wallet-framework/account/index"; import { deviceActionFlow, SpeculosButton } from "@ledgerhq/ledger-wallet-framework/bot/specs"; import type { DeviceAction } from "@ledgerhq/ledger-wallet-framework/bot/types"; import type { Transaction } from "../types"; export const acceptTransaction: DeviceAction<Transaction, any> = deviceActionFlow({ steps: [ { title: "Transfer", }, { title: "with Key #0?", button: SpeculosButton.RIGHT, }, { title: "Operator", button: SpeculosButton.RIGHT, expectedValue: ({ account }) => account.freshAddress, }, { title: "Sender", button: SpeculosButton.RIGHT, expectedValue: ({ account }) => account.freshAddress, }, { title: "Recipient", button: SpeculosButton.RIGHT, expectedValue: ({ transaction }) => transaction.recipient, }, { title: "Amount", button: SpeculosButton.RIGHT, expectedValue: ({ account, status: { amount } }) => { return ( formatCurrencyUnit(getAccountCurrency(account).units[0], amount, { disableRounding: true, showAllDigits: true, }) + " hbar" ); }, }, { title: "Fee", button: SpeculosButton.RIGHT, expectedValue: ({ account, status: { estimatedFees } }) => formatCurrencyUnit(getAccountCurrency(account).units[0], estimatedFees, { disableRounding: true, showAllDigits: true, }) + " hbar", }, { title: "Max Fee", button: SpeculosButton.RIGHT, expectedValue: () => "1 hbar", }, { title: "Memo", button: SpeculosButton.RIGHT, expectedValue: ({ transaction }) => transaction.memo as string, }, { title: "Confirm", button: SpeculosButton.BOTH, }, ], });