@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
19 lines (16 loc) • 596 B
text/typescript
import type { Account, FeeStrategy } from "@ledgerhq/types-live";
import type { NetworkInfo, Transaction } from "@ledgerhq/coin-bitcoin/types";
export const useFeesStrategy = (a: Account, t: Transaction): FeeStrategy[] => {
const networkInfo = t.networkInfo;
if (!networkInfo) return [];
const strategies = (networkInfo as NetworkInfo).feeItems.items
.map(feeItem => {
return {
label: feeItem.speed,
amount: feeItem.feePerByte,
unit: a.currency.units[a.currency.units.length - 1], // Should be sat
};
})
.reverse();
return strategies;
};