Skip to content

Reference

CouponMinter.canMintCouponsNow

Synchronous check whether CouponMinter TPS pacing allows another mint; returns canMint or waitMs.

ocp.CouponMinter.canMintCouponsNow (also importable as canMintCouponsNow from @open-captable-protocol/canton) evaluates the rate-limit inequality using maxTps and lastMint on your payload.

Example

const result = ocp.CouponMinter.canMintCouponsNow(COUPON_MINTER_PAYLOAD);
if (result.canMint) {
  // submit MintCoupons
} else {
  await sleep(result.waitMs);
}

Parameters

  • payload (required)CouponMinterPayload.
  • now (optional)Date for deterministic tests; defaults to new Date().

Returns

  • { canMint: true } when allowed.
  • { canMint: false, waitMs: number } when the next mint must wait (waitMs is whole milliseconds, ceiling of remaining microseconds).

Errors

  • OcpValidationErrorpayload.maxTps when not a positive number string (INVALID_FORMAT).
  • OcpValidationErrorpayload.lastMint.time when the timestamp is not parseable ISO (INVALID_FORMAT).

See also

Source