Open Cap Table Protocol Canton SDK - v0.2.224
    Preparing search index...

    Function canMintCouponsNow

    • Checks if minting coupons is currently allowed based on the TPS rate limit configuration.

      The rate limit formula from the DAML contract is:

      minIntervalMicros = (lastMint.count * 1_000_000) / maxTps;
      

      If enough time has elapsed since the last mint, minting is allowed. Otherwise, returns the number of milliseconds to wait before minting is allowed.

      Parameters

      • payload: CouponMinterPayload

        The CouponMinter contract payload

      • Optionalnow: Date

        Optional current time for testing (defaults to new Date())

      Returns CanMintResult

      If minting is allowed, or { canMint: false, waitMs: number } with the wait time

        const result = canMintCouponsNow(couponMinterPayload);
      if (result.canMint) {
      await mintCoupons(...);
      } else {
      console.log(`Rate limited. Waiting ${result.waitMs}ms...`);
      await sleep(result.waitMs);
      }