Skip to content

Commit

Permalink
recovery flow v1
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryn committed Aug 14, 2019
1 parent ba112a7 commit b06a90c
Show file tree
Hide file tree
Showing 31 changed files with 796 additions and 218 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ETHEREUM_DEV_CLUSTER=1
EXTENSIONS=0
FLEET=eth.beta
GROUP_CHATS_ENABLED=1
HARDWALLET_ENABLED=0
HARDWALLET_ENABLED=1
LOG_LEVEL_STATUS_GO=info
LOG_LEVEL=debug
MAILSERVER_CONFIRMATIONS_ENABLED=1
Expand Down
2 changes: 1 addition & 1 deletion .env.jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ETHEREUM_DEV_CLUSTER=1
EXTENSIONS=0
FLEET=eth.beta
GROUP_CHATS_ENABLED=1
HARDWALLET_ENABLED=0
HARDWALLET_ENABLED=1
LOG_LEVEL_STATUS_GO=info
LOG_LEVEL=debug
MAILSERVER_CONFIRMATIONS_ENABLED=1
Expand Down
3 changes: 2 additions & 1 deletion externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,5 +568,6 @@ var TopLevel = {
"multiAccountDeriveAddresses" : function () {},
"multiAccountReset" : function () {},
"multiAccountLoadAccount" : function () {},
"multiAccountStoreAccount" : function () {}
"multiAccountStoreAccount" : function () {},
"multiAccountImportMnemonic" : function () {},
}
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,25 @@ public void run() {
StatusThreadPoolExecutor.getInstance().execute(r);
}

@ReactMethod
public void multiAccountImportMnemonic(final String json, final Callback callback) {
Log.d(TAG, "multiAccountImportMnemonic");
if (!checkAvailability()) {
callback.invoke(false);
return;
}
Runnable r = new Runnable() {
@Override
public void run() {
String res = Statusgo.multiAccountImportMnemonic(json);

callback.invoke(res);
}
};

StatusThreadPoolExecutor.getInstance().execute(r);
}

private String createIdentifier() {
return UUID.randomUUID().toString();
}
Expand Down
12 changes: 11 additions & 1 deletion modules/react-native-status/ios/RCTStatus/RCTStatus.m
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,17 @@ - (void)handleSignal:(NSString *)signal
callback(@[result]);
}

//////////////////////////////////////////////////////////////////// MultiAccountDeriveAddresses
//////////////////////////////////////////////////////////////////// multiAccountImportMnemonic
RCT_EXPORT_METHOD(multiAccountImportMnemonic:(NSString *)json
callback:(RCTResponseSenderBlock)callback) {
#if DEBUG
NSLog(@"MultiAccountImportMnemonic() method called");
#endif
NSString *result = StatusgoMultiAccountImportMnemonic(json);
callback(@[result]);
}

//////////////////////////////////////////////////////////////////// multiAccountDeriveAddresses
RCT_EXPORT_METHOD(multiAccountDeriveAddresses:(NSString *)json
callback:(RCTResponseSenderBlock)callback) {
#if DEBUG
Expand Down
Binary file added resources/images/ui/keycard-logo-blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/ui/keycard-logo-gray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 14 additions & 6 deletions src/status_im/ethereum/mnemonic.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,25 @@
(defn valid-word-counts? [v]
(boolean (valid-word-counts (count v))))

(defn words-count [s]
(if (empty? s)
nil
(-> s
passphrase->words
count)))

(defn- valid-word? [s]
(re-matches #"^[A-z]+$" s))

(defn valid-words? [v]
(and (valid-word-counts? v)
(every? valid-word? v)))

(defn valid-phrase? [s]
(defn valid-length? [s]
(-> s
passphrase->words
valid-words?))
valid-word-counts?))

(defn valid-words? [s]
(->> s
passphrase->words
(every? valid-word?)))

(defn status-generated-phrase? [s]
(every? dictionary (passphrase->words s)))
7 changes: 0 additions & 7 deletions src/status_im/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,6 @@
(fn [cofx _]
(multiaccounts.recover/recover-multiaccount cofx)))

(handlers/register-handler-fx
:multiaccounts.recover.callback/recover-multiaccount-success
[(re-frame/inject-cofx :random-guid-generator)
(re-frame/inject-cofx :multiaccounts.create/get-signing-phrase)]
(fn [cofx [_ result password]]
(multiaccounts.recover/on-multiaccount-recovered cofx result password)))

;; multiaccounts login module

(handlers/register-handler-fx
Expand Down
18 changes: 3 additions & 15 deletions src/status_im/hardwallet/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -404,18 +404,19 @@
(navigation/navigate-to-cofx :keycard-recovery-enter-mnemonic nil)))

