@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
20 lines (18 loc) • 592 B
text/typescript
export type AmountScreenMessage = Readonly<{
type: "error" | "warning" | "info";
text: string;
}>;
export function getAmountScreenMessage(params: {
amountErrorTitle?: string;
amountWarningTitle?: string;
isFeeTooHigh: boolean;
hasRawAmount: boolean;
}): AmountScreenMessage | null {
if (params.amountErrorTitle && params.hasRawAmount) {
return { type: "error", text: params.amountErrorTitle };
}
if (params.amountWarningTitle && params.hasRawAmount) {
return { type: params.isFeeTooHigh ? "info" : "warning", text: params.amountWarningTitle };
}
return null;
}