Skip to content

Commit

Permalink
➕ Add methods for fetching and saving addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
shivekkhurana committed Mar 21, 2024
1 parent ee35fd5 commit c6ea86a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/status_im/contexts/wallet/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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--->)}])
,)

0 comments on commit c6ea86a

Please sign in to comment.