mirror of
https://github.com/status-im/status-react.git
synced 2025-03-03 12:01:05 +00:00
removed check spec, and moved db, events and navigation from ui to root folder
This commit is contained in:
parent
d3860508ca
commit
d91067bb96
1
.gitignore
vendored
1
.gitignore
vendored
@ -191,3 +191,4 @@ status-modules/resources
|
||||
trace.edn
|
||||
|
||||
app
|
||||
project.clj
|
||||
|
@ -4,7 +4,7 @@
|
||||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[status-im.i18n :as i18n]
|
||||
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]))
|
||||
|
||||
(def address-regex #"enode://[a-zA-Z0-9]+:?(.*)\@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b:(\d{1,5})")
|
||||
|
@ -10,7 +10,7 @@
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ui.components.list-selection :as list-selection]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.contenthash :as contenthash]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.http :as http]
|
||||
|
@ -1,54 +0,0 @@
|
||||
(ns status-im.browser.db
|
||||
(:require [cljs.spec.alpha :as spec]))
|
||||
|
||||
(spec/def :browser/browser-id (spec/nilable string?))
|
||||
(spec/def :browser/timestamp (spec/nilable int?))
|
||||
(spec/def :browser/name (spec/nilable string?))
|
||||
(spec/def :browser/url (spec/nilable string?))
|
||||
(spec/def :browser/dapp? (spec/nilable boolean?))
|
||||
(spec/def :browser/error? (spec/nilable boolean?))
|
||||
(spec/def :browser/history (spec/nilable vector?))
|
||||
(spec/def :browser/history-index (spec/nilable int?))
|
||||
(spec/def :browser/unsafe? (spec/nilable boolean?))
|
||||
(spec/def :browser/loading? (spec/nilable boolean?))
|
||||
(spec/def :browser/resolving? (spec/nilable boolean?))
|
||||
(spec/def :browser/url-editing? (spec/nilable boolean?))
|
||||
(spec/def :browser/show-tooltip (spec/nilable keyword?))
|
||||
(spec/def :browser/show-permission (spec/nilable map?))
|
||||
(spec/def :browser/resolved-ens (spec/nilable map?))
|
||||
(spec/def :browser/pending-permissions (spec/nilable list?))
|
||||
(spec/def :browser/yielding-control? (spec/nilable boolean?))
|
||||
|
||||
(spec/def :browser/options
|
||||
(spec/nilable
|
||||
(spec/keys :opt-un [:browser/browser-id
|
||||
:browser/url
|
||||
:browser/loading?
|
||||
:browser/resolving?
|
||||
:browser/url-editing?
|
||||
:browser/show-tooltip
|
||||
:browser/show-permission
|
||||
:browser/pending-permissions
|
||||
:browser/yielding-control?
|
||||
:browser/resolved-ens
|
||||
:browser/error?])))
|
||||
|
||||
(spec/def :browser/browser
|
||||
(spec/keys :req-un [:browser/browser-id
|
||||
:browser/timestamp]
|
||||
:opt-un [:browser/name
|
||||
:browser/dapp?
|
||||
:browser/history
|
||||
:browser/history-index
|
||||
:browser/unsafe?]))
|
||||
|
||||
(spec/def :browser/browsers (spec/nilable (spec/map-of :global/not-empty-string :browser/browser)))
|
||||
|
||||
(spec/def :dapp/dapp (spec/nilable string?))
|
||||
(spec/def :dapp/permissions (spec/nilable vector?))
|
||||
|
||||
(spec/def :dapp/permission-map
|
||||
(spec/keys :req-un [:dapp/dapp]
|
||||
:opt-un [:dapp/permissions]))
|
||||
|
||||
(spec/def :dapps/permissions (spec/nilable (spec/map-of :global/not-empty-string :dapp/permission-map)))
|
@ -3,7 +3,7 @@
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.qr-scanner.core :as qr-scanner]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.browser.webview-ref :as webview-ref]))
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.clocks :as utils.clocks]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.platform :as platform]
|
||||
|
@ -1,24 +0,0 @@
|
||||
(ns status-im.chat.specs
|
||||
(:require [cljs.spec.alpha :as s]))
|
||||
|
||||
(s/def :chat/chats (s/nilable map?)) ; {id (string) chat (map)} active chats on chat's tab
|
||||
(s/def :chat/current-chat-id (s/nilable string?)) ; current or last opened chat-id
|
||||
(s/def :chat/chat-id (s/nilable string?)) ; what is the difference ? ^
|
||||
(s/def :chat/new-chat-name (s/nilable string?)) ; we have name in the new-chat why do we need this field
|
||||
(s/def :chat/animations (s/nilable map?)) ; {id (string) props (map)}
|
||||
(s/def :chat/chat-ui-props (s/nilable map?)) ; {id (string) props (map)}
|
||||
(s/def :chat/chat-list-ui-props (s/nilable map?))
|
||||
(s/def :chat/layout-height (s/nilable number?)) ; height of chat's view layout
|
||||
(s/def :chat/selected-participants (s/nilable set?))
|
||||
(s/def :chat/public-group-topic (s/nilable string?))
|
||||
(s/def :chat/public-group-topic-error (s/nilable string?))
|
||||
(s/def :chat/messages (s/nilable map?)) ; messages indexed by message-id
|
||||
(s/def :chat/last-clock-value (s/nilable number?)) ; last logical clock value of messages in chat
|
||||
(s/def :chat/loaded-chats (s/nilable seq?))
|
||||
(s/def :chat/bot-db (s/nilable map?))
|
||||
(s/def :chat/cooldowns (s/nilable number?)) ; number of cooldowns given for spamming send button
|
||||
(s/def :chat/inputs (s/nilable map?))
|
||||
(s/def :chat/cooldown-enabled? (s/nilable boolean?))
|
||||
(s/def :chat/last-outgoing-message-sent-at (s/nilable number?))
|
||||
(s/def :chat/spam-messages-frequency (s/nilable number?)) ; number of consecutive spam messages sent
|
||||
(s/def :chats/loading? (s/nilable boolean?))
|
@ -9,7 +9,7 @@
|
||||
[status-im.data-store.chats :as chats-store]
|
||||
[status-im.data-store.contacts :as contacts-store]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]))
|
||||
|
||||
(fx/defn remove-current-chat-id
|
||||
|
@ -14,7 +14,7 @@
|
||||
[status-im.transport.message.protocol :as protocol]
|
||||
[status-im.tribute-to-talk.db :as tribute-to-talk]
|
||||
[status-im.tribute-to-talk.whitelist :as whitelist]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.datetime :as time]))
|
||||
|
@ -1,66 +1,10 @@
|
||||
(ns status-im.contact.db
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
[clojure.set :as cset]
|
||||
(:require [clojure.set :as cset]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.tribute-to-talk.db :as tribute-to-talk.db]
|
||||
[status-im.utils.gfycat.core :as gfycat]
|
||||
[status-im.utils.identicon :as identicon]
|
||||
status-im.utils.db))
|
||||
|
||||
;;;; DB
|
||||
|
||||
;;Contact
|
||||
|
||||
(spec/def :contact/last-online (spec/nilable int?))
|
||||
(spec/def :contact/last-updated (spec/nilable int?))
|
||||
(spec/def :contact/name (spec/nilable string?))
|
||||
(spec/def :contact/ens-verified (spec/nilable boolean?))
|
||||
(spec/def :contact/ens-verified-at (spec/nilable int?))
|
||||
(spec/def :contact/public-key :global/not-empty-string)
|
||||
(spec/def :contact/photo-path (spec/nilable string?))
|
||||
|
||||
;; contact/blocked: the user is blocked
|
||||
;; contact/added: the user was added to the contacts and a contact request was sent
|
||||
;; contact/request-received: the user sent a contact request
|
||||
(spec/def :contact/system-tags (spec/coll-of keyword? :kind set?))
|
||||
(spec/def :contact/tags (spec/coll-of string? :kind set?))
|
||||
(spec/def :contact/tribute (spec/nilable int?))
|
||||
(spec/def :contact/tribute-transaction (spec/nilable string?))
|
||||
|
||||
(spec/def :contact/contact (spec/keys :req-un [:contact/public-key
|
||||
:contact/system-tags]
|
||||
:opt-un [:contact/name
|
||||
:contact/address
|
||||
:contact/photo-path
|
||||
:contact/last-online
|
||||
:contact/last-updated
|
||||
:contact/tags
|
||||
:contact/tribute
|
||||
:contact/tribute-transaction]))
|
||||
|
||||
;;Contact list ui props
|
||||
(spec/def :contact-list-ui/edit? boolean?)
|
||||
|
||||
;;Contacts ui props
|
||||
(spec/def :contacts-ui/edit? boolean?)
|
||||
|
||||
(spec/def :contacts/contacts (spec/nilable (spec/map-of :global/not-empty-string :contact/contact)))
|
||||
;;public key of new contact during adding this new contact
|
||||
(spec/def :contacts/new-identity (spec/nilable map?))
|
||||
;;on showing this contact's profile (andrey: better to move into profile ns)
|
||||
(spec/def :contacts/identity (spec/nilable :global/not-empty-string))
|
||||
(spec/def :contacts/list-ui-props (spec/nilable (spec/keys :opt-un [:contact-list-ui/edit?])))
|
||||
(spec/def :contacts/ui-props (spec/nilable (spec/keys :opt-un [:contacts-ui/edit?])))
|
||||
;;used in modal list (for example for wallet)
|
||||
(spec/def :contacts/click-handler (spec/nilable fn?))
|
||||
;;used in modal list (for example for wallet)
|
||||
(spec/def :contacts/click-action (spec/nilable #{:send :request}))
|
||||
;;used in modal list (for example for wallet)
|
||||
(spec/def :contacts/click-params (spec/nilable map?))
|
||||
|
||||
(spec/def :contact/new-tag string?)
|
||||
(spec/def :ui/contact (spec/keys :opt [:contact/new-tag]))
|
||||
|
||||
(defn public-key->new-contact [public-key]
|
||||
(let [alias (gfycat/generate-gfy public-key)]
|
||||
{:alias alias
|
||||
|
@ -6,9 +6,9 @@
|
||||
[status-im.ui.components.react :as react]
|
||||
[reagent.core :as reagent]
|
||||
status-im.utils.db
|
||||
status-im.ui.screens.db
|
||||
status-im.ui.screens.events
|
||||
status-im.db
|
||||
status-im.subs
|
||||
status-im.events
|
||||
["react-native-languages" :default react-native-languages]
|
||||
["react-native-shake" :as react-native-shake]
|
||||
["react-native-screens" :refer (enableScreens)]
|
||||
|
47
src/status_im/db.cljs
Normal file
47
src/status_im/db.cljs
Normal file
@ -0,0 +1,47 @@
|
||||
(ns status-im.db
|
||||
(:require [status-im.utils.dimensions :as dimensions]
|
||||
[status-im.fleet.core :as fleet]
|
||||
[status-im.wallet.db :as wallet.db]))
|
||||
|
||||
;; initial state of app-db
|
||||
(def app-db {:keyboard-height 0
|
||||
:contacts/contacts {}
|
||||
:pairing/installations {}
|
||||
:qr-codes {}
|
||||
:group/selected-contacts #{}
|
||||
:chats {}
|
||||
:current-chat-id nil
|
||||
:selected-participants #{}
|
||||
:sync-state :done
|
||||
:app-state "active"
|
||||
:wallet wallet.db/default-wallet
|
||||
:wallet/all-tokens {}
|
||||
:prices {}
|
||||
:peers-count 0
|
||||
:node-info {}
|
||||
:peers-summary []
|
||||
:my-profile/editing? false
|
||||
:transport/filters {}
|
||||
:transport/message-envelopes {}
|
||||
:mailserver/mailservers (fleet/default-mailservers {})
|
||||
:mailserver/topics {}
|
||||
:mailserver/pending-requests 0
|
||||
:chat/cooldowns 0
|
||||
:chat/inputs {}
|
||||
:chat/cooldown-enabled? false
|
||||
:chat/last-outgoing-message-sent-at 0
|
||||
:chat/spam-messages-frequency 0
|
||||
:tooltips {}
|
||||
:initial-props {}
|
||||
:desktop/desktop {:tab-view-id :home}
|
||||
:dimensions/window (dimensions/window)
|
||||
:registry {}
|
||||
:stickers/packs-owned #{}
|
||||
:stickers/packs-pending #{}
|
||||
:hardwallet {:nfc-enabled? false
|
||||
:pin {:original []
|
||||
:confirmation []
|
||||
:current []
|
||||
:puk []
|
||||
:enter-step :original}}
|
||||
:two-pane-ui-enabled? (dimensions/fit-two-pane?)})
|
@ -2,8 +2,6 @@
|
||||
(:require [reagent.core :as reagent]
|
||||
[re-frame.core :as re-frame]
|
||||
status-im.utils.db
|
||||
status-im.ui.screens.db
|
||||
status-im.ui.screens.events
|
||||
status-im.subs
|
||||
[status-im.ui.screens.views :as views]
|
||||
[status-im.ui.components.react :as react]
|
||||
|
@ -1,12 +1,8 @@
|
||||
(ns status-im.ens.core
|
||||
(:require [clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.ens.db :as ens.db]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.datetime :as datetime]
|
||||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[status-im.multiaccounts.model :as multiaccounts.model]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.ethereum.abi-spec :as abi-spec]
|
||||
[status-im.ethereum.contracts :as contracts]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
@ -14,13 +10,11 @@
|
||||
[status-im.ethereum.ens :as ens]
|
||||
[status-im.ethereum.resolver :as resolver]
|
||||
[status-im.ethereum.stateofus :as stateofus]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.utils.money :as money]
|
||||
[status-im.signing.core :as signing]
|
||||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.random :as random])
|
||||
(:refer-clojure :exclude [name]))
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
(ns status-im.ens.db
|
||||
(:require [cljs.spec.alpha :as spec]))
|
||||
|
||||
(spec/def ::state #{:too-short
|
||||
:already-added
|
||||
:searching
|
||||
:invalid
|
||||
:available
|
||||
:taken
|
||||
:owned
|
||||
:connected
|
||||
:connected-with-different-key})
|
||||
|
||||
(spec/def :ens/registration (spec/keys :opt-un [::state]))
|
@ -9,7 +9,6 @@
|
||||
[status-im.multiaccounts.logout.core :as multiaccounts.logout]
|
||||
[status-im.multiaccounts.recover.core :as multiaccounts.recover]
|
||||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
status-im.multiaccounts.biometric.core
|
||||
[status-im.bootnodes.core :as bootnodes]
|
||||
[status-im.browser.core :as browser]
|
||||
[status-im.browser.permissions :as browser.permissions]
|
||||
@ -54,7 +53,7 @@
|
||||
[status-im.ui.screens.currency-settings.models
|
||||
:as
|
||||
currency-settings.models]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.build :as build]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.utils.fx :as fx]
|
||||
@ -68,7 +67,19 @@
|
||||
[status-im.utils.money :as money]
|
||||
[status-im.chat.models.message-seen :as message-seen]
|
||||
status-im.hardwallet.core
|
||||
status-im.popover.core))
|
||||
status-im.popover.core
|
||||
[status-im.hardwallet.core :as hardwallet]
|
||||
[status-im.utils.dimensions :as dimensions]
|
||||
[status-im.multiaccounts.biometric.core :as biometric]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ui.components.permissions :as permissions]
|
||||
[status-im.utils.http :as http]
|
||||
status-im.ui.screens.add-new.new-chat.events
|
||||
status-im.ui.screens.group.chat-settings.events
|
||||
status-im.ui.screens.group.events
|
||||
status-im.utils.universal-links.events
|
||||
status-im.ui.screens.profile.events))
|
||||
|
||||
;; init module
|
||||
(handlers/register-handler-fx
|
||||
@ -430,12 +441,12 @@
|
||||
(handlers/register-handler-fx
|
||||
:chat.ui/fill-gaps
|
||||
(fn [{:keys [db] :as cofx} [_ gap-ids]]
|
||||
(let [chat-id (:current-chat-id db)
|
||||
topics (mailserver.topics/topics-for-current-chat db)
|
||||
gaps (keep
|
||||
(fn [id]
|
||||
(get-in db [:mailserver/gaps chat-id id]))
|
||||
gap-ids)]
|
||||
(let [chat-id (:current-chat-id db)
|
||||
topics (mailserver.topics/topics-for-current-chat db)
|
||||
gaps (keep
|
||||
(fn [id]
|
||||
(get-in db [:mailserver/gaps chat-id id]))
|
||||
gap-ids)]
|
||||
(mailserver/fill-the-gap
|
||||
cofx
|
||||
{:gaps gaps
|
||||
@ -445,19 +456,19 @@
|
||||
(handlers/register-handler-fx
|
||||
:chat.ui/fetch-more
|
||||
(fn [{:keys [db] :as cofx}]
|
||||
(let [chat-id (:current-chat-id db)
|
||||
(let [chat-id (:current-chat-id db)
|
||||
|
||||
{:keys [lowest-request-from]}
|
||||
(get-in db [:mailserver/ranges chat-id])
|
||||
|
||||
topics (mailserver.topics/topics-for-current-chat db)
|
||||
gaps [{:id :first-gap
|
||||
:to lowest-request-from
|
||||
:from (- lowest-request-from mailserver.constants/one-day)}]]
|
||||
topics (mailserver.topics/topics-for-current-chat db)
|
||||
gaps [{:id :first-gap
|
||||
:to lowest-request-from
|
||||
:from (- lowest-request-from mailserver.constants/one-day)}]]
|
||||
(mailserver/fill-the-gap
|
||||
cofx
|
||||
{:gaps gaps
|
||||
:topics topics
|
||||
:topics topics
|
||||
:chat-id chat-id}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
@ -511,7 +522,7 @@
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:chat.ui/clear-history
|
||||
(fn [cofx [_ chat-id]]
|
||||
(fn [cofx [_ chat-id]]
|
||||
(chat/clear-history cofx chat-id)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
@ -804,10 +815,10 @@
|
||||
(log/error :send-status-message-error err)))
|
||||
|
||||
(fx/defn handle-update [cofx {:keys [chats messages] :as response}]
|
||||
(let [chats (map data-store.chats/<-rpc chats)
|
||||
messages (map data-store.messages/<-rpc messages)
|
||||
(let [chats (map data-store.chats/<-rpc chats)
|
||||
messages (map data-store.messages/<-rpc messages)
|
||||
message-fxs (map chat.message/receive-one messages)
|
||||
chat-fxs (map #(chat/ensure-chat (dissoc % :unviewed-messages-count)) chats)]
|
||||
chat-fxs (map #(chat/ensure-chat (dissoc % :unviewed-messages-count)) chats)]
|
||||
(apply fx/merge cofx (concat chat-fxs message-fxs))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
@ -1019,7 +1030,7 @@
|
||||
(fn [cofx [_ view options]]
|
||||
(bottom-sheet/show-bottom-sheet
|
||||
cofx
|
||||
{:view view
|
||||
{:view view
|
||||
:options options})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
@ -1162,5 +1173,194 @@
|
||||
:system-theme-mode-changed
|
||||
(fn [{:keys [db]} [_ theme]]
|
||||
(let [cur-theme (get-in db [:multiaccount :appearance])]
|
||||
(when (or (nil? cur-theme) (zero? cur-theme))
|
||||
(when (or (nil? cur-theme) (zero? cur-theme))
|
||||
{::multiaccounts/switch-theme (if (= :dark theme) 2 1)}))))
|
||||
|
||||
(defn- http-get [{:keys [url response-validator success-event-creator failure-event-creator timeout-ms]}]
|
||||
(let [on-success #(re-frame/dispatch (success-event-creator %))
|
||||
on-error (when failure-event-creator #(re-frame/dispatch (failure-event-creator %)))
|
||||
opts {:valid-response? response-validator
|
||||
:timeout-ms timeout-ms}]
|
||||
(http/get url on-success on-error opts)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-get
|
||||
http-get)
|
||||
|
||||
(defn- http-raw-get [{:keys [url success-event-creator failure-event-creator timeout-ms]}]
|
||||
(let [on-success #(when-let [event (success-event-creator %)] (re-frame/dispatch event))
|
||||
on-error (when failure-event-creator #(re-frame/dispatch (failure-event-creator %)))
|
||||
opts {:timeout-ms timeout-ms}]
|
||||
(http/raw-get url on-success on-error opts)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-raw-get
|
||||
http-raw-get)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-get-n
|
||||
(fn [calls]
|
||||
(doseq [call calls]
|
||||
(http-get call))))
|
||||
|
||||
(defn- http-post [{:keys [url data response-validator success-event-creator failure-event-creator timeout-ms opts]}]
|
||||
(let [on-success #(re-frame/dispatch (success-event-creator %))
|
||||
on-error (when failure-event-creator #(re-frame/dispatch (failure-event-creator %)))
|
||||
all-opts (assoc opts
|
||||
:valid-response? response-validator
|
||||
:timeout-ms timeout-ms)]
|
||||
(http/post url data on-success on-error all-opts)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-post
|
||||
http-post)
|
||||
|
||||
(defn- http-raw-post [{:keys [url body response-validator success-event-creator failure-event-creator timeout-ms opts]}]
|
||||
(let [on-success #(re-frame/dispatch (success-event-creator %))
|
||||
on-error (when failure-event-creator #(re-frame/dispatch (failure-event-creator %)))
|
||||
all-opts (assoc opts
|
||||
:valid-response? response-validator
|
||||
:timeout-ms timeout-ms)]
|
||||
(http/raw-post url body on-success on-error all-opts)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-raw-post
|
||||
http-raw-post)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:request-permissions-fx
|
||||
(fn [options]
|
||||
(permissions/request-permissions options)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:ui/listen-to-window-dimensions-change
|
||||
(fn []
|
||||
(dimensions/add-event-listener)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:ui/show-error
|
||||
(fn [content]
|
||||
(utils/show-popup "Error" content)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:ui/show-confirmation
|
||||
(fn [options]
|
||||
(utils/show-confirmation options)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:ui/close-application
|
||||
(fn [_]
|
||||
(status/close-application)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::app-state-change-fx
|
||||
(fn [state]
|
||||
(status/app-state-change state)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set
|
||||
(fn [{:keys [db]} [_ k v]]
|
||||
{:db (assoc db k v)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-once
|
||||
(fn [{:keys [db]} [_ k v]]
|
||||
(when-not (get db k)
|
||||
{:db (assoc db k v)})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-in
|
||||
(fn [{:keys [db]} [_ path v]]
|
||||
{:db (assoc-in db path v)}))
|
||||
|
||||
(def authentication-options
|
||||
{:reason (i18n/label :t/biometric-auth-reason-login)})
|
||||
|
||||
(defn- on-biometric-auth-result [{:keys [bioauth-success bioauth-code bioauth-message]}]
|
||||
(when-not bioauth-success
|
||||
(if (= bioauth-code "USER_FALLBACK")
|
||||
(re-frame/dispatch [:multiaccounts.logout.ui/logout-confirmed])
|
||||
(utils/show-confirmation {:title (i18n/label :t/biometric-auth-confirm-title)
|
||||
:content (or bioauth-message (i18n/label :t/biometric-auth-confirm-message))
|
||||
:confirm-button-text (i18n/label :t/biometric-auth-confirm-try-again)
|
||||
:cancel-button-text (i18n/label :t/biometric-auth-confirm-logout)
|
||||
:on-accept #(biometric/authenticate nil on-biometric-auth-result authentication-options)
|
||||
:on-cancel #(re-frame/dispatch [:multiaccounts.logout.ui/logout-confirmed])}))))
|
||||
|
||||
(fx/defn on-return-from-background [{:keys [db now] :as cofx}]
|
||||
(let [app-in-background-since (get db :app-in-background-since)
|
||||
signed-up? (get-in db [:multiaccount :signed-up?])
|
||||
biometric-auth? (= (:auth-method db) "biometric")
|
||||
requires-bio-auth (and
|
||||
signed-up?
|
||||
biometric-auth?
|
||||
(some? app-in-background-since)
|
||||
(>= (- now app-in-background-since)
|
||||
constants/ms-in-bg-for-require-bioauth))]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(dissoc :app-in-background-since)
|
||||
(assoc :app-active-since now))}
|
||||
(mailserver/process-next-messages-request)
|
||||
#(when requires-bio-auth
|
||||
(biometric/authenticate % on-biometric-auth-result authentication-options)))))
|
||||
|
||||
(fx/defn on-going-in-background [{:keys [db now]}]
|
||||
{:db (-> db
|
||||
(dissoc :app-active-since)
|
||||
(assoc :app-in-background-since now))})
|
||||
|
||||
(defn app-state-change [state {:keys [db] :as cofx}]
|
||||
(let [app-coming-from-background? (= state "active")
|
||||
app-going-in-background? (= state "background")]
|
||||
(fx/merge cofx
|
||||
{::app-state-change-fx state
|
||||
:db (assoc db :app-state state)}
|
||||
#(when app-coming-from-background?
|
||||
(on-return-from-background %))
|
||||
#(when app-going-in-background?
|
||||
(on-going-in-background %)))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:app-state-change
|
||||
(fn [cofx [_ state]]
|
||||
(app-state-change state cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:request-permissions
|
||||
(fn [_ [_ options]]
|
||||
{:request-permissions-fx options}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-swipe-position
|
||||
(fn [{:keys [db]} [_ type item-id value]]
|
||||
{:db (assoc-in db [:animations type item-id :delete-swiped] value)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:update-window-dimensions
|
||||
(fn [{:keys [db]} [_ dimensions]]
|
||||
{:db (assoc db :dimensions/window (dimensions/window dimensions))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-two-pane-ui-enabled
|
||||
(fn [{:keys [db]} [_ enabled?]]
|
||||
{:db (assoc db :two-pane-ui-enabled? enabled?)}))
|
||||
|
||||
;; NOTE: Will be removed with the keycard PR
|
||||
(handlers/register-handler-fx
|
||||
:screens/on-will-focus
|
||||
(fn [{:keys [db] :as cofx} [_ view-id]]
|
||||
(fx/merge cofx
|
||||
#(case view-id
|
||||
:keycard-settings (hardwallet/settings-screen-did-load %)
|
||||
:reset-card (hardwallet/reset-card-screen-did-load %)
|
||||
:enter-pin-settings (hardwallet/enter-pin-screen-did-load %)
|
||||
:keycard-login-pin (hardwallet/enter-pin-screen-did-load %)
|
||||
:add-new-account-pin (hardwallet/enter-pin-screen-did-load %)
|
||||
:hardwallet-authentication-method (hardwallet/authentication-method-screen-did-load %)
|
||||
;; We need this as if you click on universal-links you transition
|
||||
;; from chat to chat, and therefore we won't be loading new
|
||||
;; messages
|
||||
:chat (chat.loading/load-messages %)
|
||||
:multiaccounts (hardwallet/multiaccounts-screen-did-load %)
|
||||
nil))))
|
||||
|
@ -8,7 +8,7 @@
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.chat.models.message-content :as message-content]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.data-store.chats :as data-store.chats]
|
||||
[status-im.data-store.messages :as data-store.messages]
|
||||
[status-im.multiaccounts.core :as multiaccounts]
|
||||
|
@ -1,6 +1,6 @@
|
||||
(ns status-im.hardwallet.change-pin
|
||||
(:require [status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.hardwallet.onboarding :as onboarding]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
|
@ -4,7 +4,7 @@
|
||||
[status-im.ui.screens.keycard.keycard-interaction :as keycard-sheet]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.platform :as platform]
|
||||
|
@ -1,7 +1,7 @@
|
||||
(ns status-im.hardwallet.core
|
||||
(:require [status-im.multiaccounts.create.core :as multiaccounts.create]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.datetime :as utils.datetime]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.hardwallet.login :as login]
|
||||
@ -47,7 +47,7 @@
|
||||
:import-multiaccount []
|
||||
:current []}))}
|
||||
(common/listen-to-hardware-back-button)
|
||||
(navigation/navigate-replace-cofx :keycard-recovery-pin nil)))
|
||||
(navigation/navigate-replace :keycard-recovery-pin nil)))
|
||||
|
||||
(fx/defn proceed-setup-with-initialized-card
|
||||
[{:keys [db] :as cofx} flow instance-uid]
|
||||
|
@ -1,7 +1,7 @@
|
||||
(ns status-im.hardwallet.delete-key
|
||||
(:require [status-im.multiaccounts.logout.core :as multiaccounts.logout]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]))
|
||||
|
@ -1,6 +1,6 @@
|
||||
(ns status-im.hardwallet.login
|
||||
(:require [status-im.ethereum.core :as ethereum]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.types :as types]
|
||||
[taoensso.timbre :as log]
|
||||
|
@ -1,5 +1,5 @@
|
||||
(ns status-im.hardwallet.mnemonic
|
||||
(:require [status-im.ui.screens.navigation :as navigation]
|
||||
(:require [status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]
|
||||
@ -21,7 +21,7 @@
|
||||
(assoc-in [:hardwallet :setup-step] :recovery-phrase)
|
||||
(assoc-in [:hardwallet :secrets :mnemonic] mnemonic))}
|
||||
(common/clear-on-card-connected)
|
||||
(navigation/navigate-replace-cofx :keycard-onboarding-recovery-phrase nil))))
|
||||
(navigation/navigate-replace :keycard-onboarding-recovery-phrase nil))))
|
||||
|
||||
(fx/defn load-loading-keys-screen
|
||||
{:events [:hardwallet.ui/recovery-phrase-confirm-pressed
|
||||
|
@ -2,7 +2,7 @@
|
||||
(:require [clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.hardwallet.common :as common]
|
||||
[status-im.hardwallet.mnemonic :as mnemonic]
|
||||
@ -158,7 +158,7 @@
|
||||
(if (= (:view-id db) :keycard-onboarding-recovery-phrase-confirm-word1)
|
||||
(fx/merge cofx
|
||||
(recovery-phrase-next-word)
|
||||
(navigation/navigate-replace-cofx :keycard-onboarding-recovery-phrase-confirm-word2 nil))
|
||||
(navigation/navigate-replace :keycard-onboarding-recovery-phrase-confirm-word2 nil))
|
||||
(proceed-with-generating-key cofx))
|
||||
{:db (assoc-in db [:hardwallet :recovery-phrase :confirm-error] (i18n/label :t/wrong-word))})))
|
||||
|
||||
@ -237,7 +237,7 @@
|
||||
(update-in [:hardwallet :secrets] merge secrets'))}
|
||||
(common/hide-connection-sheet)
|
||||
(common/listen-to-hardware-back-button)
|
||||
(navigation/navigate-replace-cofx :keycard-onboarding-puk-code nil))))
|
||||
(navigation/navigate-replace :keycard-onboarding-puk-code nil))))
|
||||
|
||||
(fx/defn on-install-applet-and-init-card-error
|
||||
{:events [:hardwallet.callback/on-install-applet-and-init-card-error
|
||||
|
@ -1,5 +1,5 @@
|
||||
(ns status-im.hardwallet.recovery
|
||||
(:require [status-im.ui.screens.navigation :as navigation]
|
||||
(:require [status-im.navigation :as navigation]
|
||||
[status-im.utils.datetime :as utils.datetime]
|
||||
[status-im.multiaccounts.create.core :as multiaccounts.create]
|
||||
[status-im.utils.fx :as fx]
|
||||
@ -186,7 +186,7 @@
|
||||
encryption-public-key
|
||||
{})
|
||||
(if (= flow :import)
|
||||
(navigation/navigate-replace-cofx :keycard-recovery-success nil)
|
||||
(navigation/navigate-replace :keycard-recovery-success nil)
|
||||
(navigation/navigate-to-cofx :welcome nil))))))
|
||||
|
||||
(fx/defn on-generate-and-load-key-success
|
||||
|
@ -3,7 +3,7 @@
|
||||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[status-im.multiaccounts.logout.core :as multiaccounts.logout]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]))
|
||||
|
@ -6,7 +6,7 @@
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.network.net-info :as network]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.screens.db :refer [app-db]]
|
||||
[status-im.db :refer [app-db]]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.platform :as platform]
|
||||
[status-im.utils.theme :as theme]))
|
||||
|
@ -16,7 +16,7 @@
|
||||
[status-im.ui.screens.mobile-network-settings.utils
|
||||
:as
|
||||
mobile-network-utils]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
|
@ -147,7 +147,7 @@
|
||||
(-> actual :db :mailserver.edit/mailserver))))
|
||||
(testing "it navigates to edit-mailserver view"
|
||||
(is (= [:edit-mailserver nil]
|
||||
(:status-im.ui.screens.navigation/navigate-to actual))))))
|
||||
(:status-im.navigation/navigate-to actual))))))
|
||||
(testing "when an id is given"
|
||||
(testing "when the mailserver is in the list"
|
||||
(let [actual (mailserver/edit cofx "a")]
|
||||
@ -161,7 +161,7 @@
|
||||
(-> actual :db :mailserver.edit/mailserver))))
|
||||
(testing "it navigates to edit-mailserver view"
|
||||
(is (= [:edit-mailserver nil]
|
||||
(:status-im.ui.screens.navigation/navigate-to actual))))))
|
||||
(:status-im.navigation/navigate-to actual))))))
|
||||
(testing "when the mailserver is not in the list"
|
||||
(let [actual (mailserver/edit cofx "not-existing")]
|
||||
(testing "it populates the fields with the correct values"
|
||||
@ -174,7 +174,7 @@
|
||||
(-> actual :db :mailserver.edit/mailserver))))
|
||||
(testing "it navigates to edit-mailserver view"
|
||||
(is (= [:edit-mailserver nil]
|
||||
(:status-im.ui.screens.navigation/navigate-to actual)))))))))
|
||||
(:status-im.navigation/navigate-to actual)))))))))
|
||||
|
||||
(deftest connected-mailserver
|
||||
(testing "it returns true when set in mailserver/current-id"
|
||||
|
@ -1,43 +0,0 @@
|
||||
(ns status-im.mailserver.db
|
||||
(:require [status-im.mailserver.core :as mailserver]
|
||||
[cljs.spec.alpha :as spec]))
|
||||
|
||||
(spec/def :mailserver/state (spec/nilable #{:disconnected :connecting :added :connected :error}))
|
||||
(spec/def :mailserver/current-id (spec/nilable keyword?))
|
||||
(spec/def :mailserver/address (spec/and string? mailserver/valid-enode-address?))
|
||||
(spec/def :mailserver/name :global/not-empty-string)
|
||||
(spec/def :mailserver/id keyword?)
|
||||
(spec/def :mailserver/user-defined boolean?)
|
||||
(spec/def :mailserver/password :global/not-empty-string)
|
||||
(spec/def :mailserver/sym-key-id string?)
|
||||
(spec/def :mailserver/generating-sym-key? boolean?)
|
||||
(spec/def :mailserver/mailserver (spec/keys :req-un [:mailserver/address :mailserver/name :mailserver/id]
|
||||
:opt-un [:mailserver/sym-key-id
|
||||
:mailserver/generating-sym-key?
|
||||
:mailserver/user-defined
|
||||
:mailserver/password]))
|
||||
|
||||
(spec/def :mailserver/mailservers (spec/nilable (spec/map-of keyword? (spec/map-of :mailserver/id :mailserver/mailserver))))
|
||||
|
||||
(spec/def :request/from pos-int?)
|
||||
(spec/def :request/to pos-int?)
|
||||
(spec/def :request/attempts int?)
|
||||
(spec/def :request/cursor :global/not-empty-string)
|
||||
|
||||
(spec/def :mailserver.topic/last-request pos-int?)
|
||||
(spec/def :mailserver.topic/started-at pos-int?)
|
||||
(spec/def :mailserver.topic/chat-id (spec/or :keyword keyword?
|
||||
:chat-id :global/not-empty-string))
|
||||
(spec/def :mailserver.topic/chat-ids (spec/coll-of :mailserver.topic/chat-id
|
||||
:kind set?
|
||||
:min-count 1))
|
||||
|
||||
(spec/def :mailserver/topic (spec/keys :req-un [:mailserver.topic/last-request
|
||||
:mailserver.topic/chat-ids]))
|
||||
(spec/def :mailserver/request-to :request/to)
|
||||
(spec/def :mailserver/connection-checks pos-int?)
|
||||
(spec/def :mailserver/topics (spec/map-of :global/not-empty-string :mailserver/topic))
|
||||
(spec/def :mailserver/current-request (spec/keys :req-un [:request/from :request/to ::topics]
|
||||
:opt-un [:request/attempts]))
|
||||
(spec/def :mailserver/pending-requests integer?)
|
||||
(spec/def :mailserver/request-error string?)
|
@ -12,7 +12,7 @@
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.node.core :as node]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.gfycat.core :as gfycat]
|
||||
[status-im.utils.identicon :as identicon]
|
||||
@ -21,7 +21,8 @@
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.utils.platform :as platform]
|
||||
[status-im.ui.components.bottom-sheet.core :as bottom-sheet]))
|
||||
[status-im.ui.components.bottom-sheet.core :as bottom-sheet]
|
||||
[status-im.constants :as const]))
|
||||
|
||||
(def step-kw-to-num
|
||||
{:generate-key 1
|
||||
|
@ -1,100 +1,8 @@
|
||||
(ns status-im.multiaccounts.db
|
||||
(:require status-im.utils.db
|
||||
status-im.ui.screens.bootnodes-settings.db
|
||||
[cljs.spec.alpha :as spec]
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
[status-im.constants :as const]))
|
||||
|
||||
(defn valid-length? [password]
|
||||
(>= (count password) const/min-password-length))
|
||||
|
||||
(spec/def ::password (spec/and :global/not-empty-string valid-length?))
|
||||
|
||||
(spec/def :multiaccount/root-address (spec/nilable string?))
|
||||
|
||||
(spec/def :account/path string?)
|
||||
(spec/def :account/color string?)
|
||||
(spec/def :account/name string?)
|
||||
(spec/def :account/storage keyword?)
|
||||
(spec/def :account/type keyword?)
|
||||
(spec/def :account/wallet boolean?)
|
||||
(spec/def :account/chat boolean?)
|
||||
(spec/def :account/public-key :global/public-key)
|
||||
(spec/def :account/address :global/address)
|
||||
|
||||
(spec/def :multiaccount/account
|
||||
(spec/keys :req-un [:account/address :account/color :account/name]
|
||||
:opt-un [:account/public-key :account/path
|
||||
:account/storage :account/type
|
||||
:account/wallet :account/chat]))
|
||||
(spec/def :multiaccount/accounts (spec/coll-of :multiaccount/account :kind vector?))
|
||||
|
||||
(spec/def :multiaccount/address :global/address)
|
||||
(spec/def :multiaccount/key-uid :global/key-uid)
|
||||
(spec/def :multiaccount/name :global/not-empty-string)
|
||||
(spec/def :multiaccount/public-key :global/public-key)
|
||||
(spec/def :multiaccount/signed-up? (spec/nilable boolean?))
|
||||
(spec/def :multiaccount/last-updated (spec/nilable int?))
|
||||
(spec/def :multiaccount/last-sign-in (spec/nilable int?))
|
||||
(spec/def :multiaccount/timestamp (spec/nilable int?))
|
||||
(spec/def :multiaccount/last-request (spec/nilable int?))
|
||||
(spec/def :multiaccount/photo-path (spec/nilable string?))
|
||||
(spec/def :multiaccount/debug? (spec/nilable boolean?))
|
||||
(spec/def :multiaccount/chaos-mode? (spec/nilable boolean?))
|
||||
(spec/def :multiaccount/bootnodes (spec/nilable :bootnodes/bootnodes))
|
||||
(spec/def :multiaccount/mailserver (spec/nilable string?))
|
||||
(spec/def :multiaccount/signing-phrase :global/not-empty-string)
|
||||
(spec/def :multiaccount/mnemonic (spec/nilable string?))
|
||||
(spec/def :multiaccount/sharing-usage-data? (spec/nilable boolean?))
|
||||
(spec/def :multiaccount/desktop-notifications? (spec/nilable boolean?))
|
||||
(spec/def :multiaccount/dev-mode? (spec/nilable boolean?))
|
||||
(spec/def :multiaccount/installation-id :global/not-empty-string)
|
||||
(spec/def :multiaccount/wallet-set-up-passed? (spec/nilable boolean?))
|
||||
(spec/def :multiaccount/hide-home-tooltip? (spec/nilable boolean?))
|
||||
(spec/def :multiaccount/desktop-alpha-release-warning-shown? (spec/nilable boolean?))
|
||||
(spec/def :multiaccount/keycard-instance-uid (spec/nilable string?))
|
||||
(spec/def :multiaccount/key-uid (spec/nilable string?))
|
||||
(spec/def :multiaccount/keycard-pairing (spec/nilable string?))
|
||||
(spec/def :multiaccount/keycard-paired-on (spec/nilable int?))
|
||||
(spec/def :multiaccount/multiaccount (spec/keys :opt-un [:multiaccount/name :multiaccount/address
|
||||
:multiaccount/photo-path
|
||||
:multiaccount/signing-phrase
|
||||
:multiaccount/installation-id
|
||||
:multiaccount/debug? :multiaccount/last-updated :multiaccount/public-key
|
||||
:multiaccount/email :multiaccount/signed-up?
|
||||
:multiaccount/mailserver
|
||||
:multiaccount/sharing-usage-data?
|
||||
:multiaccount/mnemonic :multiaccount/desktop-notifications?
|
||||
:multiaccount/chaos-mode?
|
||||
:multiaccount/wallet-set-up-passed? :multiaccount/last-request
|
||||
:multiaccount/hide-home-tooltip?
|
||||
:multiaccount/bootnodes
|
||||
:multiaccount/desktop-alpha-release-warning-shown?
|
||||
:multiaccount/keycard-instance-uid
|
||||
:multiaccount/key-uid
|
||||
:multiaccount/keycard-pairing
|
||||
:multiaccount/keycard-paired-on
|
||||
:multiaccount/root-address
|
||||
:multiaccount/accounts]))
|
||||
;; generated multiaccounts
|
||||
(spec/def :generated-multiaccounts/id string?)
|
||||
(spec/def :generated-multiaccounts/derived-key
|
||||
(spec/keys :req-un [:multiaccount/address
|
||||
:multiaccount/public-key]))
|
||||
(spec/def :generated-multiaccounts/derived
|
||||
(spec/map-of keyword? :generated-multiaccounts/derived-key))
|
||||
(spec/def :multiaccounts/generated-multiaccount
|
||||
(spec/keys :req-un [:multiaccount/address
|
||||
:multiaccount/mnemonic
|
||||
:multiaccount/public-key
|
||||
:multiaccount/key-uid
|
||||
:generated-multiaccounts/id]
|
||||
:opt-un [:generated-multiaccounts/derived]))
|
||||
|
||||
;;used during recovering multiaccount
|
||||
(spec/def :multiaccounts/recover (spec/nilable map?))
|
||||
;;used during logging
|
||||
(spec/def :multiaccounts/login (spec/nilable map?))
|
||||
;;before login
|
||||
(spec/def :multiaccounts/multiaccount (spec/keys :req-un [:multiaccount/name :multiaccount/key-uid]
|
||||
:opt-un [:multiaccount/timestamp]))
|
||||
(spec/def :multiaccounts/multiaccounts (spec/nilable (spec/map-of :multiaccount/key-uid :multiaccounts/multiaccount)))
|
||||
|
@ -12,7 +12,7 @@
|
||||
[status-im.protocol.core :as protocol]
|
||||
[status-im.stickers.core :as stickers]
|
||||
[status-im.ui.screens.mobile-network-settings.events :as mobile-network]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
@ -23,7 +23,6 @@
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.wallet.core :as wallet]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.ui.screens.db :refer [app-db]]
|
||||
[status-im.multiaccounts.biometric.core :as biometric]
|
||||
[status-im.utils.identicon :as identicon]
|
||||
[status-im.ethereum.eip55 :as eip55]
|
||||
|
@ -6,7 +6,7 @@
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.transport.core :as transport]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.keychain.core :as keychain]))
|
||||
|
||||
(fx/defn logout-method
|
||||
|
@ -9,7 +9,7 @@
|
||||
[status-im.multiaccounts.create.core :as multiaccounts.create]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.popover.core :as popover]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.security :as security]
|
||||
[status-im.utils.types :as types]
|
||||
|
@ -1,50 +1,9 @@
|
||||
(ns status-im.ui.screens.navigation
|
||||
(ns status-im.navigation
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.ui.screens.routing.core :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.fx :as fx]))
|
||||
|
||||
(defmulti unload-data!
|
||||
(fn [db] (:view-id db)))
|
||||
|
||||
(defmethod unload-data! :default [db] db)
|
||||
|
||||
(fx/defn navigate-to-cofx
|
||||
[{:keys [db]} go-to-view-id screen-params]
|
||||
{:db
|
||||
(cond-> (assoc db :view-id go-to-view-id)
|
||||
;; TODO: Inspect the need of screen-params
|
||||
(and (seq screen-params) (:screen screen-params) (:params screen-params))
|
||||
(assoc-in [:navigation/screen-params (:screen screen-params)] (:params screen-params))
|
||||
(seq screen-params)
|
||||
(assoc-in [:navigation/screen-params go-to-view-id] screen-params))
|
||||
::navigate-to [go-to-view-id screen-params]})
|
||||
|
||||
(fx/defn navigate-replace-cofx
|
||||
[{:keys [db]} go-to-view-id screen-params]
|
||||
(let [db (cond-> (assoc db :view-id go-to-view-id)
|
||||
(seq screen-params)
|
||||
(assoc-in [:navigation/screen-params go-to-view-id]
|
||||
screen-params))]
|
||||
{:db db
|
||||
::navigate-replace [go-to-view-id screen-params]}))
|
||||
|
||||
(fx/defn navigate-reset
|
||||
[_ config]
|
||||
{::navigate-reset config})
|
||||
|
||||
(def unload-data-interceptor
|
||||
(re-frame/->interceptor
|
||||
:id unload-data-interceptor
|
||||
:before (fn unload-data-interceptor-before
|
||||
[context]
|
||||
(let [db (re-frame/get-coeffect context :db)]
|
||||
(re-frame/assoc-coeffect context :db (unload-data! db))))))
|
||||
|
||||
(def navigation-interceptors
|
||||
[unload-data-interceptor])
|
||||
|
||||
(re-frame/reg-fx
|
||||
::navigate-to
|
||||
(fn [[view-id params]]
|
||||
@ -69,34 +28,41 @@
|
||||
(log/debug :navigate-replace view-id params)
|
||||
(navigation/navigate-replace (name view-id) params)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-to
|
||||
navigation-interceptors
|
||||
(fn [cofx [_ & [go-to-view-id screen-params]]]
|
||||
(navigate-to-cofx cofx go-to-view-id screen-params)))
|
||||
(fx/defn navigate-to-cofx
|
||||
[{:keys [db]} go-to-view-id screen-params]
|
||||
{:db
|
||||
(cond-> (assoc db :view-id go-to-view-id)
|
||||
;; TODO: Inspect the need of screen-params
|
||||
(and (seq screen-params) (:screen screen-params) (:params screen-params))
|
||||
(assoc-in [:navigation/screen-params (:screen screen-params)] (:params screen-params))
|
||||
(seq screen-params)
|
||||
(assoc-in [:navigation/screen-params go-to-view-id] screen-params))
|
||||
::navigate-to [go-to-view-id screen-params]})
|
||||
|
||||
(fx/defn navigate-to
|
||||
{:events [:navigate-to]}
|
||||
[cofx go-to-view-id screen-params]
|
||||
(navigate-to-cofx cofx go-to-view-id screen-params))
|
||||
|
||||
(fx/defn navigate-back
|
||||
{:events [:navigate-back]}
|
||||
[_]
|
||||
{::navigate-back nil})
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-back
|
||||
(fn [cofx _]
|
||||
(navigate-back cofx)))
|
||||
(fx/defn navigate-reset
|
||||
{:events [:navigate-reset]}
|
||||
[_ config]
|
||||
{::navigate-reset config})
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-reset
|
||||
(fn [cofx [_ view-id]]
|
||||
(navigate-reset cofx {:index 0
|
||||
:routes [{:name view-id}]})))
|
||||
(fx/defn navigate-to-clean
|
||||
{:events [:navigate-to-clean]}
|
||||
[cofx [_ view-id params]]
|
||||
(navigate-to-cofx cofx view-id params))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-to-clean
|
||||
(fn [cofx [_ view-id params]]
|
||||
(navigate-to-cofx cofx view-id params)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-replace
|
||||
navigation-interceptors
|
||||
(fn [cofx [_ & [go-to-view-id screen-params]]]
|
||||
(navigate-replace-cofx cofx go-to-view-id screen-params)))
|
||||
(fx/defn navigate-replace
|
||||
[{:keys [db]} go-to-view-id screen-params]
|
||||
(let [db (cond-> (assoc db :view-id go-to-view-id)
|
||||
(seq screen-params)
|
||||
(assoc-in [:navigation/screen-params go-to-view-id] screen-params))]
|
||||
{:db db
|
||||
::navigate-replace [go-to-view-id screen-params]}))
|
@ -5,7 +5,7 @@
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.node.core :as node]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.http :as http]
|
||||
[status-im.utils.types :as types]))
|
||||
|
@ -1,15 +0,0 @@
|
||||
(ns status-im.network.ui.db
|
||||
(:require [cljs.spec.alpha :as spec]))
|
||||
|
||||
(spec/def :networks/id string?)
|
||||
(spec/def :networks/name string?)
|
||||
(spec/def :networks/config map?)
|
||||
|
||||
(spec/def :networks/network
|
||||
(spec/keys :req-un [:networks/id :networks/name :networks/config]))
|
||||
|
||||
(spec/def :networks/selected-network :networks/network)
|
||||
|
||||
(spec/def :networks/networks (spec/nilable (spec/map-of :networks/id :networks/network)))
|
||||
|
||||
(spec/def :networks/manage (spec/nilable map?))
|
@ -10,7 +10,7 @@
|
||||
[status-im.multiaccounts.model :as multiaccounts.model]
|
||||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[status-im.transport.message.protocol :as protocol]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.identicon :as identicon]
|
||||
|
@ -6,7 +6,7 @@
|
||||
[status-im.ethereum.contracts :as contracts]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.signing.core :as signing]
|
||||
|
@ -1,11 +1,9 @@
|
||||
(ns status-im.subs-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
reagent.core
|
||||
[re-frame.core :as re-frame]
|
||||
[day8.re-frame.test :refer [run-test-sync]]
|
||||
status-im.ui.screens.db
|
||||
status-im.db
|
||||
status-im.subs
|
||||
[status-im.ui.screens.events :as events]
|
||||
[status-im.subs :as subs]))
|
||||
|
||||
(def transactions [{:timestamp "1505912551000"}
|
||||
|
@ -1,106 +0,0 @@
|
||||
(ns ^{:doc "DB spec and utils for the transport layer"}
|
||||
status-im.transport.db
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
[clojure.string :as s]
|
||||
[clojure.set :as sets]
|
||||
status-im.contact.db
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.utils.clocks :as utils.clocks]
|
||||
[status-im.constants :as constants]))
|
||||
|
||||
;; optional
|
||||
(spec/def :transport/filter-id (spec/or :keyword keyword?
|
||||
:chat-id :global/not-empty-string))
|
||||
(spec/def :transport/filter any?)
|
||||
|
||||
(spec/def :pairing/pending? boolean?)
|
||||
(spec/def :pairing/contact (spec/keys :req-un [:contact/public-key
|
||||
:contact/name
|
||||
:contact/address]
|
||||
:opt-un [:contact/system-tags
|
||||
:contact/last-updated
|
||||
:contact/last-online
|
||||
:pairing/pending?
|
||||
:contact/tags]))
|
||||
(spec/def :pairing/contacts (spec/nilable (spec/map-of :global/not-empty-string :pairing/contact)))
|
||||
(spec/def :pairing/installation-id :global/not-empty-string)
|
||||
(spec/def :pairing/device-type :global/not-empty-string)
|
||||
|
||||
(spec/def :transport/filters (spec/map-of :transport/filter-id (spec/coll-of :transport/filter)))
|
||||
|
||||
(defn create-chat
|
||||
"Initialize datastructure for chat representation at the transport level
|
||||
Currently only :topic is actually used"
|
||||
[{:keys [topic resend? one-to-one now]}]
|
||||
{:one-to-one (boolean one-to-one)
|
||||
:resend? resend?
|
||||
:topic topic})
|
||||
|
||||
(spec/def ::profile-image :contact/photo-path)
|
||||
|
||||
(spec/def :chat/name (spec/nilable string?))
|
||||
|
||||
(spec/def :group-chat/admin :global/public-key)
|
||||
(spec/def :group-chat/signature :global/not-empty-string)
|
||||
(spec/def :group-chat/chat-id :global/not-empty-string)
|
||||
(spec/def :group-chat/type :global/not-empty-string)
|
||||
(spec/def :group-chat/member :global/not-empty-string)
|
||||
(spec/def :group-chat/name :global/not-empty-string)
|
||||
|
||||
(spec/def :group-chat/event (spec/keys :req-un [::clock-value :group-chat/type] :opt-un [:group-chat/member :group-chat/name]))
|
||||
(spec/def :group-chat/events (spec/coll-of :group-chat/event))
|
||||
(spec/def :group-chat/membership-updates (spec/coll-of (spec/keys :req-un [:group-chat/signature :group-chat/events])))
|
||||
|
||||
(spec/def :message.content/text (spec/and string? (complement s/blank?)))
|
||||
(spec/def :message.content/response-to string?)
|
||||
(spec/def :message.content/uri (spec/and string? (complement s/blank?)))
|
||||
(spec/def :message.content/pack (spec/and string? (complement s/blank?)))
|
||||
(spec/def :message.content/params (spec/map-of keyword? any?))
|
||||
|
||||
(spec/def ::content-type #{constants/content-type-text
|
||||
constants/content-type-emoji
|
||||
constants/content-type-sticker})
|
||||
(spec/def ::message-type #{constants/message-type-private-group constants/message-type-public-group constants/message-type-one-to-one})
|
||||
(spec/def ::clock-value (spec/and pos-int?
|
||||
utils.clocks/safe-timestamp?))
|
||||
(spec/def ::timestamp (spec/nilable pos-int?))
|
||||
|
||||
(spec/def :message/id string?)
|
||||
(spec/def :message/ids (spec/coll-of :message/id :kind set?))
|
||||
|
||||
(spec/def ::message (spec/or :message/contact-request :message/contact-request
|
||||
:message/contact-update :message/contact-update
|
||||
:message/contact-request-confirmed :message/contact-request-confirmed
|
||||
:message/message :message/message
|
||||
:message/message-seen :message/message-seen
|
||||
:message/group-membership-update :message/group-membership-update))
|
||||
|
||||
(spec/def :message/contact-request (spec/keys :req-un [:contact/name ::profile-image :contact/address]))
|
||||
(spec/def :message/contact-update (spec/keys :req-un [:contact/name ::profile-image :contact/address]))
|
||||
(spec/def :message/contact-request-confirmed (spec/keys :req-un [:contact/name ::profile-image :contact/address]))
|
||||
(spec/def :message/new-contact-key (spec/keys :req-un [::sym-key ::topic ::message]))
|
||||
|
||||
(spec/def :message/message-seen (spec/keys :req-un [:message/ids]))
|
||||
|
||||
(spec/def :message/group-membership-update (spec/keys :req-un [:group-chat/membership-updates :group-chat/chat-id]))
|
||||
(spec/def :message/sync-installation (spec/keys :req-un [:pairing/contacts]))
|
||||
(spec/def :message/pair-installation (spec/keys :req-un [:pairing/installation-id
|
||||
:pairing/device-type]))
|
||||
|
||||
(spec/def :message/message-common (spec/keys :req-un [::content-type ::message-type ::clock-value ::timestamp]))
|
||||
(spec/def :message.text/content (spec/keys :req-un [:message.content/text]
|
||||
:req-opt [:message.content/response-to]))
|
||||
|
||||
(spec/def :message.sticker/content (spec/keys :req-un [:message.content/hash]))
|
||||
|
||||
(defmulti content-type :content-type)
|
||||
|
||||
(defmethod content-type constants/content-type-sticker [_]
|
||||
(spec/merge :message/message-common
|
||||
(spec/keys :req-un [:message.sticker/content])))
|
||||
|
||||
(defmethod content-type :default [_]
|
||||
(spec/merge :message/message-common
|
||||
(spec/keys :req-un [:message.text/content])))
|
||||
|
||||
(spec/def :message/message (spec/multi-spec content-type :content-type))
|
@ -10,7 +10,7 @@
|
||||
[status-im.ethereum.transactions.core :as transactions]
|
||||
[status-im.tribute-to-talk.db :as tribute-to-talk.db]
|
||||
[status-im.tribute-to-talk.whitelist :as whitelist]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.money :as money]
|
||||
[taoensso.timbre :as log]
|
||||
|
@ -1,7 +1,6 @@
|
||||
(ns status-im.ui.components.bottom-sheet.core
|
||||
(:require [status-im.ui.components.bottom-sheet.view :as view]
|
||||
[status-im.ui.components.bottom-sheet.events :as events]
|
||||
status-im.ui.components.bottom-sheet.db))
|
||||
[status-im.ui.components.bottom-sheet.events :as events]))
|
||||
|
||||
(def show-bottom-sheet events/show-bottom-sheet)
|
||||
(def hide-bottom-sheet events/hide-bottom-sheet)
|
||||
|
@ -1,6 +0,0 @@
|
||||
(ns status-im.ui.components.bottom-sheet.db
|
||||
(:require [cljs.spec.alpha :as spec]))
|
||||
|
||||
(spec/def :bottom-sheet/show? (spec/nilable boolean?))
|
||||
(spec/def :bottom-sheet/view (spec/nilable any?))
|
||||
(spec/def :bottom-sheet/options (spec/nilable map?))
|
@ -1,6 +1,5 @@
|
||||
(ns status-im.ui.screens.add-new.new-public-chat.db
|
||||
(:require [clojure.string :as string]
|
||||
[cljs.spec.alpha :as spec]
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
status-im.utils.db))
|
||||
|
||||
(spec/def ::name :global/not-empty-string)
|
||||
|
@ -1,17 +0,0 @@
|
||||
(ns status-im.ui.screens.bootnodes-settings.db
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[cljs.spec.alpha :as spec]))
|
||||
|
||||
(spec/def ::not-blank-string (complement string/blank?))
|
||||
|
||||
(spec/def :bootnode/address ::not-blank-string)
|
||||
(spec/def :bootnode/name ::not-blank-string)
|
||||
(spec/def :bootnode/id ::not-blank-string)
|
||||
(spec/def :bootnode/chain ::not-blank-string)
|
||||
(spec/def :bootnode/bootnode (spec/keys :req-un [:bootnode/chain
|
||||
:bootnode/address
|
||||
:bootnode/name
|
||||
:bootnode/id]))
|
||||
|
||||
(spec/def :bootnodes/bootnodes (spec/nilable (spec/map-of :bootnode/id (spec/map-of :bootnode/id :bootnode/bootnode))))
|
@ -1,300 +0,0 @@
|
||||
(ns status-im.ui.screens.db
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.utils.dimensions :as dimensions]
|
||||
[status-im.fleet.core :as fleet]
|
||||
status-im.transport.db
|
||||
status-im.multiaccounts.db
|
||||
status-im.contact.db
|
||||
status-im.ui.screens.group.db
|
||||
status-im.chat.specs
|
||||
status-im.ui.screens.profile.db
|
||||
status-im.mailserver.db
|
||||
status-im.ens.db
|
||||
status-im.browser.db
|
||||
status-im.ui.screens.add-new.new-public-chat.db
|
||||
status-im.ui.components.bottom-sheet.core
|
||||
status-im.ui.screens.intro.db
|
||||
[status-im.wallet.db :as wallet.db]))
|
||||
|
||||
;; initial state of app-db
|
||||
(def app-db {:keyboard-height 0
|
||||
:contacts/contacts {}
|
||||
:pairing/installations {}
|
||||
:qr-codes {}
|
||||
:group/selected-contacts #{}
|
||||
:chats {}
|
||||
:current-chat-id nil
|
||||
:selected-participants #{}
|
||||
:sync-state :done
|
||||
:app-state "active"
|
||||
:wallet wallet.db/default-wallet
|
||||
:wallet/all-tokens {}
|
||||
:prices {}
|
||||
:peers-count 0
|
||||
:node-info {}
|
||||
:peers-summary []
|
||||
:my-profile/editing? false
|
||||
:transport/filters {}
|
||||
:transport/message-envelopes {}
|
||||
:mailserver/mailservers (fleet/default-mailservers {})
|
||||
:mailserver/topics {}
|
||||
:mailserver/pending-requests 0
|
||||
:chat/cooldowns 0
|
||||
:chat/inputs {}
|
||||
:chat/cooldown-enabled? false
|
||||
:chat/last-outgoing-message-sent-at 0
|
||||
:chat/spam-messages-frequency 0
|
||||
:tooltips {}
|
||||
:initial-props {}
|
||||
:desktop/desktop {:tab-view-id :home}
|
||||
:dimensions/window (dimensions/window)
|
||||
:registry {}
|
||||
:stickers/packs-owned #{}
|
||||
:stickers/packs-pending #{}
|
||||
:hardwallet {:nfc-enabled? false
|
||||
:pin {:original []
|
||||
:confirmation []
|
||||
:current []
|
||||
:puk []
|
||||
:enter-step :original}}
|
||||
:two-pane-ui-enabled? (dimensions/fit-two-pane?)})
|
||||
|
||||
;;;;GLOBAL
|
||||
|
||||
;;"http://localhost:8545"
|
||||
(spec/def ::rpc-url (spec/nilable string?))
|
||||
;;object? doesn't work
|
||||
(spec/def ::web3 (spec/nilable any?))
|
||||
(spec/def ::web3-node-version (spec/nilable string?))
|
||||
|
||||
;;height of native keyboard if shown
|
||||
(spec/def ::keyboard-height (spec/nilable number?))
|
||||
(spec/def ::keyboard-max-height (spec/nilable number?))
|
||||
;;:online - presence of internet connection in the phone
|
||||
(spec/def ::network-status (spec/nilable keyword?))
|
||||
;; ui connectivity status
|
||||
(spec/def :connectivity/ui-status-properties (spec/nilable map?))
|
||||
|
||||
(spec/def ::app-state string?)
|
||||
(spec/def ::app-in-background-since (spec/nilable number?))
|
||||
(spec/def ::app-active-since (spec/nilable number?))
|
||||
(spec/def ::logged-in-since (spec/nilable number?))
|
||||
|
||||
;;;;NODE
|
||||
|
||||
(spec/def ::sync-state (spec/nilable #{:pending :in-progress :synced :done :offline}))
|
||||
(spec/def ::sync-data (spec/nilable map?))
|
||||
|
||||
;;;;NAVIGATION
|
||||
|
||||
;;current view
|
||||
(spec/def :navigation/view-id (spec/nilable keyword?))
|
||||
;; navigation screen params
|
||||
(spec/def :navigation.screen-params/network-details (spec/keys :req [:networks/selected-network]))
|
||||
(spec/def :navigation.screen-params/browser (spec/nilable map?))
|
||||
(spec/def :navigation.screen-params.profile-qr-viewer/contact (spec/nilable map?))
|
||||
(spec/def :navigation.screen-params.profile-qr-viewer/source (spec/nilable keyword?))
|
||||
(spec/def :navigation.screen-params.profile-qr-viewer/value (spec/nilable string?))
|
||||
(spec/def :navigation.screen-params/profile-qr-viewer (spec/keys :opt-un [:navigation.screen-params.profile-qr-viewer/contact
|
||||
:navigation.screen-params.profile-qr-viewer/source
|
||||
:navigation.screen-params.profile-qr-viewer/value]))
|
||||
(spec/def :navigation.screen-params.qr-scanner/current-qr-context (spec/nilable any?))
|
||||
(spec/def :navigation.screen-params/qr-scanner (spec/keys :opt-un [:navigation.screen-params.qr-scanner/current-qr-context]))
|
||||
(spec/def :navigation.screen-params.group-contacts/show-search? (spec/nilable any?))
|
||||
(spec/def :navigation.screen-params/group-contacts (spec/keys :opt [:group/contact-group-id]
|
||||
:opt-un [:navigation.screen-params.group-contacts/show-search?]))
|
||||
(spec/def :navigation.screen-params.edit-contact-group/group (spec/nilable any?))
|
||||
(spec/def :navigation.screen-params.edit-contact-group/group-type (spec/nilable any?))
|
||||
(spec/def :navigation.screen-params/edit-contact-group (spec/keys :opt-un [:navigation.screen-params.edit-contact-group/group
|
||||
:navigation.screen-params.edit-contact-group/group-type]))
|
||||
|
||||
(spec/def :navigation.screen-params/collectibles-list map?)
|
||||
|
||||
(spec/def :navigation.screen-params/manage-dapps-permissions map?)
|
||||
|
||||
(spec/def :navigation/screen-params (spec/nilable (spec/keys :opt-un [:navigation.screen-params/network-details
|
||||
:navigation.screen-params/browser
|
||||
:navigation.screen-params/profile-qr-viewer
|
||||
:navigation.screen-params/qr-scanner
|
||||
:navigation.screen-params/group-contacts
|
||||
:navigation.screen-params/edit-contact-group
|
||||
:navigation.screen-params/collectibles-list
|
||||
:navigation.screen-params/manage-dapps-permissions])))
|
||||
|
||||
(spec/def :desktop/desktop (spec/nilable any?))
|
||||
(spec/def ::tooltips (spec/nilable any?))
|
||||
(spec/def ::initial-props (spec/nilable any?))
|
||||
(spec/def ::two-pane-ui-enabled? (spec/nilable boolean?))
|
||||
|
||||
;;;;NETWORK
|
||||
|
||||
(spec/def ::network (spec/nilable string?))
|
||||
(spec/def ::chain (spec/nilable string?))
|
||||
(spec/def ::peers-count (spec/nilable integer?))
|
||||
(spec/def ::node-info (spec/nilable map?))
|
||||
(spec/def ::peers-summary (spec/nilable vector?))
|
||||
|
||||
(spec/def ::collectible (spec/nilable map?))
|
||||
(spec/def ::collectibles (spec/nilable map?))
|
||||
|
||||
;;;;NODE
|
||||
|
||||
(spec/def ::message-envelopes (spec/nilable map?))
|
||||
|
||||
;;;; Supported Biometric authentication types
|
||||
|
||||
(spec/def ::supported-biometric-auth (spec/nilable #{:FaceID :TouchID :fingerprint}))
|
||||
|
||||
;;;;UNIVERSAL LINKS
|
||||
|
||||
(spec/def :universal-links/url (spec/nilable string?))
|
||||
|
||||
;; DIMENSIONS
|
||||
(spec/def :dimensions/window map?)
|
||||
|
||||
(spec/def ::hardwallet (spec/nilable map?))
|
||||
|
||||
(spec/def :stickers/packs (spec/nilable map?))
|
||||
(spec/def :stickers/packs-owned (spec/nilable set?))
|
||||
(spec/def :stickers/packs-pending (spec/nilable set?))
|
||||
(spec/def :stickers/packs-installed (spec/nilable map?))
|
||||
(spec/def :stickers/selected-pack (spec/nilable any?))
|
||||
(spec/def :stickers/recent (spec/nilable vector?))
|
||||
(spec/def :wallet/custom-token-screen (spec/nilable map?))
|
||||
|
||||
(spec/def :signing/queue (spec/nilable any?))
|
||||
(spec/def :signing/tx (spec/nilable map?))
|
||||
(spec/def :signing/sign (spec/nilable map?))
|
||||
(spec/def :signing/edit-fee (spec/nilable map?))
|
||||
|
||||
(spec/def :popover/popover (spec/nilable map?))
|
||||
|
||||
(spec/def :wallet/prepare-transaction (spec/nilable map?))
|
||||
|
||||
(spec/def ::db (spec/keys :opt [:contacts/contacts
|
||||
:contacts/new-identity
|
||||
:contacts/identity
|
||||
:contacts/ui-props
|
||||
:contacts/list-ui-props
|
||||
:contacts/click-handler
|
||||
:contacts/click-action
|
||||
:contacts/click-params
|
||||
:pairing/installations
|
||||
:group/selected-contacts
|
||||
:multiaccounts/multiaccounts
|
||||
:multiaccounts/recover
|
||||
:multiaccounts/login
|
||||
:multiaccount/accounts
|
||||
:my-profile/profile
|
||||
:my-profile/default-name
|
||||
:my-profile/editing?
|
||||
:my-profile/advanced?
|
||||
:my-profile/seed
|
||||
:group-chat-profile/profile
|
||||
:group-chat-profile/editing?
|
||||
:networks/selected-network
|
||||
:networks/networks
|
||||
:networks/manage
|
||||
:bootnodes/manage
|
||||
:universal-links/url
|
||||
:browser/browsers
|
||||
:browser/options
|
||||
:navigation/screen-params
|
||||
:chat/cooldowns
|
||||
:chat/inputs
|
||||
:chat/cooldown-enabled?
|
||||
:chat/last-outgoing-message-sent-at
|
||||
:chat/spam-messages-frequency
|
||||
:transport/message-envelopes
|
||||
:transport/filters
|
||||
:mailserver.edit/mailserver
|
||||
:mailserver/mailservers
|
||||
:mailserver/current-id
|
||||
:mailserver/state
|
||||
:mailserver/topics
|
||||
:mailserver/pending-requests
|
||||
:mailserver/current-request
|
||||
:mailserver/connection-checks
|
||||
:mailserver/request-to
|
||||
:mailserver/request-error
|
||||
:desktop/desktop
|
||||
:dimensions/window
|
||||
:dapps/permissions
|
||||
:wallet/all-tokens
|
||||
:ui/contact
|
||||
:ui/search
|
||||
:ui/chat
|
||||
:chats/loading?
|
||||
:stickers/packs
|
||||
:stickers/packs-installed
|
||||
:stickers/selected-pack
|
||||
:stickers/recent
|
||||
:stickers/packs-owned
|
||||
:stickers/packs-pending
|
||||
:bottom-sheet/show?
|
||||
:bottom-sheet/view
|
||||
:bottom-sheet/options
|
||||
:wallet/custom-token-screen
|
||||
:wallet/prepare-transaction
|
||||
:signing/queue
|
||||
:signing/sign
|
||||
:signing/tx
|
||||
:signing/edit-fee
|
||||
:popover/popover
|
||||
:wallet/sign-phrase-showed?]
|
||||
:opt-un [::modal
|
||||
::rpc-url
|
||||
::tooltips
|
||||
::initial-props
|
||||
::web3
|
||||
::web3-node-version
|
||||
::keyboard-height
|
||||
::keyboard-max-height
|
||||
::network-status
|
||||
::peers-count
|
||||
::node-info
|
||||
::peers-summary
|
||||
::sync-state
|
||||
::sync-data
|
||||
::network
|
||||
::chain
|
||||
::app-state
|
||||
::app-in-background-since
|
||||
::app-active-since
|
||||
::logged-in-since
|
||||
::hardwallet
|
||||
::auth-method
|
||||
:multiaccount/multiaccount
|
||||
:navigation/view-id
|
||||
:chat/chats
|
||||
:chat/current-chat-id
|
||||
:chat/chat-id
|
||||
:chat/new-chat
|
||||
:chat/new-chat-name
|
||||
:chat/animations
|
||||
:chat/chat-ui-props
|
||||
:chat/chat-list-ui-props
|
||||
:chat/layout-height
|
||||
:chat/message-data
|
||||
:chat/message-status
|
||||
:chat/selected-participants
|
||||
:chat/public-group-topic
|
||||
:chat/public-group-topic-error
|
||||
:chat/messages
|
||||
:chat/message-statuses
|
||||
:chat/last-clock-value
|
||||
:chat/loaded-chats
|
||||
:chat/bot-db
|
||||
:connectivity/ui-status-properties
|
||||
:ens/registration
|
||||
:wallet/wallet
|
||||
:prices/prices
|
||||
:prices/prices-loading?
|
||||
::supported-biometric-auth
|
||||
::collectible
|
||||
::collectibles
|
||||
:registry/registry
|
||||
::two-pane-ui-enabled?
|
||||
::add-account
|
||||
:intro-wizard/intro-wizard]))
|
@ -1,212 +0,0 @@
|
||||
(ns status-im.ui.screens.events
|
||||
(:require status-im.events
|
||||
status-im.ui.screens.add-new.new-chat.events
|
||||
status-im.ui.screens.group.chat-settings.events
|
||||
status-im.ui.screens.group.events
|
||||
status-im.utils.universal-links.events
|
||||
status-im.ui.screens.profile.events
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.chat.models.loading :as chat.loading]
|
||||
[status-im.chat.models :as chat]
|
||||
[status-im.hardwallet.core :as hardwallet]
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.multiaccounts.recover.core :as recovery]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ui.components.permissions :as permissions]
|
||||
[status-im.utils.dimensions :as dimensions]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.http :as http]
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.constants :as const]
|
||||
[status-im.multiaccounts.biometric.core :as biometric]))
|
||||
|
||||
(defn- http-get [{:keys [url response-validator success-event-creator failure-event-creator timeout-ms]}]
|
||||
(let [on-success #(re-frame/dispatch (success-event-creator %))
|
||||
on-error (when failure-event-creator #(re-frame/dispatch (failure-event-creator %)))
|
||||
opts {:valid-response? response-validator
|
||||
:timeout-ms timeout-ms}]
|
||||
(http/get url on-success on-error opts)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-get
|
||||
http-get)
|
||||
|
||||
(defn- http-raw-get [{:keys [url success-event-creator failure-event-creator timeout-ms]}]
|
||||
(let [on-success #(when-let [event (success-event-creator %)] (re-frame/dispatch event))
|
||||
on-error (when failure-event-creator #(re-frame/dispatch (failure-event-creator %)))
|
||||
opts {:timeout-ms timeout-ms}]
|
||||
(http/raw-get url on-success on-error opts)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-raw-get
|
||||
http-raw-get)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-get-n
|
||||
(fn [calls]
|
||||
(doseq [call calls]
|
||||
(http-get call))))
|
||||
|
||||
(defn- http-post [{:keys [url data response-validator success-event-creator failure-event-creator timeout-ms opts]}]
|
||||
(let [on-success #(re-frame/dispatch (success-event-creator %))
|
||||
on-error (when failure-event-creator #(re-frame/dispatch (failure-event-creator %)))
|
||||
all-opts (assoc opts
|
||||
:valid-response? response-validator
|
||||
:timeout-ms timeout-ms)]
|
||||
(http/post url data on-success on-error all-opts)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-post
|
||||
http-post)
|
||||
|
||||
(defn- http-raw-post [{:keys [url body response-validator success-event-creator failure-event-creator timeout-ms opts]}]
|
||||
(let [on-success #(re-frame/dispatch (success-event-creator %))
|
||||
on-error (when failure-event-creator #(re-frame/dispatch (failure-event-creator %)))
|
||||
all-opts (assoc opts
|
||||
:valid-response? response-validator
|
||||
:timeout-ms timeout-ms)]
|
||||
(http/raw-post url body on-success on-error all-opts)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-raw-post
|
||||
http-raw-post)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:request-permissions-fx
|
||||
(fn [options]
|
||||
(permissions/request-permissions options)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:ui/listen-to-window-dimensions-change
|
||||
(fn []
|
||||
(dimensions/add-event-listener)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:ui/show-error
|
||||
(fn [content]
|
||||
(utils/show-popup "Error" content)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:ui/show-confirmation
|
||||
(fn [options]
|
||||
(utils/show-confirmation options)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:ui/close-application
|
||||
(fn [_]
|
||||
(status/close-application)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::app-state-change-fx
|
||||
(fn [state]
|
||||
(status/app-state-change state)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set
|
||||
(fn [{:keys [db]} [_ k v]]
|
||||
{:db (assoc db k v)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-once
|
||||
(fn [{:keys [db]} [_ k v]]
|
||||
(when-not (get db k)
|
||||
{:db (assoc db k v)})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-in
|
||||
(fn [{:keys [db]} [_ path v]]
|
||||
{:db (assoc-in db path v)}))
|
||||
|
||||
(def authentication-options
|
||||
{:reason (i18n/label :t/biometric-auth-reason-login)})
|
||||
|
||||
(defn- on-biometric-auth-result [{:keys [bioauth-success bioauth-code bioauth-message]}]
|
||||
(when-not bioauth-success
|
||||
(if (= bioauth-code "USER_FALLBACK")
|
||||
(re-frame/dispatch [:multiaccounts.logout.ui/logout-confirmed])
|
||||
(utils/show-confirmation {:title (i18n/label :t/biometric-auth-confirm-title)
|
||||
:content (or bioauth-message (i18n/label :t/biometric-auth-confirm-message))
|
||||
:confirm-button-text (i18n/label :t/biometric-auth-confirm-try-again)
|
||||
:cancel-button-text (i18n/label :t/biometric-auth-confirm-logout)
|
||||
:on-accept #(biometric/authenticate on-biometric-auth-result authentication-options)
|
||||
:on-cancel #(re-frame/dispatch [:multiaccounts.logout.ui/logout-confirmed])}))))
|
||||
|
||||
(fx/defn on-return-from-background [{:keys [db now] :as cofx}]
|
||||
(let [app-in-background-since (get db :app-in-background-since)
|
||||
signed-up? (get-in db [:multiaccount :signed-up?])
|
||||
biometric-auth? (= (:auth-method db) "biometric")
|
||||
requires-bio-auth (and
|
||||
signed-up?
|
||||
biometric-auth?
|
||||
(some? app-in-background-since)
|
||||
(>= (- now app-in-background-since)
|
||||
const/ms-in-bg-for-require-bioauth))]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(dissoc :app-in-background-since)
|
||||
(assoc :app-active-since now))}
|
||||
(mailserver/process-next-messages-request)
|
||||
#(when requires-bio-auth
|
||||
(biometric/authenticate % on-biometric-auth-result authentication-options)))))
|
||||
|
||||
(fx/defn on-going-in-background [{:keys [db now]}]
|
||||
{:db (-> db
|
||||
(dissoc :app-active-since)
|
||||
(assoc :app-in-background-since now))})
|
||||
|
||||
(defn app-state-change [state {:keys [db] :as cofx}]
|
||||
(let [app-coming-from-background? (= state "active")
|
||||
app-going-in-background? (= state "background")]
|
||||
(fx/merge cofx
|
||||
{::app-state-change-fx state
|
||||
:db (assoc db :app-state state)}
|
||||
#(when app-coming-from-background?
|
||||
(on-return-from-background %))
|
||||
#(when app-going-in-background?
|
||||
(on-going-in-background %)))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:app-state-change
|
||||
(fn [cofx [_ state]]
|
||||
(app-state-change state cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:request-permissions
|
||||
(fn [_ [_ options]]
|
||||
{:request-permissions-fx options}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-swipe-position
|
||||
(fn [{:keys [db]} [_ type item-id value]]
|
||||
{:db (assoc-in db [:animations type item-id :delete-swiped] value)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:update-window-dimensions
|
||||
(fn [{:keys [db]} [_ dimensions]]
|
||||
{:db (assoc db :dimensions/window (dimensions/window dimensions))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-two-pane-ui-enabled
|
||||
(fn [{:keys [db]} [_ enabled?]]
|
||||
{:db (assoc db :two-pane-ui-enabled? enabled?)}))
|
||||
|
||||
;; NOTE: Will be removed with the keycard PR
|
||||
(handlers/register-handler-fx
|
||||
:screens/on-will-focus
|
||||
(fn [{:keys [db] :as cofx} [_ view-id]]
|
||||
(fx/merge cofx
|
||||
#(case view-id
|
||||
:keycard-settings (hardwallet/settings-screen-did-load %)
|
||||
:reset-card (hardwallet/reset-card-screen-did-load %)
|
||||
:enter-pin-settings (hardwallet/enter-pin-screen-did-load %)
|
||||
:keycard-login-pin (hardwallet/enter-pin-screen-did-load %)
|
||||
:add-new-account-pin (hardwallet/enter-pin-screen-did-load %)
|
||||
:hardwallet-authentication-method (hardwallet/authentication-method-screen-did-load %)
|
||||
;; We need this as if you click on universal-links you transition
|
||||
;; from chat to chat, and therefore we won't be loading new
|
||||
;; messages
|
||||
:chat (chat.loading/load-messages %)
|
||||
:multiaccounts (hardwallet/multiaccounts-screen-did-load %)
|
||||
nil))))
|
@ -2,7 +2,7 @@
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.chat.models.message :as models.message]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.data-store.chats :as chats-store]
|
||||
[status-im.utils.fx :as fx]))
|
||||
|
@ -1,4 +0,0 @@
|
||||
(ns status-im.ui.screens.group.db
|
||||
(:require [cljs.spec.alpha :as spec]))
|
||||
|
||||
(spec/def :group/selected-contacts (spec/nilable (spec/coll-of string? :kind set?)))
|
@ -41,7 +41,9 @@
|
||||
[react/i18n-text {:style styles/welcome-text-description
|
||||
:key :welcome-to-status-description}]]
|
||||
[react/view {:align-items :center :margin-bottom 50}
|
||||
[components.common/button {:on-press #(re-frame/dispatch [:navigate-reset :tabs])
|
||||
[components.common/button {:on-press
|
||||
#(re-frame/dispatch [:navigate-reset {:index 0
|
||||
:routes [{:name :tabs}]}])
|
||||
:accessibility-label :lets-go-button
|
||||
:label (i18n/label :t/lets-go)}]]])
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
(ns status-im.ui.screens.intro.db
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
status-im.multiaccounts.db))
|
||||
|
||||
(spec/def :intro-wizrad/encrypt-with-password? boolean?)
|
||||
(spec/def :intro-wizard/multiaccounts
|
||||
(spec/coll-of :multiaccounts/generated-multiaccount))
|
||||
(spec/def :intro-wizard/selected-storage-type? keyword?)
|
||||
(spec/def :intro-wizard/selected-id :generated-multiaccounts/id)
|
||||
(spec/def :intro-wizard/back-action keyword?)
|
||||
(spec/def :intro-wizard/weak-password? boolean?)
|
||||
(spec/def :intro-wizard/forward-action keyword?)
|
||||
(spec/def :intro-wizard/step (spec/nilable keyword?))
|
||||
(spec/def :intro-wizard/root-key :multiaccounts/generated-multiaccount)
|
||||
(spec/def :intro-wizard/passphrase string?)
|
||||
(spec/def :intro-wizard/recovering? boolean?)
|
||||
(spec/def :intro-wizard/passphrase-word-count (spec/nilable int?))
|
||||
(spec/def :intro-wizard/derived :generated-multiaccounts/derived)
|
||||
(spec/def :intro-wizard/next-button-disabled? boolean?)
|
||||
|
||||
(spec/def :intro-wizard/intro-wizard
|
||||
(spec/keys :req-un [:intro-wizrad/encrypt-with-password?
|
||||
:intro-wizard/back-action
|
||||
:intro-wizard/weak-password?
|
||||
:intro-wizard/forward-action
|
||||
:intro-wizard/step]
|
||||
:opt-un [:intro-wizard/selected-id
|
||||
:intro-wizard/selected-storage-type?
|
||||
:intro-wizard/multiaccounts
|
||||
:intro-wizard/root-key
|
||||
:intro-wizard/passphrase
|
||||
:intro-wizard/passphrase-word-count
|
||||
:intro-wizard/derived
|
||||
:intro-wizard/next-button-disabled?]))
|
@ -5,7 +5,7 @@
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.ui.components.bottom-sheet.core :as bottom-sheet]
|
||||
[status-im.multiaccounts.model :as multiaccounts.model]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.ui.screens.mobile-network-settings.utils :as utils]))
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
(ns status-im.ui.screens.profile.db
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
[clojure.string :as string]
|
||||
(:require [clojure.string :as string]
|
||||
[status-im.chat.constants :as chat.constants]))
|
||||
|
||||
(defn correct-name? [username]
|
||||
@ -17,16 +16,4 @@
|
||||
|
||||
(defn base64-encoded-image-path? [photo-path]
|
||||
(or (base64-png? photo-path)
|
||||
(base64-jpeg? photo-path)))
|
||||
|
||||
(spec/def :profile/name correct-name?)
|
||||
(spec/def :profile/status (spec/nilable string?))
|
||||
(spec/def :profile/photo-path (spec/nilable base64-encoded-image-path?))
|
||||
(spec/def :profile/photo-added? (spec/nilable boolean?))
|
||||
|
||||
(spec/def :my-profile/default-name (spec/nilable string?))
|
||||
(spec/def :my-profile/editing? (spec/nilable boolean?))
|
||||
(spec/def :my-profile/advanced? (spec/nilable boolean?))
|
||||
(spec/def :my-profile/seed (spec/nilable map?))
|
||||
(spec/def :my-profile/profile (spec/keys :opt-un [::name :profile/status :profile/photo-path
|
||||
::edit-status? ::valid-name?]))
|
||||
(base64-jpeg? photo-path)))
|
@ -2,7 +2,6 @@
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.multiaccounts.model :as multiaccounts.model]
|
||||
[status-im.ui.screens.profile.models :as profile.models]
|
||||
[status-im.ui.screens.profile.navigation]
|
||||
[status-im.ui.components.list-selection :as list-selection]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.identicon :as identicon]
|
||||
|
@ -3,7 +3,6 @@
|
||||
[clojure.string :as clojure.string]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.screens.profile.navigation]
|
||||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[status-im.chat.models :as chat-models]
|
||||
[status-im.utils.image-processing :as image-processing]
|
||||
|
@ -1,6 +0,0 @@
|
||||
(ns status-im.ui.screens.profile.navigation
|
||||
(:require [status-im.ui.screens.navigation :as navigation]))
|
||||
|
||||
(defmethod navigation/unload-data! :my-profile
|
||||
[db]
|
||||
(dissoc db :my-profile/editing?))
|
@ -1,84 +1,8 @@
|
||||
(ns status-im.utils.handlers
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
[re-frame.core :as re-frame]
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[re-frame.interceptor :refer [->interceptor get-coeffect get-effect]]
|
||||
[status-im.multiaccounts.model :as multiaccounts.model]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defn- pretty-print-event [ctx]
|
||||
(let [[first _] (get-coeffect ctx :event)]
|
||||
first))
|
||||
|
||||
(def debug-handlers-names
|
||||
"Interceptor which logs debug information to js/console for each event."
|
||||
(->interceptor
|
||||
:id :debug-handlers-names
|
||||
:before (fn debug-handlers-names-before
|
||||
[context]
|
||||
(log/debug "Handling re-frame event: " (pretty-print-event context))
|
||||
context)))
|
||||
|
||||
(def logged-in
|
||||
"Interceptor which stops the event chain if the user is logged out"
|
||||
(->interceptor
|
||||
:id :logged-in
|
||||
:before (fn logged-in-before
|
||||
[context]
|
||||
(when (multiaccounts.model/logged-in? (:coeffects context))
|
||||
context))))
|
||||
|
||||
(defn- check-spec-msg-path-problem [problem]
|
||||
(str "Spec: " (-> problem :via last) "\n"
|
||||
"Predicate: " (subs (str (:pred problem)) 0 50)))
|
||||
|
||||
(defn- check-spec-msg-path-problems [path path-problems]
|
||||
(str "Key path: " path "\n"
|
||||
"Val: " (pr-str (-> path-problems first :val)) "\n\n"
|
||||
"Number of problems: " (count path-problems) "\n\n"
|
||||
(->> path-problems
|
||||
(map check-spec-msg-path-problem)
|
||||
(interpose "\n\n")
|
||||
(apply str))))
|
||||
|
||||
(defn- check-spec-msg [event-id db]
|
||||
(let [explain-data (spec/explain-data :status-im.ui.screens.db/db db)
|
||||
problems (::spec/problems explain-data)
|
||||
db-root-keys (->> problems (map (comp first :in)) set)
|
||||
heading #(str "\n\n------\n" % "\n------\n\n")
|
||||
msg (str "re-frame db spec check failed."
|
||||
(heading "SUMMARY")
|
||||
"After event id: " event-id "\n"
|
||||
"Number of problems: " (count problems) "\n\n"
|
||||
"Failing root db keys:\n"
|
||||
(->> db-root-keys (interpose "\n") (apply str))
|
||||
(heading "PROBLEMS")
|
||||
(->> problems
|
||||
(group-by :in)
|
||||
(map (fn [[path path-problems]]
|
||||
(check-spec-msg-path-problems path path-problems)))
|
||||
(interpose "\n\n-----\n\n")
|
||||
(apply str)))]
|
||||
msg))
|
||||
|
||||
(def check-spec
|
||||
"throw an exception if db doesn't match the spec"
|
||||
(->interceptor
|
||||
:id check-spec
|
||||
:after
|
||||
(fn check-handler
|
||||
[context]
|
||||
(let [new-db (get-effect context :db)
|
||||
event-id (-> (get-coeffect context :event) first)]
|
||||
(when (and new-db (not (spec/valid? :status-im.ui.screens.db/db new-db)))
|
||||
(throw (ex-info (check-spec-msg event-id new-db) {})))
|
||||
context))))
|
||||
|
||||
(def default-interceptors
|
||||
[debug-handlers-names
|
||||
(when js/goog.DEBUG
|
||||
check-spec)
|
||||
(re-frame/inject-cofx :now)])
|
||||
|
||||
(defn- parse-json
|
||||
;; NOTE(dmitryn) Expects JSON response like:
|
||||
;; {"error": "msg"} or {"result": true}
|
||||
@ -107,8 +31,24 @@
|
||||
(error-fn error)
|
||||
(success-fn result)))))
|
||||
|
||||
(defn- pretty-print-event [ctx]
|
||||
(let [[first _] (get-coeffect ctx :event)]
|
||||
first))
|
||||
|
||||
(def debug-handlers-names
|
||||
"Interceptor which logs debug information to js/console for each event."
|
||||
(->interceptor
|
||||
:id :debug-handlers-names
|
||||
:before (fn debug-handlers-names-before
|
||||
[context]
|
||||
(log/debug "Handling re-frame event: " (pretty-print-event context))
|
||||
context)))
|
||||
|
||||
(defn register-handler-fx
|
||||
([name handler]
|
||||
(register-handler-fx name nil handler))
|
||||
([name interceptors handler]
|
||||
(re-frame/reg-event-fx name [default-interceptors interceptors] handler)))
|
||||
(re-frame/reg-event-fx
|
||||
name
|
||||
[debug-handlers-names (re-frame/inject-cofx :now) interceptors]
|
||||
handler)))
|
||||
|
@ -12,7 +12,7 @@
|
||||
[status-im.ui.components.list-selection :as list-selection]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.screens.add-new.new-chat.db :as new-chat.db]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.wallet.choose-recipient.core :as choose-recipient]))
|
||||
|
@ -10,7 +10,7 @@
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.components.list-selection :as list-selection]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.wallet.core :as wallet]
|
||||
|
@ -8,7 +8,7 @@
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.utils.money :as money]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[clojure.string :as string]
|
||||
[status-im.ethereum.stateofus :as stateofus]))
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.ethereum.tokens :as tokens]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.utils.core :as utils.core]
|
||||
[status-im.utils.fx :as fx]
|
||||
|
@ -9,7 +9,7 @@
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.money :as money]
|
||||
[status-im.wallet.core :as wallet]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.wallet.prices :as prices]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
|
@ -1,41 +1,8 @@
|
||||
(ns status-im.wallet.db
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
[status-im.i18n :as i18n]
|
||||
(:require [status-im.i18n :as i18n]
|
||||
[status-im.utils.money :as money]
|
||||
[status-im.utils.priority-map :refer [empty-transaction-map]]))
|
||||
|
||||
(spec/def :wallet.send/recipient string?)
|
||||
|
||||
(spec/def :wallet/send (spec/keys :req-un [:wallet.send/recipient]))
|
||||
|
||||
(spec/def :wallet/balance-loading? (spec/nilable boolean?))
|
||||
|
||||
;; TODO these key specs are not needed, they don't do anything
|
||||
(spec/def :wallet/errors any?)
|
||||
(spec/def :wallet/transactions any?)
|
||||
(spec/def :wallet/transactions-queue any?)
|
||||
(spec/def :wallet/edit any?)
|
||||
(spec/def :wallet/current-tab any?)
|
||||
(spec/def :wallet/current-transaction any?)
|
||||
(spec/def :wallet/modal-history? any?)
|
||||
(spec/def :wallet/visible-tokens any?)
|
||||
(spec/def :wallet/currency any?)
|
||||
(spec/def :wallet/balance any?)
|
||||
(spec/def :wallet/filters set?)
|
||||
|
||||
(spec/def :wallet/wallet (spec/keys :opt-un [:wallet/transactions-queue
|
||||
:wallet/balance-loading?
|
||||
:wallet/errors
|
||||
:wallet/transactions
|
||||
:wallet/edit
|
||||
:wallet/filters
|
||||
:wallet/current-tab
|
||||
:wallet/current-transaction
|
||||
:wallet/modal-history?
|
||||
:wallet/visible-tokens
|
||||
:wallet/currency
|
||||
:wallet/balance]))
|
||||
|
||||
(defn- too-precise-amount?
|
||||
"Checks if number has any extra digit beyond the allowed number of decimals.
|
||||
It does so by checking the number against its rounded value."
|
||||
|
Loading…
x
Reference in New Issue
Block a user