(fx/defn start-import-flow
{:events [:recovery.ui/recover-with-keycard-pressed
{:events [:recover.ui/recover-with-keycard-pressed
:keycard.login.ui/recover-key-pressed]}
[{:keys [db] :as cofx}]
(fx/merge cofx
{:db (assoc-in db [:hardwallet :flow] :import)
:dispatch [:bottom-sheet/hide-sheet]
:hardwallet/check-nfc-enabled nil}
(navigation/navigate-to-cofx :keycard-recovery-intro nil)))

(fx/defn access-key-pressed
{:events [:multiaccounts.recover.ui/recover-multiaccount-button-pressed]}
[cofx]
(multiaccounts.recover/navigate-to-recover-multiaccount-screen cofx))
{:dispatch [:bottom-sheet/show-sheet :recover-sheet]})

(fx/defn recovery-keycard-selected
{:events [:recovery.ui/keycard-option-pressed]}
Expand All @@ -425,19 +426,6 @@
:hardwallet/check-nfc-enabled nil}
(navigation/navigate-to-cofx :keycard-onboarding-intro nil)))

;NOTE to be removed when Recovery flow will be implemented
(fx/defn enter-mnemonic-next-button-pressed
{:events [:keycard.recovery.enter-mnemonic.ui/input-submitted
:keycard.recovery.enter-mnemonic.ui/next-pressed]}
[cofx]
(recovery-keycard-selected cofx))

;NOTE to be removed when Recovery flow will be implemented
(fx/defn enter-mnemonic-input-changed
{:events [:keycard.recovery.enter-mnemonic.ui/input-changed]}
[{:keys [db]} input]
{:db (assoc-in db [:hardwallet :secrets :mnemonic] input)})

(fx/defn password-option-pressed
[{:keys [db] :as cofx}]
(if (= (get-in db [:hardwallet :flow]) :create)
Expand Down
4 changes: 4 additions & 0 deletions src/status_im/init/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@
(= (get-in cofx [:db :view-id])
:create-multiaccount))

(defn recovering-multiaccount? [cofx]
(boolean (get-in cofx [:db :multiaccounts/recover])))

(defn- keycard-setup? [cofx]
(boolean (get-in cofx [:db :hardwallet :flow])))

Expand All @@ -242,6 +245,7 @@
(stickers/init-stickers-packs)
(multiaccounts.update/update-sign-in-time)
#(when-not (or (creating-multiaccount? %)
(recovering-multiaccount? %)
(keycard-setup? %))
(login-only-events % address stored-pns)))))

Expand Down
22 changes: 17 additions & 5 deletions src/status_im/multiaccounts/login/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,23 @@

(fx/defn verify-multiaccount
[{:keys [db] :as cofx} {:keys [realm-error]}]
(fx/merge cofx
{:db (-> db
(assoc :node/on-ready :verify-multiaccount)
(assoc :realm-error realm-error))}
(node/initialize nil)))
(if (get-in db [:multiaccounts/recover])
(fx/merge cofx
{:db (-> db
(update :multiaccounts/recover assoc
:processing? false
:password ""
:password-confirmation ""
:password-error :recover-password-invalid)
(update :multiaccounts/recover dissoc
:password-valid?))
:node/stop nil}
(navigation/navigate-to-cofx :recover-multiaccount-enter-password nil))
(fx/merge cofx
{:db (-> db
(assoc :node/on-ready :verify-multiaccount)
(assoc :realm-error realm-error))}
(node/initialize nil))))

(fx/defn unknown-realm-error
[cofx {:keys [realm-error erase-button]}]
Expand Down
Loading

0 comments on commit b06a90c

Please sign in to comment.