extract React Native dependencies

This commit is contained in:
Roman Volosovskyi 2017-07-16 12:04:35 +03:00
parent bd80c814c9
commit 23399c63e1
65 changed files with 409 additions and 321 deletions

5
Jenkinsfile vendored
View File

@ -20,6 +20,11 @@ node {
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') {
sh 'lein prod-build'
}

View File

@ -17,12 +17,12 @@
[lein-re-frisk "0.4.7"]
[rasom/lein-externs "0.1.7"]]
:clean-targets ["target/" "index.ios.js" "index.android.js"]
:aliases {"prod-build" ^{:doc "Recompile code with prod profile."}
["do" "clean"
["with-profile" "prod" "cljsbuild" "once" "ios"]
["with-profile" "prod" "cljsbuild" "once" "android"]]
:aliases {"prod-build" ^{:doc "Recompile code with prod profile."}
["do" "clean"
["with-profile" "prod" "cljsbuild" "once" "ios"]
["with-profile" "prod" "cljsbuild" "once" "android"]]
"generate-externs" ["with-profile" "prod" "externs" "android" "externs/externs.js"]
"test" ["doo" "phantom" "test" "once"]}
"test-cljs" ["with-profile" "test" "doo" "node" "test" "once"]}
:test-paths ["test/clj"]
:figwheel {:nrepl-port 7888}
:profiles {:dev {:dependencies [[figwheel-sidecar "0.5.11"]
@ -31,34 +31,37 @@
[com.cemerick/piggieback "0.2.1"]
[io.appium/java-client "3.4.1"]
[hawk "0.2.10"]]
:plugins [[lein-doo "0.1.7"]]
:source-paths ["src" "env/dev"]
:cljsbuild {:builds
{:ios
{:source-paths ["src" "env/dev"]
{:source-paths ["react-native/src" "src" "env/dev"]
:figwheel true
:compiler {:output-to "target/ios/app.js"
:main "env.ios.main"
:output-dir "target/ios"
:optimizations :none}}
:android
{:source-paths ["src" "env/dev"]
{:source-paths ["react-native/src" "src" "env/dev"]
:figwheel true
:compiler {:output-to "target/android/app.js"
:main "env.android.main"
:output-dir "target/android"
:optimizations :none}}
:test
{:source-paths ["src" "test/cljs"]
:compiler {:main status-im.test.runner
:output-to "target/test/test.js"
:output-dir "target"
:optimizations :none}}}}
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]
:timeout 240000}}
:test {:plugins [[lein-doo "0.1.7"]]
:cljsbuild {:builds
[{:id "test"
:source-paths ["src" "test/cljs"]
:compiler
{:main status-im.test.runner
:output-to "target/test/test.js"
:output-dir "target/test"
:optimizations :none
:target :nodejs}}]}}
:prod {:cljsbuild {:builds
{:ios
{:source-paths ["src" "env/prod"]
{:source-paths ["react-native/src" "src" "env/prod"]
:compiler {:output-to "index.ios.js"
:main "env.ios.main"
:output-dir "target/ios-prod"
@ -67,9 +70,9 @@
:optimizations :advanced
:externs ["externs/externs.js"]
:closure-defines {"goog.DEBUG" false}
:parallel-build true}}
:parallel-build true}}
:android
{:source-paths ["src" "env/prod"]
{:source-paths ["react-native/src" "src" "env/prod"]
:compiler {:output-to "index.android.js"
:main "env.android.main"
:output-dir "target/android-prod"
@ -78,4 +81,4 @@
:optimizations :advanced
:externs ["externs/externs.js"]
:closure-defines {"goog.DEBUG" false}
:parallel-build true}}}}}})
:parallel-build true}}}}}})

View File

@ -0,0 +1,5 @@
(ns cljsjs.react
(:require [status-im.react-native.js-dependencies :as rn-dependencies]))
(when (exists? js/window)
(set! js/ReactNative rn-dependencies/react-native))

View File

@ -0,0 +1,35 @@
(ns status-im.react-native.js-dependencies)
(def action-button (js/require "react-native-action-button"))
(def android-sms-listener (js/require "react-native-android-sms-listener"))
(def autolink (js/require "react-native-autolink"))
(def camera (js/require "react-native-camera"))
(def circle-checkbox (js/require "react-native-circle-checkbox"))
;; TODO see https://github.com/rt2zz/react-native-contacts/issues/45
(def contacts (js/require "react-native-contacts"))
(def dialogs (js/require "react-native-dialogs"))
(def dismiss-keyboard (js/require "dismissKeyboard"))
(def drawer (js/require "react-native-drawer-layout"))
(def emoji-picker (js/require "react-native-emoji-picker"))
(def fs (js/require "react-native-fs"))
(def http-bridge (js/require "react-native-http-bridge"))
(def i18n (js/require "react-native-i18n"))
(def image-crop-picker (js/require "react-native-image-crop-picker"))
(def image-resizer (js/require "react-native-image-resizer"))
(def instabug (js/require "instabug-reactnative"))
(def invertible-scroll-view (js/require "react-native-invertible-scroll-view"))
(def linear-gradient (js/require "react-native-linear-gradient"))
(def mapbox-gl (js/require "react-native-mapbox-gl"))
(def nfc (js/require "nfc-react-native"))
(def orientation (js/require "react-native-orientation"))
(def popup-menu (js/require "react-native-popup-menu"))
(def qr-code (js/require "react-native-qrcode"))
(def random-bytes (js/require "react-native-randombytes"))
(def react-native (js/require "react-native"))
(def realm (js/require "realm"))
(def sortable-listview (js/require "react-native-sortable-listview"))
(def swiper (js/require "react-native-swiper"))
(def vector-icons (js/require "react-native-vector-icons/Ionicons"))
(def webview-bridge (js/require "react-native-webview-bridge"))

View File

