-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use with-precision to show prettier amounts (workaround) For reference, see status-im/status-desktop#8640
- Loading branch information
Showing
12 changed files
with
202 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/status_im/contexts/communities/actions/addresses_for_permissions/events.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(ns status-im.contexts.communities.actions.addresses-for-permissions.events | ||
(:require | ||
[schema.core :as schema] | ||
[taoensso.timbre :as log] | ||
[utils.re-frame :as rf])) | ||
|
||
(defn get-permissioned-balances | ||
[{[event-id _] :original-event} [community-id]] | ||
{:fx [[:json-rpc/call | ||
[{:method :wakuext_getCommunityPermissionedBalances | ||
:params [{:communityId community-id}] | ||
:on-success [:communities/get-permissioned-balances-success community-id] | ||
:on-error (fn [error] | ||
(log/error "failed to get balances" | ||
{:community-id community-id | ||
:event event-id | ||
:error error}))}]]]}) | ||
|
||
(schema/=> get-permissioned-balances | ||
[:=> | ||
[:catn | ||
[:cofx :schema.re-frame/cofx] | ||
[:args [:schema [:catn [:community-id :string]]]]] | ||
[:map {:closed true} | ||
[:fx | ||
[:tuple | ||
[:tuple [:= :json-rpc/call] :schema.common/rpc-call]]]]]) | ||
|
||
(rf/reg-event-fx :communities/get-permissioned-balances get-permissioned-balances) | ||
|
||
(defn get-permissioned-balances-success | ||
[{:keys [db]} [community-id response]] | ||
{:db (assoc-in db [:communities/permissioned-balances community-id] response)}) | ||
|
||
(def ^:private ?account-address keyword?) | ||
|
||
(def ^:private ?permissioned-balances-response | ||
[:map-of | ||
?account-address | ||
[:sequential | ||
[:map {:closed true} | ||
[:type int?] | ||
[:symbol string?] | ||
[:decimals int?] | ||
[:amount string?]]]]) | ||
|
||
(schema/=> get-permissioned-balances-success | ||
[:=> | ||
[:catn | ||
[:cofx :schema.re-frame/cofx] | ||
[:args | ||
[:schema | ||
[:? | ||
[:catn | ||
[:community-id string?] | ||
[:response ?permissioned-balances-response]]]]]] | ||
[:map {:closed true} | ||
[:db map?]]]) | ||
|
||
(rf/reg-event-fx :communities/get-permissioned-balances-success get-permissioned-balances-success) |
15 changes: 15 additions & 0 deletions
15
src/status_im/contexts/communities/actions/addresses_for_permissions/events_test.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(ns status-im.contexts.communities.actions.addresses-for-permissions.events-test | ||
(:require | ||
[cljs.test :refer [is deftest]] | ||
[status-im.contexts.communities.actions.addresses-for-permissions.events :as sut])) | ||
|
||
(def community-id "0x1") | ||
|
||
(deftest get-permissioned-balances-test | ||
(let [cofx {:db {}}] | ||
(is (match? {:fx [[:json-rpc/call | ||
[{:method :wakuext_getCommunityPermissionedBalances | ||
:params [{:communityId community-id}] | ||
:on-success [:communities/get-permissioned-balances-success community-id] | ||
:on-error fn?}]]]} | ||
(sut/get-permissioned-balances cofx [community-id]))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters