Skip to content

Commit fcabffc

Browse files
authored
Merge branch 'develop' into share-community-qr-17993
2 parents 4877785 + 28f43ac commit fcabffc

File tree

18 files changed

+345
-139
lines changed

18 files changed

+345
-139
lines changed

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

+10
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,14 @@ public void deleteMultiaccount(final String keyUID, final Callback callback) thr
342342
final String keyStoreDir = this.utils.getKeyStorePath(keyUID);
343343
this.utils.executeRunnableStatusGoMethod(() -> Statusgo.deleteMultiaccount(keyUID, keyStoreDir), callback);
344344
}
345+
346+
@ReactMethod
347+
public void getRandomMnemonic(final Callback callback) throws JSONException {
348+
this.utils.executeRunnableStatusGoMethod(() -> Statusgo.getRandomMnemonic(), callback);
349+
}
350+
351+
@ReactMethod
352+
public void createAccountFromMnemonicAndDeriveAccountsForPaths(final String mnemonic, final Callback callback) throws JSONException {
353+
this.utils.executeRunnableStatusGoMethod(() -> Statusgo.createAccountFromMnemonicAndDeriveAccountsForPaths(mnemonic), callback);
354+
}
345355
}

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

+16
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,20 @@ -(NSString *) prepareDirAndUpdateConfig:(NSString *)config
214214
NSLog(@"%@", result);
215215
}
216216

217+
RCT_EXPORT_METHOD(getRandomMnemonic:(RCTResponseSenderBlock)callback) {
218+
#if DEBUG
219+
NSLog(@"GetRandomMnemonic() method called");
220+
#endif
221+
NSString *result = StatusgoGetRandomMnemonic();
222+
callback(@[result]);
223+
}
224+
225+
RCT_EXPORT_METHOD(createAccountFromMnemonicAndDeriveAccountsForPaths:(NSString *)mnemonic callback:(RCTResponseSenderBlock)callback) {
226+
#if DEBUG
227+
NSLog(@"createAccountFromMnemonicAndDeriveAccountsForPaths() method called");
228+
#endif
229+
NSString *result = StatusgoCreateAccountFromMnemonicAndDeriveAccountsForPaths(mnemonic);
230+
callback(@[result]);
231+
}
232+
217233
@end

src/native_module/core.cljs

+10
Original file line numberDiff line numberDiff line change
@@ -573,3 +573,13 @@
573573
(defn init-status-go-logging
574574
[{:keys [enable? mobile-system? log-level callback]}]
575575
(.initLogging ^js (log-manager) enable? mobile-system? log-level callback))
576+
577+
(defn get-random-mnemonic
578+
[callback]
579+
(.getRandomMnemonic ^js (account-manager) #(callback (types/json->clj %))))
580+
581+
(defn create-account-from-mnemonic
582+
[mnemonic callback]
583+
(.createAccountFromMnemonicAndDeriveAccountsForPaths ^js (account-manager)
584+
(types/clj->json mnemonic)
585+
#(callback (types/json->clj %))))

src/quo/components/drawers/bottom_actions/view.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
:style {:color (colors/theme-colors colors/danger-50 colors/danger-60 theme)}}
5454
error-message]])
5555

56-
(when (= description :top)
56+
(when (and (= description :top) role)
5757
[rn/view
5858
{:style style/description-top}
5959
[text/text

src/status_im/contexts/communities/actions/addresses_for_permissions/view.cljs

+6-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
(rf/dispatch [:communities/get-permissioned-balances id])
6262
(fn []
6363
(let [{:keys [name color images]} (rf/sub [:communities/community id])
64-
{:keys [highest-permission-role]} (rf/sub [:community/token-gated-overview id])
64+
{:keys [checking?
65+
highest-permission-role]} (rf/sub [:community/token-gated-overview id])
6566
accounts (rf/sub [:wallet/accounts-without-watched-accounts])
6667
selected-addresses (rf/sub [:communities/selected-permission-addresses id])
6768
share-all-addresses? (rf/sub [:communities/share-all-addresses? id])
@@ -105,7 +106,8 @@
105106
{:actions :two-actions
106107
:button-one-label (i18n/label :t/confirm-changes)
107108
:button-one-props {:customization-color color
108-
:disabled? (or (empty? selected-addresses)
109+
:disabled? (or checking?
110+
(empty? selected-addresses)
109111
(not highest-permission-role)
110112
(not unsaved-address-changes?))
111113
:on-press (fn []
@@ -123,9 +125,10 @@
123125
(not highest-permission-role))
124126
:top-error
125127
:top)
126-
:role (role-keyword highest-permission-role)
128+
:role (when-not checking? (role-keyword highest-permission-role))
127129
:error-message (cond
128130
(empty? selected-addresses) (i18n/label :t/no-addresses-selected)
129131
(not highest-permission-role) (i18n/label
130132
:t/addresses-dont-contain-tokens-needed)
131133
:else nil)}]]))))
134+

src/status_im/contexts/wallet/create_account/new_keypair/backup_recovery_phrase/view.cljs

+35-17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
(ns status-im.contexts.wallet.create-account.new-keypair.backup-recovery-phrase.view
22
(:require
3+
[clojure.string :as string]
4+
[native-module.core :as native-module]
35
[quo.core :as quo]
46
[quo.theme :as quo.theme]
57
[react-native.blur :as blur]
68
[react-native.core :as rn]
79
[reagent.core :as reagent]
8-
[status-im.contexts.wallet.common.temp :as temp]
910
[status-im.contexts.wallet.create-account.new-keypair.backup-recovery-phrase.style :as style]
1011
[utils.i18n :as i18n]
1112
[utils.re-frame :as rf]))
@@ -17,7 +18,7 @@
1718
[quo/text {:style {:margin-left 4}} item]])
1819

