Skip to content

Commit

Permalink
chore: rename alias of promesa to be more verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Son89 committed Mar 25, 2024
1 parent 399da79 commit 11febc8
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .clj-kondo/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
malli.generator malli.generator
malli.transform malli.transform
malli.util malli.util
promesa.core p
promesa.core promesa
schema.core schema
status-im.feature-flags ff
taoensso.timbre log}}
Expand Down
4 changes: 2 additions & 2 deletions src/quo/components/profile/expanded_collectible/view.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns quo.components.profile.expanded-collectible.view
(:require
[promesa.core :as p]
[promesa.core :as promesa]
[quo.components.counter.collectible-counter.view :as collectible-counter]
[quo.components.icon :as icon]
[quo.components.markdown.text :as text]
Expand Down Expand Up @@ -37,7 +37,7 @@
[image-size set-image-size] (rn/use-state {})]
(rn/use-effect
(fn []
(p/let [[image-width image-height] (rn/image-get-size image-src)]
(promesa/let [[image-width image-height] (rn/image-get-size image-src)]
(set-image-size {:width image-width
:height image-height
:aspect-ratio (/ image-width image-height)})))
Expand Down
12 changes: 6 additions & 6 deletions src/react_native/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
["react" :as react]
["react-native" :as react-native]
[oops.core :as oops]
[promesa.core :as p]
[promesa.core :as promesa]
[react-native.flat-list :as flat-list]
[react-native.platform :as platform]
[react-native.section-list :as section-list]
Expand Down Expand Up @@ -37,11 +37,11 @@

(defn image-get-size
[uri]
(p/create (fn [res rej]
(.getSize ^js (.-Image ^js react-native)
uri
(fn [width height] (res [width height]))
rej))))
(promesa/create (fn [res rej]
(.getSize ^js (.-Image ^js react-native)
uri
(fn [width height] (res [width height]))
rej))))
(def text (reagent/adapt-react-class (.-Text ^js react-native)))
(def text-input (reagent/adapt-react-class (.-TextInput ^js react-native)))

Expand Down
5 changes: 3 additions & 2 deletions src/status_im/common/log.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns status-im.common.log
(:require
[clojure.pprint :as p]
[clojure.pprint :as promesa]
[clojure.string :as string]
[native-module.core :as native-module]
[re-frame.core :as re-frame]
Expand Down Expand Up @@ -43,7 +43,8 @@
:middleware [(fn [data]
(update data
:vargs
(partial mapv #(if (string? %) % (with-out-str (p/pprint %))))))]})
(partial mapv
#(if (string? %) % (with-out-str (promesa/pprint %))))))]})
(native-module/init-status-go-logging logging-params)))))

(re-frame/reg-fx
Expand Down
34 changes: 17 additions & 17 deletions src/status_im/contexts/chat/messenger/photo_selector/effects.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns status-im.contexts.chat.messenger.photo-selector.effects
(:require
[clojure.string :as string]
[promesa.core :as p]
[promesa.core :as promesa]
[react-native.cameraroll :as cameraroll]
[react-native.core :as rn]
[react-native.image-resizer :as image-resizer]
Expand Down Expand Up @@ -31,29 +31,29 @@

(defn- resize-photo
[uri]
(p/let [[width height] (rn/image-get-size uri)
resize? (> (max width height)
maximum-image-size-px)
resized-uri (-> (image-resizer/resize
{:max-width (if resize? maximum-image-size-px width)
:max-height (if resize? maximum-image-size-px height)
:path uri
:quality 60})
(p/then (fn [^js resized-image]
(let [path (.-path resized-image)]
(if (string/starts-with? path "file")
path
(str "file://" path))))))]
(promesa/let [[width height] (rn/image-get-size uri)
resize? (> (max width height)
maximum-image-size-px)
resized-uri (-> (image-resizer/resize
{:max-width (if resize? maximum-image-size-px width)
:max-height (if resize? maximum-image-size-px height)
:path uri
:quality 60})
(promesa/then (fn [^js resized-image]
(let [path (.-path resized-image)]
(if (string/starts-with? path "file")
path
(str "file://" path))))))]
{:resized-uri resized-uri
:width width
:height height}))

(rf/reg-fx :effects.camera-roll/image-selected
(fn [[image chat-id]]
(-> (resize-photo (:uri image))
(p/then #(rf/dispatch
[:photo-selector/image-selected chat-id image %]))
(p/catch #(log/error "could not resize image" %)))))
(promesa/then #(rf/dispatch
[:photo-selector/image-selected chat-id image %]))
(promesa/catch #(log/error "could not resize image" %)))))

(defn- get-albums
[callback]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
(ns status-im.contexts.communities.actions.accounts-selection.effects
(:require
[promesa.core :as p]
[promesa.core :as promesa]
[schema.core :as schema]
[status-im.common.json-rpc.events :as rpc]
[utils.re-frame :as rf]))

(defn- generate-requests-for-signing
[pub-key community-id addresses-to-reveal]
(p/create
(promesa/create
(fn [p-resolve p-reject]
(rpc/call
{:method :wakuext_generateJoiningCommunityRequestsForSigning
Expand All @@ -17,7 +17,7 @@

(defn- sign-data
[sign-params password]
(p/create
(promesa/create
(fn [p-resolve p-reject]
(rpc/call
{:method :wakuext_signData
Expand All @@ -27,7 +27,7 @@

(defn- edit-shared-addresses-for-community
[community-id signatures addresses-to-reveal airdrop-address]
(p/create
(promesa/create
(fn [p-resolve p-reject]
(rpc/call
{:method :wakuext_editSharedAddressesForCommunity
Expand All @@ -41,7 +41,7 @@

(defn- request-to-join
[community-id signatures addresses-to-reveal airdrop-address]
(p/create
(promesa/create
(fn [p-resolve p-reject]
(rpc/call
{:method :wakuext_requestToJoinCommunity
Expand All @@ -66,14 +66,14 @@
addresses-to-reveal airdrop-address
on-success on-error
callback]}]
(-> (p/let [sign-params (generate-requests-for-signing pub-key community-id addresses-to-reveal)
signatures (sign-data sign-params password)
result (callback community-id
signatures
addresses-to-reveal
airdrop-address)]
(-> (promesa/let [sign-params (generate-requests-for-signing pub-key community-id addresses-to-reveal)
signatures (sign-data sign-params password)
result (callback community-id
signatures
addresses-to-reveal
airdrop-address)]
(run-callback-or-event on-success result))
(p/catch #(run-callback-or-event on-error %))))
(promesa/catch #(run-callback-or-event on-error %))))

(schema/=> sign-and-call-endpoint
[:=>
Expand Down
68 changes: 34 additions & 34 deletions src/test_helpers/integration.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[legacy.status-im.multiaccounts.logout.core :as logout]
legacy.status-im.subs.root
[native-module.core :as native-module]
[promesa.core :as p]
[promesa.core :as promesa]
[re-frame.core :as rf]
[re-frame.interop :as rf.interop]
status-im.events
Expand All @@ -20,7 +20,7 @@

(defn validate-mnemonic
[mnemonic]
(p/create
(promesa/create
(fn [p-resolve p-reject]
(native-module/validate-mnemonic
(security/safe-unmask-data mnemonic)
Expand Down Expand Up @@ -111,7 +111,7 @@
(wait-for event-ids default-re-frame-wait-for-timeout-ms))
([event-ids timeout-ms]
(let [waiting-ids (atom event-ids)]
(p/create
(promesa/create
(fn [promise-resolve promise-reject]
(let [cb-id (gensym "post-event-callback")
timer-id (js/setTimeout (fn []
Expand Down Expand Up @@ -148,18 +148,18 @@
[]
(test-utils/init!)
(if (app-initialized)
(p/resolved ::app-initialized)
(p/do!
(promesa/resolved ::app-initialized)
(promesa/do!
(rf/dispatch [:app-started])
(wait-for [:profile/get-profiles-overview-success]))))

(defn setup-account
[]
(if (messenger-started)
(p/resolved ::messenger-started)
(p/do!
(promesa/resolved ::messenger-started)
(promesa/do!
(create-multiaccount!)
(p/then (wait-for [:profile.login/messenger-started]) #(assert-messenger-started)))))
(promesa/then (wait-for [:profile.login/messenger-started]) #(assert-messenger-started)))))

(defn- recover-and-login
[seed-phrase]
Expand All @@ -176,8 +176,8 @@

(defn- recover-multiaccount!
[]
(p/let [masked-seed-phrase (security/mask-data (:seed-phrase constants/recovery-account))
[mnemonic key-uid] (validate-mnemonic masked-seed-phrase)]
(promesa/let [masked-seed-phrase (security/mask-data (:seed-phrase constants/recovery-account))
[mnemonic key-uid] (validate-mnemonic masked-seed-phrase)]
(rf/dispatch [:onboarding/seed-phrase-validated (security/mask-data mnemonic) key-uid])
(rf/dispatch [:pop-to-root :profiles])
(rf/dispatch [:profile/profile-selected key-uid])
Expand All @@ -186,12 +186,12 @@
(defn setup-recovered-account
[]
(if (messenger-started)
(p/resolved ::messenger-started)
(p/do!
(promesa/resolved ::messenger-started)
(promesa/do!
(recover-multiaccount!)
(p/then (wait-for [:profile.login/messenger-started]) #(assert-messenger-started))
(promesa/then (wait-for [:profile.login/messenger-started]) #(assert-messenger-started))
(enable-testnet!)
(p/then (wait-for [:wallet/store-wallet-token]) #(assert-wallet-loaded)))))
(promesa/then (wait-for [:wallet/store-wallet-token]) #(assert-wallet-loaded)))))

(defn test-async
"Runs `f` inside `cljs.test/async` macro in a restorable re-frame checkpoint.
Expand Down Expand Up @@ -225,21 +225,21 @@
done
(let [restore-fn (rf/make-restore-fn)]
(log-headline test-name)
(-> (p/do (f done))
(p/timeout timeout-ms)
(p/catch (fn [error]
(is (nil? error))
(when fail-fast?
(js/process.exit 1))))
(p/finally (fn []
(restore-fn)
(done))))))))
(-> (promesa/do (f done))
(promesa/timeout timeout-ms)
(promesa/catch (fn [error]
(is (nil? error))
(when fail-fast?
(js/process.exit 1))))
(promesa/finally (fn []
(restore-fn)
(done))))))))

(defn test-app-initialization
[]
(test-async ::initialize-app
(fn []
(p/do
(promesa/do
(test-utils/init!)
(rf/dispatch [:app-started])
;; Use initialize-view because it has the longest avg. time and is
Expand All @@ -252,7 +252,7 @@
[]
(test-async ::create-account
(fn []
(p/do
(promesa/do
(setup-app)
(setup-account)
(logout)
Expand All @@ -271,19 +271,19 @@
{:before (if (= :recovered-account type)
(fn []
(test/async done
(p/do (setup-app)
(setup-recovered-account)
(done))))
(promesa/do (setup-app)
(setup-recovered-account)
(done))))
(fn []
(test/async done
(p/do (setup-app)
(setup-account)
(done)))))
(promesa/do (setup-app)
(setup-account)
(done)))))
:after (fn []
(test/async done
(p/do (logout)
(wait-for [::logout/logout-method])
(done))))})
(promesa/do (logout)
(wait-for [::logout/logout-method])
(done))))})
([] (fixture-session [:new-account])))

(defn fixture-silence-reframe
Expand Down
4 changes: 2 additions & 2 deletions src/tests/contract_test/profile_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[cljs.test :refer [deftest is use-fixtures]]
legacy.status-im.events
legacy.status-im.subs.root
[promesa.core :as p]
[promesa.core :as promesa]
status-im.events
status-im.navigation.core
status-im.subs.root
Expand All @@ -16,4 +16,4 @@
(h/test-async :contract/wakuext_setBio
(fn []
(-> (contract-utils/call-rpc "wakuext_setBio" "new bio")
(p/catch #(is (nil? %) "Set bio RPC call should have succeeded"))))))
(promesa/catch #(is (nil? %) "Set bio RPC call should have succeeded"))))))
4 changes: 2 additions & 2 deletions src/tests/contract_test/utils.cljs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(ns tests.contract-test.utils
(:require
[promesa.core :as p]
[promesa.core :as promesa]
[status-im.common.json-rpc.events :as rpc-events]
[utils.number]))

(defn call-rpc
[method & args]
(p/create
(promesa/create
(fn [p-resolve p-reject]
(rpc-events/call {:method method
:params args
Expand Down
Loading

0 comments on commit 11febc8

Please sign in to comment.