mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-23 11:27:38 +08:00
adopt C-like function names: #989
This commit is contained in:
@@ -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"))
|
||||
|
||||
@@ -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)))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user