Exposed whisper (shh) events
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
3770243546
commit
9198b15380
|
@ -210,6 +210,16 @@
|
||||||
(def ^:const web3-uninstall-filter "eth_uninstallFilter")
|
(def ^:const web3-uninstall-filter "eth_uninstallFilter")
|
||||||
(def ^:const web3-get-filter-changes "eth_getFilterChanges")
|
(def ^:const web3-get-filter-changes "eth_getFilterChanges")
|
||||||
|
|
||||||
|
(def ^:const web3-shh-post "shh_post")
|
||||||
|
(def ^:const web3-shh-new-identity "shh_newIdentity")
|
||||||
|
(def ^:const web3-shh-has-identity "shh_hasIdentity")
|
||||||
|
(def ^:const web3-shh-new-group "shh_newGroup")
|
||||||
|
(def ^:const web3-shh-add-to-group "shh_addToGroup")
|
||||||
|
(def ^:const web3-shh-new-filter "shh_newFilter")
|
||||||
|
(def ^:const web3-shh-uninstall-filter "shh_uninstallFilter")
|
||||||
|
(def ^:const web3-shh-get-filter-changes "shh_getFilterChanges")
|
||||||
|
(def ^:const web3-shh-get-messages "shh_getMessages")
|
||||||
|
|
||||||
(def ^:const status-create-address "status_createaddress")
|
(def ^:const status-create-address "status_createaddress")
|
||||||
|
|
||||||
(def ^:const event-transfer-hash
|
(def ^:const event-transfer-hash
|
||||||
|
|
|
@ -719,7 +719,59 @@
|
||||||
:params? :vector
|
:params? :vector
|
||||||
:outputs? :vector
|
:outputs? :vector
|
||||||
:on-success :event
|
:on-success :event
|
||||||
:on-failure? :event}}}
|
:on-failure? :event}}
|
||||||
|
'ethereum/shh_post
|
||||||
|
{:permissions [:read]
|
||||||
|
:value :extensions/shh-post
|
||||||
|
:arguments {:from? :string
|
||||||
|
:to? :string
|
||||||
|
:topics :vector
|
||||||
|
:payload :string
|
||||||
|
:priority :string
|
||||||
|
:ttl :string
|
||||||
|
:on-success :event
|
||||||
|
:on-failure? :event}}
|
||||||
|
'ethereum/shh-new-identity
|
||||||
|
{:permissions [:read]
|
||||||
|
:value :extensions/shh-new-identity
|
||||||
|
:arguments {:on-success :event
|
||||||
|
:on-failure? :event}}
|
||||||
|
'ethereum/shh-has-identity
|
||||||
|
{:permissions [:read]
|
||||||
|
:value :extensions/shh-has-identity
|
||||||
|
:arguments {:address :string
|
||||||
|
:on-success :event
|
||||||
|
:on-failure? :event}}
|
||||||
|
'ethereum/shh-new-group
|
||||||
|
{:permissions [:read]
|
||||||
|
:value :extensions/shh-new-group
|
||||||
|
:arguments {:on-success :event
|
||||||
|
:on-failure? :event}}
|
||||||
|
'ethereum/shh-add-to-group
|
||||||
|
{:permissions [:read]
|
||||||
|
:value :extensions/shh-add-to-group
|
||||||
|
:arguments {:address :string
|
||||||
|
:on-success :event
|
||||||
|
:on-failure? :event}}
|
||||||
|
'ethereum/shh_new-filter
|
||||||
|
{:permissions [:read]
|
||||||
|
:value :extensions/shh-new-filter
|
||||||
|
:arguments {:to? :string
|
||||||
|
:topics :vector
|
||||||
|
:on-success :event
|
||||||
|
:on-failure? :event}}
|
||||||
|
'ethereum/shh-uninstall-filter
|
||||||
|
{:permissions [:read]
|
||||||
|
:value :extensions/shh-uninstall-filter
|
||||||
|
:arguments {:id :string}}
|
||||||
|
'ethereum/shh-get-filter-changes
|
||||||
|
{:permissions [:read]
|
||||||
|
:value :extensions/shh-get-filter-changes
|
||||||
|
:arguments {:id :string}}
|
||||||
|
'ethereum/shh-get-messages
|
||||||
|
{:permissions [:read]
|
||||||
|
:value :extensions/shh-get-messages
|
||||||
|
:arguments {:id :string}}}
|
||||||
:hooks {:chat.command commands/command-hook
|
:hooks {:chat.command commands/command-hook
|
||||||
:wallet.settings settings/hook}})
|
:wallet.settings settings/hook}})
|
||||||
|
|
||||||
|
|
|
@ -394,3 +394,69 @@
|
||||||
:extensions/ethereum-create-filter
|
:extensions/ethereum-create-filter
|
||||||
(fn [_ [_ _ {:keys [type] :as m}]]
|
(fn [_ [_ _ {:keys [type] :as m}]]
|
||||||
(rpc-call (create-filter-method type) (create-filter-arguments type m) abi-spec/hex-to-number m)))
|
(rpc-call (create-filter-method type) (create-filter-arguments type m) abi-spec/hex-to-number m)))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:extensions/shh-post
|
||||||
|
(fn [_ [_ _ {:keys [from to topics payload priority ttl] :as m}]]
|
||||||
|
(let [params [{:from from
|
||||||
|
:to to
|
||||||
|
:topics (generate-topic topics)
|
||||||
|
:payload payload
|
||||||
|
:priority (abi-spec/number-to-hex priority)
|
||||||
|
:ttl (abi-spec/number-to-hex ttl)}]]
|
||||||
|
(rpc-call constants/web3-shh-post params #(abi-spec/hex-to-value % "bool") m))))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:extensions/shh-new-identity
|
||||||
|
(fn [_ [_ _ arguments]]
|
||||||
|
(let [params []]
|
||||||
|
(rpc-call constants/web3-shh-new-identity params #(identity %) arguments))))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:extensions/shh-has-identity
|
||||||
|
(fn [_ [_ _ {:keys [address] :as m}]]
|
||||||
|
((rpc-call constants/web3-shh-has-identity address #(abi-spec/hex-to-value % "bool") m))))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:extensions/shh-new-group
|
||||||
|
(fn [_ [_ _ arguments]]
|
||||||
|
(let [params []]
|
||||||
|
(rpc-call constants/web3-shh-new-group params #(identity %) arguments))))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:extensions/shh-add-to-group
|
||||||
|
(fn [_ [_ _ {:keys [address] :as m}]]
|
||||||
|
((rpc-call constants/web3-shh-add-to-group address #(abi-spec/hex-to-value % "bool") m))))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:extensions/shh-new-filter
|
||||||
|
(fn [_ [_ _ {:keys [to topics] :as m}]]
|
||||||
|
(let [params [{:to to
|
||||||
|
:topics (generate-topic topics)}]]
|
||||||
|
(rpc-call constants/web3-shh-new-filter params abi-spec/hex-to-number m))))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:extensions/shh-uninstall-filter
|
||||||
|
(fn [_ [_ _ {:keys [id] :as m}]]
|
||||||
|
(rpc-call constants/web3-shh-uninstall-filter [(abi-spec/number-to-hex id)] #(abi-spec/hex-to-value % "bool") m)))
|
||||||
|
|
||||||
|
(defn- parse-messages [{:keys [hash from to expiry ttl sent topics payload workProved]}]
|
||||||
|
{:hash hash
|
||||||
|
:from from
|
||||||
|
:to to
|
||||||
|
:expiry (abi-spec/hex-to-number expiry)
|
||||||
|
:ttl (abi-spec/hex-to-number ttl)
|
||||||
|
:sent (abi-spec/hex-to-number sent)
|
||||||
|
:topics topics
|
||||||
|
:payload payload
|
||||||
|
:workProved (abi-spec/hex-to-number workProved)})
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:extensions/shh-get-filter-changes
|
||||||
|
(fn [_ [_ _ {:keys [id] :as m}]]
|
||||||
|
(rpc-call constants/web3-shh-get-filter-changes [(abi-spec/number-to-hex id)] #(map parse-messages %) m)))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:extensions/shh-get-messages
|
||||||
|
(fn [_ [_ _ {:keys [id] :as m}]]
|
||||||
|
(rpc-call constants/web3-shh-get-messages [(abi-spec/number-to-hex id)] #(map parse-messages %) m)))
|
||||||
|
|
Loading…
Reference in New Issue