Skip to content

Commit

Permalink
Stub implementation for generic trust monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Dec 14, 2023
1 parent 3ff40d3 commit 546017a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions convex-core/src/main/cvx/convex/trust/monitors.cvx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'convex.trust.monitors

(import convex.trust :as trust)

;; Generic check
(defn check-trusted?
^:callable?
[subject action object]
(or *scope* (fail :ARGUMENT "Null scope in generic trust monitor"))
(let [[type arg] *scope*]
(cond
(= :wl type) (contains? arg subject)
(= :and type) (reduce (fn [a b] (and a (trust/trusted? b subject action object))) true arg)
(= :or type) (reduce (fn [a b] (or a (trust/trusted? b subject action object))) false arg)
(address? type) (call *scope* (check-trusted? subject action object))
false
)))
1 change: 1 addition & 0 deletions convex-core/src/main/java/convex/core/init/Init.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ private static State addStandardLibraries(State s) {
s = doActorDeploy(s, "convex/trust/ownership-monitor.cvx");
s = doActorDeploy(s, "convex/trust/delegate.cvx");
s = doActorDeploy(s, "convex/trust/whitelist.cvx");
s = doActorDeploy(s, "convex/trust/monitors.cvx");
return s;
}

Expand Down

0 comments on commit 546017a

Please sign in to comment.