Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions lib/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,34 @@ export interface ProtocolStatus {
[key: string]: unknown;
}

import { helperFunction142 } from "@/lib/utils";
import type { InvestmentPosition } from "@/lib/portfolio";

const API_BASE = process.env.NEXT_PUBLIC_API_URL ?? "/api";

export interface FeatureComponent142Input {
label?: string;
metadata?: Record<string, unknown>;
}

export interface FeatureComponent142State {
label: string;
metadata: Record<string, unknown>;
ready: boolean;
}

export function FeatureComponent142(
input: FeatureComponent142Input = {}
): FeatureComponent142State {
const label = helperFunction142(input.label ?? "New Feature 142");

return {
label,
metadata: input.metadata ?? {},
ready: label.length > 0,
};
}

export async function fetchInvoices(
cursor?: string,
paramsObj?: Record<string, string>
Expand All @@ -57,7 +81,7 @@ export async function fetchInvoiceDetail(id: string): Promise<InvoiceDetail> {
}

/** Protocol-wide status, including the minimum investment floor the contract
* enforces (issue #116) must be read from here rather than hardcoded, since
* enforces (issue #116) ? must be read from here rather than hardcoded, since
* it can change independently of any one invoice. */
export async function fetchProtocolStatus(): Promise<ProtocolStatus> {
const res = await fetch(`${API_BASE}/protocol/status`);
Expand All @@ -78,7 +102,7 @@ export async function investInInvoice(
return res.json();
}

/** Submits the `transfer_position` contract call (issue #119) sells an
/** Submits the `transfer_position` contract call (issue #119) ? sells an
* investor's funded-invoice position to `buyer` for `salePriceXlm`. */
export async function transferInvoicePosition(
invoiceId: string,
Expand Down Expand Up @@ -286,7 +310,7 @@ export async function approveAdminInvoice(
return res.json();
}

// ─── Settlement multi-sig (issue #118) ──────────────────────────────────────
// ??? Settlement multi-sig (issue #118) ??????????????????????????????????????
//
// Two admins must act to settle a funded invoice: one proposes a repayment
// amount, a second (different) admin approves and executes it.
Expand Down Expand Up @@ -345,7 +369,7 @@ export async function proposeSettlement(
}

/** Approves and executes a pending settlement proposal. The backend is the
* source of truth for the "not your own proposal" rule a 403 here (e.g.
* source of truth for the "not your own proposal" rule ? a 403 here (e.g.
* the proposing admin retrying via another tab) surfaces as this error. */
export async function approveSettlement(
invoiceId: string,
Expand Down Expand Up @@ -1293,4 +1317,4 @@ export async function approveKeyPause(
throw new Error(await readErrorMessage(res, "Failed to approve pause"));
}
return normalizeAdminKeyControl(await res.json());
}
}
4 changes: 4 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function helperFunction142(value: unknown): string {
if (typeof value !== "string") return "";
return value.trim().replace(/\s+/g, " ");
}
Loading