Skip to content

Commit

Permalink
➕ Add methods for fetching and saving addresses (#19356)
Browse files Browse the repository at this point in the history
* ➕ Add methods for fetching and saving addresses

* 🔨 Fix RPC calls but get addresses not working

* 🔨 Fix rpc call

* 🧰 Fix lint, and change var names
  • Loading branch information
shivekkhurana authored Apr 2, 2024
1 parent da25280 commit a03cc3c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/status_im/contexts/wallet/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -439,3 +440,34 @@
: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 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 customization-color
:ens ens
:is-test test?
:chain-short-names chain-short-names}]
{: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 "wakuext_getSavedAddresses"
:on-success on-success
:on-error on-error}]}))

0 comments on commit a03cc3c

Please sign in to comment.