convex.trust.ownership-monitor.cvx Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of convex-core Show documentation
Show all versions of convex-core Show documentation
Convex core libraries and common utilities
The newest version!
'convex.trust.ownership-monitor
;; A simple trust monitor that can test for ownership of some asset quantity
;;
;; Example: a subject must hold tokens representing shares in a company
;; in order to be eligible to vote in a general meeting.
;;
;; (import convex.trust.ownership-monitor :as ownership)
;;
;; (trust/trusted? *caller* [ownership [share-token 1000]])
;;
(import convex.asset :as asset)
(defn check-trusted?
^{:callable true
:doc {:description ["Trust monitor SPI for testing asset ownership."
"Ignores action and object, simply checks if the subject owns the asset specified in *scope*."]
:examples [{:code "(call [ownership-monitor [some-token 1000]] (check-trusted *caller* nil nil))"}]
:signature [{:params [ subject action object]}]}}
[subject action object]
(asset/owns? subject *scope*))