1920
(defn- words-column
20-
[words first-half?]
21+
[{:keys [words first-half?]}]
2122
[rn/flat-list
2223
{:style {:padding-vertical 8}
2324
:data (if first-half? (subvec words 0 6) (subvec words 6))
@@ -34,18 +35,24 @@
3435
:on-change #(swap! checked? assoc (keyword (str index)) %)}]
3536
[quo/text {:style {:margin-left 12}} (i18n/label item)]])
3637

37-
(defn- view-internal
38+
(defn- f-view
3839
[{:keys [theme]}]
39-
(let [step-labels [:t/backup-step-1 :t/backup-step-2 :t/backup-step-3
40-
:t/backup-step-4]
41-
checked? (reagent/atom
42-
{:0 false
43-
:1 false
44-
:2 false
45-
:3 false})
46-
revealed? (reagent/atom false)
47-
{:keys [customization-color]} (rf/sub [:profile/profile])]
40+
(let [step-labels [:t/backup-step-1 :t/backup-step-2 :t/backup-step-3
41+
:t/backup-step-4]
42+
checked? (reagent/atom
43+
{:0 false
44+
:1 false
45+
:2 false
46+
:3 false})
47+
revealed? (reagent/atom false)
48+
customization-color (rf/sub [:profile/customization-color])
49+
secret-phrase (reagent/atom [])
50+
random-phrase (reagent/atom [])]
4851
(fn []
52+
(rn/use-effect
53+
(fn []
54+
(native-module/get-random-mnemonic #(reset! secret-phrase (string/split % #"\s")))
55+
(native-module/get-random-mnemonic #(reset! random-phrase (string/split % #"\s")))))
4956
[rn/view {:style {:flex 1}}
5057
[quo/page-nav
5158
{:icon-name :i/close
@@ -56,9 +63,15 @@
5663
:description :text
5764
:description-text (i18n/label :t/backup-recovery-phrase-description)}]
5865
[rn/view {:style (style/seed-phrase-container theme)}
59-
[words-column temp/secret-phrase true]
60-
[rn/view {:style (style/separator theme)}]
61-
[words-column temp/secret-phrase false]
66+
(when (pos? (count @secret-phrase))
67+
[:<>
68+
[words-column
69+
{:words @secret-phrase
70+
:first-half? true}]
71+
[rn/view {:style (style/separator theme)}]
72+
[words-column
73+
{:words @secret-phrase
74+
:first-half? false}]])
6275
(when-not @revealed?
6376
[rn/view {:style style/blur-container}
6477
[blur/view (style/blur theme)]])]
@@ -82,8 +95,9 @@
8295
:button-one-label (i18n/label :t/i-have-written)
8396
:button-one-props {:disabled? (some false? (vals @checked?))
8497
:customization-color customization-color
85-
:on-press #(rf/dispatch [:navigate-to
86-
:wallet-check-your-backup])}}]
98+
:on-press #(rf/dispatch [:wallet/store-secret-phrase
99+
{:secret-phrase @secret-phrase
100+
:random-phrase @random-phrase}])}}]
87101
[quo/text
88102
{:size :paragraph-2
89103
:style (style/description-text theme)}
@@ -96,4 +110,8 @@
96110
:on-press #(reset! revealed? true)}
97111
:container-style style/slide-button}])])))
98112

113+
(defn view-internal
114+
[params]
115+
[:f> f-view params])
116+
99117
(def view (quo.theme/with-theme view-internal))

src/status_im/contexts/wallet/create_account/new_keypair/check_your_backup/view.cljs

+29-24
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[quo.theme :as quo.theme]
55
[react-native.core :as rn]
66
[reagent.core :as reagent]
7-
[status-im.contexts.wallet.common.temp :as temp]
87
[status-im.contexts.wallet.create-account.new-keypair.check-your-backup.style :as style]
98
[utils.i18n :as i18n]
109
[utils.re-frame :as rf]))
@@ -31,7 +30,7 @@
3130

