@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
    entityService: EntityService
    eventPublisher: CustomerEventPublisher
    phonePaymentInstrumentAdminService: Pick<
        PhonePaymentInstrumentAdminService,
        "linkWaiting",
    >
    solanaTokenMintAddressService: SolanaTokenMintAddressService
    temporalClient: TemporalWorkflowClient<Workflows>
    walletAccountBalanceQueryService: WalletAccountBalanceQueryService
    walletApiClient: Pick<WalletApiClient, "createWallet" | "importWallet">
    withoutBalanceCache: ServiceCache<
        CachedSearchPage<LedgerAccountSearchItemWithoutBalance>,
    >

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

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

    The process default: wallet-api's create deployment, the network and queue read at each create.

    • The guards create({ wallet }) runs before it writes, writing nothing: a dry run that reports what the real create would refuse.

      Parameters

      • __namedParameters: { customerId: string; entityId: string; secretId: string }

      Returns Promise<
          | { ok: true; value: void }
          | {
              error:
                  | ServiceError<"INVALID_ENTITY">
                  | ServiceError<"NO_ADDRESS">
                  | ServiceError<"WALLET_SECRET_NOT_ALLOWED">;
              ok: false;
          },
      >

    • Parameters

      • args: CreateLedgerAccountArgs

      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";
              };
          }
          | { error: CreateLedgerAccountError; ok: false },
      >

    • 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;
          },
      >

    • 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;
                  }[];
              };
          },
      >

    • 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>

    • 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[]

    • Parameters

      • __namedParameters: {
            customerId: string;
            data: Partial<Pick<LedgerAccount, "referenceId" | "name" | "notes">>;
            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";
              };
          }
          | { error: ServiceError; ok: false },
      >