adopt C-like function names: #989

This commit is contained in:
Aaron Blankstein
2019-08-13 11:10:57 -05:00
parent e0ad8f3428
commit c60055ef83
14 changed files with 275 additions and 275 deletions

View File

@@ -13,7 +13,7 @@
(name-price int))
(if (is-ok? (contract-call! tokens token-transfer
burn-address name-price))
(begin (insert-entry! preorder-map
(begin (map-insert! preorder-map
(tuple (name-hash name-hash))
(tuple (paid name-price)
(buyer tx-sender)))
@@ -26,11 +26,11 @@
(salt int))
(let ((preorder-entry
(expects! ;; name _must_ have been preordered.
(fetch-entry preorder-map
(tuple (name-hash (hash160 (xor name salt)))))
(map-get preorder-map
(tuple (name-hash (hash160 (xor name salt)))))
(err "no preorder found")))
(name-entry
(fetch-entry name-map (tuple (name name)))))
(map-get name-map (tuple (name name)))))
(if (and
;; name shouldn't *already* exist
(is-none? name-entry)
@@ -41,10 +41,10 @@
(eq? tx-sender
(get buyer preorder-entry)))
(if (and
(insert-entry! name-map
(map-insert! name-map
(tuple (name name))
(tuple (owner recipient-principal)))
(delete-entry! preorder-map
(map-delete! preorder-map
(tuple (name-hash (hash160 (xor name salt))))))
(ok 0)
(err "failed to insert new name entry"))

View File

@@ -1,13 +1,13 @@
(define-map tokens ((account principal)) ((balance int)))
(define-private (get-balance (account principal))
(default-to 0 (get balance (fetch-entry tokens (tuple (account account))))))
(default-to 0 (get balance (map-get tokens (tuple (account account))))))
(define-private (token-credit! (account principal) (amount int))
(if (<= amount 0)
(err "must move positive balance")
(let ((current-amount (get-balance account)))
(begin
(set-entry! tokens (tuple (account account))
(map-set! tokens (tuple (account account))
(tuple (balance (+ amount current-amount))))
(ok amount)))))
@@ -16,7 +16,7 @@
(if (or (> amount balance) (<= amount 0))
(err "must transfer positive balance and possess funds")
(begin
(set-entry! tokens (tuple (account tx-sender))
(map-set! tokens (tuple (account tx-sender))
(tuple (balance (- balance amount))))
(token-credit! to amount)))))