@ -0,0 +1,29 @@
(ns status-im.react-native.resources)
(def add-icon (js/require "./images/add.png"))
(def att (js/require "./images/att.png"))
(def chat-icon (js/require "./images/chat.png"))
(def icon-close-gray (js/require "./images/icon_close_gray.png"))
(def logo-icon (js/require "./images/logo.png"))
(def nav-back-icon (js/require "./images/nav-back.png"))
(def user-no-photo (js/require "./images/no-photo.png"))
(def online-icon (js/require "./images/online.png"))
(def play (js/require "./images/play.png"))
(def trash-icon (js/require "./images/trash.png"))
(def v (js/require "./images/v.png"))
(def contacts
{:auction-house (js/require "./images/contacts/auction-house.png")
:mkr-market (js/require "./images/contacts/mkr-market.png")
:oaken-water-meter (js/require "./images/contacts/oaken-water-meter.png")
:flight-delays-suck (js/require "./images/contacts/flight-delays-suck.png")
:jarrad (js/require "./images/contacts/jarrad.png")
:firstblood (js/require "./images/contacts/FirstBlood.png")
:gnosis (js/require "./images/contacts/gnosis.png")
:melonport (js/require "./images/contacts/melonport.png")
:bchat (js/require "./images/contacts/bchat.png")
:dentacoin (js/require "./images/contacts/Dentacoin.png")
:augur (js/require "./images/contacts/augur.png")
:ethlance (js/require "./images/contacts/ethlance.png")
:commiteth (js/require "./images/contacts/commiteth.png")
:etherplay (js/require "./images/contacts/etherplay.png")})

View File

@ -1,4 +0,0 @@
(ns cljsjs.react)
(when (exists? js/window)
(set! js/ReactNative (js/require "react-native")))

View File

@ -1,5 +1,6 @@
(ns status-im.android.platform
(:require [status-im.components.styles :as styles]))
(:require [status-im.components.styles :as styles]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def component-styles
{:status-bar {:default {:height 25
@ -59,10 +60,8 @@
;; Dialogs
(def react-native-dialogs (js/require "react-native-dialogs"))
(defn show-dialog [{:keys [title options callback]}]
(let [dialog (new react-native-dialogs)]
(let [dialog (new rn-dependencies/dialogs)]
(.set dialog (clj->js {:title title
:items (mapv :text options)
:itemsCallback callback}))

View File

@ -14,8 +14,6 @@
[cljs.reader :refer [read-string]]
[status-im.navigation.handlers :as nav]))
(def web3 (js/require "web3"))
(defn by-public-key [public-key contacts]
(when-let [{:keys [address]} (contacts public-key)]
(when address {:address address})))

View File

@ -8,6 +8,7 @@
[status-im.utils.phone-number :as phone-number]
[status-im.chat.utils :as chat-utils]
[status-im.bots.constants :as bots-constants]
[status-im.js-dependencies :as dependencies]
[taoensso.timbre :as log]))
(defn text->emoji
@ -17,7 +18,7 @@
(str/replace text
#":([a-z_\-+0-9]*):"
(fn [[original emoji-id]]
(if-let [emoji-map (aget rc/emojilib "lib" emoji-id)]
(if-let [emoji-map (aget dependencies/emojis "lib" emoji-id)]
(aget emoji-map "char")
original)))))
@ -266,4 +267,4 @@
(proceed)
(set-errors [validation-message
{:title (i18n/label :t/phone-number)
:description (i18n/label :t/invalid-phone)}]))))
:description (i18n/label :t/invalid-phone)}]))))

View File

@ -23,7 +23,7 @@
[status-im.chat.views.message.datemark :refer [chat-datemark]]
[status-im.models.commands :refer [parse-command-message-content
parse-command-request]]
[status-im.resources :as res]
[status-im.react-native.resources :as res]
[status-im.constants :refer [console-chat-id
wallet-chat-id
text-content-type

View File

@ -1,13 +1,13 @@
(ns status-im.components.camera
(:require [reagent.core :as r]
[clojure.walk :refer [keywordize-keys]]
[status-im.utils.platform :as platform]))
[status-im.utils.platform :as platform]
[status-im.react-native.js-dependencies :as rn-dependecies]))
(def camera-class (js/require "react-native-camera"))
(def camera-default (.-default camera-class))
(def default-camera (.-default rn-dependecies/camera))
(defn constants [t]
(-> (aget camera-default "constants" t)
(-> (aget rn-dependecies/camera "constants" t)
(js->clj)
(keywordize-keys)))
@ -17,9 +17,9 @@
(defn request-access [callback]
(if platform/android?
(callback true)
(-> (.checkVideoAuthorizationStatus camera-default)
(-> (.checkVideoAuthorizationStatus default-camera)
(.then #(callback %))
(.catch #(callback false)))))
(defn camera [props]
(r/create-element camera-default (clj->js (merge {:inverted true} props))))
(r/create-element default-camera (clj->js (merge {:inverted true} props))))

View File

@ -6,11 +6,12 @@
text]]
[status-im.components.carousel.styles :as st]
[taoensso.timbre :as log]
[status-im.components.react :as r]))
[status-im.components.react :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn window-page-width []
(.-width (.get (.. r/react-native -Dimensions) "window")))
(.-width (.get (.. rn-dependencies/react-native -Dimensions) "window")))
(def defaults {:gap 8
:sneak 8

View File

@ -7,7 +7,7 @@
icon]]
[status-im.components.chat-icon.styles :as st]
[status-im.components.styles :refer [default-chat-color]]
[status-im.resources :as resources]
[status-im.react-native.resources :as resources]
[status-im.constants :refer [console-chat-id]]
[clojure.string :as s]))
@ -159,4 +159,4 @@
edit? :edit?}]
(let [color default-chat-color
size (if edit? 70 56)]
[profile-icon-view photo-path name color edit? size]))
[profile-icon-view photo-path name color edit? size]))

View File

@ -4,12 +4,11 @@
[status-im.i18n :refer [label]]
[status-im.utils.platform :refer [platform-specific ios?]]
[re-frame.core :refer [dispatch]]
[status-im.components.react :refer [view touchable-highlight text]]))
(def react-native-popup-menu (js/require "react-native-popup-menu"))
[status-im.components.react :refer [view touchable-highlight text]]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn get-property [name]
(aget react-native-popup-menu name))
(aget rn-dependencies/popup-menu name))
(defn adapt-class [class]
(when class

View File

@ -1,5 +1,6 @@
(ns status-im.components.icons.custom-icons
(:require [reagent.core :as r]))
(:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def ion-icon
(r/adapt-react-class (.-default (js/require "react-native-vector-icons/Ionicons"))))
(r/adapt-react-class (.-default rn-dependencies/vector-icons)))

View File

@ -1,8 +1,8 @@
(ns status-im.components.invertible-scroll-view
(:require [reagent.core :as r]))
(def class (js/require "react-native-invertible-scroll-view"))
(:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn invertible-scroll-view [props]
(r/create-element class (clj->js (merge {:inverted true} props))))
(r/create-element rn-dependencies/invertible-scroll-view
(clj->js (merge {:inverted true} props))))

