Source Code

(define-constant O tx-sender)
(define-constant E1 (err u700))
(define-constant E2 (err u701))
(define-data-var tc uint u0)
(define-map templates uint {q: (string-ascii 64), dur: uint, res-gap: uint})
(define-public (add-template (q (string-ascii 64)) (dur uint) (res-gap uint))
 (begin (asserts! (is-eq tx-sender O) E1)
  (let ((id (var-get tc)))
   (var-set tc (+ id u1))
   (ok (map-set templates id {q: q, dur: dur, res-gap: res-gap})))))
(define-public (create-from-template (tid uint))
 (let ((t (unwrap! (map-get? templates tid) E2))
       (e (+ stacks-block-height (get dur t)))
       (r (+ e (get res-gap t))))
  (contract-call? .market-core create-market (get q t) e r)))
(define-read-only (get-template (tid uint))
 (map-get? templates tid))
(define-read-only (get-template-count) (var-get tc))

Functions (4)

FunctionAccessArgs
add-templatepublicq: (string-ascii 64
create-from-templatepublictid: uint
get-templateread-onlytid: uint
get-template-countread-only