Skip to content

Commit fc18880

Browse files
committed
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 status-im/status-go@90c31af...1adcf02
1 parent 285c7c4 commit fc18880

File tree

30 files changed

+206
-415
lines changed

30 files changed

+206
-415
lines changed

.clj-kondo/babashka/fs/config.edn

Lines changed: 0 additions & 1 deletion
This file was deleted.

.clj-kondo/babashka/sci/config.edn

Lines changed: 0 additions & 1 deletion
This file was deleted.

.clj-kondo/babashka/sci/sci/core.clj

Lines changed: 0 additions & 9 deletions
This file was deleted.

.clj-kondo/config.edn

Lines changed: 0 additions & 67 deletions
This file was deleted.

.clj-kondo/status-im/config.edn

Lines changed: 0 additions & 2 deletions
This file was deleted.

.clj-kondo/status-im/utils/i18n.clj

Lines changed: 0 additions & 26 deletions
This file was deleted.

modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,11 @@ public String keystoreDir() {
11831183
return pathCombine(absRootDirPath, "keystore");
11841184
}
11851185

1186+
@ReactMethod(isBlockingSynchronousMethod = true)
1187+
public String fleets() {
1188+
return Statusgo.fleets();
1189+
}
1190+
11861191
@ReactMethod(isBlockingSynchronousMethod = true)
11871192
public String backupDisabledDataDir() {
11881193
return this.getNoBackupDirectory();

modules/react-native-status/ios/RCTStatus/RCTStatus.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,10 @@ - (void) migrateKeystore:(NSString *)accountData
981981
return StatusgoIsAddress(address);
982982
}
983983

984+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(fleets) {
985+
return StatusgoFleets();
986+
}
987+
984988
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(toChecksumAddress:(NSString *)address) {
985989
return StatusgoToChecksumAddress(address);
986990
}

modules/react-native-status/nodejs/status.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ void _MultiAccountStoreAccount(const FunctionCallbackInfo<Value>& args) {
298298
delete c;
299299
}
300300

301+
301302
void _InitKeystore(const FunctionCallbackInfo<Value>& args) {
302303
Isolate* isolate = args.GetIsolate();
303304
Local<Context> context = isolate->GetCurrentContext();
@@ -562,6 +563,17 @@ void _CheckAddressChecksum(const FunctionCallbackInfo<Value>& args) {
562563

563564
}
564565

566+
void _Fleets(const FunctionCallbackInfo<Value>& args) {
567+
Isolate* isolate = args.GetIsolate();
568+
// Call exported Go function, which returns a C string
569+
char *c = Fleets();
570+
571+
Local<String> ret = String::NewFromUtf8(isolate, c).ToLocalChecked();
572+
args.GetReturnValue().Set(ret);
573+
delete c;
574+
}
575+
576+
565577
void _IsAddress(const FunctionCallbackInfo<Value>& args) {
566578
Isolate* isolate = args.GetIsolate();
567579
Local<Context> context = isolate->GetCurrentContext();
@@ -1888,6 +1900,7 @@ void init(Local<Object> exports) {
18881900
NODE_SET_METHOD(exports, "multiAccountStoreDerivedAccounts", _MultiAccountStoreDerivedAccounts);
18891901
NODE_SET_METHOD(exports, "multiAccountStoreAccount", _MultiAccountStoreAccount);
18901902
NODE_SET_METHOD(exports, "initKeystore", _InitKeystore);
1903+
NODE_SET_METHOD(exports, "fleets", _Fleets);
18911904
NODE_SET_METHOD(exports, "stopCPUProfiling", _StopCPUProfiling);
18921905
NODE_SET_METHOD(exports, "encodeTransfer", _EncodeTransfer);
18931906
NODE_SET_METHOD(exports, "encodeFunctionCall", _EncodeFunctionCall);

src/native_module/core.cljs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,6 @@
4040
config
4141
#(callback (types/json->clj %))))
4242

43-
(defn save-account-and-login
44-
"NOTE: beware, the password has to be sha3 hashed"
45-
[key-uid multiaccount-data hashed-password settings config accounts-data]
46-
(log/debug "[native-module] save-account-and-login"
47-
"multiaccount-data"
48-
multiaccount-data)
49-
(clear-web-data)
50-
(init-keystore
51-
key-uid
52-
#(.saveAccountAndLogin
53-
^js (status)
54-
multiaccount-data
55-
hashed-password
56-
settings
57-
config
58-
accounts-data)))
59-
6043
(defn save-multiaccount-and-login-with-keycard
6144
"NOTE: chat-key is a whisper private key sent from keycard"
6245
[key-uid multiaccount-data password settings config accounts-data chat-key]
@@ -536,6 +519,10 @@
536519
[]
537520
(.backupDisabledDataDir ^js (status)))
538521

522+
(defn fleets
523+
[]
524+
(.fleets ^js (status)))
525+
539526
(defn keystore-dir
540527
[]
541528
(.keystoreDir ^js (status)))
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(ns status-im.contexts.profile.rpc
2+
(:require
3+
clojure.set
4+
[clojure.string :as string]
5+
[utils.ens.core :as utils.ens]))
6+
7+
(defn rpc->wakuv2-config
8+
[wakuv2-config]
9+
(clojure.set/rename-keys wakuv2-config {:LightClient :light-client}))
10+
11+
(defn rpc->profiles-overview
12+
[{:keys [customizationColor keycard-pairing] :as profile}]
13+
(if (map? profile)
14+
(-> profile
15+
(update :wakuv2-config rpc->wakuv2-config)
16+
(dissoc :customizationColor)
17+
(assoc :customization-color (keyword customizationColor))
18+
(assoc :ens-name? (utils.ens/is-valid-eth-name? (:name profile)))
19+
(assoc :keycard-pairing (when-not (string/blank? keycard-pairing) keycard-pairing)))
20+
profile))

src/status_im/fleet/core.cljs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,23 @@
55
[status-im.node.core :as node]
66
[status-im2.config :as config]
77
[status-im2.constants :as constants]
8+
[native-module.core :as native-module]
89
[utils.i18n :as i18n]
9-
[utils.re-frame :as rf]))
10+
[utils.re-frame :as rf]
11+
[utils.transforms :as transforms]))
12+
13+
(def ^:private default-fleets (transforms/json->clj (native-module/fleets)))
14+
(def ^:private default-fleet (:defaultFleet default-fleets))
15+
(def fleets
16+
(->> default-fleets
17+
:fleets
18+
keys
19+
(map name)))
1020