View File

@ -1,5 +1,6 @@
(ns status-im.components.item-checkbox
(:require [reagent.core :as r]))
(:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def item-checkbox (r/adapt-react-class (js/require "react-native-circle-checkbox")))
(def item-checkbox rn-dependencies/camera)

View File

@ -4,12 +4,11 @@
[status-im.i18n :refer [label]]
[status-im.utils.platform :refer [platform-specific ios?]]
[re-frame.core :refer [dispatch]]
[status-im.components.react :refer [view touchable-highlight text]]))
(def react-native-mapbox-gl (js/require "react-native-mapbox-gl"))
[status-im.components.react :refer [view touchable-highlight text]]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn get-property [name]
(aget react-native-mapbox-gl name))
(aget rn-dependencies/mapbox-gl name))
(defn adapt-class [class]
(when class
@ -18,6 +17,6 @@
(defn get-class [name]
(adapt-class (get-property name)))
(.setAccessToken react-native-mapbox-gl "pk.eyJ1Ijoic3RhdHVzaW0iLCJhIjoiY2oydmtnZjRrMDA3czMzcW9kemR4N2lxayJ9.Rz8L6xdHBjfO8cR3CDf3Cw")
(.setAccessToken rn-dependencies/mapbox-gl "pk.eyJ1Ijoic3RhdHVzaW0iLCJhIjoiY2oydmtnZjRrMDA3czMzcW9kemR4N2lxayJ9.Rz8L6xdHBjfO8cR3CDf3Cw")
(def mapview (get-class "MapView"))

View File

@ -1,7 +1,10 @@
(ns status-im.components.native-action-button
(:require [reagent.core :as r]))
(:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def class (js/require "react-native-action-button"))
(def native-action-button
(r/adapt-react-class (.-default rn-dependencies/action-button)))
(def native-action-button (r/adapt-react-class (.-default class)))
(def native-action-button-item (r/adapt-react-class (.. class -default -Item)))
(def native-action-button-item
(r/adapt-react-class (.. rn-dependencies/action-button -default -Item)))

View File

@ -1,30 +1,27 @@
(ns status-im.components.nfc
(:require [cljs.spec.alpha :as s]
[status-im.utils.platform :as platform]))
(def class
(when platform/android?
(js/require "nfc-react-native")))
[status-im.utils.platform :as platform]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def android-only-error "NFC API is available only on Android")
(defn get-card-id [on-success on-error]
(if platform/android?
(-> (.getCardId class)
(-> (.getCardId rn-dependencies/nfc)
(.then on-success)
(.catch on-error))
(on-error android-only-error)))
(defn read-tag [sectors on-success on-error]
(if platform/android?
(-> (.readTag class (clj->js sectors))
(-> (.readTag rn-dependencies/nfc (clj->js sectors))
(.then on-success)
(.catch on-error))
(on-error android-only-error)))
(defn write-tag [sectors card-id on-success on-error]
(if platform/android?
(-> (.writeTag class (clj->js sectors) card-id)
(-> (.writeTag rn-dependencies/nfc (clj->js sectors) card-id)
(.then on-success)
(.catch on-error))
(on-error android-only-error)))

View File

@ -1,8 +1,9 @@
(ns status-im.components.permissions
(:require [status-im.utils.platform :as platform]
[taoensso.timbre :as log]))
[taoensso.timbre :as log]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def permissions-class (.-PermissionsAndroid js/ReactNative))
(def permissions-class (.-PermissionsAndroid rn-dependencies/react-native))
(def permissions-map
{:read-external-storage "android.permission.READ_EXTERNAL_STORAGE"

View File

@ -1,9 +1,8 @@
(ns status-im.components.qr-code
(:require [reagent.core :as r]))
(def class (js/require "react-native-qrcode"))
(:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn qr-code [props]
(r/create-element
class
(clj->js (merge {:inverted true} props))))
rn-dependencies/qr-code
(clj->js (merge {:inverted true} props))))

View File

@ -1,18 +1,29 @@
(ns status-im.components.react
(:require [reagent.core :as r]
[status-im.components.styles :as st]
[status-im.utils.utils :as u
:refer [get-react-property get-class adapt-class]]
[status-im.utils.utils :as u]
[status-im.utils.platform :refer [platform-specific ios?]]
[status-im.i18n :as i18n]))
[status-im.i18n :as i18n]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def react-native (js/require "react-native"))
(def native-modules (.-NativeModules react-native))
(def device-event-emitter (.-DeviceEventEmitter react-native))
(def dismiss-keyboard! (js/require "dismissKeyboard"))
(def orientation (js/require "react-native-orientation"))
(defn get-react-property [name]
(if rn-dependencies/react-native
(aget rn-dependencies/react-native name)
#js {}))
(defn adapt-class [class]
(when class
(r/adapt-react-class class)))
(defn get-class [name]
(adapt-class (get-react-property name)))
(def native-modules (.-NativeModules rn-dependencies/react-native))
(def device-event-emitter (.-DeviceEventEmitter rn-dependencies/react-native))
(def dismiss-keyboard! rn-dependencies/dismiss-keyboard)
(def orientation rn-dependencies/orientation)
(def back-android (get-react-property "BackAndroid"))
(def drawer (js/require "react-native-drawer-layout"))
(def drawer rn-dependencies/drawer)
(def splash-screen (.-SplashScreen native-modules))
@ -20,6 +31,7 @@
(def app-registry (get-react-property "AppRegistry"))
(def app-state (get-react-property "AppState"))
(def net-info (get-react-property "NetInfo"))
(def navigator (get-class "Navigator"))
(def view (get-class "View"))
@ -43,14 +55,14 @@
(def modal (get-class "Modal"))
(def picker (get-class "Picker"))
(def pan-responder (.-PanResponder js/ReactNative))
(def animated (.-Animated js/ReactNative))
(def pan-responder (.-PanResponder rn-dependencies/react-native))
(def animated (.-Animated rn-dependencies/react-native))
(def animated-view (r/adapt-react-class (.-View animated)))
(def animated-text (r/adapt-react-class (.-Text animated)))
(def dimensions (.-Dimensions js/ReactNative))
(def keyboard (.-Keyboard react-native))
(def linking (.-Linking js/ReactNative))
(def dimensions (.-Dimensions rn-dependencies/react-native))
(def keyboard (.-Keyboard rn-dependencies/react-native))
(def linking (.-Linking rn-dependencies/react-native))
(def slider (get-class "Slider"))
;; Accessor methods for React Components
@ -108,17 +120,17 @@
(defn get-dimensions [name]
(js->clj (.get dimensions name) :keywordize-keys true))
(def gradient (adapt-class (.-default rn-dependencies/linear-gradient)))
(defn linear-gradient [props]
(let [class (js/require "react-native-linear-gradient")
gradient (adapt-class (.-default class))]
[gradient props]))
[gradient props])
(defn list-item [component]
(r/as-element component))
;; Image picker
(def image-picker-class (js/require "react-native-image-crop-picker"))
(def image-picker-class rn-dependencies/image-crop-picker)
(defn show-access-error [o]
(when (= "ERROR_PICKER_UNAUTHORIZED_KEY" (aget o "code")) ; Do not show error when user cancel selection
@ -132,19 +144,19 @@
(.then images-fn)
(.catch show-access-error))))
(def swiper (adapt-class (js/require "react-native-swiper")))
(def swiper (adapt-class rn-dependencies/swiper))
;; Clipboard
(def sharing
(.-Share js/ReactNative))
(.-Share rn-dependencies/react-native))
(defn copy-to-clipboard [text]
(.setString (.-Clipboard react-native) text))
(.setString (.-Clipboard rn-dependencies/react-native) text))
;; Emoji
(def emoji-picker-class (js/require "react-native-emoji-picker"))
(def emoji-picker-class rn-dependencies/emoji-picker)
(def emoji-picker
(let [emoji-picker (.-default emoji-picker-class)]
@ -152,7 +164,7 @@
;; Autolink
(def autolink-class (r/adapt-react-class (.-default (js/require "react-native-autolink"))))
(def autolink-class (r/adapt-react-class (.-default rn-dependencies/autolink)))
(defn autolink [opts]
(r/as-element
@ -160,8 +172,7 @@
;; HTTP Bridge
(def http-bridge
(js/require "react-native-http-bridge"))
(def http-bridge rn-dependencies/http-bridge)
;; KeyboardAvoidingView

View File

@ -2,12 +2,14 @@
(:require [reagent.core :as r]
[status-im.components.react :refer [view
touchable-highlight
list-item]]))
list-item]]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def sortable-list-view-class (r/adapt-react-class (js/require "react-native-sortable-listview")))
(def sortable-listview-class
(r/adapt-react-class rn-dependencies/sortable-listview))
(defn sortable-list-view [{:keys [on-row-moved render-row] :as props}]
[sortable-list-view-class
[sortable-listview-class
(assoc props :on-row-moved #(on-row-moved (js->clj % :keywordize-keys true))
:render-row #(render-row (js->clj % :keywordize-keys true)))])
@ -17,4 +19,4 @@
inner]])
(defn sortable-item [inner]
(list-item [touchable inner]))
(list-item [touchable inner]))

