dummy | #144 | nil |
gateway | #171 | nil |
mk-tip-logic | (fn [state gateway] (deploy (list do (def actor-name "tipper") (list def gateway %1) (list def state %0) (defn ^{:callable true} add-artifact [artifact] (if (not artifact) (fail :ARGUMENT "Arguments require an artifact") (call state (swap! update artifact merge {:sender *caller*})))) (defn ^{:callable true} add-recipient [artifact recipient] (when recipient (let [tips (call state (deref)) sender (:sender (get tips artifact))] (cond (not (= *caller* sender)) (fail :TRUST (str *caller* " not authorised to add recipient on behalf of " sender)) (not recipient) (fail :ARGUMENT "recipient field is nil") :else (call state (swap! assoc-in [artifact :recipient] recipient)))))) (defn ^{:callable true} add-amount [artifact amount] (let [tips (call state (deref)) sender (:sender (get tips artifact))] (cond (not (= *caller* sender)) (fail :TRUST (str *caller* " not authorised to add amount on behalf of " sender)) (not (> amount 0)) (fail :FUNDS "No tip offered!") :else (do (accept amount) (transfer gateway amount) (call state (swap! assoc-in [artifact :amount] amount)) (return "Thanks for the tip!"))))) (defn ^{:callable true} tip! [tip-map] (let [tips (call state (deref)) artifact (:artifact tip-map) amount (get-in tips [artifact :amount] *offer*) recipient (get-in tips [artifact :recipient] (:recipient tip-map))] (add-artifact artifact) (add-recipient artifact recipient) (add-amount artifact amount))) (def disabled? false) (def admin-account *caller*) (defn ^{:callable true} admin [code] (if disabled? (fail :STATE "Administrative access is permenantly disabled.") (if (not (= *caller* admin-account)) (fail :TRUST (str *caller* " is not authorised to administrate on behalf of admin " admin-account)) (eval code))))))) | nil |
tipper4 | #164 | nil |
every-thousand-seconds | (fn [] (cond (< 0 #135/a) (do (def a (dec #135/a)) (schedule* 1000000 (compile (every-thousand-seconds)))) nil)) | nil |
mk-state-actor | (fn [gateway] (deploy (list do (def actor-name "state") (list def gateway %0) (def state {}) (defn ^{:callable true} swap! [afn & args] (let [user-key *caller*] (def state (assoc state user-key (apply afn (get state user-key {}) args))))) (defn ^{:callable true} gateway-swap! [user-key afn & args] (if (not (= gateway *caller*)) (fail :TRUST "Cannot swap on behalf of gateway " gateway) (def state (assoc state user-key (apply afn (get state user-key {}) args))))) (defn ^{:callable true} deref [] (get state *caller* {})) (defn ^{:callable true} deref-as [as-account] (get state as-account {})) (def admin-account *caller*) (def disabled? false) (defn ^{:callable true} admin [code] (if disabled? (fail :STATE "Administrative access is permenantly disabled.") (if (not (= *caller* admin-account)) (fail :TRUST (str *caller* " is not authorised to administrate on behalf of parent " admin-account)) (eval code))))))) | nil |
mk-tip-gateway | (fn [] (deploy (do (def actor-name "collect-tip") (defn ^{:callable true} receive-coin [sender amount data] (accept amount)) (defn ^{:callable true} collect [state from artifact] (let [tips (call state (deref-as from)) recipient (get-in tips [artifact :recipient])] (if (not ((lookup (resolve convex.trust) trusted?) recipient *caller*)) (fail :TRUST (str *caller* " is not authorised to collect funds on behalf of " recipient " for tips-state: " tips)) (let [amount (or (get-in tips [artifact :amount]) 0)] (call state (gateway-swap! from dissoc artifact)) (transfer *caller* amount))))) (def disabled? false) (def admin-account *caller*) (defn ^{:callable true} admin [code] (if disabled? (fail :STATE "Administrative access is permenantly disabled.") (if (not (= *caller* admin-account)) (fail :TRUST (str *caller* " is not authorised to administrate on behalf of parent " admin-account)) (eval code))))))) | nil |
state | #172 | nil |
hello | "world" | nil |
test-upgradable-actor | #138 | nil |
tipper3 | #151 | nil |
mk-tip-state | (fn [state-addy] (deploy (list do (def actor-name "tip-state") (defn ^{:callable true} receive-coin [sender amount data] (accept amount)) (list def state %0) (defn ^{:callable true} collect [from artifact] (let [tips (call state (deref-as from)) recipient (get-in tips [artifact :recipient])] (if (not ((lookup (resolve convex.trust) trusted?) recipient *caller*)) (fail :TRUST (str *caller* " is not authorised to collect funds on behalf of " recipient " for tips-state: " tips)) (let [amount (or (get-in tips [artifact :amount]) 0)] (call state (swap! dissoc artifact)) (transfer *caller* amount))))) (def disabled? false) (def admin-account *caller*) (defn ^{:callable true} admin [code] (if disabled? (fail :STATE "Administrative access is permenantly disabled.") (if (not (= *caller* admin-account)) (fail :TRUST (str *caller* " is not authorised to administrate on behalf of parent " admin-account)) (eval code))))))) | nil |
mk-tipper | (fn [original-caller state] (deploy (list do (def actor-name "tipper") (list def tip-state %1) (def state (lookup tip-state state)) (defn ^{:callable true} add-artifact [artifact] (if (not artifact) (fail :ARGUMENT "Arguments require an artifact") (call state (swap! update artifact merge {:sender *caller*})))) (defn ^{:callable true} add-recipient [artifact recipient] (when recipient (let [tips (call state (deref)) sender (:sender (get tips artifact))] (cond (not (= *caller* sender)) (fail :TRUST (str *caller* " not authorised to add recipient on behalf of " sender)) (not recipient) (fail :ARGUMENT "recipient field is nil") :else (call state (swap! assoc-in [artifact :recipient] recipient)))))) (defn ^{:callable true} add-amount [artifact amount] (let [tips (call state (deref)) sender (:sender (get tips artifact))] (cond (not (= *caller* sender)) (fail :TRUST (str *caller* " not authorised to add amount on behalf of " sender)) (not (> amount 0)) (fail :FUNDS "No tip offered!") :else (do (accept amount) (call state (swap! assoc-in [artifact :amount] amount)) (return "Thanks for the tip!"))))) (defn ^{:callable true} tip! [tip-map] (let [tips (call state (deref)) artifact (:artifact tip-map) amount (get-in tips [artifact :amount] *offer*) recipient (get-in tips [artifact :recipient] (:recipient tip-map))] (add-artifact artifact) (add-recipient artifact recipient) (add-amount artifact amount))) (def disabled? false) (list def original-caller %0) (def admin-account *caller*) (defn ^{:callable true} admin [code] (if disabled? (fail :STATE "Administrative access is permenantly disabled.") (if (not (= *caller* admin-account)) (fail :TRUST (str *caller* " is not authorised to administrate on behalf of admin " admin-account)) (eval code))))))) | nil |
tipper | #173 | nil |
tip-state | (fn [] (deploy (do (def actor-name "tip-state") (def state (mk-state-actor)) (defn ^{:callable true} collect [artifact] (let [tips (call state (deref)) recipient (get-in tips [artifact :recipient])] (if (not ((lookup (resolve convex.trust) trusted?) recipient *caller*)) (fail :TRUST (str *caller* " is not authorised to collect funds on behalf of " recipient)) (let [amount (or (get-in tips [artifact :amount]) 0)] (call state (swap! dissoc artifact)) (transfer *caller* amount))))) (def disabled? false) (def parent *caller*) (defn ^{:callable true} admin [code] (if disabled? (fail :STATE "Administrative access is permenantly disabled.") (if (not (= *caller* parent)) (fail :TRUST (str *caller* " is not authorised to administrate on behalf of parent " parent)) (eval code))))))) | nil |
a | 0 | nil |
tipper6 | #170 | nil |
tipper5 | #167 | nil |
tipper2 | #148 | nil |