diff --git a/main.lisp b/main.lisp index f6c30b5..2dd3f0c 100644 --- a/main.lisp +++ b/main.lisp @@ -364,6 +364,36 @@ +;; ————————————————————————————————————— +;; DAG CALLS + +;; STRING → STRING || (NIL STRING) +(defun dag-get (dag-node) + "Get a dag node from IPFS. + /ipns/docs.ipfs.io/reference/api/http/#api-v0-dag-get" + (bind-api-result + (ipfs-call "dag/get" `(("arg" ,dag-node))) + result)) + +;; STRING [:STRING :STRING :BOOLEAN] → STRING || (NIL STRING +(defun dag-put (dag-node &key (format "cbor") (input-enc "json") (pin 'T)) + "Add a dag node to IPFS. Returns CID string. + /ipns/docs.ipfs.io/reference/api/http/#api-v0-dag-put" + (bind-api-result + (ipfs-call "dag/put" `(("arg" ,dag-node) ("format" ,format) + ("input-enc" ,input-enc) ("pin" ,pin))) + (gethash "/" (gethash "Cid" result)))) + +;; STRING → ALIST || (NIL STRING) +(defun dag-resolve (path) + "Resolve an IPLD block. + /ipns/docs.ipfs.io/reference/api/http/#api-v0-dag-resolve" + (bind-api-alist + (ipfs-call "dag/resolve" `(("arg" ,path))) + result)) + + + ;; ————————————————————————————————————— ;; VERSION CALLS diff --git a/package.lisp b/package.lisp index 6f866ae..f6d4bd9 100644 --- a/package.lisp +++ b/package.lisp @@ -43,6 +43,11 @@ :config :config-show + ;; dag calls + :dag-get + :dag-put + :dag-resolve + ;; version calls :version :version-deps))