3231
(defn- cheat-warning
3332
[]
34-
(let [{:keys [customization-color]} (rf/sub [:profile/profile])]
33+
(let [customization-color (rf/sub [:profile/customization-color])]
3534
[:<>
3635
[quo/drawer-top {:title (i18n/label :t/do-not-cheat)}]
3736
[quo/text
@@ -62,26 +61,32 @@
6261

6362
(defn- view-internal
6463
[]
65-
(let [random-indices (random-selection)
66-
quiz-index (reagent/atom 0)
67-
incorrect-count (reagent/atom 0)
68-
show-error? (reagent/atom false)]
64+
(let [random-indices (random-selection)
65+
quiz-index (reagent/atom 0)
66+
incorrect-count (reagent/atom 0)
67+
show-error? (reagent/atom false)
68+
{:keys [secret-phrase random-phrase]} (rf/sub [:wallet/create-account])]
6969
(fn []
70-
(let [current-word-index (get random-indices (min @quiz-index (dec questions-count)))
71-
current-word (get temp/secret-phrase current-word-index)
72-
[options-r-0 options-r-1] (random-words-with-string temp/random-words current-word)
73-
on-button-press (fn [word]
74-
(if (= word current-word)
75-
(do
76-
(reset! quiz-index (inc @quiz-index))
77-
(reset! incorrect-count 0)
78-
(reset! show-error? false))
79-
(do
80-
(when (> @incorrect-count 0)
81-
(rf/dispatch [:show-bottom-sheet
82-
{:content cheat-warning}]))
83-
(reset! incorrect-count (inc @incorrect-count))
84-
(reset! show-error? true))))]
70+
(let [current-word-index (get random-indices
71+
(min @quiz-index (dec questions-count)))
72+
current-word (get secret-phrase current-word-index)
73+
[options-row-0 options-row-1] (random-words-with-string random-phrase current-word)
74+
on-button-press (fn [word]
75+
(if (= word current-word)
76+
(do
77+
(when (< @quiz-index questions-count)
78+
(reset! quiz-index (inc @quiz-index)))
79+
(reset! incorrect-count 0)
80+
(reset! show-error? false)
81+
(when (= @quiz-index questions-count)
82+
(rf/dispatch [:navigate-to
83+
:wallet-keypair-name])))
84+
(do
85+
(when (> @incorrect-count 0)
86+
(rf/dispatch [:show-bottom-sheet
87+
{:content cheat-warning}]))
88+
(reset! incorrect-count (inc @incorrect-count))
89+
(reset! show-error? true))))]
8590
[rn/view {:style {:flex 1}}
8691
[quo/page-nav
8792
{:icon-name :i/arrow-left
@@ -109,7 +114,7 @@
109114

110115
:else
111116
:disabled)
112-
:word (get temp/secret-phrase num)
117+
:word (get secret-phrase num)
113118
:number (inc num)
114119
:on-press #(when (= @quiz-index index)
115120
(reset! show-error? false))}])
@@ -119,9 +124,9 @@
119124
[buttons-row
120125
{:on-press on-button-press
121126
:margin-bottom 12
122-
:options options-r-0}]
127+
:options options-row-0}]
123128
[buttons-row
124129
{:on-press on-button-press
125-
:options options-r-1}]]]))))
130+
:options options-row-1}]]]))))
126131

127132
(def view (quo.theme/with-theme view-internal))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(ns status-im.contexts.wallet.create-account.new-keypair.keypair-name.style)
2+
3+
(def header-container
4+
{:margin-horizontal 20
5+
:margin-vertical 12})
6+
7+
(def bottom-action
8+
{:position :absolute
9+
:bottom 12
10+
:left 0
11+
:right 0})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
(ns status-im.contexts.wallet.create-account.new-keypair.keypair-name.view
2+
(:require
3+
[quo.core :as quo]
4+
[react-native.core :as rn]
5+
[reagent.core :as reagent]
6+
[status-im.contexts.wallet.create-account.new-keypair.keypair-name.style :as style]
7+
[utils.i18n :as i18n]
8+
[utils.re-frame :as rf]))
9+
10+
(def keypair-name-max-length 15)
11+
12+
(defn view
13+
[]
14+
(let [keypair-name (reagent/atom "")]
15+
(fn []
16+
(let [customization-color (rf/sub [:profile/customization-color])]
17+
[rn/view {:style {:flex 1}}
18+
[quo/page-nav
19+
{:icon-name :i/arrow-left
20+
:on-press #(rf/dispatch [:navigate-back])
21+
:accessibility-label :top-bar}]
22+
[quo/text-combinations
23+
{:container-style style/header-container
24+
:title (i18n/label :t/keypair-name)
25+
:description (i18n/label :t/keypair-name-description)}]
26+
[quo/input
27+
{:container-style {:margin-horizontal 20}
28+
:placeholder (i18n/label :t/keypair-name-input-placeholder)
29+
:label (i18n/label :t/keypair-name)
30+
:char-limit keypair-name-max-length
31+
:on-change-text #(reset! keypair-name %)}]
32+
[quo/bottom-actions
33+
{:actions :one-action
34+
:button-one-label (i18n/label :t/continue)
35+
:button-one-props {:disabled? (or (zero? (count @keypair-name))
36+
(> (count @keypair-name) keypair-name-max-length))
37+
:customization-color customization-color
38+
:on-press #(rf/dispatch [:wallet/new-keypair-continue
39+
{:keypair-name @keypair-name}])}
40+
:container-style style/bottom-action}]]))))

0 commit comments

Comments
 (0)