From efbf93f6e2ce42d34070510c2cbdb8bad9fbe7d9 Mon Sep 17 00:00:00 2001 From: flexsurfer Date: Wed, 26 Apr 2023 18:14:14 +0200 Subject: [PATCH] move status native module (#15749) --- .carve_ignore | 10 +- src/{status_im => }/native_module/core.cljs | 127 ++---------------- .../native_module/core_test.cljs | 6 +- src/react_native/core.cljs | 2 + src/status_im/add_new/db.cljs | 2 +- src/status_im/browser/core.cljs | 6 +- src/status_im/chat/models/mentions.cljs | 8 +- src/status_im/ethereum/core.cljs | 10 +- src/status_im/ethereum/eip55.cljs | 6 +- src/status_im/ethereum/encode.cljs | 4 +- src/status_im/ethereum/ens.cljs | 4 +- src/status_im/events.cljs | 6 +- src/status_im/keycard/fx.cljs | 4 +- src/status_im/keycard/real_keycard.cljs | 10 +- src/status_im/keycard/recovery.cljs | 6 +- src/status_im/keycard/simulated_keycard.cljs | 30 ++--- .../multiaccounts/biometric/core.cljs | 4 +- src/status_im/multiaccounts/core.cljs | 2 +- src/status_im/multiaccounts/create/core.cljs | 10 +- .../multiaccounts/key_storage/core.cljs | 2 +- src/status_im/multiaccounts/login/core.cljs | 12 +- src/status_im/multiaccounts/logout/core.cljs | 4 +- src/status_im/multiaccounts/recover/core.cljs | 8 +- .../multiaccounts/reset_password/core.cljs | 10 +- src/status_im/network/net_info.cljs | 4 +- src/status_im/node/core.cljs | 4 +- src/status_im/notifications/local.cljs | 6 +- src/status_im/router/core.cljs | 7 +- src/status_im/signing/core.cljs | 44 +++--- src/status_im/signing/core_test.cljs | 8 +- src/status_im/signing/keycard.cljs | 18 +-- .../ui/screens/add_new/new_chat/views.cljs | 2 +- .../ui/screens/network_info/views.cljs | 4 +- .../privacy_and_security_settings/events.cljs | 6 +- src/status_im/utils/gfycat/core.cljs | 13 +- src/status_im/utils/identicon.cljs | 13 +- src/status_im/utils/keychain/core.cljs | 4 +- src/status_im/utils/logging/core.cljs | 4 +- src/status_im/utils/react_native.cljs | 8 -- src/status_im/utils/universal_links/core.cljs | 4 +- src/status_im/wallet/accounts/core.cljs | 16 +-- src/status_im2/common/json_rpc/events.cljs | 4 +- .../contexts/add_new_contact/events.cljs | 10 +- .../chat/messages/pin/banner/view.cljs | 2 +- .../messages/resolver}/message_resolver.cljs | 2 +- .../resolver}/message_resolver_test.cljs | 4 +- .../contexts/onboarding/events.cljs | 14 +- .../contexts/onboarding/profiles/view.cljs | 4 +- src/status_im2/contexts/shell/cards/view.cljs | 2 +- src/status_im2/contexts/syncing/events.cljs | 10 +- src/status_im2/core.cljs | 9 +- src/status_im2/events.cljs | 4 +- src/{status_im2 => }/utils/validators.cljs | 2 +- .../utils/validators_test.cljs | 4 +- 54 files changed, 202 insertions(+), 327 deletions(-) rename src/{status_im => }/native_module/core.cljs (80%) rename src/{status_im => }/native_module/core_test.cljs (77%) delete mode 100644 src/status_im/utils/react_native.cljs rename src/status_im2/{utils => contexts/chat/messages/resolver}/message_resolver.cljs (88%) rename src/status_im2/{utils => contexts/chat/messages/resolver}/message_resolver_test.cljs (83%) rename src/{status_im2 => }/utils/validators.cljs (89%) rename src/{status_im2 => }/utils/validators_test.cljs (91%) diff --git a/.carve_ignore b/.carve_ignore index 6914071f1e..ad0c30d692 100644 --- a/.carve_ignore +++ b/.carve_ignore @@ -12,11 +12,11 @@ status-im.chat.models.message-content/actions status-im.chat.models.message-content/blank-string status-im.chat.models.message-content/sorted-ranges status-im.ethereum.mnemonic/words->passphrase -status-im.native-module.core/listener -status-im.native-module.core/multiaccount-reset -status-im.native-module.core/extract-group-membership-signatures -status-im.native-module.core/sign-group-membership -status-im.native-module.core/update-mailservers +native-module.core/listener +native-module.core/multiaccount-reset +native-module.core/extract-group-membership-signatures +native-module.core/sign-group-membership +native-module.core/update-mailservers status-im.ethereum.abi-spec/bytes-to-hex status-im.android.core/init status-im.chat.models.message/transport-keys diff --git a/src/status_im/native_module/core.cljs b/src/native_module/core.cljs similarity index 80% rename from src/status_im/native_module/core.cljs rename to src/native_module/core.cljs index f3613595d8..4ec7f7b584 100644 --- a/src/status_im/native_module/core.cljs +++ b/src/native_module/core.cljs @@ -1,19 +1,19 @@ -(ns status-im.native-module.core +(ns native-module.core (:require ["react-native" :as react-native] - [re-frame.core :as re-frame] - [status-im2.utils.validators :as validators] - [status-im.utils.platform :as platform] - [status-im.utils.react-native :as react-native-utils] - [status-im.utils.types :as types] + [utils.validators :as validators] [taoensso.timbre :as log] - [status-im2.constants :as constants])) + [react-native.platform :as platform] + [react-native.core :as rn] + [utils.transforms :as types])) (defn status [] (when (exists? (.-NativeModules react-native)) (.-Status ^js (.-NativeModules react-native)))) -(def adjust-resize 16) +(defn init + [handler] + (.addListener ^js rn/device-event-emitter "gethEvent" #(handler (.-jsonEvent ^js %)))) (defn clear-web-data [] @@ -72,15 +72,6 @@ accounts-data chat-key))) -(defn login - "NOTE: beware, the password has to be sha3 hashed" - [key-uid account-data hashed-password] - (log/debug "[native-module] login") - (clear-web-data) - (init-keystore - key-uid - #(.login ^js (status) account-data hashed-password))) - (defn login-with-config "NOTE: beware, the password has to be sha3 hashed" [key-uid account-data hashed-password config] @@ -123,11 +114,6 @@ (clear-web-data) (.logout ^js (status))) -(defonce listener - (.addListener ^js react-native-utils/device-event-emitter - "gethEvent" - #(re-frame/dispatch [:signals/signal-received (.-jsonEvent ^js %)]))) - (defn multiaccount-load-account "NOTE: beware, the password has to be sha3 hashed @@ -141,14 +127,6 @@ :password hashed-password}) callback)) -(defn multiaccount-reset - "TODO: this function is not used anywhere - if usage isn't planned, remove" - [callback] - (log/debug "[native-module] multiaccount-reset") - (.multiAccountReset ^js (status) - callback)) - (defn multiaccount-derive-addresses "NOTE: this should be named derive-accounts this only derive addresses, they still need to be stored @@ -298,43 +276,13 @@ :key key}) (.deserializeAndCompressKey ^js (status) key callback)) - -(defn public-key->compressed-key - "Provides public key to status-go and gets back a compressed key via serialization" - [public-key callback] - (let [serialization-key constants/serialization-key - multi-code-prefix constants/multi-code-prefix - multi-code-key (str multi-code-prefix (subs public-key 2))] - (log/info "[native-module] Serializing public key" - {:fn :public-key->compressed-key - :public-key public-key - :multi-code-key multi-code-key}) - (.multiformatSerializePublicKey ^js (status) multi-code-key serialization-key callback))) - (defn compressed-key->public-key "Provides compressed key to status-go and gets back the uncompressed public key via deserialization" - [public-key callback] - (let [deserialization-key constants/deserialization-key] - (log/info "[native-module] Deserializing compressed key" - {:fn :compressed-key->public-key - :public-key public-key}) - (.multiformatDeserializePublicKey ^js (status) public-key deserialization-key callback))) - -(defn decompress-public-key - "Provides compressed key to status-go and gets back the uncompressed public key" - [public-key callback] - (log/info "[native-module] Decompressing public key" - {:fn :decompress-public-key + [public-key deserialization-key callback] + (log/info "[native-module] Deserializing compressed key" + {:fn :compressed-key->public-key :public-key public-key}) - (.decompressPublicKey ^js (status) public-key callback)) - -(defn compress-public-key - "Provides a public key to status-go and gets back a 33bit compressed key back" - [public-key callback] - (log/info "[native-module] Compressing public key" - {:fn :compress-public-key - :public-key public-key}) - (.compressPublicKey ^js (status) public-key callback)) + (.multiformatDeserializePublicKey ^js (status) public-key deserialization-key callback)) (defn hash-typed-data "used for keycard" @@ -388,11 +336,6 @@ (log/debug "[native-module] send-logs") (.sendLogs ^js (status) dbJson js-logs callback)) -(defn add-peer - [enode on-result] - (log/debug "[native-module] add-peer") - (.addPeer ^js (status) enode on-result)) - (defn close-application [] (log/debug "[native-module] close-application") @@ -408,11 +351,6 @@ (log/debug "[native-module] app-state-change") (.appStateChange ^js (status) state)) -(defn stop-local-notifications - [] - (log/debug "[native-module] stop-local-notifications") - (.stopLocalNotifications ^js (status))) - (defn start-local-notifications [] (log/debug "[native-module] start-local-notifications") @@ -433,26 +371,11 @@ :build-id (.-buildId status) :device-id (.-deviceId status)})) -(defn extract-group-membership-signatures - [signature-pairs callback] - (log/debug "[native-module] extract-group-membership-signatures") - (.extractGroupMembershipSignatures ^js (status) signature-pairs callback)) - -(defn sign-group-membership - [content callback] - (log/debug "[native-module] sign-group-membership") - (.signGroupMembership ^js (status) content callback)) - (defn get-node-config [callback] (log/debug "[native-module] get-node-config") (.getNodeConfig ^js (status) callback)) -(defn update-mailservers - [enodes on-result] - (log/debug "[native-module] update-mailservers") - (.updateMailservers ^js (status) enodes on-result)) - (defn toggle-webview-debug [on] (log/debug "[native-module] toggle-webview-debug" on) @@ -483,12 +406,6 @@ (when (validators/valid-public-key? public-key) (.generateAlias ^js (status) public-key))) -(defn generate-gfycat-async - "Generate a 3 words random name based on the user public-key, asynchronously" - [public-key callback] - (when (validators/valid-public-key? public-key) - (.generateAliasAsync ^js (status) public-key callback))) - (defn identicon "Generate a icon based on a string, synchronously" [seed] @@ -500,11 +417,6 @@ (log/debug "[native-module] encode-transfer") (.encodeTransfer ^js (status) to-norm amount-hex)) -(defn encode-function-call - [method params] - (log/debug "[native-module] encode-function-call") - (.encodeFunctionCall ^js (status) method (types/clj->json params))) - (defn decode-parameters [bytes-string types] (log/debug "[native-module] decode-parameters") @@ -555,11 +467,6 @@ (log/debug "[native-module] to-checksum-address") (.toChecksumAddress ^js (status) address)) -(defn identicon-async - "Generate a icon based on a string, asynchronously" - [seed callback] - (.identiconAsync ^js (status) seed callback)) - (defn gfycat-identicon-async "Generate an icon based on a string and 3 words random name asynchronously" [seed callback] @@ -585,16 +492,6 @@ (log/debug "[native-module] delete-imported-key") (.deleteImportedKey ^js (status) key-uid address hashed-password callback)) -(defn activate-keep-awake - [] - (log/debug "[native-module] activateKeepAwake") - (.activateKeepAwake ^js (status))) - -(defn deactivate-keep-awake - [] - (log/debug "[native-module] deactivateKeepAwake") - (.deactivateKeepAwake ^js (status))) - (defn reset-keyboard-input [input selection] (log/debug "[native-module] resetKeyboardInput") diff --git a/src/status_im/native_module/core_test.cljs b/src/native_module/core_test.cljs similarity index 77% rename from src/status_im/native_module/core_test.cljs rename to src/native_module/core_test.cljs index 9d1f37ca56..fe91fb964b 100644 --- a/src/status_im/native_module/core_test.cljs +++ b/src/native_module/core_test.cljs @@ -1,10 +1,10 @@ -(ns status-im.native-module.core-test +(ns native-module.core-test (:require [cljs.test :refer [deftest is testing]] - [status-im.native-module.core :as status])) + [native-module.core :as native-module])) (deftest identicon-test (testing "check if identicon test works" (is (= "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAjklEQVR4nOzXsQmAMBQGYRV3cUAdQwd0Gm2sJIWSBI6f+0oR8XjwSKYhhCE0htAYQmMITUzI/PXF49yv0vN12cYWP1L7/ZiJGEJjCE31xvm7bXptv5iJGEJjCE31WasVz1oPQ2gMoWlyuyvpfaN8i5mIITSG0BhCYwiNIeokZiKG0BhCYwiNITR3AAAA//+A3RtWaKqXgQAAAABJRU5ErkJggg==" - (status/identicon "a"))))) + (native-module/identicon "a"))))) diff --git a/src/react_native/core.cljs b/src/react_native/core.cljs index 873fba343c..982e6d1a9b 100644 --- a/src/react_native/core.cljs +++ b/src/react_native/core.cljs @@ -37,6 +37,8 @@ (def dismiss-keyboard! #(.dismiss keyboard)) +(def device-event-emitter (.-DeviceEventEmitter ^js react-native)) + (defn hide-splash-screen [] (.hide ^js (-> react-native .-NativeModules .-SplashScreen))) diff --git a/src/status_im/add_new/db.cljs b/src/status_im/add_new/db.cljs index 455ce01e5f..edb6dacc55 100644 --- a/src/status_im/add_new/db.cljs +++ b/src/status_im/add_new/db.cljs @@ -1,7 +1,7 @@ (ns status-im.add-new.db (:require [cljs.spec.alpha :as spec] [status-im.ethereum.ens :as ens] - [status-im2.utils.validators :as validators])) + [utils.validators :as validators])) (defn own-public-key? [{:keys [multiaccount]} public-key] diff --git a/src/status_im/browser/core.cljs b/src/status_im/browser/core.cljs index 7e83828236..bc8f61e652 100644 --- a/src/status_im/browser/core.cljs +++ b/src/status_im/browser/core.cljs @@ -13,7 +13,7 @@ [status-im.ethereum.ens :as ens] [utils.i18n :as i18n] [status-im.multiaccounts.update.core :as multiaccounts.update] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.signing.core :as signing] [status-im.ui.components.list-selection :as list-selection] [utils.re-frame :as rf] @@ -537,7 +537,7 @@ (re-frame/reg-fx :browser/call-rpc (fn [[payload callback]] - (status/call-rpc + (native-module/call-rpc (types/clj->json payload) (fn [response] (if (= "" response) @@ -559,7 +559,7 @@ (re-frame/reg-fx :browser/clear-web-data (fn [] - (status/clear-web-data))) + (native-module/clear-web-data))) (defn share-link [url] diff --git a/src/status_im/chat/models/mentions.cljs b/src/status_im/chat/models/mentions.cljs index 8a44dcf696..4e382006bd 100644 --- a/src/status_im/chat/models/mentions.cljs +++ b/src/status_im/chat/models/mentions.cljs @@ -6,7 +6,7 @@ [utils.re-frame :as rf] [status-im.utils.platform :as platform] [taoensso.timbre :as log] - [status-im.native-module.core :as status])) + [native-module.core :as native-module])) (defn- transfer-input-segments [segments] @@ -56,8 +56,8 @@ :ensVerified :ens-verified :added :added? :displayName :display-name - :searchedText :searched-text - }))) + :searchedText :searched-text}))) + {} mentionable-users)) (defn- transfer-mention-result @@ -237,7 +237,7 @@ ::reset-text-input-cursor (fn [[ref cursor]] (when ref - (status/reset-keyboard-input + (native-module/reset-keyboard-input (rn/find-node-handle (react/current-ref ref)) cursor)))) diff --git a/src/status_im/ethereum/core.cljs b/src/status_im/ethereum/core.cljs index ca4e5a356f..30b68524ce 100644 --- a/src/status_im/ethereum/core.cljs +++ b/src/status_im/ethereum/core.cljs @@ -1,23 +1,23 @@ (ns status-im.ethereum.core (:require [clojure.string :as string] [status-im.ethereum.eip55 :as eip55] - [status-im.native-module.core :as status])) + [native-module.core :as native-module])) (defn sha3 [s] (when s - (status/sha3 (str s)))) + (native-module/sha3 (str s)))) (defn utf8-to-hex [s] - (let [hex (status/utf8-to-hex (str s))] + (let [hex (native-module/utf8-to-hex (str s))] (if (empty? hex) nil hex))) (defn hex-to-utf8 [s] - (let [utf8 (status/hex-to-utf8 s)] + (let [utf8 (native-module/hex-to-utf8 s)] (if (empty? utf8) nil utf8))) @@ -118,7 +118,7 @@ (defn address? [s] (when s - (status/address? s))) + (native-module/address? s))) (defn network->chain-id [network] diff --git a/src/status_im/ethereum/eip55.cljs b/src/status_im/ethereum/eip55.cljs index b3c3fb7bca..4d15a6ac86 100644 --- a/src/status_im/ethereum/eip55.cljs +++ b/src/status_im/ethereum/eip55.cljs @@ -5,7 +5,7 @@ e.g. 0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed" (:require [clojure.string :as string] - [status-im.native-module.core :as status])) + [native-module.core :as native-module])) (def hex-prefix "0x") @@ -13,7 +13,7 @@ "Converts an arbitrary case address to one with correct checksum case." [address] (when address - (status/to-checksum-address + (native-module/to-checksum-address (if (string/starts-with? address hex-prefix) address (str hex-prefix address))))) @@ -21,4 +21,4 @@ (defn valid-address-checksum? "Checks address checksum validity." [address] - (status/check-address-checksum address)) + (native-module/check-address-checksum address)) diff --git a/src/status_im/ethereum/encode.cljs b/src/status_im/ethereum/encode.cljs index 2c33cc1081..a295648364 100644 --- a/src/status_im/ethereum/encode.cljs +++ b/src/status_im/ethereum/encode.cljs @@ -1,6 +1,6 @@ (ns status-im.ethereum.encode - (:require [status-im.native-module.core :as status])) + (:require [native-module.core :as native-module])) (defn uint [x] - (str "0x" (status/number-to-hex x))) + (str "0x" (native-module/number-to-hex x))) diff --git a/src/status_im/ethereum/ens.cljs b/src/status_im/ethereum/ens.cljs index 978556f0f6..7a719365c0 100644 --- a/src/status_im/ethereum/ens.cljs +++ b/src/status_im/ethereum/ens.cljs @@ -1,6 +1,6 @@ (ns status-im.ethereum.ens (:require [clojure.string :as string] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im2.common.json-rpc.events :as json-rpc])) ;; this is the addresses of ens registries for the different networks @@ -66,7 +66,7 @@ :params [chain-id ens-name] :on-success ;;NOTE: returns a timestamp in s and we want ms - #(cb (* (js/Number (status/hex-to-number %)) 1000))})) + #(cb (* (js/Number (native-module/hex-to-number %)) 1000))})) (defn register-prepare-tx [chain-id from ens-name pubkey cb] diff --git a/src/status_im/events.cljs b/src/status_im/events.cljs index a106a35b6f..05d767fc05 100644 --- a/src/status_im/events.cljs +++ b/src/status_im/events.cljs @@ -30,7 +30,7 @@ status-im.multiaccounts.logout.core [status-im.multiaccounts.model :as multiaccounts.model] status-im.multiaccounts.update.core - [status-im.native-module.core :as status] + [native-module.core :as native-module] status-im.network.net-info status-im.pairing.core status-im.profile.core @@ -88,7 +88,7 @@ (re-frame/reg-fx :ui/close-application (fn [_] - (status/close-application))) + (native-module/close-application))) (re-frame/reg-fx ::app-state-change-fx @@ -97,7 +97,7 @@ ;; Change the app theme if the ios device theme was updated when the app was in the background ;; https://github.com/status-im/status-mobile/issues/15708 (theme/change-device-theme (rn/get-color-scheme))) - (status/app-state-change state))) + (native-module/app-state-change state))) (re-frame/reg-fx :ui/listen-to-window-dimensions-change diff --git a/src/status_im/keycard/fx.cljs b/src/status_im/keycard/fx.cljs index 1270d2d1b1..f158a7b51c 100644 --- a/src/status_im/keycard/fx.cljs +++ b/src/status_im/keycard/fx.cljs @@ -3,7 +3,7 @@ ["react-native" :refer (BackHandler)] [re-frame.core :as re-frame] [status-im.keycard.card :as card] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.utils.types :as types] [taoensso.timbre :as log])) @@ -202,7 +202,7 @@ (re-frame/reg-fx :keycard/generate-name-and-photo (fn [{:keys [public-key on-success]}] - (status/gfycat-identicon-async + (native-module/gfycat-identicon-async public-key (fn [whisper-name photo-path] (re-frame/dispatch diff --git a/src/status_im/keycard/real_keycard.cljs b/src/status_im/keycard/real_keycard.cljs index 7bf6d667a9..372e7c0a34 100644 --- a/src/status_im/keycard/real_keycard.cljs +++ b/src/status_im/keycard/real_keycard.cljs @@ -4,7 +4,7 @@ [clojure.string :as string] [status-im.ethereum.core :as ethereum] [status-im.keycard.keycard :as keycard] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.utils.platform :as platform] [status-im.utils.types :as types] [taoensso.timbre :as log])) @@ -296,7 +296,7 @@ (defn save-multiaccount-and-login [{:keys [key-uid multiaccount-data password settings node-config accounts-data chat-key]}] - (status/save-multiaccount-and-login-with-keycard + (native-module/save-multiaccount-and-login-with-keycard key-uid (types/clj->json multiaccount-data) password @@ -307,15 +307,15 @@ (defn login [args] - (status/login-with-keycard args)) + (native-module/login-with-keycard args)) (defn send-transaction-with-signature [{:keys [transaction signature on-completed]}] - (status/send-transaction-with-signature transaction signature on-completed)) + (native-module/send-transaction-with-signature transaction signature on-completed)) (defn delete-multiaccount-before-migration [{:keys [key-uid on-success on-error]}] - (status/delete-multiaccount + (native-module/delete-multiaccount key-uid (fn [result] (let [{:keys [error]} (types/json->clj result)] diff --git a/src/status_im/keycard/recovery.cljs b/src/status_im/keycard/recovery.cljs index 1cf2e9f4cd..c22a862be2 100644 --- a/src/status_im/keycard/recovery.cljs +++ b/src/status_im/keycard/recovery.cljs @@ -10,7 +10,7 @@ status-im.keycard.fx [status-im.multiaccounts.create.core :as multiaccounts.create] [status-im.multiaccounts.model :as multiaccounts.model] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.popover.core :as popover] [utils.re-frame :as rf] [utils.datetime :as datetime] @@ -250,14 +250,14 @@ (re-frame/reg-fx ::finish-migration (fn [[account settings password encryption-pass login-params]] - (status/convert-to-keycard-account + (native-module/convert-to-keycard-account account settings password encryption-pass #(let [{:keys [error]} (types/json->clj %)] (if (string/blank? error) - (status/login-with-keycard login-params) + (native-module/login-with-keycard login-params) (throw (js/Error. "Please shake the phone to report this error and restart the app. Migration failed unexpectedly."))))))) diff --git a/src/status_im/keycard/simulated_keycard.cljs b/src/status_im/keycard/simulated_keycard.cljs index 548d0b7bcc..de0af79b69 100644 --- a/src/status_im/keycard/simulated_keycard.cljs +++ b/src/status_im/keycard/simulated_keycard.cljs @@ -7,7 +7,7 @@ [utils.i18n :as i18n] [status-im.keycard.keycard :as keycard] [status-im.multiaccounts.create.core :as multiaccounts.create] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.node.core :as node] [status-im.utils.types :as types] [status-im.utils.utils :as utils] @@ -249,14 +249,14 @@ [{:keys [password on-success]}] (when (and (not @initialization) (not @derived-acc)) - (status/multiaccount-import-mnemonic + (native-module/multiaccount-import-mnemonic "night fortune spider version version armed amused winner matter tonight cave flag" nil (fn [result] (let [{:keys [id] :as root-data} (multiaccounts.create/normalize-multiaccount-data-keys (types/json->clj result))] - (status-im.native-module.core/multiaccount-derive-addresses + (native-module.core/multiaccount-derive-addresses id [constants/path-wallet-root constants/path-eip1581 @@ -266,7 +266,7 @@ (let [derived-data (multiaccounts.create/normalize-derived-data-keys (types/json->clj result)) public-key (get-in derived-data [constants/path-whisper-keyword :public-key])] - (status/gfycat-identicon-async + (native-module/gfycat-identicon-async public-key (fn [name photo-path] (let [derived-data-extended @@ -294,7 +294,7 @@ (if delete-multiaccount? (fn [on-deletion-success] (js/alert "OH SHEET") - (status/delete-multiaccount + (native-module/delete-multiaccount key-uid (fn [result] (let [{:keys [error]} (types/json->clj result)] @@ -304,7 +304,7 @@ (fn [cb] (cb)))] (deletion-wrapper (fn [] - (status/multiaccount-store-derived + (native-module/multiaccount-store-derived id (:key-uid response) [constants/path-wallet-root @@ -398,14 +398,14 @@ path-num (inc (get-in @re-frame.db/app-db [:multiaccount :latest-derived-path])) path (str "m/" path-num)] - (status/multiaccount-load-account + (native-module/multiaccount-load-account wallet-root-address hashed-password (fn [value] (let [{:keys [id error]} (types/json->clj value)] (if error (re-frame/dispatch [::new-account-error :password-error error]) - (status/multiaccount-derive-addresses + (native-module/multiaccount-derive-addresses id [path] (fn [derived] @@ -413,7 +413,7 @@ (if (some (fn [a] (= derived-address (get a :address))) accounts) (re-frame/dispatch [::new-account-error :account-error (i18n/label :t/account-exists-title)]) - (status/multiaccount-store-derived + (native-module/multiaccount-store-derived id key-uid [path] @@ -436,7 +436,7 @@ (swap! state assoc-in [:application-info :key-uid] (:key-uid keys)) - (status/multiaccount-store-derived + (native-module/multiaccount-store-derived id (:key-uid keys) [constants/path-wallet-root @@ -473,7 +473,7 @@ {:account address :password password :data (or data (str "0x" hash))})] - (status/sign-message + (native-module/sign-message params (fn [res] (let [signature (-> res @@ -481,7 +481,7 @@ :result ethereum/normalized-hex)] (on-success signature))))) - (status/sign-typed-data + (native-module/sign-typed-data data address password @@ -498,7 +498,7 @@ (defn save-multiaccount-and-login [{:keys [key-uid multiaccount-data password settings node-config accounts-data]}] - (status/save-account-and-login + (native-module/save-account-and-login key-uid (types/clj->json multiaccount-data) password @@ -508,11 +508,11 @@ (defn login [{:keys [key-uid multiaccount-data password]}] - (status/login-with-config key-uid multiaccount-data password node/login-node-config)) + (native-module/login-with-config key-uid multiaccount-data password node/login-node-config)) (defn send-transaction-with-signature [{:keys [transaction on-completed]}] - (status/send-transaction transaction account-password on-completed)) + (native-module/send-transaction transaction account-password on-completed)) (defn delete-multiaccount-before-migration [{:keys [on-success]}] diff --git a/src/status_im/multiaccounts/biometric/core.cljs b/src/status_im/multiaccounts/biometric/core.cljs index 7741df8c2b..0a60677ebd 100644 --- a/src/status_im/multiaccounts/biometric/core.cljs +++ b/src/status_im/multiaccounts/biometric/core.cljs @@ -3,7 +3,7 @@ [quo.design-system.colors :as colors] [re-frame.core :as re-frame] [utils.i18n :as i18n] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.popover.core :as popover] [utils.re-frame :as rf] [status-im.utils.keychain.core :as keychain] @@ -17,7 +17,7 @@ ;;; android blacklist based on device info: -(def deviceinfo (status/get-device-model-info)) +(def deviceinfo (native-module/get-device-model-info)) ;; {:model ? ;; :brand "Xiaomi" diff --git a/src/status_im/multiaccounts/core.cljs b/src/status_im/multiaccounts/core.cljs index 9c361d892c..cd4ab3db87 100644 --- a/src/status_im/multiaccounts/core.cljs +++ b/src/status_im/multiaccounts/core.cljs @@ -4,7 +4,7 @@ [re-frame.core :as re-frame] [status-im.bottom-sheet.events :as bottom-sheet] [status-im.multiaccounts.update.core :as multiaccounts.update] - [status-im.native-module.core :as native-module] + [native-module.core :as native-module] [utils.re-frame :as rf] [quo2.foundations.colors :as colors] [status-im2.constants :as constants] diff --git a/src/status_im/multiaccounts/create/core.cljs b/src/status_im/multiaccounts/create/core.cljs index cd326c1a54..f654d8e568 100644 --- a/src/status_im/multiaccounts/create/core.cljs +++ b/src/status_im/multiaccounts/create/core.cljs @@ -6,7 +6,7 @@ [status-im.ethereum.core :as ethereum] [status-im.ethereum.eip55 :as eip55] [utils.i18n :as i18n] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.node.core :as node] [status-im2.config :as config] [utils.re-frame :as rf] @@ -44,7 +44,7 @@ (re-frame/reg-fx ::store-multiaccount (fn [[id key-uid hashed-password callback]] - (status/multiaccount-store-derived + (native-module/multiaccount-store-derived id key-uid [constants/path-wallet-root @@ -69,7 +69,7 @@ (fn [result] (let [derived-data (normalize-derived-data-keys (types/json->clj result)) public-key (get-in derived-data [constants/path-whisper-keyword :public-key])] - (status/gfycat-identicon-async + (native-module/gfycat-identicon-async public-key (fn [name identicon] (let [derived-whisper (derived-data constants/path-whisper-keyword) @@ -81,7 +81,7 @@ (re-frame/reg-fx :multiaccount-generate-and-derive-addresses (fn [] - (status/multiaccount-generate-and-derive-addresses + (native-module/multiaccount-generate-and-derive-addresses 5 12 [constants/path-whisper @@ -127,7 +127,7 @@ (re-frame/reg-fx ::save-account-and-login (fn [[key-uid multiaccount-data hashed-password settings config accounts-data]] - (status/save-account-and-login + (native-module/save-account-and-login key-uid multiaccount-data hashed-password diff --git a/src/status_im/multiaccounts/key_storage/core.cljs b/src/status_im/multiaccounts/key_storage/core.cljs index 881da6ee41..4986355be2 100644 --- a/src/status_im/multiaccounts/key_storage/core.cljs +++ b/src/status_im/multiaccounts/key_storage/core.cljs @@ -11,7 +11,7 @@ [status-im.multiaccounts.logout.core :as multiaccounts.logout] [status-im.multiaccounts.model :as multiaccounts.model] [status-im.multiaccounts.recover.core :as multiaccounts.recover] - [status-im.native-module.core :as native-module] + [native-module.core :as native-module] [status-im.popover.core :as popover] [utils.re-frame :as rf] [status-im.utils.types :as types] diff --git a/src/status_im/multiaccounts/login/core.cljs b/src/status_im/multiaccounts/login/core.cljs index 207e2fcf9b..50b32ab595 100644 --- a/src/status_im/multiaccounts/login/core.cljs +++ b/src/status_im/multiaccounts/login/core.cljs @@ -20,7 +20,7 @@ [status-im.mobile-sync-settings.core :as mobile-network] [status-im.multiaccounts.biometric.core :as biometric] [status-im.multiaccounts.core :as multiaccounts] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.node.core :as node] [status-im.notifications.core :as notifications] [status-im.popover.core :as popover] @@ -58,22 +58,22 @@ (re-frame/reg-fx ::login (fn [[key-uid account-data hashed-password]] - (status/login-with-config key-uid account-data hashed-password node/login-node-config))) + (native-module/login-with-config key-uid account-data hashed-password node/login-node-config))) (re-frame/reg-fx ::export-db (fn [[key-uid account-data hashed-password callback]] - (status/export-db key-uid account-data hashed-password callback))) + (native-module/export-db key-uid account-data hashed-password callback))) (re-frame/reg-fx ::import-db (fn [[key-uid account-data hashed-password]] - (status/import-db key-uid account-data hashed-password))) + (native-module/import-db key-uid account-data hashed-password))) (re-frame/reg-fx ::enable-local-notifications (fn [] - (status/start-local-notifications))) + (native-module/start-local-notifications))) (re-frame/reg-fx ::initialize-wallet-connect @@ -363,7 +363,7 @@ (rf/defn get-node-config [_] - (status/get-node-config #(re-frame/dispatch [::get-node-config-callback %]))) + (native-module/get-node-config #(re-frame/dispatch [::get-node-config-callback %]))) (rf/defn redirect-to-root "Decides which root should be initialised depending on user and app state" diff --git a/src/status_im/multiaccounts/logout/core.cljs b/src/status_im/multiaccounts/logout/core.cljs index 5f153e873a..ae7de66c0a 100644 --- a/src/status_im/multiaccounts/logout/core.cljs +++ b/src/status_im/multiaccounts/logout/core.cljs @@ -2,7 +2,7 @@ (:require [re-frame.core :as re-frame] [utils.i18n :as i18n] [status-im.multiaccounts.core :as multiaccounts] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.notifications.core :as notifications] [utils.re-frame :as rf] [status-im.utils.keychain.core :as keychain] @@ -62,4 +62,4 @@ (re-frame/reg-fx ::logout (fn [] - (status/logout))) + (native-module/logout))) diff --git a/src/status_im/multiaccounts/recover/core.cljs b/src/status_im/multiaccounts/recover/core.cljs index 9628164d51..1465812967 100644 --- a/src/status_im/multiaccounts/recover/core.cljs +++ b/src/status_im/multiaccounts/recover/core.cljs @@ -9,7 +9,7 @@ [status-im.keycard.nfc :as nfc] [status-im.multiaccounts.core :as multiaccounts] [status-im.multiaccounts.create.core :as multiaccounts.create] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.popover.core :as popover] [utils.re-frame :as rf] [status-im.utils.types :as types] @@ -89,14 +89,14 @@ ::import-multiaccount (fn [{:keys [passphrase password success-event]}] (log/debug "[recover] ::import-multiaccount") - (status/multiaccount-import-mnemonic + (native-module/multiaccount-import-mnemonic passphrase password (fn [result] (let [{:keys [id] :as root-data} (multiaccounts.create/normalize-multiaccount-data-keys (types/json->clj result))] - (status-im.native-module.core/multiaccount-derive-addresses + (native-module.core/multiaccount-derive-addresses id [constants/path-wallet-root constants/path-eip1581 @@ -106,7 +106,7 @@ (let [derived-data (multiaccounts.create/normalize-derived-data-keys (types/json->clj result)) public-key (get-in derived-data [constants/path-whisper-keyword :public-key])] - (status/gfycat-identicon-async + (native-module/gfycat-identicon-async public-key (fn [name identicon] (let [derived-data-extended diff --git a/src/status_im/multiaccounts/reset_password/core.cljs b/src/status_im/multiaccounts/reset_password/core.cljs index 1e286d8d88..a8187ed23c 100644 --- a/src/status_im/multiaccounts/reset_password/core.cljs +++ b/src/status_im/multiaccounts/reset_password/core.cljs @@ -2,7 +2,7 @@ (:require [clojure.string :as string] [re-frame.core :as re-frame] [status-im.ethereum.core :as ethereum] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.popover.core :as popover] [utils.re-frame :as rf] [status-im.utils.keychain.core :as keychain] @@ -59,7 +59,7 @@ (re-frame/reg-fx ::change-db-password (fn [[key-uid {:keys [current-password new-password]}]] - (status/reset-password + (native-module/reset-password key-uid (ethereum/sha3 (security/safe-unmask-data current-password)) (ethereum/sha3 (security/safe-unmask-data new-password)) @@ -88,9 +88,9 @@ ::validate-current-password-and-reset (fn [{:keys [address current-password] :as form-vals}] (let [hashed-pass (ethereum/sha3 (security/safe-unmask-data current-password))] - (status/verify address - hashed-pass - (partial handle-verification form-vals))))) + (native-module/verify address + hashed-pass + (partial handle-verification form-vals))))) (rf/defn reset {:events [::reset]} diff --git a/src/status_im/network/net_info.cljs b/src/status_im/network/net_info.cljs index 1195010c56..d95fe9c0fd 100644 --- a/src/status_im/network/net_info.cljs +++ b/src/status_im/network/net_info.cljs @@ -2,7 +2,7 @@ (:require ["@react-native-community/netinfo" :default net-info] [re-frame.core :as re-frame] [status-im.mobile-sync-settings.core :as mobile-network] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [utils.re-frame :as rf] [status-im.wallet.core :as wallet] [taoensso.timbre :as log])) @@ -59,4 +59,4 @@ (re-frame/reg-fx :network/notify-status-go (fn [[network-type expensive?]] - (status/connection-change network-type expensive?))) + (native-module/connection-change network-type expensive?))) diff --git a/src/status_im/node/core.cljs b/src/status_im/node/core.cljs index 546a5f4e56..ad74aee38d 100644 --- a/src/status_im/node/core.cljs +++ b/src/status_im/node/core.cljs @@ -1,6 +1,6 @@ (ns status-im.node.core (:require [re-frame.core :as re-frame] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im2.config :as config] [utils.re-frame :as rf] [status-im.utils.platform :as utils.platform] @@ -221,4 +221,4 @@ app-db" (re-frame/reg-fx ::prepare-new-config (fn [[key-uid config callback]] - (status/prepare-dir-and-update-config key-uid config callback))) + (native-module/prepare-dir-and-update-config key-uid config callback))) diff --git a/src/status_im/notifications/local.cljs b/src/status_im/notifications/local.cljs index f5f3187d62..61884cb804 100644 --- a/src/status_im/notifications/local.cljs +++ b/src/status_im/notifications/local.cljs @@ -11,9 +11,9 @@ [status-im.notifications.android :as pn-android] [utils.re-frame :as rf] [status-im.utils.money :as money] - [status-im.utils.react-native :as react-native-utils] [status-im.utils.types :as types] - [status-im.utils.utils :as utils])) + [status-im.utils.utils :as utils] + [react-native.core :as rn])) (def default-erc20-token {:symbol :ERC20 @@ -56,7 +56,7 @@ (fn [notification] (handle-notification-press {:userInfo (bean/bean (.getData ^js notification))}))) - (.addListener ^js react-native-utils/device-event-emitter + (.addListener ^js rn/device-event-emitter notification-event-android (fn [^js data] (when (and data (.-dataJSON data)) diff --git a/src/status_im/router/core.cljs b/src/status_im/router/core.cljs index b60b847abb..5208c73c24 100644 --- a/src/status_im/router/core.cljs +++ b/src/status_im/router/core.cljs @@ -9,9 +9,9 @@ [status-im.ethereum.eip681 :as eip681] [status-im.ethereum.ens :as ens] [status-im.utils.types :as types] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.ethereum.stateofus :as stateofus] - [status-im2.utils.validators :as validators] + [utils.validators :as validators] [status-im.utils.http :as http] [status-im.utils.wallet-connect :as wallet-connect] [taoensso.timbre :as log] @@ -83,8 +83,9 @@ :ens-name ens-name}) valid-compressed-key? - (status/compressed-key->public-key + (native-module/compressed-key->public-key user-id + constants/deserialization-key (fn [response] (let [{:keys [error]} (types/json->clj response)] (when-not error diff --git a/src/status_im/signing/core.cljs b/src/status_im/signing/core.cljs index 3fa7fdfb2a..426bcd0562 100644 --- a/src/status_im/signing/core.cljs +++ b/src/status_im/signing/core.cljs @@ -9,7 +9,7 @@ [utils.i18n :as i18n] [status-im.keycard.card :as keycard.card] [status-im.keycard.common :as keycard.common] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.signing.eip1559 :as eip1559] [status-im.signing.keycard :as signing.keycard] [utils.re-frame :as rf] @@ -26,9 +26,9 @@ (re-frame/reg-fx :signing/send-transaction-fx (fn [{:keys [tx-obj hashed-password cb]}] - (status/send-transaction (types/clj->json tx-obj) - hashed-password - cb))) + (native-module/send-transaction (types/clj->json tx-obj) + hashed-password + cb))) (re-frame/reg-fx :signing/show-transaction-error @@ -43,21 +43,21 @@ (re-frame/reg-fx :signing.fx/sign-message (fn [{:keys [params on-completed]}] - (status/sign-message (types/clj->json params) - on-completed))) + (native-module/sign-message (types/clj->json params) + on-completed))) (re-frame/reg-fx :signing.fx/recover-message (fn [{:keys [params on-completed]}] - (status/recover-message (types/clj->json params) - on-completed))) + (native-module/recover-message (types/clj->json params) + on-completed))) (re-frame/reg-fx :signing.fx/sign-typed-data (fn [{:keys [v4 data account on-completed hashed-password]}] (if v4 - (status/sign-typed-data-v4 data account hashed-password on-completed) - (status/sign-typed-data data account hashed-password on-completed)))) + (native-module/sign-typed-data-v4 data account hashed-password on-completed) + (native-module/sign-typed-data data account hashed-password on-completed)))) (defn get-contact [db to] @@ -109,18 +109,18 @@ (sign-message cofx) (let [tx-obj-to-send (merge tx-obj (when gas - {:gas (str "0x" (status/number-to-hex gas))}) + {:gas (str "0x" (native-module/number-to-hex gas))}) (when gasPrice - {:gasPrice (str "0x" (status/number-to-hex gasPrice))}) + {:gasPrice (str "0x" (native-module/number-to-hex gasPrice))}) (when nonce - {:nonce (str "0x" (status/number-to-hex nonce))}) + {:nonce (str "0x" (native-module/number-to-hex nonce))}) (when maxPriorityFeePerGas {:maxPriorityFeePerGas (str "0x" - (status/number-to-hex + (native-module/number-to-hex (js/parseInt maxPriorityFeePerGas)))}) (when maxFeePerGas {:maxFeePerGas (str "0x" - (status/number-to-hex + (native-module/number-to-hex (js/parseInt maxFeePerGas)))}))] (when-not in-progress? {:db (update db :signing/sign assoc :error nil :in-progress? true) @@ -184,7 +184,7 @@ (let [{:keys [symbol decimals] :as token} (tokens/address->token (:wallet/all-tokens db) to)] (when (and token data (string? data)) (when-let [type (get-method-type data)] - (let [[address value _] (status/decode-parameters + (let [[address value _] (native-module/decode-parameters (str "0x" (subs data 10)) (if (= type :approve-and-call) ["address" "uint256" "bytes"] @@ -476,7 +476,7 @@ {:events [:wallet.ui/sign-transaction-button-clicked-from-chat]} [{:keys [db] :as cofx} {:keys [to amount from token]}] (let [{:keys [symbol address]} token - amount-hex (str "0x" (status/number-to-hex amount)) + amount-hex (str "0x" (native-module/number-to-hex amount)) to-norm (ethereum/normalized-hex (if (string? to) to (:address to))) from-address (:address from) identity (:current-chat-id db) @@ -495,7 +495,7 @@ :from from-address :chat-id identity :command? true - :data (status/encode-transfer to-norm amount-hex)})})) + :data (native-module/encode-transfer to-norm amount-hex)})})) {:db db :json-rpc/call [{:method "wakuext_requestAddressForTransaction" @@ -512,7 +512,7 @@ [{:keys [db] :as cofx} {:keys [amount from token]}] (let [{:keys [request-parameters chat-id]} (:wallet/prepare-transaction db) {:keys [symbol address]} token - amount-hex (str "0x" (status/number-to-hex amount)) + amount-hex (str "0x" (native-module/number-to-hex amount)) to-norm (:address request-parameters) from-address (:address from)] (rf/merge cofx @@ -532,13 +532,13 @@ :command? true :message-id (:id request-parameters) :chat-id chat-id - :data (status/encode-transfer to-norm amount-hex)})}))))) + :data (native-module/encode-transfer to-norm amount-hex)})}))))) (rf/defn sign-transaction-button-clicked {:events [:wallet.ui/sign-transaction-button-clicked]} [{:keys [db] :as cofx} {:keys [to amount from token gas gasPrice maxFeePerGas maxPriorityFeePerGas]}] (let [{:keys [symbol address]} token - amount-hex (str "0x" (status/number-to-hex amount)) + amount-hex (str "0x" (native-module/number-to-hex amount)) to-norm (ethereum/normalized-hex (if (string? to) to (:address to))) from-address (:address from)] (rf/merge cofx @@ -558,7 +558,7 @@ {:to to-norm :value amount-hex} {:to (ethereum/normalized-hex address) - :data (status/encode-transfer to-norm amount-hex)}))})))) + :data (native-module/encode-transfer to-norm amount-hex)}))})))) (re-frame/reg-fx :signing/get-transaction-by-hash-fx diff --git a/src/status_im/signing/core_test.cljs b/src/status_im/signing/core_test.cljs index a56b49d3ee..0809ce6240 100644 --- a/src/status_im/signing/core_test.cljs +++ b/src/status_im/signing/core_test.cljs @@ -1,15 +1,15 @@ (ns status-im.signing.core-test (:require [cljs.test :refer-macros [deftest is testing]] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.signing.core :as signing])) (deftest signing-test (testing "showing sheet" (let [to "0x2f88d65f3cb52605a54a833ae118fb1363acccd2" contract "0xc55cf4b03948d7ebc8b9e8bad92643703811d162" - amount1-hex (str "0x" (status/number-to-hex "10000000000000000000")) - amount2-hex (str "0x" (status/number-to-hex "100000000000000000000")) - data (status/encode-transfer to amount2-hex) + amount1-hex (str "0x" (native-module/number-to-hex "10000000000000000000")) + amount2-hex (str "0x" (native-module/number-to-hex "100000000000000000000")) + data (native-module/encode-transfer to amount2-hex) first-tx {:tx-obj {:to to :from nil :value amount1-hex}} diff --git a/src/status_im/signing/keycard.cljs b/src/status_im/signing/keycard.cljs index 479c876cdc..039a78ff5b 100644 --- a/src/status_im/signing/keycard.cljs +++ b/src/status_im/signing/keycard.cljs @@ -1,7 +1,7 @@ (ns status-im.signing.keycard (:require [re-frame.core :as re-frame] [utils.i18n :as i18n] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [utils.re-frame :as rf] [status-im.utils.types :as types] [taoensso.timbre :as log])) @@ -9,19 +9,19 @@ (re-frame/reg-fx ::hash-transaction (fn [{:keys [transaction on-completed]}] - (status/hash-transaction (types/clj->json transaction) on-completed))) + (native-module/hash-transaction (types/clj->json transaction) on-completed))) (re-frame/reg-fx ::hash-message (fn [{:keys [message on-completed]}] - (status/hash-message message on-completed))) + (native-module/hash-message message on-completed))) (re-frame/reg-fx ::hash-typed-data (fn [{:keys [v4 data on-completed]}] (if v4 - (status/hash-typed-data-v4 data on-completed) - (status/hash-typed-data data on-completed)))) + (native-module/hash-typed-data-v4 data on-completed) + (native-module/hash-typed-data data on-completed)))) (defn prepare-transaction [{:keys [gas gasPrice data nonce tx-obj] :as params}] @@ -37,17 +37,17 @@ maxPriorityFeePerGas (assoc :maxPriorityFeePerGas (str "0x" - (status/number-to-hex + (native-module/number-to-hex (js/parseInt maxPriorityFeePerGas)))) maxFeePerGas (assoc :maxFeePerGas (str "0x" - (status/number-to-hex + (native-module/number-to-hex (js/parseInt maxFeePerGas)))) gas - (assoc :gas (str "0x" (status/number-to-hex gas))) + (assoc :gas (str "0x" (native-module/number-to-hex gas))) gasPrice - (assoc :gasPrice (str "0x" (status/number-to-hex gasPrice))) + (assoc :gasPrice (str "0x" (native-module/number-to-hex gasPrice))) data (assoc :data data) nonce diff --git a/src/status_im/ui/screens/add_new/new_chat/views.cljs b/src/status_im/ui/screens/add_new/new_chat/views.cljs index 217972a04a..2856930e26 100644 --- a/src/status_im/ui/screens/add_new/new_chat/views.cljs +++ b/src/status_im/ui/screens/add_new/new_chat/views.cljs @@ -20,7 +20,7 @@ [status-im.ui.components.react :as react] [status-im.ui.components.topbar :as topbar] [status-im.ui.screens.chat.photos :as photos] - [status-im2.utils.validators :as validators] + [utils.validators :as validators] [status-im.utils.gfycat.core :as gfycat] [status-im.utils.identicon :as identicon] [status-im.utils.utils :as utils] diff --git a/src/status_im/ui/screens/network_info/views.cljs b/src/status_im/ui/screens/network_info/views.cljs index f5dcbbcc72..0a77f4b520 100644 --- a/src/status_im/ui/screens/network_info/views.cljs +++ b/src/status_im/ui/screens/network_info/views.cljs @@ -2,7 +2,7 @@ (:require [re-frame.core :as re-frame] [reagent.core :as reagent] [status-im.ethereum.decode :as decode] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.ui.components.react :as react] [status-im2.common.json-rpc.events :as json-rpc] [utils.datetime :as datetime])) @@ -36,7 +36,7 @@ (reset! latest-block res) (get-block (str "0x" - (status/number-to-hex + (native-module/number-to-hex (last-loaded-block-number))) (fn [res] (reset! last-loaded-block res))))))] diff --git a/src/status_im/ui/screens/privacy_and_security_settings/events.cljs b/src/status_im/ui/screens/privacy_and_security_settings/events.cljs index 89c207dd33..798b222c89 100644 --- a/src/status_im/ui/screens/privacy_and_security_settings/events.cljs +++ b/src/status_im/ui/screens/privacy_and_security_settings/events.cljs @@ -3,7 +3,7 @@ [re-frame.core :as re-frame] [status-im.ethereum.core :as ethereum] [utils.i18n :as i18n] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [utils.re-frame :as rf] [status-im.utils.types :as types] [taoensso.timbre :as log] @@ -21,7 +21,7 @@ (-> masked-password security/safe-unmask-data ethereum/sha3)] - (status/verify + (native-module/verify address hashed-password (fn [result] @@ -29,7 +29,7 @@ (log/info "[delete-profile] verify-password" result error) (if-not (safe-blank? error) (callback :wrong-password nil) - (status/delete-multiaccount + (native-module/delete-multiaccount key-uid (fn [result] (let [{:keys [error]} (types/json->clj result)] diff --git a/src/status_im/utils/gfycat/core.cljs b/src/status_im/utils/gfycat/core.cljs index bf4d7dd6fc..49babbebad 100644 --- a/src/status_im/utils/gfycat/core.cljs +++ b/src/status_im/utils/gfycat/core.cljs @@ -1,6 +1,5 @@ (ns status-im.utils.gfycat.core - (:require [re-frame.core :as re-frame] - [status-im.native-module.core :as native-module])) + (:require [native-module.core :as native-module])) (def unknown-gfy "Unknown") @@ -12,13 +11,3 @@ (native-module/generate-gfycat public-key))) (def generate-gfy (memoize build-gfy)) - -(re-frame/reg-fx - :insert-gfycats - (fn [key-path-seq] - (for [key-path key-path-seq] - (let [public-key (first key-path) - path-for-gfycat (second key-path)] - (native-module/generate-gfycat-async public-key - #(re-frame/dispatch [:gfycat-generated path-for-gfycat - %])))))) diff --git a/src/status_im/utils/identicon.cljs b/src/status_im/utils/identicon.cljs index 0b8dd72f88..5fd352e461 100644 --- a/src/status_im/utils/identicon.cljs +++ b/src/status_im/utils/identicon.cljs @@ -1,15 +1,4 @@ (ns status-im.utils.identicon - (:require [re-frame.core :as re-frame] - [status-im.native-module.core :as native-module])) + (:require [native-module.core :as native-module])) (def identicon (memoize native-module/identicon)) - -(def identicon-async native-module/identicon-async) - -(re-frame/reg-fx - :insert-identicons - (fn [key-path-seq] - (for [key-path key-path-seq] - (let [public-key (first key-path) - path-for-identicon (second key-path)] - (identicon-async public-key #(re-frame/dispatch [:identicon-generated path-for-identicon %])))))) diff --git a/src/status_im/utils/keychain/core.cljs b/src/status_im/utils/keychain/core.cljs index f405d94edc..c0b96e533c 100644 --- a/src/status_im/utils/keychain/core.cljs +++ b/src/status_im/utils/keychain/core.cljs @@ -2,7 +2,7 @@ (:require ["react-native-keychain" :as react-native-keychain] [clojure.string :as string] [re-frame.core :as re-frame] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [utils.re-frame :as rf] [status-im.utils.platform :as platform] [taoensso.timbre :as log] @@ -63,7 +63,7 @@ ;; Android only (defn- device-not-rooted? [callback] - (status/rooted-device? (fn [rooted?] (callback (not rooted?))))) + (native-module/rooted-device? (fn [rooted?] (callback (not rooted?))))) ;; Android only (defn- secure-hardware-available? diff --git a/src/status_im/utils/logging/core.cljs b/src/status_im/utils/logging/core.cljs index e3dc39106b..59b682b5f0 100644 --- a/src/status_im/utils/logging/core.cljs +++ b/src/status_im/utils/logging/core.cljs @@ -5,7 +5,7 @@ [react-native.mail :as react-native-mail] [status-im.bottom-sheet.events :as bottom-sheet] [utils.i18n :as i18n] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.transport.utils :as transport.utils] [status-im.ui.components.react :as react] [status-im.utils.build :as build] @@ -20,7 +20,7 @@ (re-frame/reg-fx :logs/archive-logs (fn [[db-json callback-handler]] - (status/send-logs + (native-module/send-logs db-json (string/join "\n" (log/get-logs-queue)) #(re-frame/dispatch [callback-handler %])))) diff --git a/src/status_im/utils/react_native.cljs b/src/status_im/utils/react_native.cljs deleted file mode 100644 index 409f33e1d3..0000000000 --- a/src/status_im/utils/react_native.cljs +++ /dev/null @@ -1,8 +0,0 @@ -(ns status-im.utils.react-native - (:require ["react-native" :as react-native])) - -; Moved from status-im.ui.components.react(let's short for R), so status-im.native-module.core(short for -; N) don't need to have a dependency to R. -; We should keep N's dependencies as simple as possible, otherwise we may see issue like: -; Circular dependency detected: N -> R -> status-im.utils.utils -> status-im.ethereum.eip55 -> N -(def device-event-emitter (.-DeviceEventEmitter react-native)) \ No newline at end of file diff --git a/src/status_im/utils/universal_links/core.cljs b/src/status_im/utils/universal_links/core.cljs index 671d6193c1..1df3088790 100644 --- a/src/status_im/utils/universal_links/core.cljs +++ b/src/status_im/utils/universal_links/core.cljs @@ -15,7 +15,7 @@ [status-im.wallet.choose-recipient.core :as choose-recipient] [status-im2.navigation.events :as navigation] [taoensso.timbre :as log] - [status-im.native-module.core :as status])) + [native-module.core :as native-module])) ;; TODO(yenda) investigate why `handle-universal-link` event is ;; dispatched 7 times for the same link @@ -88,7 +88,7 @@ (rf/defn handle-desktop-community [cofx {:keys [community-id]}] - (status/deserialize-and-compress-key + (native-module/deserialize-and-compress-key community-id (fn [deserialized-key] (rf/dispatch [:handle-navigation-to-desktop-community-from-mobile cofx (str deserialized-key)])))) diff --git a/src/status_im/wallet/accounts/core.cljs b/src/status_im/wallet/accounts/core.cljs index f7e8e5fd2e..7252b5b03b 100644 --- a/src/status_im/wallet/accounts/core.cljs +++ b/src/status_im/wallet/accounts/core.cljs @@ -14,7 +14,7 @@ [status-im.multiaccounts.core :as multiaccounts] [status-im.multiaccounts.key-storage.core :as key-storage] [status-im.multiaccounts.update.core :as multiaccounts.update] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.ui.components.list-selection :as list-selection] [utils.re-frame :as rf] [status-im.utils.hex :as hex] @@ -74,7 +74,7 @@ (let [{:keys [id error]} (types/json->clj value)] (if error (re-frame/dispatch [::new-account-error :password-error error]) - (status/multiaccount-derive-addresses + (native-module/multiaccount-derive-addresses id [path] (fn [derived] @@ -82,7 +82,7 @@ (if (some #(= derived-address (get % :address)) accounts) (re-frame/dispatch [::new-account-error :account-error (i18n/label :t/account-exists-title)]) - (status/multiaccount-store-derived + (native-module/multiaccount-store-derived id key-uid [path] @@ -110,7 +110,7 @@ (re-frame/dispatch [::new-account-error (if (= error pass-error) :password-error :account-error) error]) - (status/multiaccount-store-account + (native-module/multiaccount-store-account id key-uid hashed-password @@ -119,7 +119,7 @@ (re-frame/reg-fx ::verify-password (fn [{:keys [address hashed-password]}] - (status/verify + (native-module/verify address hashed-password #(re-frame/dispatch [:wallet.accounts/add-new-account-password-verifyied % hashed-password])))) @@ -128,7 +128,7 @@ ::generate-account (fn [{:keys [derivation-info hashed-password accounts key-uid]}] (let [{:keys [address path]} derivation-info] - (status/multiaccount-load-account + (native-module/multiaccount-load-account address hashed-password (derive-and-store-account key-uid path hashed-password :generated accounts))))) @@ -136,7 +136,7 @@ (re-frame/reg-fx ::import-account-seed (fn [{:keys [passphrase hashed-password accounts key-uid]}] - (status/multiaccount-import-mnemonic + (native-module/multiaccount-import-mnemonic (mnemonic/sanitize-passphrase (security/unmask passphrase)) "" (derive-and-store-account key-uid constants/path-default-wallet hashed-password :seed accounts)))) @@ -144,7 +144,7 @@ (re-frame/reg-fx ::import-account-private-key (fn [{:keys [private-key hashed-password key-uid]}] - (status/multiaccount-import-private-key + (native-module/multiaccount-import-private-key (string/trim (security/unmask private-key)) (store-account key-uid constants/path-default-wallet hashed-password :key)))) diff --git a/src/status_im2/common/json_rpc/events.cljs b/src/status_im2/common/json_rpc/events.cljs index ad566342df..776da8ad84 100644 --- a/src/status_im2/common/json_rpc/events.cljs +++ b/src/status_im2/common/json_rpc/events.cljs @@ -2,7 +2,7 @@ (:require [clojure.string :as string] [re-frame.core :as re-frame] [react-native.background-timer :as background-timer] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [taoensso.timbre :as log] [utils.transforms :as transforms])) @@ -29,7 +29,7 @@ on-error (or on-error (on-error-retry call arg) #(log/warn :json-rpc/error method :error % :params params))] - (status/call-private-rpc + (native-module/call-private-rpc (transforms/clj->json {:jsonrpc "2.0" :id 1 :method method diff --git a/src/status_im2/contexts/add_new_contact/events.cljs b/src/status_im2/contexts/add_new_contact/events.cljs index 9703ecd2d5..bead662a60 100644 --- a/src/status_im2/contexts/add_new_contact/events.cljs +++ b/src/status_im2/contexts/add_new_contact/events.cljs @@ -6,11 +6,12 @@ [status-im.ethereum.core :as ethereum] [status-im.ethereum.ens :as ens] [status-im.ethereum.stateofus :as stateofus] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im2.navigation.events :as navigation] - [status-im2.utils.validators :as validators] + [utils.validators :as validators] [status-im2.contexts.contacts.events :as data-store.contacts] - [status-im.utils.utils :as utils])) + [status-im.utils.utils :as utils] + [status-im2.constants :as constants])) (defn init-contact "Create a new contact (persisted to app-db as [:contacts/new-identity]). @@ -124,8 +125,9 @@ (re-frame/reg-fx :contacts/decompress-public-key (fn [{:keys [compressed-key on-success on-error]}] - (status/compressed-key->public-key + (native-module/compressed-key->public-key compressed-key + constants/deserialization-key (fn [resp] (let [{:keys [error]} (types/json->clj resp)] (if error diff --git a/src/status_im2/contexts/chat/messages/pin/banner/view.cljs b/src/status_im2/contexts/chat/messages/pin/banner/view.cljs index 88b5926036..4520ed2e67 100644 --- a/src/status_im2/contexts/chat/messages/pin/banner/view.cljs +++ b/src/status_im2/contexts/chat/messages/pin/banner/view.cljs @@ -2,7 +2,7 @@ (:require [quo2.core :as quo] [utils.i18n :as i18n] [utils.re-frame :as rf] - [status-im2.utils.message-resolver :as resolver])) + [status-im2.contexts.chat.messages.resolver.message-resolver :as resolver])) (defn banner [chat-id] diff --git a/src/status_im2/utils/message_resolver.cljs b/src/status_im2/contexts/chat/messages/resolver/message_resolver.cljs similarity index 88% rename from src/status_im2/utils/message_resolver.cljs rename to src/status_im2/contexts/chat/messages/resolver/message_resolver.cljs index d450b8cc35..5da269e7a6 100644 --- a/src/status_im2/utils/message_resolver.cljs +++ b/src/status_im2/contexts/chat/messages/resolver/message_resolver.cljs @@ -1,4 +1,4 @@ -(ns status-im2.utils.message-resolver +(ns status-im2.contexts.chat.messages.resolver.message-resolver (:require [utils.re-frame :as rf])) (defn resolve-message diff --git a/src/status_im2/utils/message_resolver_test.cljs b/src/status_im2/contexts/chat/messages/resolver/message_resolver_test.cljs similarity index 83% rename from src/status_im2/utils/message_resolver_test.cljs rename to src/status_im2/contexts/chat/messages/resolver/message_resolver_test.cljs index bc510dcfbf..1c3f38ccec 100644 --- a/src/status_im2/utils/message_resolver_test.cljs +++ b/src/status_im2/contexts/chat/messages/resolver/message_resolver_test.cljs @@ -1,5 +1,5 @@ -(ns status-im2.utils.message-resolver-test - (:require [status-im2.utils.message-resolver :as resolver] +(ns status-im2.contexts.chat.messages.resolver.message-resolver-test + (:require [status-im2.contexts.chat.messages.resolver.message-resolver :as resolver] [cljs.test :as t] [utils.re-frame :as rf])) diff --git a/src/status_im2/contexts/onboarding/events.cljs b/src/status_im2/contexts/onboarding/events.cljs index 2401d285b1..3b7979129d 100644 --- a/src/status_im2/contexts/onboarding/events.cljs +++ b/src/status_im2/contexts/onboarding/events.cljs @@ -8,7 +8,7 @@ [clojure.string :as string] [utils.i18n :as i18n] [utils.security.core :as security] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.ethereum.core :as ethereum] [status-im2.constants :as constants] [status-im2.contexts.onboarding.profiles.view :as profiles.view])) @@ -16,12 +16,12 @@ (re-frame/reg-fx :multiaccount/create-account-and-login (fn [request] - (status/create-account-and-login request))) + (native-module/create-account-and-login request))) (re-frame/reg-fx :multiaccount/validate-mnemonic (fn [[mnemonic on-success on-error]] - (status/validate-mnemonic + (native-module/validate-mnemonic (security/safe-unmask-data mnemonic) (fn [result] (let [{:keys [error keyUID]} (types/json->clj result)] @@ -32,7 +32,7 @@ (re-frame/reg-fx :multiaccount/restore-account-and-login (fn [request] - (status/restore-account-and-login request))) + (native-module/restore-account-and-login request))) (rf/defn profile-data-set {:events [:onboarding-2/profile-data-set]} @@ -86,14 +86,14 @@ (security/safe-unmask-data seed-phrase)) :imagePath (strip-file-prefix image-path) :customizationColor color - :backupDisabledDataDir (status/backup-disabled-data-dir) - :rootKeystoreDir (status/keystore-dir) + :backupDisabledDataDir (native-module/backup-disabled-data-dir) + :rootKeystoreDir (native-module/keystore-dir) ;; Temporary fix until https://github.com/status-im/status-go/issues/3024 is ;; resolved :wakuV2Nameserver "1.1.1.1" :logLevel (when log-enabled? config/log-level) :logEnabled log-enabled? - :logFilePath (status/log-file-directory) + :logFilePath (native-module/log-file-directory) :openseaAPIKey config/opensea-api-key :verifyTransactionURL config/verify-transaction-url :verifyENSURL config/verify-ens-url diff --git a/src/status_im2/contexts/onboarding/profiles/view.cljs b/src/status_im2/contexts/onboarding/profiles/view.cljs index e2f41e397b..e611b3baca 100644 --- a/src/status_im2/contexts/onboarding/profiles/view.cljs +++ b/src/status_im2/contexts/onboarding/profiles/view.cljs @@ -7,7 +7,7 @@ [react-native.core :as rn] [utils.transforms :as types] [utils.security.core :as security] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im2.contexts.onboarding.profiles.style :as style] [status-im2.common.confirmation-drawer.view :as confirmation-drawer] [status-im2.contexts.onboarding.common.background.view :as background])) @@ -45,7 +45,7 @@ :close-button-text (i18n/label :t/cancel) :on-press #(do (rf/dispatch [:hide-bottom-sheet]) - (status/delete-multiaccount + (native-module/delete-multiaccount key-uid (fn [result] (let [{:keys [error]} (types/json->clj result)] diff --git a/src/status_im2/contexts/shell/cards/view.cljs b/src/status_im2/contexts/shell/cards/view.cljs index d7b18a6c5e..f4d2f86a9f 100644 --- a/src/status_im2/contexts/shell/cards/view.cljs +++ b/src/status_im2/contexts/shell/cards/view.cljs @@ -8,7 +8,7 @@ [status-im2.constants :as constants] [status-im2.contexts.shell.cards.style :as style] [status-im2.contexts.shell.constants :as shell.constants] - [status-im2.utils.message-resolver :as resolver])) + [status-im2.contexts.chat.messages.resolver.message-resolver :as resolver])) (defn content-container [type diff --git a/src/status_im2/contexts/syncing/events.cljs b/src/status_im2/contexts/syncing/events.cljs index 54d7dc6cbe..5d5cc02649 100644 --- a/src/status_im2/contexts/syncing/events.cljs +++ b/src/status_im2/contexts/syncing/events.cljs @@ -1,5 +1,5 @@ (ns status-im2.contexts.syncing.events - (:require [status-im.native-module.core :as status] + (:require [native-module.core :as native-module] [taoensso.timbre :as log] [utils.re-frame :as rf] [utils.security.core :as security] @@ -51,13 +51,13 @@ :settingCurrentNetwork config/default-network :deviceType utils.platform/os}}))] (rf/dispatch [:syncing/update-role constants/local-pairing-role-receiver]) - (status/input-connection-string-for-bootstrapping + (native-module/input-connection-string-for-bootstrapping connection-string config-map #(log/info "Initiated local pairing" {:response % :event :syncing/input-connection-string-for-bootstrapping}))))] - (status/prepare-dir-and-update-config "" default-node-config-string callback))) + (native-module/prepare-dir-and-update-config "" default-node-config-string callback))) (rf/defn preparations-for-connection-string {:events [:syncing/get-connection-string-for-bootstrapping-another-device]} @@ -68,7 +68,7 @@ (rf/dispatch [:syncing/update-role constants/local-pairing-role-sender]) (rf/dispatch [:bottom-sheet/hide]))] (if valid-password? - (let [sha3-pwd (status/sha3 (str (security/safe-unmask-data entered-password))) + (let [sha3-pwd (native-module/sha3 (str (security/safe-unmask-data entered-password))) key-uid (get-in db [:multiaccount :key-uid]) config-map (.stringify js/JSON (clj->js {:senderConfig {:keyUID key-uid @@ -76,7 +76,7 @@ :password sha3-pwd :deviceType utils.platform/os} :serverConfig {:timeout 0}}))] - (status/get-connection-string-for-bootstrapping-another-device + (native-module/get-connection-string-for-bootstrapping-another-device config-map #(show-sheet %))) (show-sheet "")))) diff --git a/src/status_im2/core.cljs b/src/status_im2/core.cljs index b06462f487..8a2315aa9c 100644 --- a/src/status_im2/core.cljs +++ b/src/status_im2/core.cljs @@ -15,7 +15,7 @@ [status-im2.setup.global-error :as global-error] [status-im2.common.log :as log] [status-im.async-storage.core :as async-storage] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.notifications.local :as notifications] [status-im.utils.universal-links.core :as utils.universal-links] status-im.events @@ -27,12 +27,15 @@ (set! interop/next-tick js/setTimeout) (set! batching/fake-raf #(js/setTimeout % 0)) +(def adjust-resize 16) + (defn init [] + (native-module/init #(re-frame/dispatch [:signals/signal-received %])) + (when platform/android? + (native-module/set-soft-input-mode adjust-resize)) (log/setup config/log-level) (global-error/register-handler) - (when platform/android? - (status/set-soft-input-mode status/adjust-resize)) (notifications/listen-notifications) (.addEventListener rn/app-state "change" #(re-frame/dispatch [:app-state-change %])) (react-native-languages/add-change-listener #(fn [lang] diff --git a/src/status_im2/events.cljs b/src/status_im2/events.cljs index 565b092b9f..bd59462fe9 100644 --- a/src/status_im2/events.cljs +++ b/src/status_im2/events.cljs @@ -2,7 +2,7 @@ (:require [clojure.string :as string] [re-frame.core :as re-frame] [status-im.multiaccounts.login.core :as multiaccounts.login] - [status-im.native-module.core :as status] + [native-module.core :as native-module] [status-im.utils.keychain.core :as keychain] [status-im2.common.json-rpc.events] [status-im2.common.theme.core :as theme] @@ -25,7 +25,7 @@ (re-frame/reg-fx :setup/open-multiaccounts (fn [callback] - (status/open-accounts callback))) + (native-module/open-accounts callback))) (re-frame/reg-fx :setup/init-theme diff --git a/src/status_im2/utils/validators.cljs b/src/utils/validators.cljs similarity index 89% rename from src/status_im2/utils/validators.cljs rename to src/utils/validators.cljs index cbe2cda0ad..78d091aec5 100644 --- a/src/status_im2/utils/validators.cljs +++ b/src/utils/validators.cljs @@ -1,4 +1,4 @@ -(ns status-im2.utils.validators) +(ns utils.validators) (defn valid-public-key? [s] diff --git a/src/status_im2/utils/validators_test.cljs b/src/utils/validators_test.cljs similarity index 91% rename from src/status_im2/utils/validators_test.cljs rename to src/utils/validators_test.cljs index 3691595bf2..5389ff0d6f 100644 --- a/src/status_im2/utils/validators_test.cljs +++ b/src/utils/validators_test.cljs @@ -1,6 +1,6 @@ -(ns status-im2.utils.validators-test +(ns utils.validators-test (:require [cljs.test :refer-macros [deftest testing is]] - [status-im2.utils.validators :refer [valid-compressed-key?]])) + [utils.validators :refer [valid-compressed-key?]])) (deftest test-valid-compressed-key (testing "valid"