WIP: debugging

This commit is contained in:
Ulises M 2024-10-29 14:01:21 -06:00
parent e9b8118c0d
commit 9fbf140da0
No known key found for this signature in database
GPG Key ID: 5A15782EB758534E
10 changed files with 51 additions and 33 deletions

View File

@ -88,6 +88,15 @@
{:chainId :chain-id
:removed :removed?})
name-details)]
(let [new-db (reduce (fn [db {:keys [username removed? chain-id] :as name-detail}]
(if removed?
(update-in db [:ens/names chain-id] dissoc username)
(let [old (get-in db [:ens/names chain-id username])]
(assoc-in db [:ens/names chain-id username] (merge old name-detail)))))
db
name-details)]
(prn "new db" new-db)
)
{:db (reduce (fn [db {:keys [username removed? chain-id] :as name-detail}]
(if removed?
(update-in db [:ens/names chain-id] dissoc username)

View File

@ -37,10 +37,8 @@
(defn ui-helper
[]
(if false
(when (exists? (.-NativeModules react-native))
(.-UIHelper ^js (.-NativeModules react-native)))
status-backend/fetch-js-obj))
(when (exists? (.-NativeModules react-native))
(.-UIHelper ^js (.-NativeModules react-native))))
(defn log-manager
[]
@ -208,9 +206,7 @@
(defn call-private-rpc
[payload callback]
(if false
(.callPrivateRPC ^js (network) payload callback)
(status-backend/call-private-rpc payload callback)))
(.callPrivateRPC ^js (network) payload callback))
(defn hash-transaction
"used for keycard"
@ -362,7 +358,9 @@
(log/debug "[native-module] set-blank-preview-flag")
;; Sometimes the app crashes during logout because `flag` is nil.
(when-not (nil? flag)
(.setBlankPreviewFlag ^js (encryption) flag)))
(.setBlankPreviewFlag ^js (when (exists? (.-NativeModules react-native))
(.-EncryptionUtils ^js (.-NativeModules react-native)))
flag)))
(defn get-device-model-info
[]
@ -441,10 +439,11 @@
(defn sha3
[s]
(log/debug "[native-module] sha3")
(let [temp-encryption (when (exists? (.-NativeModules react-native))
(.-EncryptionUtils ^js (.-NativeModules react-native)))]
(when s
(.sha3 ^js temp-encryption (str s)))))
(time
(let [temp-encryption (when (exists? (.-NativeModules react-native))
(.-EncryptionUtils ^js (.-NativeModules react-native)))]
(when s
(.sha3 ^js temp-encryption (str s))))))
(defn utf8-to-hex
[s]
@ -481,7 +480,9 @@
(defn to-checksum-address
[address]
(log/debug "[native-module] to-checksum-address")
(.toChecksumAddress ^js (utils) address))
(.toChecksumAddress ^js (when (exists? (.-NativeModules react-native))
(.-Utils ^js (.-NativeModules react-native)))
address))
(defn validate-mnemonic
"Validate that a mnemonic conforms to BIP39 dictionary/checksum standards"

View File

@ -17,8 +17,8 @@
"Content-Type" "application/json"}})
;; This dir musts exist before running the app
(def data-dir-path "/home/ulises/p/status-go/test-db")
(def data-dir-path "/home/ulises/p/status-go/1_test-db")
(def keystore-dir-path (str data-dir-path "/keystore"))
(def log-dir-path (str data-dir-path "/log"))
(def log-request-file-path (str data-dir-path "/request.log"))
(def keystore-dir-path "/home/ulises/p/status-go/1_test-db/1_keystore")
(def log-dir-path "/home/ulises/p/status-go/requests.log")
(def log-request-file-path (str data-dir-path "/requests.log"))

View File

