-make-map | (fn [a] (cond (map? %0) %0 (vector? %0) (conj {} %0) (nil? %0) {})) | nil |
mint | (fn [path amount] (call* %0 0 mint %1)) | "Mints a quantity of the given asset. User must have minting privileges." |
owns? | (fn ([owner asset] (do (cond (vector? %1) (let [[path quantity] %1 ] (recur %0 %2 %3))) (map? %1) (reduce (fn [result [asset-path quantity]] (cond (#65/owns? %0 %3 %4) true (reduced false))) true %1) (nil? %1) true)) ([owner path quantity] (query (let [bal (#65/balance %1 %0) ] (call* %1 0 quantity-subset? %2 %3))))) | "Tests whether owner owns at least a given quantity of an asset" |
create | (fn ([addr] (let [scope (call* %0 0 create) ] (vector %0 %1))) ([addr options] (let [scope (call* %0 0 create %1) ] (vector %0 %2)))) | ["Creates a scoped sub-asset given an actor address." "Return value will be a scoped asset path to the new sub-asset."] |
transfer | (fn ([receiver asset] (cond (vector? %1) (let [[path quantity] %1 ] (recur %0 %2 %3 nil)) (map? %1) (reduce (fn [m [path quantity]] (assoc %2 %3 (#65/transfer %0 %3 %4 nil))) {} %1) (nil? %1) nil :else (fail :ARGUMENT "Invalid asset"))) ([receiver path quantity] (recur %0 %1 %2 nil)) ([receiver path quantity data] (cond (callable? %0 receive-asset) (do (#65/offer %0 %1 %2) (call* %0 0 receive-asset %1 %2 %3)) (#8/actor? %0) (fail :STATE "Target Actor does not have receive-asset function") (call* %1 0 direct-transfer %0 %2 %3)))) | "Transfers asset to receiver. `data` is an arbitrary value, which will be passed to the receiver's `receive-asset` method or directly trasnferred is the target is a user account." |
total-supply | (fn [token] (query (try (call* %0 0 total-supply) nil))) | "Gets the total supply of an asset. i.e. the union of all balances. May return nil if not supported." |
quantity-add | (fn ([asset-a asset-b] (let [asset-a (#65/-make-map %0) asset-b (#65/-make-map %1) ] (reduce (fn [m [path qb]] (let [qa (get %4 %5) ] (assoc %4 %5 (#65/quantity-add %5 %7 %6)))) %2 %3))) ([path a b] (query (call* %0 0 quantity-add %1 %2)))) | ["Adds two asset quantities. Quantities must be specified in the format required by the asset type." "Nil may be used to indicate the 'zero' quantity."] |
balance | (fn ([path] (recur %0 *address*)) ([path owner] (query (call* %0 0 balance %1)))) | ["Returns asset balance for a specified owner, or for the current address if not supplied." "Return value will be in the quantity format as specified by the asset type."] |
quantity-contains? | (fn ([asset-a asset-b] (let [asset-a (#65/-make-map %0) asset-b (#65/-make-map %1) ] (reduce (fn [m [path qb]] (let [qa (get %2 %5) ] (cond (= %7 %6) true (#65/quantity-contains? %5 %7 %6) true :else (reduced false)))) true %3))) ([path a b] (call* %0 0 quantity-subset? %2 %1))) | "Returns true if first quantity is >= second quantity. Any valid quantity must contain the 'zero' quantity." |
quantity-zero | (fn [path] (call* %0 0 quantity-add nil nil)) | "Returns the unique 'zero' quantity for the given asset." |
offer | (fn ([receiver asset] (cond (vector? %1) (let [[path quantity] %1 ] (recur %0 %2 %3)) (map? %1) (reduce (fn [m [path quantity]] (assoc %2 %3 (#65/offer %0 %3 %4))) {} %1))) ([receiver path quantity] (call* %1 0 offer %0 %2))) | ["Opens an offer of an `asset` to a `receiver`, which makes it possible for the receiver to 'accept' up to this quantity." "May result in an error if the asset does not support open offers."] |
check-transfer | (fn [sender receiver [path quantity]] (do (cond (callable? %2 check-transfer) *result* (return nil)) (query (call* %2 0 check-transfer %0 %1 %3)))) | ["Checks whether sender can transfer this asset to receiver." "Returns a descriptive failure message if there is a restriction prohibiting transfer, or nil if there is no restriction."] |
get-offer | (fn [path sender receiver] (query (call* %0 0 get-offer %1 %2))) | ["Gets the current offer from `sender` to `receiver` for a given asset." "Returns the quantity representing the current offer. Will be the 'zero' quantity if no open offer exists."] |
burn | (fn ([path amount] (call* %0 0 burn %1))) | "Burns a quantity of the given asset, if allowed by the implementation. Amount must be a valid quantity owned by the user." |
quantity-sub | (fn ([asset-a asset-b] (let [asset-a (#65/-make-map %0) asset-b (#65/-make-map %1) ] (reduce (fn [m [asset-address qb]] (let [qa (get %4 %5) ] (cond (= %7 %6) (dissoc %4 %5) (assoc %4 %5 (#65/quantity-sub %5 %7 %6))))) %2 %3))) ([path a b] (call* %0 0 quantity-sub %1 %2))) | ["Subtracts an asset quantity from another quantity. Quantities must be specified in the format required by the asset type." "Subtracting a larger amount from a smaller amount should return 'zero' or equivalent, although the exact meaning of this operation may be asset-specific." "`nil` can be used yo indicate the 'zero' quantity in inputs."] |
accept | (fn ([sender asset] (cond (vector? %1) (let [path (first %1) quantity (second %1) ] (recur %0 %2 %3)) (map? %1) (reduce (fn [m [path quantity]] (assoc %2 %3 (#65/accept %0 %3 %4))) {} %1) (nil? %1) nil (fail "Bad asset argument"))) ([sender path quantity] (call* %1 0 accept %0 %2))) | ["Accepts asset from sender." "If asset contains multiple assets, accepts each in turn. MUST fail if the asset cannot be accepted."] |