@cfxlabsinc/b2b-services
    Preparing search index...

    Readonly access to a customer's ledger accounts.

    Extends LedgerAccountCache, which owns the ledger-account-search namespace this read shares with the admin surface.

    Hierarchy (View Summary)

    Index
    cache: ServiceCache<CachedSearchPage<LedgerAccountSearchItem>>
    db: B2bDatabase
    walletAccountBalanceQueryService: WalletAccountBalanceQueryService
    withoutBalanceCache: ServiceCache<
        CachedSearchPage<LedgerAccountSearchItemWithoutBalance>,
    >

    Balance-free pages: their own key space, reached by the same namespace tags.

    instance: (...args: []) => LedgerAccountQueryService = ...

    The process default: built from each dependency's own instance().

    • Get the given ledger account for the given customer

      Parameters

      • args: { customerId: string; id: string }

      Returns Promise<
          {
              ok: true;
              value: | {
                  address: Address;
                  balance: BigNumber;
                  createdAt: Date;
                  id: string;
                  name: string;
                  notes?: string;
                  paymentInstrumentId?: string;
                  permissions: "ALL"
                  | "ADMIN";
                  referenceId?: string;
                  tokenAccounts: Partial<Record<"MOVEUSD", { address: Address }>>;
                  updatedAt: Date;
                  visibility: "PRIVATE" | "PUBLIC";
              } & {
                  customerOrganizationId: string;
                  entityDisplayName: string;
                  entityId: string;
                  entityReferenceId: string
                  | null;
                  entityType: "IDENTITY" | "ORGANIZATION";
              }
              | null;
          },
      >

    • Every address each of this customer's accounts holds, per chain, ordered by chain then address. Every requested id is present, [] when unknown.

      Parameters

      • __namedParameters: { customerId: string; ids: string[] }

      Returns Promise<{ ok: true; value: T }>

    • MOVEUSD total of the customer's accounts, or of these entities' accounts. Customer-wide reads wallet_balance_total; the view groups the whole customer before any entity filter, so entities sum the per-row subquery.

      Parameters

      • __namedParameters: { customerId: string; entityIds?: string[] }

      Returns Promise<{ ok: true; value: { totalBalance: BigNumber } }>

    • Get a public ledger account that belongs to any customer

      Parameters

      • __namedParameters: { id: string }

      Returns Promise<
          | Omit<
              {
                  address: Address;
                  balance: BigNumber;
                  createdAt: Date;
                  id: string;
                  name: string;
                  notes?: string;
                  paymentInstrumentId?: string;
                  permissions: "ALL"
                  | "ADMIN";
                  referenceId?: string;
                  tokenAccounts: Partial<Record<"MOVEUSD", { address: Address }>>;
                  updatedAt: Date;
                  visibility: "PRIVATE" | "PUBLIC";
              },
              "balance",
          > & { customer: Pick<Customer, "id" | "name" | "logoPath"> }
          | null,
      >

    • Return per-entity account metadata and counts for the given customer. One row per entity (identity or organization). main is true when the entity is the customer's primary organization.

      Parameters

      • __namedParameters: { customerId: string }

      Returns Promise<
          {
              ok: true;
              value: {
                  items: {
                      count: number;
                      customerOrganizationId: string;
                      entityDisplayName: string;
                      entityId: string;
                      entityReferenceId: string
                      | null;
                      entityType: "IDENTITY" | "ORGANIZATION";
                      main: boolean;
                  }[];
              };
          },
      >

    • Whether any of the customer's accounts holds MOVEUSD. Not a search filter: its count(*) OVER () values every funded row (126 ms against 1.4 ms on 3,000 accounts), where this stops at the first.

      Parameters

      • __namedParameters: { customerId: string }

      Returns Promise<{ ok: true; value: boolean }>

    • Clear each customer's membership tag and each record tag wherever cached, and always this namespace's collection tag. keys are exact deletes in this instance's key space: the only bust a null client honours.

      Parameters

      • __namedParameters: {
            customerIds: readonly string[];
            keys?: readonly CacheKey[];
            records?: readonly string[];
        }

      Returns Promise<void>

    • The bust every ledger account write makes, whatever it changed: its record tag in every namespace copying its columns, its customer's pages on both surfaces, and the folded get keys, the one bust a null client honours. A balance change is no account write and clears none of it.

      Parameters

      • __namedParameters: { customerId: string; id: string }

      Returns Promise<void>

    • Search ledger accounts of the given customer. cache: "bypass" skips the cached read for a caller about to write on the answer; the fresh result still refreshes the entry.

      Parameters

      Returns Promise<
          {
              ok: true;
              value: {
                  hasNext: boolean;
                  items: LedgerAccountSearchItem[];
                  total: number;
              };
          },
      >

    • Search all customers' public ledger accounts

      Parameters

      • __namedParameters: {
            addresses?: Address[];
            customerIds?: string[];
            customerNameLike?: string;
            ids?: string[];
        }

      Returns Promise<
          (
              Omit<
                  {
                      address: Address;
                      balance: BigNumber;
                      createdAt: Date;
                      id: string;
                      name: string;
                      notes?: string;
                      paymentInstrumentId?: string;
                      permissions: "ALL"
                      | "ADMIN";
                      referenceId?: string;
                      tokenAccounts: Partial<Record<"MOVEUSD", { address: Address }>>;
                      updatedAt: Date;
                      visibility: "PRIVATE" | "PUBLIC";
                  },
                  "balance",
              > & { customer: Pick<Customer, "id" | "name" | "logoPath"> }
          )[],
      >

    • Tags for a page: the scope its query searched (each customer's membership tag, else the collection tag), so an empty page is bustable too, plus the records it projects and the fields that chose or ordered its rows.

      Parameters

      • __namedParameters: {
            customerIds: readonly string[] | undefined;
            fields?: readonly string[];
            records?: readonly string[];
        }

      Returns string[]