Add fetch messages behind a toggle & some advanced settings

This PR does a few things:

1) Add fetch messages implementation on any kind of chat. It's behind a
   toggle (on by default) as design is still unsure whether we want it,
   but it's very useful for debugging.
2) Allow setting light client from mobile

It also partially remove node config management from the clojure part,
as it's better if that's not explicitly managed by clients.
Some parts are still relying on it but they are not functional
(keycard), while others are still using it and will need to be updated
eventually (syncing), in order to get rid completely of node config.

Sets fleet to shards.test

90c31afe...1adcf02f
This commit is contained in:
Andrea Maria Piana 2023-11-24 14:49:54 +00:00
parent 800ca19c08
commit 32cfd214ca
No known key found for this signature in database
24 changed files with 166 additions and 339 deletions

View File

@ -1183,6 +1183,11 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
return pathCombine(absRootDirPath, "keystore"); return pathCombine(absRootDirPath, "keystore");
} }
@ReactMethod(isBlockingSynchronousMethod = true)
public String fleets() {
return Statusgo.fleets();
}
@ReactMethod(isBlockingSynchronousMethod = true) @ReactMethod(isBlockingSynchronousMethod = true)
public String backupDisabledDataDir() { public String backupDisabledDataDir() {
return this.getNoBackupDirectory(); return this.getNoBackupDirectory();

View File

@ -981,6 +981,10 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isAddress:(NSString *)address) {
return StatusgoIsAddress(address); return StatusgoIsAddress(address);
} }
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(fleets) {
return StatusgoFleets();
}
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(toChecksumAddress:(NSString *)address) { RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(toChecksumAddress:(NSString *)address) {
return StatusgoToChecksumAddress(address); return StatusgoToChecksumAddress(address);
} }

View File

