Add methods for fetching and saving addresses (#19356)

*  Add methods for fetching and saving addresses

* 🔨 Fix RPC calls but get addresses not working

* 🔨 Fix rpc call

* 🧰 Fix lint, and change var names
This commit is contained in:
Shivek Khurana 2024-04-02 12:25:28 +01:00 committed by GitHub
parent da25280555
commit a03cc3c3ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 0 deletions

View File

@ -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]
@ -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}]}))