From 1b219d229a8ce6d7fdfbd86f36e6b460f8993ac5 Mon Sep 17 00:00:00 2001 From: Shivek Khurana Date: Thu, 21 Mar 2024 17:03:56 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9E=95=20Add=20methods=20for=20fetching?= =?UTF-8?q?=20and=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 8f2e62ee6a5..2e9ee3cf1d8 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--->)}]) + ,) From 6029eeacc93439848ebcfbbacf0c7bb72a2edd73 Mon Sep 17 00:00:00 2001 From: Shivek Khurana Date: Thu, 21 Mar 2024 17:57:16 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=94=A8=20Fix=20RPC=20calls=20but=20ge?= =?UTF-8?q?t=20addresses=20not=20working?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/status_im/contexts/wallet/events.cljs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/status_im/contexts/wallet/events.cljs b/src/status_im/contexts/wallet/events.cljs index 2e9ee3cf1d8..94bf2800067 100644 --- a/src/status_im/contexts/wallet/events.cljs +++ b/src/status_im/contexts/wallet/events.cljs @@ -451,25 +451,29 @@ :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}]]]}))) + {:json-rpc/call + [{:method "wakuext_upsertSavedAddress" + :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" + [{:method "wakuext_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)}]) + {:on-success (partial prn :success--->) + :on-error (partial prn :error--->)}]) (rf/dispatch [:wallet/save-address - {:on-error (partial prn :error--->)}]) + {:name "Test 2" + :colorId :blue + :on-success (partial prn :success-->) + :address "0xffffffffffffffffffffffffffffffffffffff12" + :on-error (partial prn :error--->)}]) ,) From 0cda55d73f564e036ea8950d1429d1515aa826d1 Mon Sep 17 00:00:00 2001 From: Shivek Khurana Date: Mon, 1 Apr 2024 15:55:22 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=94=A8=20Fix=20rpc=20call?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/status_im/contexts/wallet/events.cljs | 25 ++++++++--------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/status_im/contexts/wallet/events.cljs b/src/status_im/contexts/wallet/events.cljs index 94bf2800067..68c573c33d3 100644 --- a/src/status_im/contexts/wallet/events.cljs +++ b/src/status_im/contexts/wallet/events.cljs @@ -442,14 +442,18 @@ (rf/reg-event-fx :wallet/save-address - (fn [_ [{:keys [address name color on-success on-error chain-short-names] + (fn [_ [{:keys [address name color-id on-success on-error chain-short-names ens is-test] :or {on-success (fn []) on-error (fn []) name "" - chain-short-names "eth"}}]] + ens "" + is-test false + chain-short-names "eth:"}}]] (let [address-to-save {:address address :name name - :color color + :color-id color-id + :ens ens + :is-test is-test :chain-short-names chain-short-names}] {:json-rpc/call [{:method "wakuext_upsertSavedAddress" @@ -459,21 +463,8 @@ (rf/reg-event-fx :wallet/get-saved-addresses - (fn [_ {:keys [on-success on-error]}] + (fn [_ [{:keys [on-success on-error]}]] {:json-rpc/call [{:method "wakuext_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 - {:name "Test 2" - :colorId :blue - :on-success (partial prn :success-->) - :address "0xffffffffffffffffffffffffffffffffffffff12" - :on-error (partial prn :error--->)}]) - ,) From 0e26935da0927ed1701bb3f2d6412b764939fe88 Mon Sep 17 00:00:00 2001 From: Shivek Khurana Date: Mon, 1 Apr 2024 18:27:56 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A7=B0=20Fix=20lint,=20and=20change?= =?UTF-8?q?=20var=20names?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/status_im/contexts/wallet/events.cljs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/status_im/contexts/wallet/events.cljs b/src/status_im/contexts/wallet/events.cljs index 68c573c33d3..105941c937e 100644 --- a/src/status_im/contexts/wallet/events.cljs +++ b/src/status_im/contexts/wallet/events.cljs @@ -3,6 +3,7 @@ [clojure.string :as string] [react-native.background-timer :as background-timer] [react-native.platform :as platform] + [status-im.constants :as constants] [status-im.contexts.wallet.accounts.add-account.address-to-watch.events] [status-im.contexts.wallet.common.utils :as utils] [status-im.contexts.wallet.data-store :as data-store] @@ -442,18 +443,20 @@ (rf/reg-event-fx :wallet/save-address - (fn [_ [{:keys [address name color-id on-success on-error chain-short-names ens is-test] - :or {on-success (fn []) - on-error (fn []) - name "" - ens "" - is-test false - chain-short-names "eth:"}}]] + (fn [_ + [{:keys [address name customization-color on-success on-error chain-short-names ens test?] + :or {on-success (fn []) + on-error (fn []) + name "" + ens "" + test? false + ;; the chain short names should be a string like eth: or eth:arb:opt: + chain-short-names (str constants/mainnet-short-name ":")}}]] (let [address-to-save {:address address :name name - :color-id color-id + :color-id customization-color :ens ens - :is-test is-test + :is-test test? :chain-short-names chain-short-names}] {:json-rpc/call [{:method "wakuext_upsertSavedAddress"