View File

@ -7,9 +7,9 @@
[taoensso.timbre :as log]
[cljs.core.async :refer [<! timeout]]
[status-im.utils.js-resources :as js-res]
[status-im.i18n :as i]
[status-im.utils.platform :as p]
[status-im.utils.scheduler :as scheduler]))
[status-im.utils.scheduler :as scheduler]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn cljs->json [data]
(.stringify js/JSON (clj->js data)))
@ -48,11 +48,11 @@
(recur (<! (timeout 500))))))
(def status
(when (exists? (.-NativeModules r/react-native))
(.-Status (.-NativeModules r/react-native))))
(when (exists? (.-NativeModules rn-dependencies/react-native))
(.-Status (.-NativeModules rn-dependencies/react-native))))
(defn init-jail []
(let [init-js (str js-res/status-js "I18n.locale = '" i/i18n.locale "';")]
(let [init-js (str js-res/status-js "I18n.locale = '" rn-dependencies/i18n.locale "';")]
(.initJail status init-js #(log/debug "jail initialized"))))
(defonce listener-initialized (atom false))
@ -145,7 +145,7 @@
(log/debug :call-jail :params params)
(let [params' (update params :context assoc
:debug js/goog.DEBUG
:locale i/i18n.locale)
:locale rn-dependencies/i18n.locale)
cb (fn [r]
(let [{:keys [result] :as r'} (t/json->clj r)
{:keys [messages]} result]

View File

@ -2,8 +2,7 @@
(:require [clojure.string :as s]
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
[reagent.core :as r]
[status-im.components.react :refer [react-native
view
[status-im.components.react :refer [view
text
animated-text
animated-view

View File

@ -1,8 +1,9 @@
(ns status-im.components.webview-bridge
(:require [reagent.core :as r]))
(:require [reagent.core :as r]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def webview-bridge-class
(r/adapt-react-class (.-default (js/require "react-native-webview-bridge"))))
(r/adapt-react-class (.-default rn-dependencies/webview-bridge)))
(defn webview-bridge [opts]
[webview-bridge-class opts])

View File

@ -8,13 +8,13 @@
[status-im.utils.utils :refer [http-post]]
[status-im.utils.phone-number :refer [format-phone-number]]
[status-im.utils.handlers :as u]
[status-im.utils.utils :refer [require]]
[status-im.navigation.handlers :as nav]
[status-im.utils.random :as random]
[status-im.i18n :refer [label]]
[taoensso.timbre :as log]
[cljs.reader :refer [read-string]]
[status-im.utils.js-resources :as js-res]))
[status-im.utils.js-resources :as js-res]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defmethod nav/preload-data! :group-contacts
[db [_ _ group show-search?]]
@ -122,9 +122,6 @@
(register-handler :load-contacts load-contacts!)
;; TODO see https://github.com/rt2zz/react-native-contacts/issues/45
(def react-native-contacts (js/require "react-native-contacts"))
(defn contact-name [contact]
(->> contact
((juxt :givenName :middleName :familyName))
@ -140,7 +137,7 @@
(defn fetch-contacts-from-phone!
[_ _]
(.getAll react-native-contacts
(.getAll rn-dependencies/contacts
(fn [error contacts]
(if error
(log/debug :error-on-fetching-loading error)

View File

@ -3,7 +3,6 @@
[clojure.string :as str]
[status-im.data-store.contacts :as contacts]))
(def web3 (js/require "web3"))
(defn is-address? [s]
(.isAddress web3.prototype s))

View File

@ -14,7 +14,7 @@
[status-im.components.toolbar.styles :refer [toolbar-title-container
toolbar-title-text
toolbar-background1]]
[status-im.utils.utils :refer [log http-post]]
[status-im.utils.utils :refer [http-post]]
[status-im.components.styles :refer [icon-ok
button-input-container
button-input

View File

@ -5,23 +5,23 @@
[taoensso.timbre :as log]
[status-im.utils.fs :as fs]
[clojure.string :as str]
[goog.string :as gstr])
[goog.string :as gstr]
[status-im.react-native.js-dependencies :as rn-dependencies])
(:refer-clojure :exclude [exists?]))
(def realm-class (js/require "realm"))
(defn realm-version
[file-name]
(.schemaVersion realm-class file-name))
(.schemaVersion rn-dependencies/realm file-name))
(defn open-realm
[options file-name]
(let [options (merge options {:path file-name})]
(when (cljs.core/exists? js/window)
(realm-class. (clj->js options)))))
(rn-dependencies/realm. (clj->js options)))))
(defn close [realm]
(.close realm))
(when realm
(.close realm)))
(defn migrate [file-name schemas]
(let [current-version (realm-version file-name)]
@ -37,7 +37,7 @@
(def new-account-filename "new-account")
(def base-realm (open-migrated-realm (.-defaultPath realm-class) base/schemas))
(def base-realm (open-migrated-realm (.-defaultPath rn-dependencies/realm) base/schemas))
(def account-realm (atom (open-migrated-realm new-account-filename account/schemas)))

View File

@ -30,7 +30,8 @@
[status-im.constants :refer [console-chat-id]]
[status-im.utils.ethereum-network :as enet]
[status-im.utils.instabug :as inst]
[status-im.utils.platform :as p]))
[status-im.utils.platform :as p]
[status-im.js-dependencies :as dependencies]))
;; -- Common --------------------------------------------------------------
@ -100,23 +101,23 @@
(dispatch [:load-commands!])
(when callback (callback))))))
(def ecc (js/require "eccjs"))
(register-handler :initialize-crypt
(u/side-effect!
(fn [_ _]
(log/debug "initializing crypt")
(gen-random-bytes 1024 (fn [{:keys [error buffer]}]
(if error
(do
(log/error "Failed to generate random bytes to initialize sjcl crypto")
(dispatch [:notify-user {:type :error
:error error}]))
(do
(->> (.toString buffer "hex")
(.toBits (.. ecc -sjcl -codec -hex))
(.addEntropy (.. ecc -sjcl -random)))
(dispatch [:crypt-initialized]))))))))
(gen-random-bytes
1024
(fn [{:keys [error buffer]}]
(if error
(do
(log/error "Failed to generate random bytes to initialize sjcl crypto")
(dispatch [:notify-user {:type :error
:error error}]))
(do
(->> (.toString buffer "hex")
(.toBits (.. dependencies/eccjs -sjcl -codec -hex))
(.addEntropy (.. dependencies/eccjs -sjcl -random)))
(dispatch [:crypt-initialized]))))))))
(defn node-started [_ _]
(log/debug "Started Node")

View File

@ -1,5 +1,6 @@
(ns status-im.i18n
(:require
[status-im.react-native.js-dependencies :as rn-dependencies]
[status-im.translations.af :as af]
[status-im.translations.ar :as ar]
[status-im.translations.bel :as be]
@ -48,11 +49,10 @@
[taoensso.timbre :as log]
[clojure.string :as str]))
(def i18n (js/require "react-native-i18n"))
(set! (.-fallbacks i18n) true)
(set! (.-defaultSeparator i18n) "/")
(set! (.-fallbacks rn-dependencies/i18n) true)
(set! (.-defaultSeparator rn-dependencies/i18n) "/")
(set! (.-translations i18n) (clj->js {:af af/translations
(set! (.-translations rn-dependencies/i18n) (clj->js {:af af/translations
:ar ar/translations
:be be/translations
:da da/translations
@ -124,7 +124,7 @@
(defn label-number [number]
(when number
(let [{:keys [delimiter separator]} delimeters]
(.toNumber i18n
(.toNumber rn-dependencies/i18n
(str/replace number #"," ".")
(clj->js {:precision 10
:strip_insignificant_zeros true
@ -134,14 +134,14 @@
(defn label
([path] (label path {}))
([path options]
(if (exists? i18n.t)
(if (exists? rn-dependencies/i18n.t)
(let [options (update options :amount label-number)]
(.t i18n (name path) (clj->js options)))
(.t rn-dependencies/i18n (name path) (clj->js options)))
(name path))))
(defn label-pluralize [count path & options]
(if (exists? i18n.t)
(.p i18n count (name path) (clj->js options))
(if (exists? rn-dependencies/i18n.t)
(.p rn-dependencies/i18n count (name path) (clj->js options))
(name path)))
(defn message-status-label [status]
@ -152,7 +152,7 @@
(label)))
(def locale
(.-locale i18n))
(.-locale rn-dependencies/i18n))
(defn get-contact-translated [contact-id key fallback]
(let [translation #(get-in default-contacts [(keyword contact-id) key (keyword %)])]

View File

@ -1,7 +1,8 @@
(ns status-im.ios.platform
(:require [status-im.components.styles :as styles]
[status-im.i18n :refer [label]]
[status-im.utils.utils :as utils]))
[status-im.utils.utils :as utils]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def component-styles
{:status-bar {:default {:height 20
@ -69,8 +70,6 @@
;; Dialogs
(def react-native (js/require "react-native"))
(defn action-sheet-options [options]
(let [destructive-opt-index (utils/first-index :destructive? options)
cancel-option {:text (label :t/cancel)}
@ -80,7 +79,7 @@
(when destructive-opt-index {:destructiveButtonIndex destructive-opt-index})))))
(defn show-action-sheet [{:keys [options callback]}]
(.showActionSheetWithOptions (.-ActionSheetIOS react-native)
(.showActionSheetWithOptions (.-ActionSheetIOS rn-dependencies/react-native)
(action-sheet-options options)
callback))

View File

@ -0,0 +1,9 @@
(ns status-im.js-dependencies)
(def awesome-phonenumber (js/require "awesome-phonenumber"))
(def Chance (js/require "chance"))
(def eccjs (js/require "eccjs"))
(def emojis (js/require "emojilib"))
(def homoglyph-finder (js/require "homoglyph-finder"))
(def identicon-js (js/require "identicon.js"))
(def Web3 (js/require "web3"))

View File

@ -1,16 +1,14 @@
(ns status-im.network.net-info
(:require [status-im.utils.utils :as u]
[taoensso.timbre :as log]))
(def net-info (u/get-react-property "NetInfo"))
(:require [taoensso.timbre :as log]
[status-im.components.react :as react-components]))
(defn init [callback]
(when net-info
(.then (.fetch (.-isConnected net-info))
(when react-components/net-info
(.then (.fetch (.-isConnected react-components/net-info))
(fn [is-connected?]
(log/debug "Is connected?" is-connected?)
(callback is-connected?)))))
(defn add-listener [listener]
(when net-info
(.addEventListener (.-isConnected net-info) "change" listener)))
(when react-components/net-info
(.addEventListener (.-isConnected react-components/net-info) "change" listener)))

View File

@ -1,7 +1,7 @@
(ns status-im.new-group.screen-public
(:require-macros [status-im.utils.views :refer [defview]])
(:require [re-frame.core :refer [subscribe dispatch]]
[status-im.resources :as res]
[status-im.react-native.resources :as res]
[status-im.components.react :refer [view
text
image

View File

@ -1,7 +1,7 @@
(ns status-im.participants.views.add
(:require-macros [status-im.utils.views :refer [defview]])
(:require [re-frame.core :refer [subscribe dispatch]]
[status-im.resources :as res]
[status-im.react-native.resources :as res]
[status-im.components.react :refer [view list-view list-item]]
[status-im.components.status-bar :refer [status-bar]]
[status-im.components.toolbar.view :refer [toolbar]]

View File

@ -1,7 +1,7 @@
(ns status-im.participants.views.remove
(:require-macros [status-im.utils.views :refer [defview]])
(:require [re-frame.core :refer [subscribe dispatch]]
[status-im.resources :as res]
[status-im.react-native.resources :as res]
[status-im.components.react :refer [view
text
image

View File

@ -1,22 +1,21 @@
(ns status-im.protocol.encryption)
(ns status-im.protocol.encryption
(:require [status-im.js-dependencies :as dependencies]))
(def default-curve 384)
(def ecc (js/require "eccjs"))
(defn new-keypair!
"Returns {:private \"private key\" :public \"public key\""
[]
(let [{:keys [enc dec]}
(-> ecc
(.generate (.-ENC_DEC ecc) default-curve)
(-> dependencies/eccjs
(.generate (.-ENC_DEC dependencies/eccjs) default-curve)
(js->clj :keywordize-keys true))]
{:private dec
:public enc}))
(defn encrypt [public-key content]
(.encrypt ecc public-key content))
(.encrypt dependencies/eccjs public-key content))
(defn decrypt [private-key content]
(.decrypt ecc private-key content))
(.decrypt dependencies/eccjs private-key content))

View File

@ -1,18 +1,17 @@
(ns status-im.protocol.web3.utils
(:require [cljs-time.core :refer [now]]
[cljs-time.coerce :refer [to-long]]
[status-im.utils.web-provider :as w3]))
(def web3 (js/require "web3"))
[status-im.utils.web3-provider :as w3]
[status-im.js-dependencies :as dependencies]))
(defn from-utf8 [s]
(.fromUtf8 web3.prototype s))
(.fromUtf8 dependencies/Web3.prototype s))
(defn to-ascii [s]
(.toAscii web3.prototype s))
(.toAscii dependencies/Web3.prototype s))
(defn to-utf8 [s]
(.toUtf8 web3.prototype (str s)))
(.toUtf8 dependencies/Web3.prototype (str s)))
(defn shh [web3]
(.-shh web3))
@ -20,7 +19,7 @@
(defn make-web3 [rpc-url]
(->> rpc-url
w3/get-provider
web3.))
dependencies/Web3.))
(defn timestamp []
(to-long (now)))

View File

@ -1,35 +0,0 @@
(ns status-im.resources)
(def add-icon (js/require "./images/add.png"))
(def att (js/require "./images/att.png"))
(def chat-icon (js/require "./images/chat.png"))
(def delivered-icon (js/require "./images/delivered.png"))
(def delivery-failed-icon (js/require "./images/deliveryfailed.png"))
(def icon-close-gray (js/require "./images/icon_close_gray.png"))
(def leave-icon (js/require "./images/leave.png"))
(def logo-icon (js/require "./images/logo.png"))
(def mic (js/require "./images/mic.png"))
(def nav-back-icon (js/require "./images/nav-back.png"))
(def user-no-photo (js/require "./images/no-photo.png"))
(def online-icon (js/require "./images/online.png"))
(def play (js/require "./images/play.png"))
(def seen-icon (js/require "./images/seen.png"))
(def smile (js/require "./images/smile.png"))
(def trash-icon (js/require "./images/trash.png"))
(def v (js/require "./images/v.png"))
(def contacts
{:auction-house (js/require "./images/contacts/auction-house.png")
:mkr-market (js/require "./images/contacts/mkr-market.png")
:oaken-water-meter (js/require "./images/contacts/oaken-water-meter.png")
:flight-delays-suck (js/require "./images/contacts/flight-delays-suck.png")
:jarrad (js/require "./images/contacts/jarrad.png")
:firstblood (js/require "./images/contacts/FirstBlood.png")
:gnosis (js/require "./images/contacts/gnosis.png")
:melonport (js/require "./images/contacts/melonport.png")
:bchat (js/require "./images/contacts/bchat.png")
:dentacoin (js/require "./images/contacts/Dentacoin.png")
:augur (js/require "./images/contacts/augur.png")
:ethlance (js/require "./images/contacts/ethlance.png")
:commiteth (js/require "./images/contacts/commiteth.png")
:etherplay (js/require "./images/contacts/etherplay.png")})

View File

@ -1,10 +1,9 @@
(ns status-im.utils.crypt
(:require [goog.crypt :refer [byteArrayToHex]]
[clojure.string :as s])
[clojure.string :as s]
[status-im.react-native.js-dependencies :as rn-dependencies])
(:import goog.crypt.Sha256))
(def random-bytes (js/require "react-native-randombytes"))
(def sha-256 (Sha256.))
(defn bytes-to-str [arr]
@ -19,7 +18,9 @@
(byteArrayToHex (.digest sha-256)))
(defn gen-random-bytes [length cb]
(.randomBytes random-bytes length (fn [& [err buf]]
(if err
(cb {:error err})
(cb {:buffer buf})))))
(.randomBytes rn-dependencies/random-bytes
length
(fn [& [err buf]]
(if err
(cb {:error err})
(cb {:buffer buf})))))

View File

@ -1,11 +1,10 @@
(ns status-im.utils.ethereum-network
(:require [status-im.constants :as c]
[status-im.utils.web-provider :as w3]))
(def Web3 (js/require "web3"))
[status-im.utils.web3-provider :as w3]
[status-im.js-dependencies :as dependencies]))
(defn web3 []
(Web3. (w3/get-provider c/ethereum-rpc-url)))
(dependencies/Web3. (w3/get-provider c/ethereum-rpc-url)))
(def networks
{"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" :mainnet

View File

@ -1,13 +1,12 @@
(ns status-im.utils.fs)
(def fs (js/require "react-native-fs"))
(ns status-im.utils.fs
(:require [status-im.react-native.js-dependencies :as rn-dependencies]))
(defn move-file [src dst handler]
(-> (.moveFile fs src dst)
(-> (.moveFile rn-dependencies/fs src dst)
(.then #(handler nil %))
(.catch #(handler % nil))))
(defn read-file [path encoding on-read on-error]
(-> (.readFile fs path encoding)
(-> (.readFile rn-dependencies/fs path encoding)
(.then on-read)
(.catch on-error)))

View File

@ -1,6 +1,5 @@
(ns status-im.utils.homoglyph)
(def homoglyph-finder (js/require "homoglyph-finder"))
(ns status-im.utils.homoglyph
(:require [status-im.js-dependencies :as dependencies]))
(defn matches [s1 s2]
(.isMatches homoglyph-finder s1 s2))
(.isMatches dependencies/homoglyph-finder s1 s2))

View File

@ -1,11 +1,11 @@
(ns status-im.utils.identicon)
(ns status-im.utils.identicon
(:require [status-im.js-dependencies :as dependencies]))
(def default-size 40)
(def identicon-js (js/require "identicon.js"))
(defn identicon
([hash] (identicon hash default-size))
([hash options]
(str "data:image/png;base64," (str (new identicon-js hash options)))))
(str "data:image/png;base64,"
(str (new dependencies/identicon-js hash options)))))

View File

@ -1,12 +1,11 @@
(ns status-im.utils.image-processing
(:require [status-im.utils.fs :refer [read-file]]
[taoensso.timbre :as log]
[clojure.string :as str]))
(def resizer-class (js/require "react-native-image-resizer"))
[clojure.string :as str]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn- resize [path max-width max-height on-resize on-error]
(let [resize-fn (aget resizer-class "default" "createResizedImage")]
(let [resize-fn (aget rn-dependencies/image-resizer "default" "createResizedImage")]
(-> (resize-fn path max-width max-height "JPEG" 75 0 nil)
(.then on-resize)
(.catch on-error))))

View File

@ -1,12 +1,11 @@
(ns status-im.utils.instabug
(:require [taoensso.timbre :as log]))
(def instabug-rn (js/require "instabug-reactnative"))
(:require [taoensso.timbre :as log]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn log [str]
(if js/goog.DEBUG
(log/debug str)
(.IBGLog instabug-rn str)))
(.IBGLog rn-dependencies/instabug str)))
(defn instabug-appender []
{:enabled? true

View File

@ -1,17 +1,17 @@
(ns status-im.utils.phone-number
(:require [status-im.i18n :refer [label]]))
(:require [status-im.i18n :refer [label]]
[status-im.react-native.js-dependencies :as rn-dependencies]
[status-im.js-dependencies :as dependencies]))
(def i18n (js/require "react-native-i18n"))
(def locale (or (.-locale i18n) "___en"))
(def locale (or (.-locale rn-dependencies/i18n) "___en"))
(def country-code (subs locale 3 5))
(def awesome-phonenumber (js/require "awesome-phonenumber"))
;; todo check wrong numbers, .getNumber returns empty string
(defn format-phone-number [number]
(str (.getNumber (awesome-phonenumber. number country-code) "international")))
(str (.getNumber (dependencies/awesome-phonenumber number country-code) "international")))
(defn get-examples []
(when-let [example (.getExample awesome-phonenumber country-code "mobile")]
(when-let [example (.getExample dependencies/awesome-phonenumber country-code "mobile")]
[{:number (.getNumber example)
:description (label :t/phone-e164)}
{:number (.getNumber example "international")
@ -23,7 +23,7 @@
(defn valid-mobile-number? [number]
(when (string? number)
(let [{:keys [valid type]} (-> (awesome-phonenumber. number country-code)
(let [{:keys [valid type]} (-> (dependencies/awesome-phonenumber. number country-code)
(.toJSON)
(js->clj :keywordize-keys true))]
(and valid

View File

@ -1,11 +1,10 @@
(ns status-im.utils.platform
(:require [status-im.android.platform :as android]
[status-im.ios.platform :as ios]))
(def react-native (js/require "react-native"))
[status-im.ios.platform :as ios]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def platform
(when-let [pl (.-Platform react-native)]
(when-let [pl (.-Platform rn-dependencies/react-native)]
(.-OS pl)))
(def android? (= platform "android"))

View File

@ -1,11 +1,10 @@
(ns status-im.utils.random)
(ns status-im.utils.random
(:require [status-im.js-dependencies :as dependencies]))
(defn timestamp []
(.getTime (js/Date.)))
(def Chance (js/require "chance"))
(def chance (Chance.))
(def chance (dependencies/Chance.))
(defn id []
(str (timestamp) "-" (.guid chance)))

View File

@ -1,16 +1,14 @@
(ns status-im.utils.sms-listener
(:require [status-im.utils.platform :refer [android?]]))
(def sms-listener (.-default (js/require "react-native-android-sms-listener")))
(:require [status-im.utils.platform :refer [android?]]
[status-im.react-native.js-dependencies :as rn-dependencies]))
;; Only android is supported!
(defn add-sms-listener
"Message format: {:originatingAddress string, :body string}. Returns
cancelable subscription."
[listen-fn]
(when android?
(.addListener sms-listener
(.addListener rn-dependencies/android-sms-listener
(fn [message]
(listen-fn (js->clj message :keywordize-keys true))))))

View File

@ -2,20 +2,12 @@
(:require [status-im.constants :as const]
[status-im.i18n :refer [label]]
[reagent.core :as r]
[clojure.string :as str]))
(defn require [module]
(if (exists? js/window)
(js/require module)
#js {}))
(defn log [obj]
(.log js/console obj))
(def react-native (js/require "react-native"))
[clojure.string :as str]
[taoensso.timbre :as log]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn show-popup [title content]
(.alert (.-Alert react-native)
(.alert (.-Alert rn-dependencies/react-native)
title
content))
@ -25,7 +17,7 @@
([title content s on-accept]
(show-confirmation title content s on-accept nil))
([title content s on-accept on-cancel]
(.alert (.-Alert react-native)
(.alert (.-Alert rn-dependencies/react-native)
title
content
; Styles are only relevant on iOS. On Android first button is 'neutral' and second is 'positive'
@ -45,7 +37,7 @@
:content-type "application/json"}
:body (.stringify js/JSON (clj->js data))}))
(.then (fn [response]
(log response)
(log/debug response)
(.text response)))
(.then (fn [text]
(let [json (.parse js/JSON text)
@ -62,7 +54,7 @@
(-> (.fetch js/window url (clj->js {:method "GET"
:headers {"Cache-Control" "no-cache"}}))
(.then (fn [response]
(log response)
(log/debug response)
(let [ok? (.-ok response)
ok?' (if valid-response?
(and ok? (valid-response? response))
@ -101,15 +93,5 @@
index
(recur (inc index) cond (next coll))))))
(defn get-react-property [name]
(aget react-native name))
(defn adapt-class [class]
(when class
(r/adapt-react-class class)))
(defn get-class [name]
(adapt-class (get-react-property name)))
(defn hash-tag? [s]
(= \# (first s)))

View File

@ -1,4 +1,4 @@
(ns status-im.utils.web-provider
(ns status-im.utils.web3-provider
(:require [taoensso.timbre :as log]
[status-im.components.status :as status]))

View File

@ -0,0 +1,2 @@
(ns cljsjs.react)

View File

@ -0,0 +1 @@
(ns cljsjs.react.dom)

View File

@ -0,0 +1 @@
(ns cljsjs.react.dom.server)

View File

@ -0,0 +1,14 @@
(ns reagent.core)
(defn create-element [& args])
(defn adapt-react-class [& args])
(defn atom [& args])
(defn as-element [& args])
(defn create-class [& args])
(defn set-state [& args])
(defn state [& args])
(defn after-render [& args])
(defn props [& args])
(defn current-component [& args])
(defn reactify-component [& args])

View File

@ -0,0 +1,38 @@
(ns status-im.react-native.js-dependencies)
(def action-button #js {})
(def android-sms-listener #js {})
(def autolink #js {})
(def camera #js {:constants #js {}})
(def circle-checkbox #js {})
(def contacts #js {})
(def dialogs #js {})
(def dismiss-keyboard #js {})
(def drawer #js {})
(def emoji-picker #js {})
(def fs #js {})
(def http-bridge #js {})
(def i18n #js {})
(def image-crop-picker #js {})
(def image-resizer #js {})
(def instabug #js {})
(def invertible-scroll-view #js {})
(def linear-gradient #js {})
(def mapbox-gl #js {:setAccessToken (fn [])})
(def nfc #js {})
(def orientation #js {})
(def popup-menu #js {})
(def qr-code #js {})
(def random-bytes #js {})
(def react-native
#js {:NativeModules #js {}
:Animated #js {}
:DeviceEventEmitter #js {:addListener (fn [])}})
(def realm #js {:schemaVersion (fn [])
:close (fn [])})
(def sortable-listview #js {})
(def swiper #js {})
(def vector-icons #js {})
(def webview-bridge #js {})

View File

@ -0,0 +1,29 @@
(ns status-im.react-native.resources)
(def add-icon nil)
(def att nil)
(def chat-icon nil)
(def icon-close-gray nil)
(def logo-icon nil)
(def nav-back-icon nil)
(def user-no-photo nil)
(def online-icon nil)
(def play nil)
(def trash-icon nil)
(def v nil)
(def contacts
{:auction-house nil
:mkr-market nil
:oaken-water-meter nil
:flight-delays-suck nil
:jarrad nil
:firstblood nil
:gnosis nil
:melonport nil
:bchat nil
:dentacoin nil
:augur nil
:ethlance nil
:commiteth nil
:etherplay nil})

View File

@ -1,20 +0,0 @@
(ns status-im.test.commands.handlers
(:require [cljs.test :refer-macros [deftest is]]
[status-im.commands.handlers.loading :as h]))
(deftest test-validate-hash
(let [file "some-js"
db (-> {}
(assoc-in [:chats :user :dapp-hash] -731917028)
(assoc-in [:chats :user2 :dapp-hash] 123))]
(is (::h/valid-hash (h/validate-hash db [:user file])))
(is (not (::h/valid-hash (h/validate-hash db [:user2 file]))))
(is (not (::h/valid-hash (h/validate-hash db [:user3 file]))))))
(deftest test-add-commands
(let [obj {:commands {:test {:name "name"
:description "desc"}}
:responses {:test-r {:name "r"
:description "desc-r"}}}
db (h/add-commands {} [:user nil obj])]
(is (= obj (select-keys (get-in db [:chats :user]) [:commands :responses])))))

View File

@ -1,8 +1,7 @@
(ns status-im.test.runner
(:require [doo.runner :refer-macros [doo-tests]]
[status-im.test.chat.models.input]
[status-im.test.handlers]
[status-im.test.commands.handlers]))
[status-im.test.handlers]))
(enable-console-print!)
@ -13,5 +12,4 @@
(set! goog.DEBUG false)
(doo-tests 'status-im.test.chat.models.input
'status-im.test.handlers
'status-im.test.commands.handlers)
'status-im.test.handlers)