From c6ea86a92f0e62c57facd17061c69b279ed046ec Mon Sep 17 00:00:00 2001 From: Shivek Khurana Date: Thu, 21 Mar 2024 17:03:56 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20Add=20methods=20for=20fetching=20an?= =?UTF-8?q?d=20saving=20addresses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/status_im/contexts/wallet/events.cljs | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/status_im/contexts/wallet/events.cljs b/src/status_im/contexts/wallet/events.cljs index 9f26dd86e648..1a172c165fc7 100644 --- a/src/status_im/contexts/wallet/events.cljs +++ b/src/status_im/contexts/wallet/events.cljs @@ -439,3 +439,37 @@ :type :negative :text (i18n/label :t/provider-is-down {:chains chain-names}) :duration 10000}]]])}))) + +(rf/reg-event-fx + :wallet/save-address + (fn [_ [{:keys [address name color on-success on-error chain-short-names] + :or {on-success (fn []) + on-error (fn []) + name "" + chain-short-names "eth"}}]] + (let [address-to-save {:address address + :name name + :color color + :chain-short-names chain-short-names}] + {:fx [[:json-rpc/call + [{:method "wallet_addSavedAddress" + :params [address-to-save] + :on-success on-success + :on-error on-error}]]]}))) + +(rf/reg-event-fx + :wallet/get-saved-addresses + (fn [_ {:keys [on-success on-error]}] + {:json-rpc/call + [{:method "wallet_getSavedAddresses" + :on-success on-success + :on-error on-error}]})) + +(comment + (rf/dispatch [:wallet/get-saved-addresses + {:on-success (partial prn :success) + :on-error (partial prn :error)}]) + + (rf/dispatch [:wallet/save-address + {:on-error (partial prn :error--->)}]) + ,)