refactor: go through clj-kondo warnings (#13929)

This commit is contained in:
yqrashawn 2022-09-05 18:52:39 +08:00 committed by GitHub
parent 1a3e89ea7a
commit ccd26dcfd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 186 additions and 186 deletions

View File

@ -91,7 +91,8 @@
:source-map false :source-map false
;; needed because we use deref in tests ;; needed because we use deref in tests
:static-fns false :static-fns false
:optimizations :simple}} :optimizations :simple
:infer-externs true}}
;; mock.js-dependencies is mocking the react-native libraries ;; mock.js-dependencies is mocking the react-native libraries
;; we build it as a node library so that it can be required by ;; we build it as a node library so that it can be required by

View File

@ -1,7 +1,7 @@
(ns quo.react (ns quo.react
(:refer-clojure :exclude [ref]) (:refer-clojure :exclude [ref])
(:require [oops.core :refer [oget oset!]] (:require ["react" :as react]
["react" :as react]) [oops.core :refer [oget oset!]])
(:require-macros [quo.react :refer [with-deps-check (:require-macros [quo.react :refer [with-deps-check
maybe-js-deps]])) maybe-js-deps]]))
@ -25,21 +25,21 @@
(-hash [o] (goog/getUid o)) (-hash [o] (goog/getUid o))
cljs.core/IDeref cljs.core/IDeref
(-deref [o] (-deref [_o]
value) value)
cljs.core/IReset cljs.core/IReset
(-reset! [o new-value] (-reset! [_o new-value]
(set-value new-value)) (set-value new-value))
cljs.core/ISwap cljs.core/ISwap
(-swap! [o f] (-swap! [_o f]
(set-value f)) (set-value f))
(-swap! [o f a] (-swap! [_o f a]
(set-value #(f % a))) (set-value #(f % a)))
(-swap! [o f a b] (-swap! [_o f a b]
(set-value #(f % a b))) (set-value #(f % a b)))
(-swap! [o f a b xs] (-swap! [_o f a b xs]
(set-value #(apply f % a b xs)))) (set-value #(apply f % a b xs))))
(defn state [value] (defn state [value]

View File

@ -1,25 +1,25 @@
(ns status-im.core (ns status-im.core
(:require status-im.utils.db (:require ["react-native" :refer (DevSettings LogBox)]
status-im.events ["react-native-languages" :default react-native-languages]
status-im.subs ["react-native-shake" :as react-native-shake]
status-im.navigation.core
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[re-frame.interop :as interop] [re-frame.interop :as interop]
[reagent.impl.batching :as batching] [reagent.impl.batching :as batching]
[status-im.notifications.local :as notifications] [status-im.async-storage.core :as async-storage]
status-im.events
[status-im.i18n.i18n :as i18n]
[status-im.native-module.core :as status] [status-im.native-module.core :as status]
status-im.navigation.core
[status-im.notifications.local :as notifications]
status-im.subs
[status-im.ui.components.react :as react]
[status-im.utils.config :as config]
status-im.utils.db
[status-im.utils.error-handler :as error-handler] [status-im.utils.error-handler :as error-handler]
[status-im.utils.logging.core :as utils.logs] [status-im.utils.logging.core :as utils.logs]
[status-im.utils.platform :as platform] [status-im.utils.platform :as platform]
[status-im.utils.snoopy :as snoopy] [status-im.utils.snoopy :as snoopy]
[status-im.utils.config :as config] [status-im.utils.universal-links.core :as utils.universal-links]))
[status-im.utils.universal-links.core :as utils.universal-links]
[status-im.i18n.i18n :as i18n]
[status-im.ui.components.react :as react]
[status-im.async-storage.core :as async-storage]
["react-native" :refer (DevSettings LogBox)]
["react-native-languages" :default react-native-languages]
["react-native-shake" :as react-native-shake]))
(set! interop/next-tick js/setTimeout) (set! interop/next-tick js/setTimeout)
(set! batching/fake-raf #(js/setTimeout % 0)) (set! batching/fake-raf #(js/setTimeout % 0))

View File

@ -1,8 +1,8 @@
(ns status-im.ethereum.abi-spec (ns status-im.ethereum.abi-spec
(:require [cljs.spec.alpha :as spec] (:require ["web3-utils" :as utils]
[cljs.spec.alpha :as spec]
[clojure.string :as string] [clojure.string :as string]
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]))
["web3-utils" :as utils]))
;; Utility functions for encoding ;; Utility functions for encoding
@ -213,15 +213,15 @@
(spec/def ::string string?) (spec/def ::string string?)
(defn- single-char [code] (defn- single-char [code]
(if-let [m (#{\, \[ \] \x} (first code))] (when-let [m (#{\, \[ \] \x} (first code))]
[1 m])) [1 m]))
(defn- number [code] (defn- number [code]
(if-let [m (re-find #"^[0-9]+" code)] (when-let [m (re-find #"^[0-9]+" code)]
[(count m) (js/parseInt m)])) [(count m) (js/parseInt m)]))
(defn- string [s] (defn- string [s]
(if-let [m (re-find #"^[a-z]+" s)] (when-let [m (re-find #"^[a-z]+" s)]
[(count m) m])) [(count m) m]))
(defn tokenise [code] (defn tokenise [code]

View File

@ -1,6 +1,6 @@
(ns status-im.ethereum.core (ns status-im.ethereum.core
(:require [clojure.string :as string] (:require ["web3-utils" :as utils]
["web3-utils" :as utils] [clojure.string :as string]
[status-im.ethereum.eip55 :as eip55])) [status-im.ethereum.eip55 :as eip55]))
(defn sha3 [s] (defn sha3 [s]

View File

@ -1,5 +1,5 @@
(ns status-im.ethereum.eip681-test (ns status-im.ethereum.eip681-test
(:require [cljs.test :refer-macros [deftest is]] (:require [cljs.test :refer-macros [deftest is] :as test]
[status-im.ethereum.eip681 :as eip681] [status-im.ethereum.eip681 :as eip681]
[status-im.utils.money :as money])) [status-im.utils.money :as money]))
@ -139,8 +139,8 @@
(is (.equals (money/ether->wei (money/bignumber 1)) value)) (is (.equals (money/ether->wei (money/bignumber 1)) value))
(is (= :ETH symbol)) (is (= :ETH symbol))
(is (= "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7" address))) (is (= "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7" address)))
(is (= (eip681/extract-request-details {:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e" :chain-id 1 :function-name "unknown"} (is (= (eip681/extract-request-details {:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e" :chain-id 1 :function-name "unknown"} {})
{:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e" :chain-id 1 :function-name "unknown"}))) {:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e" :chain-id 1 :function-name "unknown"}))
(let [{:keys [value symbol address]} (eip681/extract-request-details {:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e" :chain-id 1 (let [{:keys [value symbol address]} (eip681/extract-request-details {:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e" :chain-id 1
:function-name "transfer" :function-arguments {:uint256 1000 :address "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7"}} :function-name "transfer" :function-arguments {:uint256 1000 :address "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7"}}
{"0x744d70fdbe2ba4cf95131626614a1763df805b9e" {:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e" {"0x744d70fdbe2ba4cf95131626614a1763df805b9e" {:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e"

View File

@ -1,12 +1,12 @@
(ns status-im.keycard.real-keycard (ns status-im.keycard.real-keycard
(:require ["react-native-status-keycard" :default status-keycard] (:require ["react-native" :as rn]
["react-native" :as rn] ["react-native-status-keycard" :default status-keycard]
[status-im.utils.types :as types]
[status-im.native-module.core :as status]
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.keycard.keycard :as keycard] [status-im.keycard.keycard :as keycard]
[taoensso.timbre :as log] [status-im.native-module.core :as status]
[status-im.utils.platform :as platform])) [status-im.utils.platform :as platform]
[status-im.utils.types :as types]
[taoensso.timbre :as log]))
(defonce event-emitter (if platform/ios? (defonce event-emitter (if platform/ios?
(new (.-NativeEventEmitter rn) status-keycard) (new (.-NativeEventEmitter rn) status-keycard)
@ -199,7 +199,7 @@
(defn unpair (defn unpair
[{:keys [pin on-success on-failure]}] [{:keys [pin on-success on-failure]}]
(when (and pin) (when pin
(.. status-keycard (.. status-keycard
(unpair pin) (unpair pin)
(then on-success) (then on-success)
@ -298,79 +298,79 @@
(defrecord RealKeycard [] (defrecord RealKeycard []
keycard/Keycard keycard/Keycard
(keycard/start-nfc [this args] (keycard/start-nfc [_this args]
(start-nfc args)) (start-nfc args))
(keycard/stop-nfc [this args] (keycard/stop-nfc [_this args]
(stop-nfc args)) (stop-nfc args))
(keycard/set-nfc-message [this args] (keycard/set-nfc-message [_this args]
(set-nfc-message args)) (set-nfc-message args))
(keycard/check-nfc-support [this args] (keycard/check-nfc-support [_this args]
(check-nfc-support args)) (check-nfc-support args))
(keycard/check-nfc-enabled [this args] (keycard/check-nfc-enabled [_this args]
(check-nfc-enabled args)) (check-nfc-enabled args))
(keycard/open-nfc-settings [this] (keycard/open-nfc-settings [_this]
(open-nfc-settings)) (open-nfc-settings))
(keycard/register-card-events [this args] (keycard/register-card-events [_this args]
(register-card-events args)) (register-card-events args))
(keycard/on-card-connected [this callback] (keycard/on-card-connected [_this callback]
(on-card-connected callback)) (on-card-connected callback))
(keycard/on-card-disconnected [this callback] (keycard/on-card-disconnected [_this callback]
(on-card-disconnected callback)) (on-card-disconnected callback))
(keycard/remove-event-listener [this event] (keycard/remove-event-listener [_this event]
(remove-event-listener event)) (remove-event-listener event))
(keycard/remove-event-listeners [this] (keycard/remove-event-listeners [_this]
(remove-event-listeners)) (remove-event-listeners))
(keycard/set-pairings [this args] (keycard/set-pairings [_this args]
(set-pairings args)) (set-pairings args))
(keycard/get-application-info [this args] (keycard/get-application-info [_this args]
(get-application-info args)) (get-application-info args))
(keycard/factory-reset [this args] (keycard/factory-reset [_this args]
(factory-reset args)) (factory-reset args))
(keycard/install-applet [this args] (keycard/install-applet [_this args]
(install-applet args)) (install-applet args))
(keycard/install-cash-applet [this args] (keycard/install-cash-applet [_this args]
(install-cash-applet args)) (install-cash-applet args))
(keycard/init-card [this args] (keycard/init-card [_this args]
(init-card args)) (init-card args))
(keycard/install-applet-and-init-card [this args] (keycard/install-applet-and-init-card [_this args]
(install-applet-and-init-card args)) (install-applet-and-init-card args))
(keycard/pair [this args] (keycard/pair [_this args]
(pair args)) (pair args))
(keycard/generate-and-load-key [this args] (keycard/generate-and-load-key [_this args]
(generate-and-load-key args)) (generate-and-load-key args))
(keycard/unblock-pin [this args] (keycard/unblock-pin [_this args]
(unblock-pin args)) (unblock-pin args))
(keycard/verify-pin [this args] (keycard/verify-pin [_this args]
(verify-pin args)) (verify-pin args))
(keycard/change-pin [this args] (keycard/change-pin [_this args]
(change-pin args)) (change-pin args))
(keycard/change-puk [this args] (keycard/change-puk [_this args]
(change-puk args)) (change-puk args))
(keycard/change-pairing [this args] (keycard/change-pairing [_this args]
(change-pairing args)) (change-pairing args))
(keycard/unpair [this args] (keycard/unpair [_this args]
(unpair args)) (unpair args))
(keycard/delete [this args] (keycard/delete [_this args]
(delete args)) (delete args))
(keycard/remove-key [this args] (keycard/remove-key [_this args]
(remove-key args)) (remove-key args))
(keycard/remove-key-with-unpair [this args] (keycard/remove-key-with-unpair [_this args]
(remove-key-with-unpair args)) (remove-key-with-unpair args))
(keycard/export-key [this args] (keycard/export-key [_this args]
(export-key args)) (export-key args))
(keycard/unpair-and-delete [this args] (keycard/unpair-and-delete [_this args]
(unpair-and-delete args)) (unpair-and-delete args))
(keycard/import-keys [this args] (keycard/import-keys [_this args]
(import-keys args)) (import-keys args))
(keycard/get-keys [this args] (keycard/get-keys [_this args]
(get-keys args)) (get-keys args))
(keycard/sign [this args] (keycard/sign [_this args]
(sign args)) (sign args))
(keycard/sign-typed-data [this args] (keycard/sign-typed-data [_this args]
(sign-typed-data args)) (sign-typed-data args))
(keycard/save-multiaccount-and-login [this args] (keycard/save-multiaccount-and-login [_this args]
(save-multiaccount-and-login args)) (save-multiaccount-and-login args))
(keycard/login [this args] (keycard/login [_this args]
(login args)) (login args))
(keycard/send-transaction-with-signature [this args] (keycard/send-transaction-with-signature [_this args]
(send-transaction-with-signature args))) (send-transaction-with-signature args)))

View File

@ -1,17 +1,17 @@
(ns status-im.keycard.simulated-keycard (ns status-im.keycard.simulated-keycard
(:require [re-frame.core :as re-frame] (:require [clojure.string :as string]
[re-frame.core :as re-frame]
[re-frame.db :as re-frame.db] [re-frame.db :as re-frame.db]
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.i18n.i18n :as i18n]
[status-im.keycard.keycard :as keycard] [status-im.keycard.keycard :as keycard]
[status-im.multiaccounts.create.core :as multiaccounts.create]
[status-im.native-module.core :as status] [status-im.native-module.core :as status]
[status-im.node.core :as node]
[status-im.utils.types :as types] [status-im.utils.types :as types]
[status-im.utils.utils :as utils] [status-im.utils.utils :as utils]
[status-im.i18n.i18n :as i18n] [taoensso.timbre :as log]))
[clojure.string :as string]
[taoensso.timbre :as log]
[status-im.multiaccounts.create.core :as multiaccounts.create]
[status-im.node.core :as node]))
(def kk1-password "000000") (def kk1-password "000000")
(def default-pin "111111") (def default-pin "111111")
@ -243,9 +243,8 @@
{:root-key root-data {:root-key root-data
:derived derived-data-extended}))))))))))) :derived derived-data-extended})))))))))))
(when (= password (get @state :password)) (when (= password (get @state :password))
(do
(swap! state assoc-in [:application-info :paired?] true) (swap! state assoc-in [:application-info :paired?] true)
(later #(on-success (str (rand-int 10000000))))))) (later #(on-success (str (rand-int 10000000))))))
(defn generate-and-load-key (defn generate-and-load-key
[{:keys [pin on-success]}] [{:keys [pin on-success]}]
@ -441,111 +440,111 @@
(defrecord SimulatedKeycard [] (defrecord SimulatedKeycard []
keycard/Keycard keycard/Keycard
(keycard/start-nfc [this args] (keycard/start-nfc [_this args]
(log/debug "simulated card start-nfc") (log/debug "simulated card start-nfc")
(start-nfc args)) (start-nfc args))
(keycard/stop-nfc [this args] (keycard/stop-nfc [_this args]
(log/debug "simulated card stop-nfc") (log/debug "simulated card stop-nfc")
(stop-nfc args)) (stop-nfc args))
(keycard/set-nfc-message [this args] (keycard/set-nfc-message [_this args]
(log/debug "simulated card set-nfc-message") (log/debug "simulated card set-nfc-message")
(set-nfc-message args)) (set-nfc-message args))
(keycard/check-nfc-support [this args] (keycard/check-nfc-support [_this args]
(log/debug "simulated card check-nfc-support") (log/debug "simulated card check-nfc-support")
(check-nfc-support args)) (check-nfc-support args))
(keycard/check-nfc-enabled [this args] (keycard/check-nfc-enabled [_this args]
(log/debug "simulated card check-nfc-enabled") (log/debug "simulated card check-nfc-enabled")
(check-nfc-enabled args)) (check-nfc-enabled args))
(keycard/open-nfc-settings [this] (keycard/open-nfc-settings [_this]
(log/debug "simulated card open-nfc-setting") (log/debug "simulated card open-nfc-setting")
(open-nfc-settings)) (open-nfc-settings))
(keycard/register-card-events [this args] (keycard/register-card-events [_this args]
(log/debug "simulated card register-card-event") (log/debug "simulated card register-card-event")
(register-card-events args)) (register-card-events args))
(keycard/set-pairings [this args] (keycard/set-pairings [_this args]
(log/debug "simulated card set-pairings") (log/debug "simulated card set-pairings")
(set-pairings args)) (set-pairings args))
(keycard/on-card-connected [this callback] (keycard/on-card-connected [_this callback]
(log/debug "simulated card on-card-connected") (log/debug "simulated card on-card-connected")
(on-card-connected callback)) (on-card-connected callback))
(keycard/on-card-disconnected [this callback] (keycard/on-card-disconnected [_this callback]
(log/debug "simulated card on-card-disconnected") (log/debug "simulated card on-card-disconnected")
(on-card-disconnected callback)) (on-card-disconnected callback))
(keycard/remove-event-listener [this event] (keycard/remove-event-listener [_this event]
(log/debug "simulated card remove-event-listener") (log/debug "simulated card remove-event-listener")
(remove-event-listener event)) (remove-event-listener event))
(keycard/remove-event-listeners [this] (keycard/remove-event-listeners [_this]
(log/debug "simulated card remove-event-listener") (log/debug "simulated card remove-event-listener")
(remove-event-listeners)) (remove-event-listeners))
(keycard/get-application-info [this args] (keycard/get-application-info [_this args]
(log/debug "simulated card get-application-info") (log/debug "simulated card get-application-info")
(get-application-info args)) (get-application-info args))
(keycard/factory-reset [this args] (keycard/factory-reset [_this args]
(log/debug "simulated card factory-reset") (log/debug "simulated card factory-reset")
(factory-reset args)) (factory-reset args))
(keycard/install-applet [this args] (keycard/install-applet [_this args]
(log/debug "simulated card install-applet") (log/debug "simulated card install-applet")
(install-applet args)) (install-applet args))
(keycard/init-card [this args] (keycard/init-card [_this args]
(log/debug "simulated card init-card") (log/debug "simulated card init-card")
(init-card args)) (init-card args))
(keycard/install-applet-and-init-card [this args] (keycard/install-applet-and-init-card [_this args]
(log/debug "simulated card install-applet-and-init-card") (log/debug "simulated card install-applet-and-init-card")
(install-applet-and-init-card args)) (install-applet-and-init-card args))
(keycard/pair [this args] (keycard/pair [_this args]
(log/debug "simulated card pair") (log/debug "simulated card pair")
(pair args)) (pair args))
(keycard/generate-and-load-key [this args] (keycard/generate-and-load-key [_this args]
(log/debug "simulated card generate-and-load-key") (log/debug "simulated card generate-and-load-key")
(generate-and-load-key args)) (generate-and-load-key args))
(keycard/unblock-pin [this args] (keycard/unblock-pin [_this args]
(log/debug "simulated card unblock-pin") (log/debug "simulated card unblock-pin")
(unblock-pin args)) (unblock-pin args))
(keycard/verify-pin [this args] (keycard/verify-pin [_this args]
(log/debug "simulated card verify-pin") (log/debug "simulated card verify-pin")
(verify-pin args)) (verify-pin args))
(keycard/change-pin [this args] (keycard/change-pin [_this args]
(log/debug "simulated card change-pin") (log/debug "simulated card change-pin")
(change-pin args)) (change-pin args))
(keycard/change-puk [this args] (keycard/change-puk [_this args]
(log/debug "simulated card change-puk") (log/debug "simulated card change-puk")
(change-puk args)) (change-puk args))
(keycard/change-pairing [this args] (keycard/change-pairing [_this args]
(log/debug "simulated card change-pairing") (log/debug "simulated card change-pairing")
(change-pairing args)) (change-pairing args))
(keycard/unpair [this args] (keycard/unpair [_this args]
(log/debug "simulated card unpair") (log/debug "simulated card unpair")
(unpair args)) (unpair args))
(keycard/delete [this args] (keycard/delete [_this args]
(log/debug "simulated card delete") (log/debug "simulated card delete")
(delete args)) (delete args))
(keycard/remove-key [this args] (keycard/remove-key [_this args]
(log/debug "simulated card remove-key") (log/debug "simulated card remove-key")
(remove-key args)) (remove-key args))
(keycard/remove-key-with-unpair [this args] (keycard/remove-key-with-unpair [_this args]
(log/debug "simulated card remove-key-with-unpair") (log/debug "simulated card remove-key-with-unpair")
(remove-key-with-unpair args)) (remove-key-with-unpair args))
(keycard/export-key [this args] (keycard/export-key [_this args]
(log/debug "simulated card export-key") (log/debug "simulated card export-key")
(export-key args)) (export-key args))
(keycard/unpair-and-delete [this args] (keycard/unpair-and-delete [_this args]
(log/debug "simulated card unpair-and-delete") (log/debug "simulated card unpair-and-delete")
(unpair-and-delete args)) (unpair-and-delete args))
(keycard/import-keys [this args] (keycard/import-keys [_this args]
(log/debug "simulated card import-keys") (log/debug "simulated card import-keys")
(import-keys args)) (import-keys args))
(keycard/get-keys [this args] (keycard/get-keys [_this args]
(log/debug "simulated card get-keys") (log/debug "simulated card get-keys")
(get-keys args)) (get-keys args))
(keycard/sign [this args] (keycard/sign [_this args]
(log/debug "simulated card sign") (log/debug "simulated card sign")
(sign args)) (sign args))
(keycard/save-multiaccount-and-login [this args] (keycard/save-multiaccount-and-login [_this args]
(log/debug "simulated card save-multiaccount-and-login") (log/debug "simulated card save-multiaccount-and-login")
(save-multiaccount-and-login args)) (save-multiaccount-and-login args))
(keycard/login [this args] (keycard/login [_this args]
(log/debug "simulated card login") (log/debug "simulated card login")
(login args)) (login args))
(keycard/send-transaction-with-signature [this args] (keycard/send-transaction-with-signature [_this args]
(log/debug "simulated card send-transaction-with-signature") (log/debug "simulated card send-transaction-with-signature")
(send-transaction-with-signature args))) (send-transaction-with-signature args)))

View File

@ -1,9 +1,9 @@
(ns status-im.multiaccounts.login.core-test (ns status-im.multiaccounts.login.core-test
(:require [cljs.test :as test] (:require [cljs.test :as test]
[status-im.multiaccounts.login.core :as login]
[status-im.multiaccounts.biometric.core :as biometric] [status-im.multiaccounts.biometric.core :as biometric]
[status-im.utils.keychain.core :as keychain] [status-im.multiaccounts.login.core :as login]
[status-im.utils.fx :as fx])) [status-im.utils.fx :as fx]
[status-im.utils.keychain.core :as keychain]))
(test/deftest save-password-test (test/deftest save-password-test
(test/testing "check save password, biometric unavailable" (test/testing "check save password, biometric unavailable"
@ -59,4 +59,4 @@
(test/testing "disable biometric" (test/testing "disable biometric"
(let [{:keys [db]} (biometric/disable {:db db})] (let [{:keys [db]} (biometric/disable {:db db})]
(test/is (= false (get-in db [:multiaccounts/login :save-password?]))) (test/is (= false (get-in db [:multiaccounts/login :save-password?])))
(test/is (= keychain/auth-method-none) (:auth-method db))))))) (test/is (= keychain/auth-method-none (:auth-method db))))))))

View File

@ -1,19 +1,19 @@
(ns status-im.router.core (ns status-im.router.core
(:require [re-frame.core :as re-frame] (:require [bidi.bidi :as bidi]
[cljs.spec.alpha :as spec]
[clojure.string :as string] [clojure.string :as string]
[bidi.bidi :as bidi] [re-frame.core :as re-frame]
[taoensso.timbre :as log]
[status-im.add-new.db :as public-chat.db] [status-im.add-new.db :as public-chat.db]
[status-im.utils.security :as security] [status-im.chat.models :as chat.models]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip681 :as eip681] [status-im.ethereum.eip681 :as eip681]
[status-im.ethereum.ens :as ens] [status-im.ethereum.ens :as ens]
[cljs.spec.alpha :as spec] [status-im.ethereum.stateofus :as stateofus]
[status-im.ethereum.core :as ethereum]
[status-im.utils.db :as utils.db] [status-im.utils.db :as utils.db]
[status-im.utils.http :as http] [status-im.utils.http :as http]
[status-im.chat.models :as chat.models] [status-im.utils.security :as security]
[status-im.ethereum.stateofus :as stateofus] [status-im.utils.wallet-connect :as wallet-connect]
[status-im.utils.wallet-connect :as wallet-connect])) [taoensso.timbre :as log]))
(def ethereum-scheme "ethereum:") (def ethereum-scheme "ethereum:")

View File

@ -1,11 +1,17 @@
(ns status-im.subs (ns status-im.subs
(:require [cljs.spec.alpha :as spec] (:require [cljs.spec.alpha :as spec]
[clojure.set :as clojure.set]
[clojure.string :as string] [clojure.string :as string]
[quo.design-system.colors :as colors]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.add-new.db :as db]
[status-im.browser.core :as browser] [status-im.browser.core :as browser]
[status-im.chat.db :as chat.db] [status-im.chat.db :as chat.db]
[status-im.chat.models :as chat.models] [status-im.chat.models :as chat.models]
[status-im.chat.models.mentions :as mentions]
[status-im.chat.models.message-list :as models.message-list] [status-im.chat.models.message-list :as models.message-list]
[status-im.chat.models.reactions :as models.reactions]
[status-im.communities.core :as communities]
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.contact.db :as contact.db] [status-im.contact.db :as contact.db]
[status-im.ens.core :as ens] [status-im.ens.core :as ens]
@ -13,35 +19,29 @@
[status-im.ethereum.tokens :as tokens] [status-im.ethereum.tokens :as tokens]
[status-im.ethereum.transactions.core :as transactions] [status-im.ethereum.transactions.core :as transactions]
[status-im.fleet.core :as fleet] [status-im.fleet.core :as fleet]
[status-im.mailserver.core :as mailserver]
[status-im.group-chats.db :as group-chats.db]
[status-im.communities.core :as communities]
[status-im.group-chats.core :as group-chat] [status-im.group-chats.core :as group-chat]
[status-im.group-chats.db :as group-chats.db]
[status-im.i18n.i18n :as i18n] [status-im.i18n.i18n :as i18n]
[status-im.mailserver.core :as mailserver]
[status-im.multiaccounts.core :as multiaccounts] [status-im.multiaccounts.core :as multiaccounts]
[status-im.multiaccounts.db :as multiaccounts.db] [status-im.multiaccounts.db :as multiaccounts.db]
[status-im.multiaccounts.model :as multiaccounts.model] [status-im.multiaccounts.model :as multiaccounts.model]
[status-im.multiaccounts.recover.core :as recover] [status-im.multiaccounts.recover.core :as recover]
[status-im.chat.models.reactions :as models.reactions] [status-im.notifications.core :as notifications]
[status-im.pairing.core :as pairing] [status-im.pairing.core :as pairing]
[status-im.signing.gas :as signing.gas] [status-im.signing.gas :as signing.gas]
[status-im.add-new.db :as db] status-im.ui.screens.keycard.subs
[status-im.utils.mobile-sync :as mobile-network-utils] [status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
[status-im.utils.build :as build] [status-im.utils.build :as build]
[status-im.utils.config :as config] [status-im.utils.config :as config]
[status-im.utils.currency :as currency]
[status-im.utils.datetime :as datetime] [status-im.utils.datetime :as datetime]
[status-im.utils.gfycat.core :as gfycat] [status-im.utils.gfycat.core :as gfycat]
[status-im.utils.mobile-sync :as mobile-network-utils]
[status-im.utils.money :as money] [status-im.utils.money :as money]
[status-im.utils.security :as security] [status-im.utils.security :as security]
[status-im.wallet.db :as wallet.db] [status-im.wallet.db :as wallet.db]
[status-im.wallet.utils :as wallet.utils] [status-im.wallet.utils :as wallet.utils]))
status-im.ui.screens.keycard.subs
[status-im.chat.models.mentions :as mentions]
[status-im.notifications.core :as notifications]
[status-im.utils.currency :as currency]
[clojure.set :as clojure.set]
[quo.design-system.colors :as colors]
[status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]))
;; TOP LEVEL =========================================================================================================== ;; TOP LEVEL ===========================================================================================================
@ -267,10 +267,8 @@
(reg-root-key-sub :wallet-connect/session-managed :wallet-connect/session-managed) (reg-root-key-sub :wallet-connect/session-managed :wallet-connect/session-managed)
(reg-root-key-sub :contact-requests/pending :contact-requests/pending) (reg-root-key-sub :contact-requests/pending :contact-requests/pending)
; Testing ; Testing
(reg-root-key-sub :messenger/started? :messenger/started?) (reg-root-key-sub :messenger/started? :messenger/started?)
(reg-root-key-sub :information-box-states :information-box-states) (reg-root-key-sub :information-box-states :information-box-states)
@ -874,7 +872,7 @@
(fn [chats [_ community-id]] (fn [chats [_ community-id]]
(->> chats (->> chats
(keep (fn [[_ chat]] (keep (fn [[_ chat]]
(when (and (= (:community-id chat) community-id)) (when (= (:community-id chat) community-id)
chat))) chat)))
(sort-by :timestamp >)))) (sort-by :timestamp >))))
@ -3004,7 +3002,6 @@
;; NAVIGATION2 ;; NAVIGATION2
(re-frame/reg-sub (re-frame/reg-sub
:navigation2/switcher-cards :navigation2/switcher-cards
:<- [:navigation2/navigation2-stacks] :<- [:navigation2/navigation2-stacks]

View File

@ -1,9 +1,8 @@
(ns status-im.switcher.switcher-container (ns status-im.switcher.switcher-container
(:require [quo.react-native :as rn] (:require [quo.react-native :as rn]
status-im.switcher.cards.messaging-card [status-im.switcher.cards.messaging-card :as messaging-card]
[status-im.switcher.styles :as styles] [status-im.switcher.styles :as styles]
[status-im.utils.handlers :refer [<sub]] [status-im.utils.handlers :refer [<sub]]))
[status-im.switcher.cards.messaging-card :as messaging-card]))
;; TODO - use something like this to avoid multiple renders etc. ;; TODO - use something like this to avoid multiple renders etc.
;; (defn switch-screen [toggle-switcher-screen] ;; (defn switch-screen [toggle-switcher-screen]

View File

@ -1,8 +1,8 @@
(ns status-im.ui.screens.chat.message.link-preview (ns status-im.ui.screens.chat.message.link-preview
(:require [re-frame.core :as re-frame] (:require [clojure.string :as string]
[clojure.string :as string]
[status-im.ui.components.react :as react]
[quo.core :as quo] [quo.core :as quo]
[re-frame.core :as re-frame]
[status-im.ui.components.react :as react]
[status-im.utils.security :as security] [status-im.utils.security :as security]
[status-im.i18n.i18n :as i18n] [status-im.i18n.i18n :as i18n]
[status-im.ui.screens.chat.message.styles :as styles] [status-im.ui.screens.chat.message.styles :as styles]
@ -82,7 +82,7 @@
(when-not error (when-not error
[react/touchable-highlight [react/touchable-highlight
{:style (when-not (is-gif? thumbnailUrl) {:align-self :stretch}) {:style (when-not (is-gif? thumbnailUrl) {:align-self :stretch})
:on-press #(when (and (security/safe-link? link)) :on-press #(when (security/safe-link? link)
(re-frame/dispatch (re-frame/dispatch
[:browser.ui/message-link-pressed link]))} [:browser.ui/message-link-pressed link]))}
[react/view (styles/link-preview-wrapper outgoing timeline) [react/view (styles/link-preview-wrapper outgoing timeline)

View File

@ -1,6 +1,6 @@
(ns status-im.utils.money (ns status-im.utils.money
(:require [clojure.string :as string] (:require ["bignumber.js" :as BigNumber]
["bignumber.js" :as BigNumber])) [clojure.string :as string]))
;; The BigNumber version included in web3 sometimes hangs when dividing large ;; The BigNumber version included in web3 sometimes hangs when dividing large
;; numbers Hence we want to use these functions instead of fromWei etc, which ;; numbers Hence we want to use these functions instead of fromWei etc, which

View File

@ -9,15 +9,16 @@
(deftype PersistentPriorityMap [priority->set-of-items item->priority meta keyfn ^:mutable __hash] (deftype PersistentPriorityMap [priority->set-of-items item->priority meta keyfn ^:mutable __hash]
IPrintWithWriter IPrintWithWriter
(-pr-writer [coll writer opts] (-pr-writer [coll writer opts]
(let [pr-pair (fn [keyval] (pr-sequential-writer writer pr-writer "" " " "" opts keyval))] (let [pr-pair (fn [keyval]
(pr-sequential-writer writer #'cljs.core/pr-writer "" " " "" opts keyval))]
(pr-sequential-writer writer pr-pair "#status-im.utils.priority-map {" ", " "}" opts coll))) (pr-sequential-writer writer pr-pair "#status-im.utils.priority-map {" ", " "}" opts coll)))
IWithMeta IWithMeta
(-with-meta [this meta] (-with-meta [_this meta]
(PersistentPriorityMap. priority->set-of-items item->priority meta keyfn __hash)) (PersistentPriorityMap. priority->set-of-items item->priority meta keyfn __hash))
IMeta IMeta
(-meta [this] meta) (-meta [_this] meta)
ICollection ICollection
(-conj [this entry] (-conj [this entry]
@ -26,12 +27,13 @@
(reduce -conj this entry))) (reduce -conj this entry)))
IEmptyableCollection IEmptyableCollection
(-empty [this] (with-meta (-empty [_this] #_{:clj-kondo/ignore [:unresolved-symbol]}
(with-meta
status-im.utils.priority-map.PersistentPriorityMap.EMPTY status-im.utils.priority-map.PersistentPriorityMap.EMPTY
meta)) meta))
IEquiv IEquiv
(-equiv [this other] (-equiv [_this other]
(-equiv item->priority other)) (-equiv item->priority other))
IHash IHash
@ -39,7 +41,7 @@
(coreclj/caching-hash this core/hash-unordered-coll __hash)) (coreclj/caching-hash this core/hash-unordered-coll __hash))
ISeqable ISeqable
(-seq [this] (-seq [_this]
(if keyfn (if keyfn
(seq (for [[_ item-set] priority->set-of-items, item item-set] (seq (for [[_ item-set] priority->set-of-items, item item-set]
(MapEntry. item (item->priority item) nil))) (MapEntry. item (item->priority item) nil)))
@ -47,7 +49,7 @@
(MapEntry. item priority nil))))) (MapEntry. item priority nil)))))
IReversible IReversible
(-rseq [coll] (-rseq [_coll]
(if keyfn (if keyfn
(seq (for [[_ item-set] (rseq priority->set-of-items), item item-set] (seq (for [[_ item-set] (rseq priority->set-of-items), item item-set]
(MapEntry. item (item->priority item) nil))) (MapEntry. item (item->priority item) nil)))
@ -55,24 +57,24 @@
(MapEntry. item priority nil))))) (MapEntry. item priority nil)))))
ICounted ICounted
(-count [this] (-count [_this]
(count item->priority)) (count item->priority))
ILookup ILookup
(-lookup [this item] (-lookup [_this item]
(get item->priority item)) (get item->priority item))
(-lookup [coll item not-found] (-lookup [_coll item not-found]
(get item->priority item not-found)) (get item->priority item not-found))
IStack IStack
(-peek [this] (-peek [_this]
(when-not (zero? (count item->priority)) (when-not (zero? (count item->priority))
(let [f (first priority->set-of-items) (let [f (first priority->set-of-items)
item (first (val f))] item (first (val f))]
(if keyfn (if keyfn
[item (item->priority item)] [item (item->priority item)]
[item (key f)])))) [item (key f)]))))
(-pop [this] (-pop [_this]
(if (zero? (count item->priority)) (if (zero? (count item->priority))
(throw (js/Error. "Can't pop empty priority map")) (throw (js/Error. "Can't pop empty priority map"))
(let [f (first priority->set-of-items) (let [f (first priority->set-of-items)
@ -126,7 +128,7 @@
keyfn keyfn
nil)))) nil))))
(-contains-key? [this item] (-contains-key? [_this item]
(contains? item->priority item)) (contains? item->priority item))
IMap IMap
@ -153,7 +155,7 @@
ISorted ISorted
(-sorted-seq [this ascending?] (-sorted-seq [this ascending?]
((if ascending? seq rseq) this)) ((if ascending? seq rseq) this))
(-sorted-seq-from [this k ascending?] (-sorted-seq-from [_this k ascending?]
(let [sets (if ascending? (let [sets (if ascending?
(subseq priority->set-of-items >= k) (subseq priority->set-of-items >= k)
(rsubseq priority->set-of-items <= k))] (rsubseq priority->set-of-items <= k))]
@ -162,9 +164,9 @@
[item (item->priority item)])) [item (item->priority item)]))
(seq (for [[priority item-set] sets, item item-set] (seq (for [[priority item-set] sets, item item-set]
[item priority]))))) [item priority])))))
(-entry-key [this entry] (-entry-key [_this entry]
(keyfn (val entry))) (keyfn (val entry)))
(-comparator [this] compare) (-comparator [_this] compare)
IFn IFn
(-invoke [this item] (-invoke [this item]
@ -172,6 +174,7 @@
(-invoke [this item not-found] (-invoke [this item not-found]
(-lookup this item not-found))) (-lookup this item not-found)))
#_{:clj-kondo/ignore [:unresolved-symbol]}
(set! status-im.utils.priority-map.PersistentPriorityMap.EMPTY (set! status-im.utils.priority-map.PersistentPriorityMap.EMPTY
(PersistentPriorityMap. (sorted-map) {} {} identity nil)) (PersistentPriorityMap. (sorted-map) {} {} identity nil))
@ -193,6 +196,7 @@
"keyval => key val "keyval => key val
Returns a new priority map with supplied mappings." Returns a new priority map with supplied mappings."
([& keyvals] ([& keyvals]
#_{:clj-kondo/ignore [:unresolved-symbol]}
(loop [in (seq keyvals) out status-im.utils.priority-map.PersistentPriorityMap.EMPTY] (loop [in (seq keyvals) out status-im.utils.priority-map.PersistentPriorityMap.EMPTY]
(if in (if in
(recur (nnext in) (assoc out (first in) (second in))) (recur (nnext in) (assoc out (first in) (second in)))

View File

@ -1,11 +1,11 @@
(ns status-im.utils.signing-phrase.core-test (ns status-im.utils.signing-phrase.core-test
(:require [cljs.test :refer-macros [deftest is]] (:require [cljs.test :refer-macros [deftest is]]
[status-im.utils.signing-phrase.core :refer [generate]] [clojure.string :as string]
[clojure.string :as string])) [status-im.utils.signing-phrase.core :refer [generate]]))
(deftest test-generate (deftest test-generate
(doseq [_ (range 30)] (doseq [_ (range 30)]
(let [result (generate)] (let [result (generate)]
(is (not (string/starts-with? result " "))) (is (not (string/starts-with? result " ")))
(is (not (string/ends-with? result " "))) (is (not (string/ends-with? result " ")))
(is (= (get (frequencies result) " ")) 2)))) (is (= (get (frequencies result) " ") 2)))))