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.
The CouponMinter contract payload
Optional
Optional current time for testing (defaults to new Date())
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); } Copy
const result = canMintCouponsNow(couponMinterPayload); if (result.canMint) { await mintCoupons(...); } else { console.log(`Rate limited. Waiting ${result.waitMs}ms...`); await sleep(result.waitMs); }
Checks if minting coupons is currently allowed based on the TPS rate limit configuration.
The rate limit formula from the DAML contract is:
If enough time has elapsed since the last mint, minting is allowed. Otherwise, returns the number of milliseconds to wait before minting is allowed.