
;; baby-badgers-v0
(impl-trait 'SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.nft-trait.nft-trait)
(define-non-fungible-token baby-badgers-v0 uint)

;; constants
(define-constant contract-owner tx-sender)
(define-constant baby-badgers-nft-limit u1050)
(define-constant heart-price-stx u5000000)

;; Vars & Maps
(define-data-var last-id uint u0)
;; Has Bred Map
(define-map has-bred uint bool)

;; Baby Badger Mint
(define-map baby-badgers uint
  {
    baby-name: (string-ascii 48),
    parent-badger-1: uint,
    parent-badger-2: uint,
    parent-1-trait-1: uint,
    parent-1-trait-2: uint,
    parent-1-trait-3: uint,
    parent-1-trait-4: uint,
    parent-1-trait-5: uint,
    parent-1-trait-6: uint,
    parent-1-trait-7: uint,
    parent-1-trait-8: uint,
    parent-1-trait-9: uint,
    parent-1-trait-10: uint,
    parent-2-trait-1: uint,
    parent-2-trait-2: uint,
    parent-2-trait-3: uint,
    parent-2-trait-4: uint,
    parent-2-trait-5: uint,
    parent-2-trait-6: uint,
    parent-2-trait-7: uint,
    parent-2-trait-8: uint,
    parent-2-trait-9: uint,
    parent-2-trait-10: uint
  }
)
(map-set baby-badgers u0
  {
    baby-name: "helloworld1",
    parent-badger-1: u0,
    parent-badger-2: u1,
    parent-1-trait-1: u1,
    parent-1-trait-2: u0,
    parent-1-trait-3: u0,
    parent-1-trait-4: u0,
    parent-1-trait-5: u0,
    parent-1-trait-6: u1,
    parent-1-trait-7: u0,
    parent-1-trait-8: u0,
    parent-1-trait-9: u0,
    parent-1-trait-10: u0,
    parent-2-trait-1: u0,
    parent-2-trait-2: u1,
    parent-2-trait-3: u1,
    parent-2-trait-4: u0,
    parent-2-trait-5: u0,
    parent-2-trait-6: u0,
    parent-2-trait-7: u0,
    parent-2-trait-8: u0,
    parent-2-trait-9: u0,
    parent-2-trait-10: u0
  }
)
(map-set baby-badgers u1
  {
    baby-name: "helloworld2",
    parent-badger-1: u1,
    parent-badger-2: u2,
    parent-1-trait-1: u1,
    parent-1-trait-2: u0,
    parent-1-trait-3: u0,
    parent-1-trait-4: u0,
    parent-1-trait-5: u0,
    parent-1-trait-6: u1,
    parent-1-trait-7: u0,
    parent-1-trait-8: u0,
    parent-1-trait-9: u0,
    parent-1-trait-10: u0,
    parent-2-trait-1: u0,
    parent-2-trait-2: u1,
    parent-2-trait-3: u1,
    parent-2-trait-4: u0,
    parent-2-trait-5: u0,
    parent-2-trait-6: u0,
    parent-2-trait-7: u0,
    parent-2-trait-8: u0,
    parent-2-trait-9: u0,
    parent-2-trait-10: u0
  }
)

;; Get Minted Baby Badgers Maps
(define-read-only (get-baby-badgers)
  (begin
    (print (map-get? baby-badgers u0))
    (ok (print (map-get? baby-badgers u1)))
  )
)

(define-read-only (get-baby-badgers-default-test)
  (begin
    (print (map-get? baby-badgers u0))
    (print (map-get? baby-badgers u1))
    (ok (print (default-to {
      baby-name: "ignoreThisMap",
      parent-badger-1: u1,
      parent-badger-2: u2,
      parent-1-trait-1: u1,
      parent-1-trait-2: u0,
      parent-1-trait-3: u0,
      parent-1-trait-4: u0,
      parent-1-trait-5: u0,
      parent-1-trait-6: u1,
      parent-1-trait-7: u0,
      parent-1-trait-8: u0,
      parent-1-trait-9: u0,
      parent-1-trait-10: u0,
      parent-2-trait-1: u0,
      parent-2-trait-2: u1,
      parent-2-trait-3: u1,
      parent-2-trait-4: u0,
      parent-2-trait-5: u0,
      parent-2-trait-6: u0,
      parent-2-trait-7: u0,
      parent-2-trait-8: u0,
      parent-2-trait-9: u0,
      parent-2-trait-10: u0
    } (map-get? baby-badgers u2))))
  )
)

;; SIP009
(define-read-only (get-last-token-id)
  (ok (var-get last-id))
)

(define-read-only (get-owner (id uint))
  (ok (nft-get-owner? baby-badgers-v0 id))
)

(define-read-only (get-token-uri (token-id uint))
  (ok (some (concat (concat (var-get ipfs-root) (unwrap-panic (lookup token-id))) ".json")))
)

(define-public (transfer (id uint) (sender principal) (recipient principal))
  (begin
    (asserts! (is-eq tx-sender sender) (err u103))
    (nft-transfer? baby-badgers-v0 id sender recipient)
  )
)
