chore: rename alias of promesa to be more verbose (#19332)

This commit is contained in:
Jamie Caprani 2024-03-28 16:33:16 +00:00 committed by GitHub
parent e6d9ef0298
commit 53874c8343
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 120 additions and 117 deletions

View File

@ -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}}

View File

@ -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]
@ -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)})))

View File

@ -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]
@ -37,7 +37,7 @@
(defn image-get-size
[uri]
(p/create (fn [res rej]
(promesa/create (fn [res rej]
(.getSize ^js (.-Image ^js react-native)
uri
(fn [width height] (res [width height]))

View File

@ -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]
@ -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

View File

@ -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]
@ -31,7 +31,7 @@
(defn- resize-photo
[uri]
(p/let [[width height] (rn/image-get-size uri)
(promesa/let [[width height] (rn/image-get-size uri)
resize? (> (max width height)
maximum-image-size-px)
resized-uri (-> (image-resizer/resize
@ -39,7 +39,7 @@
:max-height (if resize? maximum-image-size-px height)
:path uri
:quality 60})
(p/then (fn [^js resized-image]
(promesa/then (fn [^js resized-image]
(let [path (.-path resized-image)]
(if (string/starts-with? path "file")
path
@ -51,9 +51,9 @@
(rf/reg-fx :effects.camera-roll/image-selected
(fn [[image chat-id]]
(-> (resize-photo (:uri image))
(p/then #(rf/dispatch
(promesa/then #(rf/dispatch
[:photo-selector/image-selected chat-id image %]))
(p/catch #(log/error "could not resize image" %)))))
(promesa/catch #(log/error "could not resize image" %)))))
(defn- get-albums
[callback]

View File

@ -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
@ -17,7 +17,7 @@
(defn- sign-data
[sign-params password]
(p/create
(promesa/create
(fn [p-resolve p-reject]
(rpc/call
{:method :wakuext_signData
@ -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
@ -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
@ -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)
(-> (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
[:=>

View File

@ -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
@ -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)
@ -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 []
@ -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]
@ -176,7 +176,7 @@
(defn- recover-multiaccount!
[]
(p/let [masked-seed-phrase (security/mask-data (:seed-phrase constants/recovery-account))
(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 :screen/profile.profiles])
@ -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.
@ -225,13 +225,13 @@
done
(let [restore-fn (rf/make-restore-fn)]
(log-headline test-name)
(-> (p/do (f done))
(p/timeout timeout-ms)
(p/catch (fn [error]
(-> (promesa/do (f done))
(promesa/timeout timeout-ms)
(promesa/catch (fn [error]
(is (nil? error))
(when fail-fast?
(js/process.exit 1))))
(p/finally (fn []
(promesa/finally (fn []
(restore-fn)
(done))))))))
@ -239,7 +239,7 @@
[]
(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
@ -252,7 +252,7 @@
[]
(test-async ::create-account
(fn []
(p/do
(promesa/do
(setup-app)
(setup-account)
(logout)
@ -271,17 +271,17 @@
{:before (if (= :recovered-account type)
(fn []
(test/async done
(p/do (setup-app)
(promesa/do (setup-app)
(setup-recovered-account)
(done))))
(fn []
(test/async done
(p/do (setup-app)
(promesa/do (setup-app)
(setup-account)
(done)))))
:after (fn []
(test/async done
(p/do (logout)
(promesa/do (logout)
(wait-for [::logout/logout-method])
(done))))})
([] (fixture-session [:new-account])))

View File

@ -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
@ -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"))))))

View File

@ -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

View File

@ -4,7 +4,7 @@
legacy.status-im.events
legacy.status-im.subs.root
[native-module.core :as native-module]
[promesa.core :as p]
[promesa.core :as promesa]
status-im.events
status-im.navigation.core
status-im.subs.root
@ -24,7 +24,7 @@
(deftest wallet-get-derived-addressess-contract-test
(h/test-async :wallet/create-derived-addresses
(fn []
(p/let [sha3-pwd-hash (native-module/sha3 integration-constants/password)
(promesa/let [sha3-pwd-hash (native-module/sha3 integration-constants/password)
derivation-path [integration-constants/derivation-path]
accounts (contract-utils/call-rpc "accounts_getAccounts")
default-address (contract-utils/get-default-address accounts)

View File

@ -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.common.emoji-picker.utils :as emoji-picker.utils]
[status-im.constants :as constants]
[status-im.contexts.wallet.data-store :as data-store]
@ -26,7 +26,7 @@
(deftest accounts-get-accounts-contract-test
(h/test-async :contract/accounts-get-accounts
(fn []
(p/let [result (contract-utils/call-rpc "accounts_getAccounts")]
(promesa/let [result (contract-utils/call-rpc "accounts_getAccounts")]
(assert-accounts-get-accounts result)))))
(defn check-emoji-is-updated
@ -37,7 +37,7 @@
(deftest accounts-save-accounts-contract
(h/test-async :contract/accounts-save-account
(fn []
(p/let [test-emoji (emoji-picker.utils/random-emoji)
(promesa/let [test-emoji (emoji-picker.utils/random-emoji)
account (contract-utils/call-rpc "accounts_getAccounts")
default-account (contract-utils/get-default-account account)
_ (contract-utils/call-rpc
@ -59,7 +59,7 @@
(deftest accounts-get-chains-contract
(h/test-async :contract/wallet_get-ethereum-chains
(fn []
(p/let [response (contract-utils/call-rpc "wallet_getEthereumChains")]
(promesa/let [response (contract-utils/call-rpc "wallet_getEthereumChains")]
(assert-ethereum-chains response)))))
(defn assert-wallet-tokens
@ -81,7 +81,7 @@
(deftest wallet-get-walet-token-test
(h/test-async :wallet/get-wallet-token
(fn []
(p/let [accounts (contract-utils/call-rpc "accounts_getAccounts")
(promesa/let [accounts (contract-utils/call-rpc "accounts_getAccounts")
default-address (contract-utils/get-default-address accounts)
response (contract-utils/call-rpc
"wallet_getWalletToken"
@ -98,8 +98,10 @@
(deftest wallet-get-address-details-contract-test
(h/test-async :wallet/get-address-details
(fn []
(p/let [input "test.eth"
(promesa/let [input "test.eth"
chain-id constants/ethereum-mainnet-chain-id
ens-address (contract-utils/call-rpc "ens_addressOf" chain-id input)
response (contract-utils/call-rpc "wallet_getAddressDetails" chain-id ens-address)]
response (contract-utils/call-rpc "wallet_getAddressDetails"
chain-id
ens-address)]
(assert-address-details response)))))

View File

@ -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]
[re-frame.core :as rf]
[status-im.constants :as constants]
status-im.events
@ -19,7 +19,7 @@
(deftest one-to-one-chat-test
(h/test-async ::one-to-one-chat
(fn []
(p/do
(promesa/do
(rf/dispatch-sync [:chat.ui/start-chat chat-id])
(h/wait-for [:chat/one-to-one-chat-created])
(rf/dispatch-sync [:chat/navigate-to-chat chat-id])
@ -28,7 +28,7 @@
(deftest delete-chat-test
(h/test-async ::delete-chat
(fn []
(p/do
(promesa/do
(rf/dispatch-sync [:chat.ui/start-chat chat-id])
(h/wait-for [:chat/one-to-one-chat-created])
(rf/dispatch-sync [:chat/navigate-to-chat chat-id])
@ -40,7 +40,7 @@
(deftest mute-chat-test
(h/test-async ::mute-chat
(fn []
(p/do
(promesa/do
(rf/dispatch-sync [:chat.ui/start-chat chat-id])
(h/wait-for [:chat/one-to-one-chat-created])
@ -64,7 +64,7 @@
"ed2a86050325bc8856e26898c17e31dee2602b9429c91"
"ecf65a41d62ac1f2f0823c0710dcb536e79af2763c")
primary-name "zQ3...pFNErL"]
(p/do
(promesa/do
;; Search for contact using compressed key
(rf/dispatch [:contacts/set-new-identity {:input compressed-key}])
(h/wait-for [:contacts/set-new-identity-success])

View File

@ -1,7 +1,7 @@
(ns tests.integration-test.profile-test
(:require
[cljs.test :refer [deftest is use-fixtures]]
[promesa.core :as p]
[promesa.core :as promesa]
[status-im.contexts.profile.utils :as profile.utils]
[test-helpers.integration :as h]
[tests.test-utils :as test-utils]
@ -13,7 +13,7 @@
(h/test-async ::edit-profile-name
(fn []
(let [new-name "John Doe"]
(p/do
(promesa/do
(rf/dispatch [:profile/edit-name new-name])
(h/wait-for [:navigate-back :toasts/upsert])
(let [profile (rf/sub [:profile/profile])
@ -25,7 +25,7 @@
(fn []
(let [mock-image "resources/images/mock2/monkey.png"
absolute-path (.resolve test-utils/path mock-image)]
(p/do
(promesa/do
(rf/dispatch [:profile/edit-picture absolute-path 80 80])
(h/wait-for [:profile/update-local-picture :toasts/upsert])
(let [profile (rf/sub [:profile/profile])]
@ -34,7 +34,7 @@
(deftest delete-profile-picture-test
(h/test-async ::delete-profile-picture
(fn []
(p/do
(promesa/do
(rf/dispatch [:profile/delete-picture])
(h/wait-for [:profile/update-local-picture :toasts/upsert])
(let [profile (rf/sub [:profile/profile])]
@ -44,7 +44,7 @@
(h/test-async ::edit-profile-bio
(fn []
(let [new-bio "New bio text"]
(p/do
(promesa/do
(rf/dispatch [:profile/edit-bio new-bio])
(h/wait-for [:navigate-back :toasts/upsert])
(let [profile (rf/sub [:profile/profile])