stub for ReactNativeModule
This commit is contained in:
parent
eac7e06f40
commit
8c044d9991
3
.env
3
.env
|
@ -1,4 +1,5 @@
|
|||
TESTFAIRY_ENABLED=0
|
||||
WALLET_WIP_ENABLED=1
|
||||
NOTIFICATIONS_WIP_ENABLED=1
|
||||
DEBUG_LOGS_ENABLED=1
|
||||
DEBUG_LOGS_ENABLED=1
|
||||
STUB_STATUS_GO=0
|
||||
|
|
|
@ -2,3 +2,5 @@ TESTFAIRY_ENABLED=1
|
|||
WALLET_WIP_ENABLED=1
|
||||
NOTIFICATIONS_WIP_ENABLED=0
|
||||
DEBUG_LOGS_ENABLED=1
|
||||
STUB_STATUS_GO=0
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
(def root-el (r/as-element [reloader]))
|
||||
(defn callback []
|
||||
(swap! cnt inc)
|
||||
(status-im.components.status/init-jail)
|
||||
(status-im.native-module.core/init-jail)
|
||||
(re-frame.core/dispatch [:load-commands!]))
|
||||
|
||||
(figwheel/watch-and-reload
|
||||
|
@ -19,4 +19,4 @@
|
|||
:heads-up-display false
|
||||
:jsload-callback callback)
|
||||
|
||||
(rr/enable-re-frisk-remote! {:host "10.0.3.2:4567" :on-init core/init :pre-send (fn [db] (update db :chats #(into {} %)))})
|
||||
(rr/enable-re-frisk-remote! {:host "localhost:4567" :on-init core/init :pre-send (fn [db] (update db :chats #(into {} %)))})
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
(def root-el (r/as-element [reloader]))
|
||||
|
||||
(figwheel/watch-and-reload
|
||||
:websocket-url "ws://localhost:3449/figwheel-ws"
|
||||
:websocket-url "ws://10.0.1.15:3449/figwheel-ws"
|
||||
:heads-up-display false
|
||||
:jsload-callback #(swap! cnt inc))
|
||||
|
||||
(rr/enable-re-frisk-remote! {:host "localhost:4567" :on-init core/init :pre-send (fn [db] (update db :chats #(into {} %)))})
|
||||
(rr/enable-re-frisk-remote! {:host "10.0.1.15:4567" :on-init core/init :pre-send (fn [db] (update db :chats #(into {} %)))})
|
|
@ -1833,7 +1833,7 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "#!/bin/bash\n\n# This script automatically sets the version and short version string of\n# an Xcode project from the Git repository containing the project.\n#\n# To use this script in Xcode, add the script's path to a \"Run Script\" build\n# phase for your application target.\n\nset -o errexit\nset -o nounset\n\n# First, check for git in $PATH\nhash git 2>/dev/null || { echo >&2 \"Git required, not installed. Aborting build number update script.\"; exit 0; }\n\n# Alternatively, we could use Xcode's copy of the Git binary,\n# but old Xcodes don't have this.\n#GIT=$(xcrun -find git)\n\n# Run Script build phases that operate on product files of the target that defines them should use the value of this build setting [TARGET_BUILD_DIR]. But Run Script build phases that operate on product files of other targets should use “BUILT_PRODUCTS_DIR” instead.\nINFO_PLIST=\"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"\n\n# Build version (closest-tag-or-branch \"-\" commits-since-tag \"-\" short-hash dirty-flag)\nBUILD_VERSION=$(git describe --tags --always --dirty=+)\n\n# Use the latest tag for short version (expected tag format \"vn[.n[.n]]\")\n# or if there are no tags, we make up version 0.0.<commit count>\nLATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null) || LATEST_TAG=\"HEAD\"\nif [ $LATEST_TAG = \"HEAD\" ]\nthen COMMIT_COUNT=$(git rev-list --count HEAD)\n LATEST_TAG=\"0.0.$COMMIT_COUNT\"\n COMMIT_COUNT_SINCE_TAG=0\nelse\n COMMIT_COUNT_SINCE_TAG=$(git rev-list --count ${LATEST_TAG}..)\n LATEST_TAG=${LATEST_TAG##v} # Remove the \"v\" from the front of the tag\nfi\nif [ $COMMIT_COUNT_SINCE_TAG = 0 ]; then\n SHORT_VERSION=\"$LATEST_TAG\"\nelse\n # increment final digit of tag and append \"d\" + commit-count-since-tag\n # e.g. commit after 1.0 is 1.1d1, commit after 1.0.0 is 1.0.1d1\n # this is the bit that requires /bin/bash\n OLD_IFS=$IFS\n IFS=\".\"\n VERSION_PARTS=($LATEST_TAG)\n LAST_PART=$((${#VERSION_PARTS[@]}-1))\n VERSION_PARTS[$LAST_PART]=$((${VERSION_PARTS[${LAST_PART}]}+1))\n SHORT_VERSION=\"${VERSION_PARTS[*]}d${COMMIT_COUNT_SINCE_TAG}\"\n IFS=$OLD_IFS\nfi\n \n# Bundle version (commits-on-master[-until-branch \".\" commits-on-branch])\n# Assumes that two release branches will not diverge from the same commit on master.\nif [ $(git rev-parse --abbrev-ref HEAD) = \"master\" ]; then\n MASTER_COMMIT_COUNT=$(git rev-list --count HEAD)\n BRANCH_COMMIT_COUNT=0\n BUNDLE_VERSION=\"$MASTER_COMMIT_COUNT\"\nelse\n MASTER_COMMIT_COUNT=$(git rev-list --count $(git rev-list master.. | tail -n 1)^)\n BRANCH_COMMIT_COUNT=$(git rev-list --count master..)\n if [ $BRANCH_COMMIT_COUNT = 0 ]\n then BUNDLE_VERSION=\"$MASTER_COMMIT_COUNT\"\n else BUNDLE_VERSION=\"${MASTER_COMMIT_COUNT}.${BRANCH_COMMIT_COUNT}\"\n fi\nfi\n \n# For debugging:\necho \"BUILD VERSION: $BUILD_VERSION\"\necho \"LATEST_TAG: $LATEST_TAG\"\necho \"COMMIT_COUNT_SINCE_TAG: $COMMIT_COUNT_SINCE_TAG\"\necho \"SHORT VERSION: $SHORT_VERSION\"\necho \"MASTER_COMMIT_COUNT: $MASTER_COMMIT_COUNT\"\necho \"BRANCH_COMMIT_COUNT: $BRANCH_COMMIT_COUNT\"\necho \"BUNDLE_VERSION: $BUNDLE_VERSION\"\n \n/usr/libexec/PlistBuddy -c \"Add :CFBundleBuildVersion string $BUILD_VERSION\" \"$INFO_PLIST\" 2>/dev/null || /usr/libexec/PlistBuddy -c \"Set :CFBundleBuildVersion $BUILD_VERSION\" \"$INFO_PLIST\"\n/usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $SHORT_VERSION\" \"$INFO_PLIST\"\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $BUNDLE_VERSION\" \"$INFO_PLIST\"";
|
||||
shellScript = "#!/bin/bash\n\n# This script automatically sets the version and short version string of\n# an Xcode project from the Git repository containing the project.\n#\n# To use this script in Xcode, add the script's path to a \"Run Script\" build\n# phase for your application target.\n\nset -o errexit\nset -o nounset\n\n# First, check for git in $PATH\nhash git 2>/dev/null || { echo >&2 \"Git required, not installed. Aborting build number update script.\"; exit 0; }\n\n# Alternatively, we could use Xcode's copy of the Git binary,\n# but old Xcodes don't have this.\n#GIT=$(xcrun -find git)\n\n# Run Script build phases that operate on product files of the target that defines them should use the value of this build setting [TARGET_BUILD_DIR]. But Run Script build phases that operate on product files of other targets should use ?BUILT_PRODUCTS_DIR? instead.\nINFO_PLIST=\"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"\n\n# Build version (closest-tag-or-branch \"-\" commits-since-tag \"-\" short-hash dirty-flag)\nBUILD_VERSION=$(git describe --tags --always --dirty=+)\n\n# Use the latest tag for short version (expected tag format \"vn[.n[.n]]\")\n# or if there are no tags, we make up version 0.0.<commit count>\nLATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null) || LATEST_TAG=\"HEAD\"\nif [ $LATEST_TAG = \"HEAD\" ]\nthen COMMIT_COUNT=$(git rev-list --count HEAD)\n LATEST_TAG=\"0.0.$COMMIT_COUNT\"\n COMMIT_COUNT_SINCE_TAG=0\nelse\n COMMIT_COUNT_SINCE_TAG=$(git rev-list --count ${LATEST_TAG}..)\n LATEST_TAG=${LATEST_TAG##v} # Remove the \"v\" from the front of the tag\nfi\nif [ $COMMIT_COUNT_SINCE_TAG = 0 ]; then\n SHORT_VERSION=\"$LATEST_TAG\"\nelse\n # increment final digit of tag and append \"d\" + commit-count-since-tag\n # e.g. commit after 1.0 is 1.1d1, commit after 1.0.0 is 1.0.1d1\n # this is the bit that requires /bin/bash\n OLD_IFS=$IFS\n IFS=\".\"\n VERSION_PARTS=($LATEST_TAG)\n LAST_PART=$((${#VERSION_PARTS[@]}-1))\n VERSION_PARTS[$LAST_PART]=$((${VERSION_PARTS[${LAST_PART}]}+1))\n SHORT_VERSION=\"${VERSION_PARTS[*]}d${COMMIT_COUNT_SINCE_TAG}\"\n IFS=$OLD_IFS\nfi\n \n# Bundle version (commits-on-master[-until-branch \".\" commits-on-branch])\n# Assumes that two release branches will not diverge from the same commit on master.\nif [ $(git rev-parse --abbrev-ref HEAD) = \"master\" ]; then\n MASTER_COMMIT_COUNT=$(git rev-list --count HEAD)\n BRANCH_COMMIT_COUNT=0\n BUNDLE_VERSION=\"$MASTER_COMMIT_COUNT\"\nelse\n MASTER_COMMIT_COUNT=$(git rev-list --count $(git rev-list master.. | tail -n 1)^)\n BRANCH_COMMIT_COUNT=$(git rev-list --count master..)\n if [ $BRANCH_COMMIT_COUNT = 0 ]\n then BUNDLE_VERSION=\"$MASTER_COMMIT_COUNT\"\n else BUNDLE_VERSION=\"${MASTER_COMMIT_COUNT}.${BRANCH_COMMIT_COUNT}\"\n fi\nfi\n \n# For debugging:\necho \"BUILD VERSION: $BUILD_VERSION\"\necho \"LATEST_TAG: $LATEST_TAG\"\necho \"COMMIT_COUNT_SINCE_TAG: $COMMIT_COUNT_SINCE_TAG\"\necho \"SHORT VERSION: $SHORT_VERSION\"\necho \"MASTER_COMMIT_COUNT: $MASTER_COMMIT_COUNT\"\necho \"BRANCH_COMMIT_COUNT: $BRANCH_COMMIT_COUNT\"\necho \"BUNDLE_VERSION: $BUNDLE_VERSION\"\n \n/usr/libexec/PlistBuddy -c \"Add :CFBundleBuildVersion string $BUILD_VERSION\" \"$INFO_PLIST\" 2>/dev/null || /usr/libexec/PlistBuddy -c \"Set :CFBundleBuildVersion $BUILD_VERSION\" \"$INFO_PLIST\"\n/usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $SHORT_VERSION\" \"$INFO_PLIST\"\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $BUNDLE_VERSION\" \"$INFO_PLIST\"";
|
||||
};
|
||||
E883D1F9B22B8292CC879292 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
status-im.data-store.core
|
||||
[status-im.ui.screens.views :as views]
|
||||
[status-im.components.react :as react]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.error-handler :as error-handler]
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.utils.config :as config]
|
||||
|
@ -78,7 +78,7 @@
|
|||
|
||||
(defn init []
|
||||
(error-handler/register-exception-handler!)
|
||||
(status/call-module status/init-jail)
|
||||
(status/init-jail)
|
||||
(.registerComponent react/app-registry "StatusIm" #(reagent/reactify-component app-root))
|
||||
(status/set-soft-input-mode status/adjust-resize)
|
||||
(init-back-button-handler!)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.bots.handlers
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.handlers :as u]))
|
||||
|
||||
(defn chats-with-bot [chats bot]
|
||||
|
@ -74,4 +74,4 @@
|
|||
(u/register-handler :clear-bot-db
|
||||
(fn [{:keys [current-chat-id] :as app-db} [_ {:keys [bot]}]]
|
||||
(let [bot (or bot current-chat-id)]
|
||||
(assoc-in app-db [:bot-db bot] nil))))
|
||||
(assoc-in app-db [:bot-db bot] nil))))
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
[taoensso.timbre :as log]
|
||||
[status-im.data-store.messages :as msg-store]
|
||||
[status-im.utils.handlers :refer [register-handler-fx]]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.utils.platform :as platform]))
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
[status-im.chat.models.input :as input-model]
|
||||
[status-im.chat.models.suggestions :as suggestions]
|
||||
[status-im.components.react :as react-comp]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.datetime :as time]
|
||||
[status-im.utils.handlers :refer [register-handler-db register-handler-fx]]
|
||||
[status-im.utils.random :as random]
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
[status-im.handlers.server :as server]
|
||||
[status-im.utils.phone-number :refer [format-phone-number
|
||||
valid-mobile-number?]]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.types :refer [json->clj]]
|
||||
[status-im.chat.utils :refer [console? not-console? safe-trim]]
|
||||
[status-im.utils.gfycat.core :refer [generate-gfy]]
|
||||
|
@ -628,4 +628,4 @@
|
|||
:show-profile
|
||||
(fn [{db :db} [_ identity]]
|
||||
{:db (assoc db :contacts/identity identity)
|
||||
:dispatch [:navigate-forget :profile]}))
|
||||
:dispatch [:navigate-forget :profile]}))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
(:require [status-im.utils.handlers :refer [register-handler] :as u]
|
||||
[clojure.string :as s]
|
||||
[status-im.data-store.messages :as messages]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.random :as random]
|
||||
[status-im.utils.datetime :as time]
|
||||
[re-frame.core :refer [enrich after dispatch path]]
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
[taoensso.timbre :as log]
|
||||
[status-im.models.commands :as commands]
|
||||
[status-im.commands.utils :as cu]
|
||||
[status-im.components.status :as s]
|
||||
[status-im.native-module.core :as s]
|
||||
[status-im.components.nfc :as nfc]
|
||||
[status-im.constants :as c]
|
||||
[cljs.reader :refer [read-string]]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns status-im.chat.models.input
|
||||
(:require [clojure.string :as str]
|
||||
[status-im.components.react :as rc]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.chat.constants :as const]
|
||||
[status-im.chat.views.input.validation-messages :refer [validation-message]]
|
||||
[status-im.i18n :as i18n]
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
[re-frame.core :refer [dispatch]]
|
||||
[status-im.components.webview-bridge :refer [webview-bridge]]
|
||||
[status-im.components.react :refer [view text] :as components]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.i18n :refer [label]]
|
||||
[status-im.utils.js-resources :as js-res]
|
||||
[clojure.string :as str]
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
[clojure.string :as s]
|
||||
[status-im.data-store.commands :as commands]
|
||||
[status-im.data-store.contacts :as contacts]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.types :refer [json->clj]]
|
||||
[status-im.commands.utils :refer [reg-handler]]
|
||||
[status-im.constants :refer [console-chat-id wallet-chat-id]]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
(:require [re-frame.core :refer [after dispatch]]
|
||||
[status-im.utils.handlers :refer [register-handler] :as u]
|
||||
[status-im.components.react :refer [http-bridge]]
|
||||
[status-im.components.status :refer [cljs->json]]
|
||||
[status-im.utils.types :refer [clj->json]]
|
||||
[status-im.data-store.messages :as messages]
|
||||
[status-im.data-store.accounts :as accounts]
|
||||
[taoensso.timbre :as log]
|
||||
|
@ -14,7 +14,7 @@
|
|||
(.respond http-bridge
|
||||
200
|
||||
"application/json"
|
||||
(cljs->json data)))
|
||||
(clj->json data)))
|
||||
|
||||
(register-handler :init-debug-mode
|
||||
(u/side-effect!
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
status-im.data-store.core
|
||||
[status-im.ui.screens.views :as views]
|
||||
[status-im.components.react :as react]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.error-handler :as error-handler]
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.utils.config :as config]
|
||||
|
@ -53,6 +53,6 @@
|
|||
|
||||
(defn init []
|
||||
(error-handler/register-exception-handler!)
|
||||
(status/call-module status/init-jail)
|
||||
(status/init-jail)
|
||||
(.registerComponent react/app-registry "StatusIm" #(reagent/reactify-component app-root))
|
||||
(dispatch-sync [:initialize-app]))
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
(ns status-im.native-module.core
|
||||
(:require [status-im.native-module.module :as module-interface]
|
||||
[status-im.native-module.impl.module :as native-module]
|
||||
[status-im.native-module.impl.non-status-go-module :as non-status-go-module]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.config :as config]))
|
||||
|
||||
(def rns-module
|
||||
(if config/stub-status-go?
|
||||
(non-status-go-module/ReactNativeStatus.)
|
||||
(native-module/ReactNativeStatus.)))
|
||||
|
||||
|
||||
(def adjust-resize 16)
|
||||
(def adjust-pan 32)
|
||||
|
||||
#_(defn- wrap-and-print-callback [name callback]
|
||||
(fn [& args]
|
||||
(println :callback name (str args))
|
||||
(log/debug :callback name args)
|
||||
(apply callback args)))
|
||||
|
||||
(defn init-jail []
|
||||
(module-interface/-init-jail rns-module))
|
||||
|
||||
|
||||
(defn move-to-internal-storage [callback]
|
||||
(module-interface/-move-to-internal-storage rns-module callback))
|
||||
|
||||
|
||||
(defn start-node [callback]
|
||||
(module-interface/-start-node rns-module callback))
|
||||
|
||||
|
||||
(defn stop-rpc-server []
|
||||
(module-interface/-stop-rpc-server rns-module))
|
||||
|
||||
|
||||
(defn start-rpc-server []
|
||||
(module-interface/-start-rpc-server rns-module))
|
||||
|
||||
|
||||
(defn restart-rpc []
|
||||
(module-interface/-restart-rpc rns-module))
|
||||
|
||||
|
||||
(defn create-account [password callback]
|
||||
(module-interface/-create-account rns-module password callback))
|
||||
|
||||
|
||||
(defn recover-account [passphrase password callback]
|
||||
(module-interface/-recover-account rns-module passphrase password callback))
|
||||
|
||||
|
||||
(defn login [address password callback]
|
||||
(module-interface/-login rns-module address password callback))
|
||||
|
||||
|
||||
(defn complete-transactions [hashes password callback]
|
||||
(module-interface/-complete-transactions rns-module hashes password callback))
|
||||
|
||||
|
||||
(defn discard-transaction [id]
|
||||
(module-interface/-discard-transaction rns-module id))
|
||||
|
||||
|
||||
(defn parse-jail [chat-id file callback]
|
||||
(module-interface/-parse-jail rns-module chat-id file callback))
|
||||
|
||||
|
||||
(defn call-jail [params]
|
||||
(module-interface/-call-jail rns-module params))
|
||||
|
||||
|
||||
(defn call-function! [params]
|
||||
(module-interface/-call-function! rns-module params))
|
||||
|
||||
|
||||
(defn set-soft-input-mode [mode]
|
||||
(module-interface/-set-soft-input-mode rns-module mode))
|
||||
|
||||
|
||||
(defn clear-web-data []
|
||||
(module-interface/-clear-web-data rns-module))
|
||||
|
||||
(defn call-web3 [host payload callback]
|
||||
(module-interface/-call-web3 rns-module host payload callback))
|
||||
|
||||
(defn module-initialized! []
|
||||
(module-interface/-module-initialized! rns-module))
|
||||
|
||||
(defn should-move-to-internal-storage? [callback]
|
||||
(module-interface/-should-move-to-internal-storage? rns-module callback))
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.components.status
|
||||
(ns status-im.native-module.impl.module
|
||||
(:require-macros
|
||||
[cljs.core.async.macros :refer [go-loop go]])
|
||||
(:require [status-im.components.react :as r]
|
||||
|
@ -9,10 +9,9 @@
|
|||
[status-im.utils.js-resources :as js-res]
|
||||
[status-im.utils.platform :as p]
|
||||
[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)))
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.react-native.js-dependencies :as rn-dependencies]
|
||||
[status-im.native-module.module :as module]))
|
||||
|
||||
;; if StatusModule is not initialized better to store
|
||||
;; calls and make them only when StatusModule is ready
|
||||
|
@ -52,8 +51,11 @@
|
|||
(.-Status (.-NativeModules rn-dependencies/react-native))))
|
||||
|
||||
(defn init-jail []
|
||||
(let [init-js (str js-res/status-js "I18n.locale = '" rn-dependencies/i18n.locale "';")]
|
||||
(.initJail status init-js #(log/debug "jail initialized"))))
|
||||
(when status
|
||||
(call-module
|
||||
(fn []
|
||||
(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))
|
||||
|
||||
|
@ -124,7 +126,7 @@
|
|||
[hashes password callback]
|
||||
(log/debug :complete-transactions (boolean status) hashes)
|
||||
(when status
|
||||
(call-module #(.completeTransactions status (cljs->json hashes) password callback))))
|
||||
(call-module #(.completeTransactions status (types/clj->json hashes) password callback))))
|
||||
|
||||
(defn discard-transaction
|
||||
[id]
|
||||
|
@ -154,7 +156,7 @@
|
|||
(doseq [{:keys [type message]} messages]
|
||||
(log/debug (str "VM console(" type ") - " message)))
|
||||
(callback r')))]
|
||||
(.callJail status jail-id (cljs->json path) (cljs->json params') cb))))))
|
||||
(.callJail status jail-id (types/clj->json path) (types/clj->json params') cb))))))
|
||||
|
||||
(defn call-function!
|
||||
[{:keys [chat-id function callback] :as opts}]
|
||||
|
@ -175,9 +177,50 @@
|
|||
(call-module #(.clearCookies status))
|
||||
(call-module #(.clearStorageAPIs status))))
|
||||
|
||||
(def adjust-resize 16)
|
||||
(def adjust-pan 32)
|
||||
|
||||
(defn call-web3 [host payload callback]
|
||||
(when status
|
||||
(call-module #(.sendWeb3Request status host payload callback))))
|
||||
|
||||
(defrecord ReactNativeStatus []
|
||||
module/IReactNativeStatus
|
||||
;; status-go calls
|
||||
(-init-jail [this]
|
||||
(init-jail))
|
||||
(-start-node [this callback]
|
||||
(start-node callback))
|
||||
(-stop-rpc-server [this]
|
||||
(stop-rpc-server))
|
||||
(-start-rpc-server [this]
|
||||
(start-rpc-server))
|
||||
(-restart-rpc [this]
|
||||
(restart-rpc))
|
||||
(-create-account [this password callback]
|
||||
(create-account password callback))
|
||||
(-recover-account [this passphrase password callback]
|
||||
(recover-account passphrase password callback))
|
||||
(-login [this address password callback]
|
||||
(login address password callback))
|
||||
(-complete-transactions [this hashes password callback]
|
||||
(complete-transactions hashes password callback))
|
||||
(-discard-transaction [this id]
|
||||
(discard-transaction id))
|
||||
(-parse-jail [this chat-id file callback]
|
||||
(parse-jail chat-id file callback))
|
||||
(-call-jail [this params]
|
||||
(call-jail params))
|
||||
(-call-function! [this params]
|
||||
(call-function! params))
|
||||
(-call-web3 [this host payload callback]
|
||||
(call-web3 host payload callback))
|
||||
|
||||
;; other calls
|
||||
(-move-to-internal-storage [this callback]
|
||||
(move-to-internal-storage callback))
|
||||
(-set-soft-input-mode [this mode]
|
||||
(set-soft-input-mode mode))
|
||||
(-clear-web-data [this]
|
||||
(clear-web-data))
|
||||
(-module-initialized! [this]
|
||||
(module-initialized!))
|
||||
(-should-move-to-internal-storage? [this callback]
|
||||
(should-move-to-internal-storage? callback)))
|
|
@ -0,0 +1,62 @@
|
|||
(ns status-im.native-module.impl.non-status-go-module
|
||||
(:require [status-im.native-module.module :as module]
|
||||
[status-im.native-module.impl.module :as impl]
|
||||
[status-im.constants :as constants]
|
||||
[re-frame.core :as re-frame]
|
||||
[goog.string :as gstring]
|
||||
[goog.string.format]))
|
||||
|
||||
(def wrong-password "111")
|
||||
|
||||
(defrecord ReactNativeStatus []
|
||||
module/IReactNativeStatus
|
||||
;; status-go calls
|
||||
(-init-jail [this])
|
||||
(-start-node [this callback]
|
||||
(re-frame/dispatch [:signal-event "{\"type\":\"node.started\",\"event\":{}}"])
|
||||
(re-frame/dispatch [:signal-event "{\"type\":\"node.ready\",\"event\":{}}"]))
|
||||
(-stop-rpc-server [this])
|
||||
(-start-rpc-server [this])
|
||||
(-restart-rpc [this])
|
||||
(-create-account [this password callback]
|
||||
(let [address (str "c9f5c0e2bea0aabb6b0b618e9f45ab0958" (gstring/format "%06d" (rand-int 100000)))]
|
||||
(callback (str "{\"address\":\"" address "\",\"pubkey\":\"0x046a313ba760e8853356b42a8732db1e2c339602977a3ac3d57ec2056449439b2c9f28e2e0dd243ac319f5da198b4a96f980d0ab6d4c7220ca7c5e1af2bd1ee8c7\",\"mnemonic\":\"robust rib ramp adult cannon amateur refuse burden review feel scout sell\",\"error\":\"\"}"))))
|
||||
(-recover-account [this passphrase password callback])
|
||||
(-login [this address password callback]
|
||||
(if (not= password wrong-password)
|
||||
(callback "{\"error\":\"\"}")
|
||||
(callback "{\"error\":\"cannot retrieve a valid key for a given account: could not decrypt key with given passphrase\"}")))
|
||||
(-complete-transactions [this hashes password callback])
|
||||
(-discard-transaction [this id])
|
||||
(-parse-jail [this chat-id file callback]
|
||||
(when (= chat-id constants/console-chat-id)
|
||||
(callback "{\"result\": {\"commands\":{\"debug\":{\"color\":\"#7099e6\",\"description\":\"Starts/stops a debug mode\",\"has-handler\":false,\"name\":\"debug\",\"params\":[{\"name\":\"mode\",\"type\":\"text\"}],\"registered-only\":true,\"title\":\"Debug mode\"},\"faucet\":{\"color\":\"#7099e6\",\"description\":\"Get some ETH\",\"has-handler\":false,\"name\":\"faucet\",\"params\":[{\"name\":\"url\",\"placeholder\":\"Faucet URL\",\"type\":\"text\"}],\"registered-only\":true,\"title\":\"Faucet\"},\"phone\":{\"color\":\"#5bb2a2\",\"description\":\"Find friends using your number\",\"has-handler\":false,\"icon\":\"phone_white\",\"name\":\"phone\",\"params\":[{\"name\":\"phone\",\"placeholder\":\"Phone number\",\"type\":\"phone\"}],\"registered-only\":true,\"sequential-params\":true,\"title\":\"Send Phone Number\"}},\"functions\":{},\"responses\":{\"confirmation-code\":{\"color\":\"#7099e6\",\"description\":\"Confirmation code\",\"has-handler\":false,\"name\":\"confirmation-code\",\"params\":[{\"name\":\"code\",\"type\":\"number\"}],\"sequential-params\":true},\"grant-permissions\":{\"color\":\"#7099e6\",\"description\":\"Grant permissions\",\"execute-immediately?\":true,\"has-handler\":false,\"icon\":\"lock_white\",\"name\":\"grant-permissions\",\"params\":[]},\"password\":{\"color\":\"#7099e6\",\"description\":\"Password\",\"has-handler\":false,\"icon\":\"lock_white\",\"name\":\"password\",\"params\":[{\"hidden\":true,\"name\":\"password\",\"placeholder\":\"Type your password\",\"type\":\"password\"},{\"hidden\":true,\"name\":\"password-confirmation\",\"placeholder\":\"Confirm\",\"type\":\"password\"}],\"sequential-params\":true},\"phone\":{\"color\":\"#5bb2a2\",\"description\":\"Find friends using your number\",\"has-handler\":false,\"icon\":\"phone_white\",\"name\":\"phone\",\"params\":[{\"name\":\"phone\",\"placeholder\":\"Phone number\",\"type\":\"phone\"}],\"registered-only\":true,\"sequential-params\":true,\"title\":\"Send Phone Number\"}},\"subscriptions\":{}}}")))
|
||||
(-call-jail [this {:keys [callback path] :as params}]
|
||||
(cond
|
||||
(= path [:responses "password" :preview])
|
||||
(callback {:result {:context {},
|
||||
:messages [],
|
||||
:returned {:markup ["text"
|
||||
{:style
|
||||
{:color "black",
|
||||
:fontSize 8,
|
||||
:letterSpacing 1,
|
||||
:marginBottom 2,
|
||||
:marginHorizontal 0,
|
||||
:marginTop 10}}
|
||||
"●●●●●●●●●●"]}}})
|
||||
:else (callback {:result nil})))
|
||||
(-call-function! [this params])
|
||||
(-call-web3 [this host payload callback])
|
||||
|
||||
;; other calls
|
||||
(-move-to-internal-storage [this callback]
|
||||
(impl/move-to-internal-storage callback))
|
||||
(-set-soft-input-mode [this mode]
|
||||
(impl/set-soft-input-mode mode))
|
||||
(-clear-web-data [this]
|
||||
(impl/clear-web-data))
|
||||
(-module-initialized! [this]
|
||||
(impl/module-initialized!))
|
||||
(-should-move-to-internal-storage? [this callback]
|
||||
(impl/should-move-to-internal-storage? callback)))
|
|
@ -0,0 +1,23 @@
|
|||
(ns status-im.native-module.module)
|
||||
|
||||
(defprotocol IReactNativeStatus
|
||||
(-init-jail [this])
|
||||
(-move-to-internal-storage [this callback])
|
||||
(-start-node [this callback])
|
||||
(-stop-rpc-server [this])
|
||||
(-start-rpc-server [this])
|
||||
(-restart-rpc [this])
|
||||
(-create-account [this password callback])
|
||||
(-recover-account [this passphrase password callback])
|
||||
(-login [this address password callback])
|
||||
(-complete-transactions [this hashes password callback])
|
||||
(-discard-transaction [this id])
|
||||
(-parse-jail [this chat-id file callback])
|
||||
(-call-jail [this params])
|
||||
(-call-function! [this params])
|
||||
(-set-soft-input-mode [this mode])
|
||||
(-clear-web-data [this])
|
||||
(-call-web3 [this host payload callback])
|
||||
(-module-initialized! [this])
|
||||
(-should-move-to-internal-storage? [this callback]))
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
[status-im.utils.datetime :as dt]
|
||||
[taoensso.timbre :as log :refer-macros [debug]]
|
||||
[status-im.constants :as c]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[clojure.string :refer [join]]
|
||||
[status-im.utils.scheduler :as s]
|
||||
[status-im.utils.web3-provider :as w3]
|
||||
|
@ -402,4 +402,4 @@
|
|||
(let [now (time/now-ms)
|
||||
messages (processed-messages/get-filtered (str "ttl > " now))]
|
||||
(cache/init! messages)
|
||||
(processed-messages/delete (str "ttl <=" now))))))
|
||||
(processed-messages/delete (str "ttl <=" now))))))
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
[status-im.utils.handlers :as u]
|
||||
[status-im.utils.types :as t]
|
||||
[status-im.utils.hex :refer [valid-hex? normalize-hex]]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[clojure.string :as s]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
[re-frame.core :refer [reg-cofx reg-fx dispatch inject-cofx]]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.protocol.core :as protocol]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.types :refer [json->clj]]
|
||||
[status-im.utils.identicon :refer [identicon]]
|
||||
[status-im.utils.random :as random]
|
||||
|
@ -56,8 +56,7 @@
|
|||
(log/debug "account-created")
|
||||
(when-not (str/blank? public-key)
|
||||
(dispatch [:show-mnemonic mnemonic phrase])
|
||||
(dispatch [:add-account account])
|
||||
(dispatch [:login-account address password true]))))
|
||||
(dispatch [:add-account account password]))))
|
||||
|
||||
(reg-fx
|
||||
::create-account
|
||||
|
@ -97,10 +96,11 @@
|
|||
|
||||
(register-handler-fx
|
||||
:add-account
|
||||
(fn [{{:keys [network] :as db} :db} [_ {:keys [address] :as account}]]
|
||||
(fn [{{:keys [network] :as db} :db} [_ {:keys [address] :as account} password]]
|
||||
(let [account' (assoc account :network network)]
|
||||
{:db (assoc-in db [:accounts/accounts address] account')
|
||||
::save-account account'})))
|
||||
{:db (assoc-in db [:accounts/accounts address] account')
|
||||
::save-account account'
|
||||
:dispatch-later [{:ms 400 :dispatch [:login-account address password true]}]})))
|
||||
|
||||
(register-handler-fx
|
||||
:create-account
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
[taoensso.timbre :as log]
|
||||
[status-im.utils.types :refer [json->clj]]
|
||||
[status-im.data-store.core :as data-store]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.constants :refer [console-chat-id]]))
|
||||
|
||||
;;;; FX
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
status-im.ui.screens.accounts.recover.navigation
|
||||
|
||||
[re-frame.core :refer [reg-fx inject-cofx dispatch]]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.types :refer [json->clj]]
|
||||
[status-im.utils.identicon :refer [identicon]]
|
||||
[taoensso.timbre :as log]
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
status-im.ui.screens.qr-scanner.events
|
||||
status-im.ui.screens.wallet.events
|
||||
[re-frame.core :refer [dispatch reg-fx]]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.components.permissions :as permissions]
|
||||
[status-im.constants :refer [console-chat-id]]
|
||||
[status-im.data-store.core :as data-store]
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
[status-im.utils.transactions :as transactions]
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.ui.screens.wallet.db :as wallet.db]
|
||||
[status-im.components.status :as status]
|
||||
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ui.screens.wallet.navigation]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
|
|
|
@ -12,3 +12,5 @@
|
|||
(def testfairy-enabled? (enabled? (get-config :TESTFAIRY_ENABLED)))
|
||||
(def wallet-wip-enabled? (enabled? (get-config :WALLET_WIP_ENABLED 0)))
|
||||
(def notifications-wip-enabled? (enabled? (get-config :NOTIFICATIONS_WIP_ENABLED 0)))
|
||||
(def stub-status-go? (enabled? (get-config :STUB_STATUS_GO 0)))
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.utils.web3-provider
|
||||
(:require [taoensso.timbre :as log]
|
||||
[status-im.components.status :as status]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.js-dependencies :as dependencies]))
|
||||
|
||||
(defn get-provider [rpc-url]
|
||||
|
|
Loading…
Reference in New Issue