From 4dca2e9caad80492d5d1da5b1f38d037bd88b32f Mon Sep 17 00:00:00 2001 From: Zach Zundel Date: Sat, 15 Dec 2018 18:42:07 -0700 Subject: [PATCH] Create event Signed-off-by: Julien Eluard --- src/status_im/constants.cljs | 2 ++ src/status_im/extensions/core.cljs | 4 ++++ src/status_im/extensions/ethereum.cljs | 12 ++++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index 63489177cb..81b0f4d100 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -209,6 +209,8 @@ (def ^:const web3-uninstall-filter "eth_uninstallFilter") (def ^:const web3-get-filter-changes "eth_getFilterChanges") +(def ^:const status-create-address "status_createaddress") + (def ^:const event-transfer-hash (ethereum/sha3 "Transfer(address,address,uint256)")) diff --git a/src/status_im/extensions/core.cljs b/src/status_im/extensions/core.cljs index 303978cb57..36e63b43d8 100644 --- a/src/status_im/extensions/core.cljs +++ b/src/status_im/extensions/core.cljs @@ -535,6 +535,10 @@ :data? :string :on-success :event :on-failure? :event}} + 'ethereum/create-address + {:permissions [:read] + :value :extensions/ethereum-create-address + :arguments {:on-result :event}} 'ethereum/send-transaction {:permissions [:read] :value :extensions/ethereum-send-transaction diff --git a/src/status_im/extensions/ethereum.cljs b/src/status_im/extensions/ethereum.cljs index aa029a5818..b390e6c121 100644 --- a/src/status_im/extensions/ethereum.cljs +++ b/src/status_im/extensions/ethereum.cljs @@ -344,6 +344,18 @@ :method constants/web3-personal-sign})} (navigation/navigate-to-cofx :wallet-sign-message-modal nil))))) +(handlers/register-handler-fx + :extensions/ethereum-create-address + (fn [_ [_ _ {:keys [on-result]}]] + (let [args {:jsonrpc "2.0" + :method constants/status-create-address} + payload (types/clj->json args)] + (status/call-private-rpc payload #(let [{:keys [error result]} (types/json->clj %1) + response (if error {:result result :error error} + {:result result})] + (re-frame/dispatch (on-result response))))))) + +;; poll logs implementation (handlers/register-handler-fx :extensions/ethereum-logs-changes (fn [_ [_ _ {:keys [id] :as m}]]