This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-01
Channels
- # announcements (7)
- # babashka (10)
- # beginners (60)
- # clerk (4)
- # clojure (19)
- # clojure-conj (5)
- # clojure-europe (48)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-uk (2)
- # clojurescript (12)
- # conjure (2)
- # core-async (24)
- # cursive (3)
- # datalevin (18)
- # events (1)
- # figwheel-main (5)
- # fulcro (22)
- # honeysql (29)
- # hyperfiddle (60)
- # jobs (3)
- # leiningen (18)
- # lsp (47)
- # meander (21)
- # missionary (6)
- # off-topic (35)
- # reagent (14)
- # remote-jobs (1)
- # ring (1)
- # shadow-cljs (32)
- # sql (10)
- # transit (12)
I am working with metamask and I log a result when a user selects a wallet. The log looks like this in my browser:
#js [#js
{
:id sdNyveWraMbzb9Ff9wrDU,
:parentCapability eth_accounts,
:invoker ,
:caveats #js [
#js {
:type restrictReturnedAccounts,
:value #js [0x0ea1a816024e5b33e5c9356d52aa75686d036d9b]}],
:date 1677684342237
}
]
I'm trying to get the`:value` , why is the code below not working:
(get-in addrs [0 :caveats 0 :value]
the keys in a #js
object are strings, you can't get keywords out of JS maps. so (get-in addrs [0 "caveats" 0 "value"])
should be fine. converting these to CLJS collections also is an option.
I got nil
instead of the address, even when I converted it to cljs collections.
;; addrs is the object
(let [addr-cljs (js->clj addrs)
addr (get-in addr-cljs [0 :caveats 0 :value])]
(println addr))
check what the data looks like after conversion. things aren't always what they seem when looking at JS objects
[
{
id Av0PBnI222wCqTgVjO326,
parentCapability eth_accounts,
invoker ,
caveats [
{
type restrictReturnedAccounts,
value [0x0ea1a816024e5b33e5c9356d52aa75686d036d9b]
}
],
date 1677688249071
}
]
just forget about this conversion stuff and use proper JS interop to get what you want
Thanks, I got this with (-> addrs ....
:
#js [0x0ea1a816024e5b33e5c9356d52aa75686d036d9b]
Thank you👍 1