Utilities & Helpers

getEscrowStatusLabel

getEscrowStatusLabel(state: EscrowState): EscrowStatusLabel

Converts the numeric EscrowState into a beautiful, ready-to-use object with:

  • Human-readable label
  • Tailwind color class
  • Helpful description

Perfect for badges, tags, status pills, or dashboards.

Parameters

  • state: EscrowState – The current state from contract or parsed escrow

Returns

EscrowStatusLabel object

interface EscrowStatusLabel {
  label: string;        // e.g. "Awaiting Payment"
  color: string;        // Tailwind color: "orange", "blue", "red", etc.
  description: string;  // Short explanation
}
import { createPalindromeSDK } from '@/lib/createSDK';
import { EscrowState } from '@palindromecryptoescrow/sdk';

const { sdk } = await connectAndInitSDK();

const escrow = await sdk.getEscrowByIdParsed(42n);
const status = sdk.getEscrowStatusLabel(escrow.state);

console.log("Status:", status);
// Example output:
// { label: "Awaiting Delivery", color: "blue", description: "Seller should deliver product/service" }

// Use in React:
<div className={`inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-${status.color}-100 text-${status.color}-800`}>
  {status.label}
</div>

All States & Colors

StateLabelColorDescription
AWAITING_PAYMENTAwaiting PaymentorangeBuyer needs to deposit funds
AWAITING_DELIVERYAwaiting DeliveryblueSeller should deliver product/service
DISPUTEDDisputedredDispute in progress — arbiter will resolve
COMPLETECompletegreenTransaction completed successfully
REFUNDEDRefundedgrayFunds returned to buyer
CANCELEDCanceledgrayEscrow was canceled
WITHDRAWNWithdrawngrayFunds have been claimed

Example Badge Component

<StatusBadge state={escrow.state} />

function StatusBadge({ state }: { state: EscrowState }) {
  const s = sdk.getEscrowStatusLabel(state);
  return (
    <span className={`px-3 py-1 rounded-full text-xs font-semibold bg-${s.color}-100 text-${s.color}-800`}>
      {s.label}
    </span>
  );
}

See alsogetEscrowByIdParsed() · getMaturityInfo()

Previous
getMaturityInfo