From b9d29b7fd813a5ab400397c5aef874bdc48b181f Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Mon, 24 Oct 2016 23:46:06 +0300 Subject: [PATCH] fix bugs related to release build for android devices Former-commit-id: 53e7ca91d97fdf7ec0094249b9fc16f32f8e0ead --- .re-natal | 7 +- android/app/build.gradle | 12 +++ .../com/statusim/module/StatusModule.java | 34 +++++---- package.json | 7 +- project.clj | 35 +++++---- .../accounts/recover/validations.cljs | 3 +- src/status_im/android/core.cljs | 4 +- src/status_im/android/platform.cljs | 2 +- src/status_im/components/react.cljs | 12 +-- src/status_im/components/status.cljs | 75 ++++++++++++++----- src/status_im/components/webview_bridge.cljs | 2 +- src/status_im/contacts/handlers.cljs | 2 +- src/status_im/contacts/validations.cljs | 5 +- src/status_im/data_store/realm/core.cljs | 2 +- src/status_im/handlers.cljs | 18 +++-- src/status_im/i18n.cljs | 4 +- src/status_im/ios/platform.cljs | 2 +- src/status_im/protocol/encryption.cljs | 12 +-- src/status_im/protocol/web3/utils.cljs | 6 +- src/status_im/transactions/handlers.cljs | 1 - .../transactions/views/transaction_page.cljs | 3 +- src/status_im/utils/crypt.cljs | 2 +- src/status_im/utils/fs.cljs | 4 +- src/status_im/utils/homoglyph.cljs | 2 +- src/status_im/utils/identicon.cljs | 2 +- src/status_im/utils/phone_number.cljs | 4 +- src/status_im/utils/platform.cljs | 4 +- src/status_im/utils/random.cljs | 9 ++- src/status_im/utils/sms_listener.cljs | 2 +- src/status_im/utils/utils.cljs | 2 +- 30 files changed, 178 insertions(+), 101 deletions(-) diff --git a/.re-natal b/.re-natal index 7a9c39e062..36abebbe7a 100644 --- a/.re-natal +++ b/.re-natal @@ -1,7 +1,7 @@ { "name": "StatusIm", "interface": "reagent", - "androidHost": "localhost", + "androidHost": "10.0.3.2", "modules": [ "react-native-contacts", "react-native-invertible-scroll-view", @@ -28,7 +28,10 @@ "react-native-image-crop-picker", "react-native-webview-bridge", "react-native-drawer-layout", - "homoglyph-finder" + "homoglyph-finder", + "web3", + "eccjs", + "chance" ], "imageDirs": [ "images" diff --git a/android/app/build.gradle b/android/app/build.gradle index 9cf1a19a82..06fe5036ee 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -58,6 +58,9 @@ import com.android.build.OutputFile * inputExcludes: ["android/**", "ios/**"] * ] */ +project.ext.react = [ + nodeExecutableAndArgs: ["node", "--max-old-space-size=4096"] +] apply from: "../../node_modules/react-native/react.gradle" @@ -90,6 +93,14 @@ android { abiFilters "armeabi-v7a", "x86" } } + signingConfigs { + release { + storeFile file(MYAPP_RELEASE_STORE_FILE) + storePassword MYAPP_RELEASE_STORE_PASSWORD + keyAlias MYAPP_RELEASE_KEY_ALIAS + keyPassword MYAPP_RELEASE_KEY_PASSWORD + } + } splits { abi { reset() @@ -102,6 +113,7 @@ android { release { minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + signingConfig signingConfigs.release } } // applicationVariants are e.g. debug, release diff --git a/modules/react-native-status/android/src/main/java/com/statusim/module/StatusModule.java b/modules/react-native-status/android/src/main/java/com/statusim/module/StatusModule.java index e4991ea0ba..762b288092 100644 --- a/modules/react-native-status/android/src/main/java/com/statusim/module/StatusModule.java +++ b/modules/react-native-status/android/src/main/java/com/statusim/module/StatusModule.java @@ -32,21 +32,28 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @Override public void onHostResume() { // Actvity `onResume` - Activity currentActivity = getCurrentActivity(); if (currentActivity == null) { + Log.d(TAG, "On host Activity doesn't exist"); return; } if (status == null) { status = new StatusConnector(currentActivity, StatusService.class); status.registerHandler(this); } + status.bindService(); + + WritableMap params = Arguments.createMap(); + Log.d(TAG, "Send module.initialized event"); + params.putString("jsonEvent", "{\"type\":\"module.initialized\"}"); + getReactApplicationContext() + .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) + .emit("gethEvent", params); } @Override public void onHostPause() { // Actvity `onPause` - if (status != null) { status.unbindService(); } @@ -54,7 +61,6 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @Override public void onHostDestroy() { // Actvity `onDestroy` - if (status != null) { status.stopNode(null); } @@ -126,7 +132,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void startNode(Callback callback) { - + Log.d(TAG, "startNode"); if (!checkAvailability()) { callback.invoke(false); return; @@ -140,7 +146,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void login(String address, String password, Callback callback) { - + Log.d(TAG, "login"); if (!checkAvailability()) { callback.invoke(false); return; @@ -154,7 +160,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void createAccount(String password, Callback callback) { - + Log.d(TAG, "createAccount"); if (!checkAvailability()) { callback.invoke(false); return; @@ -168,7 +174,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void recoverAccount(String passphrase, String password, Callback callback) { - + Log.d(TAG, "recoverAccount"); if (!checkAvailability()) { callback.invoke(false); return; @@ -186,7 +192,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void completeTransaction(String hash, String password, Callback callback) { - + Log.d(TAG, "completeTransaction"); if (!checkAvailability()) { callback.invoke(false); return; @@ -203,7 +209,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void initJail(String js, Callback callback) { - + Log.d(TAG, "initJail"); if (!checkAvailability()) { callback.invoke(false); return; @@ -217,7 +223,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void parseJail(String chatId, String js, Callback callback) { - + Log.d(TAG, "parseJail"); if (!checkAvailability()) { callback.invoke(false); return; @@ -231,7 +237,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void callJail(String chatId, String path, String params, Callback callback) { - + Log.d(TAG, "callJail"); if (!checkAvailability()) { callback.invoke(false); return; @@ -245,7 +251,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void setAdjustResize() { - + Log.d(TAG, "setAdjustResize"); final Activity activity = getCurrentActivity(); if (activity == null) { return; @@ -261,7 +267,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void setAdjustPan() { - + Log.d(TAG, "setAdjustPan"); final Activity activity = getCurrentActivity(); if (activity == null) { return; @@ -277,7 +283,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void setSoftInputMode(final int mode) { - + Log.d(TAG, "setSoftInputMode"); final Activity activity = getCurrentActivity(); if (activity == null) { return; diff --git a/package.json b/package.json index dc9e3dbcf6..c8c1d188ba 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,12 @@ "assert": "^1.4.1", "awesome-phonenumber": "^1.0.13", "browserify-zlib": "^0.1.4", + "chance": "1.0.4", "console-browserify": "^1.1.0", "constants-browserify": "0.0.1", "dns.js": "^1.0.1", "domain-browser": "^1.1.7", + "eccjs": "0.3.1", "events": "^1.1.1", "homoglyph-finder": "^1.1.1", "https-browserify": "0.0.1", @@ -28,7 +30,7 @@ "querystring-es3": "^0.2.1", "re-natal": "0.2.38", "react": "^15.3.1", - "react-native": "^0.33.0", + "react-native": "^0.34.0", "react-native-action-button": "^1.1.11", "react-native-android-sms-listener": "github:adrian-tiberius/react-native-android-sms-listener#listener-bugfix", "react-native-camera": "git+https://github.com/lwansbrough/react-native-camera.git", @@ -58,7 +60,8 @@ "timers-browserify": "^1.4.2", "tty-browserify": "0.0.0", "url": "^0.10.3", - "vm-browserify": "0.0.4" + "vm-browserify": "0.0.4", + "web3": "0.16.0" }, "browser": { "crypto": "react-native-crypto", diff --git a/project.clj b/project.clj index 4592c83a54..4fce99cfa7 100644 --- a/project.clj +++ b/project.clj @@ -11,12 +11,9 @@ [natal-shell "0.3.0"] [com.andrewmcveigh/cljs-time "0.4.0"] [tailrecursion/cljs-priority-map "1.2.0"] - [cljsjs/web3 "0.16.0-0"] [com.taoensso/timbre "4.7.4"] - [org.clojure/test.check "0.9.0"] - [cljsjs/chance "0.7.3-0"] - [cljsjs/eccjs "0.3.1-0"]] - :plugins [[lein-cljsbuild "1.1.1"] + [org.clojure/test.check "0.9.0"]] + :plugins [[lein-cljsbuild "1.1.4"] [lein-figwheel "0.5.0-2"]] :clean-targets ["target/" "index.ios.js" "index.android.js"] :aliases {"prod-build" ^{:doc "Recompile code with prod profile."} @@ -55,13 +52,21 @@ :optimizations :none :target :nodejs}}}} :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}} - :prod {:cljsbuild {:builds {:ios {:source-paths ["src" "env/prod"] - :compiler {:output-to "index.ios.js" - :main "env.ios.main" - :output-dir "target/ios" - :optimizations :simple}} - :android {:source-paths ["src" "env/prod"] - :compiler {:output-to "index.android.js" - :main "env.android.main" - :output-dir "target/android" - :optimizations :simple}}}}}}) + :prod {:cljsbuild {:builds [{:id "ios" + :source-paths ["src" "env/prod"] + :compiler {:output-to "index.ios.js" + :main "env.ios.main" + :output-dir "target/ios" + :static-fns true + :optimize-constants true + :optimizations :simple + :closure-defines {"goog.DEBUG" false}}} + {:id "android" + :source-paths ["src" "env/prod"] + :compiler {:output-to "index.android.js" + :main "env.android.main" + :output-dir "target/android" + :static-fns true + :optimize-constants true + :optimizations :simple + :closure-defines {"goog.DEBUG" false}}}]}}}) diff --git a/src/status_im/accounts/recover/validations.cljs b/src/status_im/accounts/recover/validations.cljs index 1c9d30c7e1..c2f8ee386f 100644 --- a/src/status_im/accounts/recover/validations.cljs +++ b/src/status_im/accounts/recover/validations.cljs @@ -1,6 +1,5 @@ (ns status-im.accounts.recover.validations - (:require [cljs.spec :as s] - [cljsjs.web3])) + (:require [cljs.spec :as s])) (s/def ::not-empty-string (s/and string? not-empty)) (s/def ::passphrase ::not-empty-string) diff --git a/src/status_im/android/core.cljs b/src/status_im/android/core.cljs index 259df98dae..243fa5e97c 100644 --- a/src/status_im/android/core.cljs +++ b/src/status_im/android/core.cljs @@ -105,10 +105,10 @@ (defn init [& [env]] (dispatch-sync [:reset-app]) + (.registerComponent app-registry "StatusIm" #(r/reactify-component app-root) (dispatch [:listen-to-network-status!]) (dispatch [:initialize-crypt]) (dispatch [:initialize-geth]) (status/set-soft-input-mode status/adjust-resize) (dispatch [:load-user-phone-number]) - (init-back-button-handler!) - (.registerComponent app-registry "StatusIm" #(r/reactify-component app-root))) + (init-back-button-handler!))) diff --git a/src/status_im/android/platform.cljs b/src/status_im/android/platform.cljs index 810332b002..65aabd41c0 100644 --- a/src/status_im/android/platform.cljs +++ b/src/status_im/android/platform.cljs @@ -34,7 +34,7 @@ ;; Dialogs -(def react-native-dialogs (u/require "react-native-dialogs")) +(def react-native-dialogs (js/require "react-native-dialogs")) (defn show-dialog [{:keys [title options callback]}] (let [dialog (new react-native-dialogs)] diff --git a/src/status_im/components/react.cljs b/src/status_im/components/react.cljs index b1e6524b63..e9142ad656 100644 --- a/src/status_im/components/react.cljs +++ b/src/status_im/components/react.cljs @@ -5,14 +5,14 @@ :refer [get-react-property get-class adapt-class]] [status-im.utils.platform :refer [platform-specific]])) -(def react-native (u/require "react-native")) +(def react-native (js/require "react-native")) (def native-modules (.-NativeModules react-native)) (def device-event-emitter (.-DeviceEventEmitter react-native)) -(def linear-gradient-module (u/require "react-native-linear-gradient")) -(def dismiss-keyboard! (u/require "dismissKeyboard")) -(def orientation (u/require "react-native-orientation")) -(def drawer (u/require "react-native-drawer-layout")) +(def linear-gradient-module (js/require "react-native-linear-gradient")) +(def dismiss-keyboard! (js/require "dismissKeyboard")) +(def orientation (js/require "react-native-orientation")) +(def drawer (js/require "react-native-drawer-layout")) ;; React Components @@ -101,7 +101,7 @@ ;; Image picker -(def image-picker-class (u/require "react-native-image-crop-picker")) +(def image-picker-class (js/require "react-native-image-crop-picker")) (defn show-image-picker [images-fn] (let [image-picker (.-default image-picker-class)] diff --git a/src/status_im/components/status.cljs b/src/status_im/components/status.cljs index 210566f407..e0923169d5 100644 --- a/src/status_im/components/status.cljs +++ b/src/status_im/components/status.cljs @@ -1,9 +1,44 @@ (ns status-im.components.status - (:require-macros [status-im.utils.slurp :refer [slurp]]) + (:require-macros [status-im.utils.slurp :refer [slurp]] + [cljs.core.async.macros :refer [go-loop go]]) (:require [status-im.components.react :as r] [status-im.utils.types :as t] [re-frame.core :refer [dispatch]] - [taoensso.timbre :as log])) + [taoensso.timbre :as log] + [cljs.core.async :refer [json [data] (.stringify js/JSON (clj->js data))) (defn call-jail [chat-id path params callback] (when status - (log/debug :chat-id chat-id) - (log/debug :path path) - (log/debug :params params) - (let [cb (fn [r] - (let [r' (t/json->clj r)] - (log/debug r') - (callback r')))] - (.callJail status chat-id (cljs->json path) (cljs->json params) cb)))) + (call-module + #(do + (log/debug :chat-id chat-id) + (log/debug :path path) + (log/debug :params params) + (let [cb (fn [r] + (let [r' (t/json->clj r)] + (log/debug r') + (callback r')))] + (.callJail status chat-id (cljs->json path) (cljs->json params) cb)))))) (defn set-soft-input-mode [mode] (when status - (.setSoftInputMode status mode))) + (call-module #(.setSoftInputMode status mode)))) (def adjust-resize 16) (def adjust-pan 32) diff --git a/src/status_im/components/webview_bridge.cljs b/src/status_im/components/webview_bridge.cljs index becbfb33b8..bce74c019d 100644 --- a/src/status_im/components/webview_bridge.cljs +++ b/src/status_im/components/webview_bridge.cljs @@ -3,7 +3,7 @@ [reagent.core :as r])) (def webview-bridge-class - (r/adapt-react-class (u/require "react-native-webview-bridge"))) + (r/adapt-react-class (js/require "react-native-webview-bridge"))) (defn webview-bridge [opts] [webview-bridge-class opts]) diff --git a/src/status_im/contacts/handlers.cljs b/src/status_im/contacts/handlers.cljs index 9f685dd5b6..7c539e7525 100644 --- a/src/status_im/contacts/handlers.cljs +++ b/src/status_im/contacts/handlers.cljs @@ -77,7 +77,7 @@ (register-handler :load-contacts load-contacts!) ;; TODO see https://github.com/rt2zz/react-native-contacts/issues/45 -(def react-native-contacts (require "react-native-contacts")) +(def react-native-contacts (js/require "react-native-contacts")) (defn contact-name [contact] (->> contact diff --git a/src/status_im/contacts/validations.cljs b/src/status_im/contacts/validations.cljs index d4af512cf4..c97e132f1e 100644 --- a/src/status_im/contacts/validations.cljs +++ b/src/status_im/contacts/validations.cljs @@ -1,10 +1,11 @@ (ns status-im.contacts.validations (:require [cljs.spec :as s] - [cljsjs.web3] [status-im.data-store.contacts :as contacts])) +(def web3 (js/require "web3")) + (defn is-address? [s] - (.isAddress js/Web3.prototype s)) + (.isAddress web3.prototype s)) (defn unique-identity? [identity] (not (contacts/exists? identity))) diff --git a/src/status_im/data_store/realm/core.cljs b/src/status_im/data_store/realm/core.cljs index fae29539a1..db218023a3 100644 --- a/src/status_im/data_store/realm/core.cljs +++ b/src/status_im/data_store/realm/core.cljs @@ -8,7 +8,7 @@ [clojure.string :as str]) (:refer-clojure :exclude [exists?])) -(def realm-class (u/require "realm")) +(def realm-class (js/require "realm")) (defn realm-version [file-name] diff --git a/src/status_im/handlers.cljs b/src/status_im/handlers.cljs index 849495b37e..fae1e4f647 100644 --- a/src/status_im/handlers.cljs +++ b/src/status_im/handlers.cljs @@ -75,6 +75,8 @@ (dispatch [:init-wallet-chat]) (dispatch [:load-commands! console-chat-id])))) +(def ecc (js/require "eccjs")) + (register-handler :initialize-crypt (u/side-effect! (fn [_ _] @@ -87,8 +89,8 @@ :error error}])) (do (->> (.toString buffer "hex") - (.toBits (.. js/ecc -sjcl -codec -hex)) - (.addEntropy (.. js/ecc -sjcl -random))) + (.toBits (.. ecc -sjcl -codec -hex)) + (.addEntropy (.. ecc -sjcl -random))) (dispatch [:crypt-initialized])))))))) (defn node-started [db result] @@ -96,9 +98,9 @@ (register-handler :initialize-geth (u/side-effect! - (fn [db _] - (log/debug "Starting node") - (status/start-node (fn [result] (node-started db result)))))) + (fn [db _] + (log/debug "Starting node") + (status/start-node (fn [result] (node-started db result)))))) (register-handler :signal-event (u/side-effect! @@ -108,8 +110,14 @@ (case type "transaction.queued" (dispatch [:transaction-queued event]) "node.started" (log/debug "Event *node.started* received") + "module.initialized" (dispatch [:status-module-initialized!]) (log/debug "Event " type " not handled")))))) +(register-handler :status-module-initialized! + (u/side-effect! + (fn [db] + (status/module-initialized!)))) + (register-handler :crypt-initialized (u/side-effect! (fn [_ _] diff --git a/src/status_im/i18n.cljs b/src/status_im/i18n.cljs index e5cf92990d..8253bb4798 100644 --- a/src/status_im/i18n.cljs +++ b/src/status_im/i18n.cljs @@ -3,7 +3,7 @@ [status-im.translations.en :as en] [status-im.utils.utils :as u])) -(def i18n (u/require "react-native-i18n")) +(def i18n (js/require "react-native-i18n")) (set! (.-fallbacks i18n) true) (set! (.-defaultSeparator i18n) "/") @@ -26,4 +26,4 @@ (name) (str "t/status-") (keyword) - (label))) \ No newline at end of file + (label))) diff --git a/src/status_im/ios/platform.cljs b/src/status_im/ios/platform.cljs index 696e96b33a..dd42b5ef9a 100644 --- a/src/status_im/ios/platform.cljs +++ b/src/status_im/ios/platform.cljs @@ -40,7 +40,7 @@ ;; Dialogs -(def react-native (u/require "react-native")) +(def react-native (js/require "react-native")) (defn show-action-sheet [{:keys [options callback cancel-text]}] (.showActionSheetWithOptions (.-ActionSheetIOS react-native) diff --git a/src/status_im/protocol/encryption.cljs b/src/status_im/protocol/encryption.cljs index e21e174623..13043b7656 100644 --- a/src/status_im/protocol/encryption.cljs +++ b/src/status_im/protocol/encryption.cljs @@ -1,21 +1,21 @@ -(ns status-im.protocol.encryption - (:require [cljsjs.chance] - [cljsjs.eccjs])) +(ns status-im.protocol.encryption) (def default-curve 384) +(def ecc (js/require "eccjs")) + (defn new-keypair! "Returns {:private \"private key\" :public \"public key\"" [] (let [{:keys [enc dec]} - (-> (.generate js/ecc (.-ENC_DEC js/ecc) default-curve) + (-> (.generate ecc (.-ENC_DEC ecc) default-curve) (js->clj :keywordize-keys true))] {:private dec :public enc})) (defn encrypt [public-key content] - (.encrypt js/ecc public-key content)) + (.encrypt ecc public-key content)) (defn decrypt [private-key content] - (.decrypt js/ecc private-key content)) + (.decrypt ecc private-key content)) diff --git a/src/status_im/protocol/web3/utils.cljs b/src/status_im/protocol/web3/utils.cljs index a044146d22..487d763b03 100644 --- a/src/status_im/protocol/web3/utils.cljs +++ b/src/status_im/protocol/web3/utils.cljs @@ -1,9 +1,9 @@ (ns status-im.protocol.web3.utils - (:require cljsjs.web3 - [cljs-time.core :refer [now]] + (:require [cljs-time.core :refer [now]] [cljs-time.coerce :refer [to-long]])) -(def web3 js/Web3) +(def web3 (js/require "web3")) + (def status-app-topic "status-app") (defn from-utf8 [s] diff --git a/src/status_im/transactions/handlers.cljs b/src/status_im/transactions/handlers.cljs index 50765be641..d135b9c778 100644 --- a/src/status_im/transactions/handlers.cljs +++ b/src/status_im/transactions/handlers.cljs @@ -5,7 +5,6 @@ [status-im.utils.handlers :as u] [status-im.utils.types :as t] [status-im.components.status :as status] - cljsjs.web3 [clojure.string :as s] [taoensso.timbre :as log])) diff --git a/src/status_im/transactions/views/transaction_page.cljs b/src/status_im/transactions/views/transaction_page.cljs index 64fafd5b6e..6b788d66bc 100644 --- a/src/status_im/transactions/views/transaction_page.cljs +++ b/src/status_im/transactions/views/transaction_page.cljs @@ -11,8 +11,7 @@ [status-im.components.styles :refer [icon-ok icon-close]] [status-im.transactions.styles :as st] - [status-im.i18n :refer [label label-pluralize]] - cljsjs.web3)) + [status-im.i18n :refer [label label-pluralize]])) (defn title-bar [title id] [view st/title-bar diff --git a/src/status_im/utils/crypt.cljs b/src/status_im/utils/crypt.cljs index 9179e7dfc0..1e40adc8bc 100644 --- a/src/status_im/utils/crypt.cljs +++ b/src/status_im/utils/crypt.cljs @@ -4,7 +4,7 @@ [status-im.utils.utils :as u]) (:import goog.crypt.Sha256)) -(def random-bytes (u/require "react-native-randombytes")) +(def random-bytes (js/require "react-native-randombytes")) (def sha-256 (Sha256.)) diff --git a/src/status_im/utils/fs.cljs b/src/status_im/utils/fs.cljs index a68f8c07d6..2a24d495c7 100644 --- a/src/status_im/utils/fs.cljs +++ b/src/status_im/utils/fs.cljs @@ -2,7 +2,7 @@ (:require [clojure.string :as s] [status-im.utils.utils :as u])) -(def fs (u/require "react-native-fs")) +(def fs (js/require "react-native-fs")) (defn move-file [src dst handler] (let [result (.moveFile fs src dst) @@ -13,4 +13,4 @@ (defn read-file [path encoding on-read on-error] (-> (.readFile fs path encoding) (.then on-read) - (.catch on-error))) \ No newline at end of file + (.catch on-error))) diff --git a/src/status_im/utils/homoglyph.cljs b/src/status_im/utils/homoglyph.cljs index 4ebb2d5414..6b96d1eee0 100644 --- a/src/status_im/utils/homoglyph.cljs +++ b/src/status_im/utils/homoglyph.cljs @@ -1,7 +1,7 @@ (ns status-im.utils.homoglyph (:require [status-im.utils.utils :as u])) -(def homoglyph-finder (u/require "homoglyph-finder")) +(def homoglyph-finder (js/require "homoglyph-finder")) (defn matches [s1 s2] (.isMatches homoglyph-finder s1 s2)) diff --git a/src/status_im/utils/identicon.cljs b/src/status_im/utils/identicon.cljs index 2d8dac64e1..0cbf00db2e 100644 --- a/src/status_im/utils/identicon.cljs +++ b/src/status_im/utils/identicon.cljs @@ -4,7 +4,7 @@ (def default-size 40) -(def identicon-js (u/require "identicon.js")) +(def identicon-js (js/require "identicon.js")) (defn identicon ([hash] (identicon hash default-size)) diff --git a/src/status_im/utils/phone_number.cljs b/src/status_im/utils/phone_number.cljs index ce0aac69a2..5ae5cb475f 100644 --- a/src/status_im/utils/phone_number.cljs +++ b/src/status_im/utils/phone_number.cljs @@ -1,10 +1,10 @@ (ns status-im.utils.phone-number (:require [status-im.utils.utils :as u])) -(def i18n (u/require "react-native-i18n")) +(def i18n (js/require "react-native-i18n")) (def locale (or (.-locale i18n) "___en")) (def country-code (subs locale 3 5)) -(def awesome-phonenumber (u/require "awesome-phonenumber")) +(def awesome-phonenumber (js/require "awesome-phonenumber")) ;; todo check wrong numbers, .getNumber returns empty string (defn format-phone-number [number] diff --git a/src/status_im/utils/platform.cljs b/src/status_im/utils/platform.cljs index 82b952e88b..f7e6095a4a 100644 --- a/src/status_im/utils/platform.cljs +++ b/src/status_im/utils/platform.cljs @@ -3,7 +3,7 @@ [status-im.android.platform :as android] [status-im.ios.platform :as ios])) -(def react-native (u/require "react-native")) +(def react-native (js/require "react-native")) (def platform (when-let [pl (.-Platform react-native)] @@ -16,4 +16,4 @@ (cond android? android/platform-specific ios? ios/platform-specific - :else {})) \ No newline at end of file + :else {})) diff --git a/src/status_im/utils/random.cljs b/src/status_im/utils/random.cljs index 367998cf20..7553790cc0 100644 --- a/src/status_im/utils/random.cljs +++ b/src/status_im/utils/random.cljs @@ -1,8 +1,11 @@ -(ns status-im.utils.random - (:require [cljsjs.chance])) +(ns status-im.utils.random) (defn timestamp [] (.getTime (js/Date.))) +(def Chance (js/require "chance")) + +(def chance (Chance.)) + (defn id [] - (str (timestamp) "-" (.guid js/chance))) + (str (timestamp) "-" (.guid chance))) diff --git a/src/status_im/utils/sms_listener.cljs b/src/status_im/utils/sms_listener.cljs index 794823f670..39afeebd0e 100644 --- a/src/status_im/utils/sms_listener.cljs +++ b/src/status_im/utils/sms_listener.cljs @@ -2,7 +2,7 @@ (:require [status-im.utils.platform :refer [android?]] [status-im.utils.utils :as u])) -(def sms-listener (.-default (u/require "react-native-android-sms-listener"))) +(def sms-listener (.-default (js/require "react-native-android-sms-listener"))) ;; Only android is supported! diff --git a/src/status_im/utils/utils.cljs b/src/status_im/utils/utils.cljs index 02d5f1d115..b7070b460f 100644 --- a/src/status_im/utils/utils.cljs +++ b/src/status_im/utils/utils.cljs @@ -12,7 +12,7 @@ (defn log [obj] (.log js/console obj)) -(def react-native (require "react-native")) +(def react-native (js/require "react-native")) (defn show-popup [title content] (.alert (.-Alert react-native)