@ -298,6 +298,7 @@ void _MultiAccountStoreAccount(const FunctionCallbackInfo<Value>& args) {
delete c; delete c;
} }
void _InitKeystore(const FunctionCallbackInfo<Value>& args) { void _InitKeystore(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate(); Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext(); Local<Context> context = isolate->GetCurrentContext();
@ -562,6 +563,17 @@ void _CheckAddressChecksum(const FunctionCallbackInfo<Value>& args) {
} }
void _Fleets(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
// Call exported Go function, which returns a C string
char *c = Fleets();
Local<String> ret = String::NewFromUtf8(isolate, c).ToLocalChecked();
args.GetReturnValue().Set(ret);
delete c;
}
void _IsAddress(const FunctionCallbackInfo<Value>& args) { void _IsAddress(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate(); Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext(); Local<Context> context = isolate->GetCurrentContext();
@ -1888,6 +1900,7 @@ void init(Local<Object> exports) {
NODE_SET_METHOD(exports, "multiAccountStoreDerivedAccounts", _MultiAccountStoreDerivedAccounts); NODE_SET_METHOD(exports, "multiAccountStoreDerivedAccounts", _MultiAccountStoreDerivedAccounts);
NODE_SET_METHOD(exports, "multiAccountStoreAccount", _MultiAccountStoreAccount); NODE_SET_METHOD(exports, "multiAccountStoreAccount", _MultiAccountStoreAccount);
NODE_SET_METHOD(exports, "initKeystore", _InitKeystore); NODE_SET_METHOD(exports, "initKeystore", _InitKeystore);
NODE_SET_METHOD(exports, "fleets", _Fleets);
NODE_SET_METHOD(exports, "stopCPUProfiling", _StopCPUProfiling); NODE_SET_METHOD(exports, "stopCPUProfiling", _StopCPUProfiling);
NODE_SET_METHOD(exports, "encodeTransfer", _EncodeTransfer); NODE_SET_METHOD(exports, "encodeTransfer", _EncodeTransfer);
NODE_SET_METHOD(exports, "encodeFunctionCall", _EncodeFunctionCall); NODE_SET_METHOD(exports, "encodeFunctionCall", _EncodeFunctionCall);

View File

@ -2,16 +2,25 @@
(:require (:require
[legacy.status-im.multiaccounts.update.core :as multiaccounts.update] [legacy.status-im.multiaccounts.update.core :as multiaccounts.update]
[legacy.status-im.node.core :as node] [legacy.status-im.node.core :as node]
[native-module.core :as native-module]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.config :as config]
[status-im.constants :as constants] [status-im.constants :as constants]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]
[utils.transforms :as transforms]))
(def ^:private default-fleets (transforms/json->clj (native-module/fleets)))
(def ^:private default-fleet (:defaultFleet default-fleets))
(def fleets
(->> default-fleets
:fleets
keys
(map name)))
(defn current-fleet-sub (defn current-fleet-sub
[multiaccount] [multiaccount]
(keyword (or (get multiaccount :fleet) (keyword (or (get multiaccount :fleet)
config/fleet))) default-fleet)))
(defn format-mailserver (defn format-mailserver
[mailserver address] [mailserver address]
@ -78,10 +87,9 @@
[{:keys [db now] :as cofx} fleet] [{:keys [db now] :as cofx} fleet]
(let [old-fleet (get-in db [:profile/profile :fleet])] (let [old-fleet (get-in db [:profile/profile :fleet])]
(when (not= fleet old-fleet) (when (not= fleet old-fleet)
(rf/merge (multiaccounts.update/multiaccount-update
cofx cofx
(multiaccounts.update/multiaccount-update :fleet fleet {}) :fleet
(node/prepare-new-config fleet
{:on-success {:on-success
#(re-frame/dispatch #(re-frame/dispatch [:logout])}))))
[:multiaccounts.update.callback/save-settings-success])})))))

View File

@ -527,23 +527,7 @@
(error-object->map response)]))})) (error-object->map response)]))}))
(defn save-multiaccount-and-login (defn save-multiaccount-and-login
[{:keys [key-uid multiaccount-data password settings node-config accounts-data chat-key]}] [_])
(if config/keycard-test-menu-enabled?
(native-module/save-account-and-login
key-uid
(types/clj->json multiaccount-data)
password
(types/clj->json settings)
node-config
(types/clj->json accounts-data))
(native-module/save-multiaccount-and-login-with-keycard
key-uid
(types/clj->json multiaccount-data)
password
(types/clj->json settings)
node-config
(types/clj->json accounts-data)
chat-key)))
(defn login (defn login
[{:keys [key-uid multiaccount-data password] :as args}] [{:keys [key-uid multiaccount-data password] :as args}]

View File

@ -16,7 +16,6 @@
[taoensso.timbre :as log] [taoensso.timbre :as log]
[utils.address :as address] [utils.address :as address]
[utils.datetime :as datetime] [utils.datetime :as datetime]
[utils.ethereum.eip.eip55 :as eip55]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf] [utils.re-frame :as rf]
[utils.security.core :as security])) [utils.security.core :as security]))
@ -151,6 +150,7 @@
:keycard/check-nfc-enabled nil} :keycard/check-nfc-enabled nil}
(intro-wizard))) (intro-wizard)))
;; NOTE: currently non functional, keycard needs to be reimplemented
(rf/defn create-keycard-multiaccount (rf/defn create-keycard-multiaccount
{:events [::create-keycard-multiaccount] {:events [::create-keycard-multiaccount]
:interceptors [(re-frame/inject-cofx :random-guid-generator) :interceptors [(re-frame/inject-cofx :random-guid-generator)
@ -181,27 +181,7 @@
(rf/merge cofx (rf/merge cofx
{:db (-> db {:db (-> db
(assoc-in [:keycard :setup-step] nil) (assoc-in [:keycard :setup-step] nil)
(dissoc :intro-wizard))} (dissoc :intro-wizard))})))
(multiaccounts.create/on-multiaccount-created
{:recovered (or recovered (get-in db [:intro-wizard :recovering?]))
:derived {constants/path-wallet-root-keyword
{:public-key wallet-root-public-key
:address (eip55/address->checksum wallet-root-address)}
constants/path-whisper-keyword
{:public-key whisper-public-key
:address (eip55/address->checksum whisper-address)}
constants/path-default-wallet-keyword
{:public-key wallet-public-key
:address (eip55/address->checksum wallet-address)}}
:address address
:public-key public-key
:keycard-instance-uid instance-uid
:key-uid (address/normalized-hex key-uid)
:keycard-pairing pairing
:keycard-paired-on paired-on
:chat-key whisper-private-key}
encryption-public-key
{}))))
(rf/defn return-to-keycard-login (rf/defn return-to-keycard-login
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]

View File

@ -1,7 +1,6 @@
(ns legacy.status-im.log-level.core (ns legacy.status-im.log-level.core
(:require (:require
[legacy.status-im.multiaccounts.update.core :as multiaccounts.update] [legacy.status-im.multiaccounts.update.core :as multiaccounts.update]
[legacy.status-im.node.core :as node]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -11,13 +10,11 @@
[{:keys [db now] :as cofx} log-level] [{:keys [db now] :as cofx} log-level]
(let [old-log-level (get-in db [:profile/profile :log-level])] (let [old-log-level (get-in db [:profile/profile :log-level])]
(when (not= old-log-level log-level) (when (not= old-log-level log-level)
(rf/merge cofx
(multiaccounts.update/multiaccount-update (multiaccounts.update/multiaccount-update
cofx
:log-level :log-level
log-level log-level
{}) {:on-success #(re-frame/dispatch [:logout])}))))
(node/prepare-new-config
{:on-success #(re-frame/dispatch [:logout])})))))
(rf/defn show-change-log-level-confirmation (rf/defn show-change-log-level-confirmation
{:events [:log-level.ui/log-level-selected]} {:events [:log-level.ui/log-level-selected]}

View File

@ -1,18 +1,11 @@
(ns legacy.status-im.multiaccounts.create.core (ns legacy.status-im.multiaccounts.create.core
(:require (:require
[legacy.status-im.data-store.settings :as data-store.settings]
[legacy.status-im.node.core :as node]
[legacy.status-im.ui.components.colors :as colors]
[legacy.status-im.utils.deprecated-types :as types] [legacy.status-im.utils.deprecated-types :as types]
[legacy.status-im.utils.signing-phrase.core :as signing-phrase] [legacy.status-im.utils.signing-phrase.core :as signing-phrase]
[native-module.core :as native-module] [native-module.core :as native-module]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.config :as config]
[status-im.constants :as constants] [status-im.constants :as constants]
[utils.ethereum.eip.eip55 :as eip55] [utils.re-frame :as rf]))
[utils.i18n :as i18n]
[utils.re-frame :as rf]
[utils.security.core :as security]))
(defn normalize-derived-data-keys (defn normalize-derived-data-keys
[derived-data] [derived-data]
@ -82,134 +75,3 @@
(rf/defn save-multiaccount-and-login-with-keycard (rf/defn save-multiaccount-and-login-with-keycard
[_ args] [_ args]
{:keycard/save-multiaccount-and-login args}) {:keycard/save-multiaccount-and-login args})
(re-frame/reg-fx
::save-account-and-login
(fn [[key-uid multiaccount-data hashed-password settings config accounts-data]]
(native-module/save-account-and-login
key-uid
multiaccount-data
hashed-password
settings
config
accounts-data)))
(rf/defn save-account-and-login
[{:keys [db]} key-uid multiaccount-data password settings node-config accounts-data]
{:db (assoc-in db [:syncing :login-sha3-password] password)
::save-account-and-login [key-uid
(types/clj->json multiaccount-data)
password
(types/clj->json settings)
node-config
(types/clj->json accounts-data)]})
(defn prepare-accounts-data
[multiaccount]
[(let [{:keys [public-key address]}
(get-in multiaccount [:derived constants/path-default-wallet-keyword])]
{:public-key public-key
:address (eip55/address->checksum address)
:color colors/blue-persist
:wallet true
:path constants/path-default-wallet
:name (i18n/label :t/main-account)})
(let [{:keys [compressed-key public-key address name]}
(get-in multiaccount [:derived constants/path-whisper-keyword])]
{:public-key public-key
:compressed-key compressed-key
:address (eip55/address->checksum address)
:name name
:path constants/path-whisper
:chat true})])
(rf/defn on-multiaccount-created
[{:keys [signing-phrase random-guid-generator db] :as cofx}
{:keys [address chat-key keycard-instance-uid key-uid
keycard-pairing keycard-paired-on mnemonic recovered]
:as multiaccount}
password
{:keys [save-mnemonic? login?] :or {login? true save-mnemonic? false}}]
(let [[wallet-account
{:keys [public-key
compressed-key
name]} :as accounts-data]
(prepare-accounts-data
multiaccount)
multiaccount-data {:name name
:address address
:key-uid key-uid
:keycard-pairing keycard-pairing}
keycard-multiaccount? (boolean keycard-pairing)
eip1581-address (get-in multiaccount
[:derived
constants/path-eip1581-keyword
:address])
new-multiaccount
(cond->
(merge
{;; address of the master key
:address address
;; sha256 of master public key
:key-uid key-uid
;; The address from which we derive any wallet
:wallet-root-address
(get-in multiaccount
[:derived
constants/path-wallet-root-keyword
:address])
:name name
;; public key of the chat account
:public-key public-key
;; compressed key of the chat account
:compressed-key compressed-key
;; default address for Dapps
:dapps-address (:address wallet-account)
:latest-derived-path 0
:signing-phrase signing-phrase
:backup-enabled? true
:installation-id (random-guid-generator)
;; default mailserver (history node) setting
:use-mailservers? true
:recovered recovered}
config/default-multiaccount)
;; The address from which we derive any chat account/encryption keys
eip1581-address
(assoc :eip1581-address eip1581-address)
save-mnemonic?
(assoc :mnemonic mnemonic)
keycard-multiaccount?
(assoc :keycard-instance-uid keycard-instance-uid
:keycard-pairing keycard-pairing
:keycard-paired-on keycard-paired-on))
db (assoc db
:profile/login {:key-uid key-uid
:name name
:password password
:creating? true
:processing true}
:profile/profile new-multiaccount
:profile/wallet-accounts [wallet-account]
:networks/current-network config/default-network
:networks/networks (data-store.settings/rpc->networks config/default-networks))
settings (assoc new-multiaccount
:networks/current-network config/default-network
:networks/networks config/default-networks)]
(rf/merge cofx
{:db db}
(if keycard-multiaccount?
(save-multiaccount-and-login-with-keycard
{:key-uid key-uid
:multiaccount-data multiaccount-data
:password password
:settings settings
:node-config (node/get-new-config db)
:accounts-data accounts-data
:chat-key chat-key})
(save-account-and-login
key-uid
multiaccount-data
(native-module/sha3 (security/safe-unmask-data password))
settings
(node/get-new-config db)
accounts-data)))))

View File

@ -1,7 +1,6 @@
(ns legacy.status-im.network.core (ns legacy.status-im.network.core
(:require (:require
[clojure.string :as string] [clojure.string :as string]
[legacy.status-im.node.core :as node]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.navigation.events :as navigation] [status-im.navigation.events :as navigation]
[utils.ethereum.chain :as chain] [utils.ethereum.chain :as chain]
@ -117,12 +116,10 @@
(rf/defn save-network-settings (rf/defn save-network-settings
{:events [::save-network-settings-pressed]} {:events [::save-network-settings-pressed]}
[{:keys [db] :as cofx} network] [{:keys [db] :as cofx} network]
(rf/merge cofx
{:db (assoc db :networks/current-network network) {:db (assoc db :networks/current-network network)
:json-rpc/call [{:method "settings_saveSetting" :json-rpc/call [{:method "settings_saveSetting"
:params [:networks/current-network network] :params [:networks/current-network network]
:on-success #()}]} :on-success #(re-frame/dispatch [:logout])}]})
(node/prepare-new-config {:on-success #(re-frame/dispatch [:logout])})))
(rf/defn remove-network (rf/defn remove-network
{:events [::remove-network-confirmed]} {:events [::remove-network-confirmed]}

View File

@ -2,11 +2,8 @@
(:require (:require
[clojure.string :as string] [clojure.string :as string]
[legacy.status-im.utils.deprecated-types :as types] [legacy.status-im.utils.deprecated-types :as types]
[native-module.core :as native-module]
[re-frame.core :as re-frame]
[react-native.platform :as platform] [react-native.platform :as platform]
[status-im.config :as config] [status-im.config :as config]))
[utils.re-frame :as rf]))
(defn- add-custom-bootnodes (defn- add-custom-bootnodes
[config network all-bootnodes] [config network all-bootnodes]
@ -196,32 +193,4 @@
:always :always
(add-log-level log-level)))) (add-log-level log-level))))
(defn get-new-config
[db]
(types/clj->json (get-multiaccount-node-config db)))
(rf/defn save-new-config
"Saves a new status-go config for the current account
This RPC method is the only way to change the node config of an account.
NOTE: it is better used indirectly through `prepare-new-config`,
which will take care of building up the proper config based on settings in
app-db"
{:events [::save-new-config]}
[_ config {:keys [on-success]}]
{:json-rpc/call [{:method "settings_saveSetting"
:params [:node-config config]
:on-success on-success}]})
(rf/defn prepare-new-config
"Use this function to apply settings to the current account node config"
[{:keys [db]} {:keys [on-success]}]
(let [key-uid (get-in db [:profile/profile :key-uid])]
{::prepare-new-config [key-uid
(get-new-config db)
#(re-frame/dispatch
[::save-new-config % {:on-success on-success}])]}))
(re-frame/reg-fx
::prepare-new-config
(fn [[key-uid config callback]]
(native-module/prepare-dir-and-update-config key-uid config callback)))

View File

@ -15,9 +15,8 @@
(defn- normal-mode-settings-data (defn- normal-mode-settings-data
[{:keys [network-name [{:keys [network-name
current-log-level current-log-level
waku-bloom-filter-mode light-client-enabled?
transactions-management-enabled? transactions-management-enabled?
wakuv2-flag
current-fleet current-fleet
webview-debug webview-debug
test-networks-enabled?]}] test-networks-enabled?]}]
@ -55,19 +54,12 @@
:accessory :text :accessory :text
:accessory-text current-fleet :accessory-text current-fleet
:chevron true} :chevron true}
(if wakuv2-flag
{:size :small {:size :small
:title (i18n/label :t/wakuv2-settings) :title (i18n/label :t/wakuv2-settings)
:accessibility-label :wakuv2-settings-button :accessibility-label :wakuv2-settings-button
:on-press :on-press
#(re-frame/dispatch [:wakuv2.ui/enter-settings-pressed]) #(re-frame/dispatch [:wakuv2.ui/enter-settings-pressed])
:chevron true} :chevron true}
{:size :small
:title (i18n/label :t/bootnodes)
:accessibility-label :bootnodes-settings-button
:on-press
#(re-frame/dispatch [:navigate-to :bootnodes-settings])
:chevron true})
{:size :small {:size :small
:title (i18n/label :t/rpc-usage-info) :title (i18n/label :t/rpc-usage-info)
:accessibility-label :rpc-usage-info :accessibility-label :rpc-usage-info
@ -82,6 +74,15 @@
:on-press :on-press
#(re-frame/dispatch [:navigate-to :peers-stats]) #(re-frame/dispatch [:navigate-to :peers-stats])
:chevron true} :chevron true}
{:size :small
:title (i18n/label :t/light-client-enabled)
:accessibility-label :light-client-enabled
:container-margin-bottom 8
:on-press
#(re-frame/dispatch
[:wakuv2.ui/toggle-light-client (not light-client-enabled?)])
:accessory :switch
:active light-client-enabled?}
{:size :small {:size :small
:title (i18n/label :t/transactions-management-enabled) :title (i18n/label :t/transactions-management-enabled)
:accessibility-label :transactions-management-enabled :accessibility-label :transactions-management-enabled
@ -109,15 +110,6 @@
#(re-frame/dispatch [:profile.settings/toggle-test-networks]) #(re-frame/dispatch [:profile.settings/toggle-test-networks])
:accessory :switch :accessory :switch
:active test-networks-enabled?} :active test-networks-enabled?}
{:size :small
:title (i18n/label :t/waku-bloom-filter-mode)
:accessibility-label :waku-bloom-filter-mode-settings-switch
:container-margin-bottom 8
:on-press
#(re-frame/dispatch
[:multiaccounts.ui/waku-bloom-filter-mode-switched (not waku-bloom-filter-mode)])
:accessory :switch
:active waku-bloom-filter-mode}
{:size :small {:size :small
:title (i18n/label :t/set-currency) :title (i18n/label :t/set-currency)
:accessibility-label :wallet-change-currency :accessibility-label :wallet-change-currency
@ -137,11 +129,10 @@
(views/defview advanced-settings (views/defview advanced-settings
[] []
(views/letsubs [{:keys [webview-debug (views/letsubs [test-networks-enabled? [:profile/test-networks-enabled?]
test-networks-enabled?]} [:profile/profile] light-client-enabled? [:profile/light-client-enabled?]
webview-debug [:profile/webview-debug]
network-name [:network-name] network-name [:network-name]
waku-bloom-filter-mode [:waku/bloom-filter-mode]
wakuv2-flag [:waku/v2-flag]
transactions-management-enabled? [:wallet-legacy/transactions-management-enabled?] transactions-management-enabled? [:wallet-legacy/transactions-management-enabled?]
current-log-level [:log-level/current-log-level] current-log-level [:log-level/current-log-level]
current-fleet [:fleets/current-fleet]] current-fleet [:fleets/current-fleet]]
@ -150,10 +141,9 @@
{:network-name network-name {:network-name network-name
:current-log-level current-log-level :current-log-level current-log-level
:transactions-management-enabled? transactions-management-enabled? :transactions-management-enabled? transactions-management-enabled?
:light-client-enabled? light-client-enabled?
:current-fleet current-fleet :current-fleet current-fleet
:dev-mode? false :dev-mode? false
:wakuv2-flag wakuv2-flag
:waku-bloom-filter-mode waku-bloom-filter-mode
:webview-debug webview-debug :webview-debug webview-debug
:test-networks-enabled? test-networks-enabled?}) :test-networks-enabled? test-networks-enabled?})
:key-fn (fn [_ i] (str i)) :key-fn (fn [_ i] (str i))

View File

@ -1,6 +1,6 @@
(ns legacy.status-im.ui.screens.fleet-settings.views (ns legacy.status-im.ui.screens.fleet-settings.views
(:require (:require
[legacy.status-im.node.core :as node] [legacy.status-im.fleet.core :as fleets]
[legacy.status-im.ui.components.icons.icons :as icons] [legacy.status-im.ui.components.icons.icons :as icons]
[legacy.status-im.ui.components.list.views :as list] [legacy.status-im.ui.components.list.views :as list]
[legacy.status-im.ui.components.react :as react] [legacy.status-im.ui.components.react :as react]
@ -30,16 +30,11 @@
[react/text {:style styles/fleet-item-name-text} [react/text {:style styles/fleet-item-name-text}
fleet]]]])) fleet]]]]))
(defn fleets
[custom-fleets]
(map name (keys (node/fleets {:custom-fleets custom-fleets}))))
(views/defview fleet-settings (views/defview fleet-settings
[] []
(views/letsubs [custom-fleets [:fleets/custom-fleets] (views/letsubs [current-fleet [:fleets/current-fleet]]
current-fleet [:fleets/current-fleet]]
[list/flat-list [list/flat-list
{:data (fleets custom-fleets) {:data fleets/fleets
:default-separator? false :default-separator? false
:key-fn identity :key-fn identity
:render-data (name current-fleet) :render-data (name current-fleet)

View File

@ -121,6 +121,9 @@
:isAddress :isAddress
(fn [address] (.isAddress native-status address)) (fn [address] (.isAddress native-status address))
:fleets
(fn [] (.fleets native-status))
:validateMnemonic :validateMnemonic
(fn [json callback] (callback (.validateMnemonic native-status json))) (fn [json callback] (callback (.validateMnemonic native-status json)))

View File

@ -1,23 +1,12 @@
(ns legacy.status-im.waku.core (ns legacy.status-im.waku.core
(:require (:require
[clojure.string :as string] [clojure.string :as string]
[legacy.status-im.multiaccounts.update.core :as multiaccounts.update]
[legacy.status-im.node.core :as node]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.navigation.events :as navigation] [status-im.navigation.events :as navigation]
[taoensso.timbre :as log]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
(rf/defn switch-waku-bloom-filter-mode
{:events [:multiaccounts.ui/waku-bloom-filter-mode-switched]}
[cofx enabled?]
(rf/merge cofx
(multiaccounts.update/multiaccount-update
:waku-bloom-filter-mode
enabled?
{})
(node/prepare-new-config
{:on-success #(re-frame/dispatch [:logout])})))
(def address-regex #"/ip4/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/tcp/\d{1,5}/p2p/[a-zA-Z0-9]+") (def address-regex #"/ip4/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/tcp/\d{1,5}/p2p/[a-zA-Z0-9]+")
@ -108,13 +97,16 @@
vals vals
(map #(vector (:name %1) (:address %1))) (map #(vector (:name %1) (:address %1)))
(into {}))] (into {}))]
(rf/merge cofx
{:db (-> db {:db (-> db
(assoc-in [:profile/profile :wakuv2-config :CustomNodes] new-nodes) (assoc-in [:profile/profile :wakuv2-config :CustomNodes] new-nodes)
(dissoc :wakuv2-nodes/manage :wakuv2-nodes/list)) (dissoc :wakuv2-nodes/manage :wakuv2-nodes/list))
:dispatch [:navigate-back]} :json-rpc/call [{:method "wakuext_setCustomNodes"
(node/prepare-new-config :params [{:customNodes new-nodes}]
{:on-success #(re-frame/dispatch [:logout])})))) :on-success #(log/info "updated custom nodes")
:on-error #(log/error "failed to set custom nodes"
{:error %
:custom-nodes new-nodes})}]
:dispatch [:navigate-back]}))
(rf/defn show-delete-node-confirmation (rf/defn show-delete-node-confirmation
{:events [:wakuv2.ui/delete-pressed]} {:events [:wakuv2.ui/delete-pressed]}
@ -131,3 +123,17 @@
(rf/merge cofx (rf/merge cofx
(delete id) (delete id)
(navigation/navigate-back))) (navigation/navigate-back)))
(rf/defn toggle-light-client
{:events [:wakuv2.ui/toggle-light-client]}
[{:keys [db]} enabled?]
{:db (assoc-in db [:profile/profile :wakuv2-config :LightClient] enabled?)
:json-rpc/call [{:method "wakuext_setLightClient"
:params [{:enabled enabled?}]
:on-success (fn []
(log/info "light client set successfully" enabled?)
(re-frame/dispatch [:logout]))
:on-error #(log/error "failed to set light client"
{:error %
:enabled? enabled?})}]})

View File

@ -40,23 +40,6 @@
config config
#(callback (types/json->clj %)))) #(callback (types/json->clj %))))
(defn save-account-and-login
"NOTE: beware, the password has to be sha3 hashed"
[key-uid multiaccount-data hashed-password settings config accounts-data]
(log/debug "[native-module] save-account-and-login"
"multiaccount-data"
multiaccount-data)
(clear-web-data)
(init-keystore
key-uid
#(.saveAccountAndLogin
^js (status)
multiaccount-data
hashed-password
settings
config
accounts-data)))
(defn save-multiaccount-and-login-with-keycard (defn save-multiaccount-and-login-with-keycard
"NOTE: chat-key is a whisper private key sent from keycard" "NOTE: chat-key is a whisper private key sent from keycard"
[key-uid multiaccount-data password settings config accounts-data chat-key] [key-uid multiaccount-data password settings config accounts-data chat-key]
@ -536,6 +519,10 @@
[] []
(.backupDisabledDataDir ^js (status))) (.backupDisabledDataDir ^js (status)))
(defn fleets
[]
(.fleets ^js (status)))
(defn keystore-dir (defn keystore-dir
[] []
(.keystoreDir ^js (status))) (.keystoreDir ^js (status)))

View File

@ -6,8 +6,10 @@
[status-im.common.confirmation-drawer.view :as confirmation-drawer] [status-im.common.confirmation-drawer.view :as confirmation-drawer]
[status-im.common.mute-drawer.view :as mute-drawer] [status-im.common.mute-drawer.view :as mute-drawer]
[status-im.common.muting.helpers :refer [format-mute-till]] [status-im.common.muting.helpers :refer [format-mute-till]]
[status-im.config :as config]
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.contexts.communities.actions.chat.view :as chat-actions] [status-im.contexts.chat.actions.view :as chat-actions]
[status-im.contexts.communities.actions.chat.view :as communities-chat-actions]
[status-im.contexts.contacts.drawers.nickname-drawer.view :as nickname-drawer] [status-im.contexts.contacts.drawers.nickname-drawer.view :as nickname-drawer]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -255,16 +257,6 @@
:chevron? true :chevron? true
:add-divider? add-divider?})) :add-divider? add-divider?}))
;; TODO(OmarBasem): Requires design input.
(defn fetch-messages-entry
[]
(entry {:icon :i/save
:label (i18n/label :t/fetch-messages)
:on-press #(js/alert "TODO: to be implemented, requires design input")
:danger? false
:accessibility-label :fetch-messages
:sub-label nil
:chevron? true}))
(defn remove-from-contacts-entry (defn remove-from-contacts-entry
[contact] [contact]
@ -422,8 +414,8 @@
[(mark-as-read-entry chat-id needs-divider?) [(mark-as-read-entry chat-id needs-divider?)
(mute-chat-entry chat-id chat-type muted-till) (mute-chat-entry chat-id chat-type muted-till)
(notifications-entry false) (notifications-entry false)
(when inside-chat? (when (and config/fetch-messages-enabled? inside-chat?)
(fetch-messages-entry)) (chat-actions/fetch-messages chat-id))
(when public? (when public?
(show-qr-entry)) (show-qr-entry))
(when public? (when public?
@ -481,7 +473,7 @@
constants/private-group-chat-type constants/private-group-chat-type
[private-group-chat-actions chat inside-chat?] [private-group-chat-actions chat inside-chat?]
constants/community-chat-type constants/community-chat-type
[chat-actions/actions chat inside-chat?] [communities-chat-actions/actions chat inside-chat?]
nil)) nil))
(defn group-details-actions (defn group-details-actions

View File

@ -158,3 +158,4 @@
(def default-kdf-iterations 3200) (def default-kdf-iterations 3200)
(def community-accounts-selection-enabled? false) (def community-accounts-selection-enabled? false)
(def fetch-messages-enabled? (enabled? (get-config :FETCH_MESSAGES_ENABLED "1")))

View File

@ -4,6 +4,16 @@
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
(defn fetch-messages
[chat-id]
{:icon :i/download
:right-icon :i/chevron-right
:accessibility-label :chat-fetch-messages
:on-press (fn []
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:chat/fetch-messages chat-id]))
:label (i18n/label :t/fetch-messages)})
(defn new-chat (defn new-chat
[] []
[quo/action-drawer [quo/action-drawer

View File

@ -442,3 +442,11 @@
(when (and id (when (and id
(not= (:current-chat-id db) (str community-id id))) (not= (:current-chat-id db) (str community-id id)))
(navigate-to-chat cofx (str community-id id) nil)))) (navigate-to-chat cofx (str community-id id) nil))))
(rf/defn fetch-messages
{:events [:chat/fetch-messages]}
[_ chat-id]
{:json-rpc/call [{:method "wakuext_fetchMessages"
:params [{:id chat-id}]
:on-success #()
:on-error #(log/error "failed to fetch messages for chat" chat-id %)}]})

View File

@ -4,6 +4,8 @@
[status-im.common.mute-drawer.view :as mute-drawer] [status-im.common.mute-drawer.view :as mute-drawer]
[status-im.common.muting.helpers :refer [format-mute-till]] [status-im.common.muting.helpers :refer [format-mute-till]]
[status-im.common.not-implemented :as not-implemented] [status-im.common.not-implemented :as not-implemented]
[status-im.config :as config]
[status-im.contexts.chat.actions.view :as chat-actions]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -83,13 +85,6 @@
:on-press not-implemented/alert :on-press not-implemented/alert
:label (i18n/label :t/pinned-messages)}) :label (i18n/label :t/pinned-messages)})
(defn- action-fetch-messages
[]
{:icon :i/download
:right-icon :i/chevron-right
:accessibility-label :chat-fetch-messages
:on-press not-implemented/alert
:label (i18n/label :t/fetch-messages)})
(defn- action-invite-people (defn- action-invite-people
[] []
@ -141,7 +136,8 @@
(action-mark-as-read) (action-mark-as-read)
(action-toggle-muted chat-id muted muted-till chat-type) (action-toggle-muted chat-id muted muted-till chat-type)
(action-notification-settings) (action-notification-settings)
(action-fetch-messages) (when config/fetch-messages-enabled?
(chat-actions/fetch-messages chat-id))
(action-invite-people) (action-invite-people)
(action-qr-code) (action-qr-code)
(action-share)]]] (action-share)]]]

View File

@ -1,12 +1,18 @@
(ns status-im.contexts.profile.rpc (ns status-im.contexts.profile.rpc
(:require (:require
clojure.set
[clojure.string :as string] [clojure.string :as string]
[utils.ens.core :as utils.ens])) [utils.ens.core :as utils.ens]))
(defn rpc->wakuv2-config
[wakuv2-config]
(clojure.set/rename-keys wakuv2-config {:LightClient :light-client}))
(defn rpc->profiles-overview (defn rpc->profiles-overview
[{:keys [customizationColor keycard-pairing] :as profile}] [{:keys [customizationColor keycard-pairing] :as profile}]
(if (map? profile) (if (map? profile)
(-> profile (-> profile
(update :wakuv2-config rpc->wakuv2-config)
(dissoc :customizationColor) (dissoc :customizationColor)
(assoc :customization-color (keyword customizationColor)) (assoc :customization-color (keyword customizationColor))
(assoc :ens-name? (utils.ens/is-valid-eth-name? (:name profile))) (assoc :ens-name? (utils.ens/is-valid-eth-name? (:name profile)))

View File

@ -77,6 +77,25 @@
(fn [{:keys [public-key]}] (fn [{:keys [public-key]}]
public-key)) public-key))
(re-frame/reg-sub
:profile/webview-debug
:<- [:profile/profile]
(fn [{:keys [webview-debug]}]
webview-debug))
(re-frame/reg-sub
:profile/light-client-enabled?
:<- [:profile/profile]
(fn [profile]
(get-in profile [:wakuv2-config :LightClient])))
(re-frame/reg-sub
:profile/test-networks-enabled?
:<- [:profile/profile]
(fn [profile]
(:test-networks-enabled? profile)))
(re-frame/reg-sub (re-frame/reg-sub
:multiaccount/contact :multiaccount/contact
:<- [:profile/profile] :<- [:profile/profile]
@ -126,12 +145,6 @@
(fn [multiaccount] (fn [multiaccount]
(get multiaccount :log-level))) (get multiaccount :log-level)))
(re-frame/reg-sub
:waku/bloom-filter-mode
:<- [:profile/profile]
(fn [multiaccount]
(boolean (get multiaccount :waku-bloom-filter-mode))))
(re-frame/reg-sub (re-frame/reg-sub
:waku/v2-flag :waku/v2-flag
:<- [:fleets/current-fleet] :<- [:fleets/current-fleet]

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>", "_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "v0.171.34", "version": "v0.171.37",
"commit-sha1": "90c31afe7ca16f36b4c4ffa4604bf0c7e70c35e1", "commit-sha1": "1adcf02f867effe39199e383d80681f47db9cef8",
"src-sha256": "1f7bdqqzwksj9yn7r28jh8kgab220hvkl5pdv27didgyd6fw0z0j" "src-sha256": "1mhz0rgd3r6jvgy78ljwq2vjha5rnp5dqhh3ggbp8hpww7nqv4v3"
} }

View File

@ -2383,6 +2383,7 @@
"edit-derivation-path": "Edit derivation path", "edit-derivation-path": "Edit derivation path",
"path-format": "Path format", "path-format": "Path format",
"reset": "Reset", "reset": "Reset",
"light-client-enabled": "Light client",
"reveal-address": "Reveal address", "reveal-address": "Reveal address",
"derive-addresses": "Derive addresses", "derive-addresses": "Derive addresses",
"sign transactions": "sign transactions", "sign transactions": "sign transactions",