Skip to content

Commit

Permalink
🎄 🧹 New Year cleanup (#21868)
Browse files Browse the repository at this point in the history
* big cleannup: warnings fixed, unused code removed
  • Loading branch information
vkjr authored Jan 6, 2025
1 parent 826410b commit 28a81f2
Show file tree
Hide file tree
Showing 285 changed files with 255 additions and 7,600 deletions.
185 changes: 0 additions & 185 deletions .carve_ignore

This file was deleted.

31 changes: 28 additions & 3 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
legacy.status-im.utils.views/letsubs clojure.core/let
reagent.core/with-let clojure.core/let
legacy.status-im.utils.fx/defn clj-kondo.lint-as/def-catch-all
utils.re-frame/defn clj-kondo.lint-as/def-catch-all
utils.re-frame/defn clojure.core/defn
quo.react/with-deps-check clojure.core/fn
quo.previews.preview/list-comp clojure.core/for
legacy.status-im.utils.styles/def clojure.core/def
Expand All @@ -13,7 +13,29 @@
test-helpers.unit/deftest-event clojure.core/defn

taoensso.tufte/defnp clojure.core/defn}
:linters {:case-duplicate-test {:level :error}
:linters {:clojure-lsp/unused-public-var {:exclude-when-defined-by #{utils.re-frame/defn}
:exclude #{
;; even if we are not
;; using color now, we
;; will need it later
quo.foundations.colors

;; same for funcs from
;; native-module
native-module.core

;; some funcs used
;; temporarily during
;; development
test-helpers.component
test-helpers.unit

;; not sure if unused
;; functions here should
;; be removed:
keycard.keycard
react-native.fs}}
:case-duplicate-test {:level :error}
:case-quoted-test {:level :error}
:case-symbol-test {:level :error}
:clj-kondo-config {:level :error}
Expand All @@ -40,7 +62,8 @@
:equals-true {:level :error}
:inline-def {:level :error}
:invalid-arity {:skip-args [legacy.status-im.utils.fx/defn
utils.re-frame/defn]}
utils.re-frame/defn
utils.re-frame/merge]}
:loop-without-recur {:level :error}
:minus-one {:level :error}
:misplaced-docstring {:level :error}
Expand All @@ -53,6 +76,8 @@
:redundant-do {:level :error}
:redundant-let {:level :error}
:refer-all {:level :error}
;; ignore error in config itself saying that `:shadowed-fn-param` is unknown
#_{:clj-kondo/ignore [:clj-kondo-config]}
:shadowed-fn-param {:level :error}
:shadowed-var {:level :error
;; We temporarily use :include to define an
Expand Down
62 changes: 7 additions & 55 deletions src/legacy/status_im/browser/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
[status-im.constants :as constants]
[status-im.contexts.chat.events :as chat.events]
[status-im.navigation.events :as navigation]
[taoensso.timbre :as log]
[utils.address :as address]
[utils.debounce :as debounce]
[utils.ens.core :as utils.ens]
[utils.ethereum.chain :as chain]
Expand Down Expand Up @@ -139,13 +137,11 @@
{:events [:browser/delete-bookmark]}
[{:keys [db] :as cofx}
url]
(let [old-bookmark (get-in db [:bookmarks/bookmarks url])
removed-bookmark (merge old-bookmark {:removed true})]
(rf/merge cofx
{:db (update db :bookmarks/bookmarks dissoc url)
:json-rpc/call [{:method "wakuext_removeBookmark"
:params [url]
:on-success #()}]})))
(rf/merge cofx
{:db (update db :bookmarks/bookmarks dissoc url)
:json-rpc/call [{:method "wakuext_removeBookmark"
:params [url]
:on-success #()}]}))

(defn can-go-back?
[{:keys [history-index]}]
Expand Down Expand Up @@ -357,43 +353,11 @@
:id (int id)
:result result}}})

(defn utf8-to-hex
[s]
(let [hex (native-module/utf8-to-hex (str s))]
(if (empty? hex)
nil
hex)))

(defn normalize-message
"NOTE (andrey) there is no spec for this, so this implementation just to be compatible with MM"
[message]
(if (string/starts-with? message "0x")
message
(utf8-to-hex message)))

(defn normalize-sign-message-params
"NOTE (andrey) we need this function, because params may be mixed up"
[params typed?]
(let [[first-param second-param] params]
(when (and (string? first-param) (string? second-param))
(cond
(address/address? first-param)
[first-param (if typed? second-param (normalize-message second-param))]
(address/address? second-param)
[second-param (if typed? first-param (normalize-message first-param))]))))

(rf/defn send-to-bridge
{:events [:browser.callback/call-rpc]}
[_ message]
{:browser/send-to-bridge message})

(defn web3-sign-message?
[method]
(#{constants/web3-sign-typed-data constants/web3-sign-typed-data-v3 constants/web3-sign-typed-data-v4
constants/web3-personal-sign
constants/web3-eth-sign constants/web3-keycard-sign-typed-data}
method))

(rf/defn handle-no-permissions
[cofx {:keys [method id]} message-id]
(if (= method "eth_accounts")
Expand Down Expand Up @@ -484,18 +448,6 @@
(when (and message webview)
(.injectJavaScript webview msg)))))

(re-frame/reg-fx
:browser/call-rpc
(fn [[payload callback]]
(native-module/call-rpc
(types/clj->json payload)
(fn [response]
(if (= "" response)
(do
(log/warn :web3-response-error)
(callback "web3-response-error" nil))
(callback nil (.parse js/JSON response)))))))

(re-frame/reg-fx
:browser/show-browser-selection
(fn [link]
Expand Down Expand Up @@ -548,8 +500,8 @@

(rf/defn lock-pressed
{:events [:browser.ui/lock-pressed]}
[cofx secure?]
(update-browser-option cofx :show-tooltip (if secure? :secure :not-secure)))
[cofx is-secure?]
(update-browser-option cofx :show-tooltip (if is-secure? :secure :not-secure)))

(rf/defn close-tooltip-pressed
{:events [:browser.ui/close-tooltip-pressed]}
Expand Down
Loading

0 comments on commit 28a81f2

Please sign in to comment.