1121
(defn current-fleet-sub
1222
[multiaccount]
1323
(keyword (or (get multiaccount :fleet)
14-
config/fleet)))
24+
default-fleet)))
1525

1626
(defn format-mailserver
1727
[mailserver address]
@@ -78,10 +88,9 @@
7888
[{:keys [db now] :as cofx} fleet]
7989
(let [old-fleet (get-in db [:profile/profile :fleet])]
8090
(when (not= fleet old-fleet)
81-
(rf/merge
91+
(multiaccounts.update/multiaccount-update
8292
cofx
83-
(multiaccounts.update/multiaccount-update :fleet fleet {})
84-
(node/prepare-new-config
85-
{:on-success
86-
#(re-frame/dispatch
87-
[:multiaccounts.update.callback/save-settings-success])})))))
93+
:fleet
94+
fleet
95+
{:on-success
96+
#(re-frame/dispatch [:logout])}))))

src/status_im/keycard/card.cljs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,7 @@
523523
(error-object->map response)]))}))
524524

525525
(defn save-multiaccount-and-login
526-
[args]
527-
(keycard/save-multiaccount-and-login card args))
526+
[_])
528527

529528
(defn login
530529
[args]

src/status_im/keycard/recovery.cljs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
[taoensso.timbre :as log]
1818
[utils.address :as address]
1919
[utils.datetime :as datetime]
20-
[utils.ethereum.eip.eip55 :as eip55]
2120
[utils.i18n :as i18n]
2221
[utils.re-frame :as rf]
2322
[utils.security.core :as security]))
@@ -152,6 +151,7 @@
152151
:keycard/check-nfc-enabled nil}
153152
(intro-wizard)))
154153

154+
;; NOTE: currently non functional, keycard needs to be reimplemented
155155
(rf/defn create-keycard-multiaccount
156156
{:events [::create-keycard-multiaccount]
157157
:interceptors [(re-frame/inject-cofx :random-guid-generator)
@@ -182,27 +182,7 @@
182182
(rf/merge cofx
183183
{:db (-> db
184184
(assoc-in [:keycard :setup-step] nil)
185-
(dissoc :intro-wizard))}
186-
(multiaccounts.create/on-multiaccount-created
187-
{:recovered (or recovered (get-in db [:intro-wizard :recovering?]))
188-
:derived {constants/path-wallet-root-keyword
189-
{:public-key wallet-root-public-key
190-
:address (eip55/address->checksum wallet-root-address)}
191-
constants/path-whisper-keyword
192-
{:public-key whisper-public-key
193-
:address (eip55/address->checksum whisper-address)}
194-
constants/path-default-wallet-keyword
195-
{:public-key wallet-public-key
196-
:address (eip55/address->checksum wallet-address)}}
197-
:address address
198-
:public-key public-key
199-
:keycard-instance-uid instance-uid
200-
:key-uid (address/normalized-hex key-uid)
201-
:keycard-pairing pairing
202-
:keycard-paired-on paired-on
203-
:chat-key whisper-private-key}
204-
encryption-public-key
205-
{}))))
185+
(dissoc :intro-wizard))})))
206186

207187
(rf/defn return-to-keycard-login
208188
[{:keys [db] :as cofx}]

src/status_im/keycard/simulated_keycard.cljs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,7 @@
489489
(log/warn "sign-typed-data not implemented" args))
490490

491491
(defn save-multiaccount-and-login
492-
[{:keys [key-uid multiaccount-data password settings node-config accounts-data]}]
493-
(native-module/save-account-and-login
494-
key-uid
495-
(types/clj->json multiaccount-data)
496-
password
497-
(types/clj->json settings)
498-
node-config
499-
(types/clj->json accounts-data)))
492+
[_])
500493

501494
(defn login
502495
[{:keys [key-uid multiaccount-data password]}]

src/status_im/log_level/core.cljs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
[{:keys [db now] :as cofx} log-level]
1212
(let [old-log-level (get-in db [:profile/profile :log-level])]
1313
(when (not= old-log-level log-level)
14-
(rf/merge cofx
15-
(multiaccounts.update/multiaccount-update
16-
:log-level
17-
log-level
18-
{})
19-
(node/prepare-new-config
20-
{:on-success #(re-frame/dispatch [:logout])})))))
14+
(multiaccounts.update/multiaccount-update
15+
cofx
16+
:log-level
17+
log-level
18+
{:on-success #(re-frame/dispatch [:logout])}))))
2119

2220
(rf/defn show-change-log-level-confirmation
2321
{:events [:log-level.ui/log-level-selected]}

0 commit comments

Comments
 (0)