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

    Consumer withdrawal reads. Extends WithdrawalCache, which owns the withdrawal-search namespace these reads go through.

    Hierarchy (View Summary)

    Index
    cache: ServiceCache<CachedSearchPage<WithdrawalSearchItem>>
    db: B2bDatabase
    instance: (...args: []) => WithdrawalQueryService = ...

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

    • Get a withdrawal by ID without customer restriction

      Parameters

      • __namedParameters: {
            customerId: string;
            id: string;
            includeHistory?: boolean;
            tx?: PgAsyncTransaction<NodePgQueryResultHKT, EmptyRelations>;
        }

      Returns Promise<
          {
              ok: true;
              value: | {
                  createdAt: Date;
                  customerId: string;
                  data: {
                      achTraceId?: string;
                      addenda?: string;
                      companyEntryDescription?: string;
                      companyId?: string;
                      companyName?: string;
                      effectiveEntryDate?: string;
                      imad?: string;
                      methodTransactionId?: string;
                      omad?: string;
                      originatorName?: string;
                      routeFusionTransferId?: string;
                      secCode?: string;
                      settlementDate?: string;
                      signedTransaction?: string;
                      victorTraceId?: string;
                      victorTransactionId?: string;
                  };
                  entityId: string;
                  entityType: "IDENTITY"
                  | "ORGANIZATION";
                  feeSweepTxId: string | null;
                  feeSweepTxType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                  history: WithdrawalStatusUpdateHistory[];
                  id: string;
                  quote: {
                      createdAt: Date;
                      customerId: string;
                      deviceIpAddress: string | null;
                      deviceLocation: { lat: number; long: number; source: "ip" } | null;
                      entityId: string;
                      expiresAt: Date;
                      fees: (
                          {
                              amount: BigNumber;
                              receiver: "CUSTOMER"
                              | "PROVIDER"
                              | "CFX";
                              type: "FIXED" | "VARIABLE";
                          } & { currency: string }
                      )[];
                      id: string;
                      metadata: {
                          brand?: string;
                          marketing?: {
                              fbp?: string;
                              gclid?: string;
                              sub1?: string;
                              sub2?: string;
                              sub3?: string;
                              userAgent?: string;
                              utmCampaign?: string;
                              utmContent?: string;
                              utmMedium?: string;
                              utmSource?: string;
                          };
                      };
                      methodData: | {
                          achBatchId?: string;
                          bankId?: string;
                          sourceLedgerAccountId?: string;
                          speed?: "same-day"
                          | "next-day";
                          type: "ACH_CREDIT";
                          vendorId?: string;
                      }
                      | {
                          achId: string;
                          bankId?: string;
                          sourceLedgerAccountId?: string;
                          type: "ACH_DEBIT";
                          vendorId?: string;
                      }
                      | {
                          bankId?: string;
                          beneficiaryReference?: string;
                          purpose: WireWithdrawalPurpose;
                          senderMessage?: string;
                          sourceLedgerAccountId: string;
                          type: "SWIFT_WIRE"
                          | "US_WIRE";
                          vendorId?: string;
                          wireBatchId?: string;
                      }
                      | {
                          country: string;
                          sourceLedgerAccountId?: string;
                          type: "AF_WITHDRAWAL";
                          withdrawalType: "bank"
                          | "momo";
                      }
                      | {
                          asset?: {
                              decimals: number;
                              mint: string;
                              symbol: string;
                              tokenProgram: string;
                          };
                          sourceLedgerAccountId: string;
                          type: "BLOCKCHAIN";
                      }
                      | {
                          bankId?: string;
                          sourceLedgerAccountId?: string;
                          type: "US_INSTANT";
                          vendorId?: string;
                      }
                      | {
                          bankId?: string;
                          drawdownId: string;
                          sourceAccountId: string;
                          type: "US_WIRE_DRAWDOWN";
                          vendorId?: string;
                      }
                      | null;
                      methodId: | "ACH_CREDIT"
                      | "ACH_DEBIT"
                      | "BLOCKCHAIN"
                      | "MX_SPEI"
                      | "US_WIRE_DRAWDOWN"
                      | "US_INSTANT"
                      | "SWIFT_WIRE"
                      | "US_WIRE"
                      | "AF_WITHDRAWAL";
                      paymentInstrumentId: string;
                      productQuoteId: string;
                      providerQuoteId: string
                      | null;
                      sourceAmount: BigNumber;
                      sourceAmountAfterFees: BigNumber;
                      sourceCurrency: string;
                      status: "ACTIVE" | "ACCEPTED" | "REJECTED" | "EXPIRED";
                      targetAmount: BigNumber;
                      targetAmountAfterFees: BigNumber;
                      targetCurrency: string;
                      unsignedWithdrawalTransaction: string | null;
                      updatedAt: Date;
                      walletAddress: Address;
                      walletBlockchain: string;
                  };
                  receiptId: string
                  | null;
                  receiptType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                  returnReceiptId: string | null;
                  status: "PENDING" | "FAILED" | "PROCESSING" | "COMPLETED" | "RETURNED";
                  statusDescription: string;
                  sweepTxId: string | null;
                  sweepTxType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                  type:
                      | "ACH_CREDIT"
                      | "ACH_DEBIT"
                      | "BLOCKCHAIN"
                      | "MX_SPEI"
                      | "US_WIRE_DRAWDOWN"
                      | "US_INSTANT"
                      | "SWIFT_WIRE"
                      | "US_WIRE"
                      | "AF_WITHDRAWAL";
                  updatedAt: Date;
              }
              | null;
          },
      >

    • The withdrawal a quote produced, if any: a quote yields at most one.

      Parameters

      • __namedParameters: {
            customerId: string;
            quoteId: string;
            tx?: PgAsyncTransaction<NodePgQueryResultHKT, EmptyRelations>;
        }

      Returns Promise<
          {
              ok: true;
              value: | {
                  createdAt: Date;
                  customerId: string;
                  data: {
                      achTraceId?: string;
                      addenda?: string;
                      companyEntryDescription?: string;
                      companyId?: string;
                      companyName?: string;
                      effectiveEntryDate?: string;
                      imad?: string;
                      methodTransactionId?: string;
                      omad?: string;
                      originatorName?: string;
                      routeFusionTransferId?: string;
                      secCode?: string;
                      settlementDate?: string;
                      signedTransaction?: string;
                      victorTraceId?: string;
                      victorTransactionId?: string;
                  };
                  entityId: string;
                  entityType: "IDENTITY"
                  | "ORGANIZATION";
                  feeSweepTxId: string | null;
                  feeSweepTxType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                  history: WithdrawalStatusUpdateHistory[];
                  id: string;
                  quote: {
                      createdAt: Date;
                      customerId: string;
                      deviceIpAddress: string | null;
                      deviceLocation: { lat: number; long: number; source: "ip" } | null;
                      entityId: string;
                      expiresAt: Date;
                      fees: (
                          {
                              amount: BigNumber;
                              receiver: "CUSTOMER"
                              | "PROVIDER"
                              | "CFX";
                              type: "FIXED" | "VARIABLE";
                          } & { currency: string }
                      )[];
                      id: string;
                      metadata: {
                          brand?: string;
                          marketing?: {
                              fbp?: string;
                              gclid?: string;
                              sub1?: string;
                              sub2?: string;
                              sub3?: string;
                              userAgent?: string;
                              utmCampaign?: string;
                              utmContent?: string;
                              utmMedium?: string;
                              utmSource?: string;
                          };
                      };
                      methodData: | {
                          achBatchId?: string;
                          bankId?: string;
                          sourceLedgerAccountId?: string;
                          speed?: "same-day"
                          | "next-day";
                          type: "ACH_CREDIT";
                          vendorId?: string;
                      }
                      | {
                          achId: string;
                          bankId?: string;
                          sourceLedgerAccountId?: string;
                          type: "ACH_DEBIT";
                          vendorId?: string;
                      }
                      | {
                          bankId?: string;
                          beneficiaryReference?: string;
                          purpose: WireWithdrawalPurpose;
                          senderMessage?: string;
                          sourceLedgerAccountId: string;
                          type: "SWIFT_WIRE"
                          | "US_WIRE";
                          vendorId?: string;
                          wireBatchId?: string;
                      }
                      | {
                          country: string;
                          sourceLedgerAccountId?: string;
                          type: "AF_WITHDRAWAL";
                          withdrawalType: "bank"
                          | "momo";
                      }
                      | {
                          asset?: {
                              decimals: number;
                              mint: string;
                              symbol: string;
                              tokenProgram: string;
                          };
                          sourceLedgerAccountId: string;
                          type: "BLOCKCHAIN";
                      }
                      | {
                          bankId?: string;
                          sourceLedgerAccountId?: string;
                          type: "US_INSTANT";
                          vendorId?: string;
                      }
                      | {
                          bankId?: string;
                          drawdownId: string;
                          sourceAccountId: string;
                          type: "US_WIRE_DRAWDOWN";
                          vendorId?: string;
                      }
                      | null;
                      methodId: | "ACH_CREDIT"
                      | "ACH_DEBIT"
                      | "BLOCKCHAIN"
                      | "MX_SPEI"
                      | "US_WIRE_DRAWDOWN"
                      | "US_INSTANT"
                      | "SWIFT_WIRE"
                      | "US_WIRE"
                      | "AF_WITHDRAWAL";
                      paymentInstrumentId: string;
                      productQuoteId: string;
                      providerQuoteId: string
                      | null;
                      sourceAmount: BigNumber;
                      sourceAmountAfterFees: BigNumber;
                      sourceCurrency: string;
                      status: "ACTIVE" | "ACCEPTED" | "REJECTED" | "EXPIRED";
                      targetAmount: BigNumber;
                      targetAmountAfterFees: BigNumber;
                      targetCurrency: string;
                      unsignedWithdrawalTransaction: string | null;
                      updatedAt: Date;
                      walletAddress: Address;
                      walletBlockchain: string;
                  };
                  receiptId: string
                  | null;
                  receiptType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                  returnReceiptId: string | null;
                  status: "PENDING" | "FAILED" | "PROCESSING" | "COMPLETED" | "RETURNED";
                  statusDescription: string;
                  sweepTxId: string | null;
                  sweepTxType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                  type:
                      | "ACH_CREDIT"
                      | "ACH_DEBIT"
                      | "BLOCKCHAIN"
                      | "MX_SPEI"
                      | "US_WIRE_DRAWDOWN"
                      | "US_INSTANT"
                      | "SWIFT_WIRE"
                      | "US_WIRE"
                      | "AF_WITHDRAWAL";
                  updatedAt: Date;
              }
              | null;
          },
      >

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

    • A customer's withdrawals. Reads through the withdrawal-search cache, except under a caller's tx.

      Parameters

      • args: WithdrawalSearchArgs

      Returns Promise<
          {
              ok: true;
              value: {
                  hasNext: boolean;
                  items: {
                      createdAt: Date;
                      customerId: string;
                      data: {
                          achTraceId?: string;
                          addenda?: string;
                          companyEntryDescription?: string;
                          companyId?: string;
                          companyName?: string;
                          effectiveEntryDate?: string;
                          imad?: string;
                          methodTransactionId?: string;
                          omad?: string;
                          originatorName?: string;
                          routeFusionTransferId?: string;
                          secCode?: string;
                          settlementDate?: string;
                          signedTransaction?: string;
                          victorTraceId?: string;
                          victorTransactionId?: string;
                      };
                      entityId: string;
                      entityType: "IDENTITY"
                      | "ORGANIZATION";
                      feeSweepTxId: string | null;
                      feeSweepTxType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                      history: WithdrawalStatusUpdateHistory[];
                      id: string;
                      quote: {
                          createdAt: Date;
                          customerId: string;
                          deviceIpAddress: string | null;
                          deviceLocation: { lat: number; long: number; source: "ip" } | null;
                          entityId: string;
                          expiresAt: Date;
                          fees: (
                              {
                                  amount: BigNumber;
                                  receiver: "CUSTOMER"
                                  | "PROVIDER"
                                  | "CFX";
                                  type: "FIXED" | "VARIABLE";
                              } & { currency: string }
                          )[];
                          id: string;
                          metadata: {
                              brand?: string;
                              marketing?: {
                                  fbp?: string;
                                  gclid?: string;
                                  sub1?: string;
                                  sub2?: string;
                                  sub3?: string;
                                  userAgent?: string;
                                  utmCampaign?: string;
                                  utmContent?: string;
                                  utmMedium?: string;
                                  utmSource?: string;
                              };
                          };
                          methodData: | {
                              achBatchId?: string;
                              bankId?: string;
                              sourceLedgerAccountId?: string;
                              speed?: "same-day"
                              | "next-day";
                              type: "ACH_CREDIT";
                              vendorId?: string;
                          }
                          | {
                              achId: string;
                              bankId?: string;
                              sourceLedgerAccountId?: string;
                              type: "ACH_DEBIT";
                              vendorId?: string;
                          }
                          | {
                              bankId?: string;
                              beneficiaryReference?: string;
                              purpose: WireWithdrawalPurpose;
                              senderMessage?: string;
                              sourceLedgerAccountId: string;
                              type: "SWIFT_WIRE"
                              | "US_WIRE";
                              vendorId?: string;
                              wireBatchId?: string;
                          }
                          | {
                              country: string;
                              sourceLedgerAccountId?: string;
                              type: "AF_WITHDRAWAL";
                              withdrawalType: "bank"
                              | "momo";
                          }
                          | {
                              asset?: {
                                  decimals: number;
                                  mint: string;
                                  symbol: string;
                                  tokenProgram: string;
                              };
                              sourceLedgerAccountId: string;
                              type: "BLOCKCHAIN";
                          }
                          | {
                              bankId?: string;
                              sourceLedgerAccountId?: string;
                              type: "US_INSTANT";
                              vendorId?: string;
                          }
                          | {
                              bankId?: string;
                              drawdownId: string;
                              sourceAccountId: string;
                              type: "US_WIRE_DRAWDOWN";
                              vendorId?: string;
                          }
                          | null;
                          methodId: | "ACH_CREDIT"
                          | "ACH_DEBIT"
                          | "BLOCKCHAIN"
                          | "MX_SPEI"
                          | "US_WIRE_DRAWDOWN"
                          | "US_INSTANT"
                          | "SWIFT_WIRE"
                          | "US_WIRE"
                          | "AF_WITHDRAWAL";
                          paymentInstrumentId: string;
                          productQuoteId: string;
                          providerQuoteId: string
                          | null;
                          sourceAmount: BigNumber;
                          sourceAmountAfterFees: BigNumber;
                          sourceCurrency: string;
                          status: "ACTIVE" | "ACCEPTED" | "REJECTED" | "EXPIRED";
                          targetAmount: BigNumber;
                          targetAmountAfterFees: BigNumber;
                          targetCurrency: string;
                          unsignedWithdrawalTransaction: string | null;
                          updatedAt: Date;
                          walletAddress: Address;
                          walletBlockchain: string;
                      };
                      receiptId: string
                      | null;
                      receiptType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                      returnReceiptId: string | null;
                      status: "PENDING" | "FAILED" | "PROCESSING" | "COMPLETED" | "RETURNED";
                      statusDescription: string;
                      sweepTxId: string | null;
                      sweepTxType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                      type:
                          | "ACH_CREDIT"
                          | "ACH_DEBIT"
                          | "BLOCKCHAIN"
                          | "MX_SPEI"
                          | "US_WIRE_DRAWDOWN"
                          | "US_INSTANT"
                          | "SWIFT_WIRE"
                          | "US_WIRE"
                          | "AF_WITHDRAWAL";
                      updatedAt: Date;
                  }[];
                  total: number;
              };
          },
      >

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

    • The keys an unfiltered WithdrawalAdminQueryService.get({ id }) reads through.

      Parameters

      • __namedParameters: { id: string }

      Returns CacheKey[]

    • The keys WithdrawalQueryService.get reads through, one per includeHistory variant (search's page default included). Writers pass them so read-after-write holds under a null client, where tag busts no-op.

      Parameters

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

      Returns CacheKey[]