Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

➕ Add methods for fetching and saving addresses #19356

Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]}]]
clauxx marked this conversation as resolved.
Show resolved Hide resolved
{:json-rpc/call
[{:method "wakuext_getSavedAddresses"
:on-success on-success
:on-error on-error}]}))