➕ 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:
parent
da25280555
commit
a03cc3c3ab
|
@ -3,6 +3,7 @@
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[react-native.background-timer :as background-timer]
|
[react-native.background-timer :as background-timer]
|
||||||
[react-native.platform :as platform]
|
[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.accounts.add-account.address-to-watch.events]
|
||||||
[status-im.contexts.wallet.common.utils :as utils]
|
[status-im.contexts.wallet.common.utils :as utils]
|
||||||
[status-im.contexts.wallet.data-store :as data-store]
|
[status-im.contexts.wallet.data-store :as data-store]
|
||||||
|
@ -439,3 +440,34 @@
|
||||||
:type :negative
|
:type :negative
|
||||||
:text (i18n/label :t/provider-is-down {:chains chain-names})
|
:text (i18n/label :t/provider-is-down {:chains chain-names})
|
||||||
:duration 10000}]]])})))
|
: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}]}))
|
||||||
|
|
Loading…
Reference in New Issue