@ -8,10 +8,13 @@
(defn fetch
([endpoint]
(println (str ".......................... 1-----: " endpoint))
(fetch endpoint nil (fn [])))
([endpoint body-params]
(println (str ".......................... 2-----: " endpoint))
(fetch endpoint body-params (fn [])))
([endpoint body-params callback]
(println (str "========================== > INVOKE: " endpoint "::" (prn-str body-params)))
(let [url (str config/status-go-url endpoint)
params (assoc config/fetch-default-params :body body-params)]
(network/fetch url params callback))))
@ -36,15 +39,18 @@
(defn init-web-socket [on-message]
(defonce web-socket (js/WebSocket. config/signals-url))
(oops/oset! web-socket "onopen" #(log/debug "[backend] Web Socket connected"))
(oops/oset! web-socket "onmessage" #(-> % (oops/oget "data") (on-message)))
(oops/oset! web-socket "onmessage" (fn [e]
(println " NEW WEBSOCKET MESSAGE! -- START")
(-> e (oops/oget "data") (on-message))
(println " NEW WEBSOCKET MESSAGE! -- END")))
(oops/oset! web-socket "onerror" #(log/error "[backend] Web Socket error" %))
(oops/oset! web-socket "onclose" #(log/error "[backend] Web Socket closed" %)))
(defn call-private-rpc [payload callback]
;; NOTE: according to the status-backend readme, we call RPCs using the `CallRPC`
;; endpoint, instead of using `CallPrivateRPC` as in mobile.
(fetch "CallRPC" payload callback))
;(defn call-private-rpc [payload callback]
; ;; NOTE: according to the status-backend readme, we call RPCs using the `CallRPC`
; ;; endpoint, instead of using `CallPrivateRPC` as in mobile.
; (fetch "CallRPC" payload callback))
(comment ;; Useful REPL commands (will be removed)

View File

@ -25,14 +25,15 @@
(rf/defn process
{:events [:signals/signal-received]}
[{:keys [db] :as cofx} event-str]
(println (str "<<<<<<<<<<<<<<<<<<<<<<<<<< SIGNAL: " (prn-str event-str)))
;; We only convert to clojure when strictly necessary or we know it
;; won't impact performance, as it is a fairly costly operation on large-ish
;; data structures
(let [^js data (.parse js/JSON event-str)
^js event-js (.-event data)
type (.-type data)]
;(log/debug "Signal received" {:type type})
;(log/trace "Signal received" {:payload event-str})
(log/debug "Signal received" {:type type})
(log/trace "Signal received" {:payload event-str})
(case type
"wallet"
{:fx [[:dispatch [:wallet/signal-received event-js]]]}
@ -108,6 +109,4 @@
"backup.performed"
{:db (assoc-in db [:profile/profile :last-backup] (oops/oget event-js :lastBackup))}
(do
#_(log/debug "Event " type " not handled")
nil))))
(log/debug "Event " type " not handled"))))

View File

@ -87,7 +87,7 @@
:screen/onboarding.new-to-status)]]]
(when-not syncing-account-recovered?
[:dispatch [:syncing/clear-syncing-installation-id]])]
:dispatch-later [{:ms constants/onboarding-generating-keys-animation-duration-ms
:dispatch-later [#_{:ms constants/onboarding-generating-keys-animation-duration-ms
:dispatch [:navigate-to-within-stack
[:screen/onboarding.enable-notifications
loading-screen]]}]

View File

@ -65,7 +65,7 @@
(defn title
[]
(let [generate-keys-opacity (reanimated/use-shared-value 1)
#_(let [generate-keys-opacity (reanimated/use-shared-value 1)
saving-keys-opacity (reanimated/use-shared-value 0)
keys-saved-opacity (reanimated/use-shared-value 0)]
(sequence-animation generate-keys-opacity saving-keys-opacity keys-saved-opacity)
@ -86,7 +86,8 @@
{:style (reanimated/apply-animations-to-style
{:opacity keys-saved-opacity}
style/title-style)}
[keys-saved-title]]]))
[keys-saved-title]]])
)
(defn content
[]

View File

@ -156,7 +156,9 @@
{:db (update db :profile/login #(-> % (dissoc :processing) (assoc :error error)))}
{:db (dissoc db :profile/login)
:fx [(when (and new-account? (not recovered-account?))
[:dispatch-later [{:ms 1000 :dispatch [:wallet-legacy/set-initial-blocks-range]}]])
;; INVALID EVENT:
;[:dispatch-later [{:ms 1000 :dispatch [:wallet-legacy/set-initial-blocks-range]}]]
)
[:dispatch-later [{:ms 2000 :dispatch [:ens/update-usernames ensUsernames]}]]
[:dispatch [:profile.login/login-existing-profile settings account]]]})))

View File

@ -89,7 +89,7 @@
;; RN to dispatch the network status update, otherwise when going
;; offline the user will immediately see a toast saying "provider
;; X is down".
[{:ms 500
[{:ms 50000
:dispatch [:wallet/blockchain-status-changed
(transforms/js->clj event-js)]}]]]}

View File

@ -22,7 +22,7 @@
(reset! handler-nesting-level 0))
(when rf.interop/debug-enabled?
(do
#_(log/debug "Handling re-frame event: "
(log/debug "Handling re-frame event: "
(first (interceptor/get-coeffect context :event)))
nil))
context)))